Title: RE: DB2EUG: select limit

Howdy:

--sorry i've been away from this to address an error ...

--when i try this:

db2 => select * from test.table fetch first 10 rows only

--i get this error:

SQL0199N  The use of the reserved word "FETCH" following "" is not valid.
Expected tokens may include:  "FOR WITH ORDER UNION EXCEPT QUERYNO OPTIMIZE ".
SQLSTATE=42601


--is this version specific?  for example, my environment is
DB2 Connect (DB2 for Windows version 5.2) connecting to DB2
v. 6.1.1 for MVS OS/390 through a AIX passthrough gateway.
I know sometimes the gateway doesn't allow certain things
to happen (at least it's the case with me).

--BUT, when i try this on my Linux server (DB2 Universal Database
Enterprise Edition verion 7.1) it works.

--what am i missing here?

--TIA

-X


-----Original Message-----
From: Helen Johnson [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 30, 2001 1:53 PM
To: [EMAIL PROTECTED]
Subject: RE: DB2EUG: select limit


None of these answers mentioned that you have to use an ORDER BY for the
column that you want the top 10 values of; otherwise you will only get
the first 10 and not the top 10.

> -----Original Message-----
> From: Sinha, Abhijit [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 5:00 PM
> To: [EMAIL PROTECTED]
> Subject: RE: DB2EUG: select limit
>
>
> select * from test.table fetch first 10 rows only
>
> -----Original Message-----
> From: Johnson, Shaunn [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 5:14 PM
> To: [EMAIL PROTECTED]
> Subject: DB2EUG: select limit
>
>
>
> Howdy:
>
> I'm sure there is a way to do this, but I
> don't know *how* ...
>
> How do you get the top 10 (or, whatever number)
> records via the command line in DB2?
>
> On some other DB apps, there is a limit function
> that allows you to do something like:
>
> [snip]
>
> database=> select * from test.table limit 10
>
> [/snip]
>
>
> This gets me the first 10 records.  How can I do
> this in DB2?
>
> TIA.
>
> -X
>

Reply via email to