[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Selecting last 200 rows.



You could order in asc order and then ask sqr to only
return the first 200 rows (which are your last 200
rows).

You do that by putting a loops=200 in your select like
below:

Begin-Select loops=200
name
address
from blah, blah, blah

just a thought.

clara

--- "Jamadagni, Rajendra"
<rajendra.jamadagni@ESPN.COM> wrote:
> If you run the following statement, oracle will
> NEVER guarantee that you'll
> get the last 200 rows. This is not allowed in
> SQL-speak. When you say last
> (or for that matter first), you have to say what is
> the criteria for calling
> a record LAST?
>
> Do you have a sequential number? That would be most
> useful .... if you have
> timestamp, not much useful if you insert more than
> one row in a second.
> Don't count on rowid for earliest or latest rows
> retrieval, that's why we
> have ORDER BY clause. Basically until you establish
> the criterion / criteria
> that CLEARLY identifies a row as last, there is
> guaranteed way.
>
> By rowid it will work, if your DBA reorganizes the
> table, export/imports
> (for reducing the row chaining) the whole sequence
> will change.
>
> Please establish a criteria first ... and no you are
> not missing anything
> because based on your simple stated requirements,
> there is no solution.
>
> HTH
> Raj
>
______________________________________________________
> Rajendra Jamadagni              MIS, ESPN Inc.
> Rajendra dot Jamadagni at ESPN dot com
> QOTD: Any clod can have facts, but having an opinion
> is an art !
> Any opinion expressed here is personal and doesn't
> reflect that of ESPN Inc.
>
>
> -----Original Message-----
> From: Hallmark, Robert J
> [mailto:robert.j.hallmark@LMCO.COM]
> Sent: Monday, December 11, 2000 4:00 PM
> To: SQR-USERS@list.iex.net
> Subject: Re: Selecting last 200 rows.
>
>
> Deb,
>
> Have you tried something like:
>
> Begin-Select  loops = 200
> column_a
> column_b
> column_c
> etc
>     from tablename
>     order by rowid desc
> End-Select
>
> -----Original Message-----
> From: Deborah DeCarvalho Subject: Selecting last 200
> rows.
>
>
> Stupid question I know...
> but does anyone know the Oracle command that would
> be the equivalent of the
> UNIX "tail" command?
> I only want to select the last 200 rows in a table.
> The table is a session
> table so using a date format won't work.
> I only want the last 200 rows regardless of date. I
> thought I could use
> rowid, but it's not working.
>
> I know I should know this, but why don't I??
>
> Thanks
>
> Deb deCarvalho
>
>
>
>
*********************************************************************
>
> 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 ESPN at (860) 766-2000 and delete this e-mail
> message from your computer, Thank you.
>
>
*********************************************************************
>
<HR>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">


<META content="MSHTML 5.00.2919.6307"
name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>If you run the
following statement, oracle will NEVER guarantee that
you'll get the last 200
rows. This is not allowed in SQL-speak. When you say
last (or for that matter
first), you have to say what is the criteria for
calling a record LAST?
</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>Do you have a
sequential number? That would be most useful .... if
you have timestamp, not
much useful if you insert more than one row in a
second. Don't count on rowid
for earliest or latest rows retrieval, that's why we
have ORDER BY clause.
Basically until you establish the criterion / criteria
that CLEARLY identifies a
row as last, there is guaranteed
way.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>By rowid it will
work, if your DBA reorganizes the table,
export/imports (for reducing the row
chaining) the whole sequence will
change.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>Please establish
a criteria first ... and no you are not missing
anything because based on your
simple stated requirements, there is no
solution.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>HTH</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000>Raj</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2><SPAN
class=169320421-11122000></SPAN></FONT><FONT
size=2>______________________________________________________</FONT>
<BR><B><FONT color=#0000ff size=2>Rajendra
Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN
Inc.</FONT></B> <BR><FONT
color=#0000ff size=1>Rajendra dot Jamadagni at ESPN
dot com</FONT> <BR><FONT
color=#0000ff size=1>QOTD: Any clod can have facts,
but having an opinion is an
art !</FONT> <BR><FONT color=#0000ff size=1>Any
opinion expressed here is
personal and doesn't reflect that of ESPN
Inc.</FONT><FONT color=#0000ff
face=Arial size=1> </FONT></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV align=left class=OutlookMessageHeader
dir=ltr><FONT face=Tahoma
  size=2>-----Original Message-----<BR><B>From:</B>
Hallmark, Robert J
  [mailto:robert.j.hallmark@LMCO.COM]<BR><B>Sent:</B>
Monday, December 11, 2000
  4:00 PM<BR><B>To:</B>
SQR-USERS@list.iex.net<BR><B>Subject:</B> Re:
Selecting
  last 200 rows.<BR><BR></DIV></FONT>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000>Deb,</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=960505520-11122000>Have
  you tried something like:</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000>Begin-Select&nbsp; loops =
200</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN

class=960505520-11122000>column_a</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN

class=960505520-11122000>column_b</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN

class=960505520-11122000>column_c</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000>etc</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000>&nbsp;&nbsp;&nbsp; from
tablename</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN
  class=960505520-11122000>&nbsp;&nbsp;&nbsp; order by
rowid
  desc</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face=Arial size=2><SPAN

class=960505520-11122000>End-Select</SPAN></FONT></DIV>
  <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
    <DIV align=left class=OutlookMessageHeader
dir=ltr><FONT face=Tahoma
    size=2>-----Original Message-----<BR><B>From:</B>
Deborah DeCarvalho
    <B>Subject:</B> Selecting last 200
rows.<BR><BR></DIV></FONT>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>Stupid question
    I know...</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>but does anyone
    know the Oracle command that would be the
equivalent of the UNIX "tail"
    command?</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>I only want to
    select the last 200 rows in a table. The table is
a session table so using a
    date format won't work.</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>I only want the
    last 200 rows regardless of date. I thought I
could use rowid, but it's not
    working.</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN

class=976404720-11122000></SPAN></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>I know I should
    know this, but why don't I??</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN

class=976404720-11122000></SPAN></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2><SPAN

class=976404720-11122000>Thanks</SPAN></FONT></DIV>
    <DIV><FONT face=Arial size=2><SPAN

class=976404720-11122000></SPAN></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2><SPAN
class=976404720-11122000>Deb

deCarvalho</SPAN></FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>



__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/