Skip to content

Instantly share code, notes, and snippets.

@haydarai
Created December 8, 2018 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haydarai/5aa40a3e7e22d88ee47c850b9cc24a1f to your computer and use it in GitHub Desktop.
Save haydarai/5aa40a3e7e22d88ee47c850b9cc24a1f to your computer and use it in GitHub Desktop.
Web Returns
select date_dim.d_year, item.i_item_sk, reason.r_reason_desc, sum(wr_return_quantity) as quantity
from web_returns, date_dim, item, reason
where web_returns.wr_returned_date_sk = date_dim.d_date_sk
and web_returns.wr_item_sk = item.i_item_sk
and web_returns.wr_reason_sk = reason.r_reason_sk
group by cube(date_dim.d_year, item.i_item_sk, reason.r_reason_desc)
order by date_dim.d_year, i_item_sk, reason.r_reason_desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment