Skip to content

Instantly share code, notes, and snippets.

@kokosing
Created March 29, 2016 07:31
Show Gist options
  • Save kokosing/912782236d728b782a7d to your computer and use it in GitHub Desktop.
Save kokosing/912782236d728b782a7d to your computer and use it in GitHub Desktop.
*** q18.sql 2016-03-25 14:10:21.906553746 +0100
--- q18_modified.sql 2016-03-25 14:10:21.906553746 +0100
***************
*** 1,16 ****
 SELECT i_item_id,
 ca_country,
 ca_state,
 ca_county,
! avg(cast(cs_quantity AS numeric(12,2))) agg1,
! avg(cast(cs_list_price AS numeric(12,2))) agg2,
! avg(cast(cs_coupon_amt AS numeric(12,2))) agg3,
! avg(cast(cs_sales_price AS numeric(12,2))) agg4,
! avg(cast(cs_net_profit AS numeric(12,2))) agg5,
! avg(cast(c_birth_year AS numeric(12,2))) agg6,
! avg(cast(cd1.cd_dep_count AS numeric(12,2))) agg7
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".customer_demographics cd1,
 "${database}"."${schema}".customer_demographics cd2,
 "${database}"."${schema}".customer,
 "${database}"."${schema}".customer_address,
--- 1,16 ----
 SELECT i_item_id,
 ca_country,
 ca_state,
 ca_county,
! avg(cast(cs_quantity AS decimal(12,2))) agg1,
! avg(cast(cs_list_price AS decimal(12,2))) agg2,
! avg(cast(cs_coupon_amt AS decimal(12,2))) agg3,
! avg(cast(cs_sales_price AS decimal(12,2))) agg4,
! avg(cast(cs_net_profit AS decimal(12,2))) agg5,
! avg(cast(c_birth_year AS decimal(12,2))) agg6,
! avg(cast(cd1.cd_dep_count AS decimal(12,2))) agg7
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".customer_demographics cd1,
 "${database}"."${schema}".customer_demographics cd2,
 "${database}"."${schema}".customer,
 "${database}"."${schema}".customer_address,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment