By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,611 Members | 2,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,611 IT Pros & Developers. It's quick & easy.

Is this the right way to go about ranking things?

P: n/a
Haven't had much experience with the various OLAP functions in DB2, but
want to work out what the best performing products were yesterday, by
category and by location. Is this the most efficient way to go about
it?:

[for this example, transactions is a summary of sales including
location, category, productcode, transdate and (count of) bookings in
it]

select category, location, productcode, bookings
FROM (
SELECT category,
location,
s.productcode, t.bookings,
dense_rank() over (partition by s.category, s.destination order by
bookings desc) as ranked_bookings
FROM transactions WHERE transdate = current date - 1 days

) as a
WHERE ranked_bookings = 1
;

Mar 22 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.