Thursday, May 10, 2007

Rownum in Oracle --Something cool..!!!

Here is how you retrieve the first row which meets the crieteria from amoung a set of rows.. =)


select * from srgt_guarantee where srgt_facility_grading_id=1882

will return multiple rows like:
Gid
2408 1882 on 1 50 -1 455 [NULL] YES NO 40
2409 1882 on 23 20 -1 100 [NULL] YES NO 50
2410 1882 [NULL] 24 100 -1 190 [NULL] YES NO 40
2414 1882 [NULL] 1000 100 -1 100 [NULL] YES NO 52
2411 1882 [NULL] 68 100 -1 100 [NULL] YES NO 40
2412 1882 [NULL] 20 100 -1 100 [NULL] YES NO 50
2413 1882 [NULL] 900 100 -1 100 [NULL] NO NO 50

now if you do this will return just a single row =)

select * from srgt_guarantee where srgt_facility_grading_id=1882 and rownum=1;

Will return just a singl row. =)

2408 1882 on 1 50 -1 455 [NULL] YES NO 40


This cool to explore
enjoy
sunita

No comments: