Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL:Only the last row of an result ?

Re: SQL:Only the last row of an result ?

From: x <tzadkiel_at_surfnetcity.com.au>
Date: 1998/03/20
Message-ID: <MPG.f7cd7209ab07e6c989681@news.ozemail.com.au>#1/1

In article <6esprk$4ubi$1_at_newssvr03-int.news.prodigy.com>, ALEXJENT_at_prodigy.net says...
> Add to the previous response:
> Select * from Table1
> where Col1 = 'Test'
> and rownum =1
> order by Col1 DESC
>
> Alex

i know it seems like it SHOULD work, but it doesn't. "rownum" returns the sequence that the rows were retrieved from the database, which is prior to the sort. this code gets you an effectively random row from the table. check my earlier posts on rankings/median to see a method that gives you what everyone instinctively thinks "rownum" should.

tzad

uncle tzad's house o'SQL Received on Fri Mar 20 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US