你工作在一个售书公司.你正在基于SQL SERVER 2005数据库创建一个报表。此
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
参考答案: