troubleshooting Question

SQL DB/2 for AS/400 question V.6.1 - OVER

Avatar of Rozamunda
Rozamunda asked on
DatabasesIBM System iDB2
2 Comments1 Solution582 ViewsLast Modified:
Hi, i want to sort by calculated field and then use over to retrieve records within certain range, it works when i sorted by a field which is in the table, but not calculated:

SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY fld1,fld2,DIFF    
 ) as ROW, 3*fld1 as REV,fld2-3*fld1 as  
 DIFF                                                              
       FROM FILE1                                     
        WHERE fld4 =1 ) as ALL                                   
                                                                   
                                                                   
 WHERE ALL.ROW  BETWEEN 1 AND 1000                                 
ASKER CERTIFIED SOLUTION
momi_sabag

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros