Which Transact-SQL statement should you use?

You have a table named Sales. You are tasked to list products that have been sold to less than ten customers.
You need to write a query to achieve the task.
Which Transact-SQL statement should you use?

You have a table named Sales. You are tasked to list products that have been sold to less than ten customers.
You need to write a query to achieve the task.
Which Transact-SQL statement should you use?

A.
SELECT ProductID, COUNT(*) AS CustomerCount FROM Sales GROUP BY ProductID, CustomerID HAVING COUNT(*) < 10;

B.
SELECT ProductID, COUNT(DISTINCT CustomerID) AS CustomerCount FROM Sales GROUP BY ProductID HAVING COUNT(DISTINCT CustomerID) < 10;

C.
SELECT ProductID, CustomerID, COUNT(DISTINCT CustomerID) AS CustomerCount FROM Sales
GROUP BY ProductID, CustomerID
HAVING COUNT(DISTINCT CustomerID) < 10;

D.
SELECT * FROM (SELECT ProductID, RANK() OVER (ORDER BY CustomerID DESC) AS Rnk
FROM Sales) s WHERE s.Rnk <= 10;



Leave a Reply 1

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


wholesale hermes belts

wholesale hermes belts

Your article Question 23095: Which Transact-SQL statement should you use? | 70-433 | Microsoft exams write very well, thank you share!