Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: select
Hi
There are two ways to get things done. First if you'r using order by
then you can flip sort of order by adding a DESC egz.
"ORDER BY Field1 " will give result [A-Z] or [1-9] "ORDER BY Field1 DESC" will give result [Z-A] or [9-1]
If you use group by you can add ORDER BY at the end With DESC after a field. So last row becomes first row. In WHERE clause add " ROWNUM <2" with or without AND (as necessary). See help for more info on rownum.
But if you do not use ORDER or GROUP BY statements than write sub query
to
query that will return
< max rows and subtract it from original query
egz.
SELECT Field1,Field2
FROM Table1
MINUS
SELECT Field1,Field2
FROM Table1
WHERE ROWNUM < (SELECT MAX(ROWNUM) FROM Table1)
IMPORTANT: both queries (Upper and Lower) must have selected same number
of fields.
For more info on MINUS see help.
Edo
Mitja Sladovic wrote:
> Hello.
>
> How can I get only LAST row from
>
> select a from table
>
> Thanks!
Received on Wed Oct 13 1999 - 00:00:00 CDT