I don’t have a databricks environment yet to run the queries and test stuff.
Could someone please help check if the below is a valid query :
insert into pqr.public.abc
with city_mapping as
(
select date,store_id,code,city from pqr.public.def where date>= current_date-1
group by 1,2,3,4
)
, runrate as(
select a.date,
case when city is null then 'Null' else city end as city,
a.store_id,b.code,round(sum(runrate),4) total_rr from pqr.public.lmn a
left join city_mapping b
on a.store_id=b.store_id and a.date=b.date
where a.date>=current_date-1
group by 1,2,3,4