Saturday, December 31, 2005

How to SELECT specific ROWS from a TABLE

Thats a tricky thing to do.At first do select with an extra row as rownum.And do another select based on this select using where to specify specific rows.I think an example can elaborate this.

table A:
----------
name roll_no
----- -------
hasim 02MCA07
mamnoon 03MCA45
matin 02MCA50
anwar 02MCA09
gafur 03MCA56

SELECT name FROM (SELECT name,ROWNUM n FROM A) WHERE n BETWEEN 2 AND 4
This query will fetch:

mamnoon
matin
anwar

Labels:

1 Comments:

Anonymous Anonymous said...

Thanks.Its really good.

2:47 PM  

Post a Comment

<< Home