question

Enrique Elizaga avatar image
0 Likes"
Enrique Elizaga asked christian.n rolled back

Can I create a Table query on a label acting as a table?

Hi, my label called THELIST is a table. I often access it like this:

Table THELIST = MYOBJECT.labels["THELIST"].as(Table);

I want to use this command on it:

Table.query("SELECT SUM(COLUMN) FROM [THELIST] WHERE [ID] == 1421 AND [DAY] == 1").cloneTo(Table("TEMP"));

Is this possible?

FlexSim 18.2.3
queryquery on label tablequery sum
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

christian.n avatar image
2 Likes"
christian.n answered christian.n rolled back

Hi Enrique.

I don't think queries can use locally declared variables.

Try using adding THELIST as a parameter for the query:

Table.query("SELECT SUM(COLUMN) FROM [$1] WHERE [ID] == 1421 AND [DAY] == 1",THELIST).cloneTo(Table("TEMP"));

I substituted THELIST in the query with a '$1' (referring to the 1st parameter of the query), and added THELIST as the parameter.

I added an example model with a source containing a label with table data, and a script with a query.

answersquerylabel.fsm


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.