HELP FOR ADVANCED SELECT

  •  

    Hello!

    I have this problem

    i need to transform a union query

    (SELECT     a, b, SUM(1) AS c

     FROM         TABLE

     WHERE     (b= 14) AND (CRITERIO1) GROUP BY a, b)

    UNION

    (SELECT     a, b, SUM(1) AS c                                                  FROM TABLE

     WHERE     (b IN (5)) AND (CRITERIO1) GROUP BY a, b)

    in a single select that return a,(how many b=14 where criterio1),(how many b=5 where criterio1)

    grouping by a,b

    Thanks!!

  • Not entirely clear on what you want; perhaps:

    SELECT a, SUM(CASE b WHEN 14 THEN 1 ELSE 0 END) b14s, SUM(CASE b WHEN 5 THEN 1 ELSE 0 END) b5s

    FROM Table

    WHERE b IN (14,5) AND (Criterio1)

    GROUP BY a



    --Jonathan

  • Hi jonathan.

    you goal my question

    thanks!!!!!!!!

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

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