Results 1 to 3 of 3

Thread: case count issue

  1. #1
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default case count issue

    Hi,

    Need help with the following query - if there is a count for USED then no NEW are counted for each day, can anyone tell me why?

    Code:
    SELECT 
    CASE eventstocklink.statusid WHEN 2 THEN count(CB.actionid) ELSE 0 END AS USED, 
    CASE eventstocklink.statusid WHEN 1 THEN count(CB.actionid) ELSE 0 END AS NEW
    FROM action AS CB 
    LEFT JOIN event ON event.eventid = CB.eventid 
    LEFT JOIN eventstocklink ON eventstocklink.eventstocklinkid = CB.eventstocklinkid 
    WHERE date(CB.actiondate) 
    BETWEEN '20091102' AND '20091108' 
    GROUP BY eventstocklink.statusid, date(CB.actiondate)
    thanks in advance

  2. #2
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    this solved my issue

    Code:
         , COUNT(CASE WHEN eventstocklink.statusid = 2 
                      THEN CB.actionid END) AS USED
         , COUNT(CASE WHEN eventstocklink.statusid = 1 
                      THEN CB.actionid END) AS NEW

  3. #3
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default case count issue

    Hi,

    CASE FBD for PLC & NovaPro SCADA:

    Oops wrote:

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •