|
Posted by Andrew Lias on 10/01/69 11:43
Let us say that I have a table with two sets of values as such:
Item Extension
--- ----
100023 1
100025 1
100025 2
100028 1
100029 1
100029 2
100029 3
[...]
Note that a given item number can appear multiple times if it has more
than one extension number.
I want to be able to select the first N entries as grouped by item
number. So if N = 3, that would return 100023, 100025 and 10028 with
their associated extentions. I would also like to be able to select
say, the 2nd through 9th entries grouped by item number.
I've tried something like this to give me row counts:
select rank = count(1), t1.item, t1.extension
from ItemTable t1 inner join itemTable t2
on t1.item >= t2.item
group by t1.item, t1.extension
order by rank
But that gives me this sort of result:
Rank Item Extension
---- --- ----
1 100023 1
3 100025 1
3 100025 2
4 100028 1
7 100029 1
7 100029 2
7 100029 3
[...]
Any suggestions would be welcome.
Navigation:
[Reply to this message]
|