| Author |
Topic |
|
learntsql
524 Posts |
Posted - 2009-08-27 : 03:32:48
|
| Hi ALL,My result set gives the following outputRowNum,State,Category,Item,Total1,AP,C1,Item1,102,AP,C1,Item1,22............Now How can i display the record which has maximum RowNUMlike2,AP,C1,Item1,22please tell me |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-27 : 03:34:10
|
| select * from your_tablewhere rownum=(select max(rownum) from your_table)MadhivananFailing to plan is Planning to fail |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-27 : 04:28:17
|
| select t.* from tablename tinner join (select max(rownum) as rownum from tablename) s on s.rownum = t.rownum |
 |
|
|
learntsql
524 Posts |
Posted - 2009-08-27 : 04:48:35
|
| when i try to execute its giving only one record i.e max record but Sorry i didnt mention butmy result set contains i have various groups,various states,Categories and Itemsi.e the same categories are repeated for many States.for eg;RowNum,State,Category,Item,Total1,AP,C1,Item1,102,AP,C1,Item1,22(10+12)1,AP,C1,Item2,21,AP,C2,Item1,232,AP,C2,Item1,30(23+7)......1,MH,C1,Item1,111,MH,C2,Item1,22......My Output Should like as followsRowNum,State,Category,Item,Total2,AP,C1,Item1,22(10+12)1,AP,C1,Item2,22,AP,C2,Item1,30(23+7)1,MH,C1,Item1,111,MH,C2,Item1,22......am i clear?please tell me the sol. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-27 : 04:56:30
|
| select t.* from tablename tinner join (select State,Category,Item,max(rownum) as rownum from tablename group by State,Category,Item) s on s.rownum = t.rownum |
 |
|
|
learntsql
524 Posts |
Posted - 2009-08-27 : 06:26:21
|
| ThankQ Allit does. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-27 : 06:35:44
|
| welcome |
 |
|
|
|
|
|