Create table #Pivot
(ClientID int,Model varchar(2),LastSyncTime_DW datetime)
Insert into #Pivot Values (1, 'A', '2018-09-26'),
(2, 'A', '2018-09-05'),
(1, 'A', '2018-08-19'),
(1, 'A', '2018-07-25'),
(3, 'B', '2018-07-03'),
(1, 'A', '2018-06-10'),
(3, 'B', '2018-06-07'),
(8, 'A', '2018-06-01'),
(1, 'A', '2018-05-31'),
(3, 'B', '2018-05-29'),
(4, 'C', '2018-05-26'),
(5, 'D', '2018-05-25'),
(6, 'C', '2018-05-24'),
(1, 'A', '2018-05-19'),
(7, 'D', '2018-05-12'),
(8, 'A', '2018-05-09'),
(9, 'A', '2018-05-05')
Select * from #Pivot
select model,
count(distinct case when LastSyncTime_DW >= '2018-09-01' and LastSyncTime_DW < '2018-10-01' then ClientID end) as cnt_201809,
count(distinct case when LastSyncTime_DW >= '2018-08-01' and LastSyncTime_DW < '2018-09-01' then ClientID end) as cnt_201808,
count(distinct case when LastSyncTime_DW >= '2018-07-01' and LastSyncTime_DW < '2018-08-01' then ClientID end) as cnt_201807,
count(distinct case when LastSyncTime_DW >= '2018-06-01' and LastSyncTime_DW < '2018-07-01' then ClientID end) as cnt_201806,
count(distinct case when LastSyncTime_DW >= '2018-05-01' and LastSyncTime_DW < '2018-06-01' then ClientID end) as cnt_201805
from #Pivot
group by model;
Вы получите следующие результаты