Multiple Criteria store proc - need a bit of help

  • I need some help writing my store proc, I tried both of the following but it does'st seem to work.  Your suggestions would be appreciated.

    SELECT count(LeadId)

    FROM dbo.Cl_Leads

    Where AccntMng=@AccntMng and (Status = 'Won' or Status = 'Lost') and InsertDate BETWEEN @dtStart AND @dtEnd

     I also tried

    SELECT count(LeadId)

    FROM (SELECT * FROM dbo.Cl_Leads WHERE InsertDate BETWEEN @dtStart AND @dtEnd)

    Where AccntMng=@AccntMng and (Status = 'Won' or Status = 'Lost') 

    This return and error: Incorrect syntax near the keyword 'Where'.

  • Post the whole proc, the ddl for the table, some sample data, and the errors you received (stick with the first syntax).

     


    And then again, I might be wrong ...
    David Webb

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply