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 > Row_number - Sql0255

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-16-09, 05:32
arammal arammal is offline
Registered User
 
Join Date: Mar 2007
Posts: 14
Row_number - Sql0255

Hello,

I am working on a AS400 V5R4 machine, I have a problem with this sql querry :

Code:
SELECT ROW_NUMBER() OVER(), TAB.* FROM (
    SELECT COL_A, COL_B, COL_C 
    FROM TAB_ABC
    WHERE COL_B = 'TOTO'
    ORDER BY COL_A, COL_B ) TAB
it gives an SQL0255 error
Does anyone have any idea to make this querry run..

thank you,
Reply With Quote
  #2 (permalink)  
Old 06-16-09, 05:59
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Have you tried alternatives - so that the query can avoid the reason codes.

a) Move the ORDER BY to the OVER () part
b)
Code:
 SELECT ROWNUMBER() OVER ( ORDER BY COLA,COLB), COLAA, COLB,COLC FROM TAB_ABC
    WHERE COL_B = 'TOTO'
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 06-16-09, 06:56
arammal arammal is offline
Registered User
 
Join Date: Mar 2007
Posts: 14
thank you sathyaram_s for your answer..

in fact the main querry:

Code:
    SELECT COL_A, COL_B, COL_C 
    FROM TAB_ABC
    WHERE COL_B = 'TOTO'
    ORDER BY COL_A, COL_B
is generated automatically by an external program..
what i am trying to do is paginating over this query by using
ROW_NUMBER() OVER() AS RN...WHERE RN BETWEEN 1 AND 20
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