Reputation: 127
i have the following dataset
1, Nike
2, Adidas
3, oasis
4, reebok
5, puma
6, airjordan
for each 2 rows affect them to A,and so on
A, 1, Nike
A, 2, Adidas
B, 3, oasis
B, 4, reebok
C, 5, puma
C, 6, airjordan
Upvotes: 0
Views: 44
Reputation: 3810
I believe this is what you looking for:
You will need to use DENSE_RANK()
Sample Data:
DECLARE @Shoes TABLE ( ShoesId INT, Brand VARCHAR(10))
INSERT INTO @Shoes
VALUES
(1, 'Nike'),
(2, 'Adidas' ),
(3, 'oasis'),
(4, 'reebok'),
(5, 'puma'),
(6, 'airjordan')
Query:
SELECT CHAR(ASCII('A') + DENSE_RANK() OVER ( ORDER BY (ShoesId%2) + ShoesId -1) - 1),
*
FROM @Shoes
Results:
Upvotes: 1