Help wanted for script

  • Hello 2 all,

    Anyone that would be so kind to help me out with a (probably for you) simple script ?

    I have two tables, ID (multiple) & SCALE (Y or N). Something like this:

    ID --- SCALE

    1001 --- Y

    1001 --- Y

    1001 --- N

    1002 --- N

    1004 --- Y

    Is a script possible that count the scale Y and N occurencies per printer? A resultset like this:

    ID --- SCALE Y --- SCALE N

    1001 --- 2 --- 1

    1002 --- 0 --- 1

    1004 --- 1 --- 0

     

    Kind regards 2 all.

     

     

     

     

  • You say "I have two tables", but from the rest of the post it seems you have one table with two columns.. I will write the query for this situation, if it isn't what you need, please post DDL of your tables.

    SELECT [ID], SUM(CASE WHEN Scale = 'Y' THEN 1 ELSE 0 END) as Scale_Y, SUM(CASE WHEN Scale = 'N' THEN 1 ELSE 0 END) as Scale_N

    FROM table

    GROUP BY [ID]

    HTH, Vladan

  • Vladan,

    Got it working. Thank you so much for helping out!!!!

    Rgds,

    T.

     

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

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