I need to find the order ID and the largest order in terms of dollars using SQL. I attached the OM database. Using SQL I think I would need to use group by or order by but I just need to find the largest order.
select order_id, sum(unit_price) from items;
It resulted in an error. I wanted it to show the order id and the sum of the unit_price and get the largest unit price to get the largest order. I’m getting an error message saying query without GROUP BY and nonaggregated column.
2
Answers
Your query would normally only return one row, but as you dind’t add an aggegation function, the error message occours
This would give you only 1 order back,
if there are multiple with same sum you need another approach
Use MySQL to achieve your desired idea.