- Apr 17, 2003
- 910
- 0
- 0
Lets say I have 100 records of sunglasses and within those records are 10 distinct frame colors. Is it possible to write a single query that will select UP TO 3 of each color out of the list, returning a result equal to 50, or below 50 if there quantities do not exist with the chosen grouping?
Example:
id - color_id
-----------------
1 - 1
2 - 1
3 - 1
4 - 1
5 - 2
6 - 2
7 - 2
8 - 3
9 - 3
10 - 4
Desired Result:
id
---------------
1
2
3
5
6
7
8
9
10
Example:
id - color_id
-----------------
1 - 1
2 - 1
3 - 1
4 - 1
5 - 2
6 - 2
7 - 2
8 - 3
9 - 3
10 - 4
Desired Result:
id
---------------
1
2
3
5
6
7
8
9
10