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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: oracle last

RE: oracle last

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Tue, 15 Jul 2003 07:07:36 -0400
Message-Id: <25929.337779@fatcity.com>


This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible.

------=_NextPartTM-000-3e03e0d2-69fb-4611-b28e-53b2f6d9b024
Content-Type: multipart/alternative;

        boundary="----_=_NextPart_001_01C34AC1.4C897048"

------_=_NextPart_001_01C34AC1.4C897048

Content-Type: text/plain;

        charset="iso-8859-1"

select name, sal
  from (select rownum rnum, name, sal

          from emp
         order by sal asc)

 where rownum < 4
/

???
Raj




Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art !

-----Original Message-----

From: Daniel Fink [mailto:daniel.fink_at_sun.com] Sent: Monday, July 14, 2003 5:54 PM
To: Multiple recipients of list ORACLE-L Subject: Re: oracle last

Depending upon the version, you may be able to use the analytical functions (8.1.6+) to achieve what you want. I don't have a ready example, but the Oracle docs are pretty good. If you want a less elegant solution, use an inline query, sort by the reverse order (asc or desc depends on your requirements) and take the top 3. You can find examples of the Top-N approach on www.optimaldba.com/library.html. Either the Top-N Row or SQL Scripting Sorcery paper/presentation will have enough info to solve the problem.

pfeffer wrote:

> 
> hi
> is there a statement like last in mysql ?
> last returns a specified number of rows from a select.
> means if i do a select and i want only the last 3 lines.
> thx
> martin
> 
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.net

------_=_NextPart_001_01C34AC1.4C897048

Content-Type: text/html;

        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2654.19">
<TITLE>RE: oracle last</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>select name, sal</FONT>
<BR><FONT SIZE=3D2>&nbsp; from (select rownum rnum, name, sal</FONT> <BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from = emp</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = order by sal asc)</FONT>
<BR><FONT SIZE=3D2>&nbsp;where rownum &lt; 4</FONT>
<BR><FONT SIZE=3D2>/</FONT>
</P>

<P><FONT SIZE=3D2>???</FONT>

<BR><FONT SIZE=3D2>Raj</FONT>
<BR><FONT =
SIZE=3D2>---------------------------------------------------------------=

-----------------</FONT>

<BR><FONT SIZE=3D2>Rajendra dot Jamadagni at nospamespn dot com</FONT> <BR><FONT SIZE=3D2>All Views expressed in this email are strictly = personal.</FONT>
<BR><FONT SIZE=3D2>QOTD: Any clod can have facts, having an opinion is = an art !</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: Daniel Fink [<A = HREF=3D"mailto:daniel.fink_at_sun.com">mailto:daniel.fink_at_sun.com</A>]</FON= T>

<BR><FONT SIZE=3D2>Sent: Monday, July 14, 2003 5:54 PM</FONT>
<BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=3D2>Subject: Re: oracle last</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Depending upon the version, you may be able to use = the analytical functions (8.1.6+) to achieve what you want. I don't = have a ready example, but the Oracle docs are pretty good. If you want = a less elegant solution, use an inline query, sort by the reverse order = (asc or desc depends on your requirements) and take the top 3. You can = find examples of the Top-N approach on www.optimaldba.com/library.html. = Either the Top-N Row or SQL Scripting Sorcery paper/presentation will = have enough info to solve</FONT></P>

<P><FONT SIZE=3D2>the problem.</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=3D2>pfeffer wrote:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; hi</FONT>
<BR><FONT SIZE=3D2>&gt; is there a statement like last in mysql = ?</FONT>
<BR><FONT SIZE=3D2>&gt; last returns a specified number of rows from a = select.</FONT>
<BR><FONT SIZE=3D2>&gt; means if i do a select and i want only the last = 3 lines.</FONT>
<BR><FONT SIZE=3D2>&gt; thx</FONT>
<BR><FONT SIZE=3D2>&gt; martin</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; --</FONT>
<BR><FONT SIZE=3D2>&gt; Please see the official ORACLE-L FAQ: <A =
HREF=3D"http://www.orafaq.net" =
TARGET=3D"_blank">http://www.orafaq.net</A></FONT> </P>

</BODY>
</HTML>
------_=_NextPart_001_01C34AC1.4C897048--

------=_NextPartTM-000-3e03e0d2-69fb-4611-b28e-53b2f6d9b024
Content-Type: text/plain;

        name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

        filename="ESPN_Disclaimer.txt"

*********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************1
Received on Tue Jul 15 2003 - 06:07:36 CDT

Original text of this message

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