SQL Procedure error

前端 未结 6 1542
北荒
北荒 2021-01-26 14:01

Changed into a procedure, getting a syntax error at \'PROCEDURE\' any ideas?

CREATE PROCEDURE performance_Report
 @startDate DATE,
 @endDate DATE
AS
    SELECT S         


        
6条回答
  •  面向向阳花
    2021-01-26 15:02

    You have AND ShopOrder.OrderDate BETWEEN @startDate AND endDate shouldn't that be AND ShopOrder.OrderDate BETWEEN @startDate AND @endDate?

    CREATE PROCEDURE performance_Report
     @startDate DATE,
     @endDate DATE
    AS
        SELECT Salesrep.Name, SUM(OrderLine.Quantity) AS Total_Sold, SUM(OrderLine.UnitSellingPrice * Orderline.Quantity) AS Total_Value
        FROM SalesRep, OrderLine, ShopOrder
        WHERE ShopOrder.SalesRepID = SalesRep.SalesRepID
        AND OrderLine.ShopOrderID = ShopOrder.ShopOrderID
        AND ShopOrder.OrderDate BETWEEN @startDate AND @endDate
        GROUP BY SalesRep.SalesRepID, SalesRep.Name
        ORDER BY Total_Value DESC;
    

    Otherwise does this query work if you remove that line entirely without being a stored procedure?

提交回复
热议问题