你工作在一个售书公司.你正在基于SQL SERVER 2005数据库创建一个报表。此

5 查阅
你工作在一个售书公司.你正在基于SQL SERVER 2005数据库创建一个报表。此报表显示本月超过销售配额的销售代表及他们的销售额 。已知,销售配额为$2,000。查询的起始日期和截至日期以变量@FromDate 和 @ToDate 传递进来。为了实现满足上述条件的报表,你应该使用下面那一个SQL查询语句?

SELECT s.AgentName, SUM(ISNULL(o.OrderTotal,0.00))AS SumOrderTotal FROMSalesAgent s JOIN OrderHeader o ON s.AgentID = o.AgentIDWHERE o.OrderDate BETWEEN @FromDate AND @ToDate GROUP BY s.AgentName

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

SELECT s.AgentName, SUM(ISNULL (o.OrderTotal,0.00)) AS SumOrderTotal FROMSalesAgent s JOIN OrderHeader o ON s.AgentID = o.AgentID WHERE o.OrderDate BETWEEN @FromDate AND @ToDateGROUP BY s.AgentNameHAVING SUM(o.OrderTotal) >= 2000

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

参考答案:

C

SQL试