468,258 Members | 1,509 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,258 developers. It's quick & easy.

Db2

How to we calculate the nth maximum value of a column?
Jun 25 '07 #1
1 842
r035198x
13,262 8TB
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.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.