How to use variable column name in SQL query?

How to use variable column name in SQL query?

rajankur6494
Collaborator Collaborator
334 Views
2 Replies
Message 1 of 3

How to use variable column name in SQL query?

rajankur6494
Collaborator
Collaborator

[ FlexSim 23.1.1 ]

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!


0 Likes
Accepted solutions (1)
335 Views
2 Replies
Replies (2)
Message 2 of 3

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

I do not know, but

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

this works.

Message 3 of 3

rajankur6494
Collaborator
Collaborator
Thanks! @Joerg Vogel

It is working.

0 Likes