vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I would like to be able to select the maximum (highest ) value for a field, the 2nd highest, 3rd highest, etc. Are there any other functions that I might consider using with SQL? MAX will only pick up the highest and MIN the lowest value, but is there a way to pick up middle values, i.e., the 2nd, 3rd, etc, so I can list them in one row, along with a common key? Thanks, Carroll Rinehart |
| ||||
| Carroll wrote: > I would like to be able to select the maximum (highest ) value for a > field, the 2nd highest, 3rd highest, etc. Are there any other > functions that I might consider using with SQL? MAX will only pick up > the highest and MIN the lowest value, but is there a way to pick up > middle values, i.e., the 2nd, 3rd, etc, so I can list them in one row, > along with a common key? SELECT key FROM (SELECT ROW_NUMBER() OVER(ORDER BY key) AS rn FROM T) AS X WHERE rn = <put your number here> Cheers Serge -- Serge Rielau DB2 Solutions Development IBM Toronto Lab |