SQL Command Not Properly Ended (Nested Aggregation with Group-by)
Posted
by
snowind
on Stack Overflow
See other posts from Stack Overflow
or by snowind
Published on 2012-04-01T03:38:17Z
Indexed on
2012/04/01
5:28 UTC
Read the original article
Hit count: 101
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.
© Stack Overflow or respective owner