Установите код:
CREATE TABLE [Table3] ([Team] nvarchar(10), [Int] int, [Player] nvarchar(10))
INSERT INTO [Table3] VALUES ('Yankees', 3, 'Carl')
INSERT INTO [Table3] VALUES ('Cubs', 2, 'Kevin')
INSERT INTO [Table3] VALUES ('Cubs', 3, 'Steve')
INSERT INTO [Table3] VALUES ('Yankees', 1, 'Tony')
INSERT INTO [Table3] VALUES ('Yankees', 2, 'Tony')
INSERT INTO [Table3] VALUES ('Red Sox', 4, 'Phil')
INSERT INTO [Table3] VALUES ('Red Sox', 5, 'Liam')
INSERT INTO [Table3] VALUES ('Dodgers', 5, 'Brad')
INSERT INTO [Table3] VALUES ('Red Sox', 7, 'Phil')
INSERT INTO [Table3] VALUES ('Red Sox', 6, 'Liam')
INSERT INTO [Table3] VALUES ('Cubs', 5, 'Kevin')
INSERT INTO [Table3] VALUES ('Cubs', 4, 'Steve')
INSERT INTO [Table3] VALUES ('Cubs', 6, 'Steve')
INSERT INTO [Table3] VALUES ('Dodgers', 3, 'Tony')
INSERT INTO [Table3] VALUES ('Dodgers', 4, 'Tony')
Я бы хотел отсортировать по Team
, а затем Int
. И затем я хотел бы видеть количество раз Player
изменений для каждого Team
.
Окончательный результат:
Team | Changes
-------------------
Cubs | 3
Dodgers | 1
Red Sox | 2
Yankees | 1