If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Select top DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-06, 04:11
GabriSam GabriSam is offline
Registered User
 
Join Date: Mar 2006
Posts: 3
Select top DB2

Hello!

Somebody could help me with this query?

select top 10 * from table1 where code not in (select top 5 code from table1)

I tried it but DB2 do not support top. I used fetch first row only

My problem is that in the first query the fetch first row only work well but in the second subquery do not work well.

thank you in advance
Reply With Quote
  #2 (permalink)  
Old 03-13-06, 05:32
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
What version of db2 are you using ???? Please always include this information.

On DB2 LUW V8 FP10, this works

select * from syscat.tables where tbspace not in (select tbspace from syscat.tablespaces fetch first 10 rows only) fetch first 10 rows only with ur
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 03-13-06, 05:57
GabriSam GabriSam is offline
Registered User
 
Join Date: Mar 2006
Posts: 3
Quote:
Originally Posted by sathyaram_s
What version of db2 are you using ???? Please always include this information.

On DB2 LUW V8 FP10, this works

select * from syscat.tables where tbspace not in (select tbspace from syscat.tablespaces fetch first 10 rows only) fetch first 10 rows only with ur

Sorry!

I am trying to excute this query using ODBC client access that connect to IBM AS400 with DB2 V5R3

thanks
Reply With Quote
  #4 (permalink)  
Old 03-13-06, 06:24
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
using 'fetch' in subselect is new functionality of DB2 v8.1
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On