If I execute the code below:
with temp as ( select \'Test\' as name UNION ALL select \'TEST\' UNION ALL select \'test\' UNION ALL select \'test
You can use an case sensitive collation:
with temp as ( select 'Test' COLLATE Latin1_General_CS_AS as name UNION ALL select 'TEST' UNION ALL select 'test' UNION ALL select 'tester' UNION ALL select 'tester' ) SELECT name, COUNT(name) FROM temp group by name