| Author |
Topic |
|
mayurcreation
Starting Member
16 Posts |
Posted - 2007-11-14 : 11:42:26
|
| Hi everybody..I have good challenging question for you. I look simple but when you try you will come to know the complex.View : View_FundsOutputrownum, portfolio_code, security_code, lot_number1, AA, 012245, null2, AA, 012245, null3, AA, 012245, null4, AA, 012245, null5, AA, 585652, null6, AA, 585652, null7, AA, 895985, null8, AA, 895985, null9, BB, 012245, null10, BB, 012245, null11, BB, 012245, null12, BB, 565895, null13, BB, 789654, null14, BB, 147852, null15, BB, 147852, null16, BB, 147852, null17, BB, 085265, null....I need to allocate lot_number in incremental formateQuery should first take portfolio_code into account and than security_code. e.g.portfolio_code, security_code, lot_numberAA 012245 1AA 012245 2AA 012245 3AA 585652 1AA 585652 2AA 895985 1AA 895985 2.....BB 012245 1BB 012245 2BB 012245 3BB 789654 1BB 789654 2BB 789654 3....Any input will be highly appreciated..... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-14 : 11:45:17
|
it can be easily done with the row_number() function. Look it up in Books On Line KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mayurcreation
Starting Member
16 Posts |
Posted - 2008-01-09 : 11:51:03
|
| Answer to above problem is as follows:-update View_FundsOutput set lot_number = q.new_numfrom View_FundsOutput vf, (SELECT portfolio_code, security_code, rownum, ROW_NUMBER() OVER(PARTITION BY portfolio_code, security_code ORDER BY rownum DESC) As new_num FROM view_fundsoutput) as qwhere vf.rownum = q.rownumThanks for your suggestions. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-10 : 01:41:13
|
| and instead of having it as seperate column, derive it in a SELECT statementMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|