Skip to content

Instantly share code, notes, and snippets.

@kokosing
Created March 29, 2016 07:31
Show Gist options
  • Save kokosing/b71c87e44be5d3ad3c0f to your computer and use it in GitHub Desktop.
Save kokosing/b71c87e44be5d3ad3c0f to your computer and use it in GitHub Desktop.
*** q32.sql 2016-03-25 14:10:21.906553746 +0100
--- q32_modified.sql 2016-03-25 14:10:21.906553746 +0100
***************
*** 2,15 ****
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".item,
 "${database}"."${schema}".date_dim
 WHERE i_manufact_id = 284
 AND i_item_sk = cs_item_sk
! AND d_date BETWEEN '2001-01-07' AND (cast('2001-01-07' AS date) + 90 days)
 AND d_date_sk = cs_sold_date_sk
 AND cs_ext_discount_amt >
 (SELECT 1.3 * avg(cs_ext_discount_amt)
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".date_dim
 WHERE cs_item_sk = i_item_sk
! AND d_date BETWEEN '2001-01-07' AND (cast('2001-01-07' AS date) + 90 days)
 AND d_date_sk = cs_sold_date_sk) LIMIT 100;
--- 2,15 ----
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".item,
 "${database}"."${schema}".date_dim
 WHERE i_manufact_id = 284
 AND i_item_sk = cs_item_sk
! AND d_date BETWEEN '2001-01-07' AND (cast('2001-01-07' AS date) + INTERVAL '90' DAY)
 AND d_date_sk = cs_sold_date_sk
 AND cs_ext_discount_amt >
 (SELECT 1.3 * avg(cs_ext_discount_amt)
 FROM "${database}"."${schema}".catalog_sales,
 "${database}"."${schema}".date_dim
 WHERE cs_item_sk = i_item_sk
! AND d_date BETWEEN '2001-01-07' AND (cast('2001-01-07' AS date) + INTERVAL '90' DAY)
 AND d_date_sk = cs_sold_date_sk) LIMIT 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment