Link to home
Start Free TrialLog in
Avatar of Freerider
FreeriderFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL MAX function

Hi all,

I'm trying to display the highest value from a table,
using the following code:

---
Query2.SQL.Add('SELECT MAX(Price1) AS maxprice');
Query2.SQL.Add(' FROM CustomDTL');
Query2.ExecSQL;
showmessage(FloatToStr(maxprice));
---

This isn't returning the result I expect.
How do I get the value "maxprice" out of the query?

Thanks,
Freerider,
Avatar of marcoszorrilla
marcoszorrilla

ShowMessage(FloatTostr(query2MaxPrice.value));

But you must Doubleclick your Tquery, and Add the Fields in order to make persistant fields.

Best Regards.
Marcos.
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Freerider

ASKER

Thanks kretzschmar,

without the "Query2.Open;" it wouldn't have worked.
But I didn't realise I had to create a new field for "MaxPrice".

Freerider.