Use hahn;
$now=CAST(CAST(CAST(CurrentUtcTimestamp() as Timestamp) as Date) as String);
$month=($date)-> { 
RETURN DateTime::Format("%Y-%m-%d")(Datetime::MakeDate(DateTime::StartOfMonth(CAST($date as Date))));};

SELECT 
month,
sales_group,
fact,
plan
FROM (

SELECT 
month,
sales_group,
sum(money_and_forec) as fact,
sum(plan) as plan
FROM `home/mcsanalytics/common/datasets/dash/mly_pf_tier`
WHERE type_slice='clients' 
and slice='База закрытия'
and scale='months'
and currency='rur'
and product='Общая выручка'
and hrcy_0 IN ('SMB', 'LE')
and period>= '2019-01-01'
GROUP BY period as month,
if(hrcy_0='LE','KA','SMB') as sales_group
)
ORDER BY month, sales_group