You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Need to select top 100 vendors based on sum of VOUCHER.GROSS_AMT in query manager

3 replies [Last post]
Guest's picture
Guest

I need to sum the VOUCHER.GROSS_AMT by vendor in query manager and only return the top 100. Can this be done?

Lepa's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: Need to select top 100 vendors based on sum of ...

sure this can be done - you need 3 things:
1. Write your query with your sum(VOUCHER.GROSS_AMT)
2. Order by sum(VOUCHER.GROSS_AMT) desc (to get resutls from top down)
3. Add the below expression to your "where" clause:

and rownum <= 100

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Nitin's picture
User offline. Last seen 5 years 44 weeks ago. Offline
Joined: 06/30/2008
Posts: 73
Re: Need to select top 100 vendors based on sum of ...

I think rownum <=100 will work only on Oracle ..
How about other platform?

Cheers
Nitin

Venkataramani's picture
User offline. Last seen 8 years 27 weeks ago. Offline
Joined: 08/29/2008
Posts: 10
Re: Need to select top 100 vendors based on sum of ...

for db2 we can use fetch 100 rows only for the same...