SQL Procedure error

前端 未结 6 1641
情话喂你
情话喂你 2021-01-26 13:57

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

    No, you cannot do that. You want your view to result in an aggregation by SalesRep.Name. What you want to do is filtering those SUMs. You have two options:

    1. Create a Stored Procedure instead of a View. That way you can have the Start date and End date as input parameters for the filtering.
    2. Do not create a DB structure at all, just use the query and have you source code populate the parameters.

    EDIT

    So, you changed the question and now you want to create a stored procedure in PostgreSql. You might want to take a look at this: A Basic Introduction to Postgres Stored Procedures. Take your time to read it, the knowledge acquired in the process will surely be helpful. And, on your way through it, you might reevaluate and think you don't really need that kind of functionality for a straightforward query such as this one. Good luck.

提交回复
热议问题