SQL Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alain

    SQL Query

    Hello
    I would like to agregate several rows :
    I would like
    [color=blue]
    > C1 C2 C3
    > ---------- ---- ----
    > VINET 5 10
    > VINET 5 11
    > VINET 5 12
    > TOMSP 5 13
    > TOMSP 5 13
    > TOMSP 6 18
    > TOMSP 7 19
    > TOMSP 6 19
    > TOMSP 7 18[/color]

    and to obtain
    [color=blue]
    > C1 C2 C3
    > ---------- ---- ----
    > VINET 5 10
    > TOMSP 5 13[/color]

    for the result
    In fact, I would like to obtain 1 single row for the same couple (C1,C2)

    what should be the request ?


  • Ty

    #2
    Re: SQL Query

    Wow.. your request could be extrapolated in a number of ways.

    Are you asking how to group all distinct combinations, or are you looking
    for the FIRST time c1 changes ordered by the lowest of the two other
    columns?

    If it is the latter, this may work:

    Select DISTINCT c1, min(c2), min(c3) FROM tblFoo
    GROUP BY c1
    ORDER BY c1 ASC




    "Alain" <alain4@hotmail .com> wrote in message
    news:bj3bs9$8g8 $1@news-reader3.wanadoo .fr...[color=blue]
    > Hello
    > I would like to agregate several rows :
    > I would like
    >[color=green]
    > > C1 C2 C3
    > > ---------- ---- ----
    > > VINET 5 10
    > > VINET 5 11
    > > VINET 5 12
    > > TOMSP 5 13
    > > TOMSP 5 13
    > > TOMSP 6 18
    > > TOMSP 7 19
    > > TOMSP 6 19
    > > TOMSP 7 18[/color]
    >
    > and to obtain
    >[color=green]
    > > C1 C2 C3
    > > ---------- ---- ----
    > > VINET 5 10
    > > TOMSP 5 13[/color]
    >
    > for the result
    > In fact, I would like to obtain 1 single row for the same couple (C1,C2)
    >
    > what should be the request ?
    >
    >[/color]


    Comment

    Working...