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

[SQL] Having count(*)>1 and but ignore duplicate if same key

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 18, 2024 às 01:12.

  1. Stack

    Stack Membro Participativo

    I used count(*) > 1 but it is showing duplicate rows as well. I want to see only unique rows

    Table: A

    id name class key
    1 abc 1 ACB3
    1 abc 1 ACB3
    2 ccd 2 XY4
    2 ccd 2 ZZ5


    Result expected:

    id name class key
    1 abc 1 ACB3
    2 ccd 2 XY4
    2 ccd 2 ZZ5


    Query:

    select id, name, class, count(*)
    from A
    group by id, name, class
    having count(*) > 1


    and result I got

    id name class
    1 abc 1
    1 abc 1
    2 ccd 2
    2 ccd 2

    Continue reading...

Compartilhe esta Página