Unix Technical Forum

how to specify the number of records to fetch

This is a discussion on how to specify the number of records to fetch within the DB2 forums, part of the Database Server Software category; --> hi can any body helps me for the equal statement at DB2 ver 7.0 for this statement at SQL? ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 05:20 AM
romina
 
Posts: n/a
Default how to specify the number of records to fetch

hi
can any body helps me for the equal statement at DB2 ver 7.0 for this
statement at SQL?
Select top 10 column1 from table1
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 05:20 AM
graham_martin
 
Posts: n/a
Default Re: how to specify the number of records to fetch

to get the first 10 rows......

select column1 from table1 fetch first 10 rows only

to get the top 10 rows........

select column1 from table1 order by column1 desc fetch first 10 rows
only

Graham Martin
http://www.ibm.com/software/data/db2/migration/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 05:20 AM
Bernd Hohmann
 
Posts: n/a
Default Re: how to specify the number of records to fetch

romina wrote:
> can any body helps me for the equal statement at DB2 ver 7.0 for this
> statement at SQL?
> Select top 10 column1 from table1


SELECT * FROM table WHERE xxx ORDER BY yyy ASC FETCH FIRST 10 ROWS ONLY

Bernd

--
"Ja, alles meine Herren" sprach Fürst Lichnowsky. "Ooch det roochen?"
"Ja, auch das Rauchen." "Ooch im Tiergarten?" "Ja, auch im Tiergarten
darf geraucht werden, meine Herren." Und so endeten die Barrikadenkämpfe
des 18. März in Berlin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 05:20 AM
Knut Stolze
 
Posts: n/a
Default Re: how to specify the number of records to fetch

romina wrote:

> hi
> can any body helps me for the equal statement at DB2 ver 7.0 for this
> statement at SQL?
> Select top 10 column1 from table1


Have a look at the DB2 manual, specifically here:
http://publib.boulder.ibm.com/infoce...n/r0000875.htm

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 05:22 AM
romina via DBMonster.com
 
Posts: n/a
Default Re: how to specify the number of records to fetch

hi ,
tanks for ur help,I did it but this error happened:

ILLEGAL USE OF KEYWORD FETCH, TOKEN , FOR WITH QUERYNO OPTIMIZE WAS EXPECTED

I don't know why!

--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200511/1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 05:22 AM
Gert van der Kooij
 
Posts: n/a
Default Re: how to specify the number of records to fetch

In article <573f8d3305960@uwe>, romina via DBMonster.com (u15590@uwe)
says...
> hi ,
> tanks for ur help,I did it but this error happened:
>
> ILLEGAL USE OF KEYWORD FETCH, TOKEN , FOR WITH QUERYNO OPTIMIZE WAS EXPECTED
>
> I don't know why!
>
>


Which DB2 do you use, DB2 v7.0 on mainframe?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-27-2008, 05:23 AM
romina via DBMonster.com
 
Posts: n/a
Default Re: how to specify the number of records to fetch

hi
it's DB2 v6.0 on mainframe
Gert van der Kooij wrote:
>> hi ,
>> tanks for ur help,I did it but this error happened:
>>
>> ILLEGAL USE OF KEYWORD FETCH, TOKEN , FOR WITH QUERYNO OPTIMIZE WAS EXPECTED
>>
>> I don't know why!

>
>Which DB2 do you use, DB2 v7.0 on mainframe?


--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200511/1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-27-2008, 05:23 AM
romina via DBMonster.com
 
Posts: n/a
Default Re: how to specify the number of records to fetch

hi
it's DB2 v6.0 on mainframe


Gert van der Kooij wrote:
>> hi ,
>> tanks for ur help,I did it but this error happened:
>>
>> ILLEGAL USE OF KEYWORD FETCH, TOKEN , FOR WITH QUERYNO OPTIMIZE WAS EXPECTED
>>
>> I don't know why!

>
>Which DB2 do you use, DB2 v7.0 on mainframe?


--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200511/1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com