Which SQL query should you use?

You work for a company that sells books. You are creating a report for a SQL Server 2005 database. The report will list sales representatives and their total sales for the current month. The report must include only those sales representatives who met their sales quota for the current month.
The monthly sales quota is $2,000.
The date parameters are passed in variables named @FromDate and @ToDate. You need to create the report so that it meets these requirements. Which SQL query should you use?

You work for a company that sells books. You are creating a report for a SQL Server 2005 database. The report will list sales representatives and their total sales for the current month. The report must include only those sales representatives who met their sales quota for the current month.
The monthly sales quota is $2,000.
The date parameters are passed in variables named @FromDate and @ToDate. You need to create the report so that it meets these requirements. Which SQL query should you use?

A.
SELECT s.AgentName, SUM(ISNULL(o.OrderTotal,0.00))AS SumOrderTotal FROM SalesAgent s
JOIN OrderHeader 0 ON s.AgentID = o.AgentID
WHERE o.OrderDate BETWEEN @FromDate AND @ToDate
GROUP BY s.AgentName

B.
SELECT s.AgentName,
SUM(ISNULL (o.OrderTotal,0.00))AS SumOrderTotal
FROM SalesAgent s
JOIN OrderHeader o ON s.AgentID = o.AgentID
WHERE o.OrderDate BETWEEN @FromDate AND @ToDate
AND o.OrderTotal >= 2000
GROUP BY s.AgentName

C.
SELECT s.AgentName,
SUM(ISNULL (o.OrderTotal,0.00)) AS SumOrderTotal
FROM SalesAgent s
JOIN OrderHeader 0 ON s.AgentID = o.AgentID
WHERE o.OrderDate BETWEEN @FromDate AND @ToDate
GROUP BY s.AgentName
HAVING SUM(o.OrderTotal) >= 2000

D.
SELECT s.AgentName, SUM(ISNULL(o.OrderTotal,0.00)) AS SumOrderTotal FROM SalesAgent s
JOIN OrderHeader o ON s.AgentID = o.AgentID WHERE o.ordertotal = 2000 AND o.OrderDate BETWEEN @FromDate AND @ToDate
GROUP BY s.AgentName
HAVING SUM(o.OrderTotal) >= 2000



Leave a Reply 0

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