I have the following table in SQL Server 2012:
CREATE TABLE [MyTable] (
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY DEFAULT NEWID(),
[MyGroup] INT NOT NULL
);
I want to output a table of the form
| MyGroup | Count
Max | |
Min | |
For example, if I have 30
rows in MyTable where MyGroup = 1
, 20
rows where MyGroup = 2
, and 10
rows where MyGroup = 3
, then
| MyGroup | Count
Max | 1 | 30
Min | 3 | 10
What sort of query would output this information?