Hi ps222,
Please refer below sample query.
SQL
DECLARE @TestDemo AS TABLE([type] VARCHAR(20), [date] DateTIME)
INSERT INTO @TestDemo VALUES('Security','2019-02-26')
INSERT INTO @TestDemo VALUES('Booking','2019-03-02')
INSERT INTO @TestDemo VALUES('Booking','2019-02-26')
INSERT INTO @TestDemo VALUES('Security','2019-02-28')
INSERT INTO @TestDemo VALUES('Cleanliness','2019-02-26')
SELECT [type] Type, COUNT([type]) [Count] FROM @TestDemo
WHERE [date] <= GETDATE()
GROUP BY [type]
Output
Type |
Count |
Booking |
2 |
Cleanliness |
1 |
Security |
2 |