Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rownum and order by to select only the second record 1

Status
Not open for further replies.

Scunningham99

Programmer
Sep 20, 2001
815
GB

i have a query which selects names and dates in order.


SELECT * FROM (
SELECT name,
date
FROM table
ORDER BY date )
WHERE rownum < 3;

this works fine and returns 2 rows. but i only wish to display the second row. how can i do this.

for example it is the second in the list i wish to display not both

thanks in advance


Sy UK
 
try this query

select t1.field1, ...
from table t1
join table t2 on t2.pk=t1.pk and
t2.datum=(select min(datum)
from table
where pk=t1.kp and
datum>(select min(datum)
from table
where pk=t1.pk))
order by t1.pk, t1.datum

zerberus
 
SELECT * from (
SELECT name,date, rownum r FROM (
SELECT name,
date
FROM table
ORDER BY date )
WHERE rownum < 3
)
WHERE r = 2;
 
thanks to you all! i wasnt aware you could select from rownum.

great help to you all but i think i will go with ddrillich



Sy UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top