question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Ankur A3 commented

How to use variable column name in SQL query?

Hi Team,

I am trying to pass the variable column name in SQL query, but it is not working as expected. This is first time when I am using variable column name instead of column values. Here, I am assigning Week as variable value to column and using SUM formula over it.

1718808317133.png


Is this syntax correct?

Could you help me to resolve it?


Thank you!


FlexSim 23.1.1
sql queryvariablecolumnsum
1718808317133.png (98.0 KiB)
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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Ankur A3 commented

I do not know, but

string Week = "Wk_1";
string qstr = "SELECT SUM("+Week+") FROM GlobalTable1"; Table result = Table.query(qstr);

this works.

· 1
5 |100000

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

Ankur A3 avatar image Ankur A3 commented ·
Thanks! @Joerg Vogel

It is working.

0 Likes 0 ·