Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Do anyone know how to use the result of a SQL sentence as the variable's value?
Thanks and best regards,
CoCo
You may compute the data directly during the script also and store the result into table.
You may also create lots of variables (MyVar1, MyVar2, MyVar ...) such a way:
let counter=1;
do while counter < NoOfRows('Meas')
MyVar$(counter)=peek('Measures', counter-1, 'Meas');
counter=counter+1;
loop
Fabrice
Hi Sokkorn,
Please see the above reply.
Hi CoCo,
Here is sample one
//This statement is to fetch Max date from field DateField.
[MaxDateTable]:
LOAD Max(DateField) AS [MaxDateValue];
SQL Select DateField From TableName;
//Here is variable vMaxDate where it get value from table above with format YYYY-MM-DD. Ex. 2014-01-21
Let vMaxDate = Date(Peek('MaxDateValue',0,'MaxDateTable'),'YYYY-MM-DD');
Regards,
Sokkorn
CoCo Xi wrote:
But when I use the same sentence in the "Variable Overiew" window, it occurs the grammar errors.
I don't know why!
Hi
I wouldn't worry about those. QV is trying to interpret the text as a QV expression, and the SQL is not a valid QV expression and QV will pass this to the database server for evaluation.
HTH
Jonathan
Hi CoCo,
For this one, I would suggest you load all data from Account table. Like this
[Age]:
SQL Select [Account ID],[Account Name], [Age] From Account;
Create new variable in "Variable Overview" by click Add:
1. Variable name: vAge2635
2. Definition: Count({$<[Age]={'26-35'}>} [Account ID])
Regards,
Sokkorn
Oh, how to definite the variable using the result of a SQL sentence correctly?
Oh, great , thanks very much!
But is this the simplest method ? As I'll create many variables like vAge2635.
Oh, dear!
It works. Thank you!!!
CoCo