Which query should you use?

You have two tables named Customers and Orders.
for customers that have placed at least one order, you need to produce a list of customer names and
the
number of orders for each customer.
Which query should you use?

You have two tables named Customers and Orders.
for customers that have placed at least one order, you need to produce a list of customer names and
the
number of orders for each customer.
Which query should you use?

A.
SELECT c.CustomerName,
SUM(o.OrderID) AS [OrderCount]
FROM Customers c
JOIN Orders o
ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerName

B.
SELECT COUNT(o.OrderId) AS [OrderCount]
FROM CUSTOMERS c
JOIN ORDERS o
ON c.CUSTOMERID = o.CUSTOMERID

C.
SELECT c.CustomerName,
COUNT(o.OrderID) AS [OrderCount]
FROM Customers c
JOIN Orders o
ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerName
HAVING COUNT(o.OrderID) > 1

D.
SELECT c.CustomerName,
COUNT(o.OrderId) AS [OrderCount]
FROM Customers c
JOIN Orders o
ON c.CustomerId = o.CustomerId
GROUP BY c.CustomerName



Leave a Reply 0

Your email address will not be published. Required fields are marked *