If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 > Creating Equal number of records based on a column.

 mac4rfree Registered User 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!!!
 anacedent Registered User Join Date: Aug 2003 Location: Where the Surf Meets the Turf @Del Mar, CA Posts: 7,613
 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. Don't say, show. Don't promise, prove.
 flyboy Registered User Join Date: Mar 2007 Posts: 615
Quote:
 Originally Posted by mac4rfree 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 Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules