1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

SQL Count by group by item

Discussão em 'Outras Linguagens' iniciado por Stack, Junho 17, 2021.

  1. Stack

    Stack Membro Participativo

    I have the query

    select count(t1.contactid) [Count],
    case
    when f.item like '%yes%' then 'Yes'
    when f.item like '%Correct%' then 'Yes'
    when f.item like '%None%' then 'No'
    when f.item like '% Notask%' then 'No'
    end as Items

    from table1 t1
    join table2 t2 on t1.contactid = t2.contactid

    group by f.item


    How do I group by each item

    the result

    Count items
    10 No
    20 No
    1 Yes
    1 Yes
    3 Yes
    1 Yes



    My goal to group No and Yes so it should look like


    Count Items
    30 No
    6 Yes



    Thank you

    Continue reading...

Compartilhe esta Página