Crosswords0 min ago
SQL Query help
5 Answers
hiya im doing a database and im required to list all customers who have made two reservations or more. we have tried the following, and many other, but still cant figure it out.
SELECT BO_ID, COUNT(C_ID) AS NUMBER_OF_RESERVATIONS
FROM BOOKING
WHERE
C_ID < 2;
SELECT BO_ID, COUNT(C_ID) AS NUMBER_OF_RESERVATIONS, C_NAME
FROM BOOKING, CUSTOMER
WHERE
BOOKING.C_ID = CUSTOMER.C_ID
AND CUSTOMER.C_ID = CUSTOMER.C_NAME
AND
ORDER NUMBER_OF_RESERVATIONS >= 2;
SELECT C_ID AS NUMBER_OF_RESERVATIONS, C_NAME, BO_ID
FROM BOOKING
WHERE C_ID > 2;
could anybody shed some light please?
SELECT BO_ID, COUNT(C_ID) AS NUMBER_OF_RESERVATIONS
FROM BOOKING
WHERE
C_ID < 2;
SELECT BO_ID, COUNT(C_ID) AS NUMBER_OF_RESERVATIONS, C_NAME
FROM BOOKING, CUSTOMER
WHERE
BOOKING.C_ID = CUSTOMER.C_ID
AND CUSTOMER.C_ID = CUSTOMER.C_NAME
AND
ORDER NUMBER_OF_RESERVATIONS >= 2;
SELECT C_ID AS NUMBER_OF_RESERVATIONS, C_NAME, BO_ID
FROM BOOKING
WHERE C_ID > 2;
could anybody shed some light please?
Answers
Best Answer
No best answer has yet been selected by yvetteness. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.As Ludwig has correctly answered, you can't use WHERE to filter results on an aggregated expression, and must use HAVING instead:
http://msdn.microsoft...library/ms173260.aspx
http://msdn.microsoft...library/ms173260.aspx
-- answer removed --