Sql - проблема с group by
Привет всем, теперь я пытаюсь выбрать таблицу, ниже теперь моя текущая таблица выбора
Source total Local Overseas Singapore ALIBABA 1 0 1 0 ALIBABA 1 0 0 1 BBB 1 1 0 0 GOOGLE ADS 1 1 0 0 Now my problem is how to make "ALIBABA" group together and the result i want is as below Source total Local Overseas Singapore ALIBABA 2 0 1 1 BBB 1 1 0 0 GOOGLE ADS 1 1 0 0
Что я уже пробовал:
select gt2.Source,count(Region) as total, CASE WHEN Region = 'MALAYSIA' THEN count(Region) ELSE 0 END as LOCAL, CASE WHEN Region = 'OVERSEAS' THEN count(Region) ELSE 0 END as OVERSEAS, CASE WHEN Region = 'SINGAPORE' THEN count(Region) ELSE 0 END as SINGAPORE from [ERP_GT].[dbo].[GTMAX_RefTable] as gt1 left join [ERP_GT].[dbo].[GTMAX_Customer] as gt2 on gt2.Region = gt1.Name where Type='reg' and Created between '2020-05-05' and '2020-05-08' group by gt2.Source, Region