From edb24a37ad8175170124c34e8d1ddf956f256b83 Mon Sep 17 00:00:00 2001 From: Rongrong Zhu <113938689+rzIBM@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:08:06 -0400 Subject: [PATCH 01/20] perf: Add new version of stream run for 10TB from perf team (#78) * add new version of stream run for 10TB * add README.md in queries_v2 * add hyperlink to TPCDS_FIXES_SUMMARY_PRESTO.md * move README location --- benchmarks/tpc-ds/ds_4streams_v2_10000_1.json | 9 + benchmarks/tpc-ds/ds_4streams_v2_10000_2.json | 9 + benchmarks/tpc-ds/ds_8streams_v2_10000_1.json | 13 + benchmarks/tpc-ds/ds_8streams_v2_10000_2.json | 13 + benchmarks/tpc-ds/ds_power_v2_10000.json | 6 + benchmarks/tpc-ds/queries_v2/10000/s0/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s0/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s0/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s0/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s0/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s0/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s0/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s0/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s0/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s0/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s0/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s0/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s0/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s0/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s0/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s0/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s0/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s0/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s0/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s0/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s0/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s0/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s0/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s0/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s0/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s0/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s0/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s0/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s0/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s0/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s0/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s0/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s0/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s0/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s0/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s0/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s0/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s0/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s0/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s0/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s0/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s0/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s0/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s0/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s0/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s1/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s1/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s1/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s1/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s1/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s1/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s1/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s1/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s1/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s1/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s1/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s1/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s1/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s1/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s1/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s1/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s1/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s1/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s1/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s1/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s1/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s1/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s1/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s1/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s1/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s1/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s1/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s1/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s1/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s1/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s1/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s1/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s1/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s1/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s1/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s1/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s1/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s1/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s1/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s1/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s1/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s1/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s1/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s1/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s10/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s10/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s10/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s10/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s10/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s10/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s10/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s10/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s10/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s10/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s10/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s10/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s10/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s10/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s10/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s10/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s10/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s10/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s10/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s10/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s10/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s10/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s10/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s10/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s10/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s10/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s10/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s10/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s10/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s10/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s10/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s10/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s10/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s10/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s10/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s10/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s10/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s10/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s10/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s10/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s10/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s10/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s10/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s10/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s10/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s10/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s10/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s10/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s10/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s10/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s10/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s10/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s10/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s10/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s10/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s10/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s10/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s10/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s10/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s10/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s10/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s10/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s10/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s10/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s10/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s10/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s10/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s10/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s10/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s10/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s10/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s10/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s10/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s10/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s10/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s10/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s10/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s10/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s10/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s10/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s10/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s10/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s10/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s10/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s10/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s10/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s10/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s10/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s10/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s10/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s10/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s10/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s10/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s10/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s10/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s10/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s10/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s10/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s10/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s11/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s11/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s11/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s11/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s11/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s11/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s11/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s11/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s11/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s11/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s11/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s11/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s11/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s11/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s11/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s11/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s11/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s11/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s11/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s11/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s11/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s11/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s11/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s11/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s11/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s11/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s11/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s11/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s11/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s11/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s11/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s11/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s11/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s11/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s11/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s11/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s11/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s11/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s11/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s11/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s11/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s11/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s11/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s11/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s11/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s11/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s11/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s11/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s11/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s11/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s11/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s11/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s11/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s11/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s11/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s11/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s11/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s11/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s11/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s11/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s11/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s11/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s11/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s11/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s11/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s11/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s11/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s11/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s11/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s11/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s11/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s11/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s11/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s11/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s11/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s11/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s11/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s11/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s11/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s11/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s11/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s11/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s11/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s11/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s11/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s11/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s11/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s11/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s11/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s11/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s11/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s11/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s11/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s11/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s11/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s11/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s11/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s11/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s11/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s12/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s12/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s12/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s12/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s12/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s12/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s12/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s12/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s12/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s12/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s12/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s12/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s12/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s12/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s12/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s12/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s12/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s12/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s12/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s12/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s12/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s12/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s12/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s12/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s12/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s12/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s12/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s12/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s12/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s12/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s12/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s12/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s12/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s12/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s12/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s12/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s12/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s12/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s12/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s12/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s12/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s12/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s12/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s12/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s12/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s12/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s12/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s12/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s12/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s12/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s12/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s12/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s12/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s12/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s12/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s12/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s12/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s12/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s12/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s12/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s12/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s12/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s12/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s12/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s12/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s12/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s12/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s12/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s12/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s12/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s12/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s12/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s12/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s12/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s12/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s12/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s12/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s12/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s12/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s12/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s12/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s12/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s12/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s12/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s12/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s12/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s12/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s12/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s12/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s12/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s12/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s12/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s12/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s12/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s12/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s12/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s12/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s12/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s12/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s13/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s13/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s13/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s13/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s13/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s13/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s13/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s13/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s13/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s13/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s13/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s13/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s13/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s13/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s13/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s13/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s13/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s13/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s13/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s13/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s13/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s13/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s13/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s13/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s13/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s13/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s13/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s13/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s13/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s13/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s13/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s13/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s13/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s13/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s13/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s13/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s13/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s13/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s13/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s13/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s13/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s13/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s13/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s13/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s13/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s13/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s13/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s13/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s13/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s13/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s13/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s13/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s13/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s13/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s13/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s13/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s13/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s13/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s13/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s13/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s13/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s13/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s13/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s13/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s13/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s13/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s13/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s13/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s13/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s13/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s13/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s13/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s13/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s13/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s13/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s13/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s13/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s13/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s13/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s13/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s13/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s13/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s13/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s13/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s13/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s13/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s13/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s13/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s13/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s13/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s13/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s13/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s13/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s13/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s13/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s13/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s13/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s13/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s13/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s14/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s14/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s14/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s14/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s14/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s14/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s14/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s14/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s14/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s14/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s14/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s14/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s14/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s14/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s14/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s14/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s14/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s14/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s14/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s14/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s14/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s14/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s14/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s14/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s14/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s14/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s14/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s14/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s14/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s14/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s14/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s14/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s14/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s14/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s14/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s14/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s14/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s14/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s14/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s14/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s14/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s14/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s14/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s14/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s14/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s14/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s14/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s14/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s14/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s14/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s14/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s14/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s14/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s14/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s14/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s14/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s14/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s14/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s14/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s14/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s14/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s14/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s14/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s14/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s14/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s14/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s14/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s14/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s14/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s14/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s14/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s14/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s14/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s14/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s14/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s14/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s14/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s14/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s14/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s14/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s14/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s14/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s14/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s14/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s14/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s14/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s14/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s14/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s14/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s14/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s14/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s14/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s14/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s14/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s14/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s14/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s14/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s14/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s14/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s15/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s15/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s15/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s15/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s15/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s15/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s15/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s15/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s15/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s15/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s15/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s15/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s15/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s15/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s15/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s15/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s15/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s15/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s15/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s15/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s15/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s15/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s15/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s15/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s15/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s15/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s15/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s15/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s15/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s15/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s15/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s15/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s15/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s15/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s15/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s15/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s15/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s15/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s15/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s15/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s15/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s15/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s15/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s15/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s15/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s15/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s15/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s15/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s15/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s15/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s15/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s15/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s15/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s15/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s15/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s15/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s15/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s15/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s15/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s15/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s15/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s15/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s15/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s15/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s15/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s15/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s15/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s15/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s15/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s15/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s15/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s15/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s15/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s15/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s15/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s15/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s15/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s15/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s15/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s15/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s15/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s15/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s15/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s15/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s15/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s15/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s15/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s15/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s15/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s15/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s15/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s15/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s15/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s15/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s15/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s15/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s15/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s15/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s15/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s16/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s16/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s16/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s16/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s16/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s16/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s16/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s16/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s16/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s16/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s16/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s16/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s16/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s16/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s16/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s16/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s16/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s16/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s16/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s16/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s16/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s16/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s16/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s16/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s16/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s16/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s16/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s16/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s16/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s16/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s16/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s16/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s16/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s16/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s16/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s16/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s16/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s16/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s16/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s16/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s16/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s16/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s16/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s16/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s16/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s16/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s16/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s16/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s16/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s16/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s16/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s16/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s16/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s16/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s16/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s16/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s16/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s16/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s16/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s16/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s16/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s16/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s16/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s16/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s16/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s16/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s16/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s16/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s16/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s16/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s16/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s16/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s16/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s16/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s16/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s16/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s16/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s16/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s16/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s16/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s16/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s16/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s16/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s16/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s16/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s16/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s16/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s16/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s16/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s16/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s16/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s16/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s16/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s16/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s16/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s16/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s16/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s16/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s16/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s17/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s17/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s17/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s17/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s17/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s17/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s17/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s17/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s17/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s17/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s17/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s17/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s17/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s17/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s17/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s17/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s17/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s17/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s17/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s17/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s17/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s17/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s17/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s17/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s17/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s17/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s17/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s17/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s17/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s17/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s17/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s17/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s17/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s17/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s17/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s17/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s17/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s17/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s17/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s17/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s17/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s17/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s17/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s17/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s17/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s17/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s17/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s17/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s17/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s17/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s17/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s17/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s17/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s17/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s17/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s17/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s17/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s17/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s17/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s17/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s17/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s17/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s17/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s17/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s17/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s17/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s17/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s17/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s17/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s17/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s17/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s17/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s17/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s17/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s17/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s17/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s17/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s17/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s17/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s17/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s17/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s17/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s17/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s17/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s17/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s17/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s17/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s17/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s17/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s17/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s17/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s17/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s17/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s17/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s17/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s17/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s17/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s17/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s17/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s18/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s18/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s18/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s18/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s18/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s18/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s18/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s18/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s18/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s18/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s18/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s18/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s18/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s18/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s18/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s18/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s18/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s18/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s18/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s18/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s18/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s18/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s18/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s18/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s18/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s18/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s18/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s18/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s18/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s18/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s18/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s18/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s18/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s18/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s18/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s18/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s18/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s18/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s18/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s18/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s18/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s18/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s18/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s18/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s18/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s18/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s18/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s18/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s18/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s18/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s18/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s18/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s18/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s18/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s18/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s18/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s18/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s18/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s18/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s18/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s18/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s18/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s18/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s18/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s18/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s18/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s18/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s18/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s18/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s18/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s18/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s18/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s18/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s18/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s18/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s18/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s18/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s18/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s18/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s18/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s18/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s18/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s18/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s18/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s18/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s18/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s18/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s18/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s18/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s18/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s18/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s18/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s18/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s18/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s18/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s18/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s18/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s18/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s18/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s19/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s19/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s19/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s19/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s19/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s19/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s19/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s19/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s19/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s19/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s19/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s19/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s19/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s19/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s19/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s19/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s19/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s19/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s19/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s19/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s19/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s19/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s19/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s19/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s19/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s19/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s19/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s19/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s19/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s19/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s19/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s19/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s19/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s19/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s19/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s19/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s19/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s19/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s19/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s19/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s19/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s19/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s19/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s19/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s19/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s19/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s19/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s19/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s19/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s19/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s19/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s19/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s19/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s19/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s19/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s19/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s19/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s19/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s19/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s19/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s19/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s19/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s19/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s19/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s19/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s19/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s19/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s19/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s19/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s19/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s19/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s19/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s19/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s19/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s19/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s19/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s19/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s19/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s19/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s19/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s19/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s19/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s19/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s19/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s19/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s19/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s19/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s19/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s19/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s19/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s19/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s19/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s19/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s19/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s19/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s19/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s19/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s19/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s19/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s2/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s2/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s2/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s2/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s2/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s2/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s2/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s2/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s2/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s2/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s2/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s2/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s2/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s2/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s2/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s2/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s2/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s2/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s2/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s2/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s2/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s2/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s2/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s2/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s2/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s2/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s2/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s2/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s2/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s2/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s2/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s2/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s2/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s2/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s2/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s2/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s2/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s2/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s2/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s2/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s2/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s2/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s2/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s2/q99.sql | 34 ++ .../tpc-ds/queries_v2/10000/s20/q01.sql | 24 + .../tpc-ds/queries_v2/10000/s20/q02.sql | 59 +++ .../tpc-ds/queries_v2/10000/s20/q03.sql | 20 + .../tpc-ds/queries_v2/10000/s20/q04.sql | 115 +++++ .../tpc-ds/queries_v2/10000/s20/q05.sql | 127 +++++ .../tpc-ds/queries_v2/10000/s20/q06.sql | 25 + .../tpc-ds/queries_v2/10000/s20/q07.sql | 20 + .../tpc-ds/queries_v2/10000/s20/q08.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s20/q09.sql | 50 ++ .../tpc-ds/queries_v2/10000/s20/q10.sql | 58 +++ .../tpc-ds/queries_v2/10000/s20/q11.sql | 80 +++ .../tpc-ds/queries_v2/10000/s20/q12.sql | 33 ++ .../tpc-ds/queries_v2/10000/s20/q13.sql | 51 ++ .../tpc-ds/queries_v2/10000/s20/q14.sql | 209 ++++++++ .../tpc-ds/queries_v2/10000/s20/q15.sql | 19 + .../tpc-ds/queries_v2/10000/s20/q16.sql | 30 ++ .../tpc-ds/queries_v2/10000/s20/q17.sql | 44 ++ .../tpc-ds/queries_v2/10000/s20/q18.sql | 33 ++ .../tpc-ds/queries_v2/10000/s20/q19.sql | 24 + .../tpc-ds/queries_v2/10000/s20/q20.sql | 29 ++ .../tpc-ds/queries_v2/10000/s20/q21.sql | 29 ++ .../tpc-ds/queries_v2/10000/s20/q22.sql | 19 + .../tpc-ds/queries_v2/10000/s20/q23.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s20/q24.sql | 106 ++++ .../tpc-ds/queries_v2/10000/s20/q25.sql | 47 ++ .../tpc-ds/queries_v2/10000/s20/q26.sql | 20 + .../tpc-ds/queries_v2/10000/s20/q27.sql | 22 + .../tpc-ds/queries_v2/10000/s20/q28.sql | 52 ++ .../tpc-ds/queries_v2/10000/s20/q29.sql | 46 ++ .../tpc-ds/queries_v2/10000/s20/q30.sql | 30 ++ .../tpc-ds/queries_v2/10000/s20/q31.sql | 51 ++ .../tpc-ds/queries_v2/10000/s20/q32.sql | 27 + .../tpc-ds/queries_v2/10000/s20/q33.sql | 74 +++ .../tpc-ds/queries_v2/10000/s20/q34.sql | 30 ++ .../tpc-ds/queries_v2/10000/s20/q35.sql | 57 +++ .../tpc-ds/queries_v2/10000/s20/q36.sql | 29 ++ .../tpc-ds/queries_v2/10000/s20/q37.sql | 16 + .../tpc-ds/queries_v2/10000/s20/q38.sql | 22 + .../tpc-ds/queries_v2/10000/s20/q39.sql | 53 ++ .../tpc-ds/queries_v2/10000/s20/q40.sql | 27 + .../tpc-ds/queries_v2/10000/s20/q41.sql | 51 ++ .../tpc-ds/queries_v2/10000/s20/q42.sql | 21 + .../tpc-ds/queries_v2/10000/s20/q43.sql | 18 + .../tpc-ds/queries_v2/10000/s20/q44.sql | 34 ++ .../tpc-ds/queries_v2/10000/s20/q45.sql | 19 + .../tpc-ds/queries_v2/10000/s20/q46.sql | 34 ++ .../tpc-ds/queries_v2/10000/s20/q47.sql | 50 ++ .../tpc-ds/queries_v2/10000/s20/q48.sql | 66 +++ .../tpc-ds/queries_v2/10000/s20/q49.sql | 128 +++++ .../tpc-ds/queries_v2/10000/s20/q50.sql | 58 +++ .../tpc-ds/queries_v2/10000/s20/q51.sql | 44 ++ .../tpc-ds/queries_v2/10000/s20/q52.sql | 21 + .../tpc-ds/queries_v2/10000/s20/q53.sql | 27 + .../tpc-ds/queries_v2/10000/s20/q54.sql | 55 ++ .../tpc-ds/queries_v2/10000/s20/q55.sql | 13 + .../tpc-ds/queries_v2/10000/s20/q56.sql | 68 +++ .../tpc-ds/queries_v2/10000/s20/q57.sql | 47 ++ .../tpc-ds/queries_v2/10000/s20/q58.sql | 64 +++ .../tpc-ds/queries_v2/10000/s20/q59.sql | 43 ++ .../tpc-ds/queries_v2/10000/s20/q60.sql | 77 +++ .../tpc-ds/queries_v2/10000/s20/q61.sql | 43 ++ .../tpc-ds/queries_v2/10000/s20/q62.sql | 34 ++ .../tpc-ds/queries_v2/10000/s20/q63.sql | 28 + .../tpc-ds/queries_v2/10000/s20/q64.sql | 120 +++++ .../tpc-ds/queries_v2/10000/s20/q65.sql | 28 + .../tpc-ds/queries_v2/10000/s20/q66.sql | 219 ++++++++ .../tpc-ds/queries_v2/10000/s20/q67.sql | 43 ++ .../tpc-ds/queries_v2/10000/s20/q68.sql | 41 ++ .../tpc-ds/queries_v2/10000/s20/q69.sql | 46 ++ .../tpc-ds/queries_v2/10000/s20/q70.sql | 37 ++ .../tpc-ds/queries_v2/10000/s20/q71.sql | 39 ++ .../tpc-ds/queries_v2/10000/s20/q72.sql | 28 + .../tpc-ds/queries_v2/10000/s20/q73.sql | 27 + .../tpc-ds/queries_v2/10000/s20/q74.sql | 60 +++ .../tpc-ds/queries_v2/10000/s20/q75.sql | 69 +++ .../tpc-ds/queries_v2/10000/s20/q76.sql | 23 + .../tpc-ds/queries_v2/10000/s20/q77.sql | 107 ++++ .../tpc-ds/queries_v2/10000/s20/q78.sql | 57 +++ .../tpc-ds/queries_v2/10000/s20/q79.sql | 22 + .../tpc-ds/queries_v2/10000/s20/q80.sql | 95 ++++ .../tpc-ds/queries_v2/10000/s20/q81.sql | 30 ++ .../tpc-ds/queries_v2/10000/s20/q82.sql | 16 + .../tpc-ds/queries_v2/10000/s20/q83.sql | 66 +++ .../tpc-ds/queries_v2/10000/s20/q84.sql | 20 + .../tpc-ds/queries_v2/10000/s20/q85.sql | 83 +++ .../tpc-ds/queries_v2/10000/s20/q86.sql | 25 + .../tpc-ds/queries_v2/10000/s20/q87.sql | 22 + .../tpc-ds/queries_v2/10000/s20/q88.sql | 93 ++++ .../tpc-ds/queries_v2/10000/s20/q89.sql | 27 + .../tpc-ds/queries_v2/10000/s20/q90.sql | 21 + .../tpc-ds/queries_v2/10000/s20/q91.sql | 30 ++ .../tpc-ds/queries_v2/10000/s20/q92.sql | 29 ++ .../tpc-ds/queries_v2/10000/s20/q93.sql | 17 + .../tpc-ds/queries_v2/10000/s20/q94.sql | 28 + .../tpc-ds/queries_v2/10000/s20/q95.sql | 31 ++ .../tpc-ds/queries_v2/10000/s20/q96.sql | 15 + .../tpc-ds/queries_v2/10000/s20/q97.sql | 24 + .../tpc-ds/queries_v2/10000/s20/q98.sql | 32 ++ .../tpc-ds/queries_v2/10000/s20/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s3/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s3/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s3/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s3/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s3/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s3/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s3/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s3/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s3/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s3/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s3/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s3/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s3/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s3/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s3/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s3/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s3/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s3/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s3/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s3/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s3/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s3/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s3/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s3/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s3/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s3/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s3/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s3/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s3/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s3/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s3/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s3/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s3/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s3/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s3/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s3/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s3/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s3/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s3/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s3/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s3/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s3/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s3/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s3/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s4/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s4/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s4/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s4/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s4/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s4/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s4/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s4/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s4/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s4/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s4/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s4/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s4/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s4/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s4/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s4/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s4/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s4/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s4/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s4/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s4/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s4/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s4/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s4/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s4/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s4/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s4/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s4/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s4/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s4/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s4/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s4/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s4/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s4/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s4/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s4/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s4/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s4/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s4/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s4/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s4/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s4/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s4/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s4/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s5/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s5/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s5/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s5/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s5/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s5/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s5/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s5/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s5/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s5/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s5/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s5/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s5/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s5/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s5/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s5/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s5/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s5/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s5/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s5/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s5/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s5/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s5/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s5/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s5/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s5/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s5/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s5/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s5/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s5/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s5/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s5/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s5/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s5/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s5/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s5/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s5/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s5/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s5/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s5/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s5/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s5/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s5/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s5/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s6/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s6/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s6/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s6/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s6/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s6/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s6/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s6/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s6/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s6/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s6/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s6/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s6/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s6/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s6/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s6/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s6/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s6/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s6/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s6/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s6/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s6/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s6/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s6/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s6/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s6/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s6/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s6/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s6/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s6/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s6/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s6/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s6/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s6/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s6/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s6/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s6/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s6/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s6/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s6/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s6/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s6/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s6/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s6/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s7/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s7/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s7/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s7/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s7/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s7/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s7/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s7/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s7/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s7/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s7/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s7/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s7/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s7/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s7/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s7/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s7/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s7/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s7/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s7/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s7/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s7/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s7/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s7/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s7/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s7/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s7/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s7/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s7/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s7/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s7/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s7/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s7/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s7/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s7/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s7/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s7/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s7/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s7/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s7/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s7/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s7/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s7/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s7/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s8/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s8/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s8/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s8/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s8/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s8/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s8/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s8/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s8/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s8/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s8/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s8/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s8/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s8/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s8/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s8/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s8/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s8/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s8/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s8/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s8/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s8/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s8/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s8/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s8/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s8/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s8/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s8/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s8/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s8/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s8/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s8/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s8/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s8/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s8/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s8/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s8/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s8/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s8/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s8/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s8/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s8/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s8/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s8/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q01.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s9/q02.sql | 59 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q03.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s9/q04.sql | 115 +++++ benchmarks/tpc-ds/queries_v2/10000/s9/q05.sql | 127 +++++ benchmarks/tpc-ds/queries_v2/10000/s9/q06.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s9/q07.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s9/q08.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q09.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q10.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q11.sql | 80 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q12.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q13.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q14.sql | 209 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s9/q15.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s9/q16.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q17.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q18.sql | 33 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q19.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s9/q20.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q21.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q22.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s9/q23.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q24.sql | 106 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q25.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q26.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s9/q27.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s9/q28.sql | 52 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q29.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q30.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q31.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q32.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s9/q33.sql | 74 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q34.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q35.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q36.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q37.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s9/q38.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s9/q39.sql | 53 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q40.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s9/q41.sql | 51 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q42.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s9/q43.sql | 18 + benchmarks/tpc-ds/queries_v2/10000/s9/q44.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q45.sql | 19 + benchmarks/tpc-ds/queries_v2/10000/s9/q46.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q47.sql | 50 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q48.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q49.sql | 128 +++++ benchmarks/tpc-ds/queries_v2/10000/s9/q50.sql | 58 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q51.sql | 44 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q52.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s9/q53.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s9/q54.sql | 55 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q55.sql | 13 + benchmarks/tpc-ds/queries_v2/10000/s9/q56.sql | 68 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q57.sql | 47 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q58.sql | 64 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q59.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q60.sql | 77 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q61.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q62.sql | 34 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q63.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s9/q64.sql | 120 +++++ benchmarks/tpc-ds/queries_v2/10000/s9/q65.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s9/q66.sql | 219 ++++++++ benchmarks/tpc-ds/queries_v2/10000/s9/q67.sql | 43 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q68.sql | 41 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q69.sql | 46 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q70.sql | 37 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q71.sql | 39 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q72.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s9/q73.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s9/q74.sql | 60 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q75.sql | 69 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q76.sql | 23 + benchmarks/tpc-ds/queries_v2/10000/s9/q77.sql | 107 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q78.sql | 57 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q79.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s9/q80.sql | 95 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q81.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q82.sql | 16 + benchmarks/tpc-ds/queries_v2/10000/s9/q83.sql | 66 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q84.sql | 20 + benchmarks/tpc-ds/queries_v2/10000/s9/q85.sql | 83 +++ benchmarks/tpc-ds/queries_v2/10000/s9/q86.sql | 25 + benchmarks/tpc-ds/queries_v2/10000/s9/q87.sql | 22 + benchmarks/tpc-ds/queries_v2/10000/s9/q88.sql | 93 ++++ benchmarks/tpc-ds/queries_v2/10000/s9/q89.sql | 27 + benchmarks/tpc-ds/queries_v2/10000/s9/q90.sql | 21 + benchmarks/tpc-ds/queries_v2/10000/s9/q91.sql | 30 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q92.sql | 29 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q93.sql | 17 + benchmarks/tpc-ds/queries_v2/10000/s9/q94.sql | 28 + benchmarks/tpc-ds/queries_v2/10000/s9/q95.sql | 31 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q96.sql | 15 + benchmarks/tpc-ds/queries_v2/10000/s9/q97.sql | 24 + benchmarks/tpc-ds/queries_v2/10000/s9/q98.sql | 32 ++ benchmarks/tpc-ds/queries_v2/10000/s9/q99.sql | 34 ++ benchmarks/tpc-ds/queries_v2/README.md | 45 ++ .../queries_v2/TPCDS_FIXES_SUMMARY_PRESTO.md | 482 ++++++++++++++++++ benchmarks/tpc-ds/streams_v2/10000/s0.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s1.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s10.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s11.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s12.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s13.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s14.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s15.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s16.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s17.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s18.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s19.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s2.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s20.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s3.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s4.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s5.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s6.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s7.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s8.json | 104 ++++ benchmarks/tpc-ds/streams_v2/10000/s9.json | 104 ++++ 2107 files changed, 102868 insertions(+) create mode 100644 benchmarks/tpc-ds/ds_4streams_v2_10000_1.json create mode 100644 benchmarks/tpc-ds/ds_4streams_v2_10000_2.json create mode 100644 benchmarks/tpc-ds/ds_8streams_v2_10000_1.json create mode 100644 benchmarks/tpc-ds/ds_8streams_v2_10000_2.json create mode 100644 benchmarks/tpc-ds/ds_power_v2_10000.json create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s0/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s1/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s10/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s11/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s12/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s13/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s14/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s15/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s16/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s17/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s18/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s19/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s2/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s20/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s3/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s4/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s5/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s6/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s7/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s8/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q01.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q02.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q03.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q04.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q05.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q06.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q07.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q08.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q09.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q10.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q11.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q12.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q13.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q14.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q15.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q16.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q17.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q18.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q19.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q20.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q21.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q22.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q23.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q24.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q25.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q26.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q27.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q28.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q29.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q30.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q31.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q32.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q33.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q34.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q35.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q36.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q37.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q38.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q39.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q40.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q41.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q42.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q43.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q44.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q45.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q46.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q47.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q48.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q49.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q50.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q51.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q52.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q53.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q54.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q55.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q56.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q57.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q58.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q59.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q60.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q61.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q62.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q63.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q64.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q65.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q66.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q67.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q68.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q69.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q70.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q71.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q72.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q73.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q74.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q75.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q76.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q77.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q78.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q79.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q80.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q81.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q82.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q83.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q84.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q85.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q86.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q87.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q88.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q89.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q90.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q91.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q92.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q93.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q94.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q95.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q96.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q97.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q98.sql create mode 100644 benchmarks/tpc-ds/queries_v2/10000/s9/q99.sql create mode 100644 benchmarks/tpc-ds/queries_v2/README.md create mode 100644 benchmarks/tpc-ds/queries_v2/TPCDS_FIXES_SUMMARY_PRESTO.md create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s0.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s1.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s10.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s11.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s12.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s13.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s14.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s15.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s16.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s17.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s18.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s19.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s2.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s20.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s3.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s4.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s5.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s6.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s7.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s8.json create mode 100644 benchmarks/tpc-ds/streams_v2/10000/s9.json diff --git a/benchmarks/tpc-ds/ds_4streams_v2_10000_1.json b/benchmarks/tpc-ds/ds_4streams_v2_10000_1.json new file mode 100644 index 00000000..ab45c978 --- /dev/null +++ b/benchmarks/tpc-ds/ds_4streams_v2_10000_1.json @@ -0,0 +1,9 @@ +{ + "description": "Run 4 parallel queries streams starting from s1 (s1 to s4) defined in the TPC-DS spec Appendix D: Query Ordering.", + "next": [ + "streams_v2/10000/s1.json", + "streams_v2/10000/s2.json", + "streams_v2/10000/s3.json", + "streams_v2/10000/s4.json" + ] +} diff --git a/benchmarks/tpc-ds/ds_4streams_v2_10000_2.json b/benchmarks/tpc-ds/ds_4streams_v2_10000_2.json new file mode 100644 index 00000000..bc515c9a --- /dev/null +++ b/benchmarks/tpc-ds/ds_4streams_v2_10000_2.json @@ -0,0 +1,9 @@ +{ + "description": "Run 4 parallel queries streams starting from s5 (s5 to s8) defined in the TPC-DS spec Appendix D: Query Ordering.", + "next": [ + "streams_v2/10000/s5.json", + "streams_v2/10000/s6.json", + "streams_v2/10000/s7.json", + "streams_v2/10000/s8.json" + ] +} diff --git a/benchmarks/tpc-ds/ds_8streams_v2_10000_1.json b/benchmarks/tpc-ds/ds_8streams_v2_10000_1.json new file mode 100644 index 00000000..3613f728 --- /dev/null +++ b/benchmarks/tpc-ds/ds_8streams_v2_10000_1.json @@ -0,0 +1,13 @@ +{ + "description": "Run 8 parallel queries streams starting from s1 (s1 to s8) defined in the TPC-DS spec Appendix D: Query Ordering.", + "next": [ + "streams_v2/10000/s1.json", + "streams_v2/10000/s2.json", + "streams_v2/10000/s3.json", + "streams_v2/10000/s4.json", + "streams_v2/10000/s5.json", + "streams_v2/10000/s6.json", + "streams_v2/10000/s7.json", + "streams_v2/10000/s8.json" + ] +} diff --git a/benchmarks/tpc-ds/ds_8streams_v2_10000_2.json b/benchmarks/tpc-ds/ds_8streams_v2_10000_2.json new file mode 100644 index 00000000..cfd004b6 --- /dev/null +++ b/benchmarks/tpc-ds/ds_8streams_v2_10000_2.json @@ -0,0 +1,13 @@ +{ + "description": "Run 8 parallel queries streams starting from s9 (s9 to s16) defined in the TPC-DS spec Appendix D: Query Ordering.", + "next": [ + "streams_v2/10000/s9.json", + "streams_v2/10000/s10.json", + "streams_v2/10000/s11.json", + "streams_v2/10000/s12.json", + "streams_v2/10000/s13.json", + "streams_v2/10000/s14.json", + "streams_v2/10000/s15.json", + "streams_v2/10000/s16.json" + ] +} diff --git a/benchmarks/tpc-ds/ds_power_v2_10000.json b/benchmarks/tpc-ds/ds_power_v2_10000.json new file mode 100644 index 00000000..079cd226 --- /dev/null +++ b/benchmarks/tpc-ds/ds_power_v2_10000.json @@ -0,0 +1,6 @@ +{ + "description": "Run the first 1 parallel queries streams defined in the TPC-DS spec Appendix D: Query Ordering.", + "next": [ + "streams_v2/10000/s0.json" + ] +} diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q01.sql new file mode 100644 index 00000000..051fba74 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'IN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q02.sql new file mode 100644 index 00000000..6b85da0a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2001) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2001+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q03.sql new file mode 100644 index 00000000..75fe15a6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 977 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q04.sql new file mode 100644 index 00000000..4632dc72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_c_firstyear.dyear = 2001 + and t_c_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q05.sql new file mode 100644 index 00000000..663e2d65 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1999-08-10' as date) + and (cast('1999-08-10' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1999-08-10' as date) + and (cast('1999-08-10' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1999-08-10' as date) + and (cast('1999-08-10' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q06.sql new file mode 100644 index 00000000..8d22306c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 1999 + and d_moy = 4 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q07.sql new file mode 100644 index 00000000..ef3b29c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q08.sql new file mode 100644 index 00000000..2e248c83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '70915','38588','55840','29153','53472','43379', + '71206','97823','73593','37640','53830', + '34131','22137','36227','69226','38637', + '25034','74253','79335','81824','26928', + '95379','12074','94055','52635','32678', + '71486','33375','18620','60826','25249', + '90870','47334','39172','56625','48860', + '53180','63354','53819','29299','83885', + '89388','89889','38581','15657','14528', + '29225','60241','23923','62045','42487', + '82577','80732','40293','45690','34859', + '71782','74650','44125','33254','99726', + '23087','27568','38352','33132','17547', + '47099','38356','53600','74389','69552', + '60131','20062','94630','34410','97094', + '92305','18128','62218','84444','86263', + '77483','28203','56547','33912','31950', + '21612','46808','40453','25475','34377', + '38914','47306','10403','32874','28771', + '70767','65067','22464','92304','22631', + '41161','88640','61291','61625','97137', + '99673','89108','58909','21152','68121', + '30932','26408','88925','15354','50749', + '51942','33660','15723','64527','30958', + '13168','88825','38761','56901','44705', + '86175','79789','94493','36775','81819', + '62990','55956','22090','29397','63838', + '67427','35624','38988','41424','26440', + '61249','27204','23915','36872','81966', + '69018','49048','16811','50464','94874', + '42760','82925','49214','25482','50115', + '52509','59531','64324','62941','59504', + '31609','92511','62208','29036','10728', + '11724','23639','10592','20715','35200', + '67631','48678','88779','54460','11782', + '12674','33562','72770','12474','40957', + '51971','68765','60702','87385','57122', + '12242','34141','50817','21734','74660', + '99863','43778','72354','51922','28612', + '81350','57161','36740','48536','39330', + '34324','22975','27002','31677','73233', + '76820','80298','36823','72397','36457', + '76004','47478','25882','11094','27048', + '59361','78959','33189','59556','67073', + '81602','80895','48186','70981','15511', + '33372','46606','62807','48958','16385', + '43207','12505','13460','67195','25240', + '41885','49575','70744','67214','95159', + '92730','11216','82321','11142','77666', + '57519','62605','45784','13221','10967', + '70469','39959','46320','58200','70252', + '45659','84161','28726','99282','15702', + '86043','24687','35026','10669','47479', + '13632','30678','56655','60571','85518', + '48697','41004','41572','91509','94685', + '79875','24822','73111','34700','19567', + '26952','73629','32213','10894','67139', + '80604','76680','89616','57056','32176', + '80314','26172','70476','77057','27782', + '86010','96638','29143','31223','35703', + '10542','21206','54298','46162','43344', + '74344','73437','14066','48420','92098', + '72816','63781','46363','73362','13893', + '13280','97259','12037','70086','56107', + '80438','22793','19584','68236','68757', + '78734','19730','34932','34137','36939', + '96573','78846','35073','24639','15813', + '82893','50459','14629','26431','58436', + '44824','63593','92678','13604','16569', + '53690','28590','36315','35360','31860', + '44753','21432','63823','37328','84608', + '80573','71418','43081','83672','58562', + '31680','21660','89355','90245','57213', + '22779','95762','75277','55039','48285', + '66347','69973','50509','15207','90438', + '26219','89140','72350','27328','20464', + '26498','76372','10179','19587','40647', + '59201','26546','37203','13442','63001', + '45086','87286','74287','89908','16014', + '55191','33353','62463','53801') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q09.sql new file mode 100644 index 00000000..9ac8bd99 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 469338863 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 11642561 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 316706005 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 83431110 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 218839369 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q10.sql new file mode 100644 index 00000000..7d1a5d95 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Hamilton County','Jefferson County','Cherokee County','Nowata County','Van Buren County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q11.sql new file mode 100644 index 00000000..bc470b14 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q12.sql new file mode 100644 index 00000000..e2e521a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Jewelry', 'Men', 'Home') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2002-05-15' as date) + and (cast('2002-05-15' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q13.sql new file mode 100644 index 00000000..7c13223b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = 'College' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Secondary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('OH', 'AL', 'IN') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('KS', 'GA', 'MN') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NC', 'TX', 'NY') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q14.sql new file mode 100644 index 00000000..bfc9a7f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 15) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 15) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q15.sql new file mode 100644 index 00000000..6c2c4f5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1998 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q16.sql new file mode 100644 index 00000000..bae9966e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-4-01' and + (cast('1999-4-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'MI' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Richland County','Oglethorpe County','Luce County','Jackson County', + 'Franklin Parish' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q17.sql new file mode 100644 index 00000000..9501ed6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1998Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q18.sql new file mode 100644 index 00000000..d2fb83fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Secondary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (4,12,10,8,7,1) and + d_year = 2001 and + ca_state in ('SC','MS','OK' + ,'IA','MN','PA','ND') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q19.sql new file mode 100644 index 00000000..4d2f8e76 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=23 + and d_moy=11 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q20.sql new file mode 100644 index 00000000..6b2cd65d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Women', 'Children', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-01-27' as date) + and (cast('1998-01-27' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q21.sql new file mode 100644 index 00000000..ffa63a69 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-04-20' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2001-04-20' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2001-04-20' as date) - INTERVAL '30' DAY) + and (cast ('2001-04-20' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q22.sql new file mode 100644 index 00000000..c387e52c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1198 and 1198 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q23.sql new file mode 100644 index 00000000..04917e0f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1999 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1999 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q24.sql new file mode 100644 index 00000000..fddf46a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'rose' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'orange' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q25.sql new file mode 100644 index 00000000..14661241 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q26.sql new file mode 100644 index 00000000..66ca9ae5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q27.sql new file mode 100644 index 00000000..c804d6dd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = 'Secondary' and + d_year = 1998 and + s_state in ('SD','MO', 'MN', 'NC', 'MI', 'IL') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q28.sql new file mode 100644 index 00000000..5c572eeb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 164 and 164+10 + or ss_coupon_amt between 13887 and 13887+1000 + or ss_wholesale_cost between 9 and 9+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 32 and 32+10 + or ss_coupon_amt between 6223 and 6223+1000 + or ss_wholesale_cost between 54 and 54+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 123 and 123+10 + or ss_coupon_amt between 855 and 855+1000 + or ss_wholesale_cost between 16 and 16+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 188 and 188+10 + or ss_coupon_amt between 2857 and 2857+1000 + or ss_wholesale_cost between 68 and 68+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 143 and 143+10 + or ss_coupon_amt between 3514 and 3514+1000 + or ss_wholesale_cost between 51 and 51+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 158 and 158+10 + or ss_coupon_amt between 12933 and 12933+1000 + or ss_wholesale_cost between 65 and 65+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q29.sql new file mode 100644 index 00000000..3ec859d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q30.sql new file mode 100644 index 00000000..9b49bb13 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MT' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q31.sql new file mode 100644 index 00000000..325746a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2001 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2001 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2001 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2001 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2001 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2001 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by web_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q32.sql new file mode 100644 index 00000000..6bbe8f2b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 42 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-01-07' and + (cast('1998-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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-01-07' and + (cast('1998-01-07' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q33.sql new file mode 100644 index 00000000..0053d61e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q34.sql new file mode 100644 index 00000000..1ad268b2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Maverick County','Levy County','Nuckolls County','Montgomery County', + 'Harper County','Green Lake County','Walker County','West Feliciana Parish') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q35.sql new file mode 100644 index 00000000..14095f38 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + max(cd_dep_count) aggtwo1, + max(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + max(cd_dep_employed_count) aggtwo2, + max(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + max(cd_dep_college_count) aggtwo3, + max(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q36.sql new file mode 100644 index 00000000..7c2fa9ff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('IN','AL','MI','LA', + 'PA','IN','KS','NE') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q37.sql new file mode 100644 index 00000000..3c8b6421 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 32 and 32 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-05-24' as date) and (cast('1999-05-24' as date) + INTERVAL '60' DAY) + and i_manufact_id in (718,740,728,776) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q38.sql new file mode 100644 index 00000000..5003c143 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q39.sql new file mode 100644 index 00000000..f187d8bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2001 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2001 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q40.sql new file mode 100644 index 00000000..f2ac8190 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-02-22' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-02-22' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-02-22' as date) - INTERVAL '30' DAY) + and (cast ('1998-02-22' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q41.sql new file mode 100644 index 00000000..9b6d817f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 746 and 746+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'magenta' or i_color = 'aquamarine') and + (i_units = 'Oz' or i_units = 'Dram') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'antique' or i_color = 'honeydew') and + (i_units = 'Pallet' or i_units = 'Bunch') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'dark' or i_color = 'dim') and + (i_units = 'Each' or i_units = 'Dozen') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'purple' or i_color = 'plum') and + (i_units = 'Tsp' or i_units = 'Cup') and + (i_size = 'small' or i_size = 'economy') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'cream' or i_color = 'chiffon') and + (i_units = 'Unknown' or i_units = 'Ton') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'lime' or i_color = 'cornsilk') and + (i_units = 'Gross' or i_units = 'Box') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'green' or i_color = 'blush') and + (i_units = 'Carton' or i_units = 'Pound') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'floral' or i_color = 'red') and + (i_units = 'Case' or i_units = 'Gram') and + (i_size = 'small' or i_size = 'economy') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q42.sql new file mode 100644 index 00000000..13d30602 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q43.sql new file mode 100644 index 00000000..f5ba0d61 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -7 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q44.sql new file mode 100644 index 00000000..8dec959b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 271 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 271 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 271 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 271 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q45.sql new file mode 100644 index 00000000..6ffaded3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q46.sql new file mode 100644 index 00000000..420bdafa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 2 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Greenfield','Mount Zion','Williamsburg','Hopewell','Hollywood') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q47.sql new file mode 100644 index 00000000..fccc4169 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name, v1.s_company_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q48.sql new file mode 100644 index 00000000..7a0d0445 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2000 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Primary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'College' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('KS', 'SD', 'GA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'IA', 'WY') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MS', 'IL', 'NE') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q49.sql new file mode 100644 index 00000000..0c9e2dd3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q50.sql new file mode 100644 index 00000000..7a9a5faa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q51.sql new file mode 100644 index 00000000..e608c72b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1189 and 1189+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1189 and 1189+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q52.sql new file mode 100644 index 00000000..4533bf32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1998 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q53.sql new file mode 100644 index 00000000..7a2f997a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1193,1193+1,1193+2,1193+3,1193+4,1193+5,1193+6,1193+7,1193+8,1193+9,1193+10,1193+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q54.sql new file mode 100644 index 00000000..d2a412e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Home' + and i_class = 'glassware' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 5 + and d_year = 2000 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2000 and d_moy = 5) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2000 and d_moy = 5) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q55.sql new file mode 100644 index 00000000..e737685e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=72 + and d_moy=11 + and d_year=2000 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q56.sql new file mode 100644 index 00000000..cbb1d47d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('burlywood','lemon','rosy')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('burlywood','lemon','rosy')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('burlywood','lemon','rosy')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q57.sql new file mode 100644 index 00000000..3e7e33c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q58.sql new file mode 100644 index 00000000..16addd55 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-04-16')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-04-16')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2000-04-16')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q59.sql new file mode 100644 index 00000000..87fad795 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1199 and 1199 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1199+ 12 and 1199 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q60.sql new file mode 100644 index 00000000..63a78516 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q61.sql new file mode 100644 index 00000000..2dc79663 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q62.sql new file mode 100644 index 00000000..2a143709 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1184 and 1184 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q63.sql new file mode 100644 index 00000000..e8ab3ed7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1215,1215+1,1215+2,1215+3,1215+4,1215+5,1215+6,1215+7,1215+8,1215+9,1215+10,1215+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q64.sql new file mode 100644 index 00000000..bd218d4b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('slate','dim','hot','tan','antique','deep') and + i_current_price between 46 and 46 + 10 and + i_current_price between 46 + 1 and 46 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q65.sql new file mode 100644 index 00000000..6f85c260 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1199 and 1199+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1199 and 1199+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q66.sql new file mode 100644 index 00000000..f749889d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'BOXBUNDLES' || ',' || 'UPS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_profit * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_profit * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_profit * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_profit * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_profit * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_profit * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_profit * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_profit * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_profit * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_profit * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_profit * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_profit * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 23930 and 23930+28800 + and sm_carrier in ('BOXBUNDLES','UPS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'BOXBUNDLES' || ',' || 'UPS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 23930 AND 23930+28800 + and sm_carrier in ('BOXBUNDLES','UPS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q67.sql new file mode 100644 index 00000000..c5ae128c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1219 and 1219+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q68.sql new file mode 100644 index 00000000..6fdc45ee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 0 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Hopewell','Hamilton') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q69.sql new file mode 100644 index 00000000..a2a12356 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('MS','GA','TX') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q70.sql new file mode 100644 index 00000000..b2eb1c87 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1214 and 1214+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1214 and 1214+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q71.sql new file mode 100644 index 00000000..8348fbec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1998 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1998 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1998 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q72.sql new file mode 100644 index 00000000..9deb80cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 1999 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q73.sql new file mode 100644 index 00000000..bd405e43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Gogebic County','Adams County','Furnas County','Surry County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q74.sql new file mode 100644 index 00000000..ae6d2ddc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 1,2,3 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q75.sql new file mode 100644 index 00000000..1f4b95d6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Children') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q76.sql new file mode 100644 index 00000000..63e89f32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_warehouse_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_warehouse_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_cdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_cdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q77.sql new file mode 100644 index 00000000..43b69c3a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q78.sql new file mode 100644 index 00000000..3f578ec5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2002 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q79.sql new file mode 100644 index 00000000..a3fc1062 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > 2) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q80.sql new file mode 100644 index 00000000..7f5aefff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1999-08-11' as date) + and (cast('1999-08-11' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1999-08-11' as date) + and (cast('1999-08-11' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1999-08-11' as date) + and (cast('1999-08-11' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q81.sql new file mode 100644 index 00000000..96a3df89 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q82.sql new file mode 100644 index 00000000..2d80b2a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 84 and 84+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-06-06' as date) and (cast('2000-06-06' as date) + INTERVAL '60' DAY) + and i_manufact_id in (663,776,591,794) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q83.sql new file mode 100644 index 00000000..3c56de4f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-02',DATE '2001-09-25',DATE '2001-11-06'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-02',DATE '2001-09-25',DATE '2001-11-06'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-02',DATE '2001-09-25',DATE '2001-11-06'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q84.sql new file mode 100644 index 00000000..608705a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Shady Grove' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 43969 + and ib_upper_bound <= 43969 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q85.sql new file mode 100644 index 00000000..73758313 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2001 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('GA', 'TX', 'NY') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('FL', 'KS', 'TN') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('VA', 'PA', 'WY') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q86.sql new file mode 100644 index 00000000..c6ddfb6a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1182 and 1182+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q87.sql new file mode 100644 index 00000000..fb7633c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q88.sql new file mode 100644 index 00000000..5d4f1b8d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q89.sql new file mode 100644 index 00000000..56f6a1c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Sports','Women','Home') and + i_class in ('guns','maternity','flatware') + ) + or (i_category in ('Shoes','Children','Music') and + i_class in ('womens','toddlers','classical') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q90.sql new file mode 100644 index 00000000..da389a78 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 10 and 10+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 16 and 16+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q91.sql new file mode 100644 index 00000000..cb8d8ca8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2001 +and d_moy = 11 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '1001-5000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q92.sql new file mode 100644 index 00000000..f47816ac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 805 +and i_item_sk = ws_item_sk +and d_date between DATE '1998-03-11' and + (cast('1998-03-11' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1998-03-11' and + (cast('1998-03-11' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q93.sql new file mode 100644 index 00000000..a47a354c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 39') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q94.sql new file mode 100644 index 00000000..6a36a9d4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-2-01' and + (cast('2002-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'AR' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q95.sql new file mode 100644 index 00000000..c0ddd3ce --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-4-01' and + (cast('1999-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'LA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q96.sql new file mode 100644 index 00000000..c03ebcba --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 20 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 1 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q97.sql new file mode 100644 index 00000000..48699c49 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1210 and 1210 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1210 and 1210 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q98.sql new file mode 100644 index 00000000..b09e37ec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Shoes', 'Home', 'Children') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2001-06-20' as date) + and (cast('2001-06-20' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s0/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s0/q99.sql new file mode 100644 index 00000000..2f523742 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s0/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1194 and 1194 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q01.sql new file mode 100644 index 00000000..2adc4ee5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REFUNDED_CASH) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2001 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NM' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q02.sql new file mode 100644 index 00000000..a3aaa0b9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q03.sql new file mode 100644 index 00000000..093c1bb5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_discount_amt) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 169 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q04.sql new file mode 100644 index 00000000..8d0a204d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q05.sql new file mode 100644 index 00000000..6f9f7dcd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2002-08-26' as date) + and (cast('2002-08-26' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2002-08-26' as date) + and (cast('2002-08-26' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2002-08-26' as date) + and (cast('2002-08-26' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q06.sql new file mode 100644 index 00000000..37895df9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 6 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q07.sql new file mode 100644 index 00000000..e89b7a44 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q08.sql new file mode 100644 index 00000000..b8d1423d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '56459','32256','81713','53798','50066','87989', + '70965','58677','19382','88743','84793', + '77337','68631','66430','14108','11563', + '39276','65050','31893','34217','37345', + '32296','89500','79152','29665','95159', + '44116','78361','59314','35870','95520', + '79821','17720','47477','36416','89488', + '34295','13728','49865','61647','79139', + '21541','69417','83065','71021','31861', + '11625','64246','67110','40792','41772', + '78884','58701','93645','95370','77973', + '67490','27336','51931','65845','45047', + '67497','33483','39443','97461','51071', + '57245','14623','18546','28763','97530', + '44302','34522','83694','85744','65774', + '97446','25311','86128','18988','62610', + '79195','42977','38314','27006','69953', + '51039','86874','95439','41023','61822', + '23881','14057','88758','48117','48965', + '90714','53169','98196','37047','69197', + '69719','16671','29779','62764','51665', + '33788','55412','85607','85141','50826', + '19950','97169','83818','23599','57972', + '10896','39241','44351','85366','28042', + '28872','84875','55289','98473','34544', + '19812','79667','48970','48158','44795', + '58175','78963','48804','11447','92707', + '27822','63640','44354','44501','83623', + '66110','78276','44327','75510','38570', + '98033','98756','48334','27434','13498', + '83591','62694','24073','96389','65615', + '12659','92948','60092','61608','28829', + '49524','57506','67501','85496','60059', + '23711','80235','88479','24323','84491', + '21364','45178','86279','78270','14996', + '80723','98863','22598','73173','21129', + '67516','49361','42261','20558','96955', + '76387','15518','35908','67631','75523', + '75231','82849','62736','25652','44654', + '68314','39506','42745','60556','93674', + '15014','22095','34716','66386','47294', + '62096','60016','92156','32971','58635', + '60572','55903','69864','82356','33955', + '29643','81896','52622','24658','23258', + '11496','69338','55958','67845','11236', + '34378','76462','78639','41744','71621', + '81295','82654','59199','21593','37321', + '77767','21571','86501','39246','74317', + '75709','28334','33930','76679','53179', + '25663','55793','55882','12517','94873', + '31500','36638','62175','93106','37984', + '44150','65295','58351','59793','71096', + '68036','13185','99969','64707','60798', + '73310','56265','43882','41038','24385', + '37636','68310','28989','44054','96523', + '38680','90411','17713','23912','80837', + '58857','25306','72555','85190','13320', + '69617','96811','93150','31449','51327', + '85793','89679','37429','51223','54736', + '30260','95164','78380','89307','22018', + '50153','85232','63747','10086','79381', + '27303','65062','62669','63915','45348', + '23502','10125','78474','13412','62754', + '36104','87041','10127','73449','22521', + '71573','95768','57505','95923','78811', + '28460','37856','13767','99514','94388', + '10945','67674','56987','80410','70438', + '43680','86904','83219','57504','39356', + '23284','91437','89277','65122','96646', + '33781','81870','60742','14213','98773', + '22273','33645','68977','95031','36169', + '67037','73176','18810','48530','25046', + '80259','80777','89966','11799','10339', + '69736','48218','18606','64488','96278', + '91068','44538','27770','31422','99776', + '49243','60034','27867','46444','25241', + '73196','94898','63730','34679','80755', + '79721','90954','55448','46739','16215', + '15628','28071','54024','12908','28538', + '91695','33134','10283','75305') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q09.sql new file mode 100644 index 00000000..d1ad4c8a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 335627871 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 102856518 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 241227070 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 253244536 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 259119761 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q10.sql new file mode 100644 index 00000000..170fd813 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Gordon County','Fannin County','Adams County','Franklin County','Foster County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q11.sql new file mode 100644 index 00000000..216a99fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q12.sql new file mode 100644 index 00000000..10d12aae --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Books', 'Jewelry', 'Sports') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-02-25' as date) + and (cast('1999-02-25' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q13.sql new file mode 100644 index 00000000..b3be01d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = 'College' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('OH', 'CO', 'WA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'GA', 'MS') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NC', 'VA', 'NE') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q14.sql new file mode 100644 index 00000000..f1db7c69 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 25) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 25) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q15.sql new file mode 100644 index 00000000..bd2496e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q16.sql new file mode 100644 index 00000000..d66e7206 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'WI' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Kittitas County','Dauphin County','Huron County','Franklin Parish', + 'Mesa County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q17.sql new file mode 100644 index 00000000..32070a34 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2000Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q18.sql new file mode 100644 index 00000000..fa19d8ac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (3,4,11,8,12,9) and + d_year = 2000 and + ca_state in ('WY','KS','AL' + ,'OR','VA','TX','WV') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q19.sql new file mode 100644 index 00000000..dc6156d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=6 + and d_moy=11 + and d_year=2001 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q20.sql new file mode 100644 index 00000000..7fb8874f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Women', 'Sports', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-01-10' as date) + and (cast('1998-01-10' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q21.sql new file mode 100644 index 00000000..625701f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-04-03' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2001-04-03' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2001-04-03' as date) - INTERVAL '30' DAY) + and (cast ('2001-04-03' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q22.sql new file mode 100644 index 00000000..fa4a7052 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1208 and 1208 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q23.sql new file mode 100644 index 00000000..04917e0f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1999 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1999 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q24.sql new file mode 100644 index 00000000..bccea94c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'indian' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'blue' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q25.sql new file mode 100644 index 00000000..14661241 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q26.sql new file mode 100644 index 00000000..12618be3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q27.sql new file mode 100644 index 00000000..35888e94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'S' and + cd_education_status = 'Advanced Degree' and + d_year = 1998 and + s_state in ('IN','NC', 'MI', 'AL', 'OK', 'WA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q28.sql new file mode 100644 index 00000000..44a87077 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 121 and 121+10 + or ss_coupon_amt between 3187 and 3187+1000 + or ss_wholesale_cost between 14 and 14+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 39 and 39+10 + or ss_coupon_amt between 15019 and 15019+1000 + or ss_wholesale_cost between 78 and 78+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 148 and 148+10 + or ss_coupon_amt between 275 and 275+1000 + or ss_wholesale_cost between 27 and 27+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 112 and 112+10 + or ss_coupon_amt between 5404 and 5404+1000 + or ss_wholesale_cost between 17 and 17+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 14 and 14+10 + or ss_coupon_amt between 13817 and 13817+1000 + or ss_wholesale_cost between 3 and 3+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 168 and 168+10 + or ss_coupon_amt between 5547 and 5547+1000 + or ss_wholesale_cost between 53 and 53+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q29.sql new file mode 100644 index 00000000..d5ade587 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_quantity) as store_sales_quantity + ,avg(sr_return_quantity) as store_returns_quantity + ,avg(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q30.sql new file mode 100644 index 00000000..2c98a404 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q31.sql new file mode 100644 index 00000000..d626b369 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2002 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2002 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2002 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2002 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2002 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2002 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q32.sql new file mode 100644 index 00000000..275b4668 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 899 +and i_item_sk = cs_item_sk +and d_date between DATE '2000-02-23' and + (cast('2000-02-23' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2000-02-23' and + (cast('2000-02-23' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q33.sql new file mode 100644 index 00000000..baf81762 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q34.sql new file mode 100644 index 00000000..bdbf3851 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Chambers County','Warren County','Cocke County','Nowata County', + 'Harper County','Franklin Parish','Pipestone County','Terrell County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q35.sql new file mode 100644 index 00000000..45e56a9c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + max(cd_dep_count) aggone1, + stddev_samp(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + max(cd_dep_employed_count) aggone2, + stddev_samp(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + max(cd_dep_college_count) aggone3, + stddev_samp(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q36.sql new file mode 100644 index 00000000..46cb989d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('NE','AL','NM','FL', + 'PA','MI','IL','KS') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q37.sql new file mode 100644 index 00000000..a8f0ee6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 32 and 32 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-05-01' as date) and (cast('2000-05-01' as date) + INTERVAL '60' DAY) + and i_manufact_id in (738,902,874,891) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q38.sql new file mode 100644 index 00000000..1d8ece59 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1212 and 1212 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q39.sql new file mode 100644 index 00000000..2a53cae2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q40.sql new file mode 100644 index 00000000..b1cbdc24 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-03-19' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2002-03-19' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2002-03-19' as date) - INTERVAL '30' DAY) + and (cast ('2002-03-19' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q41.sql new file mode 100644 index 00000000..46dd4ea9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 735 and 735+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'light' or i_color = 'dark') and + (i_units = 'Lb' or i_units = 'Case') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'hot' or i_color = 'brown') and + (i_units = 'Pallet' or i_units = 'Ounce') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'azure' or i_color = 'salmon') and + (i_units = 'Dozen' or i_units = 'Dram') and + (i_size = 'N/A' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'blush' or i_color = 'purple') and + (i_units = 'Unknown' or i_units = 'N/A') and + (i_size = 'petite' or i_size = 'small') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'sienna' or i_color = 'ivory') and + (i_units = 'Bunch' or i_units = 'Carton') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'pale' or i_color = 'midnight') and + (i_units = 'Bundle' or i_units = 'Ton') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'puff' or i_color = 'mint') and + (i_units = 'Oz' or i_units = 'Box') and + (i_size = 'N/A' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'honeydew' or i_color = 'navajo') and + (i_units = 'Tsp' or i_units = 'Cup') and + (i_size = 'petite' or i_size = 'small') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q42.sql new file mode 100644 index 00000000..fe3da293 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1999 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q43.sql new file mode 100644 index 00000000..ccfb4cd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q44.sql new file mode 100644 index 00000000..44a38699 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 695 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 695 + and ss_cdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 695 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 695 + and ss_cdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q45.sql new file mode 100644 index 00000000..52ca35cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q46.sql new file mode 100644 index 00000000..9d4c799e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 6 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Four Corners','Hopewell','Lincoln','Pleasant Valley','Vernon') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q47.sql new file mode 100644 index 00000000..77919c4f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q48.sql new file mode 100644 index 00000000..f3f7444c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1998 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Primary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('AL', 'AK', 'MO') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('OH', 'OK', 'SC') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MA', 'MI', 'MS') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q49.sql new file mode 100644 index 00000000..41429035 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q50.sql new file mode 100644 index 00000000..71fedc7d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q51.sql new file mode 100644 index 00000000..53370bb5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1197 and 1197+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1197 and 1197+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q52.sql new file mode 100644 index 00000000..7d81431b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q53.sql new file mode 100644 index 00000000..dc70893e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1220,1220+1,1220+2,1220+3,1220+4,1220+5,1220+6,1220+7,1220+8,1220+9,1220+10,1220+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q54.sql new file mode 100644 index 00000000..648d79fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Music' + and i_class = 'country' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 7 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 7) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 7) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q55.sql new file mode 100644 index 00000000..687c8fd4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=84 + and d_moy=11 + and d_year=1998 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q56.sql new file mode 100644 index 00000000..e670e42e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('forest','ivory','firebrick')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('forest','ivory','firebrick')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('forest','ivory','firebrick')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q57.sql new file mode 100644 index 00000000..9748e371 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q58.sql new file mode 100644 index 00000000..115855fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-06-06')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-06-06')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-06-06')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q59.sql new file mode 100644 index 00000000..0f4449e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1209 and 1209 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1209+ 12 and 1209 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q60.sql new file mode 100644 index 00000000..2c79f89f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q61.sql new file mode 100644 index 00000000..e9dfa91f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q62.sql new file mode 100644 index 00000000..18b28ec5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1182 and 1182 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q63.sql new file mode 100644 index 00000000..f6312d8c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1203,1203+1,1203+2,1203+3,1203+4,1203+5,1203+6,1203+7,1203+8,1203+9,1203+10,1203+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q64.sql new file mode 100644 index 00000000..439f8624 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('frosted','yellow','sienna','rosy','medium','dim') and + i_current_price between 36 and 36 + 10 and + i_current_price between 36 + 1 and 36 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q65.sql new file mode 100644 index 00000000..9d3a62cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1191 and 1191+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1191 and 1191+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q66.sql new file mode 100644 index 00000000..7a79b62f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'GERMA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 3027 and 3027+28800 + and sm_carrier in ('FEDEX','GERMA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'GERMA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 3027 AND 3027+28800 + and sm_carrier in ('FEDEX','GERMA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q67.sql new file mode 100644 index 00000000..c5d86072 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1194 and 1194+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q68.sql new file mode 100644 index 00000000..fec8589b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 8 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Manchester','Kingston') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q69.sql new file mode 100644 index 00000000..3726f745 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('CO','TX','TN') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q70.sql new file mode 100644 index 00000000..8d8c7718 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1219 and 1219+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1219 and 1219+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q71.sql new file mode 100644 index 00000000..011aa50b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=1998 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=1998 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=1998 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q72.sql new file mode 100644 index 00000000..245a1c8f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 2001 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q73.sql new file mode 100644 index 00000000..471bdca3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Pennington County','Green Lake County','Mesa County','Surry County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q74.sql new file mode 100644 index 00000000..c15cd18c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2001 + and t_s_secyear.year = 2001+1 + and t_w_firstyear.year = 2001 + and t_w_secyear.year = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q75.sql new file mode 100644 index 00000000..3c1baf40 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Electronics') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q76.sql new file mode 100644 index 00000000..cbba368b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_promo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_promo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_web_site_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_web_site_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_addr_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_addr_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q77.sql new file mode 100644 index 00000000..11502a5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-13' as date) + and (cast('2002-08-13' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q78.sql new file mode 100644 index 00000000..24ecf4fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q79.sql new file mode 100644 index 00000000..25830d86 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q80.sql new file mode 100644 index 00000000..cf24a5cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q81.sql new file mode 100644 index 00000000..12e9ec79 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'OR' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q82.sql new file mode 100644 index 00000000..26c1d3e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 44 and 44+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-02-21' as date) and (cast('2000-02-21' as date) + INTERVAL '60' DAY) + and i_manufact_id in (503,888,284,68) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q83.sql new file mode 100644 index 00000000..260f022a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-04-14',DATE '2002-08-12',DATE '2002-11-02'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-04-14',DATE '2002-08-12',DATE '2002-11-02'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-04-14',DATE '2002-08-12',DATE '2002-11-02'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q84.sql new file mode 100644 index 00000000..73fceadc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Wildwood' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 43709 + and ib_upper_bound <= 43709 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q85.sql new file mode 100644 index 00000000..363d36be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2001 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('PA', 'NC', 'FL') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MI', 'MT', 'IL') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('TX', 'WA', 'GA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q86.sql new file mode 100644 index 00000000..40a0eb9c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1215 and 1215+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q87.sql new file mode 100644 index 00000000..0c368550 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1203 and 1203+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1203 and 1203+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1203 and 1203+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q88.sql new file mode 100644 index 00000000..67da6c02 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q89.sql new file mode 100644 index 00000000..b84d2d5a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1999) and + ((i_category in ('Shoes','Children','Music') and + i_class in ('kids','newborn','classical') + ) + or (i_category in ('Jewelry','Home','Books') and + i_class in ('diamonds','glassware','mystery') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q90.sql new file mode 100644 index 00000000..e1131a43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 6 and 6+1 + and household_demographics.hd_dep_count = 8 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 16 and 16+1 + and household_demographics.hd_dep_count = 8 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q91.sql new file mode 100644 index 00000000..34d8f132 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '501-1000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q92.sql new file mode 100644 index 00000000..96a452c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 131 +and i_item_sk = ws_item_sk +and d_date between DATE '1998-01-14' and + (cast('1998-01-14' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1998-01-14' and + (cast('1998-01-14' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q93.sql new file mode 100644 index 00000000..fb0cd4c9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 40') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q94.sql new file mode 100644 index 00000000..f3572897 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'MI' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q95.sql new file mode 100644 index 00000000..b7e39c0e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-5-01' and + (cast('2000-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q96.sql new file mode 100644 index 00000000..a95f8c2e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 20 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 9 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q97.sql new file mode 100644 index 00000000..f073aaf7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1211 and 1211 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1211 and 1211 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q98.sql new file mode 100644 index 00000000..74afa115 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Books', 'Men', 'Home') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2000-06-29' as date) + and (cast('2000-06-29' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s1/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s1/q99.sql new file mode 100644 index 00000000..4c05c036 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s1/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1214 and 1214 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q01.sql new file mode 100644 index 00000000..db6089e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_RETURN_AMT_INC_TAX) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NM' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q03.sql new file mode 100644 index 00000000..4221a656 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 93 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q04.sql new file mode 100644 index 00000000..4742fec1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q05.sql new file mode 100644 index 00000000..57c99ba2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q06.sql new file mode 100644 index 00000000..a96453f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2000 + and d_moy = 1 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q07.sql new file mode 100644 index 00000000..a583267a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Primary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q08.sql new file mode 100644 index 00000000..725162dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '14867','50445','76486','94678','51188','47487', + '73674','71363','53598','61083','76580', + '25301','84813','24473','19636','58437', + '70902','96543','45931','87770','52116', + '92449','90635','93644','94442','67702', + '27334','79183','24690','11584','60005', + '73786','76695','62759','29069','91027', + '34303','12198','63236','52148','35908', + '89657','63597','18924','58278','64020', + '83397','15816','17601','23054','21892', + '48085','95304','98928','92136','65537', + '44417','19357','78645','72294','46543', + '45084','25847','69015','79135','30279', + '70550','62818','97136','25020','98911', + '35192','59797','59510','81703','32950', + '43700','52824','65681','69096','28670', + '86945','17321','85939','25156','93349', + '15178','20078','21642','27779','79227', + '80587','70032','40110','12311','83344', + '95328','12333','78233','64332','26700', + '64949','75817','11713','72803','83672', + '75287','90194','80234','31390','98305', + '31085','87162','78747','40438','76876', + '64302','98756','46739','56629','86368', + '17183','51393','70859','62440','33052', + '41167','67658','70882','83355','71018', + '77286','97894','78594','50583','40809', + '19301','92342','79030','54805','77094', + '91693','97027','24737','89084','93992', + '32831','91334','54284','54597','81127', + '50700','17514','49728','15385','24773', + '46014','27162','46141','26568','15441', + '74372','81467','31818','74172','51645', + '64891','84829','46784','87743','85062', + '73420','76670','81316','26721','26631', + '81361','54875','77754','63918','42657', + '84604','27676','36690','26245','36400', + '12711','75898','20795','21921','80272', + '47064','23826','90911','44941','26477', + '55629','58263','56637','42978','92270', + '84737','85713','91453','99600','46509', + '45044','95562','48131','50762','54128', + '92061','15387','59129','78400','85699', + '43464','68487','97419','33838','69827', + '55223','96307','82536','14453','52277', + '51249','51040','24221','97644','50882', + '97433','25158','65129','70777','48966', + '63552','84078','78788','50752','85247', + '63104','51361','22199','12520','66704', + '37074','24088','15495','73617','41409', + '22606','10789','43686','83584','36500', + '19461','86737','81651','97467','15055', + '45738','26472','88930','71316','61445', + '43229','51879','56689','48323','60972', + '30040','28002','11246','80279','68022', + '37813','32934','79037','26990','13267', + '45226','21457','54242','34971','41722', + '96222','93406','63409','16529','80760', + '99997','30353','63269','71271','76636', + '53378','25370','22261','95023','12106', + '34038','91407','37296','93276','96859', + '43886','29977','13635','12752','51730', + '14247','39503','95737','38198','62967', + '21536','11457','76849','16464','48393', + '89931','78145','14821','75577','64687', + '76856','35243','67697','26462','55459', + '97452','71053','93658','89939','59437', + '74806','66451','29918','31651','81700', + '52172','41398','30559','39453','63108', + '97395','30155','33798','17415','99704', + '61377','25078','48907','94252','56999', + '79740','41265','19128','58168','75283', + '73020','91025','42712','71169','68173', + '26521','19721','15475','95236','32042', + '47157','83409','42044','57029','82710', + '32503','14949','26047','53240','37478', + '53744','77492','59052','59873','21816', + '24421','88392','36880','86668','10474', + '68888','86451','55708','60740','80384', + '93416','48876','64096','30739') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q09.sql new file mode 100644 index 00000000..7fd6df29 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 116321471 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 347603988 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 412167900 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 49188592 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 354672641 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q10.sql new file mode 100644 index 00000000..ea09f58c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Loving County','Decatur County','Halifax County','Tolland County','Isle of Wight County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q11.sql new file mode 100644 index 00000000..96b04e18 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q12.sql new file mode 100644 index 00000000..8783e76b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Home', 'Shoes', 'Sports') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-05-14' as date) + and (cast('2000-05-14' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q13.sql new file mode 100644 index 00000000..fd0b2d72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'College' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Unknown' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('VA', 'NE', 'CA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('WY', 'LA', 'KY') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MO', 'AL', 'PA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q14.sql new file mode 100644 index 00000000..f47f288e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + 1 + and d_moy = 12 + and d_dom = 11) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + and d_moy = 12 + and d_dom = 11) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q16.sql new file mode 100644 index 00000000..f205a41b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'PA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Bronx County','Wadena County','Huron County','Williamson County', + 'Walker County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q17.sql new file mode 100644 index 00000000..4f3e0465 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q18.sql new file mode 100644 index 00000000..8cdf6673 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Unknown' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (4,11,7,10,1,5) and + d_year = 1998 and + ca_state in ('IA','KY','OK' + ,'MO','MT','IL','TX') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q19.sql new file mode 100644 index 00000000..f758d04a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=19 + and d_moy=11 + and d_year=1998 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q20.sql new file mode 100644 index 00000000..5a55d307 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Electronics', 'Jewelry', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-06-25' as date) + and (cast('1998-06-25' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q21.sql new file mode 100644 index 00000000..0af69ee1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-04-26' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2000-04-26' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2000-04-26' as date) - INTERVAL '30' DAY) + and (cast ('2000-04-26' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q22.sql new file mode 100644 index 00000000..043843f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1177 and 1177 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q23.sql new file mode 100644 index 00000000..53ea2a1c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1999 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1999 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q24.sql new file mode 100644 index 00000000..9da1767d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'royal' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'green' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q25.sql new file mode 100644 index 00000000..bdd0ee82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q26.sql new file mode 100644 index 00000000..18dea81b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q27.sql new file mode 100644 index 00000000..8075baeb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'S' and + cd_education_status = '4 yr Degree' and + d_year = 1998 and + s_state in ('MI','LA', 'IN', 'TN', 'NC', 'VT') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q28.sql new file mode 100644 index 00000000..8938adbe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 118 and 118+10 + or ss_coupon_amt between 14722 and 14722+1000 + or ss_wholesale_cost between 80 and 80+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 7 and 7+10 + or ss_coupon_amt between 1525 and 1525+1000 + or ss_wholesale_cost between 8 and 8+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 18 and 18+10 + or ss_coupon_amt between 16540 and 16540+1000 + or ss_wholesale_cost between 7 and 7+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 124 and 124+10 + or ss_coupon_amt between 12503 and 12503+1000 + or ss_wholesale_cost between 63 and 63+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 84 and 84+10 + or ss_coupon_amt between 326 and 326+1000 + or ss_wholesale_cost between 4 and 4+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 112 and 112+10 + or ss_coupon_amt between 10180 and 10180+1000 + or ss_wholesale_cost between 6 and 6+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q29.sql new file mode 100644 index 00000000..59118672 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q30.sql new file mode 100644 index 00000000..7ec5dedb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TX' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q31.sql new file mode 100644 index 00000000..e50d8538 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q32.sql new file mode 100644 index 00000000..cc2ee8a4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 293 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-01-31' and + (cast('1998-01-31' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-01-31' and + (cast('1998-01-31' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q33.sql new file mode 100644 index 00000000..2610a00c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q34.sql new file mode 100644 index 00000000..052b39a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Cocke County','Orange County','Halifax County','Wadena County', + 'Klamath County','Walker County','Coal County','Perry County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q35.sql new file mode 100644 index 00000000..8f39bbf6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + stddev_samp(cd_dep_count) aggone1, + stddev_samp(cd_dep_count) aggtwo1, + sum(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + stddev_samp(cd_dep_employed_count) aggone2, + stddev_samp(cd_dep_employed_count) aggtwo2, + sum(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + stddev_samp(cd_dep_college_count) aggone3, + stddev_samp(cd_dep_college_count) aggtwo3, + sum(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q36.sql new file mode 100644 index 00000000..ae8ffa48 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('GA','PA','TX','OK', + 'NE','OH','MI','IN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q37.sql new file mode 100644 index 00000000..78e887ec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 70 and 70 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-03-18' as date) and (cast('2002-03-18' as date) + INTERVAL '60' DAY) + and i_manufact_id in (842,724,894,872) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q38.sql new file mode 100644 index 00000000..14361ad9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q39.sql new file mode 100644 index 00000000..3669aa43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q40.sql new file mode 100644 index 00000000..96fed5a4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-06-08' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-06-08' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-06-08' as date) - INTERVAL '30' DAY) + and (cast ('1998-06-08' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q41.sql new file mode 100644 index 00000000..c50172ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 922 and 922+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'lemon' or i_color = 'magenta') and + (i_units = 'Cup' or i_units = 'Dozen') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'midnight' or i_color = 'green') and + (i_units = 'Lb' or i_units = 'Carton') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'violet' or i_color = 'azure') and + (i_units = 'Bundle' or i_units = 'Pound') and + (i_size = 'economy' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'snow' or i_color = 'cream') and + (i_units = 'Ounce' or i_units = 'Each') and + (i_size = 'medium' or i_size = 'N/A') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'medium' or i_color = 'hot') and + (i_units = 'Tbl' or i_units = 'Unknown') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'goldenrod' or i_color = 'seashell') and + (i_units = 'Bunch' or i_units = 'Dram') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'ghost' or i_color = 'peru') and + (i_units = 'Gross' or i_units = 'Case') and + (i_size = 'economy' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'firebrick' or i_color = 'cornflower') and + (i_units = 'Tsp' or i_units = 'Gram') and + (i_size = 'medium' or i_size = 'N/A') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q42.sql new file mode 100644 index 00000000..13d30602 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q43.sql new file mode 100644 index 00000000..5675fdee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q44.sql new file mode 100644 index 00000000..8a33c23a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 535 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 535 + and ss_addr_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 535 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 535 + and ss_addr_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q45.sql new file mode 100644 index 00000000..826a63d1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_county, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip, ca_county + order by ca_zip, ca_county + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q46.sql new file mode 100644 index 00000000..681f2c4a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 3 or + household_demographics.hd_vehicle_count= 2) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Mount Zion','Jefferson','Glendale','Richland','Buffalo') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q47.sql new file mode 100644 index 00000000..2e557bcf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_company_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q48.sql new file mode 100644 index 00000000..caee19de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'GA', 'MT') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('WI', 'AL', 'IL') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('AR', 'OR', 'IA') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q49.sql new file mode 100644 index 00000000..18d66524 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q50.sql new file mode 100644 index 00000000..753ed6f6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1999 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q51.sql new file mode 100644 index 00000000..c9de3104 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1211 and 1211+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1211 and 1211+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q52.sql new file mode 100644 index 00000000..69857109 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q53.sql new file mode 100644 index 00000000..873c1cef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1183,1183+1,1183+2,1183+3,1183+4,1183+5,1183+6,1183+7,1183+8,1183+9,1183+10,1183+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q54.sql new file mode 100644 index 00000000..38015676 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Women' + and i_class = 'swimwear' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 6 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 6) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 6) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q55.sql new file mode 100644 index 00000000..cad6a547 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=19 + and d_moy=11 + and d_year=2000 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q56.sql new file mode 100644 index 00000000..c22dc9b1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('mint','sky','medium')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('mint','sky','medium')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('mint','sky','medium')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q57.sql new file mode 100644 index 00000000..e0ee2527 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q58.sql new file mode 100644 index 00000000..d387a923 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-07-21')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-07-21')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2001-07-21')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q59.sql new file mode 100644 index 00000000..17e80959 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1188 and 1188 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1188+ 12 and 1188 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q60.sql new file mode 100644 index 00000000..4efe749f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q61.sql new file mode 100644 index 00000000..1c6ac84a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q62.sql new file mode 100644 index 00000000..eb6408e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1197 and 1197 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q63.sql new file mode 100644 index 00000000..2b44f347 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1197,1197+1,1197+2,1197+3,1197+4,1197+5,1197+6,1197+7,1197+8,1197+9,1197+10,1197+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q64.sql new file mode 100644 index 00000000..47b05919 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('dodger','dim','coral','bisque','linen','firebrick') and + i_current_price between 20 and 20 + 10 and + i_current_price between 20 + 1 and 20 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q65.sql new file mode 100644 index 00000000..eb5dd892 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1221 and 1221+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1221 and 1221+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q66.sql new file mode 100644 index 00000000..1a16eb4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'GERMA' || ',' || 'BOXBUNDLES' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 56844 and 56844+28800 + and sm_carrier in ('GERMA','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'GERMA' || ',' || 'BOXBUNDLES' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 56844 AND 56844+28800 + and sm_carrier in ('GERMA','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q67.sql new file mode 100644 index 00000000..ed4a0ef0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1210 and 1210+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q68.sql new file mode 100644 index 00000000..f5627f53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('White Oak','Jamestown') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q69.sql new file mode 100644 index 00000000..1175dc35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('NC','AR','SD') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 4 and 4+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 4 and 4+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 4 and 4+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q70.sql new file mode 100644 index 00000000..1a39d147 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1186 and 1186+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1186 and 1186+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q71.sql new file mode 100644 index 00000000..b547ac16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q72.sql new file mode 100644 index 00000000..4da32dd9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 2001 + and cd_marital_status = 'D' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q73.sql new file mode 100644 index 00000000..bb13e9a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Daviess County','Sierra County','Lea County','Pulaski County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q74.sql new file mode 100644 index 00000000..ea2eda0e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2001 + and t_s_secyear.year = 2001+1 + and t_w_firstyear.year = 2001 + and t_w_secyear.year = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,1,2 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q75.sql new file mode 100644 index 00000000..7b1a51bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Children') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q76.sql new file mode 100644 index 00000000..0f7cf147 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_hdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_hdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_customer_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_customer_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_warehouse_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q77.sql new file mode 100644 index 00000000..d6b96fb7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-12' as date) + and (cast('1999-08-12' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q78.sql new file mode 100644 index 00000000..90f50ef4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2002 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q79.sql new file mode 100644 index 00000000..66208fd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 2 or household_demographics.hd_vehicle_count > 3) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q80.sql new file mode 100644 index 00000000..d0405113 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q81.sql new file mode 100644 index 00000000..38b753fb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'VA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q82.sql new file mode 100644 index 00000000..7534b255 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 7 and 7+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-01-06' as date) and (cast('2001-01-06' as date) + INTERVAL '60' DAY) + and i_manufact_id in (264,801,53,690) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q83.sql new file mode 100644 index 00000000..4ebe2ba1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-15',DATE '1998-11-10'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-15',DATE '1998-11-10'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-15',DATE '1998-11-10'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q84.sql new file mode 100644 index 00000000..dc3931ae --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Hillcrest' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 59984 + and ib_upper_bound <= 59984 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q85.sql new file mode 100644 index 00000000..4039a3d9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('VT', 'OH', 'TN') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MI', 'NE', 'FL') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('TX', 'NM', 'PA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q86.sql new file mode 100644 index 00000000..27257ecd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1224 and 1224+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q87.sql new file mode 100644 index 00000000..0218d8a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q88.sql new file mode 100644 index 00000000..3e11f6c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q89.sql new file mode 100644 index 00000000..5bf7e5a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1999) and + ((i_category in ('Music','Children','Women') and + i_class in ('country','toddlers','swimwear') + ) + or (i_category in ('Jewelry','Men','Sports') and + i_class in ('semi-precious','shirts','archery') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q90.sql new file mode 100644 index 00000000..a8b94924 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 10 and 10+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 15 and 15+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q91.sql new file mode 100644 index 00000000..971ff227 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2002 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '5001-10000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q92.sql new file mode 100644 index 00000000..16bf3062 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 813 +and i_item_sk = ws_item_sk +and d_date between DATE '2002-02-28' and + (cast('2002-02-28' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2002-02-28' and + (cast('2002-02-28' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q93.sql new file mode 100644 index 00000000..baed7623 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 73') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q94.sql new file mode 100644 index 00000000..d34ca4de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'WI' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q95.sql new file mode 100644 index 00000000..9bbf18eb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-3-01' and + (cast('2002-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KY' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q96.sql new file mode 100644 index 00000000..670de290 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 1 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q97.sql new file mode 100644 index 00000000..c7fefa50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q98.sql new file mode 100644 index 00000000..0dc2a322 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Sports', 'Music', 'Electronics') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2002-01-31' as date) + and (cast('2002-01-31' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s10/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s10/q99.sql new file mode 100644 index 00000000..42125c22 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s10/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1215 and 1215 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q01.sql new file mode 100644 index 00000000..02135ee1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_STORE_CREDIT) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2002 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'TX' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q03.sql new file mode 100644 index 00000000..eed61773 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 910 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q04.sql new file mode 100644 index 00000000..659c6c43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q05.sql new file mode 100644 index 00000000..ecacbaa7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-10' as date) + and (cast('2001-08-10' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-10' as date) + and (cast('2001-08-10' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-10' as date) + and (cast('2001-08-10' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q06.sql new file mode 100644 index 00000000..a96453f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2000 + and d_moy = 1 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q07.sql new file mode 100644 index 00000000..bec6a421 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'U' and + cd_education_status = 'Primary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q08.sql new file mode 100644 index 00000000..74605530 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '61176','48595','61104','37078','66017','76581', + '40429','21505','18698','16557','72681', + '47313','45826','33225','50528','21161', + '65598','48609','52122','59285','59048', + '28349','86736','99762','95094','87962', + '87936','32354','35573','10983','39104', + '43839','26688','77667','15088','18738', + '49666','76770','29289','11351','57440', + '27020','92960','99715','98428','30183', + '75962','16752','68592','82393','59297', + '45346','14919','31831','30656','61550', + '10228','12640','45289','62791','40977', + '92232','98522','52093','68648','47694', + '59829','10593','48586','80395','38607', + '91682','48805','70071','89093','44308', + '40544','27906','61179','73056','67384', + '28308','89733','11714','52989','38216', + '70290','56859','25429','95624','73911', + '49427','41760','46410','75546','89481', + '98802','87120','73244','88561','45563', + '37460','80899','48874','53084','82186', + '22589','61420','62569','14311','97110', + '91167','49850','20215','34088','83995', + '94460','20325','90781','26066','28644', + '80296','55975','96966','78652','31653', + '26622','10559','11883','47325','36634', + '96711','13242','50235','86640','48253', + '92448','11414','24602','61739','21753', + '47597','69873','36599','60676','82714', + '94011','12798','97207','45443','49900', + '91936','75817','94311','98959','45140', + '14121','52571','93544','65858','78348', + '84662','87572','37177','89153','50433', + '30791','85212','22871','81011','76443', + '41284','49045','23123','49449','21699', + '20423','74730','92119','53749','43608', + '77857','55037','73539','99595','95206', + '64610','33298','32602','52404','37878', + '21126','87727','52607','32731','12165', + '60147','74205','30269','40833','61628', + '95112','97111','83168','17040','23439', + '13005','37787','67958','77756','45021', + '40180','72627','94702','25622','12436', + '63278','58269','58806','84134','72625', + '77281','62862','64813','74100','37847', + '90313','84447','47110','47754','17347', + '80921','19727','73296','24909','14462', + '47029','76597','76249','58413','52309', + '36313','54973','67078','81453','43235', + '64938','53390','59076','37734','31732', + '93049','61709','13422','39572','77383', + '21819','81419','15380','90612','87926', + '41827','22313','23850','10107','37321', + '94328','44900','18984','23381','25312', + '46974','90174','92213','15889','38848', + '99360','14284','97039','15574','88937', + '10783','73709','77167','51446','84319', + '28486','80078','35178','36624','10643', + '44959','61603','42794','27420','24904', + '47774','74115','71169','80826','79547', + '96570','15013','52513','38309','26822', + '85200','43320','96344','31479','32797', + '80593','49876','93667','80613','79060', + '10375','46572','30935','49789','13023', + '18662','55050','70819','76925','12433', + '25801','39870','80464','92642','50559', + '82749','86296','19417','52917','59832', + '14032','26276','12430','82866','34412', + '62232','13584','71892','14286','59428', + '15820','21991','27248','45703','58095', + '22302','17999','89197','17495','66172', + '93868','36077','12617','60860','89297', + '79552','87126','89641','48632','52639', + '58481','94882','28624','83285','29046', + '95728','23717','13861','38080','53404', + '62713','68618','71765','79353','83490', + '65327','43343','46112','47050','42051', + '49637','66215','92734','50803','35149', + '34836','98238','77390','65426','43375', + '87002','91263','13176','82858') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q09.sql new file mode 100644 index 00000000..c5a2c7fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 396221737 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 112194010 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 319694232 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 433944593 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 227282902 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q10.sql new file mode 100644 index 00000000..d2521e5a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Bonner County','Montgomery County','Sumter County','Conway County','Lenawee County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q11.sql new file mode 100644 index 00000000..346e967e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q12.sql new file mode 100644 index 00000000..a0ce40c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Women', 'Books', 'Men') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2002-06-23' as date) + and (cast('2002-06-23' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q13.sql new file mode 100644 index 00000000..3b12d507 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Primary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('KS', 'SD', 'VA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IL', 'IA', 'AK') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'GA', 'OK') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q14.sql new file mode 100644 index 00000000..13e86e74 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 21) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 21) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q15.sql new file mode 100644 index 00000000..7704820c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q16.sql new file mode 100644 index 00000000..bceebd33 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-5-01' and + (cast('1999-5-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'WV' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Ziebach County','Daviess County','Walker County','Mobile County', + 'Fairfield County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q18.sql new file mode 100644 index 00000000..a513aca9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = '4 yr Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (7,11,8,4,9,5) and + d_year = 2002 and + ca_state in ('NY','IN','OR' + ,'GA','MI','WV','TN') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q19.sql new file mode 100644 index 00000000..b0093d60 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=13 + and d_moy=12 + and d_year=1999 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q20.sql new file mode 100644 index 00000000..a34cf5a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Home', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-04-22' as date) + and (cast('2002-04-22' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q21.sql new file mode 100644 index 00000000..1248d300 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-02-01' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1999-02-01' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1999-02-01' as date) - INTERVAL '30' DAY) + and (cast ('1999-02-01' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q22.sql new file mode 100644 index 00000000..c387e52c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1198 and 1198 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q23.sql new file mode 100644 index 00000000..45b89309 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q24.sql new file mode 100644 index 00000000..65ed56b6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=7 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'green' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 7 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'midnight' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q25.sql new file mode 100644 index 00000000..9ce6b4b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_net_profit) as store_sales_profit + ,stddev_samp(sr_net_loss) as store_returns_loss + ,stddev_samp(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1999 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q26.sql new file mode 100644 index 00000000..2b0b134e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'Secondary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q27.sql new file mode 100644 index 00000000..02c9bf08 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = 'Secondary' and + d_year = 1999 and + s_state in ('IN','NC', 'TN', 'SC', 'MN', 'GA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q28.sql new file mode 100644 index 00000000..78f81de7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 98 and 98+10 + or ss_coupon_amt between 12073 and 12073+1000 + or ss_wholesale_cost between 60 and 60+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 57 and 57+10 + or ss_coupon_amt between 1859 and 1859+1000 + or ss_wholesale_cost between 14 and 14+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 143 and 143+10 + or ss_coupon_amt between 12302 and 12302+1000 + or ss_wholesale_cost between 36 and 36+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 33 and 33+10 + or ss_coupon_amt between 16049 and 16049+1000 + or ss_wholesale_cost between 16 and 16+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 5 and 5+10 + or ss_coupon_amt between 4270 and 4270+1000 + or ss_wholesale_cost between 32 and 32+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 61 and 61+10 + or ss_coupon_amt between 17901 and 17901+1000 + or ss_wholesale_cost between 67 and 67+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q29.sql new file mode 100644 index 00000000..5b133d4d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,sum(ss_quantity) as store_sales_quantity + ,sum(sr_return_quantity) as store_returns_quantity + ,sum(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q30.sql new file mode 100644 index 00000000..2c98a404 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q31.sql new file mode 100644 index 00000000..c1bc77aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q32.sql new file mode 100644 index 00000000..ff16c972 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 424 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-03-19' and + (cast('2002-03-19' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-03-19' and + (cast('2002-03-19' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q33.sql new file mode 100644 index 00000000..e2eb42dd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q34.sql new file mode 100644 index 00000000..bd0bc551 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Wadena County','Oglethorpe County','Wilkinson County','Van Buren County', + 'Lea County','Brazos County','Mobile County','Abbeville County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q35.sql new file mode 100644 index 00000000..ea6024ff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + sum(cd_dep_count) aggtwo1, + max(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + sum(cd_dep_employed_count) aggtwo2, + max(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + sum(cd_dep_college_count) aggtwo3, + max(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q36.sql new file mode 100644 index 00000000..d95c0723 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('WA','MO','MI','WV', + 'MI','MN','NY','TN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q37.sql new file mode 100644 index 00000000..a8fc5254 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 37 and 37 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-01-31' as date) and (cast('2000-01-31' as date) + INTERVAL '60' DAY) + and i_manufact_id in (757,895,973,750) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q38.sql new file mode 100644 index 00000000..bdd49090 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1214 and 1214 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1214 and 1214 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1214 and 1214 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q39.sql new file mode 100644 index 00000000..41924652 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q40.sql new file mode 100644 index 00000000..839b54c9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-05-24' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-05-24' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-05-24' as date) - INTERVAL '30' DAY) + and (cast ('1998-05-24' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q41.sql new file mode 100644 index 00000000..ceddfea2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 795 and 795+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'grey' or i_color = 'sandy') and + (i_units = 'Pound' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'hot' or i_color = 'floral') and + (i_units = 'Dram' or i_units = 'Tbl') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'plum' or i_color = 'ivory') and + (i_units = 'Carton' or i_units = 'Unknown') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'black' or i_color = 'sienna') and + (i_units = 'Oz' or i_units = 'Each') and + (i_size = 'extra large' or i_size = 'N/A') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'honeydew' or i_color = 'thistle') and + (i_units = 'Gram' or i_units = 'Case') and + (i_size = 'extra large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'peru' or i_color = 'steel') and + (i_units = 'Bundle' or i_units = 'Ounce') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'papaya' or i_color = 'violet') and + (i_units = 'Dozen' or i_units = 'N/A') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'green' or i_color = 'coral') and + (i_units = 'Gross' or i_units = 'Pallet') and + (i_size = 'extra large' or i_size = 'N/A') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q42.sql new file mode 100644 index 00000000..df1387e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2002 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q43.sql new file mode 100644 index 00000000..79576281 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q44.sql new file mode 100644 index 00000000..a8b98677 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 322 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 322 + and ss_hdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 322 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 322 + and ss_hdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q45.sql new file mode 100644 index 00000000..f7b6c99e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_county, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + group by ca_zip, ca_county + order by ca_zip, ca_county + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q46.sql new file mode 100644 index 00000000..d9764ef9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 9 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Hilltop','Corinth','Shady Grove','Greenfield','Crossroads') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q47.sql new file mode 100644 index 00000000..c1ea9c88 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name, v1.s_company_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q48.sql new file mode 100644 index 00000000..a6ee74d7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2002 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'College' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('KS', 'TX', 'WI') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('ME', 'PA', 'TN') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'FL', 'GA') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q49.sql new file mode 100644 index 00000000..18d66524 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q50.sql new file mode 100644 index 00000000..71fedc7d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q51.sql new file mode 100644 index 00000000..2502bdfa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q52.sql new file mode 100644 index 00000000..dd28b998 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q53.sql new file mode 100644 index 00000000..dee7ac70 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1214,1214+1,1214+2,1214+3,1214+4,1214+5,1214+6,1214+7,1214+8,1214+9,1214+10,1214+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q54.sql new file mode 100644 index 00000000..bab00530 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Women' + and i_class = 'fragrances' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q55.sql new file mode 100644 index 00000000..212bc5fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=14 + and d_moy=12 + and d_year=1998 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q56.sql new file mode 100644 index 00000000..565e15f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('olive','light','smoke')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('olive','light','smoke')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('olive','light','smoke')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q57.sql new file mode 100644 index 00000000..9aa77945 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q58.sql new file mode 100644 index 00000000..d92f1698 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-03-30')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-03-30')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1998-03-30')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q59.sql new file mode 100644 index 00000000..f2b05300 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1187 and 1187 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1187+ 12 and 1187 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q60.sql new file mode 100644 index 00000000..8eaae429 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 8 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 8 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 8 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q61.sql new file mode 100644 index 00000000..8b8aab7f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Books' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Books' + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q62.sql new file mode 100644 index 00000000..a07f4727 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1190 and 1190 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q63.sql new file mode 100644 index 00000000..e8ab3ed7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1215,1215+1,1215+2,1215+3,1215+4,1215+5,1215+6,1215+7,1215+8,1215+9,1215+10,1215+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q64.sql new file mode 100644 index 00000000..02f79a39 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('dark','gainsboro','misty','burlywood','saddle','sandy') and + i_current_price between 73 and 73 + 10 and + i_current_price between 73 + 1 and 73 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2001 and + cs2.syear = 2001 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q65.sql new file mode 100644 index 00000000..0a0e8d3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1192 and 1192+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1192 and 1192+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q66.sql new file mode 100644 index 00000000..07cc7587 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'MSC' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 18010 and 18010+28800 + and sm_carrier in ('FEDEX','MSC') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'MSC' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 18010 AND 18010+28800 + and sm_carrier in ('FEDEX','MSC') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q67.sql new file mode 100644 index 00000000..99ab5f68 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1201 and 1201+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q68.sql new file mode 100644 index 00000000..1e932842 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 0 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Cloverdale','Hillsdale') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q69.sql new file mode 100644 index 00000000..9ee3fa8b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('OH','MO','FL') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q70.sql new file mode 100644 index 00000000..0453880e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1201 and 1201+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1201 and 1201+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q71.sql new file mode 100644 index 00000000..695220da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=2001 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=2001 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=2001 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q72.sql new file mode 100644 index 00000000..94277631 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 1999 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q73.sql new file mode 100644 index 00000000..8280a025 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Raleigh County','Pipestone County','Red River Parish','Quay County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q74.sql new file mode 100644 index 00000000..85a4ea92 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q75.sql new file mode 100644 index 00000000..695b51ab --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Shoes') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q76.sql new file mode 100644 index 00000000..1b633a01 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_addr_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_promo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_promo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_addr_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_addr_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q77.sql new file mode 100644 index 00000000..c9ea4269 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-28' as date) + and (cast('2002-08-28' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q78.sql new file mode 100644 index 00000000..53b189fd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2001 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q79.sql new file mode 100644 index 00000000..a0f5c0f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q80.sql new file mode 100644 index 00000000..96163b86 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-05' as date) + and (cast('2001-08-05' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-05' as date) + and (cast('2001-08-05' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-05' as date) + and (cast('2001-08-05' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q81.sql new file mode 100644 index 00000000..1f498656 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =1998 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'CT' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q82.sql new file mode 100644 index 00000000..17eeff62 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 27 and 27+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-05-16' as date) and (cast('2002-05-16' as date) + INTERVAL '60' DAY) + and i_manufact_id in (827,448,508,185) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q83.sql new file mode 100644 index 00000000..81b20845 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-05-09',DATE '1998-08-09',DATE '1998-11-09'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-05-09',DATE '1998-08-09',DATE '1998-11-09'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-05-09',DATE '1998-08-09',DATE '1998-11-09'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q84.sql new file mode 100644 index 00000000..66df7cb7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Lakewood' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 53056 + and ib_upper_bound <= 53056 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q85.sql new file mode 100644 index 00000000..778b732c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('TX', 'WV', 'MN') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MT', 'MI', 'AZ') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('IN', 'VA', 'UT') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q86.sql new file mode 100644 index 00000000..1777dbdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1207 and 1207+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q87.sql new file mode 100644 index 00000000..10583415 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q88.sql new file mode 100644 index 00000000..075276b6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q89.sql new file mode 100644 index 00000000..7dbaaf75 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Women','Music','Jewelry') and + i_class in ('dresses','pop','rings') + ) + or (i_category in ('Men','Home','Electronics') and + i_class in ('shirts','blinds/shades','cameras') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q90.sql new file mode 100644 index 00000000..07835c32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 10 and 10+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 15 and 15+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q91.sql new file mode 100644 index 00000000..467b9174 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '1001-5000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q92.sql new file mode 100644 index 00000000..a09a2b20 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 208 +and i_item_sk = ws_item_sk +and d_date between DATE '1999-01-14' and + (cast('1999-01-14' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1999-01-14' and + (cast('1999-01-14' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q93.sql new file mode 100644 index 00000000..53b1c3b2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 62') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q94.sql new file mode 100644 index 00000000..e8a2a167 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-5-01' and + (cast('2002-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'MO' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q95.sql new file mode 100644 index 00000000..48f832d1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'CO' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q96.sql new file mode 100644 index 00000000..f3df595b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 6 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q97.sql new file mode 100644 index 00000000..ae48c5b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q98.sql new file mode 100644 index 00000000..d431dd30 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Men', 'Music', 'Electronics') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-01-07' as date) + and (cast('1999-01-07' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s11/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s11/q99.sql new file mode 100644 index 00000000..2a6443b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s11/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1201 and 1201 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q01.sql new file mode 100644 index 00000000..61409bc8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REVERSED_CHARGE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'GA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q03.sql new file mode 100644 index 00000000..7e859ae0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 730 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q04.sql new file mode 100644 index 00000000..4742fec1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q05.sql new file mode 100644 index 00000000..132f1449 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q06.sql new file mode 100644 index 00000000..dfad7c25 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 7 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q07.sql new file mode 100644 index 00000000..351d1b86 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q08.sql new file mode 100644 index 00000000..173a1ed6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '16585','35165','50803','29851','98319','25500', + '56994','75414','37132','85627','25753', + '69413','44607','37515','53999','89221', + '11433','17527','81786','74540','41456', + '60876','83307','46014','24499','31621', + '72936','76877','25098','84090','36854', + '60857','44440','82983','10114','63227', + '93721','69397','97515','49587','38052', + '55978','57745','24991','74869','31885', + '48688','57180','90096','64301','38089', + '27999','81344','70767','80350','97768', + '69387','98032','46273','57095','95243', + '13100','14835','20631','88172','84884', + '17773','76758','26037','39040','32492', + '92272','88266','35692','13648','91342', + '71673','99672','22693','28697','43740', + '64683','79865','12649','18308','94952', + '22752','98172','48031','31450','16247', + '24461','43148','45246','87223','91771', + '43254','28730','21167','18917','30881', + '70209','64125','50095','74427','45038', + '81419','58125','87378','13111','45860', + '74551','95762','53175','36062','90898', + '47198','96511','37538','25621','31593', + '11884','83188','11729','46128','15456', + '89862','88410','81504','30833','52463', + '39672','42401','29286','19780','27928', + '20235','58346','79297','76370','87520', + '60589','87722','96833','70744','66083', + '48963','57484','84175','72311','81047', + '40618','89106','86359','59504','90019', + '74859','68317','56914','20794','88768', + '70455','51679','16232','62680','72002', + '63944','11845','63364','91216','80885', + '83800','58403','59764','12000','83818', + '26430','20821','20050','19094','90462', + '18168','27140','74568','83003','11811', + '93431','37617','70137','61054','68429', + '38799','88526','11704','84562','36386', + '35158','89840','50516','48211','93730', + '57686','19594','98315','34420','11643', + '19622','94294','64053','69901','39455', + '36429','79798','96987','83902','64259', + '73620','15348','86835','71728','80667', + '22769','89250','76991','57330','31904', + '51563','76111','59986','29384','96990', + '43134','44258','22478','47677','50557', + '60385','32655','22145','99265','92394', + '72895','86362','17193','85217','82067', + '86034','76461','91152','12074','82861', + '25935','89078','63668','39721','82845', + '25784','36135','90926','32318','68531', + '90363','58590','57539','97556','25191', + '23666','77245','56147','11549','62164', + '27167','18714','52762','90189','83326', + '29581','25037','66636','69187','83827', + '83695','58754','42106','97775','56213', + '20118','60722','22018','62048','27721', + '47927','23137','55301','78347','71887', + '27403','77143','53199','74420','42862', + '24417','53317','92953','78762','21994', + '83313','13266','48833','53350','18683', + '74614','11285','60804','37287','53715', + '16395','88288','49629','81044','56935', + '54403','60334','29125','12945','84425', + '98395','53823','72059','84796','95373', + '96384','52234','61057','98816','26600', + '61793','60203','30635','63235','10150', + '90082','54588','66927','15763','63207', + '93278','51764','44191','22825','61204', + '25860','52928','54322','13943','79772', + '28274','89996','25884','50857','99241', + '73581','51135','42495','94274','34083', + '47271','67284','99611','95964','29553', + '40139','68069','15233','14804','15685', + '33212','82229','58214','96015','59359', + '36043','57677','61268','53818','67138', + '65933','83670','52953','66941','82698', + '44531','36318','76597','95548','18039', + '56496','90826','30622','81180') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q09.sql new file mode 100644 index 00000000..cca8d0d7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 240949717 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 330786465 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 355172619 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 466914543 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 3016569 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q10.sql new file mode 100644 index 00000000..6e12bfd7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Crawford County','Ogemaw County','Emery County','Shawnee County','DeKalb County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q11.sql new file mode 100644 index 00000000..0c8ca3df --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q12.sql new file mode 100644 index 00000000..4f6b6bc7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Electronics', 'Men', 'Women') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-01-18' as date) + and (cast('1999-01-18' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q13.sql new file mode 100644 index 00000000..da64a1cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('FL', 'MN', 'OH') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'NJ', 'ND') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('SD', 'UT', 'GA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q14.sql new file mode 100644 index 00000000..f483400c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + 1 + and d_moy = 12 + and d_dom = 7) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + and d_moy = 12 + and d_dom = 7) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q15.sql new file mode 100644 index 00000000..7704820c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q16.sql new file mode 100644 index 00000000..eb7ffa52 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2002-3-01' and + (cast('2002-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'KY' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Franklin Parish','Mesa County','Wadena County','Walker County', + 'Jefferson Davis Parish' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q17.sql new file mode 100644 index 00000000..32070a34 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2000Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q18.sql new file mode 100644 index 00000000..c666a512 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = '4 yr Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (12,2,7,10,9,4) and + d_year = 2001 and + ca_state in ('KY','SD','NY' + ,'RI','GA','MS','OH') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q19.sql new file mode 100644 index 00000000..7841ed41 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=98 + and d_moy=11 + and d_year=2000 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q20.sql new file mode 100644 index 00000000..cb65fa8a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Home', 'Music', 'Women') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2001-04-20' as date) + and (cast('2001-04-20' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q21.sql new file mode 100644 index 00000000..543c58e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-02-17' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1998-02-17' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1998-02-17' as date) - INTERVAL '30' DAY) + and (cast ('1998-02-17' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q22.sql new file mode 100644 index 00000000..ea691234 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1201 and 1201 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q23.sql new file mode 100644 index 00000000..fb5f08c8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q24.sql new file mode 100644 index 00000000..64e4245c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'olive' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'puff' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q25.sql new file mode 100644 index 00000000..bdd0ee82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q26.sql new file mode 100644 index 00000000..a36531b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q27.sql new file mode 100644 index 00000000..707b789e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = 'Secondary' and + d_year = 1998 and + s_state in ('MO','MN', 'OH', 'LA', 'GA', 'TN') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q28.sql new file mode 100644 index 00000000..ca7abfc6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 26 and 26+10 + or ss_coupon_amt between 2323 and 2323+1000 + or ss_wholesale_cost between 6 and 6+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 44 and 44+10 + or ss_coupon_amt between 2264 and 2264+1000 + or ss_wholesale_cost between 32 and 32+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 19 and 19+10 + or ss_coupon_amt between 17738 and 17738+1000 + or ss_wholesale_cost between 75 and 75+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 127 and 127+10 + or ss_coupon_amt between 17681 and 17681+1000 + or ss_wholesale_cost between 44 and 44+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 95 and 95+10 + or ss_coupon_amt between 9219 and 9219+1000 + or ss_wholesale_cost between 62 and 62+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 165 and 165+10 + or ss_coupon_amt between 12682 and 12682+1000 + or ss_wholesale_cost between 80 and 80+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q29.sql new file mode 100644 index 00000000..59118672 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q30.sql new file mode 100644 index 00000000..17ba4af4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TX' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q31.sql new file mode 100644 index 00000000..19d44142 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2001 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2001 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2001 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2001 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2001 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2001 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q32.sql new file mode 100644 index 00000000..46242255 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 425 +and i_item_sk = cs_item_sk +and d_date between DATE '2001-01-17' and + (cast('2001-01-17' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2001-01-17' and + (cast('2001-01-17' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q33.sql new file mode 100644 index 00000000..32fa1abe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q34.sql new file mode 100644 index 00000000..e663e684 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Jefferson Davis Parish','Barrow County','Pipestone County','Mesa County', + 'Henry County','Tehama County','Mariposa County','Dade County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q35.sql new file mode 100644 index 00000000..13b01dfd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + sum(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + sum(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + sum(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q36.sql new file mode 100644 index 00000000..23209d1e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('GA','NE','AL','GA', + 'CO','MI','KS','FL') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q37.sql new file mode 100644 index 00000000..93b5a2d0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 38 and 38 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-02-25' as date) and (cast('2000-02-25' as date) + INTERVAL '60' DAY) + and i_manufact_id in (979,721,995,819) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q38.sql new file mode 100644 index 00000000..b1e83067 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1191 and 1191 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1191 and 1191 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1191 and 1191 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q39.sql new file mode 100644 index 00000000..41924652 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q40.sql new file mode 100644 index 00000000..d497b019 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-06-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2000-06-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2000-06-02' as date) - INTERVAL '30' DAY) + and (cast ('2000-06-02' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q41.sql new file mode 100644 index 00000000..e107145f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 854 and 854+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'cornsilk' or i_color = 'chartreuse') and + (i_units = 'Carton' or i_units = 'Unknown') and + (i_size = 'economy' or i_size = 'petite') + ) or + (i_category = 'Women' and + (i_color = 'grey' or i_color = 'goldenrod') and + (i_units = 'Ounce' or i_units = 'Pallet') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'frosted' or i_color = 'olive') and + (i_units = 'Dram' or i_units = 'Case') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'green' or i_color = 'bisque') and + (i_units = 'Pound' or i_units = 'Box') and + (i_size = 'economy' or i_size = 'petite') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'wheat' or i_color = 'orchid') and + (i_units = 'Gross' or i_units = 'Cup') and + (i_size = 'economy' or i_size = 'petite') + ) or + (i_category = 'Women' and + (i_color = 'seashell' or i_color = 'cream') and + (i_units = 'Tsp' or i_units = 'Ton') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'antique' or i_color = 'red') and + (i_units = 'Bundle' or i_units = 'Each') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'lace' or i_color = 'floral') and + (i_units = 'Gram' or i_units = 'Dozen') and + (i_size = 'economy' or i_size = 'petite') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q42.sql new file mode 100644 index 00000000..ba1dd9be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=1998 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q43.sql new file mode 100644 index 00000000..3be4f298 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2001 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q44.sql new file mode 100644 index 00000000..a6341d71 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 316 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 316 + and ss_cdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 316 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 316 + and ss_cdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q45.sql new file mode 100644 index 00000000..777d26bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_county, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2001 + group by ca_zip, ca_county + order by ca_zip, ca_county + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q46.sql new file mode 100644 index 00000000..eef858ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 7 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Jamestown','Harmony','Clifton','Winchester','Lebanon') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q47.sql new file mode 100644 index 00000000..49560c8f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q48.sql new file mode 100644 index 00000000..448678c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'MD', 'WI') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CA', 'NJ', 'NM') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IN', 'FL', 'MT') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q49.sql new file mode 100644 index 00000000..8831bc85 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q50.sql new file mode 100644 index 00000000..753ed6f6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1999 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q51.sql new file mode 100644 index 00000000..c3b280b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1222 and 1222+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1222 and 1222+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q52.sql new file mode 100644 index 00000000..dd28b998 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q53.sql new file mode 100644 index 00000000..1d3aed2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1187,1187+1,1187+2,1187+3,1187+4,1187+5,1187+6,1187+7,1187+8,1187+9,1187+10,1187+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q54.sql new file mode 100644 index 00000000..437622fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Books' + and i_class = 'parenting' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 5 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 5) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 5) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q55.sql new file mode 100644 index 00000000..1864fb23 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=75 + and d_moy=11 + and d_year=1998 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q56.sql new file mode 100644 index 00000000..522855cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('indian','blue','rose')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('indian','blue','rose')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('indian','blue','rose')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q57.sql new file mode 100644 index 00000000..1ab3e7bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q58.sql new file mode 100644 index 00000000..be001a9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-07-17')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-07-17')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-07-17')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q59.sql new file mode 100644 index 00000000..860e4aff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1200 and 1200 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1200+ 12 and 1200 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q60.sql new file mode 100644 index 00000000..dbb56e6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q61.sql new file mode 100644 index 00000000..14312d93 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q62.sql new file mode 100644 index 00000000..004678cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1223 and 1223 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q63.sql new file mode 100644 index 00000000..e50315e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1193,1193+1,1193+2,1193+3,1193+4,1193+5,1193+6,1193+7,1193+8,1193+9,1193+10,1193+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q64.sql new file mode 100644 index 00000000..5a88dfa1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('rose','mint','steel','red','plum','drab') and + i_current_price between 26 and 26 + 10 and + i_current_price between 26 + 1 and 26 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2001 and + cs2.syear = 2001 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q65.sql new file mode 100644 index 00000000..9d3a62cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1191 and 1191+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1191 and 1191+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q66.sql new file mode 100644 index 00000000..572878cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ALLIANCE' || ',' || 'LATVIAN' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 56710 and 56710+28800 + and sm_carrier in ('ALLIANCE','LATVIAN') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ALLIANCE' || ',' || 'LATVIAN' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 56710 AND 56710+28800 + and sm_carrier in ('ALLIANCE','LATVIAN') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q67.sql new file mode 100644 index 00000000..e9f1c88e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1183 and 1183+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q68.sql new file mode 100644 index 00000000..62ca4dbc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 7 or + household_demographics.hd_vehicle_count= -1) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Mount Pleasant','Chester') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q69.sql new file mode 100644 index 00000000..2aac1e2d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('TX','IL','WI') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q70.sql new file mode 100644 index 00000000..e3776024 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1193 and 1193+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1193 and 1193+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q72.sql new file mode 100644 index 00000000..6413ceb9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 2001 + and cd_marital_status = 'M' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q73.sql new file mode 100644 index 00000000..77f05664 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Mobile County','Camden County','Somerset County','Pipestone County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q74.sql new file mode 100644 index 00000000..017da873 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q75.sql new file mode 100644 index 00000000..7b1a51bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Children') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q76.sql new file mode 100644 index 00000000..ce864036 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_store_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_store_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_web_page_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_hdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q77.sql new file mode 100644 index 00000000..0ca42dc0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-04' as date) + and (cast('1998-08-04' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q78.sql new file mode 100644 index 00000000..7cf5d4b7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2001 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q79.sql new file mode 100644 index 00000000..db828f88 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 9 or household_demographics.hd_vehicle_count > 0) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q80.sql new file mode 100644 index 00000000..0c4d714e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-27' as date) + and (cast('2002-08-27' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-27' as date) + and (cast('2002-08-27' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-27' as date) + and (cast('2002-08-27' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q81.sql new file mode 100644 index 00000000..f705dc05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q82.sql new file mode 100644 index 00000000..d759ad2a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 52 and 52+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-05-18' as date) and (cast('2001-05-18' as date) + INTERVAL '60' DAY) + and i_manufact_id in (288,989,876,448) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q83.sql new file mode 100644 index 00000000..46fd6f0a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-03-04',DATE '2000-08-08',DATE '2000-11-20'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-03-04',DATE '2000-08-08',DATE '2000-11-20'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-03-04',DATE '2000-08-08',DATE '2000-11-20'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q84.sql new file mode 100644 index 00000000..2ca6dd9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Harmony' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 50052 + and ib_upper_bound <= 50052 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q85.sql new file mode 100644 index 00000000..67060b94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('IA', 'MO', 'GA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('IN', 'NH', 'MI') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MN', 'ND', 'OK') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q86.sql new file mode 100644 index 00000000..20051b42 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1210 and 1210+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q87.sql new file mode 100644 index 00000000..7301314d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1205 and 1205+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1205 and 1205+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1205 and 1205+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q88.sql new file mode 100644 index 00000000..1028e47b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q89.sql new file mode 100644 index 00000000..343224e9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1998) and + ((i_category in ('Books','Home','Electronics') and + i_class in ('self-help','tables','automotive') + ) + or (i_category in ('Men','Sports','Women') and + i_class in ('accessories','archery','swimwear') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q90.sql new file mode 100644 index 00000000..c5bed8e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 7 and 7+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 20 and 20+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q91.sql new file mode 100644 index 00000000..54788e95 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '501-1000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q92.sql new file mode 100644 index 00000000..e8545732 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 806 +and i_item_sk = ws_item_sk +and d_date between DATE '2001-01-12' and + (cast('2001-01-12' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2001-01-12' and + (cast('2001-01-12' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q93.sql new file mode 100644 index 00000000..1b3b1cc3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'unauthoized purchase') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q94.sql new file mode 100644 index 00000000..ae806762 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-4-01' and + (cast('2000-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'PA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q95.sql new file mode 100644 index 00000000..0e4d0384 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-4-01' and + (cast('1999-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q96.sql new file mode 100644 index 00000000..90cc7564 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 9 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q97.sql new file mode 100644 index 00000000..dd7e5395 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1215 and 1215 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1215 and 1215 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q98.sql new file mode 100644 index 00000000..38902ccb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Women', 'Shoes', 'Men') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1998-06-26' as date) + and (cast('1998-06-26' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s12/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s12/q99.sql new file mode 100644 index 00000000..1b77fb0d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s12/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1202 and 1202 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q01.sql new file mode 100644 index 00000000..989a9879 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_STORE_CREDIT) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2002 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'WA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q03.sql new file mode 100644 index 00000000..441977b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 756 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q04.sql new file mode 100644 index 00000000..59bf827c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_c_firstyear.dyear = 2001 + and t_c_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q05.sql new file mode 100644 index 00000000..780e8974 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-04' as date) + and (cast('2001-08-04' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-04' as date) + and (cast('2001-08-04' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-04' as date) + and (cast('2001-08-04' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q06.sql new file mode 100644 index 00000000..e22514d6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 3 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q07.sql new file mode 100644 index 00000000..7c1b4ed4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q08.sql new file mode 100644 index 00000000..2f8845e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '55215','83543','51054','33023','58336','26392', + '29749','69488','46347','13871','52670', + '86507','80654','83644','50149','33407', + '47634','21418','93193','45013','70143', + '27905','31236','60528','71601','10408', + '31227','38569','49918','59985','54928', + '20222','41996','93646','73459','89823', + '15665','71040','82412','68691','69921', + '95096','88953','85643','94231','22029', + '94275','32950','84853','55649','95243', + '36510','59444','70400','68552','10942', + '64533','86151','96499','81951','90655', + '38193','34055','75013','62311','22130', + '34128','56229','55443','19330','46906', + '63337','72907','49187','80949','83709', + '80050','48073','28559','26064','73790', + '58195','15317','92033','94730','70380', + '46624','52925','10889','95308','73529', + '99618','62171','92472','67982','96135', + '24827','67482','91524','81502','46520', + '86495','71486','71852','32971','28631', + '12528','29575','73379','66378','44370', + '18142','15235','55814','24891','85671', + '43637','37300','67006','67478','93151', + '30189','44066','98472','12783','43233', + '53238','16642','46951','71863','74930', + '17280','70424','45316','19638','49558', + '87909','45423','83870','99288','77332', + '82551','89439','67467','66502','73069', + '41371','43234','66860','64650','98723', + '22039','54981','12317','44384','75552', + '60792','15641','47086','62664','22566', + '39992','51622','14752','61943','21192', + '90557','79514','51555','11908','62183', + '76347','82875','13332','68709','70623', + '84987','20747','38796','39939','71550', + '82414','21397','85840','35110','65843', + '21628','94102','95932','99651','34455', + '46990','28592','85986','39249','21175', + '39366','10787','41140','40024','71705', + '44308','98745','67535','96131','19613', + '61034','47261','35832','51905','54147', + '37795','71739','22877','77803','17661', + '67863','96253','53566','88948','16462', + '18502','42197','47256','85065','30617', + '88279','54209','11162','62557','24137', + '17910','41950','82860','80719','13780', + '88602','21818','39457','71609','33326', + '30911','32201','54697','31759','54412', + '10003','83894','24146','59379','72892', + '90579','15537','15882','99980','18994', + '51035','99592','81518','97346','13853', + '61659','85077','70821','88283','94976', + '87790','70786','51651','29549','64771', + '75645','97445','40278','71976','95093', + '52447','57374','16628','76726','92320', + '32153','10963','25486','95606','22065', + '83814','32648','37700','72019','79648', + '58070','69450','87919','66021','89463', + '97047','20769','22119','35922','34439', + '24430','84101','21055','69584','10768', + '20286','95070','62141','76246','67216', + '64643','51528','11261','40535','29249', + '13859','10742','97117','22805','95450', + '71781','86358','19502','96987','91863', + '22687','97761','68902','88539','44416', + '33687','20501','80963','32711','63884', + '77756','77859','49485','14700','34191', + '55584','28612','19783','85155','93065', + '38271','46639','14864','46868','27638', + '29362','36939','91540','70749','12963', + '58441','67541','73608','60071','61416', + '91370','52336','72694','47554','52124', + '46329','89385','67021','87191','53772', + '80808','74741','87410','98111','67752', + '89158','21471','46139','66451','44694', + '64153','46635','87184','16304','27051', + '30915','36323','92770','76686','41902', + '16752','92047','97577','62426','71768', + '58159','24901','53002','62852') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q09.sql new file mode 100644 index 00000000..b27ad546 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 437283862 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 349089985 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 16550780 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 65158428 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 386603715 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q10.sql new file mode 100644 index 00000000..e774683d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('McLean County','Jackson County','Adams County','Escambia County','Crawford County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q11.sql new file mode 100644 index 00000000..a6fef7b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q12.sql new file mode 100644 index 00000000..fe9cd228 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Books', 'Men', 'Sports') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1998-04-13' as date) + and (cast('1998-04-13' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q13.sql new file mode 100644 index 00000000..c140eab7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Unknown' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('CA', 'WV', 'AL') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NC', 'IL', 'GA') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('KS', 'IA', 'MS') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q14.sql new file mode 100644 index 00000000..429fe1bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 10) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 10) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q15.sql new file mode 100644 index 00000000..46e9f91b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q16.sql new file mode 100644 index 00000000..b2a5fdc3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('San Miguel County','Dauphin County','Bronx County','Ziebach County', + 'Fairfield County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q18.sql new file mode 100644 index 00000000..f6193958 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Advanced Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (4,11,10,7,1,9) and + d_year = 2002 and + ca_state in ('MN','MT','KS' + ,'GA','WV','OH','MS') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q19.sql new file mode 100644 index 00000000..997717a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=37 + and d_moy=12 + and d_year=2001 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q20.sql new file mode 100644 index 00000000..4149c7be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Children', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1999-03-04' as date) + and (cast('1999-03-04' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q21.sql new file mode 100644 index 00000000..cd6758fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-04-11' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2002-04-11' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2002-04-11' as date) - INTERVAL '30' DAY) + and (cast ('2002-04-11' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q22.sql new file mode 100644 index 00000000..987f70cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1217 and 1217 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q23.sql new file mode 100644 index 00000000..191fba16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q24.sql new file mode 100644 index 00000000..d427e086 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'green' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'steel' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q25.sql new file mode 100644 index 00000000..8aee7f72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1998 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q26.sql new file mode 100644 index 00000000..0c6378f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q27.sql new file mode 100644 index 00000000..421cf1e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = 'College' and + d_year = 2000 and + s_state in ('MN','NC', 'NY', 'NM', 'PA', 'AL') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q28.sql new file mode 100644 index 00000000..9ad2082c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 18 and 18+10 + or ss_coupon_amt between 17679 and 17679+1000 + or ss_wholesale_cost between 24 and 24+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 179 and 179+10 + or ss_coupon_amt between 9302 and 9302+1000 + or ss_wholesale_cost between 36 and 36+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 17 and 17+10 + or ss_coupon_amt between 14103 and 14103+1000 + or ss_wholesale_cost between 71 and 71+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 133 and 133+10 + or ss_coupon_amt between 2952 and 2952+1000 + or ss_wholesale_cost between 15 and 15+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 57 and 57+10 + or ss_coupon_amt between 760 and 760+1000 + or ss_wholesale_cost between 19 and 19+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 64 and 64+10 + or ss_coupon_amt between 1199 and 1199+1000 + or ss_wholesale_cost between 74 and 74+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q29.sql new file mode 100644 index 00000000..38cfd3a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_quantity) as store_sales_quantity + ,min(sr_return_quantity) as store_returns_quantity + ,min(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q30.sql new file mode 100644 index 00000000..01ac347c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'WV' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q31.sql new file mode 100644 index 00000000..e50d8538 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q32.sql new file mode 100644 index 00000000..1642193d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 553 +and i_item_sk = cs_item_sk +and d_date between DATE '1999-03-22' and + (cast('1999-03-22' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1999-03-22' and + (cast('1999-03-22' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q33.sql new file mode 100644 index 00000000..e10d5def --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q34.sql new file mode 100644 index 00000000..9cdbfe77 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Chambers County','Gage County','Carter County','Harmon County', + 'Brazos County','Van Buren County','Jefferson Davis Parish','Hubbard County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q35.sql new file mode 100644 index 00000000..bb69609b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + max(cd_dep_count) aggone1, + avg(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + max(cd_dep_employed_count) aggone2, + avg(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + max(cd_dep_college_count) aggone3, + avg(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q36.sql new file mode 100644 index 00000000..f5b7adcb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('WV','TX','MN','AL', + 'GA','AL','MI','MI') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q37.sql new file mode 100644 index 00000000..36151001 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 33 and 33 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-02-19' as date) and (cast('2001-02-19' as date) + INTERVAL '60' DAY) + and i_manufact_id in (959,988,745,838) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q38.sql new file mode 100644 index 00000000..14361ad9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q39.sql new file mode 100644 index 00000000..c039c82a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2001 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2001 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q40.sql new file mode 100644 index 00000000..fb29b443 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-03-03' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-03-03' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-03-03' as date) - INTERVAL '30' DAY) + and (cast ('2001-03-03' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q41.sql new file mode 100644 index 00000000..e6b027a0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 989 and 989+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'bisque' or i_color = 'pale') and + (i_units = 'Lb' or i_units = 'Bundle') and + (i_size = 'petite' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'peach' or i_color = 'burnished') and + (i_units = 'Box' or i_units = 'Dozen') and + (i_size = 'medium' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'cream' or i_color = 'chocolate') and + (i_units = 'Tbl' or i_units = 'Tsp') and + (i_size = 'extra large' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'midnight' or i_color = 'mint') and + (i_units = 'Gross' or i_units = 'Case') and + (i_size = 'petite' or i_size = 'economy') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'wheat' or i_color = 'aquamarine') and + (i_units = 'Bunch' or i_units = 'Ton') and + (i_size = 'petite' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'sky' or i_color = 'lace') and + (i_units = 'Each' or i_units = 'Unknown') and + (i_size = 'medium' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'papaya' or i_color = 'orchid') and + (i_units = 'N/A' or i_units = 'Oz') and + (i_size = 'extra large' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'yellow' or i_color = 'maroon') and + (i_units = 'Dram' or i_units = 'Ounce') and + (i_size = 'petite' or i_size = 'economy') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q42.sql new file mode 100644 index 00000000..df1387e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2002 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q43.sql new file mode 100644 index 00000000..68b895bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 1999 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q44.sql new file mode 100644 index 00000000..fc6ac3ee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 44 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 44 + and ss_promo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 44 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 44 + and ss_promo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q45.sql new file mode 100644 index 00000000..6ffaded3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q46.sql new file mode 100644 index 00000000..43cf88c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 2) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Stringtown','Hollywood','Five Points','Melrose','Beulah') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q47.sql new file mode 100644 index 00000000..c1bd970b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q48.sql new file mode 100644 index 00000000..8db86af4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'College' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CA', 'CO', 'PA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MO', 'MI', 'WI') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'WA', 'MT') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q49.sql new file mode 100644 index 00000000..8831bc85 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q50.sql new file mode 100644 index 00000000..e7752519 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q51.sql new file mode 100644 index 00000000..90bb1a9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1177 and 1177+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1177 and 1177+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q52.sql new file mode 100644 index 00000000..0dba5848 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1999 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q53.sql new file mode 100644 index 00000000..a1bc029a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1195,1195+1,1195+2,1195+3,1195+4,1195+5,1195+6,1195+7,1195+8,1195+9,1195+10,1195+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q54.sql new file mode 100644 index 00000000..5544cc33 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Women' + and i_class = 'dresses' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 2001 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2001 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2001 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q55.sql new file mode 100644 index 00000000..52c24ef8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=42 + and d_moy=12 + and d_year=2001 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q56.sql new file mode 100644 index 00000000..b98f9ab1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('navy','goldenrod','blue')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','goldenrod','blue')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','goldenrod','blue')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q57.sql new file mode 100644 index 00000000..1357cac0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q58.sql new file mode 100644 index 00000000..53447c20 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-05-12')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-05-12')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2001-05-12')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q59.sql new file mode 100644 index 00000000..b64c11d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1210 and 1210 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1210+ 12 and 1210 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q60.sql new file mode 100644 index 00000000..8e082fb2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q61.sql new file mode 100644 index 00000000..2dc79663 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Sports' + and s_gmt_offset = -7 + and d_year = 2002 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q62.sql new file mode 100644 index 00000000..6902b247 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1216 and 1216 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q63.sql new file mode 100644 index 00000000..5045bd5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1219,1219+1,1219+2,1219+3,1219+4,1219+5,1219+6,1219+7,1219+8,1219+9,1219+10,1219+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q64.sql new file mode 100644 index 00000000..02470a31 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('deep','medium','red','lemon','tomato','sky') and + i_current_price between 71 and 71 + 10 and + i_current_price between 71 + 1 and 71 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q65.sql new file mode 100644 index 00000000..e0652836 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1195 and 1195+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1195 and 1195+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q66.sql new file mode 100644 index 00000000..064792a7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'LATVIAN' || ',' || 'HARMSTORF' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 4478 and 4478+28800 + and sm_carrier in ('LATVIAN','HARMSTORF') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'LATVIAN' || ',' || 'HARMSTORF' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 4478 AND 4478+28800 + and sm_carrier in ('LATVIAN','HARMSTORF') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q67.sql new file mode 100644 index 00000000..dd46d47f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1214 and 1214+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q68.sql new file mode 100644 index 00000000..2f7968bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 9 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Jamestown','Edgewood') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q69.sql new file mode 100644 index 00000000..e0fbd87f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('ME','PA','NC') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q70.sql new file mode 100644 index 00000000..dceefb59 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1223 and 1223+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1223 and 1223+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q72.sql new file mode 100644 index 00000000..0de5d2bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 2000 + and cd_marital_status = 'D' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q73.sql new file mode 100644 index 00000000..c8e90662 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Furnas County','Red River Parish','Gage County','Kittitas County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q74.sql new file mode 100644 index 00000000..e499928c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,1,2 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q75.sql new file mode 100644 index 00000000..a80a038d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Jewelry') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q76.sql new file mode 100644 index 00000000..eb050e2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_customer_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_customer_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_hdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q77.sql new file mode 100644 index 00000000..23380c12 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-22' as date) + and (cast('2000-08-22' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q78.sql new file mode 100644 index 00000000..35f34084 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2000 +order by + ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q79.sql new file mode 100644 index 00000000..16c67357 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 3 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q80.sql new file mode 100644 index 00000000..d76feb65 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-05' as date) + and (cast('1998-08-05' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-05' as date) + and (cast('1998-08-05' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-05' as date) + and (cast('1998-08-05' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q81.sql new file mode 100644 index 00000000..03dd81c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TX' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q82.sql new file mode 100644 index 00000000..f4d02166 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 87 and 87+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-04-15' as date) and (cast('2000-04-15' as date) + INTERVAL '60' DAY) + and i_manufact_id in (776,391,805,209) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q83.sql new file mode 100644 index 00000000..e14fd3bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-06-21',DATE '2002-08-21',DATE '2002-11-09'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-06-21',DATE '2002-08-21',DATE '2002-11-09'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-06-21',DATE '2002-08-21',DATE '2002-11-09'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q84.sql new file mode 100644 index 00000000..0fa34c38 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Bridgeport' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 55100 + and ib_upper_bound <= 55100 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q85.sql new file mode 100644 index 00000000..8a7a3ef3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('IL', 'NY', 'AR') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MO', 'NE', 'VA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('KS', 'GA', 'OR') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q86.sql new file mode 100644 index 00000000..1bc4ace5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1198 and 1198+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q87.sql new file mode 100644 index 00000000..ff103eb3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1188 and 1188+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1188 and 1188+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1188 and 1188+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q88.sql new file mode 100644 index 00000000..1106e5a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q89.sql new file mode 100644 index 00000000..238008d5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2002) and + ((i_category in ('Home','Shoes','Sports') and + i_class in ('lighting','womens','optics') + ) + or (i_category in ('Books','Music','Electronics') and + i_class in ('computers','pop','stereo') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q90.sql new file mode 100644 index 00000000..20a374cd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 6 and 6+1 + and household_demographics.hd_dep_count = 4 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 17 and 17+1 + and household_demographics.hd_dep_count = 4 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q91.sql new file mode 100644 index 00000000..24c1f974 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2002 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '0-500%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q92.sql new file mode 100644 index 00000000..6b5242d0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 6 +and i_item_sk = ws_item_sk +and d_date between DATE '2001-02-08' and + (cast('2001-02-08' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2001-02-08' and + (cast('2001-02-08' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q93.sql new file mode 100644 index 00000000..41625d6f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 48') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q94.sql new file mode 100644 index 00000000..a3dd3397 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-2-01' and + (cast('2001-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TN' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q95.sql new file mode 100644 index 00000000..8efb3b65 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-4-01' and + (cast('2000-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'NC' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q96.sql new file mode 100644 index 00000000..d19dfe77 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 5 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q97.sql new file mode 100644 index 00000000..c7fefa50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q98.sql new file mode 100644 index 00000000..15ddafbe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Children', 'Books', 'Jewelry') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-06-09' as date) + and (cast('1999-06-09' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s13/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s13/q99.sql new file mode 100644 index 00000000..baf37bdd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s13/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1191 and 1191 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q01.sql new file mode 100644 index 00000000..d0f09dfc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1999 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'SD' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q03.sql new file mode 100644 index 00000000..a5da004b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 838 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q04.sql new file mode 100644 index 00000000..bb2237a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q05.sql new file mode 100644 index 00000000..72c58399 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1998-08-29' as date) + and (cast('1998-08-29' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1998-08-29' as date) + and (cast('1998-08-29' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1998-08-29' as date) + and (cast('1998-08-29' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q06.sql new file mode 100644 index 00000000..6ca54c53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 4 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q07.sql new file mode 100644 index 00000000..69a256e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Secondary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q08.sql new file mode 100644 index 00000000..c56f1795 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '35683','40612','20366','72512','73774','75985', + '66562','45161','74111','55813','77136', + '83881','50121','57045','35272','93028', + '71300','43513','37313','13312','20774', + '99903','63032','34973','83757','98642', + '59736','30465','63600','82521','45167', + '17559','56610','45829','48751','27902', + '51028','76392','10421','46779','39213', + '32885','59092','74088','39853','92016', + '34727','60679','77295','98386','48284', + '97344','78006','96905','11424','88583', + '10980','11726','21760','15133','83104', + '47915','87035','38313','68748','92955', + '70834','39179','52521','66902','67018', + '62916','30164','52679','17072','19394', + '43201','11397','35239','94647','97089', + '23995','53937','90369','83300','34198', + '66089','82427','17826','42814','23932', + '98852','75752','99471','72503','28285', + '78444','97200','88725','77611','23495', + '89704','67414','75488','19316','79799', + '64288','43878','20126','99767','89310', + '57447','15350','82337','84500','60543', + '42435','62884','55885','88731','30729', + '12959','33400','77017','77133','59772', + '87459','83264','95327','82399','94664', + '94501','62286','54975','24119','26446', + '84696','85440','52015','82473','63237', + '30764','66044','53623','69982','52895', + '70623','74110','72791','69628','42447', + '69451','73030','10361','17462','82001', + '31678','64157','73988','60904','19101', + '57061','21045','62343','70366','57216', + '96561','15780','10657','27730','42690', + '44459','76709','32528','93467','11856', + '92774','24131','53028','23976','32848', + '45808','68133','66159','96304','16859', + '34998','91170','19294','62367','28607', + '24757','86104','85903','42253','57088', + '51438','33713','77173','61732','33286', + '19850','36352','36557','39607','28512', + '46817','10637','20141','58229','66258', + '78513','22607','68513','47085','29320', + '86057','25548','84766','97631','78136', + '90627','57408','49315','77545','24145', + '25403','19232','37841','95951','99564', + '73539','47668','88842','83935','39121', + '79733','94255','64789','33234','31464', + '71915','36476','75171','32697','97117', + '54388','40646','48734','71181','66771', + '12410','24252','19997','30196','42970', + '17381','36316','35548','17287','82384', + '92344','22240','88538','10278','45847', + '60167','96068','90897','83621','34305', + '46771','84378','88705','93794','45129', + '41807','47252','46501','23295','66317', + '37979','67444','24748','50860','49643', + '53211','79669','41340','45994','80267', + '41450','26105','68112','24074','12787', + '87159','18478','19350','98406','65871', + '55936','39215','32061','93884','80727', + '73015','63220','12288','61417','25830', + '50018','98593','40233','89676','83579', + '25996','38798','71020','15181','36422', + '76486','94177','71635','89891','17863', + '26420','18347','60847','96267','50799', + '76342','15718','71857','78615','96105', + '82756','95474','28543','60937','72710', + '41461','63525','78643','95564','78044', + '34864','22362','62019','97904','89909', + '56878','12682','60625','58094','90306', + '69752','87671','10515','95212','79285', + '53392','17868','41710','77890','60182', + '71772','16915','93427','27098','32321', + '86011','86942','10079','90481','89133', + '51779','49018','66833','58498','55669', + '74534','19891','35164','39643','57562', + '61212','81303','98330','92487','81897', + '27133','91041','15975','96459','49669', + '16838','14165','53579','93267') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q09.sql new file mode 100644 index 00000000..96b9c4ce --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 296201016 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 340972206 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 151749269 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 16818144 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 232785551 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q10.sql new file mode 100644 index 00000000..3bad127f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Gray County','Taylor County','Dunn County','Calcasieu Parish','Menard County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q11.sql new file mode 100644 index 00000000..84700d05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q12.sql new file mode 100644 index 00000000..a373cd96 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Women', 'Men', 'Home') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-02-11' as date) + and (cast('1999-02-11' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q13.sql new file mode 100644 index 00000000..17f982ce --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'College' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IL', 'IN', 'AR') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('WI', 'MT', 'TX') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('CA', 'OH', 'TN') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q14.sql new file mode 100644 index 00000000..9ad65985 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 6) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 6) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q16.sql new file mode 100644 index 00000000..2725048e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-5-01' and + (cast('2001-5-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'GA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Jefferson Davis Parish','Gage County','Barrow County','Daviess County', + 'Mesa County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q17.sql new file mode 100644 index 00000000..ad997218 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2002Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2002Q1','2002Q2','2002Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2002Q1','2002Q2','2002Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q18.sql new file mode 100644 index 00000000..0e74711a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = '2 yr Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (3,7,4,11,2,8) and + d_year = 2001 and + ca_state in ('WV','NE','IA' + ,'OH','IL','KY','GA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q19.sql new file mode 100644 index 00000000..b290e25d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=49 + and d_moy=11 + and d_year=1999 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q20.sql new file mode 100644 index 00000000..a975e6dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Shoes', 'Music') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-06-15' as date) + and (cast('2000-06-15' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q21.sql new file mode 100644 index 00000000..7752f008 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-04-14' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1999-04-14' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1999-04-14' as date) - INTERVAL '30' DAY) + and (cast ('1999-04-14' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q22.sql new file mode 100644 index 00000000..19e0b917 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1221 and 1221 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q23.sql new file mode 100644 index 00000000..191fba16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 4 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 4 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q24.sql new file mode 100644 index 00000000..9717e9d5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'coral' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'frosted' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q25.sql new file mode 100644 index 00000000..098abcee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_net_profit) as store_sales_profit + ,avg(sr_net_loss) as store_returns_loss + ,avg(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1998 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q26.sql new file mode 100644 index 00000000..c83df7b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q27.sql new file mode 100644 index 00000000..70f8bd5f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = '2 yr Degree' and + d_year = 2001 and + s_state in ('WA','MI', 'GA', 'CO', 'MI', 'AL') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q28.sql new file mode 100644 index 00000000..011dfb93 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 190 and 190+10 + or ss_coupon_amt between 16577 and 16577+1000 + or ss_wholesale_cost between 11 and 11+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 47 and 47+10 + or ss_coupon_amt between 17491 and 17491+1000 + or ss_wholesale_cost between 59 and 59+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 186 and 186+10 + or ss_coupon_amt between 10038 and 10038+1000 + or ss_wholesale_cost between 73 and 73+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 132 and 132+10 + or ss_coupon_amt between 6672 and 6672+1000 + or ss_wholesale_cost between 53 and 53+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 23 and 23+10 + or ss_coupon_amt between 3743 and 3743+1000 + or ss_wholesale_cost between 4 and 4+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 165 and 165+10 + or ss_coupon_amt between 9042 and 9042+1000 + or ss_wholesale_cost between 31 and 31+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q29.sql new file mode 100644 index 00000000..c2d5c613 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q30.sql new file mode 100644 index 00000000..f1298359 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2002 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q31.sql new file mode 100644 index 00000000..227fdc1f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2000 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2000 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2000 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2000 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2000 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2000 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.ca_county; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q32.sql new file mode 100644 index 00000000..5a16a8ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 714 +and i_item_sk = cs_item_sk +and d_date between DATE '2001-02-12' and + (cast('2001-02-12' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2001-02-12' and + (cast('2001-02-12' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q33.sql new file mode 100644 index 00000000..89e5d6f0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q34.sql new file mode 100644 index 00000000..500f8ccb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Oglethorpe County','Lunenburg County','Van Buren County','Arthur County', + 'Mesa County','Saginaw County','Perry County','Harper County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q35.sql new file mode 100644 index 00000000..e3e50ce1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + avg(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + avg(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + avg(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q36.sql new file mode 100644 index 00000000..0685c05f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('TX','TN','WV','WA', + 'SC','KS','NE','MI') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q37.sql new file mode 100644 index 00000000..04d0be8b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 61 and 61 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-04-09' as date) and (cast('1999-04-09' as date) + INTERVAL '60' DAY) + and i_manufact_id in (679,916,804,809) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q38.sql new file mode 100644 index 00000000..a1015413 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1221 and 1221 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1221 and 1221 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1221 and 1221 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q39.sql new file mode 100644 index 00000000..84028966 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q40.sql new file mode 100644 index 00000000..26ca50b7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-04-28' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-04-28' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-04-28' as date) - INTERVAL '30' DAY) + and (cast ('2001-04-28' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q41.sql new file mode 100644 index 00000000..d18d75c2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 848 and 848+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'plum' or i_color = 'steel') and + (i_units = 'Dram' or i_units = 'Ton') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'burnished' or i_color = 'snow') and + (i_units = 'Cup' or i_units = 'Pallet') and + (i_size = 'petite' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'green' or i_color = 'aquamarine') and + (i_units = 'Oz' or i_units = 'N/A') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'blanched' or i_color = 'chiffon') and + (i_units = 'Tbl' or i_units = 'Box') and + (i_size = 'small' or i_size = 'extra large') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'pink' or i_color = 'gainsboro') and + (i_units = 'Pound' or i_units = 'Bundle') and + (i_size = 'small' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'spring' or i_color = 'smoke') and + (i_units = 'Unknown' or i_units = 'Lb') and + (i_size = 'petite' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'tan' or i_color = 'misty') and + (i_units = 'Ounce' or i_units = 'Gross') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'bisque' or i_color = 'lavender') and + (i_units = 'Each' or i_units = 'Tsp') and + (i_size = 'small' or i_size = 'extra large') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q42.sql new file mode 100644 index 00000000..58e44004 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2000 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q43.sql new file mode 100644 index 00000000..51def389 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -8 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q44.sql new file mode 100644 index 00000000..ef36720f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 527 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 527 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 527 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 527 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q45.sql new file mode 100644 index 00000000..0c3427f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q46.sql new file mode 100644 index 00000000..0536caa0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 5 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Petersburg','Farmington','Webster','Maple Grove','Waterloo') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q47.sql new file mode 100644 index 00000000..5b4e8e00 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q48.sql new file mode 100644 index 00000000..308ccca2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2000 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('SC', 'KS', 'NY') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IN', 'SD', 'LA') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MI', 'WI', 'MO') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q49.sql new file mode 100644 index 00000000..baab828a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q50.sql new file mode 100644 index 00000000..7a9a5faa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q51.sql new file mode 100644 index 00000000..f18e2edb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1216 and 1216+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1216 and 1216+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q52.sql new file mode 100644 index 00000000..a3c8cccf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q53.sql new file mode 100644 index 00000000..ee0ee16d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1202,1202+1,1202+2,1202+3,1202+4,1202+5,1202+6,1202+7,1202+8,1202+9,1202+10,1202+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q54.sql new file mode 100644 index 00000000..9bbb1dd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Children' + and i_class = 'newborn' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 2 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 2) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 2) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q55.sql new file mode 100644 index 00000000..81572d60 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=15 + and d_moy=11 + and d_year=2001 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q56.sql new file mode 100644 index 00000000..fffbf03a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('spring','indian','beige')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('spring','indian','beige')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('spring','indian','beige')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q57.sql new file mode 100644 index 00000000..2061b97b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q58.sql new file mode 100644 index 00000000..fe8ff6ba --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-06-07')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-06-07')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1998-06-07')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q59.sql new file mode 100644 index 00000000..41309f23 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1176 and 1176 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1176+ 12 and 1176 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q60.sql new file mode 100644 index 00000000..22b7b47b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q61.sql new file mode 100644 index 00000000..98ff8cc6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q62.sql new file mode 100644 index 00000000..56bc9c63 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1186 and 1186 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q63.sql new file mode 100644 index 00000000..2cb62e4c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1196,1196+1,1196+2,1196+3,1196+4,1196+5,1196+6,1196+7,1196+8,1196+9,1196+10,1196+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q64.sql new file mode 100644 index 00000000..1c6aa6cb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('puff','orange','hot','tomato','black','purple') and + i_current_price between 58 and 58 + 10 and + i_current_price between 58 + 1 and 58 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2001 and + cs2.syear = 2001 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q65.sql new file mode 100644 index 00000000..4c21a544 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q66.sql new file mode 100644 index 00000000..96d7ea42 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'PRIVATECARRIER' || ',' || 'FEDEX' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 52166 and 52166+28800 + and sm_carrier in ('PRIVATECARRIER','FEDEX') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'PRIVATECARRIER' || ',' || 'FEDEX' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 52166 AND 52166+28800 + and sm_carrier in ('PRIVATECARRIER','FEDEX') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q67.sql new file mode 100644 index 00000000..670ebd5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1182 and 1182+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q68.sql new file mode 100644 index 00000000..11b793b6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Beulah','Milltown') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q69.sql new file mode 100644 index 00000000..1c38988d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('TX','NC','OK') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q70.sql new file mode 100644 index 00000000..1d41a7f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1221 and 1221+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1221 and 1221+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q71.sql new file mode 100644 index 00000000..346613f7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q72.sql new file mode 100644 index 00000000..538c0f09 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 2000 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q73.sql new file mode 100644 index 00000000..c0248c63 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Sierra County','Perry County','Jackson County','Somerset County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q74.sql new file mode 100644 index 00000000..a25f3726 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,1,3 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q75.sql new file mode 100644 index 00000000..a72d7130 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Children') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2000 + AND prev_yr.d_year=2000-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q76.sql new file mode 100644 index 00000000..07575db0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_addr_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_customer_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_customer_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_hdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q77.sql new file mode 100644 index 00000000..43327644 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-22' as date) + and (cast('2001-08-22' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q78.sql new file mode 100644 index 00000000..3f578ec5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2002 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q79.sql new file mode 100644 index 00000000..a2196490 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 1 or household_demographics.hd_vehicle_count > 3) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q80.sql new file mode 100644 index 00000000..5772e54a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1999-08-17' as date) + and (cast('1999-08-17' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1999-08-17' as date) + and (cast('1999-08-17' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1999-08-17' as date) + and (cast('1999-08-17' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q81.sql new file mode 100644 index 00000000..a620e8ad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =1998 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q82.sql new file mode 100644 index 00000000..b43c31ab --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 22 and 22+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-07-19' as date) and (cast('2000-07-19' as date) + INTERVAL '60' DAY) + and i_manufact_id in (55,185,640,526) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q83.sql new file mode 100644 index 00000000..201944e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-25',DATE '1999-10-18',DATE '1999-11-22'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-25',DATE '1999-10-18',DATE '1999-11-22'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-25',DATE '1999-10-18',DATE '1999-11-22'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q84.sql new file mode 100644 index 00000000..7416a477 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Riverside' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 23450 + and ib_upper_bound <= 23450 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q85.sql new file mode 100644 index 00000000..3e4b399d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2000 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('VA', 'IL', 'ND') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('TX', 'SD', 'WA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MD', 'KS', 'NC') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q86.sql new file mode 100644 index 00000000..a8ff6287 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1183 and 1183+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q87.sql new file mode 100644 index 00000000..8f031807 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1190 and 1190+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1190 and 1190+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1190 and 1190+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q88.sql new file mode 100644 index 00000000..473122eb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q89.sql new file mode 100644 index 00000000..88893018 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1999) and + ((i_category in ('Electronics','Home','Shoes') and + i_class in ('televisions','lighting','kids') + ) + or (i_category in ('Jewelry','Sports','Books') and + i_class in ('estate','optics','business') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q90.sql new file mode 100644 index 00000000..2a4a3d7f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 0 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 15 and 15+1 + and household_demographics.hd_dep_count = 0 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q91.sql new file mode 100644 index 00000000..4dd8ca9e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2002 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like 'Unknown%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q92.sql new file mode 100644 index 00000000..d2665fa6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 107 +and i_item_sk = ws_item_sk +and d_date between DATE '2001-02-24' and + (cast('2001-02-24' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2001-02-24' and + (cast('2001-02-24' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q93.sql new file mode 100644 index 00000000..d97ab625 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'Not the product that was ordred') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q94.sql new file mode 100644 index 00000000..aa29a69f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q95.sql new file mode 100644 index 00000000..6616f686 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'NE' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q96.sql new file mode 100644 index 00000000..d23e976f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 8 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q97.sql new file mode 100644 index 00000000..7a717299 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1219 and 1219 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1219 and 1219 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q98.sql new file mode 100644 index 00000000..aa3c46ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Electronics', 'Women', 'Shoes') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2001-02-23' as date) + and (cast('2001-02-23' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s14/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s14/q99.sql new file mode 100644 index 00000000..2d5f1c65 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s14/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1198 and 1198 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q01.sql new file mode 100644 index 00000000..a9149858 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_RETURN_AMT_INC_TAX) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'SC' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q02.sql new file mode 100644 index 00000000..6b85da0a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2001) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2001+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q03.sql new file mode 100644 index 00000000..44a6ee20 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 48 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q04.sql new file mode 100644 index 00000000..68385599 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_c_firstyear.dyear = 2000 + and t_c_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q05.sql new file mode 100644 index 00000000..b5353bf9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2002-08-10' as date) + and (cast('2002-08-10' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2002-08-10' as date) + and (cast('2002-08-10' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2002-08-10' as date) + and (cast('2002-08-10' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q06.sql new file mode 100644 index 00000000..b7016e66 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 1999 + and d_moy = 1 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q07.sql new file mode 100644 index 00000000..f1ad3a7c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q08.sql new file mode 100644 index 00000000..3424a28d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '55186','79575','76420','71866','82035','31514', + '18506','96698','63680','14987','53063', + '11735','43191','30664','82413','85483', + '27312','75111','17359','98338','52775', + '74461','44106','73433','73772','10010', + '53694','48291','85836','69212','61548', + '72889','11129','95607','49999','94814', + '79421','68090','60356','95758','71926', + '11389','45198','21267','45170','22384', + '90391','71977','49720','48618','58633', + '77670','92720','81856','12819','84439', + '27657','49060','35077','55765','47156', + '91422','23877','26911','24063','45982', + '24470','43888','16912','78684','58469', + '13296','25968','66027','39478','30728', + '88389','88824','84150','91839','59039', + '34643','42437','74284','41604','71992', + '46762','23667','19459','20772','32353', + '75219','58548','54722','89523','65555', + '26513','39174','72721','11638','72213', + '27674','37690','36211','56993','29043', + '44894','47120','16238','19386','88663', + '46197','67208','90771','60618','31382', + '23197','22079','73990','65190','24179', + '16288','41090','88546','25786','18117', + '91437','38728','85775','57257','63102', + '82022','49378','54623','12973','43417', + '71382','70297','76278','90284','35531', + '13083','28120','83231','47852','23770', + '36130','39313','54256','63747','23002', + '19758','31256','66278','18404','49659', + '36805','32038','64964','80993','65884', + '72015','24107','87299','85961','60187', + '38030','24339','67233','48739','83188', + '61348','51131','42069','17885','18053', + '20927','25329','58215','54897','27574', + '56209','72218','45819','92076','66370', + '74267','27954','36316','63636','12379', + '67880','83284','17839','15872','88454', + '40361','47071','61894','74045','50251', + '88996','18315','23943','19014','54152', + '69144','94225','39315','44745','94553', + '47281','82926','91690','82011','50337', + '89094','68617','95619','99195','95198', + '63061','15144','97741','16589','37869', + '49352','32659','84695','44753','97633', + '54952','44009','81494','39740','79862', + '11718','71048','47151','81595','25955', + '25350','83027','29500','12606','49812', + '18980','51415','92785','53189','52491', + '66989','95278','12074','87146','39450', + '26498','36299','25709','60972','98763', + '69561','78064','25853','88366','57625', + '22806','35176','64346','50122','91720', + '43745','92952','27517','40238','95360', + '90581','82453','72894','83464','20288', + '26301','96495','48720','65941','19293', + '33401','54012','26581','76915','99830', + '34279','63971','44328','19874','43787', + '77549','51704','68759','92910','74104', + '19770','25288','96996','21551','45883', + '95205','59530','18107','91708','80339', + '10746','40442','59191','55301','24459', + '83456','55385','18331','10626','49254', + '87720','51125','13981','62014','93520', + '66863','12913','70380','38934','87403', + '68679','17896','84431','80379','41849', + '20604','18199','19685','86301','40718', + '70340','65138','83964','20048','63090', + '56381','10660','39038','33196','22458', + '69279','24360','18529','14721','22455', + '47823','85804','70004','22215','61890', + '51497','10377','51806','43034','27639', + '17129','40596','44028','84261','31266', + '98361','58896','44831','41035','98573', + '54789','30837','86996','38212','25756', + '39306','51085','60727','59694','29013', + '24859','83639','35649','63260','56581', + '37605','64145','78575','84645','13602', + '30560','57597','95452','35340') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2002 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q09.sql new file mode 100644 index 00000000..2ff7afd9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 279783140 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 45393553 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 346033532 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 330056271 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 372509753 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q10.sql new file mode 100644 index 00000000..0d78594c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Rockwall County','Saline County','Dewey County','Harper County','Eastland County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q11.sql new file mode 100644 index 00000000..346e967e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q12.sql new file mode 100644 index 00000000..badc6c5f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Shoes', 'Home', 'Sports') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-03-07' as date) + and (cast('1999-03-07' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q13.sql new file mode 100644 index 00000000..c29793a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'College' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('LA', 'PA', 'KS') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IN', 'TX', 'CA') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('WA', 'NC', 'MI') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q14.sql new file mode 100644 index 00000000..1f78de0f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 5) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 5) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q16.sql new file mode 100644 index 00000000..41e586aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2000-5-01' and + (cast('2000-5-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'AL' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Daviess County','Wadena County','Kittitas County','Mobile County', + 'San Miguel County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q18.sql new file mode 100644 index 00000000..977b9821 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (11,6,7,3,8,4) and + d_year = 2000 and + ca_state in ('MN','IL','SC' + ,'NY','TX','IA','KY') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q19.sql new file mode 100644 index 00000000..9dda860f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=2 + and d_moy=11 + and d_year=1998 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q20.sql new file mode 100644 index 00000000..4a6f52ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Music', 'Women', 'Children') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2001-01-29' as date) + and (cast('2001-01-29' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q21.sql new file mode 100644 index 00000000..a4f73296 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-04-02' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2002-04-02' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2002-04-02' as date) - INTERVAL '30' DAY) + and (cast ('2002-04-02' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q22.sql new file mode 100644 index 00000000..87b53157 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1189 and 1189 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q23.sql new file mode 100644 index 00000000..fb5f08c8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q24.sql new file mode 100644 index 00000000..18c43796 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'salmon' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'hot' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q25.sql new file mode 100644 index 00000000..44ed4f4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_net_profit) as store_sales_profit + ,stddev_samp(sr_net_loss) as store_returns_loss + ,stddev_samp(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1998 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q26.sql new file mode 100644 index 00000000..e32939ba --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'S' and + cd_education_status = 'Secondary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q27.sql new file mode 100644 index 00000000..68f3e35e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = 'Primary' and + d_year = 2000 and + s_state in ('OH','GA', 'OK', 'MN', 'KS', 'CO') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q28.sql new file mode 100644 index 00000000..92b7aa83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 144 and 144+10 + or ss_coupon_amt between 13839 and 13839+1000 + or ss_wholesale_cost between 63 and 63+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 106 and 106+10 + or ss_coupon_amt between 4460 and 4460+1000 + or ss_wholesale_cost between 11 and 11+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 7 and 7+10 + or ss_coupon_amt between 2965 and 2965+1000 + or ss_wholesale_cost between 35 and 35+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 114 and 114+10 + or ss_coupon_amt between 4258 and 4258+1000 + or ss_wholesale_cost between 45 and 45+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 148 and 148+10 + or ss_coupon_amt between 11867 and 11867+1000 + or ss_wholesale_cost between 19 and 19+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 41 and 41+10 + or ss_coupon_amt between 10738 and 10738+1000 + or ss_wholesale_cost between 78 and 78+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q29.sql new file mode 100644 index 00000000..d8d960ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_quantity) as store_sales_quantity + ,min(sr_return_quantity) as store_returns_quantity + ,min(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q30.sql new file mode 100644 index 00000000..eb0451a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q31.sql new file mode 100644 index 00000000..a3b7aac5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2000 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2000 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2000 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2000 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2000 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2000 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q32.sql new file mode 100644 index 00000000..b2f561df --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 860 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-02-25' and + (cast('2002-02-25' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-02-25' and + (cast('2002-02-25' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q33.sql new file mode 100644 index 00000000..bc1e05e0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q34.sql new file mode 100644 index 00000000..57f2c2ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Walker County','San Miguel County','Red River Parish','Barrow County', + 'Contra Costa County','Pulaski County','Hubbard County','Mobile County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q35.sql new file mode 100644 index 00000000..ef01f704 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + stddev_samp(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + stddev_samp(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + stddev_samp(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q36.sql new file mode 100644 index 00000000..a4111964 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('LA','WV','IN','VT', + 'MI','AL','MO','PA') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q37.sql new file mode 100644 index 00000000..16da9090 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 65 and 65 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-04-09' as date) and (cast('1999-04-09' as date) + INTERVAL '60' DAY) + and i_manufact_id in (898,668,952,841) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q38.sql new file mode 100644 index 00000000..c4585aa0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q39.sql new file mode 100644 index 00000000..41924652 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q40.sql new file mode 100644 index 00000000..5848babe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-05-23' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2002-05-23' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2002-05-23' as date) - INTERVAL '30' DAY) + and (cast ('2002-05-23' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q41.sql new file mode 100644 index 00000000..a4ec77b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 704 and 704+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'powder' or i_color = 'lavender') and + (i_units = 'Unknown' or i_units = 'Bundle') and + (i_size = 'N/A' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'lime' or i_color = 'beige') and + (i_units = 'Tbl' or i_units = 'Bunch') and + (i_size = 'medium' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'midnight' or i_color = 'green') and + (i_units = 'Lb' or i_units = 'Tsp') and + (i_size = 'petite' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'mint' or i_color = 'snow') and + (i_units = 'Pallet' or i_units = 'Dram') and + (i_size = 'N/A' or i_size = 'economy') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'papaya' or i_color = 'slate') and + (i_units = 'Ounce' or i_units = 'Oz') and + (i_size = 'N/A' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'steel' or i_color = 'black') and + (i_units = 'Case' or i_units = 'Each') and + (i_size = 'medium' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'yellow' or i_color = 'ghost') and + (i_units = 'N/A' or i_units = 'Ton') and + (i_size = 'petite' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'peru' or i_color = 'frosted') and + (i_units = 'Dozen' or i_units = 'Pound') and + (i_size = 'N/A' or i_size = 'economy') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q42.sql new file mode 100644 index 00000000..2aa89f83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q43.sql new file mode 100644 index 00000000..68b895bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 1999 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q44.sql new file mode 100644 index 00000000..0d95a6bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 683 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 683 + and ss_hdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 683 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 683 + and ss_hdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q45.sql new file mode 100644 index 00000000..0c3427f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q46.sql new file mode 100644 index 00000000..ea0e8ac1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 7 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Avondale','Anderson','Woodland','Liberty','Mount Vernon') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q47.sql new file mode 100644 index 00000000..f901f23c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q48.sql new file mode 100644 index 00000000..a8ad3348 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'College' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IL', 'SC', 'TX') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MS', 'IA', 'NE') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TN', 'NY', 'MT') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q49.sql new file mode 100644 index 00000000..18d66524 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q50.sql new file mode 100644 index 00000000..71fedc7d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q51.sql new file mode 100644 index 00000000..fbf73af4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1186 and 1186+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1186 and 1186+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q52.sql new file mode 100644 index 00000000..dd28b998 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q53.sql new file mode 100644 index 00000000..664787e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1218,1218+1,1218+2,1218+3,1218+4,1218+5,1218+6,1218+7,1218+8,1218+9,1218+10,1218+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q54.sql new file mode 100644 index 00000000..ac19bca8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Books' + and i_class = 'entertainments' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 5 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 5) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 5) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q55.sql new file mode 100644 index 00000000..f5bdfbb4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=47 + and d_moy=11 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q56.sql new file mode 100644 index 00000000..bb1098bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('rosy','metallic','dim')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('rosy','metallic','dim')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('rosy','metallic','dim')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q57.sql new file mode 100644 index 00000000..80897455 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q58.sql new file mode 100644 index 00000000..4609da8a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-03-15')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-03-15')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2001-03-15')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q59.sql new file mode 100644 index 00000000..fbe0e6d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1182 and 1182 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1182+ 12 and 1182 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q60.sql new file mode 100644 index 00000000..b2398a79 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q61.sql new file mode 100644 index 00000000..47834c13 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q62.sql new file mode 100644 index 00000000..558fe2bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1191 and 1191 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q63.sql new file mode 100644 index 00000000..619fce45 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1199,1199+1,1199+2,1199+3,1199+4,1199+5,1199+6,1199+7,1199+8,1199+9,1199+10,1199+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q64.sql new file mode 100644 index 00000000..2b5ee748 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('dim','blanched','orange','seashell','khaki','turquoise') and + i_current_price between 22 and 22 + 10 and + i_current_price between 22 + 1 and 22 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q65.sql new file mode 100644 index 00000000..34a076b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q66.sql new file mode 100644 index 00000000..9256bb71 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'RUPEKSA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 22503 and 22503+28800 + and sm_carrier in ('ZOUROS','RUPEKSA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'RUPEKSA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 22503 AND 22503+28800 + and sm_carrier in ('ZOUROS','RUPEKSA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q67.sql new file mode 100644 index 00000000..f62303bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1220 and 1220+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q68.sql new file mode 100644 index 00000000..ac31c91c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= -1) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Rosedale','Washington') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q69.sql new file mode 100644 index 00000000..65ee8acf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('OK','IA','IN') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q70.sql new file mode 100644 index 00000000..caf88961 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1218 and 1218+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1218 and 1218+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q71.sql new file mode 100644 index 00000000..6b55f6b6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2000 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2000 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2000 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q72.sql new file mode 100644 index 00000000..cdf2a28c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 1998 + and cd_marital_status = 'W' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q73.sql new file mode 100644 index 00000000..0915b3fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Quay County','Tehama County','Miller County','Marshall County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q74.sql new file mode 100644 index 00000000..88ab16b6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,1,2 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q75.sql new file mode 100644 index 00000000..2a0e5d06 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Women' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Women' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Women') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q76.sql new file mode 100644 index 00000000..3fe08f5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_cdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_cdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_addr_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_addr_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_mode_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_mode_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q77.sql new file mode 100644 index 00000000..bb42a501 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-09' as date) + and (cast('2002-08-09' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q78.sql new file mode 100644 index 00000000..fd1b18e9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2000 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q79.sql new file mode 100644 index 00000000..c58f4a50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > 0) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q80.sql new file mode 100644 index 00000000..8e1fcd64 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q81.sql new file mode 100644 index 00000000..f873051b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'OK' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q82.sql new file mode 100644 index 00000000..7265d31e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 33 and 33+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-06-01' as date) and (cast('1998-06-01' as date) + INTERVAL '60' DAY) + and i_manufact_id in (298,192,405,419) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q83.sql new file mode 100644 index 00000000..cd40ce3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-19',DATE '2002-09-10',DATE '2002-11-17'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-19',DATE '2002-09-10',DATE '2002-11-17'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-19',DATE '2002-09-10',DATE '2002-11-17'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q84.sql new file mode 100644 index 00000000..2e4a433a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Centerville' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 36960 + and ib_upper_bound <= 36960 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q85.sql new file mode 100644 index 00000000..343961ec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2000 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('KY', 'IL', 'WA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('GA', 'MI', 'TN') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('SD', 'AR', 'SC') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q86.sql new file mode 100644 index 00000000..65612ec0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1204 and 1204+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q87.sql new file mode 100644 index 00000000..5f4ba3c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1224 and 1224+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1224 and 1224+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1224 and 1224+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q88.sql new file mode 100644 index 00000000..22bf1a91 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q89.sql new file mode 100644 index 00000000..58cea8a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Men','Women','Home') and + i_class in ('sports-apparel','swimwear','rugs') + ) + or (i_category in ('Electronics','Children','Sports') and + i_class in ('audio','toddlers','fitness') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q90.sql new file mode 100644 index 00000000..7b9d2241 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 10 and 10+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 21 and 21+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q91.sql new file mode 100644 index 00000000..29a0afe8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '>10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q92.sql new file mode 100644 index 00000000..e0113275 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 922 +and i_item_sk = ws_item_sk +and d_date between DATE '2001-03-06' and + (cast('2001-03-06' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2001-03-06' and + (cast('2001-03-06' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q93.sql new file mode 100644 index 00000000..8818e36d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 43') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q94.sql new file mode 100644 index 00000000..cc65896d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-5-01' and + (cast('2001-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'GA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q95.sql new file mode 100644 index 00000000..81ed3648 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'GA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q96.sql new file mode 100644 index 00000000..9db03bd5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 20 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 6 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q97.sql new file mode 100644 index 00000000..b95738b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1193 and 1193 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1193 and 1193 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q98.sql new file mode 100644 index 00000000..59ae94f1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Jewelry', 'Electronics', 'Children') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2002-06-02' as date) + and (cast('2002-06-02' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s15/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s15/q99.sql new file mode 100644 index 00000000..49f3bf0b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s15/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1200 and 1200 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q01.sql new file mode 100644 index 00000000..f399a058 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_STORE_CREDIT) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'GA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q03.sql new file mode 100644 index 00000000..ac9cadd2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 609 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q04.sql new file mode 100644 index 00000000..8d0a204d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q05.sql new file mode 100644 index 00000000..39f92b31 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q06.sql new file mode 100644 index 00000000..06103a6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 1998 + and d_moy = 4 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q07.sql new file mode 100644 index 00000000..ea903b21 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q08.sql new file mode 100644 index 00000000..bf253a2f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '89902','68943','25896','17295','85321','87038', + '26813','20071','80297','92311','54569', + '96941','37835','83052','26089','28402', + '71690','76722','34289','89465','87775', + '93833','28643','88424','42641','11906', + '18453','67149','79266','25646','67434', + '79762','16035','19676','28828','31457', + '65637','59739','56211','24262','58131', + '56344','61108','99733','66375','74990', + '65676','19129','56422','46008','83895', + '87774','35760','45449','26633','71841', + '70893','20612','83266','90182','98179', + '70045','32963','99876','64941','91376', + '26573','37749','64566','50094','33673', + '76414','80864','12305','38682','27981', + '42747','25705','56232','16037','17031', + '91056','79446','36780','47317','90529', + '79652','35192','76093','17039','63240', + '14207','35867','87143','47029','58170', + '77100','96836','40362','63131','59301', + '31275','34492','88036','67631','82121', + '50210','20431','90229','92522','13356', + '15224','54113','91217','76219','39322', + '27702','45793','46318','95559','71354', + '11493','36153','68999','20031','20060', + '89043','58080','71880','56159','47387', + '51038','82363','70176','97698','96335', + '67463','73747','21554','32272','17712', + '39129','65356','43743','42264','39377', + '81812','87758','79681','31200','86179', + '68829','72106','76170','27068','77404', + '11031','42254','72121','43620','17997', + '22443','41758','91260','47297','21099', + '87383','57461','30983','62582','61150', + '10946','44065','31773','91792','61014', + '22402','63777','24920','57829','54827', + '82399','30276','17083','55496','80674', + '59586','47567','32157','59921','19641', + '54040','98989','56965','69145','88383', + '56709','60653','92912','51318','58900', + '44812','94666','27854','39906','74658', + '32340','92565','41555','76566','47619', + '73589','34655','26047','80161','64803', + '90311','86546','69940','53627','75682', + '44131','52192','94311','44973','46098', + '15297','29409','85180','80060','13508', + '46411','51323','53448','64679','84020', + '58005','53476','51381','66568','31179', + '19608','32579','46474','46052','36501', + '56690','39578','35901','84250','55706', + '50043','23329','71628','77892','97383', + '30294','30405','11358','42103','96510', + '77411','60619','26579','68795','85032', + '64338','40280','20879','84023','86260', + '48195','22514','75197','28694','29543', + '26167','15149','32210','50647','16231', + '17543','69120','23587','76637','69436', + '49396','41991','28558','32958','29911', + '24162','89923','33528','81615','25875', + '26678','21567','49806','12850','46435', + '48440','88151','24466','89204','81265', + '50820','97114','69031','56052','48338', + '11635','11352','61855','48261','52170', + '21384','99832','93588','68363','42491', + '67402','29791','20639','38072','44171', + '80097','37166','36726','90304','61352', + '48674','15013','58813','93779','82246', + '52084','27074','43480','28188','52438', + '47493','95930','83217','14003','92336', + '25138','12973','22646','75894','72194', + '52657','48234','44394','89695','15919', + '10854','63001','11175','73108','37044', + '91218','28829','69406','27385','21393', + '53121','36791','45105','93273','76956', + '84286','66154','28537','47163','91140', + '89432','66208','55838','25612','56327', + '42150','38452','82449','88494','77292', + '23229','88235','12820','83025','92686', + '35422','69919','15794','46155','24301', + '16543','58164','45460','49408') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q09.sql new file mode 100644 index 00000000..65679231 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 61874040 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 279787310 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 344231498 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 466125995 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 373821331 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q10.sql new file mode 100644 index 00000000..a9dce597 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Manistee County','Crook County','Leslie County','Beltrami County','Winkler County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q11.sql new file mode 100644 index 00000000..9ac1286e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q12.sql new file mode 100644 index 00000000..2cdc0441 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Children', 'Women', 'Men') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-02-17' as date) + and (cast('2000-02-17' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q13.sql new file mode 100644 index 00000000..f24aa1ad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = 'Primary' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('LA', 'NY', 'GA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('SD', 'MS', 'AK') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'TN', 'PA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q14.sql new file mode 100644 index 00000000..23f1f32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 4) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 4) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q15.sql new file mode 100644 index 00000000..bfc02dbd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q16.sql new file mode 100644 index 00000000..b777e3e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'IA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Franklin Parish','Raleigh County','Gage County','Jefferson Davis Parish', + 'Huron County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q17.sql new file mode 100644 index 00000000..4f3e0465 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q18.sql new file mode 100644 index 00000000..8862eec6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Secondary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (2,10,11,5,8,9) and + d_year = 1999 and + ca_state in ('CA','IL','MI' + ,'NC','TX','IN','OK') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q19.sql new file mode 100644 index 00000000..17571cb4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=95 + and d_moy=12 + and d_year=2001 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q20.sql new file mode 100644 index 00000000..028fc988 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Sports', 'Electronics') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-06-04' as date) + and (cast('2000-06-04' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q21.sql new file mode 100644 index 00000000..4013c5f7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-05-19' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2001-05-19' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2001-05-19' as date) - INTERVAL '30' DAY) + and (cast ('2001-05-19' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q22.sql new file mode 100644 index 00000000..8ca8791e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1210 and 1210 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q23.sql new file mode 100644 index 00000000..3973411f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q24.sql new file mode 100644 index 00000000..4fb5539b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'lavender' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'violet' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q25.sql new file mode 100644 index 00000000..bb04db9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_net_profit) as store_sales_profit + ,min(sr_net_loss) as store_returns_loss + ,min(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q26.sql new file mode 100644 index 00000000..770325f2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q27.sql new file mode 100644 index 00000000..1e13f573 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '4 yr Degree' and + d_year = 2002 and + s_state in ('IN','PA', 'AL', 'TN', 'CO', 'SD') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q28.sql new file mode 100644 index 00000000..b278bef2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 107 and 107+10 + or ss_coupon_amt between 5921 and 5921+1000 + or ss_wholesale_cost between 12 and 12+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 83 and 83+10 + or ss_coupon_amt between 1292 and 1292+1000 + or ss_wholesale_cost between 59 and 59+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 10 and 10+10 + or ss_coupon_amt between 8086 and 8086+1000 + or ss_wholesale_cost between 80 and 80+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 39 and 39+10 + or ss_coupon_amt between 14070 and 14070+1000 + or ss_wholesale_cost between 19 and 19+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 157 and 157+10 + or ss_coupon_amt between 12938 and 12938+1000 + or ss_wholesale_cost between 21 and 21+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 82 and 82+10 + or ss_coupon_amt between 14668 and 14668+1000 + or ss_wholesale_cost between 38 and 38+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q29.sql new file mode 100644 index 00000000..daf166f2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_quantity) as store_sales_quantity + ,max(sr_return_quantity) as store_returns_quantity + ,max(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q30.sql new file mode 100644 index 00000000..738d3653 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'CA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q31.sql new file mode 100644 index 00000000..15af75d4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by web_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q32.sql new file mode 100644 index 00000000..afbe1286 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 898 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-01-22' and + (cast('2002-01-22' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-01-22' and + (cast('2002-01-22' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q33.sql new file mode 100644 index 00000000..8eba0013 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q34.sql new file mode 100644 index 00000000..45cc774a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Perry County','Henry County','Hubbard County','Furnas County', + 'Harper County','Terrell County','Oglethorpe County','Bronx County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q35.sql new file mode 100644 index 00000000..18708517 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + stddev_samp(cd_dep_count) aggone1, + avg(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + stddev_samp(cd_dep_employed_count) aggone2, + avg(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + stddev_samp(cd_dep_college_count) aggone3, + avg(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q36.sql new file mode 100644 index 00000000..3ba2841d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('NY','GA','TN','NC', + 'MI','AL','OH','AL') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q37.sql new file mode 100644 index 00000000..81cff607 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 51 and 51 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-03-16' as date) and (cast('2000-03-16' as date) + INTERVAL '60' DAY) + and i_manufact_id in (963,677,998,992) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q38.sql new file mode 100644 index 00000000..c4077229 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1215 and 1215 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1215 and 1215 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1215 and 1215 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q39.sql new file mode 100644 index 00000000..f8f8c13f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q40.sql new file mode 100644 index 00000000..2eecdf16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-06-13' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-06-13' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-06-13' as date) - INTERVAL '30' DAY) + and (cast ('1998-06-13' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q41.sql new file mode 100644 index 00000000..06c01988 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 898 and 898+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'sky' or i_color = 'blush') and + (i_units = 'Dozen' or i_units = 'Pallet') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'salmon' or i_color = 'grey') and + (i_units = 'Each' or i_units = 'Dram') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'medium' or i_color = 'floral') and + (i_units = 'Oz' or i_units = 'Ton') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'red' or i_color = 'maroon') and + (i_units = 'Carton' or i_units = 'Gram') and + (i_size = 'petite' or i_size = 'small') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'bisque' or i_color = 'steel') and + (i_units = 'Case' or i_units = 'Bundle') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'dark' or i_color = 'cornsilk') and + (i_units = 'N/A' or i_units = 'Box') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'brown' or i_color = 'slate') and + (i_units = 'Unknown' or i_units = 'Gross') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'almond' or i_color = 'hot') and + (i_units = 'Bunch' or i_units = 'Pound') and + (i_size = 'petite' or i_size = 'small') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q42.sql new file mode 100644 index 00000000..ba1dd9be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=1998 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q43.sql new file mode 100644 index 00000000..b0986c06 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 1998 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q44.sql new file mode 100644 index 00000000..d7edbcea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 719 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 719 + and ss_addr_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 719 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 719 + and ss_addr_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q45.sql new file mode 100644 index 00000000..e1d2da0f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q46.sql new file mode 100644 index 00000000..4025a230 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Farmington','Union Hill','Milltown','Smyrna','Rosedale') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q47.sql new file mode 100644 index 00000000..c411dca8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q48.sql new file mode 100644 index 00000000..2754bd49 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2002 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('VA', 'IN', 'AL') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'IL', 'OR') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('PA', 'MN', 'AR') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q49.sql new file mode 100644 index 00000000..41429035 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q50.sql new file mode 100644 index 00000000..696f710a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2001 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q51.sql new file mode 100644 index 00000000..90bb1a9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1177 and 1177+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1177 and 1177+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q52.sql new file mode 100644 index 00000000..7d81431b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q53.sql new file mode 100644 index 00000000..ee0ee16d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1202,1202+1,1202+2,1202+3,1202+4,1202+5,1202+6,1202+7,1202+8,1202+9,1202+10,1202+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q54.sql new file mode 100644 index 00000000..cfaa2144 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Books' + and i_class = 'science' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q55.sql new file mode 100644 index 00000000..42184e4d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=90 + and d_moy=11 + and d_year=2002 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q56.sql new file mode 100644 index 00000000..0192c386 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('blush','navajo','cornflower')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('blush','navajo','cornflower')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('blush','navajo','cornflower')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q57.sql new file mode 100644 index 00000000..72caa5ad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q58.sql new file mode 100644 index 00000000..45612115 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-06-23')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-06-23')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2000-06-23')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q59.sql new file mode 100644 index 00000000..295bb6a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1178 and 1178 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1178+ 12 and 1178 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q60.sql new file mode 100644 index 00000000..2da63092 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q61.sql new file mode 100644 index 00000000..e8bdc989 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 2000 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and s_gmt_offset = -6 + and d_year = 2000 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q62.sql new file mode 100644 index 00000000..36648f13 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1213 and 1213 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q63.sql new file mode 100644 index 00000000..2cb62e4c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1196,1196+1,1196+2,1196+3,1196+4,1196+5,1196+6,1196+7,1196+8,1196+9,1196+10,1196+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q64.sql new file mode 100644 index 00000000..ca713502 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('ghost','purple','thistle','peach','light','orchid') and + i_current_price between 22 and 22 + 10 and + i_current_price between 22 + 1 and 22 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q65.sql new file mode 100644 index 00000000..0b5ba714 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1197 and 1197+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1197 and 1197+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q66.sql new file mode 100644 index 00000000..6143937b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'TBS' || ',' || 'GREAT EASTERN' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_profit * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_profit * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_profit * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_profit * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_profit * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_profit * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_profit * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_profit * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_profit * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_profit * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_profit * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_profit * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 17311 and 17311+28800 + and sm_carrier in ('TBS','GREAT EASTERN') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'TBS' || ',' || 'GREAT EASTERN' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 17311 AND 17311+28800 + and sm_carrier in ('TBS','GREAT EASTERN') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q67.sql new file mode 100644 index 00000000..4118a42f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1179 and 1179+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q68.sql new file mode 100644 index 00000000..4cfff27f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 0 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('New Hope','Springfield') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q69.sql new file mode 100644 index 00000000..16ec4323 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('SD','MS','PA') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 4 and 4+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q70.sql new file mode 100644 index 00000000..e2b5bc00 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1180 and 1180+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1180 and 1180+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q71.sql new file mode 100644 index 00000000..5afa8d2b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q72.sql new file mode 100644 index 00000000..dccc9c2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 2001 + and cd_marital_status = 'W' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q73.sql new file mode 100644 index 00000000..bb63db7c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Raleigh County','Surry County','Gogebic County','Tehama County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q74.sql new file mode 100644 index 00000000..d2a29675 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q75.sql new file mode 100644 index 00000000..2a0e5d06 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Women' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Women' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Women') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q76.sql new file mode 100644 index 00000000..584ed9d5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_cdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_cdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_web_page_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_warehouse_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q77.sql new file mode 100644 index 00000000..7ae7a5e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q78.sql new file mode 100644 index 00000000..24ecf4fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q79.sql new file mode 100644 index 00000000..9214d20c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 6 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q80.sql new file mode 100644 index 00000000..4a5a1e84 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-11' as date) + and (cast('2002-08-11' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-11' as date) + and (cast('2002-08-11' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-11' as date) + and (cast('2002-08-11' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q81.sql new file mode 100644 index 00000000..98d669e0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2000 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q82.sql new file mode 100644 index 00000000..b7af5303 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 14 and 14+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-01-17' as date) and (cast('2000-01-17' as date) + INTERVAL '60' DAY) + and i_manufact_id in (461,374,21,483) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q83.sql new file mode 100644 index 00000000..70d69da5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-21',DATE '1998-08-15',DATE '1998-11-04'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-21',DATE '1998-08-15',DATE '1998-11-04'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-21',DATE '1998-08-15',DATE '1998-11-04'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q84.sql new file mode 100644 index 00000000..7b79b03b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Bethel' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 46192 + and ib_upper_bound <= 46192 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q85.sql new file mode 100644 index 00000000..ebe2cba4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('IA', 'CA', 'CO') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('AR', 'MS', 'AK') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MO', 'ID', 'TX') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q86.sql new file mode 100644 index 00000000..c0cfcc7a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1205 and 1205+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q87.sql new file mode 100644 index 00000000..cb0e5202 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1182 and 1182+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1182 and 1182+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1182 and 1182+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q88.sql new file mode 100644 index 00000000..1894b068 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q89.sql new file mode 100644 index 00000000..f301d630 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1998) and + ((i_category in ('Sports','Electronics','Children') and + i_class in ('camping','stereo','school-uniforms') + ) + or (i_category in ('Shoes','Jewelry','Home') and + i_class in ('kids','estate','tables') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q90.sql new file mode 100644 index 00000000..53de68c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 11 and 11+1 + and household_demographics.hd_dep_count = 4 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 15 and 15+1 + and household_demographics.hd_dep_count = 4 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q91.sql new file mode 100644 index 00000000..7f1a5826 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1998 +and d_moy = 11 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '501-1000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q92.sql new file mode 100644 index 00000000..cda48cbd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 191 +and i_item_sk = ws_item_sk +and d_date between DATE '2000-03-09' and + (cast('2000-03-09' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2000-03-09' and + (cast('2000-03-09' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q93.sql new file mode 100644 index 00000000..75bb2b60 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'No service location in my area') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q94.sql new file mode 100644 index 00000000..72a566f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KS' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q95.sql new file mode 100644 index 00000000..e02f1722 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KY' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q96.sql new file mode 100644 index 00000000..d19dfe77 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 5 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q97.sql new file mode 100644 index 00000000..c7fefa50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1183 and 1183 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q98.sql new file mode 100644 index 00000000..30a28b69 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Home', 'Men', 'Electronics') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2000-06-05' as date) + and (cast('2000-06-05' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s16/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s16/q99.sql new file mode 100644 index 00000000..66d0d68a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s16/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1210 and 1210 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q01.sql new file mode 100644 index 00000000..b2c050b7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REFUNDED_CASH) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'TN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q03.sql new file mode 100644 index 00000000..c92a423f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 560 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q04.sql new file mode 100644 index 00000000..4632dc72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_c_firstyear.dyear = 2001 + and t_c_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q05.sql new file mode 100644 index 00000000..64a89b53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-08' as date) + and (cast('2001-08-08' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-08' as date) + and (cast('2001-08-08' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-08' as date) + and (cast('2001-08-08' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q06.sql new file mode 100644 index 00000000..f97cf738 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 7 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q07.sql new file mode 100644 index 00000000..70eed271 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = 'Secondary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q08.sql new file mode 100644 index 00000000..71b14c58 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '39985','74378','26364','80296','99182','55923', + '44525','48568','56711','51417','90978', + '20937','10765','22754','72291','18935', + '73640','95676','32728','95420','19981', + '56561','10691','14944','51555','72318', + '50447','10629','39950','59222','58072', + '32621','45258','85445','77434','92065', + '32676','29622','71038','89441','32677', + '65383','47994','98846','17852','39118', + '50988','48037','67240','76106','37764', + '79546','92893','96815','64142','21502', + '99501','42462','87990','17478','44720', + '93280','48923','23233','99242','10529', + '10173','63520','51217','53873','57048', + '86451','49716','49672','37412','84885', + '47391','16887','27674','11637','37213', + '71494','68714','56122','25681','25977', + '74722','11685','64832','57559','79414', + '17454','72054','79722','89409','11303', + '59415','59708','31419','48936','14150', + '53084','92502','18798','91518','19375', + '40074','78181','22561','74901','75617', + '10201','63867','44894','36086','86937', + '47164','15744','63866','78993','20273', + '44499','74900','71096','32362','83061', + '98642','85238','70641','55712','75039', + '26914','44706','27752','46701','63612', + '32443','76556','52980','53723','93212', + '71732','76228','16747','77822','96692', + '38322','88243','73415','53333','87549', + '69255','88732','55903','77021','59083', + '27745','88315','24871','39287','12043', + '77490','59250','12418','97700','53200', + '58613','51622','56051','22370','29362', + '35128','31236','14663','35328','51536', + '52175','30636','31043','31970','10080', + '33715','77749','86543','19920','47491', + '65571','89317','89484','67979','55130', + '24318','95220','39149','37352','51449', + '37256','86376','50479','43400','11473', + '74631','61859','87421','25129','43636', + '40673','76219','32164','38337','14748', + '98583','75644','51509','94985','49763', + '33631','26248','53387','14261','44579', + '29775','73109','81523','36711','87433', + '83926','26024','75523','88370','70814', + '28173','75689','38403','46318','94532', + '77408','59522','41954','44014','94036', + '28818','46191','26302','97568','44608', + '52461','30111','98788','30274','50895', + '48486','64395','15352','74820','10670', + '38571','77603','43199','31833','34612', + '36088','22752','28834','48171','25250', + '41959','36505','64058','45291','29903', + '79949','75643','20659','22395','78833', + '34094','77936','59420','53212','99310', + '41921','49587','10555','42365','13428', + '68419','25647','94482','55384','63227', + '63043','60670','10851','40865','30396', + '61855','80900','75454','69615','16832', + '12520','69846','27342','89298','47988', + '20906','74739','46808','21748','26749', + '95996','45646','74216','90799','28247', + '36756','46848','88655','45548','79479', + '43890','36610','29340','33764','72305', + '78752','69390','78504','39607','30352', + '29463','84822','26075','64389','46777', + '87719','43408','49192','99600','24866', + '86015','49175','72605','42930','13055', + '20971','11728','20042','10130','20878', + '27603','19043','85779','37398','42856', + '34147','80260','92993','78747','92268', + '12383','70938','30539','44213','92587', + '42623','99818','13758','40402','47657', + '65915','94393','44236','90495','91452', + '25789','86363','64575','98378','16059', + '54612','53058','95848','51252','93654', + '14227','67780','86635','72810','87220', + '70921','61720','42701','17931','58732', + '69192','91908','15974','19096') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q09.sql new file mode 100644 index 00000000..404357a0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 392681099 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 80727968 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 381803211 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 267462724 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 158634855 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q10.sql new file mode 100644 index 00000000..1608f9c9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Wyoming County','Elk County','Atlantic County','Chisago County','Caldwell County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q11.sql new file mode 100644 index 00000000..ee1529df --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q12.sql new file mode 100644 index 00000000..68b06e70 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Women', 'Jewelry', 'Men') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-06-03' as date) + and (cast('2000-06-03' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q13.sql new file mode 100644 index 00000000..08b78411 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NH', 'NY', 'MO') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'CO', 'OK') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MI', 'CA', 'MT') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q14.sql new file mode 100644 index 00000000..4f2f3c6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q15.sql new file mode 100644 index 00000000..46e9f91b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q16.sql new file mode 100644 index 00000000..06d85c72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-5-01' and + (cast('2001-5-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Maverick County','Pennington County','Fairfield County','Walker County', + 'Marshall County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q18.sql new file mode 100644 index 00000000..5393751d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Unknown' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (6,7,10,9,8,1) and + d_year = 1999 and + ca_state in ('MS','FL','TN' + ,'KY','ID','VA','TX') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q19.sql new file mode 100644 index 00000000..77f31b4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=29 + and d_moy=12 + and d_year=1999 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q20.sql new file mode 100644 index 00000000..978a1f0e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Electronics', 'Home') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-02-07' as date) + and (cast('2002-02-07' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q21.sql new file mode 100644 index 00000000..6deb18e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-06-04' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2000-06-04' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2000-06-04' as date) - INTERVAL '30' DAY) + and (cast ('2000-06-04' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q22.sql new file mode 100644 index 00000000..fa4a7052 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1208 and 1208 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q23.sql new file mode 100644 index 00000000..c47481b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q24.sql new file mode 100644 index 00000000..220cdef0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'tomato' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'lime' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q25.sql new file mode 100644 index 00000000..bdd0ee82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q26.sql new file mode 100644 index 00000000..a145ceae --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'D' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q27.sql new file mode 100644 index 00000000..6261baa7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = 'College' and + d_year = 2001 and + s_state in ('TX','SD', 'LA', 'FL', 'MI', 'LA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q28.sql new file mode 100644 index 00000000..5325476e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 153 and 153+10 + or ss_coupon_amt between 14743 and 14743+1000 + or ss_wholesale_cost between 53 and 53+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 174 and 174+10 + or ss_coupon_amt between 13623 and 13623+1000 + or ss_wholesale_cost between 39 and 39+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 175 and 175+10 + or ss_coupon_amt between 3305 and 3305+1000 + or ss_wholesale_cost between 42 and 42+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 43 and 43+10 + or ss_coupon_amt between 14561 and 14561+1000 + or ss_wholesale_cost between 61 and 61+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 42 and 42+10 + or ss_coupon_amt between 4727 and 4727+1000 + or ss_wholesale_cost between 65 and 65+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 49 and 49+10 + or ss_coupon_amt between 12287 and 12287+1000 + or ss_wholesale_cost between 19 and 19+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q29.sql new file mode 100644 index 00000000..519254bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_quantity) as store_sales_quantity + ,max(sr_return_quantity) as store_returns_quantity + ,max(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q30.sql new file mode 100644 index 00000000..4730917f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'OK' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q31.sql new file mode 100644 index 00000000..227fdc1f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2000 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2000 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2000 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2000 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2000 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2000 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.ca_county; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q32.sql new file mode 100644 index 00000000..870f9e24 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 711 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-03-28' and + (cast('1998-03-28' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-03-28' and + (cast('1998-03-28' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q33.sql new file mode 100644 index 00000000..40015b0c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q34.sql new file mode 100644 index 00000000..c768de13 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Jackson County','Chambers County','Karnes County','Lea County', + 'Harding County','Daviess County','Sierra County','Sumner County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q35.sql new file mode 100644 index 00000000..ee1072b9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + stddev_samp(cd_dep_count) aggtwo1, + max(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + stddev_samp(cd_dep_employed_count) aggtwo2, + max(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + stddev_samp(cd_dep_college_count) aggtwo3, + max(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q36.sql new file mode 100644 index 00000000..68fc60da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('NM','LA','NY','VT', + 'MI','MI','FL','MI') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q37.sql new file mode 100644 index 00000000..1fd4ba7f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 70 and 70 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-06-23' as date) and (cast('2002-06-23' as date) + INTERVAL '60' DAY) + and i_manufact_id in (764,885,745,835) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q38.sql new file mode 100644 index 00000000..47b5dd72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1200 and 1200 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1200 and 1200 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1200 and 1200 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q39.sql new file mode 100644 index 00000000..3669aa43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q40.sql new file mode 100644 index 00000000..57960c64 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-04-12' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2000-04-12' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2000-04-12' as date) - INTERVAL '30' DAY) + and (cast ('2000-04-12' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q41.sql new file mode 100644 index 00000000..d7820a1e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 684 and 684+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'ghost' or i_color = 'navajo') and + (i_units = 'Ton' or i_units = 'Carton') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'dark' or i_color = 'antique') and + (i_units = 'Lb' or i_units = 'Pound') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'ivory' or i_color = 'orchid') and + (i_units = 'Unknown' or i_units = 'Gross') and + (i_size = 'small' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'lace' or i_color = 'cream') and + (i_units = 'Gram' or i_units = 'Bundle') and + (i_size = 'economy' or i_size = 'extra large') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'orange' or i_color = 'rosy') and + (i_units = 'N/A' or i_units = 'Bunch') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'aquamarine' or i_color = 'goldenrod') and + (i_units = 'Pallet' or i_units = 'Tsp') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'rose' or i_color = 'black') and + (i_units = 'Box' or i_units = 'Oz') and + (i_size = 'small' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'violet' or i_color = 'plum') and + (i_units = 'Dozen' or i_units = 'Each') and + (i_size = 'economy' or i_size = 'extra large') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q42.sql new file mode 100644 index 00000000..13d30602 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q43.sql new file mode 100644 index 00000000..ccfb4cd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q44.sql new file mode 100644 index 00000000..da3868b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 52 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 52 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 52 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 52 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q45.sql new file mode 100644 index 00000000..79297689 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q46.sql new file mode 100644 index 00000000..87b3816b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Harrisburg','Providence','Walnut Grove','Avondale','Unionville') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q47.sql new file mode 100644 index 00000000..da576f25 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name, v1.s_company_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q48.sql new file mode 100644 index 00000000..484a12d3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IL', 'FL', 'GA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('KS', 'OK', 'ME') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'CA', 'IN') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q49.sql new file mode 100644 index 00000000..baab828a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q50.sql new file mode 100644 index 00000000..a77af95c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1999 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q51.sql new file mode 100644 index 00000000..0ab3fee9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1220 and 1220+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1220 and 1220+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q52.sql new file mode 100644 index 00000000..7d81431b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q53.sql new file mode 100644 index 00000000..caa3572e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1186,1186+1,1186+2,1186+3,1186+4,1186+5,1186+6,1186+7,1186+8,1186+9,1186+10,1186+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q54.sql new file mode 100644 index 00000000..4a28483c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Shoes' + and i_class = 'kids' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q55.sql new file mode 100644 index 00000000..a7863df3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=3 + and d_moy=12 + and d_year=1998 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q56.sql new file mode 100644 index 00000000..d70b346b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('burnished','powder','metallic')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('burnished','powder','metallic')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('burnished','powder','metallic')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q57.sql new file mode 100644 index 00000000..2af136cb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q58.sql new file mode 100644 index 00000000..f81e3d4c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-07-05')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-07-05')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-07-05')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q59.sql new file mode 100644 index 00000000..02dbc5b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1193 and 1193 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1193+ 12 and 1193 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q60.sql new file mode 100644 index 00000000..2aad93c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 8 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 8 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 8 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q61.sql new file mode 100644 index 00000000..352fe8bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q62.sql new file mode 100644 index 00000000..1d68b620 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1220 and 1220 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q63.sql new file mode 100644 index 00000000..239494ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1209,1209+1,1209+2,1209+3,1209+4,1209+5,1209+6,1209+7,1209+8,1209+9,1209+10,1209+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q64.sql new file mode 100644 index 00000000..a1054b29 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('floral','chocolate','linen','puff','dark','smoke') and + i_current_price between 44 and 44 + 10 and + i_current_price between 44 + 1 and 44 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q65.sql new file mode 100644 index 00000000..34a076b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q66.sql new file mode 100644 index 00000000..9d0ef5d5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'ZHOU' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 17210 and 17210+28800 + and sm_carrier in ('FEDEX','ZHOU') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'ZHOU' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 17210 AND 17210+28800 + and sm_carrier in ('FEDEX','ZHOU') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q67.sql new file mode 100644 index 00000000..670ebd5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1182 and 1182+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q68.sql new file mode 100644 index 00000000..abd9f600 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 2 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Hopewell','New Hope') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q69.sql new file mode 100644 index 00000000..c8645db6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('TX','GA','ND') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q70.sql new file mode 100644 index 00000000..fb620454 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1184 and 1184+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1184 and 1184+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q71.sql new file mode 100644 index 00000000..e1852365 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2001 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q72.sql new file mode 100644 index 00000000..e1f1eaea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 1999 + and cd_marital_status = 'D' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q73.sql new file mode 100644 index 00000000..92611abc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Saginaw County','Arthur County','Lea County','Grant County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q74.sql new file mode 100644 index 00000000..3a5a43c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2001 + and t_s_secyear.year = 2001+1 + and t_w_firstyear.year = 2001 + and t_w_secyear.year = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q75.sql new file mode 100644 index 00000000..07c25bd4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Shoes') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q76.sql new file mode 100644 index 00000000..f4291247 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_store_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_store_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_hdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q77.sql new file mode 100644 index 00000000..06c33780 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q78.sql new file mode 100644 index 00000000..896f6ae0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1998 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q79.sql new file mode 100644 index 00000000..fa2b9d67 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 2) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q80.sql new file mode 100644 index 00000000..d5f629a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-28' as date) + and (cast('2000-08-28' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-28' as date) + and (cast('2000-08-28' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-28' as date) + and (cast('2000-08-28' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q81.sql new file mode 100644 index 00000000..54d4c35d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =1998 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MI' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q82.sql new file mode 100644 index 00000000..e721c5c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 39 and 39+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-01-26' as date) and (cast('1999-01-26' as date) + INTERVAL '60' DAY) + and i_manufact_id in (181,735,232,888) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q83.sql new file mode 100644 index 00000000..3dc6f5dd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-05-29',DATE '1999-10-12',DATE '1999-11-23'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-05-29',DATE '1999-10-12',DATE '1999-11-23'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-05-29',DATE '1999-10-12',DATE '1999-11-23'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q84.sql new file mode 100644 index 00000000..f282807f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Macedonia' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 17719 + and ib_upper_bound <= 17719 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q85.sql new file mode 100644 index 00000000..22464ddc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2001 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('AR', 'TN', 'SD') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('CA', 'KY', 'AL') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('OH', 'WA', 'NY') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q86.sql new file mode 100644 index 00000000..75a5aeef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1200 and 1200+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q87.sql new file mode 100644 index 00000000..e82e3ce4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1220 and 1220+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q88.sql new file mode 100644 index 00000000..fdd4edf0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q89.sql new file mode 100644 index 00000000..7b269659 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2002) and + ((i_category in ('Women','Jewelry','Men') and + i_class in ('dresses','earings','accessories') + ) + or (i_category in ('Sports','Shoes','Home') and + i_class in ('athletic shoes','athletic','decor') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q90.sql new file mode 100644 index 00000000..9be53339 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 13 and 13+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q91.sql new file mode 100644 index 00000000..92ceee8a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '1001-5000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q92.sql new file mode 100644 index 00000000..0358c2cd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 991 +and i_item_sk = ws_item_sk +and d_date between DATE '2001-01-31' and + (cast('2001-01-31' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2001-01-31' and + (cast('2001-01-31' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q93.sql new file mode 100644 index 00000000..9bc1a584 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 42') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q94.sql new file mode 100644 index 00000000..aa14e767 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-5-01' and + (cast('2000-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'FL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q95.sql new file mode 100644 index 00000000..a9e44763 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q96.sql new file mode 100644 index 00000000..670de290 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 1 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q97.sql new file mode 100644 index 00000000..ae48c5b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q98.sql new file mode 100644 index 00000000..55599476 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Jewelry', 'Men', 'Electronics') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2000-01-19' as date) + and (cast('2000-01-19' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s17/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s17/q99.sql new file mode 100644 index 00000000..0df159fb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s17/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1216 and 1216 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q01.sql new file mode 100644 index 00000000..bdd7efb0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REVERSED_CHARGE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2002 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'WA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q03.sql new file mode 100644 index 00000000..8c0ff1a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_discount_amt) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 24 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q04.sql new file mode 100644 index 00000000..c6c630fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q05.sql new file mode 100644 index 00000000..0bd6714e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q06.sql new file mode 100644 index 00000000..a96453f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2000 + and d_moy = 1 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q07.sql new file mode 100644 index 00000000..39ab0655 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q08.sql new file mode 100644 index 00000000..aa9fc6f0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '70709','24518','14340','70038','42197','12806', + '27188','34655','73893','39389','85006', + '48977','99912','33301','57084','59213', + '36035','57673','65536','60199','39380', + '68204','80294','36071','69858','21324', + '96709','97423','58862','93278','35414', + '42484','23056','31075','46304','55659', + '47678','98606','80670','37616','37141', + '13255','87906','43996','76185','79809', + '16686','40471','93164','78256','82254', + '99987','73674','89574','68103','88001', + '86215','49030','40085','42173','90909', + '33322','16628','21624','70663','70528', + '57604','93438','41866','61687','85997', + '10618','88603','55701','72533','87227', + '65889','72341','21257','18235','48012', + '12543','30964','43649','65151','14911', + '57428','47711','63945','15964','34450', + '37993','96226','45058','43237','86698', + '93979','57230','89047','35949','42078', + '53001','27741','71132','13179','44968', + '76003','44062','32664','92259','38283', + '76295','63523','70770','99400','97306', + '94720','64877','64289','44040','50782', + '10010','17227','53193','87174','67540', + '44753','13274','19481','72499','18308', + '96392','26244','33055','66273','46317', + '44470','38682','31023','17693','74142', + '42059','91394','57612','71870','55193', + '56468','13334','80769','72522','92537', + '86982','22342','82134','54634','78005', + '18220','90545','42093','82467','22044', + '58852','24490','38711','29616','51078', + '35977','32582','47802','15147','64543', + '17950','55396','21430','19053','28724', + '59067','38292','12481','60714','36655', + '63406','95340','42033','99691','70029', + '97416','63219','42467','92149','12693', + '27114','31518','21123','73353','83708', + '32967','60398','15771','37593','34166', + '36238','55882','85200','50626','37835', + '99344','75433','25690','22445','25156', + '36286','96708','63559','52830','19731', + '52801','80438','35995','98600','52630', + '68527','85394','39505','14894','84746', + '46644','51047','43630','97078','95310', + '77925','43840','45355','58867','28150', + '76292','96195','54930','19584','99539', + '36420','74317','13306','18365','77267', + '36516','85316','80970','60499','13855', + '55819','68059','10362','95818','65614', + '37976','68358','89370','73881','90732', + '32942','30515','89028','77890','47015', + '29241','56538','11561','95025','73751', + '20111','58594','57800','28347','11086', + '24699','96923','92634','40703','74300', + '10234','85479','81741','19716','77724', + '18831','72455','33011','24572','59060', + '79957','41728','72112','26476','51521', + '14161','38207','36331','85721','69390', + '76634','69313','63732','43618','19067', + '15747','93591','48274','53459','17548', + '31069','95278','30327','94917','81233', + '68966','96387','33798','97573','48992', + '22236','62476','74132','63534','86311', + '63083','59783','68444','16822','95500', + '55799','64769','45864','69272','71710', + '74395','99622','92230','68892','28201', + '67977','24360','57028','26803','99771', + '43965','64011','26218','16575','39577', + '97716','85842','76737','18399','92859', + '49581','40700','41093','33651','40882', + '98737','93575','99472','34265','17541', + '84400','36642','57541','24386','33610', + '36149','38058','40641','97569','31410', + '74312','17801','60206','90676','48986', + '33783','41457','27521','66386','74207', + '78702','20814','16407','86373','11864', + '93887','91789','75992','20306','83395', + '91653','75273','35595','68143') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q09.sql new file mode 100644 index 00000000..3d210c55 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 182859374 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 162765659 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 221250156 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 76840897 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 3640258 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q10.sql new file mode 100644 index 00000000..2b0963d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Taylor County','Piscataquis County','Lincoln County','Jackson County','Tippecanoe County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q11.sql new file mode 100644 index 00000000..2a519e3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q12.sql new file mode 100644 index 00000000..1d58a3a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Men', 'Women', 'Books') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-01-19' as date) + and (cast('1999-01-19' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q13.sql new file mode 100644 index 00000000..fdfeee5e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Unknown' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IN', 'IL', 'OH') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MD', 'OK', 'AR') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MT', 'NJ', 'WI') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q14.sql new file mode 100644 index 00000000..0cdf9006 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 20) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 20) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q15.sql new file mode 100644 index 00000000..46e9f91b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2002 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q16.sql new file mode 100644 index 00000000..e0f64afc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2000-4-01' and + (cast('2000-4-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'MI' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Levy County','Franklin Parish','Pennington County','Gage County', + 'Mesa County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q18.sql new file mode 100644 index 00000000..d5abb75b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (8,3,9,12,5,11) and + d_year = 2001 and + ca_state in ('IL','GA','OH' + ,'TX','ID','TN','KY') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q19.sql new file mode 100644 index 00000000..ea581f41 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=30 + and d_moy=11 + and d_year=2000 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q20.sql new file mode 100644 index 00000000..c7d736b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Shoes', 'Sports', 'Women') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-03-23' as date) + and (cast('1998-03-23' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q21.sql new file mode 100644 index 00000000..5eaec3f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-05-23' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1998-05-23' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1998-05-23' as date) - INTERVAL '30' DAY) + and (cast ('1998-05-23' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q22.sql new file mode 100644 index 00000000..2bc277ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1184 and 1184 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q23.sql new file mode 100644 index 00000000..ddfbd6cd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 5 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 5 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q24.sql new file mode 100644 index 00000000..567d6187 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'khaki' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'seashell' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q25.sql new file mode 100644 index 00000000..d0abf362 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_net_profit) as store_sales_profit + ,avg(sr_net_loss) as store_returns_loss + ,avg(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q26.sql new file mode 100644 index 00000000..063d21e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'S' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q27.sql new file mode 100644 index 00000000..8a38c20c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = 'Primary' and + d_year = 2000 and + s_state in ('MN','OH', 'NM', 'WV', 'AL', 'LA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q28.sql new file mode 100644 index 00000000..d2e7e1af --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 52 and 52+10 + or ss_coupon_amt between 12084 and 12084+1000 + or ss_wholesale_cost between 44 and 44+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 128 and 128+10 + or ss_coupon_amt between 17216 and 17216+1000 + or ss_wholesale_cost between 39 and 39+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 189 and 189+10 + or ss_coupon_amt between 11538 and 11538+1000 + or ss_wholesale_cost between 29 and 29+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 0 and 0+10 + or ss_coupon_amt between 7482 and 7482+1000 + or ss_wholesale_cost between 35 and 35+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 81 and 81+10 + or ss_coupon_amt between 13005 and 13005+1000 + or ss_wholesale_cost between 20 and 20+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 131 and 131+10 + or ss_coupon_amt between 8556 and 8556+1000 + or ss_wholesale_cost between 54 and 54+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q29.sql new file mode 100644 index 00000000..38cfd3a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_quantity) as store_sales_quantity + ,min(sr_return_quantity) as store_returns_quantity + ,min(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q30.sql new file mode 100644 index 00000000..4c141a4f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'GA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q31.sql new file mode 100644 index 00000000..0568e9dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1998 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1998 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1998 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1998 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1998 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1998 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q32.sql new file mode 100644 index 00000000..b1838230 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 86 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-03-30' and + (cast('1998-03-30' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-03-30' and + (cast('1998-03-30' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q33.sql new file mode 100644 index 00000000..697bf92e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q34.sql new file mode 100644 index 00000000..5efffcc9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Somerset County','Walker County','Wilkinson County','Halifax County', + 'Mesa County','Camden County','Klamath County','Kittitas County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q35.sql new file mode 100644 index 00000000..6dff12a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + max(cd_dep_count) aggtwo1, + stddev_samp(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + max(cd_dep_employed_count) aggtwo2, + stddev_samp(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + max(cd_dep_college_count) aggtwo3, + stddev_samp(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q36.sql new file mode 100644 index 00000000..3173dc67 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('LA','CO','GA','LA', + 'OK','MI','FL','MN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q37.sql new file mode 100644 index 00000000..4dac3974 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 54 and 54 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-05-04' as date) and (cast('2000-05-04' as date) + INTERVAL '60' DAY) + and i_manufact_id in (771,927,709,969) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q38.sql new file mode 100644 index 00000000..af8af30b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1192 and 1192 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1192 and 1192 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1192 and 1192 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q39.sql new file mode 100644 index 00000000..84028966 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q40.sql new file mode 100644 index 00000000..690cbdc2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-03-24' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2000-03-24' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2000-03-24' as date) - INTERVAL '30' DAY) + and (cast ('2000-03-24' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q41.sql new file mode 100644 index 00000000..3f08e5a6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 964 and 964+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'navy' or i_color = 'chiffon') and + (i_units = 'Each' or i_units = 'Box') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'black' or i_color = 'metallic') and + (i_units = 'Dozen' or i_units = 'Pallet') and + (i_size = 'large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'ivory' or i_color = 'lace') and + (i_units = 'N/A' or i_units = 'Gram') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'red' or i_color = 'almond') and + (i_units = 'Unknown' or i_units = 'Carton') and + (i_size = 'medium' or i_size = 'N/A') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'green' or i_color = 'blanched') and + (i_units = 'Ton' or i_units = 'Pound') and + (i_size = 'medium' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'tan' or i_color = 'rosy') and + (i_units = 'Bunch' or i_units = 'Bundle') and + (i_size = 'large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'salmon' or i_color = 'firebrick') and + (i_units = 'Oz' or i_units = 'Gross') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'sandy' or i_color = 'maroon') and + (i_units = 'Ounce' or i_units = 'Case') and + (i_size = 'medium' or i_size = 'N/A') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q42.sql new file mode 100644 index 00000000..df1387e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2002 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q43.sql new file mode 100644 index 00000000..5675fdee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q44.sql new file mode 100644 index 00000000..35a62e05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 240 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 240 + and ss_cdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 240 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 240 + and ss_cdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q45.sql new file mode 100644 index 00000000..6ffaded3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q46.sql new file mode 100644 index 00000000..43dbb546 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 7 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Highland Park','Eden','Four Corners','Woodland','Red Hill') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q47.sql new file mode 100644 index 00000000..e51b53da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q48.sql new file mode 100644 index 00000000..a7a1c18d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MN', 'GA', 'TX') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('PA', 'NY', 'UT') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'MO', 'WY') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q49.sql new file mode 100644 index 00000000..2949ea35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q50.sql new file mode 100644 index 00000000..fab3d4bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q51.sql new file mode 100644 index 00000000..90daa3c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1199 and 1199+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1199 and 1199+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q52.sql new file mode 100644 index 00000000..af901517 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=1999 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q53.sql new file mode 100644 index 00000000..a0beaab8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1204,1204+1,1204+2,1204+3,1204+4,1204+5,1204+6,1204+7,1204+8,1204+9,1204+10,1204+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q54.sql new file mode 100644 index 00000000..9c1ace04 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Sports' + and i_class = 'fitness' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 6 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 6) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 6) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q55.sql new file mode 100644 index 00000000..f90578b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=11 + and d_moy=12 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q56.sql new file mode 100644 index 00000000..8e319f30 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('navy','ghost','light')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','ghost','light')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','ghost','light')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q57.sql new file mode 100644 index 00000000..c574ccba --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q58.sql new file mode 100644 index 00000000..74859df2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-01-18')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-01-18')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1998-01-18')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q59.sql new file mode 100644 index 00000000..760a5150 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1183 and 1183 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1183+ 12 and 1183 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q60.sql new file mode 100644 index 00000000..8df26aca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q61.sql new file mode 100644 index 00000000..91fb7eb2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q62.sql new file mode 100644 index 00000000..45a1f783 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1206 and 1206 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q63.sql new file mode 100644 index 00000000..bbe5ea5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1179,1179+1,1179+2,1179+3,1179+4,1179+5,1179+6,1179+7,1179+8,1179+9,1179+10,1179+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q64.sql new file mode 100644 index 00000000..d674af42 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('dim','forest','almond','blue','magenta','cyan') and + i_current_price between 36 and 36 + 10 and + i_current_price between 36 + 1 and 36 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q65.sql new file mode 100644 index 00000000..748cb6e9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1210 and 1210+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1210 and 1210+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q66.sql new file mode 100644 index 00000000..f610c2aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'AIRBORNE' || ',' || 'GERMA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 8351 and 8351+28800 + and sm_carrier in ('AIRBORNE','GERMA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'AIRBORNE' || ',' || 'GERMA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 8351 AND 8351+28800 + and sm_carrier in ('AIRBORNE','GERMA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q67.sql new file mode 100644 index 00000000..c5d86072 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1194 and 1194+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q68.sql new file mode 100644 index 00000000..e6315d82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 8 or + household_demographics.hd_vehicle_count= -1) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Buffalo','Needmore') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q69.sql new file mode 100644 index 00000000..df9facf5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('NE','KY','AK') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q70.sql new file mode 100644 index 00000000..792340e9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1207 and 1207+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1207 and 1207+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q71.sql new file mode 100644 index 00000000..e1852365 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2001 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q72.sql new file mode 100644 index 00000000..e51bfa51 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 1999 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q73.sql new file mode 100644 index 00000000..3bbfc91e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Terrell County','Lunenburg County','Dade County','Barrow County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q74.sql new file mode 100644 index 00000000..9d793de3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,2,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q75.sql new file mode 100644 index 00000000..3c1baf40 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Electronics') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q76.sql new file mode 100644 index 00000000..f3d7a556 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_hdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_mode_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_mode_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q77.sql new file mode 100644 index 00000000..b7b6ea6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-22' as date) + and (cast('1999-08-22' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q78.sql new file mode 100644 index 00000000..8d9c905b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q79.sql new file mode 100644 index 00000000..e83c43dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 0 or household_demographics.hd_vehicle_count > 0) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q80.sql new file mode 100644 index 00000000..f8be71eb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-16' as date) + and (cast('2002-08-16' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q81.sql new file mode 100644 index 00000000..4a5bd74e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'PA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q82.sql new file mode 100644 index 00000000..8cee1224 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 34 and 34+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-06-30' as date) and (cast('2000-06-30' as date) + INTERVAL '60' DAY) + and i_manufact_id in (607,30,230,285) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q83.sql new file mode 100644 index 00000000..d35dcbd9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-07-05',DATE '1999-09-08',DATE '1999-11-21'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-07-05',DATE '1999-09-08',DATE '1999-11-21'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-07-05',DATE '1999-09-08',DATE '1999-11-21'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q84.sql new file mode 100644 index 00000000..af26c285 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Florence' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 49306 + and ib_upper_bound <= 49306 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q85.sql new file mode 100644 index 00000000..8c3b1c1d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 1998 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('PA', 'OR', 'TX') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MO', 'NE', 'KY') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MN', 'SD', 'GA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q86.sql new file mode 100644 index 00000000..bc8b2f98 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1208 and 1208+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q87.sql new file mode 100644 index 00000000..0218d8a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1197 and 1197+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q88.sql new file mode 100644 index 00000000..5cff68ff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q89.sql new file mode 100644 index 00000000..47e3b57d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Electronics','Men','Children') and + i_class in ('stereo','shirts','newborn') + ) + or (i_category in ('Sports','Books','Shoes') and + i_class in ('tennis','history','athletic') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q90.sql new file mode 100644 index 00000000..6fa8cf08 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 9 and 9+1 + and household_demographics.hd_dep_count = 5 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 21 and 21+1 + and household_demographics.hd_dep_count = 5 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q91.sql new file mode 100644 index 00000000..fb65f0f6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2002 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '>10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q92.sql new file mode 100644 index 00000000..032633e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 367 +and i_item_sk = ws_item_sk +and d_date between DATE '1999-01-17' and + (cast('1999-01-17' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1999-01-17' and + (cast('1999-01-17' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q93.sql new file mode 100644 index 00000000..a22373be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 66') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q94.sql new file mode 100644 index 00000000..3e946af1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-2-01' and + (cast('2002-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'WI' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q95.sql new file mode 100644 index 00000000..e02f1722 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-3-01' and + (cast('2000-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KY' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q96.sql new file mode 100644 index 00000000..d19dfe77 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 5 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q97.sql new file mode 100644 index 00000000..892117fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1205 and 1205 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1205 and 1205 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q98.sql new file mode 100644 index 00000000..04ad7604 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Electronics', 'Shoes', 'Books') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2001-03-19' as date) + and (cast('2001-03-19' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s18/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s18/q99.sql new file mode 100644 index 00000000..b4abb900 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s18/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1183 and 1183 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q01.sql new file mode 100644 index 00000000..ee417c82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NE' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q03.sql new file mode 100644 index 00000000..6953eb1d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_discount_amt) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 406 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q04.sql new file mode 100644 index 00000000..f00ae300 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q05.sql new file mode 100644 index 00000000..11e440b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1999-08-26' as date) + and (cast('1999-08-26' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1999-08-26' as date) + and (cast('1999-08-26' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1999-08-26' as date) + and (cast('1999-08-26' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q06.sql new file mode 100644 index 00000000..2d9a473b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 2 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q07.sql new file mode 100644 index 00000000..20f33988 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q08.sql new file mode 100644 index 00000000..3717c95d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '97903','58514','53953','45534','42462','13416', + '49301','58772','12479','58994','78786', + '61300','97932','14084','39372','15840', + '37111','80425','77291','32677','50650', + '64179','59945','78578','65512','34858', + '61424','85779','46015','58900','11111', + '23907','21471','48557','92060','31617', + '82862','95058','93528','67622','46066', + '60324','48469','88917','58194','10792', + '77224','38620','13877','30925','29242', + '37451','80016','51852','27241','92571', + '47903','75807','18320','12435','86502', + '71780','12843','22977','69720','93575', + '21832','73413','72472','70530','92327', + '23004','32891','76167','56812','98510', + '91412','41698','39301','66887','88012', + '17283','80845','53386','97742','15258', + '14492','36735','48615','30403','76040', + '61760','21791','97784','94637','41454', + '65410','53573','18137','44924','60973', + '75871','21496','13981','75324','58844', + '19790','13977','82285','99831','67815', + '94357','40420','20873','12168','41850', + '69498','24007','61420','55274','50344', + '28178','12489','22986','61959','59061', + '55844','43669','25716','71302','93514', + '77483','97472','18639','96189','71423', + '38746','56562','45710','28049','66675', + '83983','41387','50244','25960','27993', + '30976','78321','58315','33101','84929', + '76529','96067','37107','24959','55125', + '40951','15236','68183','98147','18322', + '77662','76608','19106','49221','77002', + '66098','15007','73432','67824','34995', + '30067','64091','53998','19461','31900', + '63251','70834','27073','22332','28573', + '66242','93887','54681','54554','41068', + '67113','37739','72804','48256','10545', + '78685','32634','41445','46629','82006', + '78845','95169','62299','68110','46421', + '35586','66908','37416','10974','35336', + '33019','60790','92778','32746','58099', + '24466','95804','51445','40206','51469', + '65303','40547','37624','35134','57973', + '57408','75892','68842','85467','50452', + '79826','41780','26190','51629','17927', + '72150','57468','14721','53358','54875', + '49866','70433','75614','10674','62488', + '41769','15361','17847','83140','14437', + '95851','18887','14461','26416','41473', + '63886','49932','82787','77803','53586', + '23012','22034','81389','79095','81870', + '33254','42053','88793','88010','67873', + '81980','88381','63187','42221','75375', + '48363','96485','85596','94160','17380', + '78961','19478','46936','92726','10832', + '56854','43523','13139','48273','93393', + '77731','63696','54853','99089','90004', + '11282','78427','74725','50373','59485', + '90075','55589','43650','65359','10025', + '26505','98787','21138','91350','17546', + '67950','53952','47724','70722','45802', + '53894','24011','22880','81927','51573', + '58666','62642','75749','66501','62997', + '64904','23092','20860','38024','80233', + '61941','91635','78744','28267','21183', + '21315','60993','28692','36201','33915', + '86841','37820','89344','76868','37753', + '61949','94298','80904','33086','66287', + '14068','49290','51201','84879','58000', + '36115','22956','79942','20631','86408', + '66017','12717','76649','55730','55501', + '55168','62335','65545','53073','67270', + '26261','95322','70059','33550','30746', + '87813','46299','57262','48752','38403', + '95211','90520','75041','90189','20709', + '54824','79684','60066','20879','57283', + '63050','92494','14255','24472','58253', + '81928','60846','39294','91455','65229', + '31303','82578','52792','33076') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1998 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q09.sql new file mode 100644 index 00000000..f53f2a2a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 437543400 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 49672037 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 196888239 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 294443159 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 248187576 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q10.sql new file mode 100644 index 00000000..77fd7f88 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Hardin County','Kern County','Houston County','Mason County','Lawrence County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q11.sql new file mode 100644 index 00000000..6098b65b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q12.sql new file mode 100644 index 00000000..75c82ab3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Sports', 'Home', 'Books') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2001-06-17' as date) + and (cast('2001-06-17' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q13.sql new file mode 100644 index 00000000..6ef5ea83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('SD', 'MS', 'CO') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NC', 'ID', 'OR') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TN', 'NE', 'IL') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q14.sql new file mode 100644 index 00000000..b7157842 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 9) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 9) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q16.sql new file mode 100644 index 00000000..4754b980 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-2-01' and + (cast('1999-2-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'MI' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Gogebic County','Pennington County','Dauphin County','Bronx County', + 'Mobile County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q18.sql new file mode 100644 index 00000000..d60e9688 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Advanced Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (12,5,11,7,2,8) and + d_year = 2000 and + ca_state in ('TX','MS','VA' + ,'KS','WY','PA','SD') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q19.sql new file mode 100644 index 00000000..5f19e7aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=29 + and d_moy=12 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q20.sql new file mode 100644 index 00000000..5fa44406 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Men', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-06-02' as date) + and (cast('1998-06-02' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q21.sql new file mode 100644 index 00000000..7f266068 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-04-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2002-04-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2002-04-22' as date) - INTERVAL '30' DAY) + and (cast ('2002-04-22' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q22.sql new file mode 100644 index 00000000..8a1a4d9a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1179 and 1179 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q23.sql new file mode 100644 index 00000000..f89db70a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1999 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1999 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q24.sql new file mode 100644 index 00000000..61d3d282 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'olive' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'lemon' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q25.sql new file mode 100644 index 00000000..121161f5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,sum(ss_net_profit) as store_sales_profit + ,sum(sr_net_loss) as store_returns_loss + ,sum(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q26.sql new file mode 100644 index 00000000..9785a989 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2000 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q27.sql new file mode 100644 index 00000000..c23832e1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = 'Unknown' and + d_year = 2000 and + s_state in ('MI','NY', 'NE', 'AL', 'SC', 'SD') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q28.sql new file mode 100644 index 00000000..213c70aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 53 and 53+10 + or ss_coupon_amt between 2671 and 2671+1000 + or ss_wholesale_cost between 55 and 55+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 120 and 120+10 + or ss_coupon_amt between 797 and 797+1000 + or ss_wholesale_cost between 32 and 32+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 114 and 114+10 + or ss_coupon_amt between 16300 and 16300+1000 + or ss_wholesale_cost between 25 and 25+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 155 and 155+10 + or ss_coupon_amt between 6097 and 6097+1000 + or ss_wholesale_cost between 45 and 45+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 7 and 7+10 + or ss_coupon_amt between 615 and 615+1000 + or ss_wholesale_cost between 53 and 53+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 70 and 70+10 + or ss_coupon_amt between 2585 and 2585+1000 + or ss_wholesale_cost between 10 and 10+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q29.sql new file mode 100644 index 00000000..5b133d4d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,sum(ss_quantity) as store_sales_quantity + ,sum(sr_return_quantity) as store_returns_quantity + ,sum(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q30.sql new file mode 100644 index 00000000..3a225a0c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =1999 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'VA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q31.sql new file mode 100644 index 00000000..750eb20c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2001 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2001 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2001 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2001 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2001 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2001 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q32.sql new file mode 100644 index 00000000..27a33ee2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 708 +and i_item_sk = cs_item_sk +and d_date between DATE '1999-02-23' and + (cast('1999-02-23' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1999-02-23' and + (cast('1999-02-23' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q33.sql new file mode 100644 index 00000000..2200e518 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q34.sql new file mode 100644 index 00000000..5b4608cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Dauphin County','Appanoose County','Coal County','Essex County', + 'Grant County','Maverick County','Harmon County','Mesa County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q35.sql new file mode 100644 index 00000000..b5da172c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + avg(cd_dep_count) aggone1, + sum(cd_dep_count) aggtwo1, + min(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + avg(cd_dep_employed_count) aggone2, + sum(cd_dep_employed_count) aggtwo2, + min(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + avg(cd_dep_college_count) aggone3, + sum(cd_dep_college_count) aggtwo3, + min(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q36.sql new file mode 100644 index 00000000..2db21611 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2002 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('TN','GA','OK','LA', + 'TN','WV','NY','VT') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q37.sql new file mode 100644 index 00000000..632579c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 67 and 67 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-03-16' as date) and (cast('1999-03-16' as date) + INTERVAL '60' DAY) + and i_manufact_id in (761,910,734,690) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q38.sql new file mode 100644 index 00000000..14361ad9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1204 and 1204 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q39.sql new file mode 100644 index 00000000..bdc74d5a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q40.sql new file mode 100644 index 00000000..7773e7a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-05-09' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2002-05-09' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2002-05-09' as date) - INTERVAL '30' DAY) + and (cast ('2002-05-09' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q41.sql new file mode 100644 index 00000000..83d54a4a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 763 and 763+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'blanched' or i_color = 'blush') and + (i_units = 'Case' or i_units = 'Bundle') and + (i_size = 'N/A' or i_size = 'petite') + ) or + (i_category = 'Women' and + (i_color = 'navy' or i_color = 'rosy') and + (i_units = 'Bunch' or i_units = 'Ton') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'brown' or i_color = 'hot') and + (i_units = 'Oz' or i_units = 'Unknown') and + (i_size = 'medium' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'plum' or i_color = 'beige') and + (i_units = 'Box' or i_units = 'Dozen') and + (i_size = 'N/A' or i_size = 'petite') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'dark' or i_color = 'royal') and + (i_units = 'Ounce' or i_units = 'Gram') and + (i_size = 'N/A' or i_size = 'petite') + ) or + (i_category = 'Women' and + (i_color = 'cornflower' or i_color = 'burnished') and + (i_units = 'Tbl' or i_units = 'Dram') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'blue' or i_color = 'pale') and + (i_units = 'N/A' or i_units = 'Pound') and + (i_size = 'medium' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'lawn' or i_color = 'red') and + (i_units = 'Carton' or i_units = 'Each') and + (i_size = 'N/A' or i_size = 'petite') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q42.sql new file mode 100644 index 00000000..3558f2bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q43.sql new file mode 100644 index 00000000..5675fdee --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q44.sql new file mode 100644 index 00000000..ce2b9ce4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 668 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 668 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 668 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 668 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q45.sql new file mode 100644 index 00000000..fc55dc1e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q46.sql new file mode 100644 index 00000000..2ce7898a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 9 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Newport','Pine Hill','Rose Hill','Summit','Riverside') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q47.sql new file mode 100644 index 00000000..279909c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q48.sql new file mode 100644 index 00000000..4c97c100 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('AL', 'LA', 'NC') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MS', 'HI', 'TX') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MO', 'WI', 'MI') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q49.sql new file mode 100644 index 00000000..2757da90 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q50.sql new file mode 100644 index 00000000..6f780a48 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1998 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q51.sql new file mode 100644 index 00000000..c3b280b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1222 and 1222+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1222 and 1222+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q52.sql new file mode 100644 index 00000000..91345919 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q53.sql new file mode 100644 index 00000000..12d20618 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1192,1192+1,1192+2,1192+3,1192+4,1192+5,1192+6,1192+7,1192+8,1192+9,1192+10,1192+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q54.sql new file mode 100644 index 00000000..438f2413 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Music' + and i_class = 'rock' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 6 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 6) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 6) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q55.sql new file mode 100644 index 00000000..add9bd5b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=44 + and d_moy=11 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q56.sql new file mode 100644 index 00000000..577d68e8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('azure','tan','violet')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('azure','tan','violet')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('azure','tan','violet')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q57.sql new file mode 100644 index 00000000..b45c2dbc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q58.sql new file mode 100644 index 00000000..9ffa0804 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-05-02')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-05-02')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2000-05-02')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q59.sql new file mode 100644 index 00000000..6351d94a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1180 and 1180 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1180+ 12 and 1180 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q60.sql new file mode 100644 index 00000000..8f237982 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q61.sql new file mode 100644 index 00000000..42270577 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Jewelry' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Jewelry' + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q62.sql new file mode 100644 index 00000000..2ea89f10 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1221 and 1221 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q63.sql new file mode 100644 index 00000000..c46a1cc9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1202,1202+1,1202+2,1202+3,1202+4,1202+5,1202+6,1202+7,1202+8,1202+9,1202+10,1202+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q64.sql new file mode 100644 index 00000000..b1a48bca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('navy','royal','rose','metallic','azure','papaya') and + i_current_price between 63 and 63 + 10 and + i_current_price between 63 + 1 and 63 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q65.sql new file mode 100644 index 00000000..55d1a77e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1211 and 1211+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1211 and 1211+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q66.sql new file mode 100644 index 00000000..989901c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'UPS' || ',' || 'RUPEKSA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_profit * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_profit * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_profit * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_profit * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_profit * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_profit * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_profit * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_profit * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_profit * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_profit * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_profit * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_profit * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2000 + and t_time between 23444 and 23444+28800 + and sm_carrier in ('UPS','RUPEKSA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'UPS' || ',' || 'RUPEKSA' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2000 + and t_time between 23444 AND 23444+28800 + and sm_carrier in ('UPS','RUPEKSA') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q67.sql new file mode 100644 index 00000000..670ebd5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1182 and 1182+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q68.sql new file mode 100644 index 00000000..669042a0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 6 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Vernon','Pleasant Hill') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q69.sql new file mode 100644 index 00000000..4f23d230 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('OK','IL','TN') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 3 and 3+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 3 and 3+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 3 and 3+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q70.sql new file mode 100644 index 00000000..1c23a4d6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1197 and 1197+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1197 and 1197+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q72.sql new file mode 100644 index 00000000..1308afa8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 2001 + and cd_marital_status = 'D' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q73.sql new file mode 100644 index 00000000..01e3a18d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Miller County','Dauphin County','Quay County','Perry County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q74.sql new file mode 100644 index 00000000..9106bd6f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,2,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q75.sql new file mode 100644 index 00000000..d7ce6a23 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Children' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Children') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q76.sql new file mode 100644 index 00000000..d919bcf8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_cdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_cdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_hdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_mode_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_mode_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q77.sql new file mode 100644 index 00000000..86eeba70 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-14' as date) + and (cast('1998-08-14' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q78.sql new file mode 100644 index 00000000..8d9c905b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q79.sql new file mode 100644 index 00000000..4a49cb48 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 1 or household_demographics.hd_vehicle_count > -1) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q80.sql new file mode 100644 index 00000000..59a278d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-23' as date) + and (cast('2002-08-23' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-23' as date) + and (cast('2002-08-23' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-23' as date) + and (cast('2002-08-23' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q81.sql new file mode 100644 index 00000000..f045bf37 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =1998 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AZ' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q82.sql new file mode 100644 index 00000000..8253f72f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 33 and 33+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-04-14' as date) and (cast('1999-04-14' as date) + INTERVAL '60' DAY) + and i_manufact_id in (97,522,171,93) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q83.sql new file mode 100644 index 00000000..50d78419 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-23',DATE '1999-09-17',DATE '1999-11-19'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-23',DATE '1999-09-17',DATE '1999-11-19'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-23',DATE '1999-09-17',DATE '1999-11-19'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q84.sql new file mode 100644 index 00000000..a94381f1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Pleasant Valley' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 743 + and ib_upper_bound <= 743 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q85.sql new file mode 100644 index 00000000..ffbfb838 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2000 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('KY', 'TN', 'OK') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('NE', 'MO', 'TX') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('AR', 'WI', 'VA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q86.sql new file mode 100644 index 00000000..65612ec0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1204 and 1204+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q87.sql new file mode 100644 index 00000000..90c95b60 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1180 and 1180+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1180 and 1180+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1180 and 1180+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q88.sql new file mode 100644 index 00000000..dce14775 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q89.sql new file mode 100644 index 00000000..c4d3b0a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1999) and + ((i_category in ('Women','Books','Sports') and + i_class in ('fragrances','fiction','hockey') + ) + or (i_category in ('Men','Jewelry','Home') and + i_class in ('accessories','jewelry boxes','accent') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q90.sql new file mode 100644 index 00000000..a31d8375 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 11 and 11+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 21 and 21+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q91.sql new file mode 100644 index 00000000..467b9174 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '1001-5000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q92.sql new file mode 100644 index 00000000..608211f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 985 +and i_item_sk = ws_item_sk +and d_date between DATE '2000-02-19' and + (cast('2000-02-19' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2000-02-19' and + (cast('2000-02-19' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q93.sql new file mode 100644 index 00000000..ca11780c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'Not working any more') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q94.sql new file mode 100644 index 00000000..480cb9b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q95.sql new file mode 100644 index 00000000..dea82f6a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-3-01' and + (cast('1999-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'WI' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q96.sql new file mode 100644 index 00000000..3bd36bc8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 9 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q97.sql new file mode 100644 index 00000000..d1c9357e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1180 and 1180 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1180 and 1180 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q98.sql new file mode 100644 index 00000000..625570b5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Books', 'Women', 'Men') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1998-03-14' as date) + and (cast('1998-03-14' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s19/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s19/q99.sql new file mode 100644 index 00000000..0cdcfa2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s19/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1195 and 1195 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q01.sql new file mode 100644 index 00000000..9db1ea8a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_STORE_CREDIT) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'LA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q03.sql new file mode 100644 index 00000000..255055f1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_discount_amt) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 229 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q04.sql new file mode 100644 index 00000000..659c6c43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q05.sql new file mode 100644 index 00000000..0bd6714e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q06.sql new file mode 100644 index 00000000..37895df9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 6 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q07.sql new file mode 100644 index 00000000..910d6704 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q08.sql new file mode 100644 index 00000000..1bd14d66 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '51517','33994','16174','47054','48013','57690', + '52901','43115','61844','96913','66275', + '77214','96229','67623','24906','14504', + '98865','45680','91893','10589','67722', + '58190','94095','40226','71941','35224', + '59363','79308','19225','35149','88112', + '60237','29345','24474','80492','51289', + '69687','51904','33426','90377','78522', + '55883','71868','11086','65473','90211', + '31464','78886','66183','99651','40067', + '19758','98416','73400','49300','36947', + '64756','21309','83080','66066','60561', + '26048','33280','41630','94847','19659', + '96794','23885','58323','10975','99987', + '23226','66440','15797','31663','31348', + '43971','16785','84773','44595','78096', + '10679','86623','84009','61183','84447', + '56723','39554','10661','27444','42660', + '97858','82892','12127','97773','88355', + '52374','26907','51014','33600','21063', + '98620','20423','15121','90278','63406', + '61061','86916','62360','84016','35065', + '80574','62600','31123','72009','82474', + '33299','72354','60434','93556','77349', + '31402','73852','95484','28890','86533', + '72581','69785','61547','97453','90174', + '67964','77385','72885','86846','28380', + '82322','66262','19947','82900','96046', + '77324','71220','71586','31971','36959', + '92074','96627','26030','78240','15011', + '65925','20488','57697','94751','16206', + '99883','47970','65327','64163','52949', + '29338','89656','11240','57537','35050', + '13234','51784','72893','67780','70710', + '77687','57785','70882','28807','51111', + '33542','91007','41287','77224','70586', + '59300','54618','88292','13329','85921', + '53621','65260','97844','77730','57774', + '71475','22545','71434','34817','43079', + '55692','33902','23517','32714','29712', + '98901','44548','38532','38279','16430', + '70768','19006','55297','36721','36174', + '58713','22843','85959','74289','98130', + '97442','67098','69273','16362','61576', + '25313','24003','26222','71641','67256', + '91826','47322','17668','93616','26011', + '18480','88050','63820','46478','65496', + '37544','50776','69093','75787','30225', + '81726','20776','41700','12538','88209', + '25066','70127','61679','73244','79287', + '24497','55252','39805','55374','88752', + '37724','89212','49775','92110','85890', + '81123','46533','53943','12940','18115', + '74145','19561','92778','30229','62714', + '36075','22075','42490','78129','34973', + '92712','76563','40882','91052','12654', + '52079','67056','64282','48067','98679', + '84803','83394','20367','77406','54535', + '50018','19307','95152','31619','35290', + '94727','87555','33809','78364','47183', + '79872','57597','65570','94889','13820', + '76491','87616','24872','61837','96668', + '58535','95461','19539','11169','34290', + '62423','52383','78717','62383','75773', + '59645','15361','71899','91543','94963', + '92795','10813','72025','97060','11982', + '81550','70933','99684','28377','34095', + '48383','61669','52861','18493','12726', + '66557','18888','59527','63986','94425', + '58177','44170','10411','10406','86964', + '88830','85361','29465','71277','21022', + '59979','39950','36122','97159','88394', + '99935','37928','76823','47133','17538', + '70568','94971','55304','72655','85728', + '17082','87576','57637','11907','22280', + '81065','68815','12751','29887','95997', + '29596','89955','10677','44902','42005', + '69727','84312','60142','52433','18573', + '61020','61282','16671','90102','47900', + '96747','87723','86986','91790') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q09.sql new file mode 100644 index 00000000..faf0cce6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 270164384 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 479728053 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 31261127 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 469402850 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 316053926 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q10.sql new file mode 100644 index 00000000..4a5ac619 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('New Kent County','Dillon County','Leflore County','Calvert County','Chippewa County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q11.sql new file mode 100644 index 00000000..a6fef7b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q12.sql new file mode 100644 index 00000000..77343a6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Music', 'Women', 'Shoes') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-01-19' as date) + and (cast('2000-01-19' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q13.sql new file mode 100644 index 00000000..476de40b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'Primary' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'College' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MT', 'IA', 'AR') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'KS', 'VT') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NE', 'MD', 'MO') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q14.sql new file mode 100644 index 00000000..4de91bae --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + 1 + and d_moy = 12 + and d_dom = 24) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + and d_moy = 12 + and d_dom = 24) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q16.sql new file mode 100644 index 00000000..dd0576ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'KY' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('San Miguel County','Mesa County','Jackson County','Gage County', + 'Huron County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q17.sql new file mode 100644 index 00000000..32070a34 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2000Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q18.sql new file mode 100644 index 00000000..bb5cc55a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Unknown' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (4,1,3,9,10,7) and + d_year = 2000 and + ca_state in ('SD','GA','MD' + ,'ID','VA','TN','IL') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q19.sql new file mode 100644 index 00000000..722050e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=57 + and d_moy=12 + and d_year=2001 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q20.sql new file mode 100644 index 00000000..89cfcfcd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Jewelry', 'Electronics') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-06-16' as date) + and (cast('2002-06-16' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q21.sql new file mode 100644 index 00000000..00e2bbf7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-02-11' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1998-02-11' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1998-02-11' as date) - INTERVAL '30' DAY) + and (cast ('1998-02-11' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q22.sql new file mode 100644 index 00000000..e7ce24ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1203 and 1203 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q23.sql new file mode 100644 index 00000000..9053732f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q24.sql new file mode 100644 index 00000000..17bb7d7b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'white' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'antique' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q25.sql new file mode 100644 index 00000000..bb04db9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_net_profit) as store_sales_profit + ,min(sr_net_loss) as store_returns_loss + ,min(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q26.sql new file mode 100644 index 00000000..6e707d4f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = 'Advanced Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q27.sql new file mode 100644 index 00000000..9bd0c63e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = 'Secondary' and + d_year = 2000 and + s_state in ('OH','NY', 'CO', 'AL', 'MI', 'LA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q28.sql new file mode 100644 index 00000000..35cf0049 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 42 and 42+10 + or ss_coupon_amt between 15852 and 15852+1000 + or ss_wholesale_cost between 41 and 41+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 131 and 131+10 + or ss_coupon_amt between 9859 and 9859+1000 + or ss_wholesale_cost between 71 and 71+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 137 and 137+10 + or ss_coupon_amt between 16816 and 16816+1000 + or ss_wholesale_cost between 32 and 32+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 158 and 158+10 + or ss_coupon_amt between 4828 and 4828+1000 + or ss_wholesale_cost between 34 and 34+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 181 and 181+10 + or ss_coupon_amt between 15035 and 15035+1000 + or ss_wholesale_cost between 45 and 45+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 13 and 13+10 + or ss_coupon_amt between 12079 and 12079+1000 + or ss_wholesale_cost between 53 and 53+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q29.sql new file mode 100644 index 00000000..a2503610 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_quantity) as store_sales_quantity + ,avg(sr_return_quantity) as store_returns_quantity + ,avg(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q30.sql new file mode 100644 index 00000000..72b3a09d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2002 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q31.sql new file mode 100644 index 00000000..d435e123 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by web_q2_q3_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q32.sql new file mode 100644 index 00000000..eb4b9249 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 514 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-03-07' and + (cast('1998-03-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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-03-07' and + (cast('1998-03-07' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q33.sql new file mode 100644 index 00000000..ad5b1355 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q34.sql new file mode 100644 index 00000000..84156357 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Mesa County','Baltimore County','Gage County','Reagan County', + 'Appanoose County','Gogebic County','Tehama County','Fairfield County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q35.sql new file mode 100644 index 00000000..0c1c605e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + avg(cd_dep_count) aggone1, + max(cd_dep_count) aggtwo1, + sum(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + avg(cd_dep_employed_count) aggone2, + max(cd_dep_employed_count) aggtwo2, + sum(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + avg(cd_dep_college_count) aggone3, + max(cd_dep_college_count) aggtwo3, + sum(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q36.sql new file mode 100644 index 00000000..06fe2d2e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('AL','TN','CO','MN', + 'PA','IN','OK','NM') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q37.sql new file mode 100644 index 00000000..71d59f8e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 43 and 43 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-06-19' as date) and (cast('1998-06-19' as date) + INTERVAL '60' DAY) + and i_manufact_id in (902,701,874,984) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q38.sql new file mode 100644 index 00000000..c42daf64 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1186 and 1186 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1186 and 1186 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1186 and 1186 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q39.sql new file mode 100644 index 00000000..27c1665b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q40.sql new file mode 100644 index 00000000..3c4babf7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-02-10' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2000-02-10' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2000-02-10' as date) - INTERVAL '30' DAY) + and (cast ('2000-02-10' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q41.sql new file mode 100644 index 00000000..c4d90e01 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 746 and 746+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'white' or i_color = 'brown') and + (i_units = 'Case' or i_units = 'Bunch') and + (i_size = 'N/A' or i_size = 'medium') + ) or + (i_category = 'Women' and + (i_color = 'salmon' or i_color = 'red') and + (i_units = 'Carton' or i_units = 'Pallet') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'smoke' or i_color = 'turquoise') and + (i_units = 'Pound' or i_units = 'Dozen') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'plum' or i_color = 'beige') and + (i_units = 'Cup' or i_units = 'Gram') and + (i_size = 'N/A' or i_size = 'medium') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'spring' or i_color = 'puff') and + (i_units = 'Ton' or i_units = 'Each') and + (i_size = 'N/A' or i_size = 'medium') + ) or + (i_category = 'Women' and + (i_color = 'deep' or i_color = 'royal') and + (i_units = 'Dram' or i_units = 'Tsp') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'pink' or i_color = 'burnished') and + (i_units = 'Gross' or i_units = 'Bundle') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Men' and + (i_color = 'orange' or i_color = 'ivory') and + (i_units = 'Ounce' or i_units = 'Tbl') and + (i_size = 'N/A' or i_size = 'medium') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q42.sql new file mode 100644 index 00000000..fe3da293 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1999 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q43.sql new file mode 100644 index 00000000..ee3806a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2001 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q44.sql new file mode 100644 index 00000000..0bff327f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 626 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 626 + and ss_promo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 626 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 626 + and ss_promo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q45.sql new file mode 100644 index 00000000..0c3427f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q46.sql new file mode 100644 index 00000000..edef4328 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Williamsburg','Riverdale','Hollywood','Hebron','Milltown') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q47.sql new file mode 100644 index 00000000..1abc2dac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q48.sql new file mode 100644 index 00000000..cb98f254 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1998 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'College' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IN', 'IL', 'KY') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('GA', 'KS', 'AL') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'TN', 'AK') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q49.sql new file mode 100644 index 00000000..d020114e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q50.sql new file mode 100644 index 00000000..6f780a48 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1998 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q51.sql new file mode 100644 index 00000000..0ab3fee9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1220 and 1220+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1220 and 1220+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q52.sql new file mode 100644 index 00000000..7d81431b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q53.sql new file mode 100644 index 00000000..1e9ee7d7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1184,1184+1,1184+2,1184+3,1184+4,1184+5,1184+6,1184+7,1184+8,1184+9,1184+10,1184+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q54.sql new file mode 100644 index 00000000..98afb608 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Home' + and i_class = 'flatware' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 6 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 6) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 6) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q55.sql new file mode 100644 index 00000000..bf7dc301 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=23 + and d_moy=11 + and d_year=1998 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q56.sql new file mode 100644 index 00000000..bd74d5d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('ghost','lawn','pale')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('ghost','lawn','pale')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('ghost','lawn','pale')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q57.sql new file mode 100644 index 00000000..6d2596c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q58.sql new file mode 100644 index 00000000..ec593ba4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-02-21')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-02-21')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-02-21')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q59.sql new file mode 100644 index 00000000..1577cdcd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1203 and 1203 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1203+ 12 and 1203 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q60.sql new file mode 100644 index 00000000..b062931b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q61.sql new file mode 100644 index 00000000..5ffef9a6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Electronics' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 2002 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Electronics' + and s_gmt_offset = -6 + and d_year = 2002 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q62.sql new file mode 100644 index 00000000..670f4696 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1177 and 1177 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q63.sql new file mode 100644 index 00000000..b9d16180 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1201,1201+1,1201+2,1201+3,1201+4,1201+5,1201+6,1201+7,1201+8,1201+9,1201+10,1201+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q64.sql new file mode 100644 index 00000000..7ae6d0e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('cornsilk','white','cream','coral','plum','light') and + i_current_price between 55 and 55 + 10 and + i_current_price between 55 + 1 and 55 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q65.sql new file mode 100644 index 00000000..f938bd50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1189 and 1189+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1189 and 1189+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q66.sql new file mode 100644 index 00000000..9fd2625c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'USPS' || ',' || 'HARMSTORF' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_profit * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_profit * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_profit * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_profit * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_profit * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_profit * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_profit * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_profit * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_profit * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_profit * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_profit * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_profit * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 28436 and 28436+28800 + and sm_carrier in ('USPS','HARMSTORF') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'USPS' || ',' || 'HARMSTORF' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 28436 AND 28436+28800 + and sm_carrier in ('USPS','HARMSTORF') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q67.sql new file mode 100644 index 00000000..abee155a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1191 and 1191+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q68.sql new file mode 100644 index 00000000..9a6996da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 2 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Enterprise','Bridgeport') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q69.sql new file mode 100644 index 00000000..eb813427 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('WI','IN','TX') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q70.sql new file mode 100644 index 00000000..3c3693e9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1183 and 1183+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1183 and 1183+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q71.sql new file mode 100644 index 00000000..e1852365 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2001 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q72.sql new file mode 100644 index 00000000..6df933fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 2001 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q73.sql new file mode 100644 index 00000000..ff1d7cbd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Baltimore County','Red River Parish','Warren County','Barrow County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q74.sql new file mode 100644 index 00000000..2e30ab59 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2000 + and t_s_secyear.year = 2000+1 + and t_w_firstyear.year = 2000 + and t_w_secyear.year = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,1,3 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q75.sql new file mode 100644 index 00000000..07c25bd4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Shoes' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Shoes') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q76.sql new file mode 100644 index 00000000..4672d9fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_addr_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_addr_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_addr_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q77.sql new file mode 100644 index 00000000..e1d13973 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q78.sql new file mode 100644 index 00000000..91212141 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2001 +order by + ss_sold_year, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q79.sql new file mode 100644 index 00000000..5e810499 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 3 or household_demographics.hd_vehicle_count > 0) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q80.sql new file mode 100644 index 00000000..27479ab2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q81.sql new file mode 100644 index 00000000..39310d96 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2000 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q82.sql new file mode 100644 index 00000000..e2dc1280 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 43 and 43+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-03-27' as date) and (cast('2001-03-27' as date) + INTERVAL '60' DAY) + and i_manufact_id in (550,774,166,80) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q83.sql new file mode 100644 index 00000000..b7cffe56 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-04',DATE '2001-08-05',DATE '2001-11-11'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-04',DATE '2001-08-05',DATE '2001-11-11'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-04-04',DATE '2001-08-05',DATE '2001-11-11'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q84.sql new file mode 100644 index 00000000..5324ccd3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Five Forks' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 19261 + and ib_upper_bound <= 19261 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q85.sql new file mode 100644 index 00000000..33a47412 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2000 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('MO', 'KY', 'TX') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('KS', 'ID', 'MS') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('OK', 'IN', 'WI') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q86.sql new file mode 100644 index 00000000..b3158184 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1189 and 1189+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q87.sql new file mode 100644 index 00000000..fca0c8c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q88.sql new file mode 100644 index 00000000..8c1a6f6b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q89.sql new file mode 100644 index 00000000..297b3e9d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2002) and + ((i_category in ('Music','Children','Shoes') and + i_class in ('classical','toddlers','mens') + ) + or (i_category in ('Books','Electronics','Sports') and + i_class in ('cooking','personal','golf') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q90.sql new file mode 100644 index 00000000..98604df8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 6 and 6+1 + and household_demographics.hd_dep_count = 7 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 19 and 19+1 + and household_demographics.hd_dep_count = 7 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q91.sql new file mode 100644 index 00000000..e4629fa6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 11 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '5001-10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q92.sql new file mode 100644 index 00000000..e3980f66 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 853 +and i_item_sk = ws_item_sk +and d_date between DATE '2002-01-08' and + (cast('2002-01-08' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2002-01-08' and + (cast('2002-01-08' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q93.sql new file mode 100644 index 00000000..6ad35cf0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'Found a better price in a store') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q94.sql new file mode 100644 index 00000000..f8085451 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-3-01' and + (cast('2002-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KS' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q95.sql new file mode 100644 index 00000000..8c3a71cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'NC' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q96.sql new file mode 100644 index 00000000..93b2ec0c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 20 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 3 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q97.sql new file mode 100644 index 00000000..1de6468f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1204 and 1204 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1204 and 1204 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q98.sql new file mode 100644 index 00000000..e3d0f63f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Electronics', 'Jewelry', 'Children') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1998-04-15' as date) + and (cast('1998-04-15' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s2/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s2/q99.sql new file mode 100644 index 00000000..d28c2839 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s2/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1188 and 1188 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q01.sql new file mode 100644 index 00000000..92fded4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REFUNDED_CASH) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1998 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'MN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q02.sql new file mode 100644 index 00000000..a3aaa0b9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q03.sql new file mode 100644 index 00000000..e187411c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 213 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q04.sql new file mode 100644 index 00000000..39e93d44 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q05.sql new file mode 100644 index 00000000..d0f5fb35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2000-08-08' as date) + and (cast('2000-08-08' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2000-08-08' as date) + and (cast('2000-08-08' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2000-08-08' as date) + and (cast('2000-08-08' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q06.sql new file mode 100644 index 00000000..37895df9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 6 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q07.sql new file mode 100644 index 00000000..34d147f1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q08.sql new file mode 100644 index 00000000..c1ccdc48 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '24346','38337','95156','75456','55168','48494', + '48575','47945','64778','73822','36143', + '44804','26589','29161','45302','81529', + '10996','67852','33189','44689','93998', + '73195','13887','83261','81100','84633', + '47340','47895','64848','52448','27543', + '55012','20010','72701','28363','25511', + '19216','23375','57243','98987','51714', + '34343','28654','54263','27115','33817', + '84323','81561','51499','99962','98041', + '95961','64357','76818','59858','52531', + '39275','18175','27347','65150','46374', + '59368','16605','34565','30183','33852', + '37385','90527','43583','13664','35615', + '75436','50776','26016','31039','76623', + '36881','77548','81307','13466','62737', + '31312','61357','44256','65189','24991', + '70133','46918','30014','96771','40161', + '83094','98757','87031','77135','71863', + '15003','88498','88125','40649','41199', + '31605','84927','91794','76655','17560', + '33308','72882','74167','90584','70944', + '32356','23477','90545','89579','82675', + '40672','70616','54894','92703','50544', + '18102','25995','27955','52495','41367', + '11732','68311','79491','95953','32194', + '16591','12717','82322','45853','85616', + '70776','20443','90589','44415','11162', + '75282','58101','70659','53453','32618', + '47148','99214','47925','40937','38395', + '36635','15429','42794','65844','28491', + '95144','57548','60325','93944','45645', + '24591','18473','58454','85225','86355', + '15320','47371','26738','56024','55617', + '25692','86844','17342','13116','24145', + '84522','42325','61011','82383','50220', + '59579','35100','84820','94007','45984', + '77998','61993','66167','90627','57925', + '78887','41782','15999','57522','31388', + '60513','23710','27549','77033','79808', + '54401','32711','14897','37437','48179', + '53757','93830','74262','93338','84079', + '40951','96643','56350','94579','85254', + '45900','94582','84081','64947','56147', + '65475','55276','93277','63835','58556', + '64624','70029','24630','80742','69167', + '46090','74137','56217','73553','11667', + '49853','98909','33833','11899','28690', + '74410','34247','26188','50447','19186', + '38122','64072','48323','33391','60507', + '27514','56974','47630','94156','56417', + '97168','73717','86115','17547','11826', + '26701','94748','17884','88158','97585', + '74203','43488','82528','81658','91876', + '51844','73118','31586','31480','85332', + '60098','98226','62740','44390','76986', + '68902','43306','53869','14770','22071', + '42858','23793','19957','82920','93294', + '82013','76706','68541','61988','46200', + '76540','75013','88908','44919','99100', + '82646','43701','19076','37650','41366', + '17707','75971','41236','65757','47093', + '46007','29757','77624','40765','67652', + '86878','63723','49740','57869','46041', + '59907','73941','89240','19711','27211', + '13313','11719','78278','42511','45898', + '50632','84902','73820','68359','81611', + '34622','30524','60168','18677','89058', + '88595','16147','22795','36795','48356', + '10052','14915','11357','90333','17188', + '65239','30010','34061','97061','90419', + '79617','72510','77967','72135','33855', + '56933','57123','20122','64198','17404', + '16121','81750','54592','68314','17095', + '46185','22998','63320','92321','67051', + '44732','82479','50324','11856','86285', + '51294','68215','66187','14796','71951', + '21017','68092','28364','15782','30575', + '38345','80792','37430','50705','90335', + '51626','48389','36908','80872') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q09.sql new file mode 100644 index 00000000..c8b7f110 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 371960506 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 351822782 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 161739050 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 383141339 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 389202713 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q10.sql new file mode 100644 index 00000000..e4a56122 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Blue Earth County','Cameron Parish','Yellowstone County','Adams County','Darlington County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q11.sql new file mode 100644 index 00000000..2a519e3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q12.sql new file mode 100644 index 00000000..ea531707 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Shoes', 'Women', 'Children') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1998-01-31' as date) + and (cast('1998-01-31' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q13.sql new file mode 100644 index 00000000..b03ce2e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('GA', 'KS', 'NE') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'OR', 'NJ') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MO', 'OK', 'IA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q14.sql new file mode 100644 index 00000000..4f2f3c6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q15.sql new file mode 100644 index 00000000..bd2496e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q16.sql new file mode 100644 index 00000000..3c720e3b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2000-4-01' and + (cast('2000-4-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Fairfield County','Franklin Parish','Jackson County','Kittitas County', + 'Bronx County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q18.sql new file mode 100644 index 00000000..d29eba45 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'College' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (2,3,12,7,11,1) and + d_year = 2002 and + ca_state in ('AL','UT','VA' + ,'VT','KS','AR','OH') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q19.sql new file mode 100644 index 00000000..9a3d04fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=28 + and d_moy=11 + and d_year=2000 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q20.sql new file mode 100644 index 00000000..7983b241 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Shoes', 'Music', 'Home') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-01-25' as date) + and (cast('2000-01-25' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q21.sql new file mode 100644 index 00000000..0989511c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-06-20' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2000-06-20' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2000-06-20' as date) - INTERVAL '30' DAY) + and (cast ('2000-06-20' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q22.sql new file mode 100644 index 00000000..3f63a47c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1204 and 1204 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q23.sql new file mode 100644 index 00000000..a191a247 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q24.sql new file mode 100644 index 00000000..0f3f63e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'firebrick' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 8 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'indian' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q25.sql new file mode 100644 index 00000000..121161f5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,sum(ss_net_profit) as store_sales_profit + ,sum(sr_net_loss) as store_returns_loss + ,sum(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q26.sql new file mode 100644 index 00000000..ebd1932a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'Advanced Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q27.sql new file mode 100644 index 00000000..076b6254 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'U' and + cd_education_status = '4 yr Degree' and + d_year = 2000 and + s_state in ('VT','LA', 'WV', 'KS', 'MI', 'MO') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q28.sql new file mode 100644 index 00000000..03fbee6d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 183 and 183+10 + or ss_coupon_amt between 3614 and 3614+1000 + or ss_wholesale_cost between 12 and 12+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 47 and 47+10 + or ss_coupon_amt between 4566 and 4566+1000 + or ss_wholesale_cost between 0 and 0+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 120 and 120+10 + or ss_coupon_amt between 15450 and 15450+1000 + or ss_wholesale_cost between 70 and 70+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 8 and 8+10 + or ss_coupon_amt between 16948 and 16948+1000 + or ss_wholesale_cost between 66 and 66+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 77 and 77+10 + or ss_coupon_amt between 8258 and 8258+1000 + or ss_wholesale_cost between 39 and 39+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 59 and 59+10 + or ss_coupon_amt between 7973 and 7973+1000 + or ss_wholesale_cost between 38 and 38+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q29.sql new file mode 100644 index 00000000..d5ade587 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_quantity) as store_sales_quantity + ,avg(sr_return_quantity) as store_returns_quantity + ,avg(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q30.sql new file mode 100644 index 00000000..a9324c41 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'KS' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q31.sql new file mode 100644 index 00000000..d626b369 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2002 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2002 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2002 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2002 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2002 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2002 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q32.sql new file mode 100644 index 00000000..b42aa55f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 911 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-02-26' and + (cast('2002-02-26' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-02-26' and + (cast('2002-02-26' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q33.sql new file mode 100644 index 00000000..0c662156 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q34.sql new file mode 100644 index 00000000..6d341586 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Quay County','Williamson County','Perry County','Cocke County', + 'Oglethorpe County','Luce County','Stillwater County','Jackson County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q35.sql new file mode 100644 index 00000000..bfe4adec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + max(cd_dep_count) aggtwo1, + sum(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + max(cd_dep_employed_count) aggtwo2, + sum(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + max(cd_dep_college_count) aggtwo3, + sum(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q36.sql new file mode 100644 index 00000000..29f58f4a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('LA','NY','WV','AL', + 'WA','MI','VT','OK') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q37.sql new file mode 100644 index 00000000..28c01f43 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 40 and 40 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-02-14' as date) and (cast('1999-02-14' as date) + INTERVAL '60' DAY) + and i_manufact_id in (709,715,738,859) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q38.sql new file mode 100644 index 00000000..3bb8101b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1219 and 1219 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q39.sql new file mode 100644 index 00000000..f5eb21cc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1999 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q40.sql new file mode 100644 index 00000000..101e723a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-03-21' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2002-03-21' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2002-03-21' as date) - INTERVAL '30' DAY) + and (cast ('2002-03-21' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q41.sql new file mode 100644 index 00000000..b3d3749f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 764 and 764+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'lawn' or i_color = 'blue') and + (i_units = 'Carton' or i_units = 'Unknown') and + (i_size = 'extra large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'beige' or i_color = 'orange') and + (i_units = 'Each' or i_units = 'Gross') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'brown' or i_color = 'medium') and + (i_units = 'Pallet' or i_units = 'Dram') and + (i_size = 'economy' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'plum' or i_color = 'burnished') and + (i_units = 'N/A' or i_units = 'Tbl') and + (i_size = 'extra large' or i_size = 'N/A') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'lace' or i_color = 'slate') and + (i_units = 'Ton' or i_units = 'Ounce') and + (i_size = 'extra large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'rose' or i_color = 'thistle') and + (i_units = 'Bundle' or i_units = 'Case') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'navy' or i_color = 'navajo') and + (i_units = 'Lb' or i_units = 'Cup') and + (i_size = 'economy' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'cyan' or i_color = 'floral') and + (i_units = 'Tsp' or i_units = 'Oz') and + (i_size = 'extra large' or i_size = 'N/A') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q42.sql new file mode 100644 index 00000000..b1fd1a46 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q43.sql new file mode 100644 index 00000000..68b895bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 1999 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q44.sql new file mode 100644 index 00000000..8b714202 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 39 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 39 + and ss_hdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 39 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 39 + and ss_hdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q45.sql new file mode 100644 index 00000000..d9f799e0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2002 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q46.sql new file mode 100644 index 00000000..1285a1dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 0 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Woodlawn','Buffalo','Pleasant Hill','White Oak','Needmore') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q47.sql new file mode 100644 index 00000000..4a6d94d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q48.sql new file mode 100644 index 00000000..a6d2243e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2000 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IL', 'NC', 'GA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('OH', 'CO', 'TN') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('SD', 'MI', 'CA') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q49.sql new file mode 100644 index 00000000..18d66524 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q50.sql new file mode 100644 index 00000000..fab3d4bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q51.sql new file mode 100644 index 00000000..a971a791 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1176 and 1176+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1176 and 1176+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q52.sql new file mode 100644 index 00000000..0dba5848 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1999 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q53.sql new file mode 100644 index 00000000..caa3572e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1186,1186+1,1186+2,1186+3,1186+4,1186+5,1186+6,1186+7,1186+8,1186+9,1186+10,1186+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q54.sql new file mode 100644 index 00000000..8c5fb16a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Books' + and i_class = 'travel' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 3 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 3) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 3) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q55.sql new file mode 100644 index 00000000..81196c3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=14 + and d_moy=11 + and d_year=2000 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q56.sql new file mode 100644 index 00000000..2ba02e18 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('medium','salmon','sky')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('medium','salmon','sky')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('medium','salmon','sky')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q57.sql new file mode 100644 index 00000000..b45c2dbc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q58.sql new file mode 100644 index 00000000..b8458609 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-01-26')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-01-26')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2001-01-26')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q59.sql new file mode 100644 index 00000000..0f4449e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1209 and 1209 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1209+ 12 and 1209 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q60.sql new file mode 100644 index 00000000..171254af --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 8 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 8 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 8 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q61.sql new file mode 100644 index 00000000..fded4005 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 2000 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and s_gmt_offset = -6 + and d_year = 2000 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q62.sql new file mode 100644 index 00000000..eb6408e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1197 and 1197 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q63.sql new file mode 100644 index 00000000..ca80e8c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q64.sql new file mode 100644 index 00000000..05491755 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('pink','misty','rosy','powder','plum','rose') and + i_current_price between 29 and 29 + 10 and + i_current_price between 29 + 1 and 29 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q65.sql new file mode 100644 index 00000000..0a0e8d3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1192 and 1192+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1192 and 1192+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q66.sql new file mode 100644 index 00000000..ca3b942a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'BOXBUNDLES' || ',' || 'ORIENTAL' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 11467 and 11467+28800 + and sm_carrier in ('BOXBUNDLES','ORIENTAL') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'BOXBUNDLES' || ',' || 'ORIENTAL' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 11467 AND 11467+28800 + and sm_carrier in ('BOXBUNDLES','ORIENTAL') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q67.sql new file mode 100644 index 00000000..7b1d2ee2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1211 and 1211+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q68.sql new file mode 100644 index 00000000..7106add1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Watson','Mount Olive') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q69.sql new file mode 100644 index 00000000..e8cfc0b5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('NE','VA','IA') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q70.sql new file mode 100644 index 00000000..18fb1aad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1210 and 1210+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1210 and 1210+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q72.sql new file mode 100644 index 00000000..c1e61aef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 2000 + and cd_marital_status = 'W' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q73.sql new file mode 100644 index 00000000..defbe59e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Klamath County','Karnes County','Wilkinson County','Dauphin County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q74.sql new file mode 100644 index 00000000..e499928c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,stddev_samp(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,1,2 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q75.sql new file mode 100644 index 00000000..4668adfd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Books' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Books' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Books') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q76.sql new file mode 100644 index 00000000..80971281 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_store_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_store_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_promo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_promo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q77.sql new file mode 100644 index 00000000..234c2ced --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-22' as date) + and (cast('1998-08-22' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q78.sql new file mode 100644 index 00000000..963a8299 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2000 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q79.sql new file mode 100644 index 00000000..190485e7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > 2) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q80.sql new file mode 100644 index 00000000..651b2975 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-07' as date) + and (cast('2000-08-07' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q81.sql new file mode 100644 index 00000000..5a67dd7a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'GA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q82.sql new file mode 100644 index 00000000..9b2c2c4d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 76 and 76+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-02-22' as date) and (cast('2001-02-22' as date) + INTERVAL '60' DAY) + and i_manufact_id in (529,752,887,794) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q83.sql new file mode 100644 index 00000000..17117b5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-27',DATE '2002-10-12',DATE '2002-11-09'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-27',DATE '2002-10-12',DATE '2002-11-09'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2002-03-27',DATE '2002-10-12',DATE '2002-11-09'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q84.sql new file mode 100644 index 00000000..2338c98e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Lakewood' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 58563 + and ib_upper_bound <= 58563 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q85.sql new file mode 100644 index 00000000..75b52f2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2001 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('WA', 'KY', 'VA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('FL', 'TX', 'TN') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('AK', 'IN', 'LA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q86.sql new file mode 100644 index 00000000..431b3d18 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1190 and 1190+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q87.sql new file mode 100644 index 00000000..7ece68a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1222 and 1222+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1222 and 1222+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1222 and 1222+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q88.sql new file mode 100644 index 00000000..16498b7e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q89.sql new file mode 100644 index 00000000..a22e30fd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (1998) and + ((i_category in ('Music','Sports','Electronics') and + i_class in ('country','sailing','camcorders') + ) + or (i_category in ('Home','Jewelry','Shoes') and + i_class in ('paint','gold','kids') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q90.sql new file mode 100644 index 00000000..18ea927e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 6 and 6+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 20 and 20+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q91.sql new file mode 100644 index 00000000..5cc75329 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2001 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '5001-10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q92.sql new file mode 100644 index 00000000..2075ee20 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 938 +and i_item_sk = ws_item_sk +and d_date between DATE '2000-01-06' and + (cast('2000-01-06' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2000-01-06' and + (cast('2000-01-06' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q93.sql new file mode 100644 index 00000000..65af8bcd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'Found a better extended warranty in a store') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q94.sql new file mode 100644 index 00000000..d187a6f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-2-01' and + (cast('2000-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'VA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q95.sql new file mode 100644 index 00000000..d877268d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-4-01' and + (cast('2000-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'MS' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q96.sql new file mode 100644 index 00000000..f3df595b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 6 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q97.sql new file mode 100644 index 00000000..284d31ff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1184 and 1184 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1184 and 1184 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q98.sql new file mode 100644 index 00000000..79e02b26 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Women', 'Music', 'Books') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2000-04-04' as date) + and (cast('2000-04-04' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s20/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s20/q99.sql new file mode 100644 index 00000000..42125c22 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s20/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1215 and 1215 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q01.sql new file mode 100644 index 00000000..7654b7c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REVERSED_CHARGE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NM' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q02.sql new file mode 100644 index 00000000..a3aaa0b9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q03.sql new file mode 100644 index 00000000..e4864574 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 569 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q04.sql new file mode 100644 index 00000000..8f3deaa2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_c_firstyear.dyear = 2001 + and t_c_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q05.sql new file mode 100644 index 00000000..0bd6714e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-17' as date) + and (cast('2001-08-17' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q06.sql new file mode 100644 index 00000000..8ca7caac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 1998 + and d_moy = 3 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q07.sql new file mode 100644 index 00000000..4a0d0bf2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q08.sql new file mode 100644 index 00000000..0f0ba2f5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '19286','12261','59853','40188','65084','14513', + '99073','59654','30298','91378','86597', + '32371','97087','21191','92929','14923', + '22640','60782','14463','47104','73462', + '81126','39608','60297','90609','13571', + '34330','67430','69713','66367','99635', + '19743','66642','15380','45150','58819', + '75521','52639','44379','45521','14512', + '52545','87696','59664','34385','58032', + '41553','57295','97745','76338','41887', + '47756','41753','18670','82374','82428', + '53513','25541','10628','84648','33098', + '92116','85897','17979','54446','59819', + '64300','50568','48305','92303','74138', + '89008','90619','50858','23925','59037', + '71616','63835','67876','57922','74529', + '75060','71965','10709','91806','89664', + '17731','28806','22831','14511','60493', + '12597','45461','39901','99997','18788', + '92485','15086','43390','89341','78756', + '99663','80361','18297','73016','73097', + '26679','48106','96317','87905','99448', + '88804','59773','78167','82864','71094', + '24600','72809','73351','42643','80005', + '42065','39757','41808','91988','82068', + '82370','72189','35011','50389','92690', + '16310','34450','45835','64060','15464', + '33376','21160','67418','96185','31366', + '66793','33905','80398','46624','84909', + '44447','41201','68769','44261','12999', + '76350','14279','22418','97334','85592', + '32768','30645','97900','41738','75739', + '93887','18111','60285','20704','26268', + '34022','48742','84860','19195','11531', + '38371','25881','18002','92882','68197', + '57840','52712','53656','94306','98510', + '77352','65688','90527','60524','49141', + '61944','67048','86800','27527','75613', + '18728','11436','94237','49834','98599', + '29853','63401','96696','96900','58350', + '42501','23840','78716','82467','47892', + '83964','66812','35800','71103','14118', + '60161','45734','40321','73558','98615', + '68691','58577','83746','94215','52644', + '35546','51199','44220','74914','40666', + '65824','29619','58562','47303','84450', + '66485','77677','59317','60637','88186', + '87770','94788','37804','15398','83362', + '47656','19796','74239','53455','48292', + '56630','96688','98418','30834','91377', + '44834','22694','17624','81274','89251', + '15391','52856','41445','91637','50303', + '42010','34882','25356','75735','37518', + '15056','56360','37397','91307','92032', + '71723','30400','35655','53562','10452', + '94947','73229','49412','95398','89647', + '31127','65071','86525','32347','33778', + '92208','74907','90653','19199','97853', + '41441','94116','98165','25287','45464', + '75884','12388','63905','94040','16808', + '21921','24144','60307','83710','25955', + '71421','10472','12878','99493','11399', + '81186','11707','66888','67253','55182', + '50528','28704','72912','30587','55210', + '36001','66342','92429','71031','12333', + '61553','95540','43795','74486','27741', + '40772','38081','67818','80822','68072', + '82226','83378','39288','93714','59573', + '54705','65190','20243','96072','63223', + '36093','52025','53109','94208','45033', + '86758','25445','97536','31807','32077', + '53483','81066','54632','89683','77331', + '77465','87589','27806','91593','87442', + '34091','45817','24716','47929','49186', + '76629','71533','22064','40874','15193', + '52107','22513','60481','52243','67772', + '20238','43245','83057','56815','53714', + '90702','58201','21131','51489','69804', + '87716','46527','95832','97337','66327', + '44643','43600','99044','57340') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1998 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q09.sql new file mode 100644 index 00000000..0b38316b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 184075333 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 13465026 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 395667954 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 226926736 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 31972642 + then (select avg(ss_ext_sales_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q10.sql new file mode 100644 index 00000000..f7386e7b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('San Juan County','Barnwell County','Palo Alto County','Lycoming County','Pearl River County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 1 and 1+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 1 ANd 1+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 1 and 1+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q11.sql new file mode 100644 index 00000000..bc470b14 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q12.sql new file mode 100644 index 00000000..a78de4b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Men', 'Home', 'Women') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2002-04-05' as date) + and (cast('2002-04-05' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q13.sql new file mode 100644 index 00000000..60f48bd4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Primary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MI', 'NC', 'NY') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TN', 'SC', 'MT') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'ID', 'AR') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q14.sql new file mode 100644 index 00000000..3fbbd59b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 27) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 27) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q15.sql new file mode 100644 index 00000000..39e90be8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q16.sql new file mode 100644 index 00000000..0e19e449 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2002-4-01' and + (cast('2002-4-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'NE' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Levy County','Marshall County','Bronx County','Kittitas County', + 'Daviess County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q17.sql new file mode 100644 index 00000000..ad997218 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2002Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2002Q1','2002Q2','2002Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2002Q1','2002Q2','2002Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q18.sql new file mode 100644 index 00000000..3ac4b3c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (9,2,7,10,5,6) and + d_year = 2001 and + ca_state in ('ND','TX','CO' + ,'NY','KY','MT','VA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q19.sql new file mode 100644 index 00000000..70211f65 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=58 + and d_moy=12 + and d_year=2000 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q20.sql new file mode 100644 index 00000000..c12026a0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Women', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2001-06-29' as date) + and (cast('2001-06-29' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q21.sql new file mode 100644 index 00000000..daea3edc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-02-03' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2002-02-03' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2002-02-03' as date) - INTERVAL '30' DAY) + and (cast ('2002-02-03' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q22.sql new file mode 100644 index 00000000..ce0667ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1187 and 1187 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q23.sql new file mode 100644 index 00000000..542523d9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 6 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 6 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 6 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 6 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q24.sql new file mode 100644 index 00000000..d0e5eeb6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'peach' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'dark' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q25.sql new file mode 100644 index 00000000..9d4d5fd5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_net_profit) as store_sales_profit + ,min(sr_net_loss) as store_returns_loss + ,min(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q26.sql new file mode 100644 index 00000000..e9af1b5e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q27.sql new file mode 100644 index 00000000..4512fbf3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'U' and + cd_education_status = 'Unknown' and + d_year = 2002 and + s_state in ('MN','NE', 'SD', 'TX', 'IL', 'GA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q28.sql new file mode 100644 index 00000000..17520c04 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 118 and 118+10 + or ss_coupon_amt between 11437 and 11437+1000 + or ss_wholesale_cost between 2 and 2+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 77 and 77+10 + or ss_coupon_amt between 17043 and 17043+1000 + or ss_wholesale_cost between 80 and 80+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 169 and 169+10 + or ss_coupon_amt between 10013 and 10013+1000 + or ss_wholesale_cost between 73 and 73+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 146 and 146+10 + or ss_coupon_amt between 15632 and 15632+1000 + or ss_wholesale_cost between 38 and 38+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 14 and 14+10 + or ss_coupon_amt between 10180 and 10180+1000 + or ss_wholesale_cost between 33 and 33+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 91 and 91+10 + or ss_coupon_amt between 3394 and 3394+1000 + or ss_wholesale_cost between 40 and 40+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q29.sql new file mode 100644 index 00000000..59118672 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q30.sql new file mode 100644 index 00000000..9865e444 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =1999 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'GA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q31.sql new file mode 100644 index 00000000..c1bc77aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q32.sql new file mode 100644 index 00000000..48448b77 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 442 +and i_item_sk = cs_item_sk +and d_date between DATE '2001-03-22' and + (cast('2001-03-22' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2001-03-22' and + (cast('2001-03-22' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q33.sql new file mode 100644 index 00000000..800a96cd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Electronics')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q34.sql new file mode 100644 index 00000000..feaca42f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Raleigh County','Somerset County','Ziebach County','Jackson County', + 'Salem County','Wadena County','Harper County','Carter County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q35.sql new file mode 100644 index 00000000..8d594494 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + min(cd_dep_count) aggtwo1, + max(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + min(cd_dep_employed_count) aggtwo2, + max(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + min(cd_dep_college_count) aggtwo3, + max(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q36.sql new file mode 100644 index 00000000..82333808 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('PA','SD','FL','TN', + 'NM','MI','OK','MO') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q37.sql new file mode 100644 index 00000000..fd4d1d1e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 62 and 62 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-07-11' as date) and (cast('2002-07-11' as date) + INTERVAL '60' DAY) + and i_manufact_id in (840,759,843,838) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q38.sql new file mode 100644 index 00000000..5003c143 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q39.sql new file mode 100644 index 00000000..6d3b999a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q40.sql new file mode 100644 index 00000000..fb0159b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-06-16' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-06-16' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-06-16' as date) - INTERVAL '30' DAY) + and (cast ('2001-06-16' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q41.sql new file mode 100644 index 00000000..ac3a37a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 858 and 858+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'antique' or i_color = 'purple') and + (i_units = 'Tbl' or i_units = 'Oz') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'magenta' or i_color = 'lemon') and + (i_units = 'Cup' or i_units = 'Case') and + (i_size = 'N/A' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'floral' or i_color = 'gainsboro') and + (i_units = 'Bundle' or i_units = 'Each') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'chartreuse' or i_color = 'blush') and + (i_units = 'Pallet' or i_units = 'Carton') and + (i_size = 'economy' or i_size = 'small') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'steel' or i_color = 'black') and + (i_units = 'Gram' or i_units = 'Dram') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'navajo' or i_color = 'sky') and + (i_units = 'Gross' or i_units = 'Lb') and + (i_size = 'N/A' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'azure' or i_color = 'drab') and + (i_units = 'Ounce' or i_units = 'Unknown') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'puff' or i_color = 'lawn') and + (i_units = 'Box' or i_units = 'Tsp') and + (i_size = 'economy' or i_size = 'small') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q42.sql new file mode 100644 index 00000000..13d30602 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q43.sql new file mode 100644 index 00000000..c902291e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 1999 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q44.sql new file mode 100644 index 00000000..ca15b39f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 416 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 416 + and ss_cdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 416 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 416 + and ss_cdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q45.sql new file mode 100644 index 00000000..9896ee79 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q46.sql new file mode 100644 index 00000000..00cd2c5a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 7 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Sulphur Springs','Bethel','Midway','Woodlawn','Antioch') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q47.sql new file mode 100644 index 00000000..890847eb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q48.sql new file mode 100644 index 00000000..f698c67e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1998 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'College' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'CO', 'IL') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('WV', 'WI', 'MD') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('AL', 'GA', 'OH') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q49.sql new file mode 100644 index 00000000..baab828a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q50.sql new file mode 100644 index 00000000..de2392e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 9 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q51.sql new file mode 100644 index 00000000..2502bdfa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q52.sql new file mode 100644 index 00000000..a3c8cccf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2001 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q53.sql new file mode 100644 index 00000000..065c0d36 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1224,1224+1,1224+2,1224+3,1224+4,1224+5,1224+6,1224+7,1224+8,1224+9,1224+10,1224+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q54.sql new file mode 100644 index 00000000..f4542ee1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Women' + and i_class = 'swimwear' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 4 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 4) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 4) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q55.sql new file mode 100644 index 00000000..e8213d10 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=6 + and d_moy=12 + and d_year=2001 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q56.sql new file mode 100644 index 00000000..0489fe2d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('violet','pink','peach')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('violet','pink','peach')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('violet','pink','peach')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 5 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q57.sql new file mode 100644 index 00000000..85dfd34b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q58.sql new file mode 100644 index 00000000..d5653eca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-03-08')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2001-03-08')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2001-03-08')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q59.sql new file mode 100644 index 00000000..b9b9771e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1192 and 1192 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1192+ 12 and 1192 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q60.sql new file mode 100644 index 00000000..73750612 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q61.sql new file mode 100644 index 00000000..17c7b06a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Electronics' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Electronics' + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q62.sql new file mode 100644 index 00000000..23e9e4c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1180 and 1180 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q63.sql new file mode 100644 index 00000000..2cbda088 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1192,1192+1,1192+2,1192+3,1192+4,1192+5,1192+6,1192+7,1192+8,1192+9,1192+10,1192+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q64.sql new file mode 100644 index 00000000..e5598e78 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('dim','deep','navy','burlywood','violet','pink') and + i_current_price between 47 and 47 + 10 and + i_current_price between 47 + 1 and 47 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2001 and + cs2.syear = 2001 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q65.sql new file mode 100644 index 00000000..6937e673 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1184 and 1184+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1184 and 1184+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q66.sql new file mode 100644 index 00000000..b2179ba2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'LATVIAN' || ',' || 'USPS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 4728 and 4728+28800 + and sm_carrier in ('LATVIAN','USPS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'LATVIAN' || ',' || 'USPS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 4728 AND 4728+28800 + and sm_carrier in ('LATVIAN','USPS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q67.sql new file mode 100644 index 00000000..325b9320 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1223 and 1223+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q68.sql new file mode 100644 index 00000000..cebbfd18 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Deerfield','Four Corners') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q69.sql new file mode 100644 index 00000000..fda5c991 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('VA','SC','TX') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 3 and 3+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q70.sql new file mode 100644 index 00000000..caf88961 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1218 and 1218+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1218 and 1218+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q71.sql new file mode 100644 index 00000000..b547ac16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q72.sql new file mode 100644 index 00000000..71f9d245 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 1999 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q73.sql new file mode 100644 index 00000000..124e0280 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Surry County','Salem County','Barrow County','Jackson County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q74.sql new file mode 100644 index 00000000..4d027d64 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,2,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q75.sql new file mode 100644 index 00000000..057f2c58 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Jewelry') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q76.sql new file mode 100644 index 00000000..6d00e802 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_store_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_store_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_cdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_cdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q77.sql new file mode 100644 index 00000000..cc6fdd3a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-09' as date) + and (cast('1998-08-09' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q78.sql new file mode 100644 index 00000000..ce76b3a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_item_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1998 +order by + ss_item_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q79.sql new file mode 100644 index 00000000..efe3c39e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 0 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q80.sql new file mode 100644 index 00000000..5e8d3d30 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-11' as date) + and (cast('1998-08-11' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-11' as date) + and (cast('1998-08-11' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-11' as date) + and (cast('1998-08-11' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q81.sql new file mode 100644 index 00000000..37b805a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =1999 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'KS' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q82.sql new file mode 100644 index 00000000..363ed98a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 71 and 71+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-01-03' as date) and (cast('2001-01-03' as date) + INTERVAL '60' DAY) + and i_manufact_id in (344,476,15,981) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q83.sql new file mode 100644 index 00000000..3deccbe5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-10',DATE '1999-09-25',DATE '1999-11-22'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-10',DATE '1999-09-25',DATE '1999-11-22'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-03-10',DATE '1999-09-25',DATE '1999-11-22'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q84.sql new file mode 100644 index 00000000..e21b2767 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Pleasant Grove' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 40576 + and ib_upper_bound <= 40576 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q85.sql new file mode 100644 index 00000000..4ccd7867 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2000 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('MI', 'IL', 'ME') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('SD', 'WI', 'FL') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('GA', 'WV', 'MO') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q86.sql new file mode 100644 index 00000000..62513266 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1176 and 1176+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q87.sql new file mode 100644 index 00000000..3f1a8570 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q88.sql new file mode 100644 index 00000000..08930bad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q89.sql new file mode 100644 index 00000000..c850fbcb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Home','Sports','Women') and + i_class in ('glassware','sailing','maternity') + ) + or (i_category in ('Music','Books','Men') and + i_class in ('country','home repair','sports-apparel') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q90.sql new file mode 100644 index 00000000..d50b5227 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 9 and 9+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 13 and 13+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q91.sql new file mode 100644 index 00000000..24c8f4d6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '5001-10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q92.sql new file mode 100644 index 00000000..e0d13460 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 870 +and i_item_sk = ws_item_sk +and d_date between DATE '2002-01-19' and + (cast('2002-01-19' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2002-01-19' and + (cast('2002-01-19' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q93.sql new file mode 100644 index 00000000..997a1634 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 51') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q94.sql new file mode 100644 index 00000000..62476ae9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-2-01' and + (cast('2001-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q95.sql new file mode 100644 index 00000000..3a3addd7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-5-01' and + (cast('1999-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'FL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q96.sql new file mode 100644 index 00000000..76c77a9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 3 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q97.sql new file mode 100644 index 00000000..e9ad0526 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1196 and 1196 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1196 and 1196 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q98.sql new file mode 100644 index 00000000..ae787f9c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Music', 'Electronics', 'Home') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2002-02-01' as date) + and (cast('2002-02-01' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s3/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s3/q99.sql new file mode 100644 index 00000000..2d019595 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s3/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1223 and 1223 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q01.sql new file mode 100644 index 00000000..e071fd87 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REVERSED_CHARGE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'LA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q03.sql new file mode 100644 index 00000000..fad6d110 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_net_profit) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 843 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q04.sql new file mode 100644 index 00000000..4742fec1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q05.sql new file mode 100644 index 00000000..1737c41c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1998-08-27' as date) + and (cast('1998-08-27' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q06.sql new file mode 100644 index 00000000..a96453f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2000 + and d_moy = 1 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q07.sql new file mode 100644 index 00000000..fa7665bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'D' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q08.sql new file mode 100644 index 00000000..359da2a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '22464','81515','96597','37639','98332','39012', + '68267','23488','91033','17741','86639', + '92952','25838','69885','96189','44697', + '82077','78942','18142','84615','39052', + '78472','29500','14952','34763','26363', + '90971','80912','44961','13353','12853', + '54028','45371','65761','91173','98730', + '51632','65256','44494','62420','96387', + '61364','62608','81810','44376','78614', + '34882','27034','74269','35435','15027', + '65534','79316','14817','66088','50436', + '14247','19896','50624','15512','62233', + '96989','71174','50051','81648','96893', + '73752','12372','32241','37478','47016', + '39283','79235','89512','33388','69199', + '10534','15059','96081','78012','41761', + '36266','29906','79934','96066','71817', + '75515','62876','16787','99273','81011', + '54862','87871','11156','34934','85932', + '36264','64276','62192','99405','85091', + '41505','83423','47122','31835','12398', + '58381','18023','35670','49244','13934', + '77601','96595','72631','95350','13460', + '87670','15335','89067','99376','72443', + '43835','76680','86354','25496','95211', + '11936','34526','43409','50588','82934', + '63443','57565','64894','56922','45968', + '17427','55192','11062','91128','93266', + '85502','64911','83092','27823','58603', + '44153','43659','32300','24383','50567', + '85244','47635','79916','47605','42292', + '85073','53583','11228','14904','13006', + '74488','97569','67075','57222','20817', + '46109','43668','81359','54922','31409', + '85567','82974','58237','51604','10570', + '62037','20636','50137','58180','40302', + '23425','82333','66557','72041','54506', + '59706','91029','55798','69498','94953', + '97504','19646','99807','54953','16860', + '38884','77784','62441','52471','61194', + '84816','33075','90672','29218','22633', + '45220','88355','32693','43828','42561', + '51260','51280','57236','91724','33838', + '74058','22352','85314','35975','30070', + '29689','53378','29094','72240','86683', + '87636','24365','75471','39370','79997', + '68856','21480','64047','47677','16542', + '47242','79992','78593','45689','50087', + '48516','59780','42583','22556','18085', + '78777','31294','46145','71718','90924', + '80297','54677','33111','55706','83365', + '80276','16754','39729','44922','34242', + '49642','23011','22458','93808','42799', + '64177','41024','27313','81460','36957', + '36783','61640','90421','50331','29646', + '62946','68553','29308','34413','77944', + '25923','60058','25397','33409','14125', + '79954','80555','20565','10602','82317', + '80881','57873','25334','25610','25882', + '74184','78691','94208','74582','54256', + '55740','23121','41351','73992','91360', + '68817','57963','73551','12017','21355', + '29200','26848','14310','37996','36856', + '43015','22411','82585','46018','22467', + '68464','41734','86340','80577','90321', + '39434','64785','99199','70568','32754', + '50999','41832','52554','71444','56144', + '47089','29908','62683','68966','90440', + '78935','59029','35242','69443','14870', + '96413','43669','65548','22828','10646', + '67689','68657','27813','40341','87545', + '73924','93222','83196','86404','29875', + '70615','74034','65591','55799','65922', + '86714','43298','38294','14796','56120', + '51619','23220','91734','15987','58936', + '93338','54965','19980','39549','83740', + '29257','69987','27546','81879','26676', + '30489','88186','24453','11811','57185', + '69557','92066','37877','22427','38217', + '34898','26939','27381','75256') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q09.sql new file mode 100644 index 00000000..8bf42e41 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 335766277 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 392537569 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 323359326 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 354052543 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 422318194 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q10.sql new file mode 100644 index 00000000..ad79b58f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Wayne County','Clermont County','Pierce County','Mercer County','Amite County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q11.sql new file mode 100644 index 00000000..84700d05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q12.sql new file mode 100644 index 00000000..c0a09df8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Electronics', 'Men', 'Women') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1998-04-08' as date) + and (cast('1998-04-08' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q13.sql new file mode 100644 index 00000000..9bf36c56 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'S' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Primary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NY', 'ID', 'VA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('PA', 'IN', 'NM') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TN', 'TX', 'WI') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q14.sql new file mode 100644 index 00000000..f156f0d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 12) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 12) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q15.sql new file mode 100644 index 00000000..2718b3ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q16.sql new file mode 100644 index 00000000..6444043a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-3-01' and + (cast('1999-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'MS' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Maverick County','Jefferson Davis Parish','Mobile County','Oglethorpe County', + 'Gogebic County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q18.sql new file mode 100644 index 00000000..34bda7f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Secondary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (3,1,7,5,6,12) and + d_year = 1999 and + ca_state in ('FL','AL','VA' + ,'AR','WV','PA','KS') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q19.sql new file mode 100644 index 00000000..8172fe49 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=27 + and d_moy=11 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q20.sql new file mode 100644 index 00000000..4532ea91 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Women', 'Music', 'Men') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-05-03' as date) + and (cast('2000-05-03' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q21.sql new file mode 100644 index 00000000..97c557a6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-04-04' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2000-04-04' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2000-04-04' as date) - INTERVAL '30' DAY) + and (cast ('2000-04-04' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q22.sql new file mode 100644 index 00000000..ed66b9b1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1194 and 1194 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q23.sql new file mode 100644 index 00000000..9053732f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 2 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 2 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q24.sql new file mode 100644 index 00000000..08f508e5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'burlywood' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'cyan' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q25.sql new file mode 100644 index 00000000..bdd0ee82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2001 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2001 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q26.sql new file mode 100644 index 00000000..7a9a5e8f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'U' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q27.sql new file mode 100644 index 00000000..8f731860 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'F' and + cd_marital_status = 'M' and + cd_education_status = 'Secondary' and + d_year = 2000 and + s_state in ('MI','NE', 'PA', 'AL', 'KS', 'SD') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q28.sql new file mode 100644 index 00000000..4ad897f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 114 and 114+10 + or ss_coupon_amt between 9239 and 9239+1000 + or ss_wholesale_cost between 52 and 52+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 127 and 127+10 + or ss_coupon_amt between 3635 and 3635+1000 + or ss_wholesale_cost between 40 and 40+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 63 and 63+10 + or ss_coupon_amt between 8302 and 8302+1000 + or ss_wholesale_cost between 19 and 19+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 68 and 68+10 + or ss_coupon_amt between 1844 and 1844+1000 + or ss_wholesale_cost between 45 and 45+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 175 and 175+10 + or ss_coupon_amt between 16760 and 16760+1000 + or ss_wholesale_cost between 47 and 47+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 133 and 133+10 + or ss_coupon_amt between 1515 and 1515+1000 + or ss_wholesale_cost between 73 and 73+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q29.sql new file mode 100644 index 00000000..19990d42 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_quantity) as store_sales_quantity + ,min(sr_return_quantity) as store_returns_quantity + ,min(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q30.sql new file mode 100644 index 00000000..dd7c7742 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q31.sql new file mode 100644 index 00000000..325746a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2001 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2001 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2001 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2001 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2001 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2001 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by web_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q32.sql new file mode 100644 index 00000000..dbfa21e8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 680 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-03-28' and + (cast('2002-03-28' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-03-28' and + (cast('2002-03-28' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q33.sql new file mode 100644 index 00000000..1d05889c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q34.sql new file mode 100644 index 00000000..fc409f0b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Essex County','Salem County','Luce County','Huron County', + 'Pennington County','Chambers County','Adams County','Red River Parish') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q35.sql new file mode 100644 index 00000000..43a922fd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + max(cd_dep_count) aggone1, + avg(cd_dep_count) aggtwo1, + stddev_samp(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + max(cd_dep_employed_count) aggone2, + avg(cd_dep_employed_count) aggtwo2, + stddev_samp(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + max(cd_dep_college_count) aggone3, + avg(cd_dep_college_count) aggtwo3, + stddev_samp(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q36.sql new file mode 100644 index 00000000..4df7e53a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('IN','TN','NE','MI', + 'SD','AL','SC','OH') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q37.sql new file mode 100644 index 00000000..604e478b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 66 and 66 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-07-02' as date) and (cast('2001-07-02' as date) + INTERVAL '60' DAY) + and i_manufact_id in (979,963,827,860) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q38.sql new file mode 100644 index 00000000..0f1ccc93 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1176 and 1176 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1176 and 1176 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1176 and 1176 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q39.sql new file mode 100644 index 00000000..41924652 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q40.sql new file mode 100644 index 00000000..886ef74a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-06-30' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1999-06-30' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1999-06-30' as date) - INTERVAL '30' DAY) + and (cast ('1999-06-30' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q41.sql new file mode 100644 index 00000000..a37bb835 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 901 and 901+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'salmon' or i_color = 'dark') and + (i_units = 'Tsp' or i_units = 'Cup') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'moccasin' or i_color = 'midnight') and + (i_units = 'Box' or i_units = 'Pallet') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'seashell' or i_color = 'lawn') and + (i_units = 'Bunch' or i_units = 'Dram') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'burnished' or i_color = 'yellow') and + (i_units = 'Oz' or i_units = 'Ounce') and + (i_size = 'small' or i_size = 'economy') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'mint' or i_color = 'azure') and + (i_units = 'Tbl' or i_units = 'N/A') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Women' and + (i_color = 'puff' or i_color = 'khaki') and + (i_units = 'Pound' or i_units = 'Gross') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'almond' or i_color = 'firebrick') and + (i_units = 'Each' or i_units = 'Carton') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'pale' or i_color = 'cream') and + (i_units = 'Gram' or i_units = 'Dozen') and + (i_size = 'small' or i_size = 'economy') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q42.sql new file mode 100644 index 00000000..2aa89f83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q43.sql new file mode 100644 index 00000000..ee3806a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2001 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q44.sql new file mode 100644 index 00000000..58d6a9c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 216 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 216 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 216 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 216 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q45.sql new file mode 100644 index 00000000..852c0c6d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1998 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q46.sql new file mode 100644 index 00000000..f9295dc3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 5 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Eureka','Georgetown','Pleasant View','Manchester','Belmont') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q47.sql new file mode 100644 index 00000000..cd205a3f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q48.sql new file mode 100644 index 00000000..88b35a9a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2002 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'College' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'AL', 'SD') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MO', 'OH', 'WV') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MA', 'PA', 'KS') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q49.sql new file mode 100644 index 00000000..18d66524 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q50.sql new file mode 100644 index 00000000..7fa6ff78 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 9 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q51.sql new file mode 100644 index 00000000..c860644a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1196 and 1196+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1196 and 1196+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q52.sql new file mode 100644 index 00000000..7d81431b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2002 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q53.sql new file mode 100644 index 00000000..065c0d36 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1224,1224+1,1224+2,1224+3,1224+4,1224+5,1224+6,1224+7,1224+8,1224+9,1224+10,1224+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q54.sql new file mode 100644 index 00000000..b481c49c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Sports' + and i_class = 'fishing' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 5 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 5) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 5) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q55.sql new file mode 100644 index 00000000..81327393 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=60 + and d_moy=12 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q56.sql new file mode 100644 index 00000000..0bd1e65a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('thistle','grey','powder')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('thistle','grey','powder')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('thistle','grey','powder')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q57.sql new file mode 100644 index 00000000..f3084ea8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 1999 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q58.sql new file mode 100644 index 00000000..2fe81065 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-05-08')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2000-05-08')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2000-05-08')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q59.sql new file mode 100644 index 00000000..f2b05300 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1187 and 1187 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1187+ 12 and 1187 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q60.sql new file mode 100644 index 00000000..2b51c6e2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Men')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q61.sql new file mode 100644 index 00000000..365f3931 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Electronics' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Electronics' + and s_gmt_offset = -6 + and d_year = 1999 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q62.sql new file mode 100644 index 00000000..fd85b929 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1193 and 1193 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q63.sql new file mode 100644 index 00000000..2e77f64b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1177,1177+1,1177+2,1177+3,1177+4,1177+5,1177+6,1177+7,1177+8,1177+9,1177+10,1177+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q64.sql new file mode 100644 index 00000000..277b7299 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('lemon','floral','chartreuse','sienna','navajo','pale') and + i_current_price between 10 and 10 + 10 and + i_current_price between 10 + 1 and 10 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q65.sql new file mode 100644 index 00000000..f310940d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1194 and 1194+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1194 and 1194+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q66.sql new file mode 100644 index 00000000..7ff85914 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'GREAT EASTERN' || ',' || 'ZHOU' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 44370 and 44370+28800 + and sm_carrier in ('GREAT EASTERN','ZHOU') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'GREAT EASTERN' || ',' || 'ZHOU' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 44370 AND 44370+28800 + and sm_carrier in ('GREAT EASTERN','ZHOU') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q67.sql new file mode 100644 index 00000000..1ccf448d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1205 and 1205+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q68.sql new file mode 100644 index 00000000..fe86c2d5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 6 or + household_demographics.hd_vehicle_count= 3) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Sherwood Forest','Pleasant Valley') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q69.sql new file mode 100644 index 00000000..26109057 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('MT','GA','OH') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q70.sql new file mode 100644 index 00000000..1d41a7f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1221 and 1221+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1221 and 1221+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q72.sql new file mode 100644 index 00000000..e8ed7ace --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 2001 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q73.sql new file mode 100644 index 00000000..049fe899 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Marshall County','Nuckolls County','Reagan County','Stillwater County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q74.sql new file mode 100644 index 00000000..63cf35bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q75.sql new file mode 100644 index 00000000..e74c5225 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Sports') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q76.sql new file mode 100644 index 00000000..bc665128 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_hdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q77.sql new file mode 100644 index 00000000..6665b71e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1999-08-05' as date) + and (cast('1999-08-05' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q78.sql new file mode 100644 index 00000000..1622ef35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q79.sql new file mode 100644 index 00000000..099ebeff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 9 or household_demographics.hd_vehicle_count > 3) + and date_dim.d_dow = 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q80.sql new file mode 100644 index 00000000..335032be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-14' as date) + and (cast('2000-08-14' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-14' as date) + and (cast('2000-08-14' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-14' as date) + and (cast('2000-08-14' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q81.sql new file mode 100644 index 00000000..48d9f8bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2000 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'OH' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q82.sql new file mode 100644 index 00000000..91ab3964 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 64 and 64+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-03-06' as date) and (cast('2002-03-06' as date) + INTERVAL '60' DAY) + and i_manufact_id in (671,884,647,797) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q83.sql new file mode 100644 index 00000000..3e2a7965 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-04-26',DATE '2000-09-27',DATE '2000-11-11'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-04-26',DATE '2000-09-27',DATE '2000-11-11'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2000-04-26',DATE '2000-09-27',DATE '2000-11-11'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q84.sql new file mode 100644 index 00000000..2ef94ff9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Pleasant Valley' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 40976 + and ib_upper_bound <= 40976 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q85.sql new file mode 100644 index 00000000..a9096ec8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('GA', 'OK', 'VA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MI', 'TX', 'CT') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('IA', 'FL', 'AR') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q86.sql new file mode 100644 index 00000000..62513266 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1176 and 1176+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q87.sql new file mode 100644 index 00000000..3f1a8570 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1183 and 1183+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q88.sql new file mode 100644 index 00000000..1028e47b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q89.sql new file mode 100644 index 00000000..adf4f0de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Shoes','Sports','Children') and + i_class in ('mens','sailing','toddlers') + ) + or (i_category in ('Home','Women','Books') and + i_class in ('kids','dresses','sports') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q90.sql new file mode 100644 index 00000000..739ae75a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 11 and 11+1 + and household_demographics.hd_dep_count = 5 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 14 and 14+1 + and household_demographics.hd_dep_count = 5 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q91.sql new file mode 100644 index 00000000..a6012ab0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 11 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '5001-10000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q92.sql new file mode 100644 index 00000000..68411557 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 211 +and i_item_sk = ws_item_sk +and d_date between DATE '2002-02-13' and + (cast('2002-02-13' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2002-02-13' and + (cast('2002-02-13' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q93.sql new file mode 100644 index 00000000..baed7623 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 73') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q94.sql new file mode 100644 index 00000000..5068955c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-3-01' and + (cast('1999-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'AR' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q95.sql new file mode 100644 index 00000000..7de60836 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-5-01' and + (cast('2001-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q96.sql new file mode 100644 index 00000000..b96d137b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 5 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q97.sql new file mode 100644 index 00000000..ae48c5b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1179 and 1179 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q98.sql new file mode 100644 index 00000000..7fab5c3d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Electronics', 'Men', 'Sports') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2002-01-28' as date) + and (cast('2002-01-28' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s4/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s4/q99.sql new file mode 100644 index 00000000..2a6443b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s4/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1201 and 1201 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q01.sql new file mode 100644 index 00000000..c8226b30 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_RETURN_AMT_INC_TAX) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1999 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'WA' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q03.sql new file mode 100644 index 00000000..ca519328 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_net_profit) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 916 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q04.sql new file mode 100644 index 00000000..39e93d44 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q05.sql new file mode 100644 index 00000000..815e1ddd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2002-08-22' as date) + and (cast('2002-08-22' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2002-08-22' as date) + and (cast('2002-08-22' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2002-08-22' as date) + and (cast('2002-08-22' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q06.sql new file mode 100644 index 00000000..2dcb384d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2000 + and d_moy = 6 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q07.sql new file mode 100644 index 00000000..079026ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'S' and + cd_education_status = 'Primary' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1999 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q08.sql new file mode 100644 index 00000000..3703f5e0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '70915','12059','18594','75002','17144','31573', + '13709','39885','59123','73912','98508', + '51680','33864','53575','30212','50186', + '79749','25403','80639','90741','74763', + '95320','94118','37310','44934','65437', + '27044','71410','63277','59582','69589', + '20565','51418','43707','79825','66365', + '68503','33967','75761','70447','10886', + '13611','89681','96470','70001','56444', + '84458','80035','45338','20385','43346', + '89253','13902','17512','74688','16271', + '60756','86425','49088','61110','94129', + '67121','81894','75108','95670','27492', + '31996','88760','38574','59531','29628', + '25701','34504','18849','78246','84467', + '72483','70699','93542','42492','56595', + '77344','55376','89709','26644','83507', + '15173','47724','62661','53734','86447', + '71597','44654','21389','16605','24663', + '55155','49191','53434','57449','36446', + '63767','27987','41968','92148','62678', + '49702','91742','45552','89331','51372', + '86614','51701','36831','47316','10067', + '17223','12711','75508','73690','59501', + '90383','49689','26598','14889','49995', + '98907','71182','87140','12712','83838', + '61906','24933','27149','72915','39916', + '51887','13658','61274','78137','87430', + '70176','68876','17761','24387','20296', + '86885','71156','50888','84699','95880', + '67735','26088','72257','56747','65829', + '66459','48157','88416','77917','55948', + '30037','37952','32540','59838','37179', + '87648','29186','94434','80276','46424', + '30600','34705','22698','86217','31958', + '71037','12212','46804','90382','45316', + '58363','50827','65195','19398','46690', + '20265','57026','32661','97916','72993', + '47472','92377','16936','59659','76222', + '69748','40656','68511','23812','30645', + '19061','20649','61794','62776','62860', + '28967','82386','19905','99330','99136', + '83548','26346','85557','58106','60913', + '69065','30861','55478','72650','79114', + '17653','19457','61682','67161','56625', + '52717','49324','53632','93385','80094', + '73901','17829','93463','43162','59616', + '92315','62257','55253','23008','92840', + '42803','63368','87818','73764','12108', + '92849','70424','97767','43467','22874', + '17688','12463','70423','25952','14816', + '90214','60552','50440','81550','57033', + '16390','62189','80685','57812','27589', + '72668','80028','74914','33432','66271', + '63341','95820','32525','33810','20922', + '51499','12247','98651','13019','92838', + '20589','52028','60935','91813','44910', + '96681','52289','37730','95454','64615', + '96389','44335','34355','38204','56802', + '65218','28367','17278','96062','97867', + '39855','16998','79815','83541','83673', + '74905','45934','57978','47307','20998', + '11623','97672','66731','99593','58038', + '23801','66606','38127','65290','11992', + '79405','77570','99923','97207','76970', + '89394','76337','10030','68385','40673', + '68750','56904','51163','63932','54610', + '34311','77621','36758','21431','28769', + '20440','66283','38993','47322','39624', + '69546','33400','53222','79028','41585', + '54299','53170','56629','53255','16635', + '42102','46723','68130','31215','30648', + '34728','37471','15042','98155','51975', + '30730','30386','32039','85439','68028', + '74038','84148','74286','80821','17621', + '20244','75640','80487','79484','40036', + '90521','20147','90054','33738','89393', + '55811','52703','36400','98153','44251', + '20253','28883','90061','83603','20016', + '75577','80720','35741','25429') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q09.sql new file mode 100644 index 00000000..cae75500 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 52445528 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 31757901 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 355600586 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 53365722 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 112323043 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q10.sql new file mode 100644 index 00000000..00a79fd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Kenai Peninsula Borough','Fluvanna County','Brooks County','Beaufort County','Ventura County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q11.sql new file mode 100644 index 00000000..bc470b14 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q12.sql new file mode 100644 index 00000000..3f1b7019 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Women', 'Jewelry', 'Shoes') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-03-12' as date) + and (cast('2000-03-12' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q13.sql new file mode 100644 index 00000000..ea96df75 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'College' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = '4 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MI', 'GA', 'VA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NC', 'KS', 'OH') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'ID', 'WV') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q14.sql new file mode 100644 index 00000000..116dbc98 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + 1 + and d_moy = 12 + and d_dom = 16) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + and d_moy = 12 + and d_dom = 16) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q15.sql new file mode 100644 index 00000000..6c2c4f5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1998 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q16.sql new file mode 100644 index 00000000..b5eca65b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-2-01' and + (cast('2001-2-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'LA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Mobile County','Walker County','Gogebic County','Daviess County', + 'Marshall County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q17.sql new file mode 100644 index 00000000..9501ed6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1998Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q18.sql new file mode 100644 index 00000000..58a84754 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'College' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (1,5,10,3,7,2) and + d_year = 2001 and + ca_state in ('VA','TN','MO' + ,'IN','AZ','KY','MS') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q19.sql new file mode 100644 index 00000000..b3dfd64b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=30 + and d_moy=11 + and d_year=2001 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q20.sql new file mode 100644 index 00000000..a6892e00 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Shoes', 'Men', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-05-03' as date) + and (cast('1998-05-03' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q21.sql new file mode 100644 index 00000000..45276562 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2000-05-18' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2000-05-18' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2000-05-18' as date) - INTERVAL '30' DAY) + and (cast ('2000-05-18' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q22.sql new file mode 100644 index 00000000..e8ec59cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1200 and 1200 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q23.sql new file mode 100644 index 00000000..3e0d2283 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 6 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 6 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 6 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 6 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q24.sql new file mode 100644 index 00000000..a4feb4f0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'aquamarine' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid_inc_tax) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'mint' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q25.sql new file mode 100644 index 00000000..bb04db9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_net_profit) as store_sales_profit + ,min(sr_net_loss) as store_returns_loss + ,min(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q26.sql new file mode 100644 index 00000000..77a96bd8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = '4 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q27.sql new file mode 100644 index 00000000..f78034bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'D' and + cd_education_status = '2 yr Degree' and + d_year = 2000 and + s_state in ('SD','PA', 'IL', 'IN', 'WA', 'TN') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q28.sql new file mode 100644 index 00000000..6682fe32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 124 and 124+10 + or ss_coupon_amt between 15485 and 15485+1000 + or ss_wholesale_cost between 9 and 9+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 184 and 184+10 + or ss_coupon_amt between 7544 and 7544+1000 + or ss_wholesale_cost between 35 and 35+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 130 and 130+10 + or ss_coupon_amt between 13003 and 13003+1000 + or ss_wholesale_cost between 18 and 18+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 41 and 41+10 + or ss_coupon_amt between 9061 and 9061+1000 + or ss_wholesale_cost between 6 and 6+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 155 and 155+10 + or ss_coupon_amt between 4564 and 4564+1000 + or ss_wholesale_cost between 44 and 44+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 59 and 59+10 + or ss_coupon_amt between 10168 and 10168+1000 + or ss_wholesale_cost between 42 and 42+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q29.sql new file mode 100644 index 00000000..d5ade587 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_quantity) as store_sales_quantity + ,avg(sr_return_quantity) as store_returns_quantity + ,avg(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1999,1999+1,1999+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q30.sql new file mode 100644 index 00000000..dc1a312c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2001 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'WV' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q31.sql new file mode 100644 index 00000000..54042caf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2000 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2000 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2000 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2000 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2000 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2000 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q32.sql new file mode 100644 index 00000000..b5462167 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 199 +and i_item_sk = cs_item_sk +and d_date between DATE '2002-02-15' and + (cast('2002-02-15' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2002-02-15' and + (cast('2002-02-15' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q33.sql new file mode 100644 index 00000000..dbb09049 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 6 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 6 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 6 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q34.sql new file mode 100644 index 00000000..b56c2fe4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Raleigh County','Brazos County','Williamson County','Karnes County', + 'Wadena County','Terry County','Marshall County','Pennington County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q35.sql new file mode 100644 index 00000000..d18854b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + min(cd_dep_count) aggtwo1, + max(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + min(cd_dep_employed_count) aggtwo2, + max(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + min(cd_dep_college_count) aggtwo3, + max(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q36.sql new file mode 100644 index 00000000..fe1c3e8f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('TX','LA','WA','VT', + 'IL','MN','IN','NE') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q37.sql new file mode 100644 index 00000000..a775185e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 10 and 10 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-05-24' as date) and (cast('2000-05-24' as date) + INTERVAL '60' DAY) + and i_manufact_id in (916,986,971,830) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q38.sql new file mode 100644 index 00000000..3cced6ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1201 and 1201 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1201 and 1201 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1201 and 1201 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q39.sql new file mode 100644 index 00000000..41924652 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=3 + and inv2.d_moy=3+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q40.sql new file mode 100644 index 00000000..3f02d56b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-05-02' as date) - INTERVAL '30' DAY) + and (cast ('2001-05-02' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q41.sql new file mode 100644 index 00000000..9495d2d1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 694 and 694+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'chartreuse' or i_color = 'magenta') and + (i_units = 'Oz' or i_units = 'Each') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'hot' or i_color = 'cream') and + (i_units = 'Bunch' or i_units = 'Dram') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'azure' or i_color = 'red') and + (i_units = 'Gross' or i_units = 'Ounce') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'cyan' or i_color = 'honeydew') and + (i_units = 'Case' or i_units = 'Tbl') and + (i_size = 'large' or i_size = 'extra large') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'pink' or i_color = 'puff') and + (i_units = 'Dozen' or i_units = 'Unknown') and + (i_size = 'large' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'ghost' or i_color = 'cornflower') and + (i_units = 'Cup' or i_units = 'Pound') and + (i_size = 'small' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'almond' or i_color = 'navy') and + (i_units = 'Bundle' or i_units = 'Tsp') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'plum' or i_color = 'lace') and + (i_units = 'Pallet' or i_units = 'Box') and + (i_size = 'large' or i_size = 'extra large') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q42.sql new file mode 100644 index 00000000..2aa89f83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q43.sql new file mode 100644 index 00000000..ccfb4cd1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q44.sql new file mode 100644 index 00000000..607beef2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 346 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 346 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 346 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 346 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q45.sql new file mode 100644 index 00000000..cba1900b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q46.sql new file mode 100644 index 00000000..d562daca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 9 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Belmont','Bethlehem','Brownsville','Valley View','Pleasant Ridge') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q47.sql new file mode 100644 index 00000000..3b7028cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_company_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q48.sql new file mode 100644 index 00000000..5510a0de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2002 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'College' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = '4 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('WI', 'NE', 'ID') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('FL', 'MO', 'MI') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('KS', 'SC', 'AK') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q49.sql new file mode 100644 index 00000000..dce88428 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q50.sql new file mode 100644 index 00000000..7a9a5faa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q51.sql new file mode 100644 index 00000000..c9de3104 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1211 and 1211+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1211 and 1211+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q52.sql new file mode 100644 index 00000000..4533bf32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1998 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q53.sql new file mode 100644 index 00000000..f30d8ce4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1215,1215+1,1215+2,1215+3,1215+4,1215+5,1215+6,1215+7,1215+8,1215+9,1215+10,1215+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q54.sql new file mode 100644 index 00000000..16ee7b5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Jewelry' + and i_class = 'costume' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 2 + and d_year = 2000 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2000 and d_moy = 2) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2000 and d_moy = 2) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q55.sql new file mode 100644 index 00000000..01e05f0a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=32 + and d_moy=11 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q56.sql new file mode 100644 index 00000000..36c2d7a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('magenta','honeydew','ghost')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('magenta','honeydew','ghost')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('magenta','honeydew','ghost')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q57.sql new file mode 100644 index 00000000..5bc3d7b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q58.sql new file mode 100644 index 00000000..645eaaec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-05-26')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-05-26')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-05-26')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q59.sql new file mode 100644 index 00000000..b64c11d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1210 and 1210 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1210+ 12 and 1210 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q60.sql new file mode 100644 index 00000000..73750612 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Shoes')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q61.sql new file mode 100644 index 00000000..50ccd83b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 2001 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Books' + and s_gmt_offset = -6 + and d_year = 2001 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q62.sql new file mode 100644 index 00000000..b649bc72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1181 and 1181 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q63.sql new file mode 100644 index 00000000..9e514782 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1183,1183+1,1183+2,1183+3,1183+4,1183+5,1183+6,1183+7,1183+8,1183+9,1183+10,1183+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q64.sql new file mode 100644 index 00000000..9e169ced --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('ivory','lace','tan','cornflower','drab','salmon') and + i_current_price between 84 and 84 + 10 and + i_current_price between 84 + 1 and 84 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q65.sql new file mode 100644 index 00000000..34a076b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1187 and 1187+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q66.sql new file mode 100644 index 00000000..dd0a4982 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'ORIENTAL' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 28731 and 28731+28800 + and sm_carrier in ('FEDEX','ORIENTAL') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'FEDEX' || ',' || 'ORIENTAL' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1999 + and t_time between 28731 AND 28731+28800 + and sm_carrier in ('FEDEX','ORIENTAL') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q67.sql new file mode 100644 index 00000000..1ccf448d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1205 and 1205+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q68.sql new file mode 100644 index 00000000..d3b20ad0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 6 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Dayton','Jacksonville') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q69.sql new file mode 100644 index 00000000..00b436bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('FL','MO','AL') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q70.sql new file mode 100644 index 00000000..abee51c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1205 and 1205+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1205 and 1205+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q71.sql new file mode 100644 index 00000000..1191ce94 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q72.sql new file mode 100644 index 00000000..dcdf8986 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 1998 + and cd_marital_status = 'M' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q73.sql new file mode 100644 index 00000000..bc1b43cd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Williamson County','Arthur County','Contra Costa County','Huron County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q74.sql new file mode 100644 index 00000000..8398cd4f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2001 + and t_s_secyear.year = 2001+1 + and t_w_firstyear.year = 2001 + and t_w_secyear.year = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,2,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q75.sql new file mode 100644 index 00000000..3f56e7de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Music' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Music' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Music') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q76.sql new file mode 100644 index 00000000..20fa2813 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_hdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_hdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_addr_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_addr_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_mode_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_mode_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q77.sql new file mode 100644 index 00000000..82caf73e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-26' as date) + and (cast('2001-08-26' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q78.sql new file mode 100644 index 00000000..24ecf4fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q79.sql new file mode 100644 index 00000000..5a7a2d47 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 9 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q80.sql new file mode 100644 index 00000000..64e0db2b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-23' as date) + and (cast('2001-08-23' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-23' as date) + and (cast('2001-08-23' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-23' as date) + and (cast('2001-08-23' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q81.sql new file mode 100644 index 00000000..1604092c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'IA' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q82.sql new file mode 100644 index 00000000..918abf5d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 45 and 45+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-06-27' as date) and (cast('1998-06-27' as date) + INTERVAL '60' DAY) + and i_manufact_id in (989,310,773,225) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q83.sql new file mode 100644 index 00000000..9fbe9aed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-06-07',DATE '1998-09-22',DATE '1998-11-20'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-06-07',DATE '1998-09-22',DATE '1998-11-20'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-06-07',DATE '1998-09-22',DATE '1998-11-20'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q84.sql new file mode 100644 index 00000000..a148c513 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Waterloo' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 12255 + and ib_upper_bound <= 12255 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q85.sql new file mode 100644 index 00000000..a8b39e35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 1998 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('MN', 'VT', 'ND') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('KY', 'TX', 'CA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('TN', 'NC', 'GA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q86.sql new file mode 100644 index 00000000..b5781f69 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1203 and 1203+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q87.sql new file mode 100644 index 00000000..9b4a0c02 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1194 and 1194+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1194 and 1194+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1194 and 1194+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q88.sql new file mode 100644 index 00000000..23c3d2be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q89.sql new file mode 100644 index 00000000..0f346484 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Books','Sports','Children') and + i_class in ('mystery','basketball','toddlers') + ) + or (i_category in ('Shoes','Men','Home') and + i_class in ('athletic','pants','kids') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q90.sql new file mode 100644 index 00000000..be9b0417 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 11 and 11+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 21 and 21+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q91.sql new file mode 100644 index 00000000..916a733a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 11 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '1001-5000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q92.sql new file mode 100644 index 00000000..616038e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 285 +and i_item_sk = ws_item_sk +and d_date between DATE '1999-02-02' and + (cast('1999-02-02' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1999-02-02' and + (cast('1999-02-02' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q93.sql new file mode 100644 index 00000000..f164c239 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 59') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q94.sql new file mode 100644 index 00000000..38184747 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-4-01' and + (cast('1999-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'MI' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q95.sql new file mode 100644 index 00000000..db0c536a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-2-01' and + (cast('2001-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q96.sql new file mode 100644 index 00000000..c917c4a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 1 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q97.sql new file mode 100644 index 00000000..728c546d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1217 and 1217 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1217 and 1217 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q98.sql new file mode 100644 index 00000000..cc4494c0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Books', 'Men', 'Electronics') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-01-12' as date) + and (cast('1999-01-12' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s5/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s5/q99.sql new file mode 100644 index 00000000..28a7386a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s5/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1209 and 1209 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q01.sql new file mode 100644 index 00000000..3a3b6c23 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_REFUNDED_CASH) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2001 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'IN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q03.sql new file mode 100644 index 00000000..0044cb54 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 7 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q04.sql new file mode 100644 index 00000000..39e93d44 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_c_firstyear.dyear = 1998 + and t_c_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q05.sql new file mode 100644 index 00000000..8c584825 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1999-08-14' as date) + and (cast('1999-08-14' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1999-08-14' as date) + and (cast('1999-08-14' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1999-08-14' as date) + and (cast('1999-08-14' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q06.sql new file mode 100644 index 00000000..95c8358a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 3 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q07.sql new file mode 100644 index 00000000..3f6359f8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q08.sql new file mode 100644 index 00000000..a786c4bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '80235','74820','63434','61741','94938','88857', + '17568','26993','72027','30609','35911', + '35658','31674','62986','55519','20430', + '10184','63781','71819','27019','12278', + '31272','85120','30274','41486','79707', + '89066','68234','14347','56193','36207', + '65623','11536','17468','81656','66166', + '23157','73024','99634','24057','87035', + '10799','64664','68712','85514','46137', + '55814','14509','65417','85519','88990', + '19473','96945','40659','17956','70184', + '19764','16436','69470','78344','17319', + '96295','58876','53352','85959','84524', + '93650','25571','17505','91570','38413', + '57938','85772','30819','74762','16985', + '25791','63638','39674','12968','57074', + '40475','60905','17341','46966','36020', + '50451','20208','45096','63776','62392', + '55708','68178','77025','11767','90653', + '76876','71220','59107','91396','13874', + '67206','95447','74062','67091','30088', + '43911','38694','33006','71173','75877', + '63745','91042','66801','33398','71813', + '15271','32800','45754','58606','27201', + '96962','18040','18654','45135','56451', + '91147','56092','48946','25624','98718', + '37337','19173','23819','20185','14120', + '94719','52077','72956','84904','19185', + '10848','43734','45190','90431','72562', + '47322','11663','22076','81678','22788', + '99094','48585','42985','40121','36164', + '59438','56117','90031','37120','40751', + '58739','22636','17370','71708','33932', + '71171','76551','90826','93013','84489', + '38469','89147','75547','77774','83920', + '40520','50031','10904','73496','15603', + '57686','41523','49892','56493','94260', + '88703','99357','78433','42766','92888', + '78435','56011','41188','10025','78528', + '68978','77145','36653','79964','60173', + '72736','31858','64050','69866','77892', + '70756','18853','94402','78991','99990', + '12552','78391','67018','77395','75800', + '75343','43345','12647','48613','69827', + '96187','28785','59825','83780','60472', + '25179','52113','42744','34801','89825', + '64084','44788','23925','19266','19782', + '24733','10095','72465','62188','93173', + '45904','24636','88104','66596','43282', + '80024','41024','60569','70178','56361', + '76783','23780','62035','33966','53586', + '99022','98176','15185','41836','54486', + '68082','41665','47733','80406','96066', + '77135','67707','28071','94399','37693', + '10089','30948','17825','63661','67165', + '15798','41915','15400','38425','55181', + '69384','41061','48167','11195','13748', + '11966','12102','33518','51865','91484', + '31984','34137','74302','70421','21634', + '18116','94853','39939','45290','53181', + '73609','21690','36286','16465','11111', + '34173','47459','40856','42579','51294', + '24324','35593','86787','33675','52713', + '84196','51401','20356','65325','63353', + '36911','59611','81227','54318','31368', + '25212','37053','21331','64327','15345', + '49814','21656','91970','92191','24121', + '37025','28803','56745','92954','47300', + '93417','26698','69816','58084','26366', + '99816','90974','32689','21188','31604', + '77344','37824','19064','66650','10273', + '76313','34946','75832','15240','74350', + '82798','18694','26347','16477','94887', + '59892','16782','69232','20844','74040', + '66514','58936','44497','61881','38701', + '44815','34567','48776','66141','95153', + '92463','63394','68683','38590','28020', + '36070','41797','75516','59916','44784', + '10423','37288','24894','39100','61113', + '63701','12284','14981','35117') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q09.sql new file mode 100644 index 00000000..aaa475ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 272082747 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 371185941 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 227579426 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 265533799 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 374768608 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q10.sql new file mode 100644 index 00000000..a043a6b1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Lewis and Clark County','Laclede County','Kitsap County','Winnebago County','Parke County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q11.sql new file mode 100644 index 00000000..823c4842 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q12.sql new file mode 100644 index 00000000..8567b621 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Electronics', 'Sports', 'Women') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-03-02' as date) + and (cast('2000-03-02' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q13.sql new file mode 100644 index 00000000..9517f3ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('SC', 'TN', 'NH') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('CA', 'MT', 'NE') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'IN', 'KS') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q14.sql new file mode 100644 index 00000000..26aa1cac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + 1 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1999 + and d_moy = 12 + and d_dom = 17) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q16.sql new file mode 100644 index 00000000..ffaf43d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-2-01' and + (cast('1999-2-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'CA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Mobile County','Williamson County','Pennington County','Marshall County', + 'Huron County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q17.sql new file mode 100644 index 00000000..ee45871e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1999Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1999Q1','1999Q2','1999Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q18.sql new file mode 100644 index 00000000..6614db7a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = '4 yr Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (10,4,3,7,5,6) and + d_year = 1998 and + ca_state in ('KY','ND','MS' + ,'VA','ID','NE','CO') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q19.sql new file mode 100644 index 00000000..e15f8782 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=68 + and d_moy=12 + and d_year=1999 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q20.sql new file mode 100644 index 00000000..556a32de --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Home', 'Electronics', 'Women') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-03-24' as date) + and (cast('2000-03-24' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q21.sql new file mode 100644 index 00000000..db066980 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-02-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1998-02-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1998-02-22' as date) - INTERVAL '30' DAY) + and (cast ('1998-02-22' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q22.sql new file mode 100644 index 00000000..ed66b9b1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1194 and 1194 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q23.sql new file mode 100644 index 00000000..a191a247 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q24.sql new file mode 100644 index 00000000..cc753ae1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'sienna' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_ext_sales_price) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 6 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'thistle' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q25.sql new file mode 100644 index 00000000..bb04db9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_net_profit) as store_sales_profit + ,min(sr_net_loss) as store_returns_loss + ,min(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q26.sql new file mode 100644 index 00000000..9e05c645 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q27.sql new file mode 100644 index 00000000..9e376aca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + d_year = 1998 and + s_state in ('NM','SC', 'NM', 'NC', 'IL', 'GA') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q28.sql new file mode 100644 index 00000000..0db79db0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 61 and 61+10 + or ss_coupon_amt between 2251 and 2251+1000 + or ss_wholesale_cost between 41 and 41+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 32 and 32+10 + or ss_coupon_amt between 2281 and 2281+1000 + or ss_wholesale_cost between 53 and 53+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 183 and 183+10 + or ss_coupon_amt between 4897 and 4897+1000 + or ss_wholesale_cost between 39 and 39+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 110 and 110+10 + or ss_coupon_amt between 9142 and 9142+1000 + or ss_wholesale_cost between 21 and 21+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 159 and 159+10 + or ss_coupon_amt between 710 and 710+1000 + or ss_wholesale_cost between 12 and 12+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 190 and 190+10 + or ss_coupon_amt between 11141 and 11141+1000 + or ss_wholesale_cost between 74 and 74+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q29.sql new file mode 100644 index 00000000..59118672 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q30.sql new file mode 100644 index 00000000..78bcf2b7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2002 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AR' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q31.sql new file mode 100644 index 00000000..0be44cef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1998 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1998 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1998 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1998 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1998 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1998 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.d_year; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q32.sql new file mode 100644 index 00000000..f5f5bd2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 17 +and i_item_sk = cs_item_sk +and d_date between DATE '2000-01-30' and + (cast('2000-01-30' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2000-01-30' and + (cast('2000-01-30' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q33.sql new file mode 100644 index 00000000..1c0df90e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 1 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q34.sql new file mode 100644 index 00000000..47f9dbb4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Terrell County','Nowata County','Lunenburg County','Anderson County', + 'Pipestone County','Harding County','Green Lake County','Coal County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q35.sql new file mode 100644 index 00000000..8747cb38 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + min(cd_dep_count) aggone1, + max(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + min(cd_dep_employed_count) aggone2, + max(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + min(cd_dep_college_count) aggone3, + max(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q36.sql new file mode 100644 index 00000000..3317831b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('FL','SD','AL','NE', + 'GA','NC','MO','GA') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q37.sql new file mode 100644 index 00000000..2482451d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 24 and 24 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-02-03' as date) and (cast('2002-02-03' as date) + INTERVAL '60' DAY) + and i_manufact_id in (884,882,988,877) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q38.sql new file mode 100644 index 00000000..ae84dab5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1193 and 1193 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1193 and 1193 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1193 and 1193 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q39.sql new file mode 100644 index 00000000..a0923bea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q40.sql new file mode 100644 index 00000000..f10563f6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-04-17' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-04-17' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-04-17' as date) - INTERVAL '30' DAY) + and (cast ('1998-04-17' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q41.sql new file mode 100644 index 00000000..c1a6151a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 875 and 875+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'azure' or i_color = 'navajo') and + (i_units = 'Box' or i_units = 'Ton') and + (i_size = 'large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'chocolate' or i_color = 'puff') and + (i_units = 'Carton' or i_units = 'Tbl') and + (i_size = 'extra large' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'turquoise' or i_color = 'floral') and + (i_units = 'Dozen' or i_units = 'Case') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'orchid' or i_color = 'lawn') and + (i_units = 'Cup' or i_units = 'Unknown') and + (i_size = 'large' or i_size = 'N/A') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'powder' or i_color = 'hot') and + (i_units = 'Gross' or i_units = 'Lb') and + (i_size = 'large' or i_size = 'N/A') + ) or + (i_category = 'Women' and + (i_color = 'blue' or i_color = 'rose') and + (i_units = 'Ounce' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'medium' or i_color = 'spring') and + (i_units = 'Pallet' or i_units = 'N/A') and + (i_size = 'petite' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'purple' or i_color = 'moccasin') and + (i_units = 'Bundle' or i_units = 'Oz') and + (i_size = 'large' or i_size = 'N/A') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q42.sql new file mode 100644 index 00000000..2aa89f83 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2001 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q43.sql new file mode 100644 index 00000000..f52d0818 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q44.sql new file mode 100644 index 00000000..8baee348 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 521 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 521 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 521 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 521 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q45.sql new file mode 100644 index 00000000..cba1900b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1999 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q46.sql new file mode 100644 index 00000000..5cf3c255 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 6 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Shiloh','Lakeview','Highland','Springdale','White Oak') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q47.sql new file mode 100644 index 00000000..589d2bb7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_company_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q48.sql new file mode 100644 index 00000000..e383d539 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'College' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MN', 'KY', 'GA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('AZ', 'TX', 'VA') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IA', 'ME', 'NE') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q49.sql new file mode 100644 index 00000000..3b4eaa26 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q50.sql new file mode 100644 index 00000000..71fedc7d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q51.sql new file mode 100644 index 00000000..489d6f53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1223 and 1223+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1223 and 1223+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q52.sql new file mode 100644 index 00000000..af901517 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=1999 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q53.sql new file mode 100644 index 00000000..f1770da1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1213,1213+1,1213+2,1213+3,1213+4,1213+5,1213+6,1213+7,1213+8,1213+9,1213+10,1213+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q54.sql new file mode 100644 index 00000000..5c58c825 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Shoes' + and i_class = 'kids' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 2 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 2) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 2) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q55.sql new file mode 100644 index 00000000..539bbaf6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=81 + and d_moy=11 + and d_year=1999 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q56.sql new file mode 100644 index 00000000..6ffc9e50 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('spring','saddle','orange')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('spring','saddle','orange')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('spring','saddle','orange')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -8 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q57.sql new file mode 100644 index 00000000..e0c28890 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q58.sql new file mode 100644 index 00000000..68fa7980 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-02-10')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-02-10')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1998-02-10')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q59.sql new file mode 100644 index 00000000..6bb7f359 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1212 and 1212 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1212+ 12 and 1212 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q60.sql new file mode 100644 index 00000000..93db8993 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q61.sql new file mode 100644 index 00000000..a0fa971d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Home' + and s_gmt_offset = -6 + and d_year = 1998 + and d_moy = 12) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q62.sql new file mode 100644 index 00000000..b649bc72 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1181 and 1181 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q63.sql new file mode 100644 index 00000000..239494ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1209,1209+1,1209+2,1209+3,1209+4,1209+5,1209+6,1209+7,1209+8,1209+9,1209+10,1209+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q64.sql new file mode 100644 index 00000000..d31482a4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('brown','dodger','turquoise','cornflower','slate','peach') and + i_current_price between 55 and 55 + 10 and + i_current_price between 55 + 1 and 55 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q65.sql new file mode 100644 index 00000000..eb5dd892 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1221 and 1221+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1221 and 1221+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q66.sql new file mode 100644 index 00000000..0ccce5bb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'DIAMOND' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2000 + and t_time between 50373 and 50373+28800 + and sm_carrier in ('ZOUROS','DIAMOND') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'DIAMOND' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2000 + and t_time between 50373 AND 50373+28800 + and sm_carrier in ('ZOUROS','DIAMOND') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q67.sql new file mode 100644 index 00000000..a3098cef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1190 and 1190+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q68.sql new file mode 100644 index 00000000..7459616a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 2 or + household_demographics.hd_vehicle_count= -1) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Cross Roads','Webster') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q69.sql new file mode 100644 index 00000000..f67c2c71 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('VA','FL','NM') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q70.sql new file mode 100644 index 00000000..b65f15a4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1177 and 1177+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1177 and 1177+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q71.sql new file mode 100644 index 00000000..b547ac16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q72.sql new file mode 100644 index 00000000..33acf443 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 2002 + and cd_marital_status = 'U' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q73.sql new file mode 100644 index 00000000..0d7109e7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Miller County','Montgomery County','Halifax County','Harper County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q74.sql new file mode 100644 index 00000000..f41484c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,avg(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2000 + and t_s_secyear.year = 2000+1 + and t_w_firstyear.year = 2000 + and t_w_secyear.year = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q75.sql new file mode 100644 index 00000000..b8637731 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Electronics' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Electronics') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q76.sql new file mode 100644 index 00000000..bbf810a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_cdemo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_cdemo_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_ship_customer_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_ship_customer_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_hdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q77.sql new file mode 100644 index 00000000..177bb6c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-04' as date) + and (cast('2000-08-04' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q78.sql new file mode 100644 index 00000000..24ecf4fc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1999 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q79.sql new file mode 100644 index 00000000..c4a13d8c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 1 or household_demographics.hd_vehicle_count > 1) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q80.sql new file mode 100644 index 00000000..84dfafc5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-03' as date) + and (cast('2000-08-03' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-03' as date) + and (cast('2000-08-03' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-03' as date) + and (cast('2000-08-03' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q81.sql new file mode 100644 index 00000000..47c226d3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AL' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q82.sql new file mode 100644 index 00000000..f4a1aafe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 38 and 38+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-05-29' as date) and (cast('1998-05-29' as date) + INTERVAL '60' DAY) + and i_manufact_id in (752,284,742,543) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q83.sql new file mode 100644 index 00000000..cfb4733e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-03-25',DATE '1998-08-08',DATE '1998-11-09'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-03-25',DATE '1998-08-08',DATE '1998-11-09'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-03-25',DATE '1998-08-08',DATE '1998-11-09'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q84.sql new file mode 100644 index 00000000..c2451d54 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Farmington' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 36227 + and ib_upper_bound <= 36227 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q85.sql new file mode 100644 index 00000000..f374e30d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 1999 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '4 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('WI', 'CT', 'VA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('MS', 'UT', 'ND') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('WY', 'NE', 'FL') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q86.sql new file mode 100644 index 00000000..62b8e009 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1179 and 1179+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q87.sql new file mode 100644 index 00000000..216878c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1195 and 1195+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1195 and 1195+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1195 and 1195+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q88.sql new file mode 100644 index 00000000..71015cf3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q89.sql new file mode 100644 index 00000000..342af808 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Electronics','Shoes','Home') and + i_class in ('memory','mens','kids') + ) + or (i_category in ('Books','Music','Women') and + i_class in ('history','classical','fragrances') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q90.sql new file mode 100644 index 00000000..5eab6182 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 7 and 7+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 17 and 17+1 + and household_demographics.hd_dep_count = 3 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q91.sql new file mode 100644 index 00000000..5dfc10bd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like 'Unknown%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q92.sql new file mode 100644 index 00000000..73429f13 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 86 +and i_item_sk = ws_item_sk +and d_date between DATE '1998-03-12' and + (cast('1998-03-12' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '1998-03-12' and + (cast('1998-03-12' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q93.sql new file mode 100644 index 00000000..eac88eb7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 53') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q94.sql new file mode 100644 index 00000000..3382f6e6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-2-01' and + (cast('2000-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IL' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q95.sql new file mode 100644 index 00000000..ee453b4c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-2-01' and + (cast('2001-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'KS' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q96.sql new file mode 100644 index 00000000..86ca4f1d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 5 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q97.sql new file mode 100644 index 00000000..b10fb204 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1185 and 1185 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1185 and 1185 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q98.sql new file mode 100644 index 00000000..f3a6640e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Women', 'Home', 'Shoes') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-05-17' as date) + and (cast('1999-05-17' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s6/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s6/q99.sql new file mode 100644 index 00000000..75e70a97 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s6/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1205 and 1205 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q01.sql new file mode 100644 index 00000000..a50aec9d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_RETURN_TAX) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2002 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NE' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q02.sql new file mode 100644 index 00000000..3c0cc32f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 2000+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q03.sql new file mode 100644 index 00000000..25ea1dbf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_net_profit) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 415 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q04.sql new file mode 100644 index 00000000..0c8c44b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_c_firstyear.dyear = 2000 + and t_c_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q05.sql new file mode 100644 index 00000000..c8bb1af8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1998-08-15' as date) + and (cast('1998-08-15' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q06.sql new file mode 100644 index 00000000..6ca54c53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 4 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q07.sql new file mode 100644 index 00000000..856fcf1d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q08.sql new file mode 100644 index 00000000..0b7c35c2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '60807','47189','43551','25574','91355','26885', + '88054','51445','56852','16645','22044', + '34222','84008','79292','80903','66043', + '73266','31540','13913','78907','48019', + '92610','45985','40745','58918','83317', + '80739','62185','74098','52608','72576', + '43186','21129','63368','21264','53868', + '76276','98659','24589','23208','50669', + '87878','40759','45960','25271','94635', + '20304','30224','93485','59644','21817', + '12767','93184','32051','16668','40491', + '71195','93949','79435','74911','70657', + '63816','36643','99913','10692','81659', + '38569','61738','77984','75343','90834', + '72047','64087','81140','47656','37429', + '84823','41877','18771','90899','29644', + '18204','77248','81368','85779','26598', + '78414','19538','69466','68410','86865', + '37377','91077','92849','57635','19124', + '95260','32060','62365','11441','95810', + '21602','38775','34994','96476','29519', + '66332','85355','50099','90692','45893', + '62774','56030','95529','50395','81336', + '29052','79772','63642','32021','21913', + '26031','78562','52980','44278','18830', + '80932','37667','44481','22255','34393', + '80849','56878','48445','50416','98373', + '27155','13191','56192','87916','54796', + '66395','78005','62848','16183','33464', + '13223','31557','68312','54939','55832', + '43402','24902','70243','83969','25360', + '99370','84102','25770','44385','46711', + '66885','76797','65860','20045','71802', + '46042','65417','18380','91471','90459', + '71249','40872','99142','22677','15312', + '80356','92287','47818','42043','70466', + '75568','71738','78438','73017','17266', + '19240','38452','51377','86619','44464', + '80137','18439','15483','73256','48199', + '46615','79699','35679','56746','10413', + '48638','69729','82262','64215','21681', + '49938','48348','76885','34622','85243', + '30596','32533','14325','22674','30298', + '41515','29994','67308','54606','23093', + '61470','82877','78550','40889','99992', + '95104','91433','92461','36767','82887', + '43658','61160','76835','82847','99616', + '84869','84403','43917','44066','20570', + '75117','12119','86595','31111','16388', + '68229','73992','27101','37171','98433', + '98577','66465','40350','25841','96189', + '46654','67786','51758','58979','63581', + '48356','36868','25957','18273','14785', + '33842','91987','59544','42169','65413', + '22778','28738','34924','36688','46256', + '54262','11745','17608','41190','26415', + '86926','41249','75673','66609','68469', + '79127','16344','10785','94688','86167', + '71878','68423','97835','85191','35971', + '51406','79167','55639','69860','33732', + '35427','78152','34688','10814','52110', + '67789','27279','88995','20725','32039', + '97233','30603','58522','65873','22054', + '95361','34336','25361','64710','11096', + '96091','19248','38163','37444','89026', + '66469','20972','23633','47888','60973', + '34287','12219','15640','74872','41311', + '26597','92711','25375','86500','90625', + '11977','48080','89444','38473','99264', + '26739','50836','62315','90994','65234', + '57277','67956','17723','71449','65982', + '29010','16335','43015','47931','62766', + '82949','63232','19732','87176','99532', + '27648','97533','10180','30165','76778', + '54176','98536','65209','31367','49223', + '25827','72635','38702','21262','18286', + '71794','93983','50963','44114','94542', + '70078','59203','38707','37978','66343', + '76625','97918','28055','14474','54299', + '79440','27630','90206','18229') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q09.sql new file mode 100644 index 00000000..ce02bf4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 155425275 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 307401322 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 289651493 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 141929797 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 30269574 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q10.sql new file mode 100644 index 00000000..7110cada --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Stephens County','Hyde County','Monroe County','San Juan County','Pepin County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q11.sql new file mode 100644 index 00000000..f284e9a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2001 + and t_s_secyear.dyear = 2001+1 + and t_w_firstyear.dyear = 2001 + and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q12.sql new file mode 100644 index 00000000..a439412b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Children', 'Women', 'Men') + and ws_sold_date_sk = d_date_sk + and d_date between cast('1999-01-23' as date) + and (cast('1999-01-23' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q13.sql new file mode 100644 index 00000000..7d8510ec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'College' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('FL', 'CO', 'AK') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MI', 'ME', 'IL') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('AR', 'NE', 'IA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q14.sql new file mode 100644 index 00000000..6e0492a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 2000 AND 2000 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 2000 AND 2000 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 2000 AND 2000 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 2000 and 2000 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + 1 + and d_moy = 12 + and d_dom = 16) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 2000 + and d_moy = 12 + and d_dom = 16) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q15.sql new file mode 100644 index 00000000..2718b3ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q16.sql new file mode 100644 index 00000000..ff5bdb4d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '1999-3-01' and + (cast('1999-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'WA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Williamson County','Pennington County','Dauphin County','Gage County', + 'Barrow County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q17.sql new file mode 100644 index 00000000..4f3e0465 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q18.sql new file mode 100644 index 00000000..386816f1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (1,11,2,7,8,9) and + d_year = 1999 and + ca_state in ('MA','VA','SD' + ,'CO','MN','IL','PA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q19.sql new file mode 100644 index 00000000..02afa18e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=65 + and d_moy=11 + and d_year=1998 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q20.sql new file mode 100644 index 00000000..24465816 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Electronics', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('1998-04-02' as date) + and (cast('1998-04-02' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q21.sql new file mode 100644 index 00000000..2e050131 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-05-17' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2002-05-17' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2002-05-17' as date) - INTERVAL '30' DAY) + and (cast ('2002-05-17' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q22.sql new file mode 100644 index 00000000..6d04cc53 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1202 and 1202 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q23.sql new file mode 100644 index 00000000..a191a247 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q24.sql new file mode 100644 index 00000000..6449d95c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'burnished' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'plum' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q25.sql new file mode 100644 index 00000000..329c01a1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,avg(ss_net_profit) as store_sales_profit + ,avg(sr_net_loss) as store_returns_loss + ,avg(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2002 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2002 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2002 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q26.sql new file mode 100644 index 00000000..57577cd9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'U' and + cd_education_status = 'Advanced Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q27.sql new file mode 100644 index 00000000..ddc691ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'S' and + cd_education_status = 'Secondary' and + d_year = 2001 and + s_state in ('AL','FL', 'MN', 'LA', 'NC', 'MN') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q28.sql new file mode 100644 index 00000000..6e3c984c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 103 and 103+10 + or ss_coupon_amt between 7495 and 7495+1000 + or ss_wholesale_cost between 42 and 42+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 185 and 185+10 + or ss_coupon_amt between 6324 and 6324+1000 + or ss_wholesale_cost between 78 and 78+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 47 and 47+10 + or ss_coupon_amt between 13048 and 13048+1000 + or ss_wholesale_cost between 4 and 4+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 187 and 187+10 + or ss_coupon_amt between 8815 and 8815+1000 + or ss_wholesale_cost between 72 and 72+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 125 and 125+10 + or ss_coupon_amt between 2860 and 2860+1000 + or ss_wholesale_cost between 74 and 74+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 156 and 156+10 + or ss_coupon_amt between 10186 and 10186+1000 + or ss_wholesale_cost between 28 and 28+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q29.sql new file mode 100644 index 00000000..ff3abef6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_quantity) as store_sales_quantity + ,max(sr_return_quantity) as store_returns_quantity + ,max(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q30.sql new file mode 100644 index 00000000..53a9bda3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =1999 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TX' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q31.sql new file mode 100644 index 00000000..46227e5e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1998 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1998 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1998 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1998 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1998 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1998 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q2_q3_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q32.sql new file mode 100644 index 00000000..c5ef0735 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 604 +and i_item_sk = cs_item_sk +and d_date between DATE '2000-02-17' and + (cast('2000-02-17' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '2000-02-17' and + (cast('2000-02-17' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q33.sql new file mode 100644 index 00000000..929ffe2b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Sports')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q34.sql new file mode 100644 index 00000000..33b9acb0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Pipestone County','Terry County','Hubbard County','Franklin Parish', + 'Stillwater County','San Miguel County','Karnes County','Nuckolls County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q35.sql new file mode 100644 index 00000000..7cf3e14c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + min(cd_dep_count) aggtwo1, + sum(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + min(cd_dep_employed_count) aggtwo2, + sum(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + min(cd_dep_college_count) aggtwo3, + sum(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q36.sql new file mode 100644 index 00000000..360f01ca --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2002 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('MI','IN','MI','MI', + 'SD','NM','OK','NC') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q37.sql new file mode 100644 index 00000000..217452d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 41 and 41 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-04-15' as date) and (cast('1998-04-15' as date) + INTERVAL '60' DAY) + and i_manufact_id in (786,959,839,868) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q38.sql new file mode 100644 index 00000000..5003c143 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1181 and 1181 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q39.sql new file mode 100644 index 00000000..2a53cae2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=2 + and inv2.d_moy=2+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q40.sql new file mode 100644 index 00000000..674857b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2002-05-26' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2002-05-26' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2002-05-26' as date) - INTERVAL '30' DAY) + and (cast ('2002-05-26' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q41.sql new file mode 100644 index 00000000..b36af984 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 842 and 842+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'honeydew' or i_color = 'peru') and + (i_units = 'Tsp' or i_units = 'Case') and + (i_size = 'extra large' or i_size = 'large') + ) or + (i_category = 'Women' and + (i_color = 'lace' or i_color = 'pink') and + (i_units = 'Ton' or i_units = 'Gram') and + (i_size = 'economy' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'red' or i_color = 'cornsilk') and + (i_units = 'N/A' or i_units = 'Box') and + (i_size = 'medium' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'cyan' or i_color = 'ivory') and + (i_units = 'Cup' or i_units = 'Pound') and + (i_size = 'extra large' or i_size = 'large') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'cream' or i_color = 'hot') and + (i_units = 'Pallet' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'large') + ) or + (i_category = 'Women' and + (i_color = 'olive' or i_color = 'floral') and + (i_units = 'Bundle' or i_units = 'Carton') and + (i_size = 'economy' or i_size = 'N/A') + ) or + (i_category = 'Men' and + (i_color = 'papaya' or i_color = 'green') and + (i_units = 'Oz' or i_units = 'Dozen') and + (i_size = 'medium' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'dim' or i_color = 'wheat') and + (i_units = 'Each' or i_units = 'Dram') and + (i_size = 'extra large' or i_size = 'large') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q42.sql new file mode 100644 index 00000000..df1387e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2002 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q43.sql new file mode 100644 index 00000000..79576281 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 2002 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q44.sql new file mode 100644 index 00000000..fadeadb0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 639 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 639 + and ss_promo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 639 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 639 + and ss_promo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q45.sql new file mode 100644 index 00000000..b3ae0590 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2001 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q46.sql new file mode 100644 index 00000000..9a095384 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Columbia','Woodville','Crossroads','Mount Carmel','Green Acres') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q47.sql new file mode 100644 index 00000000..c74350f3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.s_store_name, v1.s_company_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, psum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q48.sql new file mode 100644 index 00000000..dd1f6e82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2000 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Unknown' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'KS', 'CA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MS', 'IN', 'MD') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('FL', 'KY', 'SD') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q49.sql new file mode 100644 index 00000000..41429035 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q50.sql new file mode 100644 index 00000000..71fedc7d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2002 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q51.sql new file mode 100644 index 00000000..90daa3c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1199 and 1199+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1199 and 1199+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q52.sql new file mode 100644 index 00000000..5821767e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=2000 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q53.sql new file mode 100644 index 00000000..f30d8ce4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1215,1215+1,1215+2,1215+3,1215+4,1215+5,1215+6,1215+7,1215+8,1215+9,1215+10,1215+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q54.sql new file mode 100644 index 00000000..6b94253f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Music' + and i_class = 'country' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 2 + and d_year = 2001 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2001 and d_moy = 2) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2001 and d_moy = 2) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q55.sql new file mode 100644 index 00000000..a0fe7b91 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=9 + and d_moy=12 + and d_year=2002 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q56.sql new file mode 100644 index 00000000..acbf10be --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('navy','dim','saddle')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','dim','saddle')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('navy','dim','saddle')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 4 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q57.sql new file mode 100644 index 00000000..7cdcd2c5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year, v1.d_moy + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q58.sql new file mode 100644 index 00000000..3bfb4577 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2002-03-23')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '2002-03-23')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '2002-03-23')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q59.sql new file mode 100644 index 00000000..87fad795 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1199 and 1199 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1199+ 12 and 1199 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q60.sql new file mode 100644 index 00000000..26c747b3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q61.sql new file mode 100644 index 00000000..ee1cf68e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Electronics' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2001 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Electronics' + and s_gmt_offset = -7 + and d_year = 2001 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q62.sql new file mode 100644 index 00000000..7159343c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1189 and 1189 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q63.sql new file mode 100644 index 00000000..a66684c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1198,1198+1,1198+2,1198+3,1198+4,1198+5,1198+6,1198+7,1198+8,1198+9,1198+10,1198+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q64.sql new file mode 100644 index 00000000..df776739 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('powder','plum','lemon','magenta','lace','burnished') and + i_current_price between 16 and 16 + 10 and + i_current_price between 16 + 1 and 16 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q65.sql new file mode 100644 index 00000000..647cb5a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1179 and 1179+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1179 and 1179+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q66.sql new file mode 100644 index 00000000..a7ed119f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'TBS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42678 and 42678+28800 + and sm_carrier in ('ZOUROS','TBS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'ZOUROS' || ',' || 'TBS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42678 AND 42678+28800 + and sm_carrier in ('ZOUROS','TBS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q67.sql new file mode 100644 index 00000000..c35df1c8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1216 and 1216+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q68.sql new file mode 100644 index 00000000..46796e05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 3 or + household_demographics.hd_vehicle_count= 2) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Brownsville','Enterprise') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q69.sql new file mode 100644 index 00000000..a36944b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('NC','IN','TN') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q70.sql new file mode 100644 index 00000000..0453880e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1201 and 1201+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1201 and 1201+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q71.sql new file mode 100644 index 00000000..e1852365 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=11 + and d_year=2001 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=11 + and d_year=2001 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q72.sql new file mode 100644 index 00000000..6b0969a2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '>10000' + and d1.d_year = 2001 + and cd_marital_status = 'W' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q73.sql new file mode 100644 index 00000000..929bf084 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Appanoose County','San Miguel County','Klamath County','Nowata County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q74.sql new file mode 100644 index 00000000..83b5a34b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,1,3 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q75.sql new file mode 100644 index 00000000..d4e3650e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Home' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Home' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Home') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q76.sql new file mode 100644 index 00000000..39e0c7ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_promo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_promo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_ship_cdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_ship_cdemo_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q77.sql new file mode 100644 index 00000000..59b75712 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2002-08-17' as date) + and (cast('2002-08-17' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q78.sql new file mode 100644 index 00000000..35f34084 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2000 +order by + ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q79.sql new file mode 100644 index 00000000..3f41c224 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 4 or household_demographics.hd_vehicle_count > 4) + and date_dim.d_dow = 1 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q80.sql new file mode 100644 index 00000000..fb920f2e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-06' as date) + and (cast('2001-08-06' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-06' as date) + and (cast('2001-08-06' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-06' as date) + and (cast('2001-08-06' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q81.sql new file mode 100644 index 00000000..77445f21 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MO' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q82.sql new file mode 100644 index 00000000..4114ca8f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 1 and 1+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1999-06-22' as date) and (cast('1999-06-22' as date) + INTERVAL '60' DAY) + and i_manufact_id in (459,55,610,168) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q83.sql new file mode 100644 index 00000000..1e7004ed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-02-15',DATE '2001-08-15',DATE '2001-11-15'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-02-15',DATE '2001-08-15',DATE '2001-11-15'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '2001-02-15',DATE '2001-08-15',DATE '2001-11-15'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q84.sql new file mode 100644 index 00000000..e80e8fda --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Woodland' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 15482 + and ib_upper_bound <= 15482 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q85.sql new file mode 100644 index 00000000..90bcb6f5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2001 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('KY', 'AR', 'NC') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('VA', 'GA', 'IA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('UT', 'MN', 'WI') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q86.sql new file mode 100644 index 00000000..179dfaab --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1220 and 1220+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q87.sql new file mode 100644 index 00000000..0870fc47 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1198 and 1198+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1198 and 1198+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1198 and 1198+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q88.sql new file mode 100644 index 00000000..e5a989ce --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q89.sql new file mode 100644 index 00000000..d2fa614d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Music','Jewelry','Men') and + i_class in ('country','womens watch','shirts') + ) + or (i_category in ('Home','Electronics','Children') and + i_class in ('mattresses','automotive','infants') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q90.sql new file mode 100644 index 00000000..ab4e4937 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 14 and 14+1 + and household_demographics.hd_dep_count = 1 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q91.sql new file mode 100644 index 00000000..935153e8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 1999 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '0-500%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q92.sql new file mode 100644 index 00000000..268d93c7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 132 +and i_item_sk = ws_item_sk +and d_date between DATE '2000-03-19' and + (cast('2000-03-19' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2000-03-19' and + (cast('2000-03-19' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q93.sql new file mode 100644 index 00000000..fe670d07 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 67') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q94.sql new file mode 100644 index 00000000..b3544044 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-4-01' and + (cast('2001-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'CO' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q95.sql new file mode 100644 index 00000000..7e659a5c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2000-5-01' and + (cast('2000-5-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'TX' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q96.sql new file mode 100644 index 00000000..32241b04 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 7 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q97.sql new file mode 100644 index 00000000..284d31ff --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1184 and 1184 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1184 and 1184 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q98.sql new file mode 100644 index 00000000..68d248d1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Jewelry', 'Men', 'Music') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1998-05-20' as date) + and (cast('1998-05-20' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s7/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s7/q99.sql new file mode 100644 index 00000000..f799ad4e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s7/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1219 and 1219 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q01.sql new file mode 100644 index 00000000..1921afcd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =1999 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'IN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q02.sql new file mode 100644 index 00000000..5fe5d885 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q03.sql new file mode 100644 index 00000000..0af67143 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 498 + and dt.d_moy=12 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q04.sql new file mode 100644 index 00000000..c6c630fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_login +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q05.sql new file mode 100644 index 00000000..33a51cbf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('1999-08-24' as date) + and (cast('1999-08-24' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('1999-08-24' as date) + and (cast('1999-08-24' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('1999-08-24' as date) + and (cast('1999-08-24' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q06.sql new file mode 100644 index 00000000..543170ef --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2001 + and d_moy = 4 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q07.sql new file mode 100644 index 00000000..4a0d0bf2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'D' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q08.sql new file mode 100644 index 00000000..51f68afb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '21828','97442','38273','19462','92159','46359', + '51206','49569','49073','36584','60247', + '74504','18414','78356','31253','75392', + '54711','20313','26314','51726','59401', + '30343','36579','20141','51326','85772', + '46980','38387','47845','68917','44602', + '43932','49579','19703','84633','50891', + '79207','73898','83357','57761','88715', + '48809','15326','99386','83937','68108', + '38025','34013','85207','13986','28584', + '81491','20979','20769','12758','41756', + '91030','14009','23718','99223','20599', + '73278','48281','70693','19056','27399', + '22036','15266','63403','56037','16469', + '63001','14099','29517','73866','37826', + '73370','77448','89827','88589','22931', + '85779','32579','26086','46914','84197', + '30528','12008','19897','75110','56988', + '48679','71820','70662','85843','76695', + '85680','71249','89021','43052','47448', + '16933','11221','42508','27877','93990', + '36614','33878','25015','97924','40532', + '87087','77385','68090','96762','56521', + '44185','78237','75193','78601','26376', + '78223','62787','21220','46746','19488', + '53867','40250','76945','19144','48571', + '72439','86487','58158','11887','63439', + '36050','80166','91245','58910','48271', + '78493','97602','77691','53417','87627', + '12421','74092','90800','18250','70852', + '42310','29052','58900','98798','21318', + '69719','16164','12264','42193','64924', + '36166','44142','38452','44217','49553', + '25873','47908','22193','19530','63826', + '91545','29539','49246','11845','27697', + '67633','78448','44466','68680','56000', + '42414','99812','23712','43352','37369', + '63101','50512','13831','55570','30024', + '27078','23418','94434','34509','77823', + '33760','12735','27652','62779','68648', + '47861','97137','27463','86949','97445', + '62768','95684','10819','78295','43424', + '68093','80337','38208','12120','68812', + '38711','44879','87029','39229','12884', + '83171','58374','41542','71007','33849', + '92640','51272','77282','17604','23436', + '64026','23117','87905','67868','23090', + '87960','41815','24286','74636','87057', + '96913','64440','97009','65706','56892', + '83255','25288','67098','71230','94865', + '45817','54594','24783','57705','45963', + '29218','32354','18561','33689','47476', + '96438','49529','68828','41134','83910', + '93398','38966','87717','12108','71180', + '65614','67167','72735','33149','71698', + '76143','69375','89197','92881','91740', + '95074','80959','46190','85816','58796', + '23450','44633','50046','68978','17756', + '40001','29124','82592','38781','14182', + '40754','53476','98330','94638','97611', + '14488','70141','35004','60033','74766', + '90614','30090','73011','88519','74753', + '56964','12240','38183','94456','56001', + '95213','68609','20443','87114','41054', + '72701','92614','37355','47846','36491', + '93987','68741','59808','13527','97463', + '16856','60416','11895','61527','14650', + '22053','58702','57364','43592','43234', + '79390','14709','66784','89167','74998', + '39995','66444','84410','55743','81093', + '52833','44437','93025','41836','58488', + '39960','78071','19971','99014','23922', + '88558','10398','48921','32565','37296', + '34217','11031','24364','14380','15446', + '87118','88078','86498','88097','60230', + '82709','52229','78060','65198','17577', + '91468','56070','61860','24731','95991', + '30569','56525','97433','10539','21379', + '73704','86141','45326','20698','70960', + '61587','99650','70856','50057') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q09.sql new file mode 100644 index 00000000..c3eec87d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 217442009 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 437569119 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 32174528 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 234031305 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 365805856 + then (select avg(ss_ext_list_price) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q10.sql new file mode 100644 index 00000000..d56894c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Henry County','Effingham County','Attala County','Sacramento County','Granite County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 and 2+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 ANd 2+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_moy between 2 and 2+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q11.sql new file mode 100644 index 00000000..5b3bd9c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q12.sql new file mode 100644 index 00000000..22baa64b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Music', 'Men', 'Children') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-05-29' as date) + and (cast('2000-05-29' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q13.sql new file mode 100644 index 00000000..119911da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'U' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('SD', 'MT', 'NE') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IN', 'WV', 'IL') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('TX', 'OK', 'VA') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q14.sql new file mode 100644 index 00000000..461885fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 15) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 15) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q15.sql new file mode 100644 index 00000000..bd2496e3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q16.sql new file mode 100644 index 00000000..434f143a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2001-3-01' and + (cast('2001-3-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Bronx County','Mesa County','Walker County','Wadena County', + 'Franklin Parish' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q17.sql new file mode 100644 index 00000000..9501ed6e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '1998Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q18.sql new file mode 100644 index 00000000..8edf5222 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'M' and + cd1.cd_education_status = '2 yr Degree' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (8,4,9,6,2,7) and + d_year = 2002 and + ca_state in ('TN','KS','NC' + ,'FL','ME','TX','NJ') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q19.sql new file mode 100644 index 00000000..8172fe49 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=27 + and d_moy=11 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q20.sql new file mode 100644 index 00000000..800f2517 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Music', 'Home', 'Books') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2000-01-15' as date) + and (cast('2000-01-15' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q21.sql new file mode 100644 index 00000000..4e7982a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-05-09' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('2001-05-09' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('2001-05-09' as date) - INTERVAL '30' DAY) + and (cast ('2001-05-09' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q22.sql new file mode 100644 index 00000000..e0904bde --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1216 and 1216 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q23.sql new file mode 100644 index 00000000..a1025efe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1998 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1998 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1998,1998 + 1,1998 + 2,1998 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1,1998+2,1998+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1998 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q24.sql new file mode 100644 index 00000000..7f8fad75 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'misty' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 10 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'green' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q25.sql new file mode 100644 index 00000000..9ce6b4b4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_net_profit) as store_sales_profit + ,stddev_samp(sr_net_loss) as store_returns_loss + ,stddev_samp(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1999 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q26.sql new file mode 100644 index 00000000..a9658ee8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q27.sql new file mode 100644 index 00000000..b5f784a7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '2 yr Degree' and + d_year = 1998 and + s_state in ('IL','OH', 'MO', 'AL', 'SD', 'MI') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q28.sql new file mode 100644 index 00000000..6efa998f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 114 and 114+10 + or ss_coupon_amt between 16291 and 16291+1000 + or ss_wholesale_cost between 23 and 23+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 110 and 110+10 + or ss_coupon_amt between 6724 and 6724+1000 + or ss_wholesale_cost between 41 and 41+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 169 and 169+10 + or ss_coupon_amt between 4801 and 4801+1000 + or ss_wholesale_cost between 33 and 33+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 130 and 130+10 + or ss_coupon_amt between 15810 and 15810+1000 + or ss_wholesale_cost between 7 and 7+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 70 and 70+10 + or ss_coupon_amt between 16377 and 16377+1000 + or ss_wholesale_cost between 80 and 80+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 66 and 66+10 + or ss_coupon_amt between 12895 and 12895+1000 + or ss_wholesale_cost between 77 and 77+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q29.sql new file mode 100644 index 00000000..c2d5c613 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,stddev_samp(ss_quantity) as store_sales_quantity + ,stddev_samp(sr_return_quantity) as store_returns_quantity + ,stddev_samp(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q30.sql new file mode 100644 index 00000000..c38df50b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2002 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TX' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q31.sql new file mode 100644 index 00000000..19d44142 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2001 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2001 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2001 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2001 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2001 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2001 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q1_q2_increase; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q32.sql new file mode 100644 index 00000000..90555019 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 942 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-02-16' and + (cast('1998-02-16' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-02-16' and + (cast('1998-02-16' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q33.sql new file mode 100644 index 00000000..52e7af5e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q34.sql new file mode 100644 index 00000000..abc3c523 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '501-1000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_county in ('Mesa County','San Miguel County','Perry County','Fairfield County', + 'Orange County','West Feliciana Parish','Dauphin County','Essex County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q35.sql new file mode 100644 index 00000000..85559f2e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + max(cd_dep_count) aggone1, + sum(cd_dep_count) aggtwo1, + stddev_samp(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + max(cd_dep_employed_count) aggone2, + sum(cd_dep_employed_count) aggtwo2, + stddev_samp(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + max(cd_dep_college_count) aggone3, + sum(cd_dep_college_count) aggtwo3, + stddev_samp(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2000 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q36.sql new file mode 100644 index 00000000..4c2d15f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('MO','GA','WV','MN', + 'LA','NY','CO','FL') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q37.sql new file mode 100644 index 00000000..30be104f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 13 and 13 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-06-23' as date) and (cast('2002-06-23' as date) + INTERVAL '60' DAY) + and i_manufact_id in (774,897,735,680) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q38.sql new file mode 100644 index 00000000..efff13fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1216 and 1216 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1216 and 1216 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1216 and 1216 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q39.sql new file mode 100644 index 00000000..f8f8c13f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =1998 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=4 + and inv2.d_moy=4+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q40.sql new file mode 100644 index 00000000..7beacabd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-05-25' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1998-05-25' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1998-05-25' as date) - INTERVAL '30' DAY) + and (cast ('1998-05-25' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q41.sql new file mode 100644 index 00000000..bb9195ac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 884 and 884+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'cream' or i_color = 'metallic') and + (i_units = 'Lb' or i_units = 'Box') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'midnight' or i_color = 'cyan') and + (i_units = 'Tsp' or i_units = 'Cup') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'smoke' or i_color = 'mint') and + (i_units = 'Bunch' or i_units = 'Carton') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'white' or i_color = 'olive') and + (i_units = 'Dram' or i_units = 'Pound') and + (i_size = 'economy' or i_size = 'extra large') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'sandy' or i_color = 'frosted') and + (i_units = 'Tbl' or i_units = 'Oz') and + (i_size = 'economy' or i_size = 'extra large') + ) or + (i_category = 'Women' and + (i_color = 'green' or i_color = 'almond') and + (i_units = 'Gram' or i_units = 'Case') and + (i_size = 'large' or i_size = 'medium') + ) or + (i_category = 'Men' and + (i_color = 'floral' or i_color = 'salmon') and + (i_units = 'N/A' or i_units = 'Ton') and + (i_size = 'petite' or i_size = 'small') + ) or + (i_category = 'Men' and + (i_color = 'bisque' or i_color = 'steel') and + (i_units = 'Dozen' or i_units = 'Unknown') and + (i_size = 'economy' or i_size = 'extra large') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q42.sql new file mode 100644 index 00000000..b1fd1a46 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q43.sql new file mode 100644 index 00000000..68b895bf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -6 and + d_year = 1999 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q44.sql new file mode 100644 index 00000000..35e54577 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 68 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 68 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 68 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 68 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q45.sql new file mode 100644 index 00000000..fc55dc1e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 1999 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q46.sql new file mode 100644 index 00000000..46f46cbc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 2) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Greenwood','Sulphur Springs','Prospect','Walnut Grove','Pine Grove') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q47.sql new file mode 100644 index 00000000..3f6b0b08 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_brand + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q48.sql new file mode 100644 index 00000000..f7eedb1b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'W' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'U' + and + cd_education_status = 'Primary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'KS', 'GA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('SC', 'VA', 'ID') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MS', 'SD', 'MA') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q49.sql new file mode 100644 index 00000000..2949ea35 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q50.sql new file mode 100644 index 00000000..7fa6ff78 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2000 +and d2.d_moy = 9 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q51.sql new file mode 100644 index 00000000..517ca533 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1191 and 1191+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1191 and 1191+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q52.sql new file mode 100644 index 00000000..82f88375 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=1998 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q53.sql new file mode 100644 index 00000000..7e41db6f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1209,1209+1,1209+2,1209+3,1209+4,1209+5,1209+6,1209+7,1209+8,1209+9,1209+10,1209+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q54.sql new file mode 100644 index 00000000..d4fbbaa6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Books' + and i_class = 'self-help' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 3 + and d_year = 2002 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 2002 and d_moy = 3) + and (select distinct d_month_seq+3 + from date_dim where d_year = 2002 and d_moy = 3) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q55.sql new file mode 100644 index 00000000..d6989aba --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=60 + and d_moy=12 + and d_year=2001 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q56.sql new file mode 100644 index 00000000..27547eb2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('blanched','lawn','papaya')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('blanched','lawn','papaya')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('blanched','lawn','papaya')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 7 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q57.sql new file mode 100644 index 00000000..2af136cb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q58.sql new file mode 100644 index 00000000..6a54cea9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-02-13')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1998-02-13')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1998-02-13')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q59.sql new file mode 100644 index 00000000..fc3f3691 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1198 and 1198 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1198+ 12 and 1198 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q60.sql new file mode 100644 index 00000000..63a78516 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Music')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2002 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q61.sql new file mode 100644 index 00000000..9abfa542 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Jewelry' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2001 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Jewelry' + and s_gmt_offset = -7 + and d_year = 2001 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q62.sql new file mode 100644 index 00000000..9b6d88f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1176 and 1176 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q63.sql new file mode 100644 index 00000000..3329478c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1176,1176+1,1176+2,1176+3,1176+4,1176+5,1176+6,1176+7,1176+8,1176+9,1176+10,1176+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q64.sql new file mode 100644 index 00000000..f1d1d9a9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('chocolate','medium','pink','slate','grey','lime') and + i_current_price between 27 and 27 + 10 and + i_current_price between 27 + 1 and 27 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q65.sql new file mode 100644 index 00000000..b66b5591 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1220 and 1220+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1220 and 1220+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q66.sql new file mode 100644 index 00000000..326bdd2a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'PRIVATECARRIER' || ',' || 'BOXBUNDLES' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 9696 and 9696+28800 + and sm_carrier in ('PRIVATECARRIER','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'PRIVATECARRIER' || ',' || 'BOXBUNDLES' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_tax * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 1998 + and t_time between 9696 AND 9696+28800 + and sm_carrier in ('PRIVATECARRIER','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q67.sql new file mode 100644 index 00000000..cdc9e996 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1199 and 1199+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q68.sql new file mode 100644 index 00000000..8bbfaf34 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 9 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Oak Ridge','Georgetown') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q69.sql new file mode 100644 index 00000000..8a6c5d81 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('NH','LA','AK') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q70.sql new file mode 100644 index 00000000..233bd89a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1211 and 1211+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1211 and 1211+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q71.sql new file mode 100644 index 00000000..346613f7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=1999 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=1999 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=1999 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q72.sql new file mode 100644 index 00000000..dccc9c2c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '501-1000' + and d1.d_year = 2001 + and cd_marital_status = 'W' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q73.sql new file mode 100644 index 00000000..588be2e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Gogebic County','Sumner County','Barrow County','Nowata County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q74.sql new file mode 100644 index 00000000..444cb1c1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,sum(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2000,2000+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2000 + and t_s_secyear.year = 2000+1 + and t_w_firstyear.year = 2000 + and t_w_secyear.year = 2000+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 2,3,1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q75.sql new file mode 100644 index 00000000..102498da --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Jewelry' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Jewelry') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q76.sql new file mode 100644 index 00000000..400badd4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_web_page_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q77.sql new file mode 100644 index 00000000..4a2a557d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('1998-08-25' as date) + and (cast('1998-08-25' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q78.sql new file mode 100644 index 00000000..7cf5d4b7 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, ss_item_sk, ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=2001 +order by + ss_sold_year, ss_item_sk, ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q79.sql new file mode 100644 index 00000000..f2e1f5b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 6 or household_demographics.hd_vehicle_count > 2) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q80.sql new file mode 100644 index 00000000..6870606c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-05' as date) + and (cast('2000-08-05' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-05' as date) + and (cast('2000-08-05' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-05' as date) + and (cast('2000-08-05' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q81.sql new file mode 100644 index 00000000..5290778d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'NC' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q82.sql new file mode 100644 index 00000000..4b2e9166 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 45 and 45+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('1998-06-27' as date) and (cast('1998-06-27' as date) + INTERVAL '60' DAY) + and i_manufact_id in (878,60,241,348) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q83.sql new file mode 100644 index 00000000..582f2320 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-07',DATE '1998-11-13'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-07',DATE '1998-11-13'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1998-07-20',DATE '1998-10-07',DATE '1998-11-13'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q84.sql new file mode 100644 index 00000000..7755b6f9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Five Forks' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 39843 + and ib_upper_bound <= 39843 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q85.sql new file mode 100644 index 00000000..2d617368 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'W' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = '2 yr Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('KY', 'MT', 'TX') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('AL', 'NE', 'PA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('IL', 'MO', 'IA') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q86.sql new file mode 100644 index 00000000..431b3d18 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1190 and 1190+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q87.sql new file mode 100644 index 00000000..8ea3db2f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1206 and 1206+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1206 and 1206+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1206 and 1206+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q88.sql new file mode 100644 index 00000000..ac3af8b8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or + (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q89.sql new file mode 100644 index 00000000..64f7a5ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2000) and + ((i_category in ('Men','Home','Shoes') and + i_class in ('accessories','flatware','mens') + ) + or (i_category in ('Sports','Children','Electronics') and + i_class in ('fishing','infants','musical') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q90.sql new file mode 100644 index 00000000..595809d4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 14 and 14+1 + and household_demographics.hd_dep_count = 2 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q91.sql new file mode 100644 index 00000000..7c727390 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '>10000%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q92.sql new file mode 100644 index 00000000..91cad0dc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 738 +and i_item_sk = ws_item_sk +and d_date between DATE '2000-02-04' and + (cast('2000-02-04' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2000-02-04' and + (cast('2000-02-04' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q93.sql new file mode 100644 index 00000000..fe670d07 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 67') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q94.sql new file mode 100644 index 00000000..2ba4c7fa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2001-4-01' and + (cast('2001-4-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'NM' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q95.sql new file mode 100644 index 00000000..ff38621f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-2-01' and + (cast('2002-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q96.sql new file mode 100644 index 00000000..cb5c407f --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 15 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 0 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q97.sql new file mode 100644 index 00000000..4cc219a5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1201 and 1201 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1201 and 1201 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q98.sql new file mode 100644 index 00000000..cc35c069 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Music', 'Shoes', 'Home') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2002-01-08' as date) + and (cast('2002-01-08' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s8/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s8/q99.sql new file mode 100644 index 00000000..d28c2839 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s8/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1188 and 1188 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q01.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q01.sql new file mode 100644 index 00000000..206a46a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q01.sql @@ -0,0 +1,24 @@ +-- q01.sql + +with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_RETURN_AMT) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2002 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'NM' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q02.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q02.sql new file mode 100644 index 00000000..a3aaa0b9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q02.sql @@ -0,0 +1,59 @@ +-- q02.sql + +with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) x), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1999+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q03.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q03.sql new file mode 100644 index 00000000..238096f4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q03.sql @@ -0,0 +1,20 @@ +-- q03.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 359 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q04.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q04.sql new file mode 100644 index 00000000..1e3f5fa9 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q04.sql @@ -0,0 +1,115 @@ +-- q04.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 2000 + and t_s_secyear.dyear = 2000+1 + and t_c_firstyear.dyear = 2000 + and t_c_secyear.dyear = 2000+1 + and t_w_firstyear.dyear = 2000 + and t_w_secyear.dyear = 2000+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_preferred_cust_flag +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q05.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q05.sql new file mode 100644 index 00000000..c6cd1cdc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q05.sql @@ -0,0 +1,127 @@ +-- q05.sql + +with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2001-08-09' as date) + and (cast('2001-08-09' as date) + INTERVAL '14' DAY) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2001-08-09' as date) + and (cast('2001-08-09' as date) + INTERVAL '14' DAY) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2001-08-09' as date) + and (cast('2001-08-09' as date) + INTERVAL '14' DAY) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || s_store_id as id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || cp_catalog_page_id as id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q06.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q06.sql new file mode 100644 index 00000000..d21e70dd --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q06.sql @@ -0,0 +1,25 @@ +-- q06.sql + +select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 1999 + and d_moy = 5 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q07.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q07.sql new file mode 100644 index 00000000..6566cacc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q07.sql @@ -0,0 +1,20 @@ +-- q07.sql + +select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'D' and + cd_education_status = '2 yr Degree' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 1998 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q08.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q08.sql new file mode 100644 index 00000000..542c22c3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q08.sql @@ -0,0 +1,107 @@ +-- q08.sql + +select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '20223','75533','33634','10616','87354','80251', + '46225','91267','55682','87211','32293', + '50124','13955','51162','66695','81551', + '94621','89570','39412','85645','22186', + '77007','81176','79187','56317','83382', + '65128','94547','12834','16628','40803', + '56609','14770','23502','88132','69297', + '97886','66820','47049','71462','29293', + '57996','26453','65481','62750','61174', + '95527','18395','50915','43574','27600', + '40762','74017','26653','94531','69037', + '78284','72505','35254','10648','44656', + '86312','35741','90212','28902','18747', + '81776','12308','70572','76847','26341', + '14670','22510','59760','98052','67938', + '49350','52543','88014','56716','49448', + '11980','80479','98669','16914','43242', + '76799','44355','37600','10476','85791', + '42702','75530','98398','86315','18501', + '26597','49097','49578','74816','39981', + '39725','31095','37258','98119','75801', + '74018','50550','82351','68612','59639', + '28358','27852','11231','20119','89561', + '51720','49055','59848','66616','47586', + '23919','68549','66315','31230','56618', + '51930','71905','14574','76919','34452', + '77649','77043','94613','55115','81044', + '34552','37382','28803','76140','26939', + '15832','61819','64614','47622','70681', + '14633','68842','62099','59275','91756', + '16344','31828','10926','25700','54857', + '26918','84860','62808','19954','42293', + '24158','65573','49162','14497','34429', + '70342','57665','25614','71983','55779', + '82203','66186','52866','31961','90736', + '98962','65943','54232','50928','22581', + '16833','23857','67392','22721','72868', + '65892','45582','20834','66941','45296', + '83140','81931','22263','32978','70345', + '82344','49253','55367','72744','35351', + '14305','22245','13321','77294','52094', + '67921','67359','32612','83411','15684', + '74823','75785','50510','22269','75039', + '25635','94216','68174','75557','58792', + '36847','96553','58098','73949','80669', + '55346','53509','26115','92162','52447', + '11578','95651','59145','49593','93538', + '31637','81332','35296','45922','46423', + '95149','37354','17898','42073','52658', + '83323','51947','93227','94678','51462', + '87113','65897','23793','45271','79588', + '29013','37553','95314','74618','20533', + '23863','90039','68138','81824','27444', + '66611','40562','34428','23258','10816', + '64724','13507','74936','20336','84815', + '32527','24467','24121','98132','32711', + '37605','13123','70663','20172','17103', + '23048','37203','48935','63412','91401', + '57264','81791','39073','89428','96311', + '30240','96505','34500','25734','63524', + '99798','83241','39927','33067','82875', + '49042','66405','76855','54447','84623', + '51490','69861','44155','89690','47875', + '79505','64867','81654','54262','19977', + '37707','27010','52160','39495','32595', + '54874','85055','10490','99350','42643', + '64425','26063','95960','79099','32313', + '25177','97750','79958','96998','33201', + '14845','88959','17658','49105','45412', + '58690','38799','26849','80796','97858', + '68589','84666','99548','86520','17466', + '95045','28874','24844','48989','75513', + '26228','68434','36997','84472','26234', + '18891','63490','11726','96369','40976', + '54706','15487','14630','45328','78978', + '49631','70778','96455','42903','27104', + '25685','84812','43686','72140','28564', + '44967','28872','30209','90928','76210', + '81388','48199','12996','57801','40504', + '82721','10244','29636','48698') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2000 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q09.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q09.sql new file mode 100644 index 00000000..683bb919 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q09.sql @@ -0,0 +1,50 @@ +-- q09.sql + +select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 94687769 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 64748964 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 409128540 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 155605026 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 245830934 + then (select avg(ss_ext_discount_amt) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_profit) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q10.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q10.sql new file mode 100644 index 00000000..4d8643ce --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q10.sql @@ -0,0 +1,58 @@ +-- q10.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Henderson County','Fayette County','Shelby County','Venango County','Las Animas County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 ANd 4+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 4 and 4+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q11.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q11.sql new file mode 100644 index 00000000..84700d05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q11.sql @@ -0,0 +1,80 @@ +-- q11.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q12.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q12.sql new file mode 100644 index 00000000..98050ee8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q12.sql @@ -0,0 +1,33 @@ +-- q12.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Electronics', 'Jewelry', 'Books') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2000-05-09' as date) + and (cast('2000-05-09' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q13.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q13.sql new file mode 100644 index 00000000..f69361b5 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q13.sql @@ -0,0 +1,51 @@ +-- q13.sql + +select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'Unknown' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Advanced Degree' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = 'Secondary' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('AR', 'MN', 'IA') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('NE', 'IL', 'IN') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('LA', 'TX', 'TN') + and ss_net_profit between 50 and 250 + )) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q14.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q14.sql new file mode 100644 index 00000000..a70fd011 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q14.sql @@ -0,0 +1,209 @@ +-- q14.sql + +with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100; +with cross_items as +(select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1998 AND 1998 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1998 AND 1998 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1998 AND 1998 + 2) x + where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), + avg_sales as +(select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1998 and 1998 + 2) x) + select this_year.channel ty_channel + ,this_year.i_brand_id ty_brand + ,this_year.i_class_id ty_class + ,this_year.i_category_id ty_category + ,this_year.sales ty_sales + ,this_year.number_sales ty_number_sales + ,last_year.channel ly_channel + ,last_year.i_brand_id ly_brand + ,last_year.i_class_id ly_class + ,last_year.i_category_id ly_category + ,last_year.sales ly_sales + ,last_year.number_sales ly_number_sales + from + (select 'store' channel, i_brand_id,i_class_id,i_category_id + ,sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + 1 + and d_moy = 12 + and d_dom = 9) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year, + (select 'store' channel, i_brand_id,i_class_id + ,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_week_seq = (select d_week_seq + from date_dim + where d_year = 1998 + and d_moy = 12 + and d_dom = 9) + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year + where this_year.i_brand_id= last_year.i_brand_id + and this_year.i_class_id = last_year.i_class_id + and this_year.i_category_id = last_year.i_category_id + order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q15.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q15.sql new file mode 100644 index 00000000..65e5cfdb --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q15.sql @@ -0,0 +1,19 @@ +-- q15.sql + +select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q16.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q16.sql new file mode 100644 index 00000000..a841559b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q16.sql @@ -0,0 +1,30 @@ +-- q16.sql + +select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between DATE '2000-5-01' and + (cast('2000-5-01' as date) + INTERVAL '60' DAY) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'MN' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Oglethorpe County','Jefferson Davis Parish','Gogebic County','Richland County', + 'Wadena County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q17.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q17.sql new file mode 100644 index 00000000..4f3e0465 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q17.sql @@ -0,0 +1,44 @@ +-- q17.sql + +select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q18.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q18.sql new file mode 100644 index 00000000..958a6cb3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q18.sql @@ -0,0 +1,33 @@ +-- q18.sql + +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 catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Secondary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (1,6,11,5,10,7) and + d_year = 1998 and + ca_state in ('LA','KS','VA' + ,'FL','TN','MI','GA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q19.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q19.sql new file mode 100644 index 00000000..78cca25b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q19.sql @@ -0,0 +1,24 @@ +-- q19.sql + +select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=23 + and d_moy=12 + and d_year=1998 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q20.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q20.sql new file mode 100644 index 00000000..1fc804cf --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q20.sql @@ -0,0 +1,29 @@ +-- q20.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Children', 'Men', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-03-09' as date) + and (cast('2002-03-09' as date) + INTERVAL '30' DAY) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q21.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q21.sql new file mode 100644 index 00000000..99fd5e67 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q21.sql @@ -0,0 +1,29 @@ +-- q21.sql + +select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1998-06-07' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1998-06-07' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1998-06-07' as date) - INTERVAL '30' DAY) + and (cast ('1998-06-07' as date) + INTERVAL '30' DAY) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q22.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q22.sql new file mode 100644 index 00000000..01797993 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q22.sql @@ -0,0 +1,19 @@ +-- q22.sql + +select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1220 and 1220 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q23.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q23.sql new file mode 100644 index 00000000..f89db70a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q23.sql @@ -0,0 +1,106 @@ +-- q23.sql + +with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 1999 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 1999 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) x + limit 100; +with frequent_ss_items as +(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1,1999+2,1999+3) + group by c_customer_sk)), + best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * + from max_store_sales)) + select c_last_name,c_first_name,sales + from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + from catalog_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and cs_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + from web_sales + ,customer + ,date_dim + where d_year = 1999 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) + and ws_bill_customer_sk = c_customer_sk + group by c_last_name,c_first_name) x + order by c_last_name,c_first_name,sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q24.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q24.sql new file mode 100644 index 00000000..99dac297 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q24.sql @@ -0,0 +1,106 @@ +-- q24.sql + +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'rose' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; +with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_profit) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip + and s_market_id = 9 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'khaki' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q25.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q25.sql new file mode 100644 index 00000000..3242b50c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q25.sql @@ -0,0 +1,47 @@ +-- q25.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,sum(ss_net_profit) as store_sales_profit + ,sum(sr_net_loss) as store_returns_loss + ,sum(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 2000 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q26.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q26.sql new file mode 100644 index 00000000..17288963 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q26.sql @@ -0,0 +1,20 @@ +-- q26.sql + +select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q27.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q27.sql new file mode 100644 index 00000000..07453442 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q27.sql @@ -0,0 +1,22 @@ +-- q27.sql + +select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'M' and + cd_education_status = '2 yr Degree' and + d_year = 1999 and + s_state in ('SD','NY', 'KS', 'WA', 'MN', 'OK') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q28.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q28.sql new file mode 100644 index 00000000..59a1e3c4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q28.sql @@ -0,0 +1,52 @@ +-- q28.sql + +select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 164 and 164+10 + or ss_coupon_amt between 2520 and 2520+1000 + or ss_wholesale_cost between 56 and 56+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 145 and 145+10 + or ss_coupon_amt between 14763 and 14763+1000 + or ss_wholesale_cost between 53 and 53+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 33 and 33+10 + or ss_coupon_amt between 6466 and 6466+1000 + or ss_wholesale_cost between 29 and 29+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 170 and 170+10 + or ss_coupon_amt between 7949 and 7949+1000 + or ss_wholesale_cost between 13 and 13+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 126 and 126+10 + or ss_coupon_amt between 4538 and 4538+1000 + or ss_wholesale_cost between 78 and 78+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 138 and 138+10 + or ss_coupon_amt between 9369 and 9369+1000 + or ss_wholesale_cost between 54 and 54+20)) B6 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q29.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q29.sql new file mode 100644 index 00000000..d8d960ea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q29.sql @@ -0,0 +1,46 @@ +-- q29.sql + +select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,min(ss_quantity) as store_sales_quantity + ,min(sr_return_quantity) as store_returns_quantity + ,min(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 2000 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (2000,2000+1,2000+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q30.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q30.sql new file mode 100644 index 00000000..2b64d70a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q30.sql @@ -0,0 +1,30 @@ +-- q30.sql + +with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =1999 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MS' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q31.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q31.sql new file mode 100644 index 00000000..69f8fbf0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q31.sql @@ -0,0 +1,51 @@ +-- q31.sql + +with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 2002 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 2002 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 2002 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 2002 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 2002 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =2002 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by ss1.ca_county; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q32.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q32.sql new file mode 100644 index 00000000..43b8747e --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q32.sql @@ -0,0 +1,27 @@ +-- q32.sql + +select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 261 +and i_item_sk = cs_item_sk +and d_date between DATE '1998-03-15' and + (cast('1998-03-15' 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 + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between DATE '1998-03-15' and + (cast('1998-03-15' as date) + INTERVAL '90' DAY) + and d_date_sk = cs_sold_date_sk + ) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q33.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q33.sql new file mode 100644 index 00000000..b0290615 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q33.sql @@ -0,0 +1,74 @@ +-- q33.sql + +with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Home')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 2 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q34.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q34.sql new file mode 100644 index 00000000..d43a3def --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q34.sql @@ -0,0 +1,30 @@ +-- q34.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = 'Unknown') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Karnes County','Pulaski County','Mariposa County','Chambers County', + 'Salem County','Cocke County','Warren County','Levy County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q35.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q35.sql new file mode 100644 index 00000000..aab84b01 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q35.sql @@ -0,0 +1,57 @@ +-- q35.sql + +select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + sum(cd_dep_count) aggone1, + avg(cd_dep_count) aggtwo1, + avg(cd_dep_count) aggthree1, + cd_dep_employed_count, + count(*) cnt2, + sum(cd_dep_employed_count) aggone2, + avg(cd_dep_employed_count) aggtwo2, + avg(cd_dep_employed_count) aggthree2, + cd_dep_college_count, + count(*) cnt3, + sum(cd_dep_college_count) aggone3, + avg(cd_dep_college_count) aggtwo3, + avg(cd_dep_college_count) aggthree3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q36.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q36.sql new file mode 100644 index 00000000..f62f22a8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q36.sql @@ -0,0 +1,29 @@ +-- q36.sql + +select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2001 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('GA','KS','NM','AL', + 'GA','PA','MI','TN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q37.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q37.sql new file mode 100644 index 00000000..590833ad --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q37.sql @@ -0,0 +1,16 @@ +-- q37.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 33 and 33 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2000-05-19' as date) and (cast('2000-05-19' as date) + INTERVAL '60' DAY) + and i_manufact_id in (759,706,891,701) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q38.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q38.sql new file mode 100644 index 00000000..fa522a9a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q38.sql @@ -0,0 +1,22 @@ +-- q38.sql + +select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1179 and 1179 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1179 and 1179 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1179 and 1179 + 11 +) hot_cust +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q39.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q39.sql new file mode 100644 index 00000000..a0923bea --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q39.sql @@ -0,0 +1,53 @@ +-- q39.sql + +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2002 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 + and inv1.cov > 1.5 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q40.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q40.sql new file mode 100644 index 00000000..7f8b4fec --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q40.sql @@ -0,0 +1,27 @@ +-- q40.sql + +select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-05-10' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('1999-05-10' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('1999-05-10' as date) - INTERVAL '30' DAY) + and (cast ('1999-05-10' as date) + INTERVAL '30' DAY) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q41.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q41.sql new file mode 100644 index 00000000..afd171d8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q41.sql @@ -0,0 +1,51 @@ +-- q41.sql + +select distinct(i_product_name) + from item i1 + where i_manufact_id between 973 and 973+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'bisque' or i_color = 'peru') and + (i_units = 'Box' or i_units = 'Unknown') and + (i_size = 'extra large' or i_size = 'medium') + ) or + (i_category = 'Women' and + (i_color = 'ivory' or i_color = 'chocolate') and + (i_units = 'Tsp' or i_units = 'Pound') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'maroon' or i_color = 'light') and + (i_units = 'Tbl' or i_units = 'Dram') and + (i_size = 'petite' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'cornflower' or i_color = 'rosy') and + (i_units = 'Dozen' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'medium') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'misty' or i_color = 'pale') and + (i_units = 'Carton' or i_units = 'Gram') and + (i_size = 'extra large' or i_size = 'medium') + ) or + (i_category = 'Women' and + (i_color = 'cornsilk' or i_color = 'violet') and + (i_units = 'Bundle' or i_units = 'Case') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'white' or i_color = 'chartreuse') and + (i_units = 'Oz' or i_units = 'Each') and + (i_size = 'petite' or i_size = 'economy') + ) or + (i_category = 'Men' and + (i_color = 'firebrick' or i_color = 'purple') and + (i_units = 'Gross' or i_units = 'Lb') and + (i_size = 'extra large' or i_size = 'medium') + )))) > 0 + order by i_product_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q42.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q42.sql new file mode 100644 index 00000000..b1fd1a46 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q42.sql @@ -0,0 +1,21 @@ +-- q42.sql + +select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q43.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q43.sql new file mode 100644 index 00000000..f52d0818 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q43.sql @@ -0,0 +1,18 @@ +-- q43.sql + +select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q44.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q44.sql new file mode 100644 index 00000000..7645a085 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q44.sql @@ -0,0 +1,34 @@ +-- q44.sql + +select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 83 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 83 + and ss_customer_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 83 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 83 + and ss_customer_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q45.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q45.sql new file mode 100644 index 00000000..4452a1c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q45.sql @@ -0,0 +1,19 @@ +-- q45.sql + +select ca_zip, ca_state, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + group by ca_zip, ca_state + order by ca_zip, ca_state + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q46.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q46.sql new file mode 100644 index 00000000..e639f5aa --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q46.sql @@ -0,0 +1,34 @@ +-- q46.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 2 or + household_demographics.hd_vehicle_count= 1) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Jamestown','Smithville','Unionville','Troy','Providence') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q47.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q47.sql new file mode 100644 index 00000000..edd3fe1d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q47.sql @@ -0,0 +1,50 @@ +-- q47.sql + +with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.i_category + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q48.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q48.sql new file mode 100644 index 00000000..ebcfc444 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q48.sql @@ -0,0 +1,66 @@ +-- q48.sql + +select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 1999 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = 'Primary' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('TX', 'FL', 'PA') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('IL', 'WI', 'MI') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('NY', 'MN', 'KY') + and ss_net_profit between 50 and 25000 + ) + ) +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q49.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q49.sql new file mode 100644 index 00000000..41429035 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q49.sql @@ -0,0 +1,128 @@ +-- q49.sql + +select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1999 + and d_moy = 12 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) x + order by 1,4,5,2 + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q50.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q50.sql new file mode 100644 index 00000000..a77af95c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q50.sql @@ -0,0 +1,58 @@ +-- q50.sql + +select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 1999 +and d2.d_moy = 10 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q51.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q51.sql new file mode 100644 index 00000000..fbf73af4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q51.sql @@ -0,0 +1,44 @@ +-- q51.sql + +WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1186 and 1186+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1186 and 1186+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q52.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q52.sql new file mode 100644 index 00000000..4533bf32 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q52.sql @@ -0,0 +1,21 @@ +-- q52.sql + +select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1998 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q53.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q53.sql new file mode 100644 index 00000000..f1770da1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q53.sql @@ -0,0 +1,27 @@ +-- q53.sql + +select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1213,1213+1,1213+2,1213+3,1213+4,1213+5,1213+6,1213+7,1213+8,1213+9,1213+10,1213+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q54.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q54.sql new file mode 100644 index 00000000..16789cf3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q54.sql @@ -0,0 +1,55 @@ +-- q54.sql + +with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Children' + and i_class = 'toddlers' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 7 + and d_year = 1998 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1998 and d_moy = 7) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1998 and d_moy = 7) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q55.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q55.sql new file mode 100644 index 00000000..7a1d7fe1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q55.sql @@ -0,0 +1,13 @@ +-- q55.sql + +select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=17 + and d_moy=12 + and d_year=2001 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q56.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q56.sql new file mode 100644 index 00000000..e230deed --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q56.sql @@ -0,0 +1,68 @@ +-- q56.sql + +with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('seashell','light','almond')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 6 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('seashell','light','almond')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 6 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('seashell','light','almond')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 6 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -7 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q57.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q57.sql new file mode 100644 index 00000000..ccb768d1 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q57.sql @@ -0,0 +1,47 @@ +-- q57.sql + +with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, sum_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q58.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q58.sql new file mode 100644 index 00000000..15f630e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q58.sql @@ -0,0 +1,64 @@ +-- q58.sql + +with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-03-19')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = DATE '1999-03-19')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = DATE '1999-03-19')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q59.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q59.sql new file mode 100644 index 00000000..17e80959 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q59.sql @@ -0,0 +1,43 @@ +-- q59.sql + +with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1188 and 1188 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + ss_store_sk = s_store_sk and + d_month_seq between 1188+ 12 and 1188 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q60.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q60.sql new file mode 100644 index 00000000..9cdbd4c6 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q60.sql @@ -0,0 +1,77 @@ +-- q60.sql + +with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 9 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 9 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 9 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q61.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q61.sql new file mode 100644 index 00000000..352fe8bc --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q61.sql @@ -0,0 +1,43 @@ +-- q61.sql + +select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 11) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and s_gmt_offset = -7 + and d_year = 1999 + and d_moy = 11) all_sales +order by promotions, total +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q62.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q62.sql new file mode 100644 index 00000000..cb8e243c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q62.sql @@ -0,0 +1,34 @@ +-- q62.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1194 and 1194 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q63.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q63.sql new file mode 100644 index 00000000..08f50261 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q63.sql @@ -0,0 +1,28 @@ +-- q63.sql + +select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1186,1186+1,1186+2,1186+3,1186+4,1186+5,1186+6,1186+7,1186+8,1186+9,1186+10,1186+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q64.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q64.sql new file mode 100644 index 00000000..30b80e75 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q64.sql @@ -0,0 +1,120 @@ +-- q64.sql + +with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('magenta','deep','royal','almond','dim','turquoise') and + i_current_price between 25 and 25 + 10 and + i_current_price between 25 + 1 and 25 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 2000 and + cs2.syear = 2000 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q65.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q65.sql new file mode 100644 index 00000000..647cb5a3 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q65.sql @@ -0,0 +1,28 @@ +-- q65.sql + +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1179 and 1179+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1179 and 1179+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q66.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q66.sql new file mode 100644 index 00000000..23fde3e8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q66.sql @@ -0,0 +1,219 @@ +-- q66.sql + +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'DIAMOND' || ',' || 'TBS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_list_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_list_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_list_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_list_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_list_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_list_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_list_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_list_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_list_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_list_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_list_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_list_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 38498 and 38498+28800 + and sm_carrier in ('DIAMOND','TBS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,'DIAMOND' || ',' || 'TBS' as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_sales_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_profit * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_profit * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_profit * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_profit * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_profit * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_profit * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_profit * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_profit * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_profit * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_profit * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_profit * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_profit * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2002 + and t_time between 38498 AND 38498+28800 + and sm_carrier in ('DIAMOND','TBS') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q67.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q67.sql new file mode 100644 index 00000000..1ccf448d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q67.sql @@ -0,0 +1,43 @@ +-- q67.sql + +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1205 and 1205+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q68.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q68.sql new file mode 100644 index 00000000..6e50a9d2 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q68.sql @@ -0,0 +1,41 @@ +-- q68.sql + +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 1 or + household_demographics.hd_vehicle_count= 2) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Cloverdale','Oakdale') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q69.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q69.sql new file mode 100644 index 00000000..aeb176b0 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q69.sql @@ -0,0 +1,46 @@ +-- q69.sql + +select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('SD','TX','NC') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2004 and + d_moy between 2 and 2+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q70.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q70.sql new file mode 100644 index 00000000..3c23c8fe --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q70.sql @@ -0,0 +1,37 @@ +-- q70.sql + +select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1202 and 1202+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1202 and 1202+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q71.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q71.sql new file mode 100644 index 00000000..011aa50b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q71.sql @@ -0,0 +1,39 @@ +-- q71.sql + +select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=1998 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=1998 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=1998 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + ; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q72.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q72.sql new file mode 100644 index 00000000..015c7335 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q72.sql @@ -0,0 +1,28 @@ +-- q72.sql + +select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and d3.d_date > d1.d_date + INTERVAL '5' DAY + and hd_buy_potential = '1001-5000' + and d1.d_year = 1998 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q73.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q73.sql new file mode 100644 index 00000000..7e3ac287 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q73.sql @@ -0,0 +1,27 @@ +-- q73.sql + +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_county in ('Jefferson Davis Parish','Harding County','Orange County','Pipestone County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q74.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q74.sql new file mode 100644 index 00000000..609e5162 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q74.sql @@ -0,0 +1,60 @@ +-- q74.sql + +with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,min(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (2001,2001+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 2001 + and t_s_secyear.year = 2001+1 + and t_w_firstyear.year = 2001 + and t_w_secyear.year = 2001+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 3,1,2 +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q75.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q75.sql new file mode 100644 index 00000000..8c643591 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q75.sql @@ -0,0 +1,69 @@ +-- q75.sql + +WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Music' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Music' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Music') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=1999 + AND prev_yr.d_year=1999-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q76.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q76.sql new file mode 100644 index 00000000..dfc32674 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q76.sql @@ -0,0 +1,23 @@ +-- q76.sql + +select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_store_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_store_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_bill_hdemo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_warehouse_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q77.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q77.sql new file mode 100644 index 00000000..2114382a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q77.sql @@ -0,0 +1,107 @@ +-- q77.sql + +with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2001-08-19' as date) + and (cast('2001-08-19' as date) + INTERVAL '30' DAY) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q78.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q78.sql new file mode 100644 index 00000000..ce68f644 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q78.sql @@ -0,0 +1,57 @@ +-- q78.sql + +with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null + group by d_year, ss_item_sk, ss_customer_sk + ) + select +ss_sold_year, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1998 +order by + ss_sold_year, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q79.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q79.sql new file mode 100644 index 00000000..9b120b33 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q79.sql @@ -0,0 +1,22 @@ +-- q79.sql + +select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 0 or household_demographics.hd_vehicle_count > 2) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q80.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q80.sql new file mode 100644 index 00000000..5e00c624 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q80.sql @@ -0,0 +1,95 @@ +-- q80.sql + +with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('1998-08-13' as date) + and (cast('1998-08-13' as date) + INTERVAL '30' DAY) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('1998-08-13' as date) + and (cast('1998-08-13' as date) + INTERVAL '30' DAY) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('1998-08-13' as date) + and (cast('1998-08-13' as date) + INTERVAL '30' DAY) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , 'store' || store_id as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , 'catalog_page' || catalog_page_id as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , 'web_site' || web_site_id as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q81.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q81.sql new file mode 100644 index 00000000..f705dc05 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q81.sql @@ -0,0 +1,30 @@ +-- q81.sql + +with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2002 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'MN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q82.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q82.sql new file mode 100644 index 00000000..e28aed16 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q82.sql @@ -0,0 +1,16 @@ +-- q82.sql + +select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 2 and 2+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) + INTERVAL '60' DAY) + and i_manufact_id in (852,878,870,3) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q83.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q83.sql new file mode 100644 index 00000000..5bc7d21c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q83.sql @@ -0,0 +1,66 @@ +-- q83.sql + +with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-28',DATE '1999-08-25',DATE '1999-11-15'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-28',DATE '1999-08-25',DATE '1999-11-15'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in (DATE '1999-01-28',DATE '1999-08-25',DATE '1999-11-15'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q84.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q84.sql new file mode 100644 index 00000000..660fe42a --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q84.sql @@ -0,0 +1,20 @@ +-- q84.sql + +select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Salem' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 30253 + and ib_upper_bound <= 30253 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q85.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q85.sql new file mode 100644 index 00000000..df36e49c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q85.sql @@ -0,0 +1,83 @@ +-- q85.sql + +select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 2002 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'M' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Secondary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Unknown' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('MT', 'AL', 'TX') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('NC', 'GA', 'WI') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('WY', 'IL', 'NY') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q86.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q86.sql new file mode 100644 index 00000000..97c18db4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q86.sql @@ -0,0 +1,25 @@ +-- q86.sql + +select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1194 and 1194+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q87.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q87.sql new file mode 100644 index 00000000..6f0c99e4 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q87.sql @@ -0,0 +1,22 @@ +-- q87.sql + +select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1178 and 1178+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1178 and 1178+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1178 and 1178+11) +) cool_cust +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q88.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q88.sql new file mode 100644 index 00000000..7279ee07 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q88.sql @@ -0,0 +1,93 @@ +-- q88.sql + +select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2) or + (household_demographics.hd_dep_count = 2 and household_demographics.hd_vehicle_count<=2+2)) + and store.s_store_name = 'ese') s8 +; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q89.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q89.sql new file mode 100644 index 00000000..55918b82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q89.sql @@ -0,0 +1,27 @@ +-- q89.sql + +select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Music','Electronics','Shoes') and + i_class in ('country','wireless','womens') + ) + or (i_category in ('Sports','Books','Men') and + i_class in ('football','history','shirts') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q90.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q90.sql new file mode 100644 index 00000000..8b0b7dd8 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q90.sql @@ -0,0 +1,21 @@ +-- q90.sql + +select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 6 and 6+1 + and household_demographics.hd_dep_count = 9 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 18 and 18+1 + and household_demographics.hd_dep_count = 9 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q91.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q91.sql new file mode 100644 index 00000000..66f2992b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q91.sql @@ -0,0 +1,30 @@ +-- q91.sql + +select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2002 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like '>10000%' +and ca_gmt_offset = -6 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q92.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q92.sql new file mode 100644 index 00000000..1617a120 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q92.sql @@ -0,0 +1,29 @@ +-- q92.sql + +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 597 +and i_item_sk = ws_item_sk +and d_date between DATE '2002-01-25' and + (cast('2002-01-25' as date) + INTERVAL '90' DAY) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between DATE '2002-01-25' and + (cast('2002-01-25' as date) + INTERVAL '90' DAY) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q93.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q93.sql new file mode 100644 index 00000000..5cfc9926 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q93.sql @@ -0,0 +1,17 @@ +-- q93.sql + +select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 71') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q94.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q94.sql new file mode 100644 index 00000000..e20c45ac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q94.sql @@ -0,0 +1,28 @@ +-- q94.sql + +select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '1999-2-01' and + (cast('1999-2-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'NY' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q95.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q95.sql new file mode 100644 index 00000000..9729c57d --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q95.sql @@ -0,0 +1,31 @@ +-- q95.sql + +with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between DATE '2002-3-01' and + (cast('2002-3-01' as date) + INTERVAL '60' DAY) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'IN' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q96.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q96.sql new file mode 100644 index 00000000..76c77a9b --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q96.sql @@ -0,0 +1,15 @@ +-- q96.sql + +select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 16 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 3 + and store.s_store_name = 'ese' +order by count(*) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q97.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q97.sql new file mode 100644 index 00000000..88eb3f1c --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q97.sql @@ -0,0 +1,24 @@ +-- q97.sql + +with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q98.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q98.sql new file mode 100644 index 00000000..7efdf851 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q98.sql @@ -0,0 +1,32 @@ +-- q98.sql + +select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Electronics', 'Sports', 'Home') + and ss_sold_date_sk = d_date_sk + and d_date between cast('2001-04-15' as date) + and (cast('2001-04-15' as date) + INTERVAL '30' DAY) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio; diff --git a/benchmarks/tpc-ds/queries_v2/10000/s9/q99.sql b/benchmarks/tpc-ds/queries_v2/10000/s9/q99.sql new file mode 100644 index 00000000..f1db56ac --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/10000/s9/q99.sql @@ -0,0 +1,34 @@ +-- q99.sql + +select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1213 and 1213 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100; diff --git a/benchmarks/tpc-ds/queries_v2/README.md b/benchmarks/tpc-ds/queries_v2/README.md new file mode 100644 index 00000000..88813376 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/README.md @@ -0,0 +1,45 @@ +TPC-DS Query Generation Information +==================================== +As per TPC-DS Specification v4.0.0 at https://www.tpc.org/TPC_Documents_Current_Versions/pdf/TPC-DS_v4.0.0.pdf + +- Engine: presto +- Scale Factor: 1 / 1000 / 10000 (in GB) +- Maximum Stream ID: 20 (generates streams s0 to s20, total 21 streams) +- Random Seed: 01271612345 +- Include Variants: false + +Sample Output Structure for 10000 +--------------------------------- +``` +10000/ + s0/ + s1/ + s2/ + ... + s20/ +``` +Each stream directory contains: +- qNN.sql: Individual query files (NN = 01-99, e.g., q01.sql, q10.sql) + +Template Fixes Applied: +------------------------ +- 40 total fixes for Presto C++ compatibility +- Date arithmetic converted to INTERVAL syntax +- Subquery aliases added where required +- See [TPCDS_FIXES_SUMMARY_PRESTO.md](TPCDS_FIXES_SUMMARY_PRESTO.md) for complete details + +Notes: +------ +- Seed format per TPC-DS spec: mmddhhmmsss (timestamp of load end time) +- Each stream has different query parameters because of different seed +- All queries for all 21 streams were generated using TPC-DS provided dsqgen tool at one go +- All queries were tested with IBM watsonx.data Presto C++ +- Queries in stream s0 are to be used for power run aka single-stream run +- Queries in stream s1 through sN are to be used for throughput test 1 with N streams +- Queries in stream sN+1 through s2*N are to be used for throughput test 2 with N streams +- Queries in a particular stream must be run in exact sequence as mentioned in the specification pdf Appendix D: Query Ordering + +For more information, see: +- TPC-DS Specification v4.0.0 at https://www.tpc.org/TPC_Documents_Current_Versions/pdf/TPC-DS_v4.0.0.pdf +- [TPCDS_FIXES_SUMMARY_PRESTO.md](TPCDS_FIXES_SUMMARY_PRESTO.md) + diff --git a/benchmarks/tpc-ds/queries_v2/TPCDS_FIXES_SUMMARY_PRESTO.md b/benchmarks/tpc-ds/queries_v2/TPCDS_FIXES_SUMMARY_PRESTO.md new file mode 100644 index 00000000..aa4b6f82 --- /dev/null +++ b/benchmarks/tpc-ds/queries_v2/TPCDS_FIXES_SUMMARY_PRESTO.md @@ -0,0 +1,482 @@ +# TPC-DS Template Fixes for IBM watsonx.data Presto C++ + +## Summary + +All TPC-DS query templates have been audited and fixed for compatibility with IBM watsonx.data Presto C++. This document summarizes all changes made to ensure production-ready benchmarking. + +--- + +## Complete List of Fixes Applied + +| # | File | Line | Issue | Fix Applied | Source | +|---|------|------|-------|-------------|--------| +| 1 | **netezza.tpl** | 38 | Missing _END definition | Added `define _END = "";` | Template requirement | +| 2 | **query2.tpl** | 47 | Missing subquery alias | Added `) x),` after UNION ALL | Presto requirement | +| 3 | **query14.tpl** | 70 | Missing subquery alias | Added `) x` after INTERSECT subquery | Presto requirement | +| 4 | **query22a.tpl** | 48,51,53 | Warehouse join + invalid GROUP BY | Removed warehouse table and GROUP BY | GitHub Issue #31 | +| 5 | **query23.tpl** | 87,142 | Missing subquery aliases | Added `) x` after both UNION ALL subqueries | Presto requirement | +| 6 | **query49.tpl** | 162 | Missing subquery alias | Added `) x` after closing parenthesis | Presto requirement | +| 7 | **query51a.tpl** | 86 | Missing subquery alias | Added `) vx` after closing parenthesis | Presto requirement | +| 8 | **query77a.tpl** | 76 | Missing comma in SELECT | Added `,` after cr_call_center_sk | GitHub Issue #43 | +| 9 | **query58.tpl** | 50,64,78 | Date literal comparison | Changed `d_date = '[DATE]'` to `d_date = DATE '[DATE]'` | Presto C++ requirement | +| 10 | **query16.tpl** | 57 | Date literal in BETWEEN | Changed `d_date between '[DATE]'` to `d_date between DATE '[DATE]'` | Presto C++ requirement | +| 11 | **query32.tpl** | 48,60 | Date literal in BETWEEN | Changed `d_date between '[DATE]'` to `d_date between DATE '[DATE]'` | Presto C++ requirement | +| 12 | **query92.tpl** | 50,62 | Date literal in BETWEEN | Changed `d_date between '[DATE]'` to `d_date between DATE '[DATE]'` | Presto C++ requirement | +| 13 | **query94.tpl** | 51 | Date literal in BETWEEN | Changed `d_date between '[DATE]'` to `d_date between DATE '[DATE]'` | Presto C++ requirement | +| 14 | **query95.tpl** | 56 | Date literal in BETWEEN | Changed `d_date between '[DATE]'` to `d_date between DATE '[DATE]'` | Presto C++ requirement | +| 15 | **query72.tpl** | 60 | Date arithmetic without INTERVAL | Changed `d1.d_date + 5` to `d1.d_date + INTERVAL '5' DAY` | Presto C++ requirement | +| 16 | **query83.tpl** | 54,70,86 | Date literals in IN clause | Changed `('[DATE]','[DATE]','[DATE]')` to `(DATE '[DATE]',DATE '[DATE]',DATE '[DATE]')` | Presto C++ requirement | +| 17-37 | **21 query templates** | Multiple | Date arithmetic not Presto-compatible | Changed `date + N` to `date + INTERVAL 'N' DAY` | Presto C++ requirement | +| 38-40 | **3 variant templates** | Multiple | Date arithmetic not Presto-compatible | Changed `cast(...) + N` to `cast(...) + INTERVAL 'N' DAY` | Presto C++ requirement | + +--- + +## Files Modified + +### query_templates/ +- ✅ **netezza.tpl** - Added _END definition for template compatibility +- ✅ **query2.tpl** - Added subquery alias 'x' for UNION ALL result +- ✅ **query14.tpl** - Added subquery alias 'x' after INTERSECT subquery +- ✅ **query23.tpl** - Added subquery alias 'x' for both UNION ALL query variants +- ✅ **query49.tpl** - Added subquery alias 'x' for derived table +- ✅ **query58.tpl** - Fixed date literal comparison (3 occurrences) +- ✅ **5 templates with date BETWEEN** - Fixed date literals in BETWEEN clauses: + - query16.tpl (1 occurrence), query32.tpl (2 occurrences), query92.tpl (2 occurrences) + - query94.tpl (1 occurrence), query95.tpl (1 occurrence) +- ✅ **21 templates with date arithmetic** - Fixed for Presto C++ compatibility: + - query5.tpl, query12.tpl, query16.tpl, query20.tpl, query21.tpl + - query30.tpl, query32.tpl, query37.tpl, query40.tpl, query50.tpl + - query52.tpl, query58.tpl, query72.tpl, query77.tpl, query80.tpl + - query82.tpl, query83.tpl, query92.tpl, query94.tpl, query95.tpl, query98.tpl + +### query_variants/ +- ✅ **query22a.tpl** - Removed unnecessary warehouse join and invalid GROUP BY +- ✅ **query51a.tpl** - Added subquery alias 'vx' for inner subquery +- ✅ **query77a.tpl** - Added missing comma in SELECT statement +- ✅ **query5a.tpl** - Fixed date arithmetic for Presto C++ (3 occurrences) +- ✅ **query77a.tpl** - Fixed date arithmetic for Presto C++ (6 occurrences) +- ✅ **query80a.tpl** - Fixed date arithmetic for Presto C++ (3 occurrences) + +--- + +## Detailed Fix Descriptions + +### 1. netezza.tpl - Template Definition +**Issue**: Missing `_END` substitution parameter +**Fix**: Added `define _END = "";` at line 38 +**Impact**: Enables proper query generation from templates + +### 2. query2.tpl - Subquery Alias +**Issue**: UNION ALL result used as derived table without alias +**Before**: +```sql +from (select ... from web_sales + union all + select ... from catalog_sales)) +``` +**After**: +```sql +from (select ... from web_sales + union all + select ... from catalog_sales) x) +``` +**Impact**: Presto requires all derived tables to have aliases + +### 3. query14.tpl - Subquery Alias +**Issue**: INTERSECT result used as derived table without alias +**Before**: +```sql +select ... from ( + select ... from catalog_sales + intersect + select ... from web_sales) +where i_brand_id = brand_id +``` +**After**: +```sql +select ... from ( + select ... from catalog_sales + intersect + select ... from web_sales) x +where i_brand_id = brand_id +``` +**Impact**: Presto requires all derived tables to have aliases + +### 4. query22a.tpl - Invalid Query Structure +**Issue**: Unnecessary warehouse table join and invalid GROUP BY +**Removed**: +- Line 48: `,warehouse` +- Line 51: `and inv_warehouse_sk = w_warehouse_sk` +- Line 53: `group by i_product_name,i_brand,i_class,i_category` + +**Impact**: +- Fixes GitHub Issue #31 +- Removes unused table join +- Corrects aggregation logic (GROUP BY was applied before aggregation in results_rollup) + +### 5. query49.tpl - Subquery Alias +**Issue**: Derived table without alias +**Fix**: Changed `)` to `) x` at line 162 +**Impact**: Presto compliance for derived tables + +### 6. query23.tpl - Subquery Aliases for Query Variants +**Issue**: Query 23 has two query variants (both using UNION ALL), and both derived tables were missing aliases +**Before (first variant, line 87)**: +```sql +select sum(sales) +from (select cs_quantity*cs_list_price sales + ... + union all + select ws_quantity*ws_list_price sales + ...) +``` +**After (first variant, line 87)**: +```sql +select sum(sales) +from (select cs_quantity*cs_list_price sales + ... + union all + select ws_quantity*ws_list_price sales + ...) x +``` +**Before (second variant, line 142)**: +```sql +select c_last_name,c_first_name,sales +from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + ... + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + ...) +``` +**After (second variant, line 142)**: +```sql +select c_last_name,c_first_name,sales +from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales + ... + union all + select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales + ...) x +``` +**Impact**: Presto requires all derived tables to have aliases; fixes both query variants + +### 7. query51a.tpl - Nested Subquery Alias +**Issue**: Inner subquery in CTE 'v' without alias +**Fix**: Changed `)` to `) vx` at line 86 +**Impact**: Presto compliance for nested subqueries + +### 8. query77a.tpl - Syntax Error +**Issue**: Missing comma in SELECT statement +**Before**: +```sql +cr as +(select cr_call_center_sk + sum(cr_return_amount) as returns, +``` +**After**: +```sql +cr as +(select cr_call_center_sk, + sum(cr_return_amount) as returns, +``` +**Impact**: +- Fixes GitHub Issue #43 +- Corrects critical syntax error that would fail in all databases + +### 9. query58.tpl - Date Literal Comparison + +**Issue**: Presto C++ requires DATE constructor for date literals in comparisons +**Lines**: 50, 64, 78 + +**Before**: +```sql +where d_date = '[SALES_DATE]' +-- Generates as: where d_date = '1999-02-23' +``` + +**After**: +```sql +where d_date = DATE '[SALES_DATE]' +-- Generates as: where d_date = DATE '1999-02-23' +``` + +**Error Without Fix**: +``` +'=' cannot be applied to date, varchar(10) +``` + +**Impact**: +- Fixes type mismatch error in query 58 +- Ensures date column can be compared with date literal +- Required for Presto C++ type safety + +### 10-14. Date Literal in BETWEEN Clauses (5 templates) - Presto C++ Compatibility + +**Issue**: Presto C++ requires DATE constructor for date literals in BETWEEN clauses +**Templates Fixed**: +- query16.tpl (line 57) +- query32.tpl (lines 48, 60) +- query92.tpl (lines 50, 62) +- query94.tpl (line 51) +- query95.tpl (line 56) + +**Before**: +```sql +where d_date between '1999-01-28' and (cast('1999-01-28' as date) + INTERVAL '90' DAY) +-- Generates error: Cannot check if date is BETWEEN varchar(10) and date +``` + +**After**: +```sql +where d_date between DATE '1999-01-28' and (cast('1999-01-28' as date) + INTERVAL '90' DAY) +``` + +**Error Without Fix**: +``` +Cannot check if date is BETWEEN varchar(10) and date +``` + +**Impact**: +- Fixes type mismatch in BETWEEN clauses for 5 queries +- First operand must be DATE type, not varchar +- Total 7 occurrences fixed across 5 templates +- Required for Presto C++ type safety + +### 15. query72.tpl - Date Arithmetic Without INTERVAL + +**Issue**: Presto C++ requires INTERVAL syntax for date arithmetic +**Line**: 60 + +**Before**: +```sql +and d3.d_date > d1.d_date + 5 +``` + +**After**: +```sql +and d3.d_date > d1.d_date + INTERVAL '5' DAY +``` + +**Error Without Fix**: +``` +'+' cannot be applied to date, integer +``` + +**Impact**: +- Fixes type error in query 72 +- Part of comprehensive date arithmetic fixes +- Required for Presto C++ type safety + +### 16. query83.tpl - Date Literals in IN Clause + +**Issue**: Presto C++ requires DATE constructor for date literals in IN clauses +**Lines**: 54, 70, 86 + +**Before**: +```sql +where d_date in ('1999-04-23','1999-09-15','1999-11-06') +-- Generates error: IN value and list items must be the same type: date +``` + +**After**: +```sql +where d_date in (DATE '1999-04-23',DATE '1999-09-15',DATE '1999-11-06') +``` + +**Error Without Fix**: +``` +IN value and list items must be the same type: date +``` + +**Impact**: +- Fixes type mismatch in IN clauses for query 83 +- All three date literals in IN clause must use DATE constructor +- Total 3 occurrences fixed (one per subquery) +- Required for Presto C++ type safety + +### 17-37. Date Arithmetic Templates (21 templates) - Presto C++ Compatibility +**Issue**: Date arithmetic using `date + N` or `date + N days` syntax not supported in Presto C++ +**Templates Fixed**: +- query5.tpl, query12.tpl, query16.tpl, query20.tpl, query21.tpl +- query30.tpl, query32.tpl, query37.tpl, query40.tpl, query50.tpl +- query52.tpl, query58.tpl, query72.tpl, query77.tpl, query80.tpl +- query82.tpl, query83.tpl, query92.tpl, query94.tpl, query95.tpl, query98.tpl + +**Before**: +```sql +select d_date + 30 from date_dim; +select d_date + 30 days from date_dim; +select d_date - 30 from date_dim; +select cast('2000-01-01' as date) + 14 from date_dim; +``` + +**After**: +```sql +select d_date + INTERVAL '30' DAY from date_dim; +select d_date + INTERVAL '30' DAY from date_dim; +select d_date - INTERVAL '30' DAY from date_dim; +select cast('2000-01-01' as date) + INTERVAL '14' DAY from date_dim; +``` + +**Impact**: +- Fixes all date arithmetic to use Presto C++ INTERVAL syntax +- Only converts DATE columns (d_date), preserves INTEGER columns (d_month_seq, d_week_seq, etc.) +- Queries now generate with correct syntax from the start +- No post-processing required + +**Tool Created**: `tools/fix_tpcds_templates.sh` - Automated fix script with backup + +### 38-40. Date Arithmetic Variants (3 templates) - Presto C++ Compatibility +**Issue**: Same date arithmetic issue in variant templates +**Templates Fixed**: +- query5a.tpl (3 occurrences) +- query77a.tpl (6 occurrences) +- query80a.tpl (3 occurrences) + +**Before**: +```sql +and (cast('[SALES_DATE]' as date) + 14) +and (cast('[SALES_DATE]' as date) + 30) +``` + +**After**: +```sql +and (cast('[SALES_DATE]' as date) + INTERVAL '14' DAY) +and (cast('[SALES_DATE]' as date) + INTERVAL '30' DAY) +``` + +**Impact**: +- Variant queries now also generate with correct Presto C++ syntax +- Consistent with main template fixes + +--- + +## Audit Results + +- **Total templates audited**: 118 files +- **Issues found**: 40 (16 original + 24 date arithmetic) +- **Issues fixed**: 40 +- **Syntax errors remaining**: 0 +- **Presto compatibility**: 100% +- **Known GitHub issues**: All resolved + +--- + +## Template Selection for Presto + +**Recommended Dialect**: `netezza` + +### Why Netezza Template? +- ✅ Uses standard `LIMIT n` syntax (Presto-compatible) +- ❌ ANSI template uses `TOP n` (SQL Server syntax, not supported) +- ⚠️ DB2 template uses `FETCH FIRST n ROWS ONLY` (works but verbose) + +--- + +## Query Generation Command + +### Generate All Queries (21 Streams) + +```bash +cd DSGen-software-code-4.0.0/tools + +# Clean previous generation +rm -rf queries_presto + +# Generate with all fixes applied +./dsqgen -DIRECTORY ../query_templates \ + -INPUT ../query_templates/templates.lst \ + -SCALE 10000 \ + -DIALECT netezza \ + -STREAMS 21 \ + -RNGSEED 01271612345 \ + -OUTPUT_DIR ./queries_presto \ +``` + +### Parameters Explained +- `-SCALE 10000`: 10TB dataset (10000 GB) +- `-DIALECT netezza`: Uses Presto-compatible LIMIT syntax +- `-STREAMS 21`: Generates 21 different query streams +- `-RNGSEED 01271612345`: Base seed for reproducible results +- Each stream gets different substitution parameters (dates, states, values, etc.) + +--- + +## Query Generation Details + +### Understanding TPC-DS Query Generation + +#### 1. Does query structure differ by scale factor? +**NO** - Query structure remains the same regardless of scale factor (1GB, 100GB, 1TB, etc.) +- Only data volume changes +- Substitution parameters are randomized but not scale-dependent + +#### 2. Will queries differ by stream sequence? +**YES** - Each stream generates different query variants +- Different streams use different random seeds +- Same query template produces varied parameter values +- Enables concurrent testing without identical queries + +#### 3. Does query generation depend on random seed? +**YES** - RNGSEED controls all substitution parameters: +- Years: `d_year = 2000` vs `d_year = 1998` +- States: `s_state = 'MO'` vs `s_state = 'CA'` +- Dates: `'2002-06-05'` vs `'2001-03-15'` +- Numeric ranges: `between 16 and 46` vs `between 20 and 50` +- Manufacturer IDs: `(841,790,796,739)` vs `(123,456,789,012)` + +**Same seed = same query; different seed = different parameter values** + +--- + +## Known GitHub Issues Resolved + +### Issue #31 - query22a.tpl +**Problem**: +- Unnecessary warehouse table join +- Invalid GROUP BY before aggregation + +**Resolution**: +- Removed warehouse table and join condition +- Removed GROUP BY from 'results' CTE +- Aggregation now correctly happens only in 'results_rollup' + +### Issue #43 - query77a.tpl +**Problem**: +- Missing comma after first column in 'cr' CTE +- Caused syntax error in all databases + +**Resolution**: +- Added comma after `cr_call_center_sk` +- Now consistent with other CTEs (ss, sr, cs, ws, wr) + +--- + +## Production Readiness Checklist + +- ✅ All syntax errors fixed +- ✅ All Presto compatibility issues resolved +- ✅ All known GitHub issues addressed +- ✅ Template definitions complete +- ✅ Subquery aliases added where required +- ✅ Query generation tested and verified +- ✅ Documentation complete + +--- + +## Contact & References + +### TPC-DS Specification +- **Version**: 4.0.0 +- **Specification**: https://www.tpc.org/TPC_Documents_Current_Versions/pdf/TPC-DS_v4.0.0.pdf +- **Tools**: https://www.tpc.org/tpc_documents_current_versions/current_specifications5.asp + +### GitHub Issues +- Issue #31: https://github.com/gregrahn/tpcds-kit/issues/31 +- Issue #43: https://github.com/gregrahn/tpcds-kit/issues/43 + +### IBM watsonx.data +- **Engine**: Presto C++ +- **SQL Dialect**: Standard SQL with Presto extensions +- **Compatibility**: Full TPC-DS benchmark support + +--- diff --git a/benchmarks/tpc-ds/streams_v2/10000/s0.json b/benchmarks/tpc-ds/streams_v2/10000/s0.json new file mode 100644 index 00000000..d6ce1234 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s0.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s0/q96.sql", + "../../queries_v2/10000/s0/q07.sql", + "../../queries_v2/10000/s0/q75.sql", + "../../queries_v2/10000/s0/q44.sql", + "../../queries_v2/10000/s0/q39.sql", + "../../queries_v2/10000/s0/q80.sql", + "../../queries_v2/10000/s0/q32.sql", + "../../queries_v2/10000/s0/q19.sql", + "../../queries_v2/10000/s0/q25.sql", + "../../queries_v2/10000/s0/q78.sql", + "../../queries_v2/10000/s0/q86.sql", + "../../queries_v2/10000/s0/q01.sql", + "../../queries_v2/10000/s0/q91.sql", + "../../queries_v2/10000/s0/q21.sql", + "../../queries_v2/10000/s0/q43.sql", + "../../queries_v2/10000/s0/q27.sql", + "../../queries_v2/10000/s0/q94.sql", + "../../queries_v2/10000/s0/q45.sql", + "../../queries_v2/10000/s0/q58.sql", + "../../queries_v2/10000/s0/q64.sql", + "../../queries_v2/10000/s0/q36.sql", + "../../queries_v2/10000/s0/q33.sql", + "../../queries_v2/10000/s0/q46.sql", + "../../queries_v2/10000/s0/q62.sql", + "../../queries_v2/10000/s0/q16.sql", + "../../queries_v2/10000/s0/q10.sql", + "../../queries_v2/10000/s0/q63.sql", + "../../queries_v2/10000/s0/q69.sql", + "../../queries_v2/10000/s0/q60.sql", + "../../queries_v2/10000/s0/q59.sql", + "../../queries_v2/10000/s0/q37.sql", + "../../queries_v2/10000/s0/q98.sql", + "../../queries_v2/10000/s0/q85.sql", + "../../queries_v2/10000/s0/q70.sql", + "../../queries_v2/10000/s0/q67.sql", + "../../queries_v2/10000/s0/q28.sql", + "../../queries_v2/10000/s0/q81.sql", + "../../queries_v2/10000/s0/q97.sql", + "../../queries_v2/10000/s0/q66.sql", + "../../queries_v2/10000/s0/q90.sql", + "../../queries_v2/10000/s0/q17.sql", + "../../queries_v2/10000/s0/q47.sql", + "../../queries_v2/10000/s0/q95.sql", + "../../queries_v2/10000/s0/q92.sql", + "../../queries_v2/10000/s0/q03.sql", + "../../queries_v2/10000/s0/q51.sql", + "../../queries_v2/10000/s0/q35.sql", + "../../queries_v2/10000/s0/q49.sql", + "../../queries_v2/10000/s0/q09.sql", + "../../queries_v2/10000/s0/q31.sql", + "../../queries_v2/10000/s0/q11.sql", + "../../queries_v2/10000/s0/q93.sql", + "../../queries_v2/10000/s0/q29.sql", + "../../queries_v2/10000/s0/q38.sql", + "../../queries_v2/10000/s0/q22.sql", + "../../queries_v2/10000/s0/q89.sql", + "../../queries_v2/10000/s0/q15.sql", + "../../queries_v2/10000/s0/q06.sql", + "../../queries_v2/10000/s0/q52.sql", + "../../queries_v2/10000/s0/q50.sql", + "../../queries_v2/10000/s0/q42.sql", + "../../queries_v2/10000/s0/q41.sql", + "../../queries_v2/10000/s0/q08.sql", + "../../queries_v2/10000/s0/q12.sql", + "../../queries_v2/10000/s0/q20.sql", + "../../queries_v2/10000/s0/q88.sql", + "../../queries_v2/10000/s0/q82.sql", + "../../queries_v2/10000/s0/q23.sql", + "../../queries_v2/10000/s0/q14.sql", + "../../queries_v2/10000/s0/q57.sql", + "../../queries_v2/10000/s0/q65.sql", + "../../queries_v2/10000/s0/q71.sql", + "../../queries_v2/10000/s0/q34.sql", + "../../queries_v2/10000/s0/q48.sql", + "../../queries_v2/10000/s0/q30.sql", + "../../queries_v2/10000/s0/q74.sql", + "../../queries_v2/10000/s0/q87.sql", + "../../queries_v2/10000/s0/q77.sql", + "../../queries_v2/10000/s0/q73.sql", + "../../queries_v2/10000/s0/q84.sql", + "../../queries_v2/10000/s0/q54.sql", + "../../queries_v2/10000/s0/q55.sql", + "../../queries_v2/10000/s0/q56.sql", + "../../queries_v2/10000/s0/q02.sql", + "../../queries_v2/10000/s0/q26.sql", + "../../queries_v2/10000/s0/q40.sql", + "../../queries_v2/10000/s0/q72.sql", + "../../queries_v2/10000/s0/q53.sql", + "../../queries_v2/10000/s0/q79.sql", + "../../queries_v2/10000/s0/q18.sql", + "../../queries_v2/10000/s0/q13.sql", + "../../queries_v2/10000/s0/q24.sql", + "../../queries_v2/10000/s0/q04.sql", + "../../queries_v2/10000/s0/q99.sql", + "../../queries_v2/10000/s0/q68.sql", + "../../queries_v2/10000/s0/q83.sql", + "../../queries_v2/10000/s0/q61.sql", + "../../queries_v2/10000/s0/q05.sql", + "../../queries_v2/10000/s0/q76.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s1.json b/benchmarks/tpc-ds/streams_v2/10000/s1.json new file mode 100644 index 00000000..b4a3912e --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s1.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s1/q83.sql", + "../../queries_v2/10000/s1/q32.sql", + "../../queries_v2/10000/s1/q30.sql", + "../../queries_v2/10000/s1/q92.sql", + "../../queries_v2/10000/s1/q66.sql", + "../../queries_v2/10000/s1/q84.sql", + "../../queries_v2/10000/s1/q98.sql", + "../../queries_v2/10000/s1/q58.sql", + "../../queries_v2/10000/s1/q16.sql", + "../../queries_v2/10000/s1/q77.sql", + "../../queries_v2/10000/s1/q40.sql", + "../../queries_v2/10000/s1/q96.sql", + "../../queries_v2/10000/s1/q13.sql", + "../../queries_v2/10000/s1/q36.sql", + "../../queries_v2/10000/s1/q95.sql", + "../../queries_v2/10000/s1/q63.sql", + "../../queries_v2/10000/s1/q99.sql", + "../../queries_v2/10000/s1/q03.sql", + "../../queries_v2/10000/s1/q06.sql", + "../../queries_v2/10000/s1/q12.sql", + "../../queries_v2/10000/s1/q28.sql", + "../../queries_v2/10000/s1/q85.sql", + "../../queries_v2/10000/s1/q51.sql", + "../../queries_v2/10000/s1/q41.sql", + "../../queries_v2/10000/s1/q27.sql", + "../../queries_v2/10000/s1/q78.sql", + "../../queries_v2/10000/s1/q08.sql", + "../../queries_v2/10000/s1/q14.sql", + "../../queries_v2/10000/s1/q50.sql", + "../../queries_v2/10000/s1/q52.sql", + "../../queries_v2/10000/s1/q81.sql", + "../../queries_v2/10000/s1/q05.sql", + "../../queries_v2/10000/s1/q26.sql", + "../../queries_v2/10000/s1/q57.sql", + "../../queries_v2/10000/s1/q82.sql", + "../../queries_v2/10000/s1/q69.sql", + "../../queries_v2/10000/s1/q54.sql", + "../../queries_v2/10000/s1/q61.sql", + "../../queries_v2/10000/s1/q88.sql", + "../../queries_v2/10000/s1/q18.sql", + "../../queries_v2/10000/s1/q94.sql", + "../../queries_v2/10000/s1/q35.sql", + "../../queries_v2/10000/s1/q68.sql", + "../../queries_v2/10000/s1/q24.sql", + "../../queries_v2/10000/s1/q75.sql", + "../../queries_v2/10000/s1/q11.sql", + "../../queries_v2/10000/s1/q67.sql", + "../../queries_v2/10000/s1/q09.sql", + "../../queries_v2/10000/s1/q25.sql", + "../../queries_v2/10000/s1/q37.sql", + "../../queries_v2/10000/s1/q86.sql", + "../../queries_v2/10000/s1/q04.sql", + "../../queries_v2/10000/s1/q60.sql", + "../../queries_v2/10000/s1/q97.sql", + "../../queries_v2/10000/s1/q33.sql", + "../../queries_v2/10000/s1/q79.sql", + "../../queries_v2/10000/s1/q43.sql", + "../../queries_v2/10000/s1/q80.sql", + "../../queries_v2/10000/s1/q93.sql", + "../../queries_v2/10000/s1/q31.sql", + "../../queries_v2/10000/s1/q47.sql", + "../../queries_v2/10000/s1/q17.sql", + "../../queries_v2/10000/s1/q19.sql", + "../../queries_v2/10000/s1/q01.sql", + "../../queries_v2/10000/s1/q64.sql", + "../../queries_v2/10000/s1/q53.sql", + "../../queries_v2/10000/s1/q55.sql", + "../../queries_v2/10000/s1/q46.sql", + "../../queries_v2/10000/s1/q21.sql", + "../../queries_v2/10000/s1/q15.sql", + "../../queries_v2/10000/s1/q20.sql", + "../../queries_v2/10000/s1/q65.sql", + "../../queries_v2/10000/s1/q70.sql", + "../../queries_v2/10000/s1/q49.sql", + "../../queries_v2/10000/s1/q59.sql", + "../../queries_v2/10000/s1/q48.sql", + "../../queries_v2/10000/s1/q72.sql", + "../../queries_v2/10000/s1/q87.sql", + "../../queries_v2/10000/s1/q34.sql", + "../../queries_v2/10000/s1/q02.sql", + "../../queries_v2/10000/s1/q38.sql", + "../../queries_v2/10000/s1/q22.sql", + "../../queries_v2/10000/s1/q89.sql", + "../../queries_v2/10000/s1/q07.sql", + "../../queries_v2/10000/s1/q10.sql", + "../../queries_v2/10000/s1/q90.sql", + "../../queries_v2/10000/s1/q71.sql", + "../../queries_v2/10000/s1/q29.sql", + "../../queries_v2/10000/s1/q73.sql", + "../../queries_v2/10000/s1/q45.sql", + "../../queries_v2/10000/s1/q91.sql", + "../../queries_v2/10000/s1/q62.sql", + "../../queries_v2/10000/s1/q44.sql", + "../../queries_v2/10000/s1/q76.sql", + "../../queries_v2/10000/s1/q23.sql", + "../../queries_v2/10000/s1/q56.sql", + "../../queries_v2/10000/s1/q42.sql", + "../../queries_v2/10000/s1/q39.sql", + "../../queries_v2/10000/s1/q74.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s10.json b/benchmarks/tpc-ds/streams_v2/10000/s10.json new file mode 100644 index 00000000..eef6066d --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s10.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s10/q43.sql", + "../../queries_v2/10000/s10/q50.sql", + "../../queries_v2/10000/s10/q41.sql", + "../../queries_v2/10000/s10/q48.sql", + "../../queries_v2/10000/s10/q54.sql", + "../../queries_v2/10000/s10/q53.sql", + "../../queries_v2/10000/s10/q31.sql", + "../../queries_v2/10000/s10/q39.sql", + "../../queries_v2/10000/s10/q02.sql", + "../../queries_v2/10000/s10/q96.sql", + "../../queries_v2/10000/s10/q93.sql", + "../../queries_v2/10000/s10/q15.sql", + "../../queries_v2/10000/s10/q91.sql", + "../../queries_v2/10000/s10/q21.sql", + "../../queries_v2/10000/s10/q18.sql", + "../../queries_v2/10000/s10/q32.sql", + "../../queries_v2/10000/s10/q63.sql", + "../../queries_v2/10000/s10/q24.sql", + "../../queries_v2/10000/s10/q66.sql", + "../../queries_v2/10000/s10/q70.sql", + "../../queries_v2/10000/s10/q36.sql", + "../../queries_v2/10000/s10/q20.sql", + "../../queries_v2/10000/s10/q30.sql", + "../../queries_v2/10000/s10/q25.sql", + "../../queries_v2/10000/s10/q07.sql", + "../../queries_v2/10000/s10/q01.sql", + "../../queries_v2/10000/s10/q98.sql", + "../../queries_v2/10000/s10/q69.sql", + "../../queries_v2/10000/s10/q47.sql", + "../../queries_v2/10000/s10/q94.sql", + "../../queries_v2/10000/s10/q82.sql", + "../../queries_v2/10000/s10/q37.sql", + "../../queries_v2/10000/s10/q64.sql", + "../../queries_v2/10000/s10/q86.sql", + "../../queries_v2/10000/s10/q87.sql", + "../../queries_v2/10000/s10/q28.sql", + "../../queries_v2/10000/s10/q55.sql", + "../../queries_v2/10000/s10/q85.sql", + "../../queries_v2/10000/s10/q38.sql", + "../../queries_v2/10000/s10/q44.sql", + "../../queries_v2/10000/s10/q27.sql", + "../../queries_v2/10000/s10/q78.sql", + "../../queries_v2/10000/s10/q45.sql", + "../../queries_v2/10000/s10/q49.sql", + "../../queries_v2/10000/s10/q62.sql", + "../../queries_v2/10000/s10/q59.sql", + "../../queries_v2/10000/s10/q77.sql", + "../../queries_v2/10000/s10/q80.sql", + "../../queries_v2/10000/s10/q84.sql", + "../../queries_v2/10000/s10/q67.sql", + "../../queries_v2/10000/s10/q52.sql", + "../../queries_v2/10000/s10/q76.sql", + "../../queries_v2/10000/s10/q42.sql", + "../../queries_v2/10000/s10/q33.sql", + "../../queries_v2/10000/s10/q65.sql", + "../../queries_v2/10000/s10/q23.sql", + "../../queries_v2/10000/s10/q90.sql", + "../../queries_v2/10000/s10/q88.sql", + "../../queries_v2/10000/s10/q99.sql", + "../../queries_v2/10000/s10/q35.sql", + "../../queries_v2/10000/s10/q10.sql", + "../../queries_v2/10000/s10/q16.sql", + "../../queries_v2/10000/s10/q05.sql", + "../../queries_v2/10000/s10/q57.sql", + "../../queries_v2/10000/s10/q34.sql", + "../../queries_v2/10000/s10/q97.sql", + "../../queries_v2/10000/s10/q72.sql", + "../../queries_v2/10000/s10/q75.sql", + "../../queries_v2/10000/s10/q14.sql", + "../../queries_v2/10000/s10/q40.sql", + "../../queries_v2/10000/s10/q73.sql", + "../../queries_v2/10000/s10/q79.sql", + "../../queries_v2/10000/s10/q11.sql", + "../../queries_v2/10000/s10/q06.sql", + "../../queries_v2/10000/s10/q17.sql", + "../../queries_v2/10000/s10/q58.sql", + "../../queries_v2/10000/s10/q56.sql", + "../../queries_v2/10000/s10/q83.sql", + "../../queries_v2/10000/s10/q51.sql", + "../../queries_v2/10000/s10/q29.sql", + "../../queries_v2/10000/s10/q22.sql", + "../../queries_v2/10000/s10/q71.sql", + "../../queries_v2/10000/s10/q68.sql", + "../../queries_v2/10000/s10/q60.sql", + "../../queries_v2/10000/s10/q12.sql", + "../../queries_v2/10000/s10/q04.sql", + "../../queries_v2/10000/s10/q89.sql", + "../../queries_v2/10000/s10/q61.sql", + "../../queries_v2/10000/s10/q46.sql", + "../../queries_v2/10000/s10/q92.sql", + "../../queries_v2/10000/s10/q13.sql", + "../../queries_v2/10000/s10/q09.sql", + "../../queries_v2/10000/s10/q74.sql", + "../../queries_v2/10000/s10/q08.sql", + "../../queries_v2/10000/s10/q03.sql", + "../../queries_v2/10000/s10/q95.sql", + "../../queries_v2/10000/s10/q26.sql", + "../../queries_v2/10000/s10/q81.sql", + "../../queries_v2/10000/s10/q19.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s11.json b/benchmarks/tpc-ds/streams_v2/10000/s11.json new file mode 100644 index 00000000..b8a57872 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s11.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s11/q95.sql", + "../../queries_v2/10000/s11/q31.sql", + "../../queries_v2/10000/s11/q17.sql", + "../../queries_v2/10000/s11/q49.sql", + "../../queries_v2/10000/s11/q38.sql", + "../../queries_v2/10000/s11/q29.sql", + "../../queries_v2/10000/s11/q37.sql", + "../../queries_v2/10000/s11/q66.sql", + "../../queries_v2/10000/s11/q07.sql", + "../../queries_v2/10000/s11/q83.sql", + "../../queries_v2/10000/s11/q04.sql", + "../../queries_v2/10000/s11/q43.sql", + "../../queries_v2/10000/s11/q13.sql", + "../../queries_v2/10000/s11/q36.sql", + "../../queries_v2/10000/s11/q45.sql", + "../../queries_v2/10000/s11/q98.sql", + "../../queries_v2/10000/s11/q08.sql", + "../../queries_v2/10000/s11/q62.sql", + "../../queries_v2/10000/s11/q88.sql", + "../../queries_v2/10000/s11/q57.sql", + "../../queries_v2/10000/s11/q28.sql", + "../../queries_v2/10000/s11/q64.sql", + "../../queries_v2/10000/s11/q59.sql", + "../../queries_v2/10000/s11/q16.sql", + "../../queries_v2/10000/s11/q32.sql", + "../../queries_v2/10000/s11/q96.sql", + "../../queries_v2/10000/s11/q05.sql", + "../../queries_v2/10000/s11/q14.sql", + "../../queries_v2/10000/s11/q35.sql", + "../../queries_v2/10000/s11/q99.sql", + "../../queries_v2/10000/s11/q55.sql", + "../../queries_v2/10000/s11/q81.sql", + "../../queries_v2/10000/s11/q12.sql", + "../../queries_v2/10000/s11/q40.sql", + "../../queries_v2/10000/s11/q72.sql", + "../../queries_v2/10000/s11/q69.sql", + "../../queries_v2/10000/s11/q22.sql", + "../../queries_v2/10000/s11/q26.sql", + "../../queries_v2/10000/s11/q97.sql", + "../../queries_v2/10000/s11/q92.sql", + "../../queries_v2/10000/s11/q63.sql", + "../../queries_v2/10000/s11/q77.sql", + "../../queries_v2/10000/s11/q03.sql", + "../../queries_v2/10000/s11/q09.sql", + "../../queries_v2/10000/s11/q41.sql", + "../../queries_v2/10000/s11/q52.sql", + "../../queries_v2/10000/s11/q87.sql", + "../../queries_v2/10000/s11/q84.sql", + "../../queries_v2/10000/s11/q02.sql", + "../../queries_v2/10000/s11/q82.sql", + "../../queries_v2/10000/s11/q93.sql", + "../../queries_v2/10000/s11/q74.sql", + "../../queries_v2/10000/s11/q47.sql", + "../../queries_v2/10000/s11/q85.sql", + "../../queries_v2/10000/s11/q20.sql", + "../../queries_v2/10000/s11/q46.sql", + "../../queries_v2/10000/s11/q18.sql", + "../../queries_v2/10000/s11/q53.sql", + "../../queries_v2/10000/s11/q76.sql", + "../../queries_v2/10000/s11/q67.sql", + "../../queries_v2/10000/s11/q78.sql", + "../../queries_v2/10000/s11/q27.sql", + "../../queries_v2/10000/s11/q39.sql", + "../../queries_v2/10000/s11/q15.sql", + "../../queries_v2/10000/s11/q70.sql", + "../../queries_v2/10000/s11/q61.sql", + "../../queries_v2/10000/s11/q71.sql", + "../../queries_v2/10000/s11/q30.sql", + "../../queries_v2/10000/s11/q21.sql", + "../../queries_v2/10000/s11/q90.sql", + "../../queries_v2/10000/s11/q34.sql", + "../../queries_v2/10000/s11/q73.sql", + "../../queries_v2/10000/s11/q86.sql", + "../../queries_v2/10000/s11/q80.sql", + "../../queries_v2/10000/s11/q94.sql", + "../../queries_v2/10000/s11/q06.sql", + "../../queries_v2/10000/s11/q89.sql", + "../../queries_v2/10000/s11/q56.sql", + "../../queries_v2/10000/s11/q11.sql", + "../../queries_v2/10000/s11/q60.sql", + "../../queries_v2/10000/s11/q33.sql", + "../../queries_v2/10000/s11/q65.sql", + "../../queries_v2/10000/s11/q23.sql", + "../../queries_v2/10000/s11/q50.sql", + "../../queries_v2/10000/s11/q01.sql", + "../../queries_v2/10000/s11/q44.sql", + "../../queries_v2/10000/s11/q79.sql", + "../../queries_v2/10000/s11/q42.sql", + "../../queries_v2/10000/s11/q51.sql", + "../../queries_v2/10000/s11/q24.sql", + "../../queries_v2/10000/s11/q91.sql", + "../../queries_v2/10000/s11/q25.sql", + "../../queries_v2/10000/s11/q48.sql", + "../../queries_v2/10000/s11/q19.sql", + "../../queries_v2/10000/s11/q75.sql", + "../../queries_v2/10000/s11/q68.sql", + "../../queries_v2/10000/s11/q10.sql", + "../../queries_v2/10000/s11/q54.sql", + "../../queries_v2/10000/s11/q58.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s12.json b/benchmarks/tpc-ds/streams_v2/10000/s12.json new file mode 100644 index 00000000..c39f5cc4 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s12.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s12/q68.sql", + "../../queries_v2/10000/s12/q37.sql", + "../../queries_v2/10000/s12/q94.sql", + "../../queries_v2/10000/s12/q09.sql", + "../../queries_v2/10000/s12/q97.sql", + "../../queries_v2/10000/s12/q60.sql", + "../../queries_v2/10000/s12/q81.sql", + "../../queries_v2/10000/s12/q88.sql", + "../../queries_v2/10000/s12/q32.sql", + "../../queries_v2/10000/s12/q56.sql", + "../../queries_v2/10000/s12/q44.sql", + "../../queries_v2/10000/s12/q95.sql", + "../../queries_v2/10000/s12/q91.sql", + "../../queries_v2/10000/s12/q28.sql", + "../../queries_v2/10000/s12/q03.sql", + "../../queries_v2/10000/s12/q05.sql", + "../../queries_v2/10000/s12/q19.sql", + "../../queries_v2/10000/s12/q41.sql", + "../../queries_v2/10000/s12/q53.sql", + "../../queries_v2/10000/s12/q15.sql", + "../../queries_v2/10000/s12/q69.sql", + "../../queries_v2/10000/s12/q12.sql", + "../../queries_v2/10000/s12/q52.sql", + "../../queries_v2/10000/s12/q27.sql", + "../../queries_v2/10000/s12/q98.sql", + "../../queries_v2/10000/s12/q83.sql", + "../../queries_v2/10000/s12/q39.sql", + "../../queries_v2/10000/s12/q21.sql", + "../../queries_v2/10000/s12/q67.sql", + "../../queries_v2/10000/s12/q76.sql", + "../../queries_v2/10000/s12/q22.sql", + "../../queries_v2/10000/s12/q54.sql", + "../../queries_v2/10000/s12/q01.sql", + "../../queries_v2/10000/s12/q90.sql", + "../../queries_v2/10000/s12/q71.sql", + "../../queries_v2/10000/s12/q14.sql", + "../../queries_v2/10000/s12/q33.sql", + "../../queries_v2/10000/s12/q10.sql", + "../../queries_v2/10000/s12/q61.sql", + "../../queries_v2/10000/s12/q24.sql", + "../../queries_v2/10000/s12/q08.sql", + "../../queries_v2/10000/s12/q87.sql", + "../../queries_v2/10000/s12/q75.sql", + "../../queries_v2/10000/s12/q25.sql", + "../../queries_v2/10000/s12/q17.sql", + "../../queries_v2/10000/s12/q93.sql", + "../../queries_v2/10000/s12/q72.sql", + "../../queries_v2/10000/s12/q02.sql", + "../../queries_v2/10000/s12/q07.sql", + "../../queries_v2/10000/s12/q55.sql", + "../../queries_v2/10000/s12/q04.sql", + "../../queries_v2/10000/s12/q48.sql", + "../../queries_v2/10000/s12/q35.sql", + "../../queries_v2/10000/s12/q26.sql", + "../../queries_v2/10000/s12/q64.sql", + "../../queries_v2/10000/s12/q51.sql", + "../../queries_v2/10000/s12/q45.sql", + "../../queries_v2/10000/s12/q29.sql", + "../../queries_v2/10000/s12/q74.sql", + "../../queries_v2/10000/s12/q82.sql", + "../../queries_v2/10000/s12/q77.sql", + "../../queries_v2/10000/s12/q63.sql", + "../../queries_v2/10000/s12/q66.sql", + "../../queries_v2/10000/s12/q43.sql", + "../../queries_v2/10000/s12/q57.sql", + "../../queries_v2/10000/s12/q42.sql", + "../../queries_v2/10000/s12/q65.sql", + "../../queries_v2/10000/s12/q59.sql", + "../../queries_v2/10000/s12/q36.sql", + "../../queries_v2/10000/s12/q18.sql", + "../../queries_v2/10000/s12/q70.sql", + "../../queries_v2/10000/s12/q34.sql", + "../../queries_v2/10000/s12/q40.sql", + "../../queries_v2/10000/s12/q84.sql", + "../../queries_v2/10000/s12/q99.sql", + "../../queries_v2/10000/s12/q80.sql", + "../../queries_v2/10000/s12/q79.sql", + "../../queries_v2/10000/s12/q89.sql", + "../../queries_v2/10000/s12/q86.sql", + "../../queries_v2/10000/s12/q50.sql", + "../../queries_v2/10000/s12/q85.sql", + "../../queries_v2/10000/s12/q20.sql", + "../../queries_v2/10000/s12/q46.sql", + "../../queries_v2/10000/s12/q31.sql", + "../../queries_v2/10000/s12/q96.sql", + "../../queries_v2/10000/s12/q92.sql", + "../../queries_v2/10000/s12/q73.sql", + "../../queries_v2/10000/s12/q47.sql", + "../../queries_v2/10000/s12/q11.sql", + "../../queries_v2/10000/s12/q62.sql", + "../../queries_v2/10000/s12/q13.sql", + "../../queries_v2/10000/s12/q16.sql", + "../../queries_v2/10000/s12/q49.sql", + "../../queries_v2/10000/s12/q58.sql", + "../../queries_v2/10000/s12/q30.sql", + "../../queries_v2/10000/s12/q23.sql", + "../../queries_v2/10000/s12/q78.sql", + "../../queries_v2/10000/s12/q38.sql", + "../../queries_v2/10000/s12/q06.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s13.json b/benchmarks/tpc-ds/streams_v2/10000/s13.json new file mode 100644 index 00000000..c8a6d46a --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s13.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s13/q23.sql", + "../../queries_v2/10000/s13/q81.sql", + "../../queries_v2/10000/s13/q99.sql", + "../../queries_v2/10000/s13/q25.sql", + "../../queries_v2/10000/s13/q61.sql", + "../../queries_v2/10000/s13/q50.sql", + "../../queries_v2/10000/s13/q54.sql", + "../../queries_v2/10000/s13/q53.sql", + "../../queries_v2/10000/s13/q98.sql", + "../../queries_v2/10000/s13/q89.sql", + "../../queries_v2/10000/s13/q92.sql", + "../../queries_v2/10000/s13/q68.sql", + "../../queries_v2/10000/s13/q13.sql", + "../../queries_v2/10000/s13/q69.sql", + "../../queries_v2/10000/s13/q75.sql", + "../../queries_v2/10000/s13/q39.sql", + "../../queries_v2/10000/s13/q58.sql", + "../../queries_v2/10000/s13/q17.sql", + "../../queries_v2/10000/s13/q29.sql", + "../../queries_v2/10000/s13/q43.sql", + "../../queries_v2/10000/s13/q14.sql", + "../../queries_v2/10000/s13/q01.sql", + "../../queries_v2/10000/s13/q93.sql", + "../../queries_v2/10000/s13/q63.sql", + "../../queries_v2/10000/s13/q05.sql", + "../../queries_v2/10000/s13/q56.sql", + "../../queries_v2/10000/s13/q66.sql", + "../../queries_v2/10000/s13/q36.sql", + "../../queries_v2/10000/s13/q82.sql", + "../../queries_v2/10000/s13/q74.sql", + "../../queries_v2/10000/s13/q33.sql", + "../../queries_v2/10000/s13/q38.sql", + "../../queries_v2/10000/s13/q96.sql", + "../../queries_v2/10000/s13/q18.sql", + "../../queries_v2/10000/s13/q65.sql", + "../../queries_v2/10000/s13/q21.sql", + "../../queries_v2/10000/s13/q85.sql", + "../../queries_v2/10000/s13/q78.sql", + "../../queries_v2/10000/s13/q42.sql", + "../../queries_v2/10000/s13/q62.sql", + "../../queries_v2/10000/s13/q19.sql", + "../../queries_v2/10000/s13/q72.sql", + "../../queries_v2/10000/s13/q30.sql", + "../../queries_v2/10000/s13/q16.sql", + "../../queries_v2/10000/s13/q94.sql", + "../../queries_v2/10000/s13/q04.sql", + "../../queries_v2/10000/s13/q71.sql", + "../../queries_v2/10000/s13/q07.sql", + "../../queries_v2/10000/s13/q32.sql", + "../../queries_v2/10000/s13/q22.sql", + "../../queries_v2/10000/s13/q44.sql", + "../../queries_v2/10000/s13/q49.sql", + "../../queries_v2/10000/s13/q67.sql", + "../../queries_v2/10000/s13/q10.sql", + "../../queries_v2/10000/s13/q12.sql", + "../../queries_v2/10000/s13/q11.sql", + "../../queries_v2/10000/s13/q03.sql", + "../../queries_v2/10000/s13/q60.sql", + "../../queries_v2/10000/s13/q48.sql", + "../../queries_v2/10000/s13/q55.sql", + "../../queries_v2/10000/s13/q87.sql", + "../../queries_v2/10000/s13/q08.sql", + "../../queries_v2/10000/s13/q88.sql", + "../../queries_v2/10000/s13/q95.sql", + "../../queries_v2/10000/s13/q15.sql", + "../../queries_v2/10000/s13/q47.sql", + "../../queries_v2/10000/s13/q20.sql", + "../../queries_v2/10000/s13/q52.sql", + "../../queries_v2/10000/s13/q28.sql", + "../../queries_v2/10000/s13/q45.sql", + "../../queries_v2/10000/s13/q57.sql", + "../../queries_v2/10000/s13/q70.sql", + "../../queries_v2/10000/s13/q90.sql", + "../../queries_v2/10000/s13/q02.sql", + "../../queries_v2/10000/s13/q76.sql", + "../../queries_v2/10000/s13/q84.sql", + "../../queries_v2/10000/s13/q73.sql", + "../../queries_v2/10000/s13/q79.sql", + "../../queries_v2/10000/s13/q40.sql", + "../../queries_v2/10000/s13/q31.sql", + "../../queries_v2/10000/s13/q26.sql", + "../../queries_v2/10000/s13/q64.sql", + "../../queries_v2/10000/s13/q51.sql", + "../../queries_v2/10000/s13/q37.sql", + "../../queries_v2/10000/s13/q83.sql", + "../../queries_v2/10000/s13/q24.sql", + "../../queries_v2/10000/s13/q34.sql", + "../../queries_v2/10000/s13/q35.sql", + "../../queries_v2/10000/s13/q86.sql", + "../../queries_v2/10000/s13/q41.sql", + "../../queries_v2/10000/s13/q91.sql", + "../../queries_v2/10000/s13/q27.sql", + "../../queries_v2/10000/s13/q09.sql", + "../../queries_v2/10000/s13/q06.sql", + "../../queries_v2/10000/s13/q59.sql", + "../../queries_v2/10000/s13/q46.sql", + "../../queries_v2/10000/s13/q77.sql", + "../../queries_v2/10000/s13/q97.sql", + "../../queries_v2/10000/s13/q80.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s14.json b/benchmarks/tpc-ds/streams_v2/10000/s14.json new file mode 100644 index 00000000..96db2e37 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s14.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s14/q46.sql", + "../../queries_v2/10000/s14/q54.sql", + "../../queries_v2/10000/s14/q76.sql", + "../../queries_v2/10000/s14/q16.sql", + "../../queries_v2/10000/s14/q42.sql", + "../../queries_v2/10000/s14/q31.sql", + "../../queries_v2/10000/s14/q38.sql", + "../../queries_v2/10000/s14/q29.sql", + "../../queries_v2/10000/s14/q05.sql", + "../../queries_v2/10000/s14/q79.sql", + "../../queries_v2/10000/s14/q24.sql", + "../../queries_v2/10000/s14/q23.sql", + "../../queries_v2/10000/s14/q91.sql", + "../../queries_v2/10000/s14/q14.sql", + "../../queries_v2/10000/s14/q30.sql", + "../../queries_v2/10000/s14/q66.sql", + "../../queries_v2/10000/s14/q06.sql", + "../../queries_v2/10000/s14/q94.sql", + "../../queries_v2/10000/s14/q60.sql", + "../../queries_v2/10000/s14/q95.sql", + "../../queries_v2/10000/s14/q21.sql", + "../../queries_v2/10000/s14/q96.sql", + "../../queries_v2/10000/s14/q04.sql", + "../../queries_v2/10000/s14/q08.sql", + "../../queries_v2/10000/s14/q39.sql", + "../../queries_v2/10000/s14/q89.sql", + "../../queries_v2/10000/s14/q88.sql", + "../../queries_v2/10000/s14/q28.sql", + "../../queries_v2/10000/s14/q55.sql", + "../../queries_v2/10000/s14/q48.sql", + "../../queries_v2/10000/s14/q85.sql", + "../../queries_v2/10000/s14/q97.sql", + "../../queries_v2/10000/s14/q83.sql", + "../../queries_v2/10000/s14/q45.sql", + "../../queries_v2/10000/s14/q20.sql", + "../../queries_v2/10000/s14/q36.sql", + "../../queries_v2/10000/s14/q26.sql", + "../../queries_v2/10000/s14/q77.sql", + "../../queries_v2/10000/s14/q47.sql", + "../../queries_v2/10000/s14/q41.sql", + "../../queries_v2/10000/s14/q58.sql", + "../../queries_v2/10000/s14/q71.sql", + "../../queries_v2/10000/s14/q59.sql", + "../../queries_v2/10000/s14/q27.sql", + "../../queries_v2/10000/s14/q99.sql", + "../../queries_v2/10000/s14/q44.sql", + "../../queries_v2/10000/s14/q65.sql", + "../../queries_v2/10000/s14/q32.sql", + "../../queries_v2/10000/s14/q98.sql", + "../../queries_v2/10000/s14/q33.sql", + "../../queries_v2/10000/s14/q92.sql", + "../../queries_v2/10000/s14/q09.sql", + "../../queries_v2/10000/s14/q82.sql", + "../../queries_v2/10000/s14/q78.sql", + "../../queries_v2/10000/s14/q01.sql", + "../../queries_v2/10000/s14/q86.sql", + "../../queries_v2/10000/s14/q75.sql", + "../../queries_v2/10000/s14/q50.sql", + "../../queries_v2/10000/s14/q49.sql", + "../../queries_v2/10000/s14/q22.sql", + "../../queries_v2/10000/s14/q72.sql", + "../../queries_v2/10000/s14/q19.sql", + "../../queries_v2/10000/s14/q53.sql", + "../../queries_v2/10000/s14/q68.sql", + "../../queries_v2/10000/s14/q43.sql", + "../../queries_v2/10000/s14/q35.sql", + "../../queries_v2/10000/s14/q64.sql", + "../../queries_v2/10000/s14/q93.sql", + "../../queries_v2/10000/s14/q69.sql", + "../../queries_v2/10000/s14/q03.sql", + "../../queries_v2/10000/s14/q15.sql", + "../../queries_v2/10000/s14/q57.sql", + "../../queries_v2/10000/s14/q18.sql", + "../../queries_v2/10000/s14/q07.sql", + "../../queries_v2/10000/s14/q74.sql", + "../../queries_v2/10000/s14/q02.sql", + "../../queries_v2/10000/s14/q34.sql", + "../../queries_v2/10000/s14/q73.sql", + "../../queries_v2/10000/s14/q90.sql", + "../../queries_v2/10000/s14/q37.sql", + "../../queries_v2/10000/s14/q10.sql", + "../../queries_v2/10000/s14/q12.sql", + "../../queries_v2/10000/s14/q11.sql", + "../../queries_v2/10000/s14/q81.sql", + "../../queries_v2/10000/s14/q56.sql", + "../../queries_v2/10000/s14/q62.sql", + "../../queries_v2/10000/s14/q70.sql", + "../../queries_v2/10000/s14/q67.sql", + "../../queries_v2/10000/s14/q40.sql", + "../../queries_v2/10000/s14/q17.sql", + "../../queries_v2/10000/s14/q13.sql", + "../../queries_v2/10000/s14/q63.sql", + "../../queries_v2/10000/s14/q25.sql", + "../../queries_v2/10000/s14/q80.sql", + "../../queries_v2/10000/s14/q52.sql", + "../../queries_v2/10000/s14/q51.sql", + "../../queries_v2/10000/s14/q87.sql", + "../../queries_v2/10000/s14/q61.sql", + "../../queries_v2/10000/s14/q84.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s15.json b/benchmarks/tpc-ds/streams_v2/10000/s15.json new file mode 100644 index 00000000..e8aaadf5 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s15.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s15/q51.sql", + "../../queries_v2/10000/s15/q38.sql", + "../../queries_v2/10000/s15/q74.sql", + "../../queries_v2/10000/s15/q27.sql", + "../../queries_v2/10000/s15/q47.sql", + "../../queries_v2/10000/s15/q37.sql", + "../../queries_v2/10000/s15/q97.sql", + "../../queries_v2/10000/s15/q60.sql", + "../../queries_v2/10000/s15/q39.sql", + "../../queries_v2/10000/s15/q73.sql", + "../../queries_v2/10000/s15/q62.sql", + "../../queries_v2/10000/s15/q46.sql", + "../../queries_v2/10000/s15/q13.sql", + "../../queries_v2/10000/s15/q21.sql", + "../../queries_v2/10000/s15/q59.sql", + "../../queries_v2/10000/s15/q88.sql", + "../../queries_v2/10000/s15/q80.sql", + "../../queries_v2/10000/s15/q99.sql", + "../../queries_v2/10000/s15/q50.sql", + "../../queries_v2/10000/s15/q68.sql", + "../../queries_v2/10000/s15/q36.sql", + "../../queries_v2/10000/s15/q83.sql", + "../../queries_v2/10000/s15/q44.sql", + "../../queries_v2/10000/s15/q19.sql", + "../../queries_v2/10000/s15/q66.sql", + "../../queries_v2/10000/s15/q79.sql", + "../../queries_v2/10000/s15/q53.sql", + "../../queries_v2/10000/s15/q69.sql", + "../../queries_v2/10000/s15/q22.sql", + "../../queries_v2/10000/s15/q49.sql", + "../../queries_v2/10000/s15/q26.sql", + "../../queries_v2/10000/s15/q61.sql", + "../../queries_v2/10000/s15/q56.sql", + "../../queries_v2/10000/s15/q03.sql", + "../../queries_v2/10000/s15/q64.sql", + "../../queries_v2/10000/s15/q28.sql", + "../../queries_v2/10000/s15/q10.sql", + "../../queries_v2/10000/s15/q87.sql", + "../../queries_v2/10000/s15/q35.sql", + "../../queries_v2/10000/s15/q17.sql", + "../../queries_v2/10000/s15/q06.sql", + "../../queries_v2/10000/s15/q65.sql", + "../../queries_v2/10000/s15/q52.sql", + "../../queries_v2/10000/s15/q63.sql", + "../../queries_v2/10000/s15/q76.sql", + "../../queries_v2/10000/s15/q92.sql", + "../../queries_v2/10000/s15/q20.sql", + "../../queries_v2/10000/s15/q98.sql", + "../../queries_v2/10000/s15/q05.sql", + "../../queries_v2/10000/s15/q85.sql", + "../../queries_v2/10000/s15/q24.sql", + "../../queries_v2/10000/s15/q25.sql", + "../../queries_v2/10000/s15/q55.sql", + "../../queries_v2/10000/s15/q77.sql", + "../../queries_v2/10000/s15/q96.sql", + "../../queries_v2/10000/s15/q40.sql", + "../../queries_v2/10000/s15/q30.sql", + "../../queries_v2/10000/s15/q31.sql", + "../../queries_v2/10000/s15/q09.sql", + "../../queries_v2/10000/s15/q33.sql", + "../../queries_v2/10000/s15/q71.sql", + "../../queries_v2/10000/s15/q58.sql", + "../../queries_v2/10000/s15/q29.sql", + "../../queries_v2/10000/s15/q23.sql", + "../../queries_v2/10000/s15/q95.sql", + "../../queries_v2/10000/s15/q67.sql", + "../../queries_v2/10000/s15/q12.sql", + "../../queries_v2/10000/s15/q04.sql", + "../../queries_v2/10000/s15/q14.sql", + "../../queries_v2/10000/s15/q75.sql", + "../../queries_v2/10000/s15/q43.sql", + "../../queries_v2/10000/s15/q15.sql", + "../../queries_v2/10000/s15/q45.sql", + "../../queries_v2/10000/s15/q32.sql", + "../../queries_v2/10000/s15/q48.sql", + "../../queries_v2/10000/s15/q07.sql", + "../../queries_v2/10000/s15/q70.sql", + "../../queries_v2/10000/s15/q34.sql", + "../../queries_v2/10000/s15/q18.sql", + "../../queries_v2/10000/s15/q81.sql", + "../../queries_v2/10000/s15/q78.sql", + "../../queries_v2/10000/s15/q01.sql", + "../../queries_v2/10000/s15/q86.sql", + "../../queries_v2/10000/s15/q54.sql", + "../../queries_v2/10000/s15/q89.sql", + "../../queries_v2/10000/s15/q41.sql", + "../../queries_v2/10000/s15/q57.sql", + "../../queries_v2/10000/s15/q82.sql", + "../../queries_v2/10000/s15/q90.sql", + "../../queries_v2/10000/s15/q94.sql", + "../../queries_v2/10000/s15/q91.sql", + "../../queries_v2/10000/s15/q08.sql", + "../../queries_v2/10000/s15/q16.sql", + "../../queries_v2/10000/s15/q84.sql", + "../../queries_v2/10000/s15/q93.sql", + "../../queries_v2/10000/s15/q11.sql", + "../../queries_v2/10000/s15/q72.sql", + "../../queries_v2/10000/s15/q42.sql", + "../../queries_v2/10000/s15/q02.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s16.json b/benchmarks/tpc-ds/streams_v2/10000/s16.json new file mode 100644 index 00000000..a0f938a0 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s16.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s16/q11.sql", + "../../queries_v2/10000/s16/q97.sql", + "../../queries_v2/10000/s16/q48.sql", + "../../queries_v2/10000/s16/q63.sql", + "../../queries_v2/10000/s16/q35.sql", + "../../queries_v2/10000/s16/q81.sql", + "../../queries_v2/10000/s16/q61.sql", + "../../queries_v2/10000/s16/q50.sql", + "../../queries_v2/10000/s16/q66.sql", + "../../queries_v2/10000/s16/q34.sql", + "../../queries_v2/10000/s16/q41.sql", + "../../queries_v2/10000/s16/q51.sql", + "../../queries_v2/10000/s16/q91.sql", + "../../queries_v2/10000/s16/q36.sql", + "../../queries_v2/10000/s16/q52.sql", + "../../queries_v2/10000/s16/q53.sql", + "../../queries_v2/10000/s16/q84.sql", + "../../queries_v2/10000/s16/q76.sql", + "../../queries_v2/10000/s16/q31.sql", + "../../queries_v2/10000/s16/q23.sql", + "../../queries_v2/10000/s16/q28.sql", + "../../queries_v2/10000/s16/q56.sql", + "../../queries_v2/10000/s16/q92.sql", + "../../queries_v2/10000/s16/q58.sql", + "../../queries_v2/10000/s16/q88.sql", + "../../queries_v2/10000/s16/q73.sql", + "../../queries_v2/10000/s16/q29.sql", + "../../queries_v2/10000/s16/q14.sql", + "../../queries_v2/10000/s16/q33.sql", + "../../queries_v2/10000/s16/q09.sql", + "../../queries_v2/10000/s16/q10.sql", + "../../queries_v2/10000/s16/q42.sql", + "../../queries_v2/10000/s16/q89.sql", + "../../queries_v2/10000/s16/q75.sql", + "../../queries_v2/10000/s16/q12.sql", + "../../queries_v2/10000/s16/q69.sql", + "../../queries_v2/10000/s16/q78.sql", + "../../queries_v2/10000/s16/q72.sql", + "../../queries_v2/10000/s16/q67.sql", + "../../queries_v2/10000/s16/q94.sql", + "../../queries_v2/10000/s16/q80.sql", + "../../queries_v2/10000/s16/q20.sql", + "../../queries_v2/10000/s16/q93.sql", + "../../queries_v2/10000/s16/q08.sql", + "../../queries_v2/10000/s16/q74.sql", + "../../queries_v2/10000/s16/q24.sql", + "../../queries_v2/10000/s16/q64.sql", + "../../queries_v2/10000/s16/q05.sql", + "../../queries_v2/10000/s16/q39.sql", + "../../queries_v2/10000/s16/q26.sql", + "../../queries_v2/10000/s16/q62.sql", + "../../queries_v2/10000/s16/q16.sql", + "../../queries_v2/10000/s16/q22.sql", + "../../queries_v2/10000/s16/q87.sql", + "../../queries_v2/10000/s16/q83.sql", + "../../queries_v2/10000/s16/q90.sql", + "../../queries_v2/10000/s16/q59.sql", + "../../queries_v2/10000/s16/q37.sql", + "../../queries_v2/10000/s16/q25.sql", + "../../queries_v2/10000/s16/q85.sql", + "../../queries_v2/10000/s16/q65.sql", + "../../queries_v2/10000/s16/q06.sql", + "../../queries_v2/10000/s16/q60.sql", + "../../queries_v2/10000/s16/q46.sql", + "../../queries_v2/10000/s16/q68.sql", + "../../queries_v2/10000/s16/q82.sql", + "../../queries_v2/10000/s16/q01.sql", + "../../queries_v2/10000/s16/q44.sql", + "../../queries_v2/10000/s16/q21.sql", + "../../queries_v2/10000/s16/q30.sql", + "../../queries_v2/10000/s16/q95.sql", + "../../queries_v2/10000/s16/q43.sql", + "../../queries_v2/10000/s16/q03.sql", + "../../queries_v2/10000/s16/q98.sql", + "../../queries_v2/10000/s16/q49.sql", + "../../queries_v2/10000/s16/q32.sql", + "../../queries_v2/10000/s16/q57.sql", + "../../queries_v2/10000/s16/q70.sql", + "../../queries_v2/10000/s16/q45.sql", + "../../queries_v2/10000/s16/q54.sql", + "../../queries_v2/10000/s16/q77.sql", + "../../queries_v2/10000/s16/q96.sql", + "../../queries_v2/10000/s16/q40.sql", + "../../queries_v2/10000/s16/q38.sql", + "../../queries_v2/10000/s16/q79.sql", + "../../queries_v2/10000/s16/q17.sql", + "../../queries_v2/10000/s16/q15.sql", + "../../queries_v2/10000/s16/q55.sql", + "../../queries_v2/10000/s16/q18.sql", + "../../queries_v2/10000/s16/q99.sql", + "../../queries_v2/10000/s16/q13.sql", + "../../queries_v2/10000/s16/q19.sql", + "../../queries_v2/10000/s16/q27.sql", + "../../queries_v2/10000/s16/q02.sql", + "../../queries_v2/10000/s16/q04.sql", + "../../queries_v2/10000/s16/q86.sql", + "../../queries_v2/10000/s16/q71.sql", + "../../queries_v2/10000/s16/q47.sql", + "../../queries_v2/10000/s16/q07.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s17.json b/benchmarks/tpc-ds/streams_v2/10000/s17.json new file mode 100644 index 00000000..a4e2df2e --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s17.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s17/q86.sql", + "../../queries_v2/10000/s17/q61.sql", + "../../queries_v2/10000/s17/q49.sql", + "../../queries_v2/10000/s17/q08.sql", + "../../queries_v2/10000/s17/q67.sql", + "../../queries_v2/10000/s17/q54.sql", + "../../queries_v2/10000/s17/q42.sql", + "../../queries_v2/10000/s17/q31.sql", + "../../queries_v2/10000/s17/q88.sql", + "../../queries_v2/10000/s17/q70.sql", + "../../queries_v2/10000/s17/q17.sql", + "../../queries_v2/10000/s17/q11.sql", + "../../queries_v2/10000/s17/q13.sql", + "../../queries_v2/10000/s17/q28.sql", + "../../queries_v2/10000/s17/q93.sql", + "../../queries_v2/10000/s17/q29.sql", + "../../queries_v2/10000/s17/q02.sql", + "../../queries_v2/10000/s17/q74.sql", + "../../queries_v2/10000/s17/q37.sql", + "../../queries_v2/10000/s17/q46.sql", + "../../queries_v2/10000/s17/q69.sql", + "../../queries_v2/10000/s17/q89.sql", + "../../queries_v2/10000/s17/q24.sql", + "../../queries_v2/10000/s17/q06.sql", + "../../queries_v2/10000/s17/q53.sql", + "../../queries_v2/10000/s17/q34.sql", + "../../queries_v2/10000/s17/q60.sql", + "../../queries_v2/10000/s17/q21.sql", + "../../queries_v2/10000/s17/q85.sql", + "../../queries_v2/10000/s17/q25.sql", + "../../queries_v2/10000/s17/q78.sql", + "../../queries_v2/10000/s17/q47.sql", + "../../queries_v2/10000/s17/q79.sql", + "../../queries_v2/10000/s17/q30.sql", + "../../queries_v2/10000/s17/q01.sql", + "../../queries_v2/10000/s17/q14.sql", + "../../queries_v2/10000/s17/q77.sql", + "../../queries_v2/10000/s17/q71.sql", + "../../queries_v2/10000/s17/q82.sql", + "../../queries_v2/10000/s17/q99.sql", + "../../queries_v2/10000/s17/q84.sql", + "../../queries_v2/10000/s17/q64.sql", + "../../queries_v2/10000/s17/q04.sql", + "../../queries_v2/10000/s17/q19.sql", + "../../queries_v2/10000/s17/q48.sql", + "../../queries_v2/10000/s17/q62.sql", + "../../queries_v2/10000/s17/q12.sql", + "../../queries_v2/10000/s17/q39.sql", + "../../queries_v2/10000/s17/q66.sql", + "../../queries_v2/10000/s17/q10.sql", + "../../queries_v2/10000/s17/q41.sql", + "../../queries_v2/10000/s17/q27.sql", + "../../queries_v2/10000/s17/q33.sql", + "../../queries_v2/10000/s17/q72.sql", + "../../queries_v2/10000/s17/q56.sql", + "../../queries_v2/10000/s17/q18.sql", + "../../queries_v2/10000/s17/q52.sql", + "../../queries_v2/10000/s17/q81.sql", + "../../queries_v2/10000/s17/q16.sql", + "../../queries_v2/10000/s17/q26.sql", + "../../queries_v2/10000/s17/q20.sql", + "../../queries_v2/10000/s17/q80.sql", + "../../queries_v2/10000/s17/q50.sql", + "../../queries_v2/10000/s17/q51.sql", + "../../queries_v2/10000/s17/q23.sql", + "../../queries_v2/10000/s17/q55.sql", + "../../queries_v2/10000/s17/q96.sql", + "../../queries_v2/10000/s17/q92.sql", + "../../queries_v2/10000/s17/q36.sql", + "../../queries_v2/10000/s17/q59.sql", + "../../queries_v2/10000/s17/q68.sql", + "../../queries_v2/10000/s17/q95.sql", + "../../queries_v2/10000/s17/q75.sql", + "../../queries_v2/10000/s17/q05.sql", + "../../queries_v2/10000/s17/q09.sql", + "../../queries_v2/10000/s17/q98.sql", + "../../queries_v2/10000/s17/q15.sql", + "../../queries_v2/10000/s17/q57.sql", + "../../queries_v2/10000/s17/q03.sql", + "../../queries_v2/10000/s17/q38.sql", + "../../queries_v2/10000/s17/q87.sql", + "../../queries_v2/10000/s17/q83.sql", + "../../queries_v2/10000/s17/q90.sql", + "../../queries_v2/10000/s17/q97.sql", + "../../queries_v2/10000/s17/q73.sql", + "../../queries_v2/10000/s17/q94.sql", + "../../queries_v2/10000/s17/q43.sql", + "../../queries_v2/10000/s17/q22.sql", + "../../queries_v2/10000/s17/q45.sql", + "../../queries_v2/10000/s17/q76.sql", + "../../queries_v2/10000/s17/q91.sql", + "../../queries_v2/10000/s17/q58.sql", + "../../queries_v2/10000/s17/q63.sql", + "../../queries_v2/10000/s17/q07.sql", + "../../queries_v2/10000/s17/q44.sql", + "../../queries_v2/10000/s17/q40.sql", + "../../queries_v2/10000/s17/q65.sql", + "../../queries_v2/10000/s17/q35.sql", + "../../queries_v2/10000/s17/q32.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s18.json b/benchmarks/tpc-ds/streams_v2/10000/s18.json new file mode 100644 index 00000000..0abc28a6 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s18.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s18/q40.sql", + "../../queries_v2/10000/s18/q42.sql", + "../../queries_v2/10000/s18/q09.sql", + "../../queries_v2/10000/s18/q19.sql", + "../../queries_v2/10000/s18/q82.sql", + "../../queries_v2/10000/s18/q38.sql", + "../../queries_v2/10000/s18/q47.sql", + "../../queries_v2/10000/s18/q37.sql", + "../../queries_v2/10000/s18/q53.sql", + "../../queries_v2/10000/s18/q57.sql", + "../../queries_v2/10000/s18/q94.sql", + "../../queries_v2/10000/s18/q86.sql", + "../../queries_v2/10000/s18/q91.sql", + "../../queries_v2/10000/s18/q69.sql", + "../../queries_v2/10000/s18/q04.sql", + "../../queries_v2/10000/s18/q60.sql", + "../../queries_v2/10000/s18/q07.sql", + "../../queries_v2/10000/s18/q48.sql", + "../../queries_v2/10000/s18/q81.sql", + "../../queries_v2/10000/s18/q51.sql", + "../../queries_v2/10000/s18/q14.sql", + "../../queries_v2/10000/s18/q79.sql", + "../../queries_v2/10000/s18/q62.sql", + "../../queries_v2/10000/s18/q80.sql", + "../../queries_v2/10000/s18/q29.sql", + "../../queries_v2/10000/s18/q70.sql", + "../../queries_v2/10000/s18/q50.sql", + "../../queries_v2/10000/s18/q36.sql", + "../../queries_v2/10000/s18/q26.sql", + "../../queries_v2/10000/s18/q16.sql", + "../../queries_v2/10000/s18/q77.sql", + "../../queries_v2/10000/s18/q35.sql", + "../../queries_v2/10000/s18/q73.sql", + "../../queries_v2/10000/s18/q59.sql", + "../../queries_v2/10000/s18/q96.sql", + "../../queries_v2/10000/s18/q21.sql", + "../../queries_v2/10000/s18/q87.sql", + "../../queries_v2/10000/s18/q65.sql", + "../../queries_v2/10000/s18/q55.sql", + "../../queries_v2/10000/s18/q76.sql", + "../../queries_v2/10000/s18/q02.sql", + "../../queries_v2/10000/s18/q12.sql", + "../../queries_v2/10000/s18/q44.sql", + "../../queries_v2/10000/s18/q58.sql", + "../../queries_v2/10000/s18/q49.sql", + "../../queries_v2/10000/s18/q41.sql", + "../../queries_v2/10000/s18/q01.sql", + "../../queries_v2/10000/s18/q66.sql", + "../../queries_v2/10000/s18/q88.sql", + "../../queries_v2/10000/s18/q78.sql", + "../../queries_v2/10000/s18/q17.sql", + "../../queries_v2/10000/s18/q63.sql", + "../../queries_v2/10000/s18/q85.sql", + "../../queries_v2/10000/s18/q71.sql", + "../../queries_v2/10000/s18/q89.sql", + "../../queries_v2/10000/s18/q45.sql", + "../../queries_v2/10000/s18/q93.sql", + "../../queries_v2/10000/s18/q54.sql", + "../../queries_v2/10000/s18/q27.sql", + "../../queries_v2/10000/s18/q10.sql", + "../../queries_v2/10000/s18/q64.sql", + "../../queries_v2/10000/s18/q84.sql", + "../../queries_v2/10000/s18/q31.sql", + "../../queries_v2/10000/s18/q11.sql", + "../../queries_v2/10000/s18/q46.sql", + "../../queries_v2/10000/s18/q22.sql", + "../../queries_v2/10000/s18/q83.sql", + "../../queries_v2/10000/s18/q24.sql", + "../../queries_v2/10000/s18/q28.sql", + "../../queries_v2/10000/s18/q52.sql", + "../../queries_v2/10000/s18/q23.sql", + "../../queries_v2/10000/s18/q68.sql", + "../../queries_v2/10000/s18/q30.sql", + "../../queries_v2/10000/s18/q39.sql", + "../../queries_v2/10000/s18/q25.sql", + "../../queries_v2/10000/s18/q05.sql", + "../../queries_v2/10000/s18/q43.sql", + "../../queries_v2/10000/s18/q15.sql", + "../../queries_v2/10000/s18/q75.sql", + "../../queries_v2/10000/s18/q97.sql", + "../../queries_v2/10000/s18/q72.sql", + "../../queries_v2/10000/s18/q56.sql", + "../../queries_v2/10000/s18/q18.sql", + "../../queries_v2/10000/s18/q61.sql", + "../../queries_v2/10000/s18/q34.sql", + "../../queries_v2/10000/s18/q99.sql", + "../../queries_v2/10000/s18/q95.sql", + "../../queries_v2/10000/s18/q33.sql", + "../../queries_v2/10000/s18/q03.sql", + "../../queries_v2/10000/s18/q74.sql", + "../../queries_v2/10000/s18/q13.sql", + "../../queries_v2/10000/s18/q06.sql", + "../../queries_v2/10000/s18/q08.sql", + "../../queries_v2/10000/s18/q32.sql", + "../../queries_v2/10000/s18/q92.sql", + "../../queries_v2/10000/s18/q90.sql", + "../../queries_v2/10000/s18/q20.sql", + "../../queries_v2/10000/s18/q67.sql", + "../../queries_v2/10000/s18/q98.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s19.json b/benchmarks/tpc-ds/streams_v2/10000/s19.json new file mode 100644 index 00000000..c18c537d --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s19.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s19/q90.sql", + "../../queries_v2/10000/s19/q47.sql", + "../../queries_v2/10000/s19/q25.sql", + "../../queries_v2/10000/s19/q58.sql", + "../../queries_v2/10000/s19/q55.sql", + "../../queries_v2/10000/s19/q97.sql", + "../../queries_v2/10000/s19/q35.sql", + "../../queries_v2/10000/s19/q81.sql", + "../../queries_v2/10000/s19/q29.sql", + "../../queries_v2/10000/s19/q15.sql", + "../../queries_v2/10000/s19/q99.sql", + "../../queries_v2/10000/s19/q40.sql", + "../../queries_v2/10000/s19/q13.sql", + "../../queries_v2/10000/s19/q14.sql", + "../../queries_v2/10000/s19/q44.sql", + "../../queries_v2/10000/s19/q50.sql", + "../../queries_v2/10000/s19/q32.sql", + "../../queries_v2/10000/s19/q49.sql", + "../../queries_v2/10000/s19/q54.sql", + "../../queries_v2/10000/s19/q11.sql", + "../../queries_v2/10000/s19/q21.sql", + "../../queries_v2/10000/s19/q73.sql", + "../../queries_v2/10000/s19/q41.sql", + "../../queries_v2/10000/s19/q84.sql", + "../../queries_v2/10000/s19/q60.sql", + "../../queries_v2/10000/s19/q57.sql", + "../../queries_v2/10000/s19/q31.sql", + "../../queries_v2/10000/s19/q28.sql", + "../../queries_v2/10000/s19/q10.sql", + "../../queries_v2/10000/s19/q27.sql", + "../../queries_v2/10000/s19/q87.sql", + "../../queries_v2/10000/s19/q67.sql", + "../../queries_v2/10000/s19/q34.sql", + "../../queries_v2/10000/s19/q52.sql", + "../../queries_v2/10000/s19/q83.sql", + "../../queries_v2/10000/s19/q36.sql", + "../../queries_v2/10000/s19/q72.sql", + "../../queries_v2/10000/s19/q20.sql", + "../../queries_v2/10000/s19/q22.sql", + "../../queries_v2/10000/s19/q74.sql", + "../../queries_v2/10000/s19/q07.sql", + "../../queries_v2/10000/s19/q01.sql", + "../../queries_v2/10000/s19/q92.sql", + "../../queries_v2/10000/s19/q06.sql", + "../../queries_v2/10000/s19/q09.sql", + "../../queries_v2/10000/s19/q17.sql", + "../../queries_v2/10000/s19/q96.sql", + "../../queries_v2/10000/s19/q88.sql", + "../../queries_v2/10000/s19/q53.sql", + "../../queries_v2/10000/s19/q77.sql", + "../../queries_v2/10000/s19/q94.sql", + "../../queries_v2/10000/s19/q08.sql", + "../../queries_v2/10000/s19/q26.sql", + "../../queries_v2/10000/s19/q65.sql", + "../../queries_v2/10000/s19/q79.sql", + "../../queries_v2/10000/s19/q03.sql", + "../../queries_v2/10000/s19/q04.sql", + "../../queries_v2/10000/s19/q38.sql", + "../../queries_v2/10000/s19/q63.sql", + "../../queries_v2/10000/s19/q78.sql", + "../../queries_v2/10000/s19/q12.sql", + "../../queries_v2/10000/s19/q02.sql", + "../../queries_v2/10000/s19/q37.sql", + "../../queries_v2/10000/s19/q86.sql", + "../../queries_v2/10000/s19/q51.sql", + "../../queries_v2/10000/s19/q33.sql", + "../../queries_v2/10000/s19/q56.sql", + "../../queries_v2/10000/s19/q62.sql", + "../../queries_v2/10000/s19/q69.sql", + "../../queries_v2/10000/s19/q93.sql", + "../../queries_v2/10000/s19/q46.sql", + "../../queries_v2/10000/s19/q23.sql", + "../../queries_v2/10000/s19/q59.sql", + "../../queries_v2/10000/s19/q66.sql", + "../../queries_v2/10000/s19/q16.sql", + "../../queries_v2/10000/s19/q39.sql", + "../../queries_v2/10000/s19/q95.sql", + "../../queries_v2/10000/s19/q43.sql", + "../../queries_v2/10000/s19/q30.sql", + "../../queries_v2/10000/s19/q61.sql", + "../../queries_v2/10000/s19/q71.sql", + "../../queries_v2/10000/s19/q89.sql", + "../../queries_v2/10000/s19/q45.sql", + "../../queries_v2/10000/s19/q42.sql", + "../../queries_v2/10000/s19/q70.sql", + "../../queries_v2/10000/s19/q76.sql", + "../../queries_v2/10000/s19/q68.sql", + "../../queries_v2/10000/s19/q85.sql", + "../../queries_v2/10000/s19/q75.sql", + "../../queries_v2/10000/s19/q48.sql", + "../../queries_v2/10000/s19/q91.sql", + "../../queries_v2/10000/s19/q80.sql", + "../../queries_v2/10000/s19/q19.sql", + "../../queries_v2/10000/s19/q98.sql", + "../../queries_v2/10000/s19/q24.sql", + "../../queries_v2/10000/s19/q18.sql", + "../../queries_v2/10000/s19/q64.sql", + "../../queries_v2/10000/s19/q82.sql", + "../../queries_v2/10000/s19/q05.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s2.json b/benchmarks/tpc-ds/streams_v2/10000/s2.json new file mode 100644 index 00000000..63e1cc3e --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s2.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s2/q56.sql", + "../../queries_v2/10000/s2/q98.sql", + "../../queries_v2/10000/s2/q59.sql", + "../../queries_v2/10000/s2/q24.sql", + "../../queries_v2/10000/s2/q88.sql", + "../../queries_v2/10000/s2/q02.sql", + "../../queries_v2/10000/s2/q05.sql", + "../../queries_v2/10000/s2/q06.sql", + "../../queries_v2/10000/s2/q27.sql", + "../../queries_v2/10000/s2/q87.sql", + "../../queries_v2/10000/s2/q90.sql", + "../../queries_v2/10000/s2/q83.sql", + "../../queries_v2/10000/s2/q91.sql", + "../../queries_v2/10000/s2/q28.sql", + "../../queries_v2/10000/s2/q68.sql", + "../../queries_v2/10000/s2/q08.sql", + "../../queries_v2/10000/s2/q76.sql", + "../../queries_v2/10000/s2/q75.sql", + "../../queries_v2/10000/s2/q80.sql", + "../../queries_v2/10000/s2/q01.sql", + "../../queries_v2/10000/s2/q69.sql", + "../../queries_v2/10000/s2/q26.sql", + "../../queries_v2/10000/s2/q11.sql", + "../../queries_v2/10000/s2/q17.sql", + "../../queries_v2/10000/s2/q63.sql", + "../../queries_v2/10000/s2/q77.sql", + "../../queries_v2/10000/s2/q19.sql", + "../../queries_v2/10000/s2/q21.sql", + "../../queries_v2/10000/s2/q31.sql", + "../../queries_v2/10000/s2/q93.sql", + "../../queries_v2/10000/s2/q54.sql", + "../../queries_v2/10000/s2/q39.sql", + "../../queries_v2/10000/s2/q10.sql", + "../../queries_v2/10000/s2/q15.sql", + "../../queries_v2/10000/s2/q55.sql", + "../../queries_v2/10000/s2/q14.sql", + "../../queries_v2/10000/s2/q38.sql", + "../../queries_v2/10000/s2/q42.sql", + "../../queries_v2/10000/s2/q53.sql", + "../../queries_v2/10000/s2/q45.sql", + "../../queries_v2/10000/s2/q99.sql", + "../../queries_v2/10000/s2/q67.sql", + "../../queries_v2/10000/s2/q23.sql", + "../../queries_v2/10000/s2/q62.sql", + "../../queries_v2/10000/s2/q30.sql", + "../../queries_v2/10000/s2/q86.sql", + "../../queries_v2/10000/s2/q82.sql", + "../../queries_v2/10000/s2/q25.sql", + "../../queries_v2/10000/s2/q16.sql", + "../../queries_v2/10000/s2/q81.sql", + "../../queries_v2/10000/s2/q40.sql", + "../../queries_v2/10000/s2/q44.sql", + "../../queries_v2/10000/s2/q50.sql", + "../../queries_v2/10000/s2/q61.sql", + "../../queries_v2/10000/s2/q85.sql", + "../../queries_v2/10000/s2/q73.sql", + "../../queries_v2/10000/s2/q95.sql", + "../../queries_v2/10000/s2/q84.sql", + "../../queries_v2/10000/s2/q04.sql", + "../../queries_v2/10000/s2/q37.sql", + "../../queries_v2/10000/s2/q35.sql", + "../../queries_v2/10000/s2/q94.sql", + "../../queries_v2/10000/s2/q58.sql", + "../../queries_v2/10000/s2/q96.sql", + "../../queries_v2/10000/s2/q12.sql", + "../../queries_v2/10000/s2/q29.sql", + "../../queries_v2/10000/s2/q22.sql", + "../../queries_v2/10000/s2/q51.sql", + "../../queries_v2/10000/s2/q36.sql", + "../../queries_v2/10000/s2/q43.sql", + "../../queries_v2/10000/s2/q64.sql", + "../../queries_v2/10000/s2/q20.sql", + "../../queries_v2/10000/s2/q57.sql", + "../../queries_v2/10000/s2/q09.sql", + "../../queries_v2/10000/s2/q52.sql", + "../../queries_v2/10000/s2/q49.sql", + "../../queries_v2/10000/s2/q71.sql", + "../../queries_v2/10000/s2/q72.sql", + "../../queries_v2/10000/s2/q70.sql", + "../../queries_v2/10000/s2/q07.sql", + "../../queries_v2/10000/s2/q97.sql", + "../../queries_v2/10000/s2/q33.sql", + "../../queries_v2/10000/s2/q79.sql", + "../../queries_v2/10000/s2/q32.sql", + "../../queries_v2/10000/s2/q78.sql", + "../../queries_v2/10000/s2/q18.sql", + "../../queries_v2/10000/s2/q65.sql", + "../../queries_v2/10000/s2/q60.sql", + "../../queries_v2/10000/s2/q34.sql", + "../../queries_v2/10000/s2/q03.sql", + "../../queries_v2/10000/s2/q13.sql", + "../../queries_v2/10000/s2/q41.sql", + "../../queries_v2/10000/s2/q92.sql", + "../../queries_v2/10000/s2/q74.sql", + "../../queries_v2/10000/s2/q46.sql", + "../../queries_v2/10000/s2/q89.sql", + "../../queries_v2/10000/s2/q47.sql", + "../../queries_v2/10000/s2/q66.sql", + "../../queries_v2/10000/s2/q48.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s20.json b/benchmarks/tpc-ds/streams_v2/10000/s20.json new file mode 100644 index 00000000..fb030ee8 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s20.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s20/q18.sql", + "../../queries_v2/10000/s20/q35.sql", + "../../queries_v2/10000/s20/q16.sql", + "../../queries_v2/10000/s20/q06.sql", + "../../queries_v2/10000/s20/q22.sql", + "../../queries_v2/10000/s20/q61.sql", + "../../queries_v2/10000/s20/q67.sql", + "../../queries_v2/10000/s20/q54.sql", + "../../queries_v2/10000/s20/q60.sql", + "../../queries_v2/10000/s20/q43.sql", + "../../queries_v2/10000/s20/q76.sql", + "../../queries_v2/10000/s20/q90.sql", + "../../queries_v2/10000/s20/q91.sql", + "../../queries_v2/10000/s20/q21.sql", + "../../queries_v2/10000/s20/q92.sql", + "../../queries_v2/10000/s20/q31.sql", + "../../queries_v2/10000/s20/q98.sql", + "../../queries_v2/10000/s20/q09.sql", + "../../queries_v2/10000/s20/q38.sql", + "../../queries_v2/10000/s20/q86.sql", + "../../queries_v2/10000/s20/q36.sql", + "../../queries_v2/10000/s20/q34.sql", + "../../queries_v2/10000/s20/q17.sql", + "../../queries_v2/10000/s20/q02.sql", + "../../queries_v2/10000/s20/q50.sql", + "../../queries_v2/10000/s20/q15.sql", + "../../queries_v2/10000/s20/q37.sql", + "../../queries_v2/10000/s20/q69.sql", + "../../queries_v2/10000/s20/q78.sql", + "../../queries_v2/10000/s20/q63.sql", + "../../queries_v2/10000/s20/q72.sql", + "../../queries_v2/10000/s20/q82.sql", + "../../queries_v2/10000/s20/q70.sql", + "../../queries_v2/10000/s20/q93.sql", + "../../queries_v2/10000/s20/q56.sql", + "../../queries_v2/10000/s20/q28.sql", + "../../queries_v2/10000/s20/q71.sql", + "../../queries_v2/10000/s20/q64.sql", + "../../queries_v2/10000/s20/q33.sql", + "../../queries_v2/10000/s20/q48.sql", + "../../queries_v2/10000/s20/q32.sql", + "../../queries_v2/10000/s20/q96.sql", + "../../queries_v2/10000/s20/q24.sql", + "../../queries_v2/10000/s20/q80.sql", + "../../queries_v2/10000/s20/q25.sql", + "../../queries_v2/10000/s20/q94.sql", + "../../queries_v2/10000/s20/q83.sql", + "../../queries_v2/10000/s20/q53.sql", + "../../queries_v2/10000/s20/q29.sql", + "../../queries_v2/10000/s20/q87.sql", + "../../queries_v2/10000/s20/q99.sql", + "../../queries_v2/10000/s20/q19.sql", + "../../queries_v2/10000/s20/q10.sql", + "../../queries_v2/10000/s20/q20.sql", + "../../queries_v2/10000/s20/q73.sql", + "../../queries_v2/10000/s20/q75.sql", + "../../queries_v2/10000/s20/q44.sql", + "../../queries_v2/10000/s20/q97.sql", + "../../queries_v2/10000/s20/q08.sql", + "../../queries_v2/10000/s20/q77.sql", + "../../queries_v2/10000/s20/q01.sql", + "../../queries_v2/10000/s20/q07.sql", + "../../queries_v2/10000/s20/q81.sql", + "../../queries_v2/10000/s20/q40.sql", + "../../queries_v2/10000/s20/q11.sql", + "../../queries_v2/10000/s20/q85.sql", + "../../queries_v2/10000/s20/q89.sql", + "../../queries_v2/10000/s20/q41.sql", + "../../queries_v2/10000/s20/q14.sql", + "../../queries_v2/10000/s20/q04.sql", + "../../queries_v2/10000/s20/q51.sql", + "../../queries_v2/10000/s20/q46.sql", + "../../queries_v2/10000/s20/q52.sql", + "../../queries_v2/10000/s20/q88.sql", + "../../queries_v2/10000/s20/q27.sql", + "../../queries_v2/10000/s20/q66.sql", + "../../queries_v2/10000/s20/q68.sql", + "../../queries_v2/10000/s20/q95.sql", + "../../queries_v2/10000/s20/q59.sql", + "../../queries_v2/10000/s20/q42.sql", + "../../queries_v2/10000/s20/q65.sql", + "../../queries_v2/10000/s20/q79.sql", + "../../queries_v2/10000/s20/q03.sql", + "../../queries_v2/10000/s20/q47.sql", + "../../queries_v2/10000/s20/q57.sql", + "../../queries_v2/10000/s20/q74.sql", + "../../queries_v2/10000/s20/q23.sql", + "../../queries_v2/10000/s20/q26.sql", + "../../queries_v2/10000/s20/q30.sql", + "../../queries_v2/10000/s20/q49.sql", + "../../queries_v2/10000/s20/q13.sql", + "../../queries_v2/10000/s20/q84.sql", + "../../queries_v2/10000/s20/q58.sql", + "../../queries_v2/10000/s20/q05.sql", + "../../queries_v2/10000/s20/q62.sql", + "../../queries_v2/10000/s20/q45.sql", + "../../queries_v2/10000/s20/q12.sql", + "../../queries_v2/10000/s20/q55.sql", + "../../queries_v2/10000/s20/q39.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s3.json b/benchmarks/tpc-ds/streams_v2/10000/s3.json new file mode 100644 index 00000000..03340b43 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s3.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s3/q89.sql", + "../../queries_v2/10000/s3/q05.sql", + "../../queries_v2/10000/s3/q52.sql", + "../../queries_v2/10000/s3/q62.sql", + "../../queries_v2/10000/s3/q53.sql", + "../../queries_v2/10000/s3/q07.sql", + "../../queries_v2/10000/s3/q39.sql", + "../../queries_v2/10000/s3/q80.sql", + "../../queries_v2/10000/s3/q63.sql", + "../../queries_v2/10000/s3/q72.sql", + "../../queries_v2/10000/s3/q18.sql", + "../../queries_v2/10000/s3/q56.sql", + "../../queries_v2/10000/s3/q13.sql", + "../../queries_v2/10000/s3/q69.sql", + "../../queries_v2/10000/s3/q23.sql", + "../../queries_v2/10000/s3/q19.sql", + "../../queries_v2/10000/s3/q74.sql", + "../../queries_v2/10000/s3/q30.sql", + "../../queries_v2/10000/s3/q84.sql", + "../../queries_v2/10000/s3/q96.sql", + "../../queries_v2/10000/s3/q14.sql", + "../../queries_v2/10000/s3/q10.sql", + "../../queries_v2/10000/s3/q86.sql", + "../../queries_v2/10000/s3/q94.sql", + "../../queries_v2/10000/s3/q08.sql", + "../../queries_v2/10000/s3/q87.sql", + "../../queries_v2/10000/s3/q58.sql", + "../../queries_v2/10000/s3/q36.sql", + "../../queries_v2/10000/s3/q37.sql", + "../../queries_v2/10000/s3/q04.sql", + "../../queries_v2/10000/s3/q38.sql", + "../../queries_v2/10000/s3/q66.sql", + "../../queries_v2/10000/s3/q78.sql", + "../../queries_v2/10000/s3/q43.sql", + "../../queries_v2/10000/s3/q22.sql", + "../../queries_v2/10000/s3/q21.sql", + "../../queries_v2/10000/s3/q97.sql", + "../../queries_v2/10000/s3/q47.sql", + "../../queries_v2/10000/s3/q29.sql", + "../../queries_v2/10000/s3/q03.sql", + "../../queries_v2/10000/s3/q76.sql", + "../../queries_v2/10000/s3/q82.sql", + "../../queries_v2/10000/s3/q46.sql", + "../../queries_v2/10000/s3/q41.sql", + "../../queries_v2/10000/s3/q59.sql", + "../../queries_v2/10000/s3/q40.sql", + "../../queries_v2/10000/s3/q55.sql", + "../../queries_v2/10000/s3/q16.sql", + "../../queries_v2/10000/s3/q27.sql", + "../../queries_v2/10000/s3/q54.sql", + "../../queries_v2/10000/s3/q90.sql", + "../../queries_v2/10000/s3/q92.sql", + "../../queries_v2/10000/s3/q31.sql", + "../../queries_v2/10000/s3/q42.sql", + "../../queries_v2/10000/s3/q26.sql", + "../../queries_v2/10000/s3/q34.sql", + "../../queries_v2/10000/s3/q68.sql", + "../../queries_v2/10000/s3/q02.sql", + "../../queries_v2/10000/s3/q44.sql", + "../../queries_v2/10000/s3/q81.sql", + "../../queries_v2/10000/s3/q67.sql", + "../../queries_v2/10000/s3/q99.sql", + "../../queries_v2/10000/s3/q06.sql", + "../../queries_v2/10000/s3/q83.sql", + "../../queries_v2/10000/s3/q01.sql", + "../../queries_v2/10000/s3/q60.sql", + "../../queries_v2/10000/s3/q33.sql", + "../../queries_v2/10000/s3/q11.sql", + "../../queries_v2/10000/s3/q28.sql", + "../../queries_v2/10000/s3/q95.sql", + "../../queries_v2/10000/s3/q12.sql", + "../../queries_v2/10000/s3/q64.sql", + "../../queries_v2/10000/s3/q15.sql", + "../../queries_v2/10000/s3/q25.sql", + "../../queries_v2/10000/s3/q93.sql", + "../../queries_v2/10000/s3/q09.sql", + "../../queries_v2/10000/s3/q65.sql", + "../../queries_v2/10000/s3/q71.sql", + "../../queries_v2/10000/s3/q57.sql", + "../../queries_v2/10000/s3/q32.sql", + "../../queries_v2/10000/s3/q61.sql", + "../../queries_v2/10000/s3/q85.sql", + "../../queries_v2/10000/s3/q73.sql", + "../../queries_v2/10000/s3/q98.sql", + "../../queries_v2/10000/s3/q77.sql", + "../../queries_v2/10000/s3/q45.sql", + "../../queries_v2/10000/s3/q20.sql", + "../../queries_v2/10000/s3/q50.sql", + "../../queries_v2/10000/s3/q70.sql", + "../../queries_v2/10000/s3/q75.sql", + "../../queries_v2/10000/s3/q91.sql", + "../../queries_v2/10000/s3/q17.sql", + "../../queries_v2/10000/s3/q24.sql", + "../../queries_v2/10000/s3/q48.sql", + "../../queries_v2/10000/s3/q51.sql", + "../../queries_v2/10000/s3/q79.sql", + "../../queries_v2/10000/s3/q35.sql", + "../../queries_v2/10000/s3/q88.sql", + "../../queries_v2/10000/s3/q49.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s4.json b/benchmarks/tpc-ds/streams_v2/10000/s4.json new file mode 100644 index 00000000..34f74a7d --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s4.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s4/q79.sql", + "../../queries_v2/10000/s4/q39.sql", + "../../queries_v2/10000/s4/q93.sql", + "../../queries_v2/10000/s4/q41.sql", + "../../queries_v2/10000/s4/q29.sql", + "../../queries_v2/10000/s4/q32.sql", + "../../queries_v2/10000/s4/q66.sql", + "../../queries_v2/10000/s4/q84.sql", + "../../queries_v2/10000/s4/q08.sql", + "../../queries_v2/10000/s4/q71.sql", + "../../queries_v2/10000/s4/q45.sql", + "../../queries_v2/10000/s4/q89.sql", + "../../queries_v2/10000/s4/q91.sql", + "../../queries_v2/10000/s4/q14.sql", + "../../queries_v2/10000/s4/q46.sql", + "../../queries_v2/10000/s4/q58.sql", + "../../queries_v2/10000/s4/q48.sql", + "../../queries_v2/10000/s4/q59.sql", + "../../queries_v2/10000/s4/q02.sql", + "../../queries_v2/10000/s4/q83.sql", + "../../queries_v2/10000/s4/q21.sql", + "../../queries_v2/10000/s4/q78.sql", + "../../queries_v2/10000/s4/q40.sql", + "../../queries_v2/10000/s4/q99.sql", + "../../queries_v2/10000/s4/q19.sql", + "../../queries_v2/10000/s4/q72.sql", + "../../queries_v2/10000/s4/q06.sql", + "../../queries_v2/10000/s4/q28.sql", + "../../queries_v2/10000/s4/q81.sql", + "../../queries_v2/10000/s4/q44.sql", + "../../queries_v2/10000/s4/q97.sql", + "../../queries_v2/10000/s4/q88.sql", + "../../queries_v2/10000/s4/q77.sql", + "../../queries_v2/10000/s4/q95.sql", + "../../queries_v2/10000/s4/q33.sql", + "../../queries_v2/10000/s4/q36.sql", + "../../queries_v2/10000/s4/q61.sql", + "../../queries_v2/10000/s4/q35.sql", + "../../queries_v2/10000/s4/q60.sql", + "../../queries_v2/10000/s4/q75.sql", + "../../queries_v2/10000/s4/q74.sql", + "../../queries_v2/10000/s4/q55.sql", + "../../queries_v2/10000/s4/q51.sql", + "../../queries_v2/10000/s4/q17.sql", + "../../queries_v2/10000/s4/q52.sql", + "../../queries_v2/10000/s4/q90.sql", + "../../queries_v2/10000/s4/q22.sql", + "../../queries_v2/10000/s4/q27.sql", + "../../queries_v2/10000/s4/q63.sql", + "../../queries_v2/10000/s4/q38.sql", + "../../queries_v2/10000/s4/q18.sql", + "../../queries_v2/10000/s4/q24.sql", + "../../queries_v2/10000/s4/q37.sql", + "../../queries_v2/10000/s4/q47.sql", + "../../queries_v2/10000/s4/q10.sql", + "../../queries_v2/10000/s4/q70.sql", + "../../queries_v2/10000/s4/q23.sql", + "../../queries_v2/10000/s4/q07.sql", + "../../queries_v2/10000/s4/q92.sql", + "../../queries_v2/10000/s4/q54.sql", + "../../queries_v2/10000/s4/q82.sql", + "../../queries_v2/10000/s4/q76.sql", + "../../queries_v2/10000/s4/q80.sql", + "../../queries_v2/10000/s4/q56.sql", + "../../queries_v2/10000/s4/q96.sql", + "../../queries_v2/10000/s4/q50.sql", + "../../queries_v2/10000/s4/q85.sql", + "../../queries_v2/10000/s4/q86.sql", + "../../queries_v2/10000/s4/q69.sql", + "../../queries_v2/10000/s4/q68.sql", + "../../queries_v2/10000/s4/q01.sql", + "../../queries_v2/10000/s4/q12.sql", + "../../queries_v2/10000/s4/q43.sql", + "../../queries_v2/10000/s4/q16.sql", + "../../queries_v2/10000/s4/q04.sql", + "../../queries_v2/10000/s4/q25.sql", + "../../queries_v2/10000/s4/q20.sql", + "../../queries_v2/10000/s4/q65.sql", + "../../queries_v2/10000/s4/q15.sql", + "../../queries_v2/10000/s4/q98.sql", + "../../queries_v2/10000/s4/q42.sql", + "../../queries_v2/10000/s4/q26.sql", + "../../queries_v2/10000/s4/q34.sql", + "../../queries_v2/10000/s4/q05.sql", + "../../queries_v2/10000/s4/q87.sql", + "../../queries_v2/10000/s4/q03.sql", + "../../queries_v2/10000/s4/q64.sql", + "../../queries_v2/10000/s4/q31.sql", + "../../queries_v2/10000/s4/q57.sql", + "../../queries_v2/10000/s4/q30.sql", + "../../queries_v2/10000/s4/q13.sql", + "../../queries_v2/10000/s4/q94.sql", + "../../queries_v2/10000/s4/q62.sql", + "../../queries_v2/10000/s4/q49.sql", + "../../queries_v2/10000/s4/q11.sql", + "../../queries_v2/10000/s4/q73.sql", + "../../queries_v2/10000/s4/q67.sql", + "../../queries_v2/10000/s4/q53.sql", + "../../queries_v2/10000/s4/q09.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s5.json b/benchmarks/tpc-ds/streams_v2/10000/s5.json new file mode 100644 index 00000000..def1e224 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s5.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s5/q73.sql", + "../../queries_v2/10000/s5/q66.sql", + "../../queries_v2/10000/s5/q04.sql", + "../../queries_v2/10000/s5/q17.sql", + "../../queries_v2/10000/s5/q60.sql", + "../../queries_v2/10000/s5/q98.sql", + "../../queries_v2/10000/s5/q88.sql", + "../../queries_v2/10000/s5/q02.sql", + "../../queries_v2/10000/s5/q19.sql", + "../../queries_v2/10000/s5/q65.sql", + "../../queries_v2/10000/s5/q03.sql", + "../../queries_v2/10000/s5/q79.sql", + "../../queries_v2/10000/s5/q13.sql", + "../../queries_v2/10000/s5/q21.sql", + "../../queries_v2/10000/s5/q51.sql", + "../../queries_v2/10000/s5/q06.sql", + "../../queries_v2/10000/s5/q49.sql", + "../../queries_v2/10000/s5/q52.sql", + "../../queries_v2/10000/s5/q07.sql", + "../../queries_v2/10000/s5/q56.sql", + "../../queries_v2/10000/s5/q36.sql", + "../../queries_v2/10000/s5/q77.sql", + "../../queries_v2/10000/s5/q90.sql", + "../../queries_v2/10000/s5/q76.sql", + "../../queries_v2/10000/s5/q58.sql", + "../../queries_v2/10000/s5/q71.sql", + "../../queries_v2/10000/s5/q80.sql", + "../../queries_v2/10000/s5/q69.sql", + "../../queries_v2/10000/s5/q54.sql", + "../../queries_v2/10000/s5/q92.sql", + "../../queries_v2/10000/s5/q61.sql", + "../../queries_v2/10000/s5/q53.sql", + "../../queries_v2/10000/s5/q87.sql", + "../../queries_v2/10000/s5/q68.sql", + "../../queries_v2/10000/s5/q85.sql", + "../../queries_v2/10000/s5/q28.sql", + "../../queries_v2/10000/s5/q42.sql", + "../../queries_v2/10000/s5/q67.sql", + "../../queries_v2/10000/s5/q50.sql", + "../../queries_v2/10000/s5/q30.sql", + "../../queries_v2/10000/s5/q48.sql", + "../../queries_v2/10000/s5/q22.sql", + "../../queries_v2/10000/s5/q11.sql", + "../../queries_v2/10000/s5/q94.sql", + "../../queries_v2/10000/s5/q93.sql", + "../../queries_v2/10000/s5/q18.sql", + "../../queries_v2/10000/s5/q33.sql", + "../../queries_v2/10000/s5/q63.sql", + "../../queries_v2/10000/s5/q08.sql", + "../../queries_v2/10000/s5/q97.sql", + "../../queries_v2/10000/s5/q45.sql", + "../../queries_v2/10000/s5/q62.sql", + "../../queries_v2/10000/s5/q81.sql", + "../../queries_v2/10000/s5/q35.sql", + "../../queries_v2/10000/s5/q78.sql", + "../../queries_v2/10000/s5/q57.sql", + "../../queries_v2/10000/s5/q46.sql", + "../../queries_v2/10000/s5/q32.sql", + "../../queries_v2/10000/s5/q24.sql", + "../../queries_v2/10000/s5/q38.sql", + "../../queries_v2/10000/s5/q55.sql", + "../../queries_v2/10000/s5/q74.sql", + "../../queries_v2/10000/s5/q84.sql", + "../../queries_v2/10000/s5/q89.sql", + "../../queries_v2/10000/s5/q83.sql", + "../../queries_v2/10000/s5/q31.sql", + "../../queries_v2/10000/s5/q26.sql", + "../../queries_v2/10000/s5/q40.sql", + "../../queries_v2/10000/s5/q14.sql", + "../../queries_v2/10000/s5/q23.sql", + "../../queries_v2/10000/s5/q96.sql", + "../../queries_v2/10000/s5/q01.sql", + "../../queries_v2/10000/s5/q95.sql", + "../../queries_v2/10000/s5/q27.sql", + "../../queries_v2/10000/s5/q44.sql", + "../../queries_v2/10000/s5/q16.sql", + "../../queries_v2/10000/s5/q64.sql", + "../../queries_v2/10000/s5/q20.sql", + "../../queries_v2/10000/s5/q43.sql", + "../../queries_v2/10000/s5/q05.sql", + "../../queries_v2/10000/s5/q47.sql", + "../../queries_v2/10000/s5/q10.sql", + "../../queries_v2/10000/s5/q70.sql", + "../../queries_v2/10000/s5/q39.sql", + "../../queries_v2/10000/s5/q72.sql", + "../../queries_v2/10000/s5/q75.sql", + "../../queries_v2/10000/s5/q12.sql", + "../../queries_v2/10000/s5/q37.sql", + "../../queries_v2/10000/s5/q15.sql", + "../../queries_v2/10000/s5/q59.sql", + "../../queries_v2/10000/s5/q91.sql", + "../../queries_v2/10000/s5/q99.sql", + "../../queries_v2/10000/s5/q41.sql", + "../../queries_v2/10000/s5/q09.sql", + "../../queries_v2/10000/s5/q86.sql", + "../../queries_v2/10000/s5/q34.sql", + "../../queries_v2/10000/s5/q82.sql", + "../../queries_v2/10000/s5/q29.sql", + "../../queries_v2/10000/s5/q25.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s6.json b/benchmarks/tpc-ds/streams_v2/10000/s6.json new file mode 100644 index 00000000..f1bba401 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s6.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s6/q34.sql", + "../../queries_v2/10000/s6/q88.sql", + "../../queries_v2/10000/s6/q44.sql", + "../../queries_v2/10000/s6/q94.sql", + "../../queries_v2/10000/s6/q50.sql", + "../../queries_v2/10000/s6/q05.sql", + "../../queries_v2/10000/s6/q53.sql", + "../../queries_v2/10000/s6/q07.sql", + "../../queries_v2/10000/s6/q58.sql", + "../../queries_v2/10000/s6/q20.sql", + "../../queries_v2/10000/s6/q75.sql", + "../../queries_v2/10000/s6/q73.sql", + "../../queries_v2/10000/s6/q91.sql", + "../../queries_v2/10000/s6/q36.sql", + "../../queries_v2/10000/s6/q11.sql", + "../../queries_v2/10000/s6/q80.sql", + "../../queries_v2/10000/s6/q09.sql", + "../../queries_v2/10000/s6/q93.sql", + "../../queries_v2/10000/s6/q32.sql", + "../../queries_v2/10000/s6/q89.sql", + "../../queries_v2/10000/s6/q28.sql", + "../../queries_v2/10000/s6/q87.sql", + "../../queries_v2/10000/s6/q18.sql", + "../../queries_v2/10000/s6/q74.sql", + "../../queries_v2/10000/s6/q06.sql", + "../../queries_v2/10000/s6/q65.sql", + "../../queries_v2/10000/s6/q84.sql", + "../../queries_v2/10000/s6/q14.sql", + "../../queries_v2/10000/s6/q38.sql", + "../../queries_v2/10000/s6/q24.sql", + "../../queries_v2/10000/s6/q42.sql", + "../../queries_v2/10000/s6/q29.sql", + "../../queries_v2/10000/s6/q72.sql", + "../../queries_v2/10000/s6/q23.sql", + "../../queries_v2/10000/s6/q26.sql", + "../../queries_v2/10000/s6/q69.sql", + "../../queries_v2/10000/s6/q47.sql", + "../../queries_v2/10000/s6/q82.sql", + "../../queries_v2/10000/s6/q31.sql", + "../../queries_v2/10000/s6/q59.sql", + "../../queries_v2/10000/s6/q49.sql", + "../../queries_v2/10000/s6/q33.sql", + "../../queries_v2/10000/s6/q86.sql", + "../../queries_v2/10000/s6/q99.sql", + "../../queries_v2/10000/s6/q04.sql", + "../../queries_v2/10000/s6/q45.sql", + "../../queries_v2/10000/s6/q85.sql", + "../../queries_v2/10000/s6/q08.sql", + "../../queries_v2/10000/s6/q19.sql", + "../../queries_v2/10000/s6/q61.sql", + "../../queries_v2/10000/s6/q03.sql", + "../../queries_v2/10000/s6/q41.sql", + "../../queries_v2/10000/s6/q54.sql", + "../../queries_v2/10000/s6/q67.sql", + "../../queries_v2/10000/s6/q77.sql", + "../../queries_v2/10000/s6/q15.sql", + "../../queries_v2/10000/s6/q51.sql", + "../../queries_v2/10000/s6/q98.sql", + "../../queries_v2/10000/s6/q62.sql", + "../../queries_v2/10000/s6/q97.sql", + "../../queries_v2/10000/s6/q22.sql", + "../../queries_v2/10000/s6/q48.sql", + "../../queries_v2/10000/s6/q02.sql", + "../../queries_v2/10000/s6/q79.sql", + "../../queries_v2/10000/s6/q56.sql", + "../../queries_v2/10000/s6/q37.sql", + "../../queries_v2/10000/s6/q10.sql", + "../../queries_v2/10000/s6/q90.sql", + "../../queries_v2/10000/s6/q21.sql", + "../../queries_v2/10000/s6/q46.sql", + "../../queries_v2/10000/s6/q83.sql", + "../../queries_v2/10000/s6/q96.sql", + "../../queries_v2/10000/s6/q68.sql", + "../../queries_v2/10000/s6/q63.sql", + "../../queries_v2/10000/s6/q92.sql", + "../../queries_v2/10000/s6/q27.sql", + "../../queries_v2/10000/s6/q12.sql", + "../../queries_v2/10000/s6/q64.sql", + "../../queries_v2/10000/s6/q95.sql", + "../../queries_v2/10000/s6/q39.sql", + "../../queries_v2/10000/s6/q35.sql", + "../../queries_v2/10000/s6/q78.sql", + "../../queries_v2/10000/s6/q57.sql", + "../../queries_v2/10000/s6/q66.sql", + "../../queries_v2/10000/s6/q71.sql", + "../../queries_v2/10000/s6/q30.sql", + "../../queries_v2/10000/s6/q01.sql", + "../../queries_v2/10000/s6/q81.sql", + "../../queries_v2/10000/s6/q43.sql", + "../../queries_v2/10000/s6/q52.sql", + "../../queries_v2/10000/s6/q13.sql", + "../../queries_v2/10000/s6/q76.sql", + "../../queries_v2/10000/s6/q17.sql", + "../../queries_v2/10000/s6/q25.sql", + "../../queries_v2/10000/s6/q40.sql", + "../../queries_v2/10000/s6/q70.sql", + "../../queries_v2/10000/s6/q55.sql", + "../../queries_v2/10000/s6/q60.sql", + "../../queries_v2/10000/s6/q16.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s7.json b/benchmarks/tpc-ds/streams_v2/10000/s7.json new file mode 100644 index 00000000..5238d6c9 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s7.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s7/q70.sql", + "../../queries_v2/10000/s7/q53.sql", + "../../queries_v2/10000/s7/q92.sql", + "../../queries_v2/10000/s7/q99.sql", + "../../queries_v2/10000/s7/q31.sql", + "../../queries_v2/10000/s7/q39.sql", + "../../queries_v2/10000/s7/q29.sql", + "../../queries_v2/10000/s7/q32.sql", + "../../queries_v2/10000/s7/q06.sql", + "../../queries_v2/10000/s7/q64.sql", + "../../queries_v2/10000/s7/q30.sql", + "../../queries_v2/10000/s7/q34.sql", + "../../queries_v2/10000/s7/q13.sql", + "../../queries_v2/10000/s7/q28.sql", + "../../queries_v2/10000/s7/q86.sql", + "../../queries_v2/10000/s7/q84.sql", + "../../queries_v2/10000/s7/q25.sql", + "../../queries_v2/10000/s7/q04.sql", + "../../queries_v2/10000/s7/q98.sql", + "../../queries_v2/10000/s7/q79.sql", + "../../queries_v2/10000/s7/q69.sql", + "../../queries_v2/10000/s7/q72.sql", + "../../queries_v2/10000/s7/q45.sql", + "../../queries_v2/10000/s7/q48.sql", + "../../queries_v2/10000/s7/q80.sql", + "../../queries_v2/10000/s7/q20.sql", + "../../queries_v2/10000/s7/q02.sql", + "../../queries_v2/10000/s7/q21.sql", + "../../queries_v2/10000/s7/q97.sql", + "../../queries_v2/10000/s7/q62.sql", + "../../queries_v2/10000/s7/q47.sql", + "../../queries_v2/10000/s7/q60.sql", + "../../queries_v2/10000/s7/q71.sql", + "../../queries_v2/10000/s7/q46.sql", + "../../queries_v2/10000/s7/q10.sql", + "../../queries_v2/10000/s7/q14.sql", + "../../queries_v2/10000/s7/q35.sql", + "../../queries_v2/10000/s7/q55.sql", + "../../queries_v2/10000/s7/q37.sql", + "../../queries_v2/10000/s7/q52.sql", + "../../queries_v2/10000/s7/q09.sql", + "../../queries_v2/10000/s7/q85.sql", + "../../queries_v2/10000/s7/q40.sql", + "../../queries_v2/10000/s7/q76.sql", + "../../queries_v2/10000/s7/q44.sql", + "../../queries_v2/10000/s7/q03.sql", + "../../queries_v2/10000/s7/q26.sql", + "../../queries_v2/10000/s7/q19.sql", + "../../queries_v2/10000/s7/q58.sql", + "../../queries_v2/10000/s7/q42.sql", + "../../queries_v2/10000/s7/q75.sql", + "../../queries_v2/10000/s7/q17.sql", + "../../queries_v2/10000/s7/q38.sql", + "../../queries_v2/10000/s7/q82.sql", + "../../queries_v2/10000/s7/q87.sql", + "../../queries_v2/10000/s7/q43.sql", + "../../queries_v2/10000/s7/q11.sql", + "../../queries_v2/10000/s7/q05.sql", + "../../queries_v2/10000/s7/q41.sql", + "../../queries_v2/10000/s7/q61.sql", + "../../queries_v2/10000/s7/q33.sql", + "../../queries_v2/10000/s7/q49.sql", + "../../queries_v2/10000/s7/q07.sql", + "../../queries_v2/10000/s7/q73.sql", + "../../queries_v2/10000/s7/q89.sql", + "../../queries_v2/10000/s7/q81.sql", + "../../queries_v2/10000/s7/q78.sql", + "../../queries_v2/10000/s7/q18.sql", + "../../queries_v2/10000/s7/q36.sql", + "../../queries_v2/10000/s7/q51.sql", + "../../queries_v2/10000/s7/q56.sql", + "../../queries_v2/10000/s7/q83.sql", + "../../queries_v2/10000/s7/q23.sql", + "../../queries_v2/10000/s7/q08.sql", + "../../queries_v2/10000/s7/q24.sql", + "../../queries_v2/10000/s7/q63.sql", + "../../queries_v2/10000/s7/q01.sql", + "../../queries_v2/10000/s7/q12.sql", + "../../queries_v2/10000/s7/q68.sql", + "../../queries_v2/10000/s7/q66.sql", + "../../queries_v2/10000/s7/q67.sql", + "../../queries_v2/10000/s7/q77.sql", + "../../queries_v2/10000/s7/q15.sql", + "../../queries_v2/10000/s7/q88.sql", + "../../queries_v2/10000/s7/q65.sql", + "../../queries_v2/10000/s7/q59.sql", + "../../queries_v2/10000/s7/q96.sql", + "../../queries_v2/10000/s7/q54.sql", + "../../queries_v2/10000/s7/q95.sql", + "../../queries_v2/10000/s7/q93.sql", + "../../queries_v2/10000/s7/q91.sql", + "../../queries_v2/10000/s7/q74.sql", + "../../queries_v2/10000/s7/q94.sql", + "../../queries_v2/10000/s7/q16.sql", + "../../queries_v2/10000/s7/q90.sql", + "../../queries_v2/10000/s7/q57.sql", + "../../queries_v2/10000/s7/q22.sql", + "../../queries_v2/10000/s7/q50.sql", + "../../queries_v2/10000/s7/q27.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s8.json b/benchmarks/tpc-ds/streams_v2/10000/s8.json new file mode 100644 index 00000000..b55b2213 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s8.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s8/q57.sql", + "../../queries_v2/10000/s8/q29.sql", + "../../queries_v2/10000/s8/q24.sql", + "../../queries_v2/10000/s8/q76.sql", + "../../queries_v2/10000/s8/q37.sql", + "../../queries_v2/10000/s8/q66.sql", + "../../queries_v2/10000/s8/q60.sql", + "../../queries_v2/10000/s8/q98.sql", + "../../queries_v2/10000/s8/q80.sql", + "../../queries_v2/10000/s8/q12.sql", + "../../queries_v2/10000/s8/q59.sql", + "../../queries_v2/10000/s8/q70.sql", + "../../queries_v2/10000/s8/q91.sql", + "../../queries_v2/10000/s8/q69.sql", + "../../queries_v2/10000/s8/q40.sql", + "../../queries_v2/10000/s8/q02.sql", + "../../queries_v2/10000/s8/q16.sql", + "../../queries_v2/10000/s8/q44.sql", + "../../queries_v2/10000/s8/q05.sql", + "../../queries_v2/10000/s8/q73.sql", + "../../queries_v2/10000/s8/q14.sql", + "../../queries_v2/10000/s8/q71.sql", + "../../queries_v2/10000/s8/q03.sql", + "../../queries_v2/10000/s8/q49.sql", + "../../queries_v2/10000/s8/q84.sql", + "../../queries_v2/10000/s8/q64.sql", + "../../queries_v2/10000/s8/q07.sql", + "../../queries_v2/10000/s8/q36.sql", + "../../queries_v2/10000/s8/q61.sql", + "../../queries_v2/10000/s8/q41.sql", + "../../queries_v2/10000/s8/q35.sql", + "../../queries_v2/10000/s8/q50.sql", + "../../queries_v2/10000/s8/q65.sql", + "../../queries_v2/10000/s8/q51.sql", + "../../queries_v2/10000/s8/q78.sql", + "../../queries_v2/10000/s8/q21.sql", + "../../queries_v2/10000/s8/q67.sql", + "../../queries_v2/10000/s8/q22.sql", + "../../queries_v2/10000/s8/q81.sql", + "../../queries_v2/10000/s8/q93.sql", + "../../queries_v2/10000/s8/q25.sql", + "../../queries_v2/10000/s8/q26.sql", + "../../queries_v2/10000/s8/q90.sql", + "../../queries_v2/10000/s8/q74.sql", + "../../queries_v2/10000/s8/q92.sql", + "../../queries_v2/10000/s8/q75.sql", + "../../queries_v2/10000/s8/q10.sql", + "../../queries_v2/10000/s8/q58.sql", + "../../queries_v2/10000/s8/q06.sql", + "../../queries_v2/10000/s8/q47.sql", + "../../queries_v2/10000/s8/q30.sql", + "../../queries_v2/10000/s8/q94.sql", + "../../queries_v2/10000/s8/q97.sql", + "../../queries_v2/10000/s8/q55.sql", + "../../queries_v2/10000/s8/q72.sql", + "../../queries_v2/10000/s8/q95.sql", + "../../queries_v2/10000/s8/q86.sql", + "../../queries_v2/10000/s8/q39.sql", + "../../queries_v2/10000/s8/q17.sql", + "../../queries_v2/10000/s8/q42.sql", + "../../queries_v2/10000/s8/q85.sql", + "../../queries_v2/10000/s8/q09.sql", + "../../queries_v2/10000/s8/q32.sql", + "../../queries_v2/10000/s8/q34.sql", + "../../queries_v2/10000/s8/q79.sql", + "../../queries_v2/10000/s8/q54.sql", + "../../queries_v2/10000/s8/q77.sql", + "../../queries_v2/10000/s8/q45.sql", + "../../queries_v2/10000/s8/q28.sql", + "../../queries_v2/10000/s8/q11.sql", + "../../queries_v2/10000/s8/q89.sql", + "../../queries_v2/10000/s8/q56.sql", + "../../queries_v2/10000/s8/q46.sql", + "../../queries_v2/10000/s8/q19.sql", + "../../queries_v2/10000/s8/q62.sql", + "../../queries_v2/10000/s8/q08.sql", + "../../queries_v2/10000/s8/q96.sql", + "../../queries_v2/10000/s8/q01.sql", + "../../queries_v2/10000/s8/q23.sql", + "../../queries_v2/10000/s8/q88.sql", + "../../queries_v2/10000/s8/q82.sql", + "../../queries_v2/10000/s8/q87.sql", + "../../queries_v2/10000/s8/q43.sql", + "../../queries_v2/10000/s8/q53.sql", + "../../queries_v2/10000/s8/q20.sql", + "../../queries_v2/10000/s8/q52.sql", + "../../queries_v2/10000/s8/q83.sql", + "../../queries_v2/10000/s8/q38.sql", + "../../queries_v2/10000/s8/q68.sql", + "../../queries_v2/10000/s8/q04.sql", + "../../queries_v2/10000/s8/q13.sql", + "../../queries_v2/10000/s8/q48.sql", + "../../queries_v2/10000/s8/q99.sql", + "../../queries_v2/10000/s8/q27.sql", + "../../queries_v2/10000/s8/q18.sql", + "../../queries_v2/10000/s8/q15.sql", + "../../queries_v2/10000/s8/q33.sql", + "../../queries_v2/10000/s8/q31.sql", + "../../queries_v2/10000/s8/q63.sql" + ], + "start_on_new_client": true +} diff --git a/benchmarks/tpc-ds/streams_v2/10000/s9.json b/benchmarks/tpc-ds/streams_v2/10000/s9.json new file mode 100644 index 00000000..2af130d9 --- /dev/null +++ b/benchmarks/tpc-ds/streams_v2/10000/s9.json @@ -0,0 +1,104 @@ +{ + "query_files": [ + "../../queries_v2/10000/s9/q15.sql", + "../../queries_v2/10000/s9/q60.sql", + "../../queries_v2/10000/s9/q62.sql", + "../../queries_v2/10000/s9/q74.sql", + "../../queries_v2/10000/s9/q81.sql", + "../../queries_v2/10000/s9/q88.sql", + "../../queries_v2/10000/s9/q50.sql", + "../../queries_v2/10000/s9/q05.sql", + "../../queries_v2/10000/s9/q84.sql", + "../../queries_v2/10000/s9/q01.sql", + "../../queries_v2/10000/s9/q52.sql", + "../../queries_v2/10000/s9/q57.sql", + "../../queries_v2/10000/s9/q13.sql", + "../../queries_v2/10000/s9/q14.sql", + "../../queries_v2/10000/s9/q90.sql", + "../../queries_v2/10000/s9/q07.sql", + "../../queries_v2/10000/s9/q27.sql", + "../../queries_v2/10000/s9/q92.sql", + "../../queries_v2/10000/s9/q39.sql", + "../../queries_v2/10000/s9/q34.sql", + "../../queries_v2/10000/s9/q21.sql", + "../../queries_v2/10000/s9/q65.sql", + "../../queries_v2/10000/s9/q75.sql", + "../../queries_v2/10000/s9/q09.sql", + "../../queries_v2/10000/s9/q02.sql", + "../../queries_v2/10000/s9/q12.sql", + "../../queries_v2/10000/s9/q32.sql", + "../../queries_v2/10000/s9/q28.sql", + "../../queries_v2/10000/s9/q42.sql", + "../../queries_v2/10000/s9/q17.sql", + "../../queries_v2/10000/s9/q67.sql", + "../../queries_v2/10000/s9/q31.sql", + "../../queries_v2/10000/s9/q20.sql", + "../../queries_v2/10000/s9/q11.sql", + "../../queries_v2/10000/s9/q77.sql", + "../../queries_v2/10000/s9/q36.sql", + "../../queries_v2/10000/s9/q82.sql", + "../../queries_v2/10000/s9/q33.sql", + "../../queries_v2/10000/s9/q54.sql", + "../../queries_v2/10000/s9/q04.sql", + "../../queries_v2/10000/s9/q16.sql", + "../../queries_v2/10000/s9/q10.sql", + "../../queries_v2/10000/s9/q18.sql", + "../../queries_v2/10000/s9/q48.sql", + "../../queries_v2/10000/s9/q24.sql", + "../../queries_v2/10000/s9/q30.sql", + "../../queries_v2/10000/s9/q78.sql", + "../../queries_v2/10000/s9/q06.sql", + "../../queries_v2/10000/s9/q80.sql", + "../../queries_v2/10000/s9/q35.sql", + "../../queries_v2/10000/s9/q59.sql", + "../../queries_v2/10000/s9/q99.sql", + "../../queries_v2/10000/s9/q61.sql", + "../../queries_v2/10000/s9/q22.sql", + "../../queries_v2/10000/s9/q71.sql", + "../../queries_v2/10000/s9/q68.sql", + "../../queries_v2/10000/s9/q40.sql", + "../../queries_v2/10000/s9/q66.sql", + "../../queries_v2/10000/s9/q94.sql", + "../../queries_v2/10000/s9/q47.sql", + "../../queries_v2/10000/s9/q26.sql", + "../../queries_v2/10000/s9/q25.sql", + "../../queries_v2/10000/s9/q98.sql", + "../../queries_v2/10000/s9/q70.sql", + "../../queries_v2/10000/s9/q73.sql", + "../../queries_v2/10000/s9/q38.sql", + "../../queries_v2/10000/s9/q87.sql", + "../../queries_v2/10000/s9/q03.sql", + "../../queries_v2/10000/s9/q69.sql", + "../../queries_v2/10000/s9/q86.sql", + "../../queries_v2/10000/s9/q79.sql", + "../../queries_v2/10000/s9/q89.sql", + "../../queries_v2/10000/s9/q51.sql", + "../../queries_v2/10000/s9/q58.sql", + "../../queries_v2/10000/s9/q41.sql", + "../../queries_v2/10000/s9/q19.sql", + "../../queries_v2/10000/s9/q83.sql", + "../../queries_v2/10000/s9/q96.sql", + "../../queries_v2/10000/s9/q46.sql", + "../../queries_v2/10000/s9/q53.sql", + "../../queries_v2/10000/s9/q55.sql", + "../../queries_v2/10000/s9/q72.sql", + "../../queries_v2/10000/s9/q95.sql", + "../../queries_v2/10000/s9/q29.sql", + "../../queries_v2/10000/s9/q64.sql", + "../../queries_v2/10000/s9/q93.sql", + "../../queries_v2/10000/s9/q56.sql", + "../../queries_v2/10000/s9/q97.sql", + "../../queries_v2/10000/s9/q23.sql", + "../../queries_v2/10000/s9/q44.sql", + "../../queries_v2/10000/s9/q91.sql", + "../../queries_v2/10000/s9/q49.sql", + "../../queries_v2/10000/s9/q76.sql", + "../../queries_v2/10000/s9/q63.sql", + "../../queries_v2/10000/s9/q45.sql", + "../../queries_v2/10000/s9/q43.sql", + "../../queries_v2/10000/s9/q85.sql", + "../../queries_v2/10000/s9/q37.sql", + "../../queries_v2/10000/s9/q08.sql" + ], + "start_on_new_client": true +} From f55e6b4f7d603a94e64bd2b91dafe1d1cc496f4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 03:47:54 -0500 Subject: [PATCH 02/20] build(deps): bump golang.org/x/crypto from 0.36.0 to 0.45.0 (#79) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.45.0. - [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.45.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.45.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 3e361f7d..eaa1d153 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/rs/zerolog v1.34.0 github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 - golang.org/x/sys v0.35.0 + golang.org/x/sys v0.38.0 ) require ( @@ -34,9 +34,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.9 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/net v0.38.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/crypto v0.45.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/text v0.31.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 050151a8..cd4c7b2b 100644 --- a/go.sum +++ b/go.sum @@ -78,17 +78,17 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 01b78911964bf5bebac9db2fc1835e5b3ad0f486 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 02:13:36 -0500 Subject: [PATCH 03/20] build(deps): bump filippo.io/edwards25519 from 1.1.0 to 1.1.1 (#80) Bumps [filippo.io/edwards25519](https://github.com/FiloSottile/edwards25519) from 1.1.0 to 1.1.1. - [Commits](https://github.com/FiloSottile/edwards25519/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: filippo.io/edwards25519 dependency-version: 1.1.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index eaa1d153..3d7e50d5 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( ) require ( - filippo.io/edwards25519 v1.1.0 // indirect + filippo.io/edwards25519 v1.1.1 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/go-units v0.5.0 // indirect diff --git a/go.sum b/go.sum index cd4c7b2b..cac4e4ca 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= -filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw= +filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= From 84ad21f5670cd8a584394d45922d9c181dd96d2b Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Thu, 19 Mar 2026 02:53:57 -0500 Subject: [PATCH 04/20] fix: address code review findings across stage, cmd, and utils packages - Fix data race: remove concurrent write to pseudoStage.States.RunStartTime inside syncedTime callback in loadjson (line 118 sets it after goroutines finish) - Guard saveQueryJsonFile against empty QueryId to avoid calling GetQueryInfo("") - Fix zerolog field chain in runShellScripts: assign result back to logEntry so stdout, stderr, exit_code, and stage fields are actually emitted - Remove dead ValidateRequiredFlags() call in queryplan (no required flags exist) - Log os.Remove error in genconfig stale file cleanup - Switch FileBasedRunRecorder to encoding/csv.Writer to properly escape fields and log write errors instead of silently discarding them - Replace shared package-level RunsValueOne/RunsValueZero with intPtr() helper to avoid aliasing risk where mutation would affect all stages - Use errors.New instead of fmt.Errorf("%s", ...) in loadjson - Replace custom fileNameWithoutPathAndExt with filepath.Base + filepath.Ext - Check handleQueryError return value for SELECT COUNT(*) in table_summary --- cmd/genconfig/gen.go | 4 +++- cmd/loadjson/main.go | 10 ++++----- cmd/queryplan/main.go | 1 - cmd/save/table_summary.go | 5 ++++- stage/map.go | 18 ++++----------- stage/run_recorder.go | 46 ++++++++++++++++++++++++++++----------- stage/stage.go | 2 +- stage/stage_utils.go | 24 ++++++++++---------- utils/orm.go | 4 ++-- 9 files changed, 64 insertions(+), 50 deletions(-) diff --git a/cmd/genconfig/gen.go b/cmd/genconfig/gen.go index 8ca4b833..da025d80 100644 --- a/cmd/genconfig/gen.go +++ b/cmd/genconfig/gen.go @@ -199,7 +199,9 @@ func GenerateFiles(configs []ConfigData) { } if !written[path] { log.Info().Msgf("removing stale file %s", path) - os.Remove(path) + if err := os.Remove(path); err != nil { + log.Error().Err(err).Str("path", path).Msg("failed to remove stale file") + } } return nil }) diff --git a/cmd/loadjson/main.go b/cmd/loadjson/main.go index 2f9bcdcb..ebd44e37 100644 --- a/cmd/loadjson/main.go +++ b/cmd/loadjson/main.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "encoding/json" - "fmt" + "errors" "os" "os/signal" "path/filepath" @@ -76,7 +76,7 @@ func Run(_ *cobra.Command, args []string) { // To reuse the `pbench run` code, especially run recorders, we create a pseudo main stage. pseudoStage = &stage.Stage{ Id: "load_json", - ColdRuns: &stage.RunsValueOne, + ColdRuns: intPtr(1), States: &stage.SharedStageStates{ RunName: RunName, Comment: Comment, @@ -179,15 +179,13 @@ func processFile(ctx context.Context, path string) { } if queryInfo.ErrorCode != nil { // Need to set this so the run recorders will mark this query as failed. - queryResult.QueryError = fmt.Errorf("%s", *queryInfo.ErrorCode.Name) + queryResult.QueryError = errors.New(*queryInfo.ErrorCode.Name) } // Unlike benchmarks run by pbench, we do not know when did the run start and finish when loading them from files. // We infer that the whole run starts at min(queryStartTime) and ends at max(queryEndTime). runStartTime.Synchronized(func(st *syncedTime) { if queryResult.StartTime.Before(st.t) { st.t = queryResult.StartTime - // Changes to the pseudoStage will be synced to the database by the run recorder. - pseudoStage.States.RunStartTime = queryResult.StartTime } }) if queryResult.EndTime != nil { @@ -268,6 +266,8 @@ func processPath(ctx context.Context, path string) error { return nil } +func intPtr(v int) *int { return &v } + func registerRunRecorder(r stage.RunRecorder) { if r == nil || reflect.ValueOf(r).IsNil() { return diff --git a/cmd/queryplan/main.go b/cmd/queryplan/main.go index 25531f89..77155c64 100644 --- a/cmd/queryplan/main.go +++ b/cmd/queryplan/main.go @@ -51,7 +51,6 @@ func init() { } func run(c *cobra.Command, args []string) { - c.ValidateRequiredFlags() csvFile := args[0] log.Info().Msgf("parsing the query plan at column %d in %s", queryPlanColumn, csvFile) diff --git a/cmd/save/table_summary.go b/cmd/save/table_summary.go index 95bc0292..eea8d7ea 100644 --- a/cmd/save/table_summary.go +++ b/cmd/save/table_summary.go @@ -132,7 +132,10 @@ func (s *TableSummary) QueryTableSummary(ctx context.Context, client *presto.Ses } // Unlikely but if the row count is still NULL, then do SELECT COUNT(*) if s.RowCount == nil { - handleQueryError(prestoapi.QueryAndUnmarshal(ctx, client, "SELECT COUNT(*) FROM "+fullyQualifiedTableName, &s.RowCount), true) + if _, fatal := handleQueryError(prestoapi.QueryAndUnmarshal(ctx, client, "SELECT COUNT(*) FROM "+fullyQualifiedTableName, &s.RowCount), true); fatal != nil { + abortLog(fatal) + return + } } // Zero rows, no need to do anything more. diff --git a/stage/map.go b/stage/map.go index 9fd0f102..85fe819e 100644 --- a/stage/map.go +++ b/stage/map.go @@ -124,21 +124,11 @@ func ParseStage(stage *Stage, stages Map) (*Stage, error) { } func fileNameWithoutPathAndExt(filePath string) string { - // The stage ID is the file name without directory path and extension. - // It will be filePath[lastPathSeparator+1 : lastDot], so we have the following default values. - lastPathSeparator, lastDot := -1, len(filePath) - for i := 0; i < len(filePath); i++ { - switch filePath[i] { - case os.PathSeparator: - lastPathSeparator = i - case '.': - lastDot = i - } - } - if lastDot <= lastPathSeparator+1 || lastPathSeparator+1 >= len(filePath) { - return filePath + base := filepath.Base(filePath) + if ext := filepath.Ext(base); ext != "" { + return base[:len(base)-len(ext)] } - return filePath[lastPathSeparator+1 : lastDot] + return base } func checkStageLinks(stage *Stage) error { diff --git a/stage/run_recorder.go b/stage/run_recorder.go index 1f51938f..994a67c5 100644 --- a/stage/run_recorder.go +++ b/stage/run_recorder.go @@ -1,11 +1,14 @@ package stage import ( + "bytes" "context" + "encoding/csv" "fmt" "os" "path/filepath" - "strings" + "pbench/log" + "strconv" "time" ) @@ -16,7 +19,8 @@ type RunRecorder interface { } type FileBasedRunRecorder struct { - summaryBuilder strings.Builder + buf bytes.Buffer + csvWriter *csv.Writer } func NewFileBasedRunRecorder() *FileBasedRunRecorder { @@ -24,18 +28,21 @@ func NewFileBasedRunRecorder() *FileBasedRunRecorder { } func (f *FileBasedRunRecorder) Start(_ context.Context, _ *Stage) error { - f.summaryBuilder.WriteString("stage_id,query_file,query_index,cold_run,sequence_no,info_url,succeeded,row_count,expected_row_count,start_time,end_time,duration_in_seconds\n") + f.csvWriter = csv.NewWriter(&f.buf) + f.csvWriter.UseCRLF = false + f.csvWriter.Write([]string{ + "stage_id", "query_file", "query_index", "cold_run", "sequence_no", + "info_url", "succeeded", "row_count", "expected_row_count", + "start_time", "end_time", "duration_in_seconds", + }) return nil } func (f *FileBasedRunRecorder) RecordQuery(_ context.Context, _ *Stage, result *QueryResult) { - f.summaryBuilder.WriteString(result.StageId + ",") + queryFile := "inline" if result.Query.File != nil { - f.summaryBuilder.WriteString(*result.Query.File) - } else { - f.summaryBuilder.WriteString("inline") + queryFile = *result.Query.File } - // EndTime and Duration are nil when ConcludeExecution was not called (e.g., query error). endTimeStr := "" if result.EndTime != nil { endTimeStr = result.EndTime.Format(time.RFC3339) @@ -44,12 +51,25 @@ func (f *FileBasedRunRecorder) RecordQuery(_ context.Context, _ *Stage, result * if result.Duration != nil { durationSecs = result.Duration.Seconds() } - f.summaryBuilder.WriteString(fmt.Sprintf(",%d,%t,%d,%s,%t,%d,%d,%s,%s,%f\n", - result.Query.Index, result.Query.ColdRun, result.Query.SequenceNo, result.InfoUrl, - result.QueryError == nil, result.RowCount, result.Query.ExpectedRowCount, result.StartTime.Format(time.RFC3339), - endTimeStr, durationSecs)) + f.csvWriter.Write([]string{ + result.StageId, + queryFile, + strconv.Itoa(result.Query.Index), + strconv.FormatBool(result.Query.ColdRun), + strconv.Itoa(result.Query.SequenceNo), + result.InfoUrl, + strconv.FormatBool(result.QueryError == nil), + strconv.Itoa(result.RowCount), + strconv.Itoa(result.Query.ExpectedRowCount), + result.StartTime.Format(time.RFC3339), + endTimeStr, + fmt.Sprintf("%f", durationSecs), + }) } func (f *FileBasedRunRecorder) RecordRun(_ context.Context, s *Stage, _ []*QueryResult) { - _ = os.WriteFile(filepath.Join(s.States.OutputPath, s.Id+"_summary.csv"), []byte(f.summaryBuilder.String()), 0644) + f.csvWriter.Flush() + if err := os.WriteFile(filepath.Join(s.States.OutputPath, s.Id+"_summary.csv"), f.buf.Bytes(), 0644); err != nil { + log.Error().Err(err).Msg("failed to write run summary CSV") + } } diff --git a/stage/stage.go b/stage/stage.go index bc8c545e..c7c9587d 100644 --- a/stage/stage.go +++ b/stage/stage.go @@ -548,7 +548,7 @@ func (s *Stage) runShellScripts(ctx context.Context, shellScripts []string, extr } else { logEntry = log.Info() } - logEntry.EmbedObject(s).Int("script_index", i).Str("script", script). + logEntry = logEntry.EmbedObject(s).Int("script_index", i).Str("script", script). Int("exit_code", cmd.ProcessState.ExitCode()).Str("status", cmd.ProcessState.String()). Dur("system_time", cmd.ProcessState.SystemTime()).Str("stdout", outBuf.String()). Str("stderr", errBuf.String()) diff --git a/stage/stage_utils.go b/stage/stage_utils.go index ef8119ef..525f4c7e 100644 --- a/stage/stage_utils.go +++ b/stage/stage_utils.go @@ -20,10 +20,7 @@ const ( DefaultStageFileExt = ".json" ) -var ( - RunsValueOne = 1 - RunsValueZero = 0 -) +func intPtr(v int) *int { return &v } type OnQueryCompletionFn func(result *QueryResult) @@ -233,14 +230,14 @@ func (s *Stage) setDefaults() { s.SaveJson = &falseValue } if s.ColdRuns == nil { - s.ColdRuns = &RunsValueZero + s.ColdRuns = intPtr(0) } if s.WarmRuns == nil { - s.WarmRuns = &RunsValueZero + s.WarmRuns = intPtr(0) } if *s.ColdRuns+*s.WarmRuns <= 0 { - s.ColdRuns = &RunsValueOne - s.WarmRuns = &RunsValueZero + s.ColdRuns = intPtr(1) + s.WarmRuns = intPtr(0) } } @@ -280,13 +277,13 @@ func (s *Stage) propagateStates() { nextStage.ColdRuns = s.ColdRuns nextStage.WarmRuns = s.WarmRuns } else if nextStage.ColdRuns == nil { - nextStage.ColdRuns = &RunsValueZero + nextStage.ColdRuns = intPtr(0) } else if nextStage.WarmRuns == nil { - nextStage.WarmRuns = &RunsValueZero + nextStage.WarmRuns = intPtr(0) } if *nextStage.ColdRuns+*nextStage.WarmRuns <= 0 { - nextStage.ColdRuns = &RunsValueOne - nextStage.WarmRuns = &RunsValueZero + nextStage.ColdRuns = intPtr(1) + nextStage.WarmRuns = intPtr(0) } if nextStage.AbortOnError == nil { nextStage.AbortOnError = s.AbortOnError @@ -311,6 +308,9 @@ func (s *Stage) saveQueryJsonFile(result *QueryResult) { if !*s.SaveJson && result.QueryError == nil { return } + if result.QueryId == "" { + return + } s.States.wgExitMainStage.Add(1) go func() { checkErr := func(err error) { diff --git a/utils/orm.go b/utils/orm.go index e893725a..526ad34a 100644 --- a/utils/orm.go +++ b/utils/orm.go @@ -14,6 +14,8 @@ import ( type TableName string +const MaxCartesianProductSize = 100_000 + // MergeRowsMap merges two table→rows maps by computing a cartesian product per table. For each table // in b, its rows are cross-joined with the existing rows in a for that table (via MultiplyRows). If a // has no rows yet for a table, a single empty row is used as the seed so that b's columns are preserved. @@ -21,8 +23,6 @@ type TableName string // This is the core mechanism for denormalizing nested structs: parent-level scalar fields produce 1 row // in a, and a nested slice of N structs produces N rows in b. The merge yields N rows, each carrying // both the parent's columns and one child's columns — equivalent to a SQL cross join. -const MaxCartesianProductSize = 100_000 - func MergeRowsMap(a, b map[TableName][]*Row) (map[TableName][]*Row, error) { for tableName, rows2 := range b { rows1 := a[tableName] From 89eb056e4e746bf7d3592b879205d4f711149fc3 Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Thu, 19 Mar 2026 02:55:32 -0500 Subject: [PATCH 05/20] chore: update presto-go-client to v2.0.1 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3d7e50d5..c90a16ad 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-sql-driver/mysql v1.8.1 github.com/influxdata/influxdb-client-go/v2 v2.13.0 github.com/pkg/errors v0.9.1 - github.com/prestodb/presto-go-client/v2 v2.0.0 + github.com/prestodb/presto-go-client/v2 v2.0.1 github.com/rs/zerolog v1.34.0 github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 diff --git a/go.sum b/go.sum index cac4e4ca..10bc7e6c 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prestodb/presto-go-client/v2 v2.0.0 h1:RcMTc5pRQADTGTR4UT5LebhdaLN1ajjfGryG0PHj/vs= -github.com/prestodb/presto-go-client/v2 v2.0.0/go.mod h1:vfkqZB6qWlvlSZpQet/LXFUdwkWMBCV502hmqD9Czvw= +github.com/prestodb/presto-go-client/v2 v2.0.1 h1:Qu5tizqabl+jGwQIsSWNT0H+uheIcEE+WIzuj3++hYU= +github.com/prestodb/presto-go-client/v2 v2.0.1/go.mod h1:vfkqZB6qWlvlSZpQet/LXFUdwkWMBCV502hmqD9Czvw= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= From a5ca816ff61edc5e42ea6061575ef4a8a42f88c5 Mon Sep 17 00:00:00 2001 From: Ethan Zhang Date: Fri, 20 Mar 2026 16:43:54 -0500 Subject: [PATCH 06/20] fix: explicit returns mixed with implicit (fall through) returns (#81) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- benchmarks/scripts/mysql_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/scripts/mysql_utils.py b/benchmarks/scripts/mysql_utils.py index fd03f8a6..152bc998 100644 --- a/benchmarks/scripts/mysql_utils.py +++ b/benchmarks/scripts/mysql_utils.py @@ -24,3 +24,4 @@ def execute_mysql_query(connection, query, cluster_name): return result except Error as e: print(f"The error '{e}' occurred") + return [] From e78455f60187748cc579e944b3ced75df9d4e16b Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Sun, 22 Mar 2026 03:10:30 -0500 Subject: [PATCH 07/20] chore: delete orphaned Presto query records Replace the previous run-specific delete with a generic cleanup that removes orphaned rows from five Presto query metadata tables (presto_query_creation_info, presto_query_operator_stats, presto_query_plans, presto_query_stage_stats, presto_query_statistics). Each DELETE uses a LEFT JOIN to presto_benchmarks.pbench_queries and removes rows where p.query_id IS NULL, ensuring metadata not referenced by pbench_queries is purged. This replaces the prior ad-hoc delete targeting r.run_id IN (2833). --- stage/delete_run.sql | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/stage/delete_run.sql b/stage/delete_run.sql index 9c930e7b..637a4655 100644 --- a/stage/delete_run.sql +++ b/stage/delete_run.sql @@ -13,12 +13,22 @@ left join presto_query_stage_stats p4 on p1.query_id = p4.query_id left join presto_query_statistics p5 on p1.query_id = p5.query_id where r.run_id between 3078 and 3083; -delete p1, p2, p3, p4, p5 -from pbench_queries q - join pbench_runs r on q.run_id = r.run_id - join presto_query_creation_info p1 on q.query_id = p1.query_id - join presto_query_operator_stats p2 on p1.query_id = p2.query_id - join presto_query_plans p3 on p1.query_id = p3.query_id - join presto_query_stage_stats p4 on p1.query_id = p4.query_id - join presto_query_statistics p5 on p1.query_id = p5.query_id -where r.run_id IN (2833); \ No newline at end of file +DELETE t FROM presto_benchmarks.presto_query_creation_info t + LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id +WHERE p.query_id IS NULL; + +DELETE t FROM presto_benchmarks.presto_query_operator_stats t + LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id +WHERE p.query_id IS NULL; + +DELETE t FROM presto_benchmarks.presto_query_plans t + LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id +WHERE p.query_id IS NULL; + +DELETE t FROM presto_benchmarks.presto_query_stage_stats t + LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id +WHERE p.query_id IS NULL; + +DELETE t FROM presto_benchmarks.presto_query_statistics t + LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id +WHERE p.query_id IS NULL; From 35b312f26624b506b7154adaeac03cbf3fb37530 Mon Sep 17 00:00:00 2001 From: Ethan Zhang Date: Tue, 24 Mar 2026 10:03:01 -0500 Subject: [PATCH 08/20] fix: unused local variable (#82) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- benchmarks/scripts/system_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/scripts/system_utils.py b/benchmarks/scripts/system_utils.py index 0f8afdb0..856749f4 100644 --- a/benchmarks/scripts/system_utils.py +++ b/benchmarks/scripts/system_utils.py @@ -19,6 +19,7 @@ def execute_ssh_command(worker_ip, login_user, ssh_key_path, command): sys.exit(1) else: print(f'Successfully finished running command on {worker_ip}') + return stdout_output except paramiko.SSHException as ssh_err: print(f'SSH error on {worker_ip}: {ssh_err}') sys.exit(1) From c9e52b46006288b75947bf61b14e71471c4da5c5 Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Tue, 24 Mar 2026 10:28:42 -0500 Subject: [PATCH 09/20] chore: add pre-commit hook for fmt, vet, staticcheck, tests, and coverage --- .githooks/pre-commit | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..1188e31c --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,58 @@ +#!/bin/bash +# Git pre-commit hook: runs fmt, vet, staticcheck, tests, and coverage + +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "$REPO_ROOT" || exit 1 + +FAILED=0 + +# Format check +echo "Checking formatting..." +UNFORMATTED=$(gofmt -l .) +if [ -n "$UNFORMATTED" ]; then + echo "Files not formatted:" + echo "$UNFORMATTED" + FAILED=1 +fi + +# Vet +echo "Running go vet..." +if ! go vet ./...; then + FAILED=1 +fi + +# Staticcheck +if command -v staticcheck &>/dev/null; then + echo "Running staticcheck..." + if ! staticcheck ./...; then + FAILED=1 + fi +fi + +# Tests with race detection +echo "Running tests..." +if ! go test ./... -race -count=1 -timeout 120s; then + FAILED=1 +fi + +# Coverage threshold (80%) +echo "Checking coverage..." +go test ./... -count=1 -coverprofile=coverage.out -covermode=atomic -timeout 120s +COVERAGE=$(go tool cover -func=coverage.out 2>/dev/null | grep total | awk '{print $3}' | sed 's/%//') +if [ -n "$COVERAGE" ]; then + if (( $(echo "$COVERAGE < 50" | bc -l) )); then + echo "Coverage ${COVERAGE}% is below 50% threshold" + FAILED=1 + else + echo "Coverage: ${COVERAGE}%" + fi +fi +rm -f coverage.out + +if [ "$FAILED" -eq 1 ]; then + echo "Pre-commit checks failed. Fix issues before committing." + exit 1 +fi + +echo "All checks passed." +exit 0 From 3c77594b47ebce3be188d132a581e79dfe33e247 Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Tue, 24 Mar 2026 22:27:23 -0500 Subject: [PATCH 10/20] fix: delete_run query --- stage/delete_run.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage/delete_run.sql b/stage/delete_run.sql index 637a4655..7bd73b24 100644 --- a/stage/delete_run.sql +++ b/stage/delete_run.sql @@ -5,13 +5,13 @@ where r.run_id IN (2834, 2832); delete q, r, p1, p2, p3, p4, p5 from pbench_queries q -left join pbench_runs r on q.run_id = r.run_id +join pbench_runs r on q.run_id = r.run_id left join presto_query_creation_info p1 on q.query_id = p1.query_id left join presto_query_operator_stats p2 on p1.query_id = p2.query_id left join presto_query_plans p3 on p1.query_id = p3.query_id left join presto_query_stage_stats p4 on p1.query_id = p4.query_id left join presto_query_statistics p5 on p1.query_id = p5.query_id -where r.run_id between 3078 and 3083; +where r.duration_ms is null; DELETE t FROM presto_benchmarks.presto_query_creation_info t LEFT JOIN presto_benchmarks.pbench_queries p ON t.query_id = p.query_id From 5f819c5aac9fce20e6a59ed0a9e4ebbdd81f82f5 Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Tue, 24 Mar 2026 23:52:59 -0500 Subject: [PATCH 11/20] =?UTF-8?q?fix:=20address=20code=20review=20findings?= =?UTF-8?q?=20=E2=80=94=20SQL=20injection,=20error=20handling,=20context?= =?UTF-8?q?=20propagation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Quote SQL identifiers in table_summary.go to prevent injection via adversarial names - Handle RowsAffected errors in mysql_run_recorder.go instead of discarding - Check csv.Writer.Write errors in run_recorder.go - Propagate parent context in GetCtxWithTimeout instead of using context.Background() - Add dedicated HTTP client with 30s timeout for Pulumi API calls - Handle JSON null in Float64Time.UnmarshalJSON - Log queryOutputFile.Close() errors in stage.go - Remove redundant continue in unmarshaller.go pointer loop - Add tests for sqlIdent, Float64Time null, GetCtxWithTimeout, FileBasedRunRecorder --- cmd/loadjson/main.go | 4 +- cmd/replay/float64_time_test.go | 80 +++++++++++++++++++++++++++++ cmd/replay/query_log.go | 2 + cmd/save/sql_ident_test.go | 28 ++++++++++ cmd/save/table_summary.go | 24 +++++---- cmd/save/table_summary_mock_test.go | 26 +++++----- prestoapi/unmarshaller.go | 1 - stage/mysql_run_recorder.go | 10 +++- stage/pulumi_run_recorder.go | 4 +- stage/run_recorder.go | 12 +++-- stage/run_recorder_test.go | 63 +++++++++++++++++++++++ stage/stage.go | 10 ++-- stage/stage_utils.go | 2 +- utils/utils.go | 6 --- 14 files changed, 229 insertions(+), 43 deletions(-) create mode 100644 cmd/replay/float64_time_test.go create mode 100644 cmd/save/sql_ident_test.go create mode 100644 stage/run_recorder_test.go diff --git a/cmd/loadjson/main.go b/cmd/loadjson/main.go index ebd44e37..ff145f16 100644 --- a/cmd/loadjson/main.go +++ b/cmd/loadjson/main.go @@ -118,7 +118,7 @@ func Run(_ *cobra.Command, args []string) { pseudoStage.States.RunStartTime = runStartTime.GetTime() pseudoStage.States.RunFinishTime = runEndTime.GetTime() for _, r := range runRecorders { - rCtx, rCancel := utils.GetCtxWithTimeout(time.Second * 5) + rCtx, rCancel := context.WithTimeout(ctx, time.Second*5) r.RecordRun(rCtx, pseudoStage, queryResults) rCancel() } @@ -230,7 +230,7 @@ func processFile(ctx context.Context, path string) { } } for _, r := range runRecorders { - rCtx, rCancel := utils.GetCtxWithTimeout(time.Second * 5) + rCtx, rCancel := context.WithTimeout(ctx, time.Second*5) r.RecordQuery(rCtx, pseudoStage, queryResult) rCancel() } diff --git a/cmd/replay/float64_time_test.go b/cmd/replay/float64_time_test.go new file mode 100644 index 00000000..4abf752e --- /dev/null +++ b/cmd/replay/float64_time_test.go @@ -0,0 +1,80 @@ +package replay + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestFloat64Time_UnmarshalJSON(t *testing.T) { + tests := []struct { + name string + input string + wantErr bool + check func(t *testing.T, ft Float64Time) + }{ + { + name: "valid float64 timestamp", + input: `1700000000.0`, + check: func(t *testing.T, ft Float64Time) { + expected := time.UnixMilli(int64(1700000000.0 * 1000)) + assert.Equal(t, expected, ft.Time) + }, + }, + { + name: "null value", + input: `null`, + check: func(t *testing.T, ft Float64Time) { + assert.True(t, ft.Time.IsZero(), "null should produce zero time") + }, + }, + { + name: "string value", + input: `"not a number"`, + wantErr: true, + }, + { + name: "boolean value", + input: `true`, + wantErr: true, + }, + { + name: "zero value", + input: `0.0`, + check: func(t *testing.T, ft Float64Time) { + assert.Equal(t, time.UnixMilli(0), ft.Time) + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var ft Float64Time + err := json.Unmarshal([]byte(tt.input), &ft) + if tt.wantErr { + require.Error(t, err) + return + } + require.NoError(t, err) + tt.check(t, ft) + }) + } +} + +func TestFloat64Time_UnmarshalJSON_InStruct(t *testing.T) { + // Simulate a query log entry where timestamps can be null + type Entry struct { + CreateTime Float64Time `json:"createTime,omitempty"` + EndTime Float64Time `json:"endTime,omitempty"` + } + + input := `{"createTime": 1700000000.0, "endTime": null}` + var entry Entry + require.NoError(t, json.Unmarshal([]byte(input), &entry)) + + assert.False(t, entry.CreateTime.Time.IsZero()) + assert.True(t, entry.EndTime.Time.IsZero()) +} diff --git a/cmd/replay/query_log.go b/cmd/replay/query_log.go index b471eb79..9b45cfa7 100644 --- a/cmd/replay/query_log.go +++ b/cmd/replay/query_log.go @@ -249,6 +249,8 @@ func (t *Float64Time) UnmarshalJSON(bytes []byte) error { return err } switch value := v.(type) { + case nil: + return nil case float64: t.Time = time.UnixMilli(int64(value * 1000)) return nil diff --git a/cmd/save/sql_ident_test.go b/cmd/save/sql_ident_test.go new file mode 100644 index 00000000..f61a5290 --- /dev/null +++ b/cmd/save/sql_ident_test.go @@ -0,0 +1,28 @@ +package save + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestSqlIdent(t *testing.T) { + tests := []struct { + name string + input string + expected string + }{ + {"simple name", "my_table", `"my_table"`}, + {"name with double quote", `my"table`, `"my""table"`}, + {"empty string", "", `""`}, + {"name with spaces", "my table", `"my table"`}, + {"name with special chars", "x); DROP TABLE --", `"x); DROP TABLE --"`}, + {"multiple double quotes", `a""b`, `"a""""b"`}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.expected, sqlIdent(tt.input)) + }) + } +} diff --git a/cmd/save/table_summary.go b/cmd/save/table_summary.go index eea8d7ea..e5c94882 100644 --- a/cmd/save/table_summary.go +++ b/cmd/save/table_summary.go @@ -16,6 +16,11 @@ import ( "syscall" ) +// sqlIdent quotes a SQL identifier to prevent injection via adversarial names. +func sqlIdent(name string) string { + return `"` + strings.ReplaceAll(name, `"`, `""`) + `"` +} + const ( BooleanType = "boolean" TinyIntType = "tinyint" @@ -104,7 +109,7 @@ func handleQueryError(err error, abortOnError bool) (retry bool, fatal error) { } func (s *TableSummary) QueryTableSummary(ctx context.Context, client *presto.Session, analyze bool) { - fullyQualifiedTableName := fmt.Sprintf("%s.%s.%s", s.Catalog, s.Schema, s.Name) + fullyQualifiedTableName := fmt.Sprintf("%s.%s.%s", sqlIdent(s.Catalog), sqlIdent(s.Schema), sqlIdent(s.Name)) abortLog := func(err error) { log.Error().Err(err).Msgf("querying table summary for %s aborted", fullyQualifiedTableName) @@ -158,31 +163,32 @@ func (s *TableSummary) QueryTableSummary(ctx context.Context, client *presto.Ses rawDataType = rawDataType[:parenthesis] } statistics := make([]string, 0, 4) + quotedCol := sqlIdent(stat.ColumnName) if stat.NullsFraction == nil { - statistics = append(statistics, fmt.Sprintf("count(%s) AS non_null_values_count", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("count(%s) AS non_null_values_count", quotedCol)) } internalFunctionPrefixMu.RLock() prefix := internalFunctionPrefix internalFunctionPrefixMu.RUnlock() if rawDataType == BooleanType { - statistics = append(statistics, fmt.Sprintf("count_if(%s) AS true_values_count", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("count_if(%s) AS true_values_count", quotedCol)) } else if IsSizable[rawDataType] { - statistics = append(statistics, fmt.Sprintf("\"%smax_data_size_for_stats\"(%s) AS max_data_size", prefix, stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("\"%smax_data_size_for_stats\"(%s) AS max_data_size", prefix, quotedCol)) if stat.DataSize == nil { - statistics = append(statistics, fmt.Sprintf("\"%ssum_data_size_for_stats\"(%s) AS data_size", prefix, stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("\"%ssum_data_size_for_stats\"(%s) AS data_size", prefix, quotedCol)) } if stat.DistinctValuesCount == nil && (rawDataType == VarcharType || rawDataType == CharType) { - statistics = append(statistics, fmt.Sprintf("approx_distinct(%s) AS distinct_values_count", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("approx_distinct(%s) AS distinct_values_count", quotedCol)) } } else if IsNumericType[rawDataType] || rawDataType == DateType || rawDataType == TimestampType { if stat.LowValue == nil { - statistics = append(statistics, fmt.Sprintf("min(%s) AS low_value", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("min(%s) AS low_value", quotedCol)) } if stat.HighValue == nil { - statistics = append(statistics, fmt.Sprintf("max(%s) AS high_value", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("max(%s) AS high_value", quotedCol)) } if stat.DistinctValuesCount == nil { - statistics = append(statistics, fmt.Sprintf("approx_distinct(%s) AS distinct_values_count", stat.ColumnName)) + statistics = append(statistics, fmt.Sprintf("approx_distinct(%s) AS distinct_values_count", quotedCol)) } } diff --git a/cmd/save/table_summary_mock_test.go b/cmd/save/table_summary_mock_test.go index 2d190459..38e9aada 100644 --- a/cmd/save/table_summary_mock_test.go +++ b/cmd/save/table_summary_mock_test.go @@ -19,14 +19,14 @@ func TestQueryTableSummary_Basic(t *testing.T) { // SHOW CREATE TABLE mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW CREATE TABLE test_catalog.test_schema.test_table", + SQL: `SHOW CREATE TABLE "test_catalog"."test_schema"."test_table"`, Columns: []presto.Column{{Name: "Create Table", Type: "varchar"}}, Data: [][]any{{"CREATE TABLE test_catalog.test_schema.test_table (\n id bigint,\n name varchar\n)"}}, }) // SHOW STATS FOR mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW STATS FOR test_catalog.test_schema.test_table", + SQL: `SHOW STATS FOR "test_catalog"."test_schema"."test_table"`, Columns: []presto.Column{ {Name: "column_name", Type: "varchar"}, {Name: "data_size", Type: "double"}, @@ -45,7 +45,7 @@ func TestQueryTableSummary_Basic(t *testing.T) { // DESCRIBE — returns column metadata, not statistics mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "DESCRIBE test_catalog.test_schema.test_table", + SQL: `DESCRIBE "test_catalog"."test_schema"."test_table"`, Columns: []presto.Column{ {Name: "Column", Type: "varchar"}, {Name: "Type", Type: "varchar"}, @@ -101,14 +101,14 @@ func TestQueryTableSummary_FallbackToCount(t *testing.T) { // SHOW CREATE TABLE mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW CREATE TABLE cat.sch.tbl", + SQL: `SHOW CREATE TABLE "cat"."sch"."tbl"`, Columns: []presto.Column{{Name: "Create Table", Type: "varchar"}}, Data: [][]any{{"CREATE TABLE cat.sch.tbl (id bigint)"}}, }) // SHOW STATS FOR - no row count in summary row mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW STATS FOR cat.sch.tbl", + SQL: `SHOW STATS FOR "cat"."sch"."tbl"`, Columns: []presto.Column{ {Name: "column_name", Type: "varchar"}, {Name: "data_size", Type: "double"}, @@ -126,7 +126,7 @@ func TestQueryTableSummary_FallbackToCount(t *testing.T) { // DESCRIBE — returns column metadata, not statistics mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "DESCRIBE cat.sch.tbl", + SQL: `DESCRIBE "cat"."sch"."tbl"`, Columns: []presto.Column{ {Name: "Column", Type: "varchar"}, {Name: "Type", Type: "varchar"}, @@ -143,7 +143,7 @@ func TestQueryTableSummary_FallbackToCount(t *testing.T) { // SELECT COUNT(*) fallback mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SELECT COUNT(*) FROM cat.sch.tbl", + SQL: `SELECT COUNT(*) FROM "cat"."sch"."tbl"`, Columns: []presto.Column{{Name: "_col0", Type: "bigint"}}, Data: [][]any{{42}}, }) @@ -169,7 +169,7 @@ func TestQueryTableSummary_ErrorRecovery(t *testing.T) { // SHOW CREATE TABLE returns an error mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW CREATE TABLE err_cat.err_sch.err_tbl", + SQL: `SHOW CREATE TABLE "err_cat"."err_sch"."err_tbl"`, QueueBatches: 1, Error: &presto.QueryError{ ErrorName: "TABLE_NOT_FOUND", @@ -201,14 +201,14 @@ func TestQueryTableSummary_Analyze(t *testing.T) { // SHOW CREATE TABLE mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW CREATE TABLE tpch.sf1.lineitem", + SQL: `SHOW CREATE TABLE "tpch"."sf1"."lineitem"`, Columns: []presto.Column{{Name: "Create Table", Type: "varchar"}}, Data: [][]any{{"CREATE TABLE tpch.sf1.lineitem (\n orderkey bigint,\n comment varchar\n)"}}, }) // SHOW STATS FOR — orderkey has full stats, comment has sparse stats mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SHOW STATS FOR tpch.sf1.lineitem", + SQL: `SHOW STATS FOR "tpch"."sf1"."lineitem"`, Columns: []presto.Column{ {Name: "column_name", Type: "varchar"}, {Name: "data_size", Type: "double"}, @@ -227,7 +227,7 @@ func TestQueryTableSummary_Analyze(t *testing.T) { // DESCRIBE mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "DESCRIBE tpch.sf1.lineitem", + SQL: `DESCRIBE "tpch"."sf1"."lineitem"`, Columns: []presto.Column{ {Name: "Column", Type: "varchar"}, {Name: "Type", Type: "varchar"}, @@ -245,14 +245,14 @@ func TestQueryTableSummary_Analyze(t *testing.T) { // Analyze query for orderkey (bigint — numeric type, all stats missing) mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: "SELECT count(orderkey) AS non_null_values_count, min(orderkey) AS low_value, max(orderkey) AS high_value, approx_distinct(orderkey) AS distinct_values_count FROM tpch.sf1.lineitem", + SQL: `SELECT count("orderkey") AS non_null_values_count, min("orderkey") AS low_value, max("orderkey") AS high_value, approx_distinct("orderkey") AS distinct_values_count FROM "tpch"."sf1"."lineitem"`, Columns: []presto.Column{{Name: "non_null_values_count", Type: "bigint"}, {Name: "low_value", Type: "bigint"}, {Name: "high_value", Type: "bigint"}, {Name: "distinct_values_count", Type: "bigint"}}, Data: [][]any{{95.0, 1.0, 1000.0, 500.0}}, }) // Analyze query for comment (varchar — sizable type, data_size present, distinct missing) mock.AddQuery(&prestotest.MockQueryTemplate{ - SQL: `SELECT count(comment) AS non_null_values_count, "max_data_size_for_stats"(comment) AS max_data_size, approx_distinct(comment) AS distinct_values_count FROM tpch.sf1.lineitem`, + SQL: `SELECT count("comment") AS non_null_values_count, "max_data_size_for_stats"("comment") AS max_data_size, approx_distinct("comment") AS distinct_values_count FROM "tpch"."sf1"."lineitem"`, Columns: []presto.Column{{Name: "non_null_values_count", Type: "bigint"}, {Name: "max_data_size", Type: "bigint"}, {Name: "distinct_values_count", Type: "bigint"}}, Data: [][]any{{90.0, 128.0, 80.0}}, }) diff --git a/prestoapi/unmarshaller.go b/prestoapi/unmarshaller.go index a674b255..74fdddea 100644 --- a/prestoapi/unmarshaller.go +++ b/prestoapi/unmarshaller.go @@ -58,7 +58,6 @@ func unmarshalScalar(data any, v reflect.Value) { } v = v.Elem() vt = v.Type() - continue } if !v.CanSet() { return diff --git a/stage/mysql_run_recorder.go b/stage/mysql_run_recorder.go index 5cc9736f..0abd199a 100644 --- a/stage/mysql_run_recorder.go +++ b/stage/mysql_run_recorder.go @@ -110,7 +110,10 @@ cold_run, succeeded, start_time, end_time, row_count, expected_row_count, durati Msg("failed to update the run information in the MySQL database") return } - if rowsAffected, _ := res.RowsAffected(); rowsAffected > 1 { + if rowsAffected, raErr := res.RowsAffected(); raErr != nil { + log.Error().Err(raErr).Str("run_name", s.States.RunName).Int64("run_id", m.runId). + Msg("failed to get rows affected when updating run information") + } else if rowsAffected > 1 { log.Error().Str("run_name", s.States.RunName).Int64("run_id", m.runId).Int64("rows_affected", rowsAffected). Msg("more than 1 row was affected when trying to complete the run information in the MySQL database") } @@ -129,7 +132,10 @@ func (m *MySQLRunRecorder) RecordRun(ctx context.Context, s *Stage, results []*Q Msg("failed to complete the run information in the MySQL database") return } - if rowsAffected, _ := res.RowsAffected(); rowsAffected > 1 { + if rowsAffected, raErr := res.RowsAffected(); raErr != nil { + log.Error().Err(raErr).Str("run_name", s.States.RunName).Int64("run_id", m.runId). + Msg("failed to get rows affected when completing run information") + } else if rowsAffected > 1 { log.Error().Str("run_name", s.States.RunName).Int64("run_id", m.runId).Int64("rows_affected", rowsAffected). Msg("more than 1 row was affected when trying to complete the run information in the MySQL database") } diff --git a/stage/pulumi_run_recorder.go b/stage/pulumi_run_recorder.go index 198345a8..e8190128 100644 --- a/stage/pulumi_run_recorder.go +++ b/stage/pulumi_run_recorder.go @@ -16,6 +16,8 @@ import ( "time" ) +var pulumiHTTPClient = &http.Client{Timeout: 30 * time.Second} + const PulumiAPIEndpoint = "https://api.pulumi.com" const PulumiResourceTypeStack = "pulumi:pulumi:Stack" @@ -82,7 +84,7 @@ func (p *PulumiMySQLRunRecorder) newGetRequest(urlStr string) (*http.Request, er func (p *PulumiMySQLRunRecorder) doRequest(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error) { req = req.WithContext(ctx) - resp, err := http.DefaultClient.Do(req) + resp, err := pulumiHTTPClient.Do(req) if err != nil { // If we got an error, and the context has been canceled, // the context's error is probably more useful. diff --git a/stage/run_recorder.go b/stage/run_recorder.go index 994a67c5..8f10128b 100644 --- a/stage/run_recorder.go +++ b/stage/run_recorder.go @@ -30,11 +30,13 @@ func NewFileBasedRunRecorder() *FileBasedRunRecorder { func (f *FileBasedRunRecorder) Start(_ context.Context, _ *Stage) error { f.csvWriter = csv.NewWriter(&f.buf) f.csvWriter.UseCRLF = false - f.csvWriter.Write([]string{ + if err := f.csvWriter.Write([]string{ "stage_id", "query_file", "query_index", "cold_run", "sequence_no", "info_url", "succeeded", "row_count", "expected_row_count", "start_time", "end_time", "duration_in_seconds", - }) + }); err != nil { + return fmt.Errorf("failed to write CSV header: %w", err) + } return nil } @@ -51,7 +53,7 @@ func (f *FileBasedRunRecorder) RecordQuery(_ context.Context, _ *Stage, result * if result.Duration != nil { durationSecs = result.Duration.Seconds() } - f.csvWriter.Write([]string{ + if err := f.csvWriter.Write([]string{ result.StageId, queryFile, strconv.Itoa(result.Query.Index), @@ -64,7 +66,9 @@ func (f *FileBasedRunRecorder) RecordQuery(_ context.Context, _ *Stage, result * result.StartTime.Format(time.RFC3339), endTimeStr, fmt.Sprintf("%f", durationSecs), - }) + }); err != nil { + log.Error().Err(err).Msg("failed to write CSV row") + } } func (f *FileBasedRunRecorder) RecordRun(_ context.Context, s *Stage, _ []*QueryResult) { diff --git a/stage/run_recorder_test.go b/stage/run_recorder_test.go new file mode 100644 index 00000000..b3cbe9ba --- /dev/null +++ b/stage/run_recorder_test.go @@ -0,0 +1,63 @@ +package stage + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestFileBasedRunRecorder_StartWritesHeader(t *testing.T) { + recorder := NewFileBasedRunRecorder() + err := recorder.Start(context.Background(), nil) + require.NoError(t, err) + + // csv.Writer buffers internally; flush to see the output + recorder.csvWriter.Flush() + assert.Contains(t, recorder.buf.String(), "stage_id") + assert.Contains(t, recorder.buf.String(), "duration_in_seconds") +} + +func TestFileBasedRunRecorder_RecordQuery(t *testing.T) { + recorder := NewFileBasedRunRecorder() + require.NoError(t, recorder.Start(context.Background(), nil)) + + queryFile := "test.sql" + endTime := time.Now() + dur := 1500 * time.Millisecond + result := &QueryResult{ + StageId: "stage_1", + Query: &Query{File: &queryFile, Index: 0, ColdRun: true, SequenceNo: 0, ExpectedRowCount: 10}, + QueryId: "q1", + RowCount: 10, + StartTime: endTime.Add(-dur), + EndTime: &endTime, + Duration: &dur, + } + + recorder.RecordQuery(context.Background(), nil, result) + + recorder.csvWriter.Flush() + output := recorder.buf.String() + assert.Contains(t, output, "stage_1") + assert.Contains(t, output, "test.sql") +} + +func TestFileBasedRunRecorder_RecordQueryInline(t *testing.T) { + recorder := NewFileBasedRunRecorder() + require.NoError(t, recorder.Start(context.Background(), nil)) + + result := &QueryResult{ + StageId: "stage_1", + Query: &Query{Index: 0, ColdRun: false, SequenceNo: 1, ExpectedRowCount: -1}, + StartTime: time.Now(), + } + + recorder.RecordQuery(context.Background(), nil, result) + + recorder.csvWriter.Flush() + output := recorder.buf.String() + assert.Contains(t, output, "inline") +} diff --git a/stage/stage.go b/stage/stage.go index c7c9587d..7e6ee5ad 100644 --- a/stage/stage.go +++ b/stage/stage.go @@ -199,7 +199,7 @@ func (s *Stage) Run(ctx context.Context) int { case result := <-s.States.resultChan: results = append(results, result) for _, recorder := range s.States.runRecorders { - rCtx, rCancel := utils.GetCtxWithTimeout(time.Second * 5) + rCtx, rCancel := context.WithTimeout(ctx, time.Second*5) recorder.RecordQuery(rCtx, s, result) rCancel() } @@ -218,7 +218,7 @@ func (s *Stage) Run(ctx context.Context) int { case result := <-s.States.resultChan: results = append(results, result) for _, recorder := range s.States.runRecorders { - rCtx, rCancel := utils.GetCtxWithTimeout(time.Second * 5) + rCtx, rCancel := context.WithTimeout(ctx, time.Second*5) recorder.RecordQuery(rCtx, s, result) rCancel() } @@ -236,7 +236,7 @@ func (s *Stage) Run(ctx context.Context) int { } } for _, recorder := range s.States.runRecorders { - rCtx, rCancel := utils.GetCtxWithTimeout(time.Second * 5) + rCtx, rCancel := context.WithTimeout(ctx, time.Second*5) recorder.RecordRun(rCtx, s, results) rCancel() } @@ -732,7 +732,9 @@ func (s *Stage) runQuery(ctx context.Context, query *Query) (result *QueryResult } else { log.Info().EmbedObject(resultSnapshot).Msg("query data saved successfully") } - _ = queryOutputFile.Close() + if closeErr := queryOutputFile.Close(); closeErr != nil { + log.Error().Err(closeErr).EmbedObject(resultSnapshot).Msg("failed to close query output file") + } s.States.wgExitMainStage.Done() }() } diff --git a/stage/stage_utils.go b/stage/stage_utils.go index 525f4c7e..80e9da58 100644 --- a/stage/stage_utils.go +++ b/stage/stage_utils.go @@ -326,7 +326,7 @@ func (s *Stage) saveQueryJsonFile(result *QueryResult) { checkErr(err) if err == nil { // We need to save the query json file even if the stage context is canceled. - qCtx, qCancel := utils.GetCtxWithTimeout(time.Second * 5) + qCtx, qCancel := context.WithTimeout(context.Background(), time.Second*5) _, err = s.Client.GetQueryInfo(qCtx, result.QueryId, queryJsonFile) qCancel() checkErr(err) diff --git a/utils/utils.go b/utils/utils.go index 75daf8f2..8556cf3f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,7 +2,6 @@ package utils import ( "bufio" - "context" "database/sql" "encoding/json" "errors" @@ -15,7 +14,6 @@ import ( "pbench/log" "reflect" "strings" - "time" ) const ( @@ -23,10 +21,6 @@ const ( DirectoryNameTimeFormat = "060102-150405" ) -func GetCtxWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc) { - return context.WithTimeout(context.Background(), timeout) -} - func ExpandHomeDirectory(path *string) { if path != nil && (*path == "~" || strings.HasPrefix(*path, "~/")) { if home, err := os.UserHomeDir(); err == nil { From 0d7d29cff86f18a2721189529cf2726e45c247ce Mon Sep 17 00:00:00 2001 From: "Yiqun (Ethan) Zhang" Date: Wed, 25 Mar 2026 00:57:36 -0500 Subject: [PATCH 12/20] chore: update presto-go-client to v2.1.1 The query_json package was renamed to queryjson in v2.1.1. Updated all import paths and package qualifiers across 6 files. --- cmd/forward/main.go | 6 ++-- cmd/loadjson/main.go | 4 +-- cmd/loadjson/query_info_test.go | 4 +-- cmd/replay/query_log.go | 12 +++---- go.mod | 28 +++++++-------- go.sum | 62 +++++++++++++++++---------------- utils/orm.go | 6 ++-- utils/orm_test.go | 6 ++-- 8 files changed, 65 insertions(+), 63 deletions(-) diff --git a/cmd/forward/main.go b/cmd/forward/main.go index 7884a120..4ca2fed9 100644 --- a/cmd/forward/main.go +++ b/cmd/forward/main.go @@ -10,7 +10,7 @@ import ( "pbench/utils" presto "github.com/prestodb/presto-go-client/v2" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" "regexp" "sync" "sync/atomic" @@ -218,11 +218,11 @@ func checkAndCancelQuery(ctx context.Context, queryState *presto.QueryStateInfo) func forwardQuery(ctx context.Context, queryState *presto.QueryStateInfo, clients []*presto.Client) { defer runningTasks.Done() var queryInfoErr error - queryInfo := new(query_json.QueryInfo) + queryInfo := new(queryjson.QueryInfo) for attempt := 1; attempt <= maxRetry; attempt++ { _, queryInfoErr = clients[0].GetQueryInfo(ctx, queryState.QueryId, queryInfo) if queryInfoErr != nil { - queryInfo = new(query_json.QueryInfo) + queryInfo = new(queryjson.QueryInfo) log.Error().Str("source_query_id", queryState.QueryId).Err(queryInfoErr). Msgf("failed to get query info for forwarding, attempt %d/%d", attempt, maxRetry) waitForNextPoll(ctx) diff --git a/cmd/loadjson/main.go b/cmd/loadjson/main.go index ff145f16..f613ba0a 100644 --- a/cmd/loadjson/main.go +++ b/cmd/loadjson/main.go @@ -16,7 +16,7 @@ import ( "syscall" "time" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" "github.com/spf13/cobra" ) @@ -147,7 +147,7 @@ func processFile(ctx context.Context, path string) { log.Error().Err(ioErr).Str("path", path).Msg("failed to read file") return } - queryInfo := new(query_json.QueryInfo) + queryInfo := new(queryjson.QueryInfo) // Note that this step can succeed with any valid JSON file. But we need to do some additional validation to skip // invalid query JSON files. if unmarshalErr := json.Unmarshal(bytes, queryInfo); unmarshalErr != nil { diff --git a/cmd/loadjson/query_info_test.go b/cmd/loadjson/query_info_test.go index 91cd9441..700490f9 100644 --- a/cmd/loadjson/query_info_test.go +++ b/cmd/loadjson/query_info_test.go @@ -3,7 +3,7 @@ package loadjson import ( "embed" "encoding/json" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" "github.com/stretchr/testify/assert" "testing" ) @@ -39,7 +39,7 @@ func TestParseQueryInfo(t *testing.T) { jsonBytes, err := testFiles.ReadFile(tc.filePath) assert.Nil(t, err) - queryInfo := new(query_json.QueryInfo) + queryInfo := new(queryjson.QueryInfo) assert.Nil(t, json.Unmarshal(jsonBytes, queryInfo)) assert.Nil(t, queryInfo.PrepareForInsert()) assert.Nil(t, queryInfo.OutputStage) diff --git a/cmd/replay/query_log.go b/cmd/replay/query_log.go index 9b45cfa7..c6777650 100644 --- a/cmd/replay/query_log.go +++ b/cmd/replay/query_log.go @@ -3,7 +3,7 @@ package replay import ( "encoding/json" "fmt" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" "time" ) @@ -222,11 +222,11 @@ type QueryLog struct { //QueryOptimiserEvent any `json:"queryOptimiserEvent,omitempty"` //SplitCompletedEvent any `json:"splitCompletedEvent,omitempty"` //Plan string `json:"plan,omitempty"` - CPUTimeMillis query_json.Duration `json:"cpuTimeMillis,omitempty"` - RetriedCPUTimeMillis query_json.Duration `json:"retriedCpuTimeMillis,omitempty"` - WallTimeMillis query_json.Duration `json:"wallTimeMillis,omitempty"` - QueuedTimeMillis query_json.Duration `json:"queuedTimeMillis,omitempty"` - AnalysisTimeMillis query_json.Duration `json:"analysisTimeMillis,omitempty"` + CPUTimeMillis queryjson.Duration `json:"cpuTimeMillis,omitempty"` + RetriedCPUTimeMillis queryjson.Duration `json:"retriedCpuTimeMillis,omitempty"` + WallTimeMillis queryjson.Duration `json:"wallTimeMillis,omitempty"` + QueuedTimeMillis queryjson.Duration `json:"queuedTimeMillis,omitempty"` + AnalysisTimeMillis queryjson.Duration `json:"analysisTimeMillis,omitempty"` } type Value struct { diff --git a/go.mod b/go.mod index c90a16ad..09d4a253 100644 --- a/go.mod +++ b/go.mod @@ -3,24 +3,24 @@ module pbench go 1.26.1 require ( - github.com/alecthomas/participle/v2 v2.1.1 - github.com/go-playground/validator/v10 v10.24.0 - github.com/go-sql-driver/mysql v1.8.1 - github.com/influxdata/influxdb-client-go/v2 v2.13.0 + github.com/alecthomas/participle/v2 v2.1.4 + github.com/go-playground/validator/v10 v10.30.1 + github.com/go-sql-driver/mysql v1.9.3 + github.com/influxdata/influxdb-client-go/v2 v2.14.0 github.com/pkg/errors v0.9.1 - github.com/prestodb/presto-go-client/v2 v2.0.1 + github.com/prestodb/presto-go-client/v2 v2.1.1 github.com/rs/zerolog v1.34.0 github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 - golang.org/x/sys v0.38.0 + golang.org/x/sys v0.42.0 ) require ( - filippo.io/edwards25519 v1.1.1 // indirect + filippo.io/edwards25519 v1.2.0 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.8 // indirect + github.com/gabriel-vasile/mimetype v1.4.13 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/google/uuid v1.6.0 // indirect @@ -28,15 +28,15 @@ require ( github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect github.com/kr/pretty v0.1.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/oapi-codegen/runtime v1.1.1 // indirect + github.com/oapi-codegen/runtime v1.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/pflag v1.0.9 // indirect + github.com/spf13/pflag v1.0.10 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/net v0.47.0 // indirect - golang.org/x/text v0.31.0 // indirect + golang.org/x/crypto v0.49.0 // indirect + golang.org/x/net v0.52.0 // indirect + golang.org/x/text v0.35.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 10bc7e6c..bf17eeee 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ -filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw= -filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= +filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= -github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= -github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= -github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= -github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= -github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= -github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= +github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/participle/v2 v2.1.4 h1:W/H79S8Sat/krZ3el6sQMvMaahJ+XcM9WSI2naI7w2U= +github.com/alecthomas/participle/v2 v2.1.4/go.mod h1:8tqVbpTX20Ru4NfYQgZf4mP18eXPTBViyMWiArNEgGI= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= @@ -17,18 +17,18 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= -github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= +github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM= +github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg= -github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= -github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= -github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w= +github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM= +github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo= +github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -36,8 +36,8 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/influxdata/influxdb-client-go/v2 v2.13.0 h1:ioBbLmR5NMbAjP4UVA5r9b5xGjpABD7j65pI8kFphDM= -github.com/influxdata/influxdb-client-go/v2 v2.13.0/go.mod h1:k+spCbt9hcvqvUiz0sr5D8LolXHqAAOfPw9v/RIRHl4= +github.com/influxdata/influxdb-client-go/v2 v2.14.0 h1:AjbBfJuq+QoaXNcrova8smSjwJdUHnwvfjMF71M1iI4= +github.com/influxdata/influxdb-client-go/v2 v2.14.0/go.mod h1:Ahpm3QXKMJslpXl3IftVLVezreAUtBOTZssDrjZEFHI= github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf h1:7JTmneyiNEwVBOHSjoMxiWAqB992atOeepeFYegn5RU= github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= @@ -48,28 +48,30 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= -github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= +github.com/oapi-codegen/runtime v1.3.0 h1:vyK1zc0gDWWXgk2xoQa4+X4RNNc5SL2RbTpJS/4vMYA= +github.com/oapi-codegen/runtime v1.3.0/go.mod h1:kOdeacKy7t40Rclb1je37ZLFboFxh+YLy0zaPCMibPY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prestodb/presto-go-client/v2 v2.0.1 h1:Qu5tizqabl+jGwQIsSWNT0H+uheIcEE+WIzuj3++hYU= -github.com/prestodb/presto-go-client/v2 v2.0.1/go.mod h1:vfkqZB6qWlvlSZpQet/LXFUdwkWMBCV502hmqD9Czvw= +github.com/prestodb/presto-go-client/v2 v2.1.1 h1:3mIaMitux4x/kV5CCpT0XQEcyPuPxi7eIfdXtB9VGJg= +github.com/prestodb/presto-go-client/v2 v2.1.1/go.mod h1:xXanlGM7ptbiRDX9rn4G7GXlITtR+pWX5MoR5G7t8cI= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= -github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -78,17 +80,17 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4= +golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= +golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0= +golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= +golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/utils/orm.go b/utils/orm.go index 526ad34a..8af62d78 100644 --- a/utils/orm.go +++ b/utils/orm.go @@ -9,7 +9,7 @@ import ( "reflect" "strings" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" ) type TableName string @@ -95,7 +95,7 @@ func SqlInsertObject(ctx context.Context, db *sql.DB, obj any, tableNames ...Tab // Nested structs are traversed recursively and their columns are merged via cartesian product with the // parent's columns (so if a parent contributes 1 row and a child slice contributes 3, the result is 3 // rows each containing both parent and child columns). Slice/array fields of structs produce one row -// per element. json.RawMessage values are compacted, and query_json.Duration values are converted to +// per element. json.RawMessage values are compacted, and queryjson.Duration values are converted to // milliseconds. func collectRowsForEachTable(v reflect.Value, tableNames ...TableName) (rowsMap map[TableName][]*Row, err error) { rowsMap = make(map[TableName][]*Row) @@ -123,7 +123,7 @@ func collectRowsForEachTable(v reflect.Value, tableNames ...TableName) (rowsMap typed = compactedJson.Bytes() } fieldValue = string(typed) - case query_json.Duration: + case queryjson.Duration: // TODO: Add a tag for precision. EventListener only uses ms. fieldValue = typed.Milliseconds() default: diff --git a/utils/orm_test.go b/utils/orm_test.go index 7fd64328..f00fafd6 100644 --- a/utils/orm_test.go +++ b/utils/orm_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/prestodb/presto-go-client/v2/query_json" + "github.com/prestodb/presto-go-client/v2/queryjson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -122,9 +122,9 @@ func TestCollectRowsForEachTable_JsonRawMessage(t *testing.T) { func TestCollectRowsForEachTable_Duration(t *testing.T) { type withDuration struct { - Elapsed query_json.Duration `table_d:"elapsed_ms"` + Elapsed queryjson.Duration `table_d:"elapsed_ms"` } - var dur query_json.Duration + var dur queryjson.Duration err := json.Unmarshal([]byte(`"5.00s"`), &dur) require.NoError(t, err) obj := withDuration{Elapsed: dur} From 3628c2bca890cdab6737d6feb2df7b7ac346bb90 Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Mon, 30 Mar 2026 11:29:47 +0530 Subject: [PATCH 13/20] Enhanced ingestion workflow --- cmd/genddl/create_source_table.sql.tmpl | 45 +++++++++ cmd/genddl/create_target_table.sql.tmpl | 71 ++++++++++++++ cmd/genddl/insert_table.sql.tmpl | 46 ++++++++++ cmd/genddl/main.go | 117 +++++++++++++++++++++--- 4 files changed, 266 insertions(+), 13 deletions(-) create mode 100644 cmd/genddl/create_source_table.sql.tmpl create mode 100644 cmd/genddl/create_target_table.sql.tmpl diff --git a/cmd/genddl/create_source_table.sql.tmpl b/cmd/genddl/create_source_table.sql.tmpl new file mode 100644 index 00000000..74bacbfc --- /dev/null +++ b/cmd/genddl/create_source_table.sql.tmpl @@ -0,0 +1,45 @@ +{{- /*gotype:pbench/cmd/genddl.Schema*/ -}} +{{- /* This template is used for ENHANCED_INGESTION mode - creates source tables */ -}} +{{- if .SourceSchema }} +{{- if .SourceCatalog }} +CREATE SCHEMA IF NOT EXISTS {{ .SourceCatalog }}.{{ .SourceSchema }} +WITH ( + location = '{{ .S3SourceLocation }}/' +); + +USE {{ .SourceCatalog }}.{{ .SourceSchema }}; +{{- else }} +CREATE SCHEMA IF NOT EXISTS hive.{{ .SourceSchema }} +WITH ( + location = '{{ .S3SourceLocation }}/' +); + +USE hive.{{ .SourceSchema }}; +{{- end }} + +{{ range .Tables }} +CREATE TABLE IF NOT EXISTS {{ .Name }} ( +{{- $first := true }} +{{- range .Columns }} + {{- if $first }} + {{- $first = false }} + {{- else }}, + {{- end }} + {{- if eq $.SourceFileFormat "CSV" }} + {{ .Name }} varchar + {{- else }} + {{ .Name }} {{ .Type }} + {{- end }} +{{- end }}) +WITH ( + external_location = '{{ $.S3SourceLocation }}/{{ .Name }}/', + {{- if eq $.SourceFileFormat "CSV" }} + format = 'CSV', + csv_separator = '|' + {{- else }} + format = 'TEXTFILE', + textfile_field_delim = '|' + {{- end }} +); +{{ end }} +{{- end }} \ No newline at end of file diff --git a/cmd/genddl/create_target_table.sql.tmpl b/cmd/genddl/create_target_table.sql.tmpl new file mode 100644 index 00000000..3db33270 --- /dev/null +++ b/cmd/genddl/create_target_table.sql.tmpl @@ -0,0 +1,71 @@ +{{- /*gotype:pbench/cmd/genddl.Schema*/ -}} +{{- /* This template is used for ENHANCED_INGESTION mode - creates target tables */ -}} +{{- if .TargetSchema }} +{{- if .TargetCatalog }} +{{- if .Iceberg }} +USE {{ .TargetCatalog }}; +CREATE SCHEMA IF NOT EXISTS {{ .TargetSchema }} LOCATION '{{ .S3TargetLocation }}/'; + +USE {{ .TargetCatalog }}.{{ .TargetSchema }}; +{{- else }} +CREATE SCHEMA IF NOT EXISTS {{ .TargetCatalog }}.{{ .TargetSchema }} +WITH ( + location = '{{ .S3TargetLocation }}/' +); + +USE {{ .TargetCatalog }}.{{ .TargetSchema }}; +{{- end }} +{{- else }} +{{- if .Iceberg }} +USE iceberg; +CREATE SCHEMA IF NOT EXISTS {{ .TargetSchema }} LOCATION '{{ .S3TargetLocation }}/'; + +USE iceberg.{{ .TargetSchema }}; +{{- else }} +CREATE SCHEMA IF NOT EXISTS hive.{{ .TargetSchema }} +WITH ( + location = '{{ .S3TargetLocation }}/' +); + +USE hive.{{ .TargetSchema }}; +{{- end }} +{{- end }} + +{{ range .Tables }} +CREATE TABLE IF NOT EXISTS {{ .Name }} ( +{{- $first := true }} +{{- range .Columns }} + {{- if $first }} + {{- $first = false }} + {{- else -}} + , + {{- end }} + {{ .Name }} {{ .Type }} +{{- end }} +) +{{- if eq $.Engine "spark" }} +USING iceberg +{{- if .Partitioned }} +PARTITIONED BY ({{ .LastColumn.Name }}) +{{- end }} +TBLPROPERTIES ('write.target-file-size-bytes' = 268435456, 'write.parquet.row-group-size-bytes' = 67108864) +LOCATION '{{ $.S3TargetLocation }}/{{ .Name }}'; +{{- else }} +WITH ( + format = 'PARQUET' + {{- if $.Partitioned }} + {{- if $.Iceberg}} + , partitioning = array['{{ .LastColumn.Name }}'] + {{- else if .Partitioned }} + , partitioned_by = array['{{ .LastColumn.Name }}'] + , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' + {{- else }} + , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' + {{- end }} + {{- else }} + , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' + {{- end }} +); +{{- end }} +{{ end }} +{{- end }} \ No newline at end of file diff --git a/cmd/genddl/insert_table.sql.tmpl b/cmd/genddl/insert_table.sql.tmpl index 360b4e7c..41207c67 100644 --- a/cmd/genddl/insert_table.sql.tmpl +++ b/cmd/genddl/insert_table.sql.tmpl @@ -3,6 +3,50 @@ SET SESSION {{ $key }}='{{ $value }}'; {{ end }} +{{- if .TargetSchema }} +{{- /* ENHANCED_INGESTION MODE */ -}} +{{- if .TargetCatalog }} +USE {{ .TargetCatalog }}.{{ .TargetSchema }}; +{{- else }} +{{- if .Iceberg }} +USE iceberg.{{ .TargetSchema }}; +{{- else }} +USE hive.{{ .TargetSchema }}; +{{- end }} +{{- end }} + +{{ range .InsertTables -}} +{{- if $.TargetCatalog }} +INSERT INTO {{ $.TargetCatalog }}.{{ $.TargetSchema }}.{{ .Name }} +{{- else }} +INSERT INTO {{ .Name }} +{{- end }} +SELECT +{{- $first := true }} +{{- range .Columns }} + {{- if $first }} + {{- $first = false }} + {{- else }}, + {{- end }} + {{- if eq $.SourceFileFormat "CSV" }} + {{- if .IsVarchar }} + NULLIF({{ .Name }}, '') AS {{ .Name }} + {{- else }} + CAST(NULLIF({{ .Name }}, '') AS {{ .Type }}) AS {{ .Name }} + {{- end }} + {{- else }} + {{- if .IsVarchar }} + {{ .Name }} + {{- else }} + CAST({{ .Name }} AS {{ .Type }}) AS {{ .Name }} + {{- end }} + {{- end }} +{{- end }} +FROM {{ if $.SourceCatalog }}{{ $.SourceCatalog }}.{{ $.SourceSchema }}.{{ .Name }}{{ else }}hive.{{ $.SourceSchema }}.{{ .Name }}{{ end }}; + +{{ end }} +{{- else }} +{{- /* LEGACY MODE (old workflow) */ -}} {{- if .Iceberg }} USE iceberg.{{ .SchemaName }}; {{- else }} @@ -31,6 +75,8 @@ SELECT * FROM {{ if $.Iceberg }}iceberg{{ else }}hive{{ end }}.{{ $.Uncompressed {{- end }} {{ end }} +{{- end }} + {{- range .InsertTables -}} ANALYZE {{ .Name }}; {{ end -}} diff --git a/cmd/genddl/main.go b/cmd/genddl/main.go index 346f8709..fe547c5f 100644 --- a/cmd/genddl/main.go +++ b/cmd/genddl/main.go @@ -31,6 +31,17 @@ type Schema struct { Tables map[string]*Table `json:"tables"` InsertTables map[string]*Table `json:"insert_tables"` SessionVariables map[string]string `json:"session_variables"` + + // Enhanced ingestion workflow fields + Mode string `json:"mode"` // "legacy", "ingestion", or "enhanced_ingestion" + S3SourceLocation string `json:"s3_source_location"` // S3 path for source data + S3TargetLocation string `json:"s3_target_location"` // S3 path for target data + SourceSchema string `json:"source_schema"` // Source schema name + TargetSchema string `json:"target_schema"` // Target schema name + SourceFileFormat string `json:"source_file_format"` // "CSV" or "TEXTFILE" + SourceCatalog string `json:"source_catalog"` // Source catalog name (optional) + TargetCatalog string `json:"target_catalog"` // Target catalog name (optional) + Engine string `json:"engine"` // "presto" or "spark" } type Column struct { @@ -54,6 +65,12 @@ type RegisterTable struct { ExternalLocation *string } +// isEnhancedIngestionMode returns true if this schema should use the enhanced ingestion workflow +// (source tables + target tables + INSERT statements with catalog support and CSV/TEXTFILE handling) +func (s *Schema) isEnhancedIngestionMode() bool { + return s.Mode == "enhanced_ingestion" +} + func Run(_ *cobra.Command, args []string) { // Reset template cache for each invocation. templateCache = make(map[string]*template.Template) @@ -140,8 +157,12 @@ func generateSchemaFromDef(schema *Schema, defDir string, configDir string, outp registerTable.ExternalLocation = externalLoc schema.RegisterTables = append(schema.RegisterTables, ®isterTable) } else { - tbl.reorderColumns(schema) // Move PartitionKey columns to the bottom - tbl.LastColumn = tbl.Columns[len(tbl.Columns)-1] + // Only reorder columns for Hive tables (Iceberg doesn't require partition columns at end) + if !schema.Iceberg { + tbl.reorderColumns(schema) + } + // Set LastColumn for template rendering (finds partition key or uses last column) + tbl.setLastColumn(schema) schema.Tables[tbl.Name] = tbl } if isInsertTable(tbl, schema) { @@ -161,15 +182,22 @@ func generateSchemaFromDef(schema *Schema, defDir string, configDir string, outp func generateCreateTable(schema *Schema, currDir string, outputDirs []string, step int) { genSubSteps := !schema.Iceberg && schema.Partitioned - tName := "create_table.sql.tmpl" - var fName string - if genSubSteps { - // If there are sub-tasks, prefix the first output file with step a - fName = strconv.Itoa(step+1) + "a-create-" + schema.LocationName + ".sql" + if schema.isEnhancedIngestionMode() { + // Enhanced ingestion mode: generate separate source and target table files + generateSourceTable(schema, currDir, outputDirs, step) + generateTargetTable(schema, currDir, outputDirs, step) } else { - fName = strconv.Itoa(step+1) + "-create-" + schema.LocationName + ".sql" + // Legacy mode: single create table file + tName := "create_table.sql.tmpl" + var fName string + if genSubSteps { + // If there are sub-tasks, prefix the first output file with step a + fName = strconv.Itoa(step+1) + "a-create-" + schema.LocationName + ".sql" + } else { + fName = strconv.Itoa(step+1) + "-create-" + schema.LocationName + ".sql" + } + execTemplate(schema, getTemplate(tName, currDir), fName, outputDirs) } - execTemplate(schema, getTemplate(tName, currDir), fName, outputDirs) if genSubSteps { generateAwsS3Mv(schema, currDir, outputDirs, step) // Generate step b @@ -178,6 +206,20 @@ func generateCreateTable(schema *Schema, currDir string, outputDirs []string, st } } +// generateSourceTable generates source table DDL for enhanced ingestion mode +func generateSourceTable(schema *Schema, currDir string, outputDirs []string, step int) { + tName := "create_source_table.sql.tmpl" + fName := strconv.Itoa(step+1) + "a-create-source-" + schema.LocationName + ".sql" + execTemplate(schema, getTemplate(tName, currDir), fName, outputDirs) +} + +// generateTargetTable generates target table DDL for enhanced ingestion mode +func generateTargetTable(schema *Schema, currDir string, outputDirs []string, step int) { + tName := "create_target_table.sql.tmpl" + fName := strconv.Itoa(step+1) + "b-create-target-" + schema.LocationName + ".sql" + execTemplate(schema, getTemplate(tName, currDir), fName, outputDirs) +} + func generateInsertTable(schema *Schema, currDir string, outputDirs []string, step int) { tName := "insert_table.sql.tmpl" fName := strconv.Itoa(step+1) + "-insert-" + schema.LocationName + ".sql" @@ -265,10 +307,20 @@ func cleanOutputDir(dir string) error { } func (s *Schema) shouldGenInsert() bool { + // Enhanced ingestion mode always generates inserts + if s.isEnhancedIngestionMode() { + return true + } + // Legacy mode: only generate inserts for Iceberg return s.Iceberg } func isRegisterTable(table *Table, schema *Schema) bool { + // Enhanced ingestion mode doesn't use register tables + if schema.isEnhancedIngestionMode() { + return false + } + // Legacy mode: register non-partitioned tables in Iceberg partitioned schemas if schema.Iceberg && schema.Partitioned { return !table.Partitioned } @@ -276,6 +328,11 @@ func isRegisterTable(table *Table, schema *Schema) bool { } func isInsertTable(table *Table, schema *Schema) bool { + // Enhanced ingestion mode: all tables get inserts + if schema.isEnhancedIngestionMode() { + return true + } + // Legacy mode: partitioned tables in partitioned schemas, or all tables in non-partitioned if schema.Partitioned { return table.Partitioned } @@ -283,14 +340,26 @@ func isInsertTable(table *Table, schema *Schema) bool { } func getNamedOutput(configData []byte, workload string) (string, error) { - var config map[string]string + // Use interface{} to handle both string and boolean values in config + var config map[string]interface{} if err := json.Unmarshal(configData, &config); err != nil { return "", err } - scaleFactor := config["scale_factor"] - fileFormat := config["file_format"] - compressionMethod := config["compression_method"] + // Extract string values with type assertion (these are always strings in config) + scaleFactor, ok := config["scale_factor"].(string) + if !ok { + return "", fmt.Errorf("scale_factor must be a string") + } + fileFormat, ok := config["file_format"].(string) + if !ok { + return "", fmt.Errorf("file_format must be a string") + } + compressionMethod, ok := config["compression_method"].(string) + if !ok { + return "", fmt.Errorf("compression_method must be a string") + } + var compressionSuffix string if compressionMethod == "uncompressed" { compressionSuffix = "" @@ -323,6 +392,10 @@ func loadSchemas(data []byte) ([]*Schema, error) { if base.WorkloadDefinition == "" { base.WorkloadDefinition = "tpc-ds" } + // Default engine for enhanced ingestion mode + if base.Engine == "" && base.isEnhancedIngestionMode() { + base.Engine = "presto" + } combinations := []struct { Iceberg bool @@ -395,6 +468,24 @@ func (t *Table) reorderColumns(s *Schema) { } } +// setLastColumn sets the LastColumn field for template rendering. +// For partitioned tables, it finds the column marked with partition_key=true. +// For non-partitioned tables or if no partition key is found, it uses the last column. +// This works for both Iceberg (partition columns can be anywhere) and Hive (after reordering). +func (t *Table) setLastColumn(s *Schema) { + // Look for partition key column + for _, col := range t.Columns { + if col.PartitionKey != nil && *col.PartitionKey { + t.LastColumn = col + return + } + } + // Fallback to last column if no partition key found + if len(t.Columns) > 0 { + t.LastColumn = t.Columns[len(t.Columns)-1] + } +} + func (s *Schema) setSessionVars() { s.SessionVariables["query_max_execution_time"] = "12h" s.SessionVariables["query_max_run_time"] = "12h" From 0c9d73356a8bd2121b8177810bb2c5e421f4234f Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Wed, 1 Apr 2026 18:46:02 +0530 Subject: [PATCH 14/20] Insert teamplate and schema creation fix If source file format is TEXTFILE then insert can be completed without CAST. Schema creation for target table has a syntax error now fixed. The sql files are created for the specified schema and catalog and not for every table combinations. --- cmd/genddl/create_target_table.sql.tmpl | 13 ++++------- cmd/genddl/insert_table.sql.tmpl | 10 ++++---- cmd/genddl/main.go | 31 ++++++++++++++++++++----- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/cmd/genddl/create_target_table.sql.tmpl b/cmd/genddl/create_target_table.sql.tmpl index 3db33270..be7d9939 100644 --- a/cmd/genddl/create_target_table.sql.tmpl +++ b/cmd/genddl/create_target_table.sql.tmpl @@ -2,23 +2,18 @@ {{- /* This template is used for ENHANCED_INGESTION mode - creates target tables */ -}} {{- if .TargetSchema }} {{- if .TargetCatalog }} -{{- if .Iceberg }} -USE {{ .TargetCatalog }}; -CREATE SCHEMA IF NOT EXISTS {{ .TargetSchema }} LOCATION '{{ .S3TargetLocation }}/'; - -USE {{ .TargetCatalog }}.{{ .TargetSchema }}; -{{- else }} CREATE SCHEMA IF NOT EXISTS {{ .TargetCatalog }}.{{ .TargetSchema }} WITH ( location = '{{ .S3TargetLocation }}/' ); USE {{ .TargetCatalog }}.{{ .TargetSchema }}; -{{- end }} {{- else }} {{- if .Iceberg }} -USE iceberg; -CREATE SCHEMA IF NOT EXISTS {{ .TargetSchema }} LOCATION '{{ .S3TargetLocation }}/'; +CREATE SCHEMA IF NOT EXISTS iceberg.{{ .TargetSchema }} +WITH ( + location = '{{ .S3TargetLocation }}/' +); USE iceberg.{{ .TargetSchema }}; {{- else }} diff --git a/cmd/genddl/insert_table.sql.tmpl b/cmd/genddl/insert_table.sql.tmpl index 41207c67..52c08280 100644 --- a/cmd/genddl/insert_table.sql.tmpl +++ b/cmd/genddl/insert_table.sql.tmpl @@ -21,6 +21,9 @@ INSERT INTO {{ $.TargetCatalog }}.{{ $.TargetSchema }}.{{ .Name }} {{- else }} INSERT INTO {{ .Name }} {{- end }} +{{- if eq $.SourceFileFormat "TEXTFILE" }} +SELECT * FROM {{ if $.SourceCatalog }}{{ $.SourceCatalog }}.{{ $.SourceSchema }}.{{ .Name }}{{ else }}hive.{{ $.SourceSchema }}.{{ .Name }}{{ end }}; +{{- else }} SELECT {{- $first := true }} {{- range .Columns }} @@ -34,15 +37,10 @@ SELECT {{- else }} CAST(NULLIF({{ .Name }}, '') AS {{ .Type }}) AS {{ .Name }} {{- end }} - {{- else }} - {{- if .IsVarchar }} - {{ .Name }} - {{- else }} - CAST({{ .Name }} AS {{ .Type }}) AS {{ .Name }} - {{- end }} {{- end }} {{- end }} FROM {{ if $.SourceCatalog }}{{ $.SourceCatalog }}.{{ $.SourceSchema }}.{{ .Name }}{{ else }}hive.{{ $.SourceSchema }}.{{ .Name }}{{ end }}; +{{- end }} {{ end }} {{- else }} diff --git a/cmd/genddl/main.go b/cmd/genddl/main.go index fe547c5f..97f92ae9 100644 --- a/cmd/genddl/main.go +++ b/cmd/genddl/main.go @@ -397,14 +397,33 @@ func loadSchemas(data []byte) ([]*Schema, error) { base.Engine = "presto" } - combinations := []struct { + // In enhanced ingestion mode, detect catalog type and generate only for that type + var combinations []struct { Iceberg bool Partitioned bool - }{ - {true, false}, - {true, true}, - {false, false}, - {false, true}, + } + + if base.isEnhancedIngestionMode() { + // Use the iceberg property from config to determine catalog type + // Generate only for the specified catalog type, with both partitioned variants + combinations = []struct { + Iceberg bool + Partitioned bool + }{ + {base.Iceberg, false}, + {base.Iceberg, true}, + } + } else { + // Legacy mode: generate all 4 combinations + combinations = []struct { + Iceberg bool + Partitioned bool + }{ + {true, false}, + {true, true}, + {false, false}, + {false, true}, + } } for _, c := range combinations { From f5f6bb3fcbb11405da7a07ffc648005521db1f08 Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Wed, 1 Apr 2026 20:56:58 +0530 Subject: [PATCH 15/20] Create config_enhanced_ingestion.json.example --- .../config_enhanced_ingestion.json.example | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cmd/genddl/config_enhanced_ingestion.json.example diff --git a/cmd/genddl/config_enhanced_ingestion.json.example b/cmd/genddl/config_enhanced_ingestion.json.example new file mode 100644 index 00000000..0818ccab --- /dev/null +++ b/cmd/genddl/config_enhanced_ingestion.json.example @@ -0,0 +1,18 @@ +{ + "mode": "enhanced_ingestion", + "scale_factor": "1000", + "file_format": "parquet", + "compression_method": "uncompressed", + "workload": "tpcds", + "workload_definition": "tpc-ds", + "iceberg": true, + "source_file_format": "CSV", + "source_catalog": "source_catalog_name", + "target_catalog": "target_catalog_name", + "source_schema": "source_schema_name", + "target_schema": "target_schema_name", + "s3_source_location": "s3a://bucket-name/path/to/source/data", + "s3_target_location": "s3a://bucket-name/path/to/target/data", + "engine": "presto", + "session_variables": {} +} \ No newline at end of file From 502ddee00a841c5a06c7768962cba04f39aff97c Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Wed, 1 Apr 2026 22:27:49 +0530 Subject: [PATCH 16/20] target table sql syntax fix --- cmd/genddl/create_target_table.sql.tmpl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmd/genddl/create_target_table.sql.tmpl b/cmd/genddl/create_target_table.sql.tmpl index be7d9939..6c93d219 100644 --- a/cmd/genddl/create_target_table.sql.tmpl +++ b/cmd/genddl/create_target_table.sql.tmpl @@ -53,12 +53,7 @@ WITH ( , partitioning = array['{{ .LastColumn.Name }}'] {{- else if .Partitioned }} , partitioned_by = array['{{ .LastColumn.Name }}'] - , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' - {{- else }} - , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' {{- end }} - {{- else }} - , external_location = '{{ $.S3TargetLocation }}/{{ .Name }}/' {{- end }} ); {{- end }} From 8123238391cc8147a2b4475520b1e583341eae5f Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Mon, 6 Apr 2026 12:13:55 +0530 Subject: [PATCH 17/20] Generate specific sql files as per config provided. --- cmd/genddl/main.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/genddl/main.go b/cmd/genddl/main.go index 97f92ae9..a96b0156 100644 --- a/cmd/genddl/main.go +++ b/cmd/genddl/main.go @@ -404,14 +404,12 @@ func loadSchemas(data []byte) ([]*Schema, error) { } if base.isEnhancedIngestionMode() { - // Use the iceberg property from config to determine catalog type - // Generate only for the specified catalog type, with both partitioned variants + // Enhanced ingestion mode: generate only for the exact configuration specified combinations = []struct { Iceberg bool Partitioned bool }{ - {base.Iceberg, false}, - {base.Iceberg, true}, + {base.Iceberg, base.Partitioned}, } } else { // Legacy mode: generate all 4 combinations From eaab87907c9a561b50dc3a9932539ac305438fa3 Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Fri, 10 Apr 2026 16:30:25 +0530 Subject: [PATCH 18/20] Partitioned tables creation --- cmd/genddl/create_target_table.sql.tmpl | 4 ++-- cmd/genddl/main.go | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/genddl/create_target_table.sql.tmpl b/cmd/genddl/create_target_table.sql.tmpl index 6c93d219..22e781e7 100644 --- a/cmd/genddl/create_target_table.sql.tmpl +++ b/cmd/genddl/create_target_table.sql.tmpl @@ -48,10 +48,10 @@ LOCATION '{{ $.S3TargetLocation }}/{{ .Name }}'; {{- else }} WITH ( format = 'PARQUET' - {{- if $.Partitioned }} + {{- if and $.Partitioned .Partitioned }} {{- if $.Iceberg}} , partitioning = array['{{ .LastColumn.Name }}'] - {{- else if .Partitioned }} + {{- else }} , partitioned_by = array['{{ .LastColumn.Name }}'] {{- end }} {{- end }} diff --git a/cmd/genddl/main.go b/cmd/genddl/main.go index a96b0156..c3f0436c 100644 --- a/cmd/genddl/main.go +++ b/cmd/genddl/main.go @@ -504,6 +504,13 @@ func (t *Table) setLastColumn(s *Schema) { } func (s *Schema) setSessionVars() { + // In enhanced ingestion mode, only use session variables from config + // Don't auto-add compression codec - let users control it via config + if s.isEnhancedIngestionMode() { + return + } + + // Legacy mode: auto-add default session variables s.SessionVariables["query_max_execution_time"] = "12h" s.SessionVariables["query_max_run_time"] = "12h" if s.Iceberg && s.CompressionMethod == "uncompressed" { From 99ea6cbba25e6a66385c0bb5f1e7fac5cd243b52 Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Fri, 17 Apr 2026 01:55:34 +0530 Subject: [PATCH 19/20] Column header name fix --- cmd/genddl/definition/tpc-ds/promotion.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/genddl/definition/tpc-ds/promotion.json b/cmd/genddl/definition/tpc-ds/promotion.json index eeeb333c..56f153e1 100644 --- a/cmd/genddl/definition/tpc-ds/promotion.json +++ b/cmd/genddl/definition/tpc-ds/promotion.json @@ -26,7 +26,7 @@ "type": "DECIMAL(15,2)" }, { - "name": "p_response_targe", + "name": "p_response_target", "type": "INT" }, { From 2f4a5cb420bf269502e4026317028635fb340fcc Mon Sep 17 00:00:00 2001 From: Ron Daniel Date: Tue, 21 Apr 2026 13:57:20 +0530 Subject: [PATCH 20/20] Overwrite minscale factor for partitioned tables with config parameter --- cmd/genddl/main.go | 28 +++++++++++++++++++++++++--- cmd/genddl/main_test.go | 31 ++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/cmd/genddl/main.go b/cmd/genddl/main.go index c3f0436c..6333a99e 100644 --- a/cmd/genddl/main.go +++ b/cmd/genddl/main.go @@ -146,8 +146,8 @@ func generateSchemaFromDef(schema *Schema, defDir string, configDir string, outp log.Fatal().Err(umErr).Str("file", entry.Name()).Msg("Failed to unmarshal file to type Table") } tbl.initIsVarchar() // Populates the IsVarchar var for all columns - // Set partitioned if above scale factor min - if tbl.isPartitioned(schema.intScaleFactor()) { + // Set partitioned if above scale factor min or if schema.Partitioned is true + if tbl.isPartitioned(schema.intScaleFactor(), schema.Partitioned, schema.Mode) { tbl.Partitioned = true } @@ -558,10 +558,32 @@ func toHyphen(s string) string { return strings.Replace(s, "_", "-", 1) } -func (t *Table) isPartitioned(sf int) bool { +func (t *Table) isPartitioned(sf int, schemaPartitioned bool, mode string) bool { + // If table has partition keys defined, check partitioning logic + hasPartitionKeys := false + for _, col := range t.Columns { + if col.PartitionKey != nil && *col.PartitionKey { + hasPartitionKeys = true + break + } + } + + // If no partition keys defined, table cannot be partitioned + if !hasPartitionKeys { + return false + } + + // If schema.Partitioned is explicitly true AND mode is enhanced_ingestion, override min scale check + if schemaPartitioned && mode == "enhanced_ingestion" { + return true + } + + // If PartitionedMinScale is set, check scale factor threshold if t.PartitionedMinScale > 0 { return sf >= t.PartitionedMinScale } + + // Otherwise, use the Partitioned field from table definition return t.Partitioned } diff --git a/cmd/genddl/main_test.go b/cmd/genddl/main_test.go index ca87b733..ea77e491 100644 --- a/cmd/genddl/main_test.go +++ b/cmd/genddl/main_test.go @@ -173,18 +173,31 @@ func TestCleanOutputDirNonExistent(t *testing.T) { } func TestIsPartitioned(t *testing.T) { + // Create a partition key column for testing + partitionKeyTrue := true + partitionCol := &Column{Name: "date_sk", PartitionKey: &partitionKeyTrue} + // Table with explicit PartitionedMinScale. - tbl := &Table{PartitionedMinScale: 100} - assert.False(t, tbl.isPartitioned(10)) - assert.True(t, tbl.isPartitioned(100)) - assert.True(t, tbl.isPartitioned(1000)) + tbl := &Table{PartitionedMinScale: 100, Columns: []*Column{partitionCol}} + assert.False(t, tbl.isPartitioned(10, false, "legacy")) + assert.True(t, tbl.isPartitioned(100, false, "legacy")) + assert.True(t, tbl.isPartitioned(1000, false, "legacy")) // Table without PartitionedMinScale uses Partitioned field. - tbl2 := &Table{Partitioned: true} - assert.True(t, tbl2.isPartitioned(1)) - - tbl3 := &Table{Partitioned: false} - assert.False(t, tbl3.isPartitioned(1)) + tbl2 := &Table{Partitioned: true, Columns: []*Column{partitionCol}} + assert.True(t, tbl2.isPartitioned(1, false, "legacy")) + + tbl3 := &Table{Partitioned: false, Columns: []*Column{partitionCol}} + assert.False(t, tbl3.isPartitioned(1, false, "legacy")) + + // Test enhanced_ingestion mode with schema.Partitioned = true overrides min scale + tbl4 := &Table{PartitionedMinScale: 10000, Columns: []*Column{partitionCol}} + assert.False(t, tbl4.isPartitioned(1000, false, "enhanced_ingestion")) + assert.True(t, tbl4.isPartitioned(1000, true, "enhanced_ingestion")) + + // Test legacy mode does NOT override min scale even with schema.Partitioned = true + tbl5 := &Table{PartitionedMinScale: 10000, Columns: []*Column{partitionCol}} + assert.False(t, tbl5.isPartitioned(1000, true, "legacy")) } func TestInitIsVarchar(t *testing.T) {