Subject How to return a count using a SQL Select Statment
Author stwizard

This stored procedure returns:

PREP Shawnee  KS 10/01/2015 - 10/06/2015         248

RES Wyandotte  KS 10/01/2015 - 10/15/2015             4        

 

SET TERM ^^ ;

CREATE PROCEDURE SPS_DOCKET_WORKLIST_LIST returns (

  WORKLIST_NAME VarChar(60),

  WORKLIST_COUNT SmallInt)

AS

begin

  FOR SELECT DISTINCT WORKLIST_NAME

        FROM DOCKET_WORKLIST

        INTO :WORKLIST_NAME DO

    BEGIN

      SELECT COUNT(*)

        FROM DOCKET_WORKLIST

       WHERE WORKLIST_NAME = :WORKLIST_NAME

        INTO :WORKLIST_COUNT; 

        

      SUSPEND; 

    END       

end ^^

SET TERM ; ^^

 

I know there is a way to do this with a SQL select statement.  Can someone share how?

 

Thanks,

Mike