TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Peter Garner
from: Thos Davis
date: 1996-08-14 20:20:00
subject: Db2

PG|... DB2 doesn't seem to have the limit keyword, but it might have
  |something similiar as you had pointed out.  Which Database is
  |does support that?  Perhaps I can work backword from that?

So far the only system I've found which supports the LIMIT keyword
is the one I learned SQL on, R:Base. I was a little surprised by
this as LIMIT is on the "alert" list of potential keywords under
consideration for future SQL standards.

However, LAST is an SQL-2 keyword. As R:Base is SQL-2 compliant, and
LAST is used in R:Base as in the following predicate
    WHERE COUNT = LAST
I would think that you may have luck using the following statement.

SELECT *
   FROM relation
   WHERE COUNT > 8
   ORDER BY tupleX DESC;

I've also noted in another message thread that there is some concern
about the order of the tuples returned. I was under the impression
that under DB/2 the date type is a timestamp. That is that it
includes a time as well as a date value. If that is the case, it may
be that you will have less chance of duplication than with a date
only implementation.

However, the use of DISTINCT may not solve your problems as it may
act over the entire tuple and not just a single attribute. So that
given the relation People, with the attributes Name, Age, and
FavColor

    Kelly           42          Blue
    Chris           37          Orange
    Pat              4          Orange
    Robin           21          Red

The query
    SELECT DISTINCT * FROM PEOPLE
will return all four rows as each is unique.

The query
    SELECT DISTINCT FavColor FROM PEOPLE
will return only three rows
    Blue
    Orange
    Red

Of course it may be that COUNT = LAST won't work, in which the
DISTINCT issue will not be that important for you anyway.
___
 X SLMR 2.1a X 

--- Maximus/2 2.02
* Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1
@PATH: 109/347 18 13/25 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.