Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    57

    Creating Equal number of records based on a column.

    Hi Guys,

    The Table i am talking about it is as follows.

    Col1 Col2 Col3 Col4

    Col1 can have 5 different values (1,2,5,6,7).

    Based on the Col2, i will see how many such values are present for Col1. Then i have to create the remaining records with col3 and col4 as '99'.

    For an example,

    1 AA 87 98
    2 AA 77 56
    6 BB yu io


    So, for AA i have to add 3 more records, with value for the first record as 5,6,7 and the remaining col3 and col4 as '99'

    For BB, we have to add 4 more records with value for the first record as 1,2,5,7 and the remaining col3 and col4 as '99'.

    Can somebody help me out with this.

    Cheers!!!

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,622
    what does your post have to do with Oracle?
    why does your post contain no SQL?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  3. #3
    Join Date
    Mar 2007
    Posts
    615
    Quote Originally Posted by mac4rfree View Post
    Can somebody help me out with this.
    Hi,
    in Oracle, I would use partitioned outer join to join "table you are talking about" with the table with one numeric column containing row for each of "5 different values" (= having 5 rows in total; may be created artifically e.g. from that list of values).
    It (partitioned outer join) is described in SQL Language Reference, which is available with other Oracle documentation books e.g. online on http://tahiti.oracle.com/.
    Have a look at the chapter about the SELECT statement about more details.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •