Convert following redshift SQL query to hive
with base as ( select [login to view URL]
,fcs.campaign_code||' : '||fcs.campaign_start_date||' : wk'||fcs.campaign_week_nbr||' then ' as cmp
,sum(bss.tot_sales_incld_gst-bss.tot_wow_dollar_incld_gst) as spend
from loyalty_bi_analytics.fact_campaign_sales fcs
left join loyalty.lylty_card_detail lcd
on fcs.crn=[login to view URL]
left join (select * from loyalty.basket_sales_summary where start_txn_date between '2019-10-07' and '2019-10-13') bss
on lcd.lylty_card_nbr=bss.lylty_card_nbr
where fcs.offer_start_date between '2019-10-07' and '2019-10-13'
and fcs.special_sales is NULL
and fcs.campaign_audience_type='T'
and fcs.redeem_flag is not NULL
group by 1,2
order by 1,2
)
,listy as ( select cmp
,row_number() over (order by cmp)
from base
group by 1
)
,agg as ( select [login to view URL]
,[login to view URL]
,listagg([login to view URL]) within group (order by [login to view URL], [login to view URL]) as path
-------------------------------------^^^
,count([login to view URL]) as pathorder
from base
left join listy
on listy.cmp=[login to view URL]
group by 1,2
)
,spendtab as ( select path
,pathorder
,count(crn) as records
,sum(spend) as sum_spend
from agg
group by 1,2
)
CREATE TABLE customer_spend_table
USING PARQUET
select *
from spendtab
My name is Sridhar. I am living in japan and I have 8 years of experience. Currently working with one of the big insurance company. I am responsible in data distribution to the banks. I am mainly using COBOL, SQL, PLSQL, ETL Hive, NiFi and Shell script.
Hello.
We are a team of freelancers with solid skills in our field.
We are experienced programmers and Java developers.
We are ready to work with you with high speed and quality.
Looking forward to it.
profiency in SQL and Hive
Thanks.