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

Home -> Community -> Usenet -> c.d.o.server -> Latest n rows of table - without a nested select

Latest n rows of table - without a nested select

From: Peter Groarke <peter.groarke_at_orbiscom.com>
Date: 24 Oct 2005 06:59:48 -0700
Message-ID: <1130162388.796734.323010@f14g2000cwb.googlegroups.com>


Hi,

   Within oracle SPL, I want to select 2 columns of the latest n rows of a table.
I currently do this with a nested select. For example to get columns a and b of the most recent single row of table a_journal:

           select a,b into p_a, p_b FROM
              (SELECT a, b, from a_journal
	      where (c = 'O' or c = 'A')
              order by system_date desc)
	  where rownum = 1;


Is there any way of doing this in a single select (i.e. not using a nested select)
Note: The table also contains a sequence (the tables primary key). Can this be used ?

Any help appreciated,
Peter Received on Mon Oct 24 2005 - 08:59:48 CDT

Original text of this message

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