Subject RE: [firebird-support] How to return a count using a SQL Select Statment
Author Edward Mendez

Mike,

 

You should be able to accomplish this with the use of a group by query.

 

SELECT WORKLIST_NAME,

       COUNT(*) WORKLIST_COUNT

FROM DOCKET_WORKLIST

GROUP BY WORKLIST_NAME 

 

Thanks,

Ed Mendez

 

From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Sent: Thursday, November 12, 2015 9:23 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] How to return a count using a SQL Select Statment

 

 

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