Hi,
How can i select maximum price from a product group?
I using this code "select id,name,max(price) from pruducts group by category" but it isn't working correctly.
Can i use another method for listing max pirices by pruduct category?
Thank You.
Depending on your database, you may not be able to mix aggregate and non-aggregate fields in a single query.
See if just this works:
select max(price) from products group by category;
Chris
In Postgres you have to use "group by" to specify the non-aggregate columns like this
select id, name, max(price) from products group by id, name
or it errors and tells you you can't do that kind of thing.
Tim Frank
Well how can i write a script for listing maximum value by categories! I used --while-- but it's not working...
select category, max(price) from products group by category;