View gist:673d5b059879af2f522809911d9c1693
Select case when u.marketing_source_id = 8382 then 'Яндекс Директ - курсы_main'
when u.marketing_source_id = 8381 then 'Google Adwords - курсы_main'
end Маркетинговый_Источник,
count(u.id) as Платящие_пользователи,
CASE
WHEN ((u.marketing_source_id IN (8381, 8382))
AND (c.marketing_source_id NOT IN (
SELECT ms.id AS id_ms
FROM marketing_sources ms
WHERE (ms.Source_Group_ID >= 1 AND ms.Source_Group_ID <= 53)