Count multiple items from the same column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • redeye
    New Member
    • Oct 2007
    • 5

    Count multiple items from the same column

    Hi All,
    I need to do a count of individual items in one column I call status. The status column contains only three values (‘Not Available’, Partially Available’, ‘Fully Available’). My sql statement below just gets me the count for the status column, I need to know how to count the status column for the specific items.

    SELECT EEI.EEI_NAME, COUNT(EEI_INSTA NCE_RECOVERY.ST ATUS) AS EXPR1
    FROM MTS_EVENT INNER JOIN EEI_INSTANCE_RE COVERY
    ON MTS_EVENT.EVENT _ID = EEI_INSTANCE_RE COVERY.EVENT_ID
    INNER JOIN EEI_OBJECT_INST ANCE
    ON EEI_INSTANCE_RE COVERY.INSTANCE _ID = EEI_OBJECT_INST ANCE.INSTANCE_I D
    INNER JOIN EEI ON EEI_OBJECT_INST ANCE.EEI_ID = EEI.EEI_ID
    WHERE (EEI.EEI_TYPE = 'Critical Infrastructure' )
    AND (EEI_INSTANCE_R ECOVERY.EVENT_I D = :EVENT_ID)
    GROUP BY EEI.EEI_NAME ORDER BY EEI.EEI_NAME ASC

    The results from this query gets me part way there, it returns is like

    EEI_NAME EXPR1
    Name_one....... ..8
    Name_two....... ..5

    My goal is to have it return

    EEI_NAME EXPR1 Not_Available Partially_Avail able Fully_Availavle
    Name_one....... 8 ..............2 ............... .........2..... ............... .. 4
    Name_two....... .5............. ..0 ............... .........0 ............... .......5

    Thank you for any help!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to use COUNT and SUM with DECODE.

    That will solve your problem.

    Comment

    • redeye
      New Member
      • Oct 2007
      • 5

      #3
      Thank You,
      It worked great.

      Comment

      Working...