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

Grouping Query Required

Discussion in 'Oracle' started by gvsrao, Jul 26, 2007.

  1. gvsrao

    gvsrao New Member

    Joined:
    Jul 26, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hai Every one , Please help me in writing the query for the following requirement

    Let us Suppose there is one table with two columns.

    Col1 Col2
    1 01-jan-07
    1 01-Feb-07
    1 01-mar-07
    1 01-Apr-07

    2 05-jan-07
    2 06-Feb-07
    2 07-mar-07
    2 10-Apr-07

    I need a query which assigns the sequnece numbers to each group. i.e. i should get the out put as follows

    1 1 01-jan-07
    2 1 01-Feb-07
    3 1 01-mar-07
    4 1 01-Apr-07


    1 2 05-jan-07
    2 2 06-Feb-07
    3 2 07-mar-07
    4 2 10-Apr-07
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Code:
    Select col1, col1, col2 from table1, table1 where table1.col2 = table2.col2
     

Share This Page