I am trying to write a select query where, I need the Title and Max of Cost in a table;
Any help on this would be really appreciated, thanks!
1) Below query is giving me the all the columns
select Title, MAX(sold)
from software
Group by Title, sold;
2) Below query is giving me the right result but here I'm hard coding the highest value in 'Sold' column
select Title, sold
from software
where sold = '84';
You can try to query something like this which would give the details of max value record in table.
select * from software where sold = (select MAX(sold)from software)
Hope this was helpful.
您可以在下面尝试-
select Title, sold from software where sold=(select MAX(sold) from software))
You were close. When you are aggregating a field you generally don't want to group by it as well.
This should work for you:
select Title, MAX(sold)
from software
Group by Title;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.