Why does this work
SELECT DISTINCT FIRSTNAME, LASTNAME
FROM books, CUSTOMERS, orders, orderitems
WHERE STATE IN('FL ', 'GA')
GROUP BY orders.order#, firstname, lastname
HAVING SUM(retail*quantity) > 80
but when firstname, lastname is removed from group by it doesn’t?
ORA-00979: not a GROUP BY expression
In that case where
firstname, lastnameare removed from thegroup by, you get that error because you’reSELECTing a column(s) that aren’t in theGROUP BYexpression, or aren’t part of an aggregation/function (i.e. MIN, MAX, AVG, and others).You could also eliminate the
DISTINCTas well.