Using SQL, count how many classes each customer has signed up for. Show the customers last name,
Question:
Using SQL, count how many classes each customer has signed up for. Show the customer’s last name, first name, and number of classes. Use an appropriate JOIN.
a. SELECT LastName, FirstName, Count(ReservationID) AS [Number of Classes]
FROM Customers INNER JOIN Reservations ON CustomerID = CustomerID GROUP BY LastName, FirstName;
b. SELECT LastName, FirstName, Count(ReservationID) AS [Number of Classes]
FROM Customers INNER JOIN Reservations ON Customers.CustomerID = Reservations.
CustomerID GROUP BY LastName, FirstName;
c. SELECT LastName, FirstName, Count(ReservationID) AS [Number of Classes]
FROM Customers INNER JOIN Reservations ON Customers.CustomerID = Reservations.
CustomerID;
d. SELECT LastName, FirstName, Count(ReservationID) AS [Number of Classes]
FROM Customers OUTER JOIN Reservations ON Customers.CustomerID = Reservations.
CustomerID GROUP BY LastName, FirstName;
Step by Step Answer:
Concepts Of Database Management
ISBN: 9780357422083
10th Edition
Authors: Lisa Friedrichsen, Lisa Ruffolo, Ellen Monk, Joy L. Starks, Philip J. Pratt