![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Suppose I have a query like the following. What's the best way to find the position of a particular item? e.g. I would like to find out that: 'fred' is position 3 of 4 total. select seq,name from tbl order by seq; seq name --- ---- 2 bob 5 able 8 fred 9 steve |
#3
| |||
| |||
|
|
m... (AT) pixar (DOT) com, 22.07.2009 12:11: Suppose I have a query like the following. What's the best way to find the position of a particular item? e.g. I would like to find out that: * * * 'fred' is position 3 of 4 total. select seq,name from tbl order by seq; seq * name --- * ---- * 2 * *bob * 5 * *able * 8 * *fred * 9 * *steve Use the row_number() function select seq, name, row_number() over (order by seq) from tbl order by seq; |
#4
| |||
| |||
|
|
Suppose I have a query like the following. What's the best way to find the position of a particular item? e.g. I would like to find out that: * * * 'fred' is position 3 of 4 total. select seq,name from tbl order by seq; seq * name --- * ---- * 2 * *bob * 5 * *able * 8 * *fred * 9 * *steve Many TIA! Mark -- Mark Harrison Pixar Animation Studios |
![]() |
| Thread Tools | |
| Display Modes | |
| |