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

Db2

P: n/a
How to we calculate the nth maximum value of a column?
Jun 25 '07 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
How to we calculate the nth maximum value of a column?
Suppose you have a table called items with a column called price then to find the item with the third highest price you can try

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM items a WHERE 3 = (SELECT COUNT(DISTINCT(b.PRICE)) FROM  items  b WHERE  a.price <= b.price)
Jun 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.