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] Select records from table until a duplicate

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    Is there a way I can select a set of records from a table ordering by a column till a duplicate.

    TableName --> temp

    Columns --> key1, key2, key3, key4, rowCount

    Select condition

    1. Order by rowcount
    2. Till a duplicate on combination of key1, key2 and key3
    key1 key2 key3 key4 rowCount
    k1.1 k2.1 k3.1 k4.1 1
    k1.2 k2.2 k3.2 k4.2 2
    k1.3 k2.3 k3.3 k4.3 3
    k1.1 k2.1 k3.1 k4.4 4
    k1.5 k2.5 k3.5 k4.5 5
    k1.6 k2.6 k3.6 k4.6 6

    The select query should return me the following records

    key1 key2 key3 key4 rowCount
    k1.1 k2.1 k3.1 k4.1 1
    k1.2 k2.2 k3.2 k4.2 2
    k1.3 k2.3 k3.3 k4.3 3

    Continue reading...

Compartilhe esta Página