Expression Tags including SQL Query

I’m trying to get values from a table and make a calculation with them. Is it possible to include all this in an expression tag?

I found out the Expression Function executeQuery and used this script as a test :

executeQuery(“SELECT tool1 FROM table WHERE ndx=500”,“Result”)
getDatasetValueByIndex(“Result”,0,0,-1)

I should get a single int value, but nothing seems to work.

Of course this is a dumb test as I could use a Query Tag to do this, but what I actually want to achieve is to get multiple values before I make my calculation.

By the way the User Manual is not up to date considering Expression Tags since it still talks about DB Tags.

I think you are trying to do this with a single expression tag, right? You want to query multiple values and do a calculation off of them. If so, you can query multiple values using the executeScalarQuery expression function on an expression tag. Something like this:toInt(executeScalarQuery("SELECT tool1 FROM table WHERE ndx = 500", "DatabaseName")) + toInt(executeScalarQuery("SELECT tool1 FROM table WHERE ndx = 501", "DatabaseName"))