I am creating an instance in which the customer has more than 1 reservation. To do this, each time the customer number is listed more than once in the reservation table, this signifies that they have more than one reservation (which again, is the condition). Unfortunately, when I attempt to run this query I get:
Error Code: 1111 (Invalid use of group function).
Here is what I have done below.
SELECT FirstName, LastName, tripName
FROM reservation, customer, trip
WHERE reservation.CustomerNum = customer.CustomerNum
AND reservation.TripID = trip.TripID
AND COUNT(reservation.CustomerNum) > 1
GROUP BY reservation.CustomerNum;
I am very new to SQL, any advice will be very helpful.
If you are using GROUP BY, all the fields you select must be in an aggregate function or included in the GROUP BY clause.