Page 1 of 1

sql query

Posted: Mon 12 May 2008 09:23
by dj_sherbu
i am trying to extract some data from a table and rank the records found, but the code i am trying to use is not allowed in TMyQuery though it works in standard sql query. here is the piece of code:

Code: Select all

[b]SET @i:=0; [/b]SELECT @i:=@i+1 AS rank , client_code, SUM(invoice_total) AS Total_Value
FROM facturi
GROUP BY cod_client
ORDER BY val_totala DESC;
the error i get is generated by using SET before SELECT; if i paste the same code in any sql editor, it returns the corect data, with ranking and no errors.
how can i get the data i need? is there any way?

Posted: Mon 12 May 2008 14:07
by Dimon
We could not reproduce the problem.
Please send a complete small sample to dmitryg*crlab*com to demonstrate it, including a script to create and fill table.

Also supply us the following information
- exact version of Delphi, C++ Builder or Kylix;
- exact version of MyDAC. You can see it in the About sheet of TMyConnection Editor;
- exact version of MySQL server and MySQL client. You can see it in the Info sheet of TMyConnection Editor.