Skip to content

Instantly share code, notes, and snippets.

@harleyholt
Created March 17, 2014 23:39
Show Gist options
  • Save harleyholt/9610681 to your computer and use it in GitHub Desktop.
Save harleyholt/9610681 to your computer and use it in GitHub Desktop.
Retrieves the data we want to get from RedShift.
select
row_type_cd,
row_sub_type_cd,
date_pst,
publisher_id,
site_id,
case
when user_type_cd = 'C' then 'control'
when user_type_cd = 'T' then 'test'
else 'other'
end as user_type,
is_registered_user_flg,
'X' as is_new_registered_user_flg,
sum(value) as value,
max(dw_cycle_id) as dw_cycle_id
from
dw_prod_dm.rpt_levr_daily_pst
where
date_pst = '2014-02-18'
and row_type_cd in ('mau', 'dau')
group by
date_pst,
row_type_cd,
row_sub_type_cd,
publisher_id,
site_id,
user_type,
is_registered_user_flg,
is_new_registered_user_flg
order by
date_pst,
row_type_cd,
row_sub_type_cd,
publisher_id,
site_id,
user_type,
is_registered_user_flg,
is_new_registered_user_flg
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment