SQL Command Not Properly Ended (Nested Aggregation with Group-by)
- by snowind
I keep getting this error when I tried to execute this query, although I couldn't figure out what went wrong. I'm using Oracle and JDBC.
Here's the query:
SELECT Temp.flight_number, Temp.avgprice
FROM (SELECT P.flight_number, AVG (P.amount) AS avgprice
FROM purchase P
GROUP BY P.flight_number) AS Temp
WHERE Temp.avgprice = (SELECT MAX (Temp.avgprice)
FROM Temp)
I'm trying to get the maximum of average price of the tickets that customers have booked, group by flight_number.