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 ?


  • Bob Quintal

    #2
    Re: SQL Query

    "Alain" <alain4@hotmail .com> wrote in
    news:bj3br5$rp4 $1@news-reader2.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]

    You cannot do that.

    You can get
    C1 C2
    ---------- ----
    VINET 5
    TOMSP 5
    TOMSP 6
    TOMSP 7

    By issuing the SQL statement
    SELECT DISTINCT C.C1, C.C2 from C
    given C as the name for your table, or

    SELECT C.C1 from C will give you
    C1
    ----------
    VINET
    TOMSP


    Bob Q

    Comment

    • John Winterbottom

      #3
      Re: SQL Query

      "Alain" <alain4@hotmail .com> wrote in message
      news:bj3br5$rp4 $1@news-reader2.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][/color]


      select C1, min(C2) as C2_min, min(C3) as C3_min
      from alain
      group by C1

      [color=blue]
      > for the result
      > In fact, I would like to obtain 1 single row for the same couple (C1,C2)
      >[/color]

      select min(C2) as C2_min, min(C3) as C3_min
      from alain





      Comment

      • TC

        #4
        Re: SQL Query

        DON'T POST THE SAME QUESTION UNDER DIFFERENT HEADINGS!

        I just spent some time answering the other friggin' one.

        This is not a good way to get further help :-(

        TC


        "Alain" <alain4@hotmail .com> wrote in message
        news:bj3br5$rp4 $1@news-reader2.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...