text
stringlengths
84
1.49k
benchmark
stringclasses
4 values
SELECT i_item_id, i_item_desc, i_current_price FROM item JOIN inventory ON i_item_sk = inv_item_sk JOIN date_dim ON d_date_sk = inv_date_sk JOIN catalog_sales ON cs_item_sk = i_item_sk WHERE i_manufact_id IN (211, 362, 413, 88) AND i_current_price <= 77 + 30 AND d_date BETWEEN CAST('2001-07-13' AS DATE) AND (CAST('2001...
tpcds
SELECT MIN(n.name) AS voicing_actress, MIN(t.title) AS voiced_movie FROM aka_name AS an, char_name AS chn, cast_info AS ci, company_name AS cn, info_type AS it, movie_companies AS mc, movie_info AS mi, name AS n, role_type AS rt, title AS t WHERE ci.person_id = an.person_id AND t.id = mc.movie_id AND t.id = ci.movie_id...
job
SELECT MIN(mc.note) AS production_note, MIN(t.title) AS movie_title, MIN(t.production_year) AS movie_year FROM company_type AS ct, info_type AS it, movie_companies AS mc, movie_info_idx AS mi_idx, title AS t WHERE mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND mc.movie_id = mi_idx.movie_id AND it.info = 'to...
job
SELECT c_custkey, c_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_acctbal, n_name, c_address, c_phone, c_comment FROM customer, orders, lineitem, nation WHERE o_orderdate < DATE 1 + INTERVAL '3' MONTH AND c_nationkey = n_nationkey AND l_orderkey = o_orderkey AND o_orderdate >= DATE 1 AND c_custkey = o_cus...
tpch
Select Count(1) From badges As b, users As u, posts As p Where u.Id = b.UserId And u.Id = p.OwnerUserId And u.Reputation >= 1 And p.PostTypeId = 1 LIMIT 20;
stats
select extended_price, extended_tax, ca_city, bought_city, ss_ticket_number, c_last_name, list_price, c_first_name from ( select ss_ticket_number, ss_customer_sk, ca_city as bought_city, sum(ss_ext_sales_price) as extended_price, sum(ss_ext_list_price) as list_price, sum(ss_ext_tax) as extended_tax from store_sales joi...
tpcds
Select s_name, Count(1) As numwait From supplier, lineitem l1, orders, nation Where o_orderstatus = 'F' AND s_nationkey = n_nationkey AND Exists ( Select * From lineitem l2 Where l2.l_orderkey = l1.l_orderkey And l2.l_suppkey <> l1.l_suppkey ) AND Not Exists ( Select * From lineitem l3 Where l3.l_orderkey = l1.l_orderk...
tpch
SELECT s_name, p_partkey, s_acctbal, n_name, p_mfgr, s_phone, s_comment, s_address FROM part, supplier, partsupp, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND p_size = 1 AND p_type LIKE 1 AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 AND ps_supplycost = ( SELEC...
tpch
SELECT i_brand_id AS brand_id, i_brand AS brand, i_manufact_id, i_manufact, SUM(ss_ext_sales_price) AS ext_price FROM date_dim INNER JOIN store_sales ON d_date_sk = ss_sold_date_sk INNER JOIN item ON ss_item_sk = i_item_sk INNER JOIN customer ON ss_customer_sk = c_customer_sk INNER JOIN customer_address ON c_current_ad...
tpcds
select c_name, sum(l_quantity), o_orderkey, c_custkey, o_totalprice, o_orderdate from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 1 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdat...
tpch
SELECT MIN(cn.name) AS from_company, MIN(lt.link) AS link_type, MIN(t.title) AS western_sequel FROM company_name AS cn, company_type AS ct, info_type AS it, keyword AS k, link_type AS lt, movie_companies AS mc, movie_info AS mi, movie_keyword AS mk, movie_link AS ml, title AS t WHERE lt.link LIKE '%follow%' AND t.id = ...
job
SELECT o_year, SUM( CASE WHEN nation = 1 THEN volume ELSE 0 END ) / SUM(volume) AS mkt_share FROM ( SELECT EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) AS volume, n2.n_name AS nation FROM part, supplier, lineitem, orders, customer, nation n1, nation n2, region WHERE s_nationkey = n2.n_na...
tpch
WITH _q AS ( SELECT MIN(n.name) AS voicing_actress, MIN(t.title) AS voiced_movie FROM aka_name AS an, char_name AS chn, cast_info AS ci, company_name AS cn, info_type AS it, movie_companies AS mc, movie_info AS mi, name AS n, role_type AS rt, title AS t WHERE n.id = ci.person_id AND rt.role = 'actress' AND it.info = 'r...
job
SELECT o_year, SUM( CASE WHEN nation = 1 THEN volume ELSE 0 END ) / SUM(volume) AS mkt_share FROM ( SELECT EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) AS volume, n2.n_name AS nation FROM part, supplier, lineitem, orders, customer, nation n1, nation n2, region WHERE p_type = 1 ) AS all_n...
tpch
SELECT MIN(k.keyword) AS movie_keyword, MIN(n.name) AS actor_name, MIN(t.title) AS marvel_movie FROM cast_info AS ci, keyword AS k, movie_keyword AS mk, name AS n, title AS t WHERE n.id = ci.person_id AND ci.movie_id = mk.movie_id AND t.production_year > 2010 AND t.id = mk.movie_id AND t.id = ci.movie_id AND k.keyword ...
job
SELECT supp_nation, cust_nation, l_year, SUM(volume) AS revenue FROM ( SELECT n1.n_name AS supp_nation, n2.n_name AS cust_nation, EXTRACT(YEAR FROM l_shipdate) AS l_year, l_extendedprice * (1 - l_discount) AS volume FROM supplier, lineitem, orders, customer, nation n1, nation n2 WHERE c_nationkey = n2.n_nationkey AND l...
tpch
SELECT MIN(mi_idx.info) AS rating, MIN(t.title) AS northamerican_movie FROM aka_title AS at, company_name AS cn, info_type AS it1, info_type AS it2, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, title AS t WHERE mi_idx.info < '3.5' AND t.id = mi_idx.movie_id AND t.production_year >...
job
SELECT AVG(ss_quantity), AVG(ss_ext_wholesale_cost), AVG(ss_ext_sales_price), SUM(ss_ext_wholesale_cost) FROM store_sales JOIN store ON s_store_sk = ss_store_sk JOIN customer_demographics ON cd_demo_sk = ss_cdemo_sk JOIN household_demographics ON hd_demo_sk = ss_hdemo_sk JOIN customer_address ON ca_address_sk = ss_addr...
tpcds
SELECT AVG(cs_quantity) AS agg1, i_item_id, AVG(cs_list_price) AS agg2, AVG(cs_sales_price) AS agg4, AVG(cs_coupon_amt) AS agg3 FROM catalog_sales JOIN customer_demographics ON cs_bill_cdemo_sk = cd_demo_sk JOIN date_dim ON cs_sold_date_sk = d_date_sk JOIN item ON cs_item_sk = i_item_sk JOIN promotion ON cs_promo_sk = ...
tpcds
Select cc_call_center_id As call_center, cc_name As call_center_name, cc_manager As manager, Sum(cr_net_loss) As returns_loss From call_center Join catalog_returns On cr_call_center_sk = cc_call_center_sk Join date_dim On cr_returned_date_sk = d_date_sk Join customer On cr_returning_customer_sk = c_customer_sk Join cus...
tpcds
SELECT MIN(cn.name) AS movie_company, MIN(t.title) AS western_violent_movie, MIN(mi_idx.info) AS rating FROM company_name AS cn, company_type AS ct, info_type AS it1, info_type AS it2, keyword AS k, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, movie_keyword AS mk, title AS t WHERE...
job
SELECT MIN(k.keyword) AS movie_keyword, MIN(n.name) AS actor_name, MIN(t.title) AS marvel_movie FROM cast_info AS ci, keyword AS k, movie_keyword AS mk, name AS n, title AS t WHERE n.id = ci.person_id AND ci.movie_id = mk.movie_id AND t.production_year > 2010 AND k.keyword = 'marvel-cinematic-universe' AND k.id = mk.ke...
job
SELECT CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100, total, promotions FROM ( SELECT SUM(ss_ext_sales_price) AS promotions FROM store_sales JOIN store ON ss_store_sk = s_store_sk JOIN promotion ON ss_promo_sk = p_promo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN customer ON ss_custo...
tpcds
SELECT MIN(cn.name) AS movie_company, MIN(mi_idx.info) AS rating, MIN(t.title) AS western_violent_movie FROM company_name AS cn, company_type AS ct, info_type AS it1, info_type AS it2, keyword AS k, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, movie_keyword AS mk, title AS t WHERE...
job
SELECT MIN(t.title) AS american_movie FROM company_type AS ct, info_type AS it, movie_companies AS mc, movie_info AS mi, title AS t WHERE mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND mc.movie_id = mi.movie_id AND it.info = 'bottom 10 rank' AND t.id = mc.movie_id AND (mc.note LIKE '%(co-production)%' OR mc...
job
SELECT MIN(chn.name) AS uncredited_voiced_character, MIN(t.title) AS russian_movie FROM char_name AS chn, cast_info AS ci, company_name AS cn, company_type AS ct, movie_companies AS mc, role_type AS rt, title AS t WHERE t.id = ci.movie_id AND ci.note LIKE '%(uncredited)%' AND chn.id = ci.person_role_id AND ci.movie_id ...
job
WITH year_total AS ( SELECT c_birth_country AS customer_birth_country, c_login AS customer_login, d_year AS dyear, c_last_name AS customer_last_name, 's' AS sale_type, c_first_name AS customer_first_name, SUM(((ss_ext_list_price - ss_ext_wholesale_cost - ss_ext_discount_amt) + ss_ext_sales_price) / 2) AS year_total, c_...
tpcds
SELECT MIN(an1.name) AS actress_pseudonym, MIN(t.title) AS japanese_movie_dubbed FROM aka_name AS an1, cast_info AS ci, company_name AS cn, movie_companies AS mc, name AS n1, role_type AS rt, title AS t WHERE n1.id = ci.person_id AND n1.name NOT LIKE '%Yu%' AND cn.country_code = '[jp]' AND an1.person_id = ci.person_id ...
job
SELECT MIN(t.title) AS movie_title FROM keyword AS k, movie_info AS mi, movie_keyword AS mk, title AS t WHERE mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German') AND t.id = mk.movie_id AND t.production_year > 2000 AND mk.movie_id = mi.movie_id AND t.id = mi.movie_id AND k.k...
job
With _q As ( Select i_item_id, i_current_price, i_item_desc From item Join inventory On i_item_sk = inv_item_sk Join date_dim On d_date_sk = inv_date_sk Join catalog_sales On cs_item_sk = i_item_sk Where i_current_price Between 95 And 95 + 30 And d_date Between CAST('2002-01-23' As DATE) And (CAST('2002-01-23' As DATE)...
tpcds
SELECT MIN(cn.name) AS from_company, MIN(lt.link) AS link_type, MIN(t.title) AS western_sequel FROM company_name AS cn, company_type AS ct, info_type AS it, keyword AS k, link_type AS lt, movie_companies AS mc, movie_info AS mi, movie_keyword AS mk, movie_link AS ml, title AS t WHERE mc.note NOT LIKE '%(as Metro-Goldwy...
job
SELECT promotions, total, CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100 FROM ( SELECT SUM(ss_ext_sales_price) AS promotions FROM store_sales JOIN store ON ss_store_sk = s_store_sk JOIN promotion ON ss_promo_sk = p_promo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN customer ON ss_custo...
tpcds
SELECT MIN(t.title) AS northamerican_movie, MIN(mi_idx.info) AS rating FROM aka_title AS at, company_name AS cn, info_type AS it1, info_type AS it2, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, title AS t WHERE cn.country_code = '[us]' AND t.id = mi.movie_id AND it1.id = mi_idx.in...
job
SELECT MIN(t.title) AS biography_movie, MIN(n.name) AS of_person FROM aka_name AS an, cast_info AS ci, info_type AS it, link_type AS lt, movie_link AS ml, name AS n, person_info AS pi, title AS t WHERE ci.movie_id = ml.linked_movie_id AND t.production_year BETWEEN 1980 AND 1995 AND lt.id = ml.link_type_id AND ml.linked...
job
SELECT COUNT(*) FROM badges AS b, posts AS p WHERE b.UserId = p.OwnerUserId AND p.AnswerCount <= 4 AND b.Date <= '2014-09-11 08:55:52'::timestamp AND p.AnswerCount >= 0 LIMIT 500;
stats
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, postHistory AS ph, votes AS v, users AS u WHERE p.PostTypeId = 1 AND p.Id = c.PostId AND u.Id = p.OwnerUserId AND p.Id = ph.PostId AND p.Id = v.PostId AND p.AnswerCount >= 0 AND p.Id = pl.PostId
stats
SELECT supp_nation, cust_nation, l_year, SUM(volume) AS revenue FROM ( SELECT n1.n_name AS supp_nation, n2.n_name AS cust_nation, EXTRACT(YEAR FROM l_shipdate) AS l_year, l_extendedprice * (1 - l_discount) AS volume FROM supplier, lineitem, orders, customer, nation n1, nation n2 WHERE ( (n1.n_name = 1 AND n2.n_name = 1...
tpch
WITH year_total AS ( SELECT d_year AS dyear, c_last_name AS customer_last_name, c_birth_country AS customer_birth_country, SUM(((ss_ext_list_price - ss_ext_wholesale_cost - ss_ext_discount_amt) + ss_ext_sales_price) / 2) AS year_total, c_customer_id AS customer_id, c_preferred_cust_flag AS customer_preferred_cust_flag,...
tpcds
Select p_brand, p_type, p_size, Count(Distinct ps_suppkey) As supplier_cnt From partsupp, part Where p_brand <> 1 And p_type Not Like 1 And ps_suppkey Not In ( Select s_suppkey From supplier Where s_comment Like '%Customer%Complaints%' ) And p_size In (1, 1, 1, 1, 1, 1, 1, 1) And p_partkey = ps_partkey Group By p_brand...
tpch
SELECT MIN(n.name) AS of_person, MIN(t.title) AS biography_movie FROM aka_name AS an, cast_info AS ci, info_type AS it, link_type AS lt, movie_link AS ml, name AS n, person_info AS pi, title AS t WHERE n.id = pi.person_id AND it.id = pi.info_type_id AND pi.person_id = an.person_id AND (n.gender = 'm' OR (n.gender = 'f'...
job
SELECT COUNT(DISTINCT ps_suppkey) AS supplier_cnt, p_type, p_brand, p_size FROM partsupp, part WHERE p_size IN (1, 1, 1, 1, 1, 1, 1, 1) AND ps_suppkey NOT IN ( SELECT s_suppkey FROM supplier WHERE s_comment LIKE '%Customer%Complaints%' ) AND p_partkey = ps_partkey AND p_brand <> 1 AND p_type NOT LIKE 1 GROUP BY p_brand...
tpch
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, postHistory AS ph, votes AS v, users AS u WHERE p.Id = ph.PostId AND u.Id = p.OwnerUserId AND p.Id = v.PostId AND p.AnswerCount >= 0 AND p.PostTypeId = 1 AND p.Id = c.PostId AND p.Id = pl.PostId LIMIT 20;
stats
with _q as ( select dt.d_year, item.i_brand_id as brand_id, item.i_brand as brand, sum(ss_ext_sales_price) as ext_price from date_dim as dt join store_sales on dt.d_date_sk = store_sales.ss_sold_date_sk join item on store_sales.ss_item_sk = item.i_item_sk where item.i_manager_id = 67 and dt.d_moy = 11 and dt.d_year = 1...
tpcds
WITH _q AS ( SELECT MIN(cn.name) AS movie_company, MIN(mi_idx.info) AS rating, MIN(t.title) AS western_violent_movie FROM company_name AS cn, company_type AS ct, info_type AS it1, info_type AS it2, keyword AS k, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, movie_keyword AS mk, tit...
job
select min(t.title) as movie_title from keyword as k, movie_info as mi, movie_keyword as mk, title as t where k.keyword like '%sequel%' AND t.production_year > 2000 AND t.id = mk.movie_id AND t.id = mi.movie_id AND mi.info in ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German') AND k.i...
job
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, votes AS v WHERE c.CreationDate >= '2010-08-02 23:52:10'::timestamp AND v.VoteTypeId = 2 AND p.Score >= -3 AND c.PostId = pl.PostId AND p.Id = c.PostId AND pl.PostId = v.PostId LIMIT 200;
stats
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(*) as cnt from store_sales join date_dim on ss_sold_date_sk = d_date_sk join store on ss_store_sk = s_store_sk join household_demographics on ss_hdemo_sk = hd_demo_sk where ...
tpcds
select count(*) from postHistory as ph, posts as p, votes as v, badges as b, users as u, comments as c where p.Id = ph.PostId and p.Score <= 192 and u.Id = b.UserId and p.ViewCount >= 0 and u.Id = p.OwnerUserId and p.Id = v.PostId and p.Id = c.PostId
stats
SELECT promotions, total, CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100 FROM ( SELECT SUM(ss_ext_sales_price) AS promotions FROM store_sales JOIN store ON ss_store_sk = s_store_sk JOIN promotion ON ss_promo_sk = p_promo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN customer ON ss_custo...
tpcds
select min(t.title) as movie_title from keyword as k, movie_info as mi, movie_keyword as mk, title as t where t.id = mk.movie_id and k.keyword like '%sequel%' and mk.movie_id = mi.movie_id and t.id = mi.movie_id and k.id = mk.keyword_id and t.production_year > 2010 and mi.info in ('Sweden', 'Norway', 'Germany', 'Danish...
job
SELECT MIN(an.name) AS cool_actor_pseudonym, MIN(t.title) AS series_named_after_char FROM aka_name AS an, cast_info AS ci, company_name AS cn, keyword AS k, movie_companies AS mc, movie_keyword AS mk, name AS n, title AS t WHERE t.episode_nr < 100 AND k.keyword = 'character-name-in-title' AND mc.company_id = cn.id AND ...
job
SELECT SUM(CASE WHEN (CAST(d_date AS DATE) < CAST('2000-03-11' 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-11' AS DATE)) THEN cs_sales_price - COALESCE(cr_refunded_cash, 0) ELSE 0 END) AS sales_after, w_state, i_item_id ...
tpcds
SELECT MIN(t.title) AS movie_title FROM keyword AS k, movie_info AS mi, movie_keyword AS mk, title AS t WHERE k.id = mk.keyword_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German') AND t.id = mk.movie_id AND k.keyword LIKE '%sequel%' AND t.id = mi.movie_id AND t.produ...
job
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(*) AS cnt FROM store_sales JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN store ON ss_store_sk = s_store_sk JOIN household_demographics ON ss_hdemo_sk = hd_demo_sk WHERE ...
tpcds
SELECT MIN(an.name) AS cool_actor_pseudonym, MIN(t.title) AS series_named_after_char FROM aka_name AS an, cast_info AS ci, company_name AS cn, keyword AS k, movie_companies AS mc, movie_keyword AS mk, name AS n, title AS t WHERE t.episode_nr < 100 AND n.id = ci.person_id AND t.episode_nr >= 50 AND an.person_id = ci.per...
job
select o_totalprice, o_orderdate, c_name, o_orderkey, c_custkey, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 1 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdat...
tpch
SELECT item.i_brand AS brand, dt.d_year, SUM(ss_ext_sales_price) AS ext_price, item.i_brand_id AS brand_id FROM date_dim AS dt INNER JOIN store_sales ON dt.d_date_sk = store_sales.ss_sold_date_sk INNER JOIN item ON store_sales.ss_item_sk = item.i_item_sk WHERE item.i_manager_id = 69 AND dt.d_moy = 11 AND dt.d_year = 20...
tpcds
with _q as ( select ca_zip, sum(cs_sales_price) from catalog_sales join customer on cs_bill_customer_sk = c_customer_sk join customer_address on c_current_addr_sk = ca_address_sk join date_dim on cs_sold_date_sk = d_date_sk where d_year = 2002 AND d_qoy = 3 AND (SUBSTR(ca_zip, 1, 5) in ( '85669', '86197', '88274', '834...
tpcds
Select l_shipmode, Sum( Case When o_orderpriority = '1-URGENT' Or o_orderpriority = '2-HIGH' Then 1 Else 0 End ) As high_line_count, Sum( Case When o_orderpriority <> '1-URGENT' And o_orderpriority <> '2-HIGH' Then 1 Else 0 End ) As low_line_count From orders, lineitem Where l_shipdate < l_commitdate And o_orderkey = l...
tpch
select count(*) from comments as c, posts as p, postLinks as pl, postHistory as ph, votes as v, users as u where u.Id = p.OwnerUserId and p.PostTypeId = 1 and p.Id = pl.PostId and p.Id = c.PostId and p.AnswerCount >= 0 and p.Id = ph.PostId and p.Id = v.PostId LIMIT 20;
stats
SELECT MIN(n.name) AS of_person, MIN(t.title) AS biography_movie FROM aka_name AS an, cast_info AS ci, info_type AS it, link_type AS lt, movie_link AS ml, name AS n, person_info AS pi, title AS t WHERE it.info = 'mini biography' AND pi.note = 'Volker Boehm' AND an.name LIKE '%a%' AND n.name_pcode_cf BETWEEN 'A' AND 'F'...
job
select w_state, i_item_id, sum(case when (CAST(d_date as DATE) >= CAST('2000-03-11' as DATE)) then cs_sales_price - COALESCE(cr_refunded_cash, 0) else 0 end) as sales_after, sum(case when (CAST(d_date as DATE) < CAST('2000-03-11' as DATE)) then cs_sales_price - COALESCE(cr_refunded_cash, 0) else 0 end) as sales_before ...
tpcds
SELECT MIN(chn.name) AS uncredited_voiced_character, MIN(t.title) AS russian_movie FROM char_name AS chn, cast_info AS ci, company_name AS cn, company_type AS ct, movie_companies AS mc, role_type AS rt, title AS t WHERE ct.id = mc.company_type_id AND ci.movie_id = mc.movie_id AND cn.country_code = '[ru]' AND ci.note LI...
job
Select cntrycode, Count(*) As numcust, Sum(c_acctbal) As totacctbal From ( Select SUBSTRING(c_phone From 1 FOR 2) As cntrycode, c_acctbal From customer Where Not Exists ( Select * From orders Where o_custkey = c_custkey ) ) As custsale And SUBSTRING(c_phone From 1 FOR 2) In (1, 1, 1, 1, 1, 1, 1) And c_acctbal > ( Selec...
tpch
SELECT MIN(mi_idx.info) AS rating, MIN(t.title) AS northamerican_movie FROM aka_title AS at, company_name AS cn, info_type AS it1, info_type AS it2, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, title AS t WHERE it1.info = 'rating' AND cn.country_code = '[us]' AND mi.info LIKE 'USA...
job
SELECT MIN(n.name) AS voicing_actress, MIN(t.title) AS voiced_movie FROM aka_name AS an, char_name AS chn, cast_info AS ci, company_name AS cn, info_type AS it, movie_companies AS mc, movie_info AS mi, name AS n, role_type AS rt, title AS t WHERE cn.id = mc.company_id AND mi.movie_id = ci.movie_id AND t.id = mc.movie_i...
job
SELECT nation, o_year, SUM(amount) AS sum_profit FROM ( SELECT n_name AS nation, EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity AS amount FROM part, supplier, lineitem, partsupp, orders, nation WHERE p_name LIKE 1 ) AS profit AND ps_partkey = l_partkey AND s_na...
tpch
Select MAX(t.title) As movie_title, MAX(t.production_year) As movie_year, MAX(mc.note) As production_note From company_type As ct, info_type As it, movie_companies As mc, movie_info_idx As mi_idx, title As t Where ct.kind = 'production companies' And it.info = 'top 250 rank' And mc.note Not Like '%(As Metro-Goldwyn-May...
job
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(1) As cnt From store_sales Join date_dim On ss_sold_date_sk = d_date_sk Join store On ss_store_sk = s_store_sk Join household_demographics On ss_hdemo_sk = hd_demo_sk Where ...
tpcds
SELECT COUNT(1) FROM postHistory AS ph, posts AS p, votes AS v, badges AS b, users AS u, comments AS c WHERE p.Id = v.PostId AND u.Id = p.OwnerUserId AND p.Id = ph.PostId AND p.Id = c.PostId AND p.Score <= 192 AND p.ViewCount >= 0 AND u.Id = b.UserId
stats
WITH _q AS ( SELECT SUM(l_extendedprice * l_discount) AS revenue FROM lineitem WHERE l_shipdate >= DATE 1 AND l_shipdate < DATE 1 + INTERVAL '1' YEAR AND l_discount BETWEEN 1 - 0.01 AND 1 + 0.01 AND l_quantity < 1 ) SELECT * FROM _q;
tpch
SELECT l_year, cust_nation, supp_nation, SUM(volume) AS revenue FROM ( SELECT n1.n_name AS supp_nation, n2.n_name AS cust_nation, EXTRACT(YEAR FROM l_shipdate) AS l_year, l_extendedprice * (1 - l_discount) AS volume FROM supplier, lineitem, orders, customer, nation n1, nation n2 WHERE c_nationkey = n2.n_nationkey AND o...
tpch
SELECT MIN(n.name) AS voicing_actress, MIN(t.title) AS voiced_movie FROM aka_name AS an, char_name AS chn, cast_info AS ci, company_name AS cn, info_type AS it, movie_companies AS mc, movie_info AS mi, name AS n, role_type AS rt, title AS t WHERE t.id = ci.movie_id AND mi.movie_id = ci.movie_id AND t.id = mi.movie_id A...
job
select max(cs_net_profit) as catalog_sales_profit, max(ss_net_profit) as store_sales_profit, s_store_name, i_item_desc, i_item_id, s_store_id, max(sr_net_loss) as store_returns_loss from store_sales join store_returns on store_sales.ss_customer_sk = store_returns.sr_customer_sk and store_sales.ss_item_sk = store_return...
tpcds
SELECT MIN(chn.name) AS uncredited_voiced_character, MIN(t.title) AS russian_movie FROM char_name AS chn, cast_info AS ci, company_name AS cn, company_type AS ct, movie_companies AS mc, role_type AS rt, title AS t WHERE t.id = mc.movie_id AND rt.id = ci.role_id AND t.production_year > 2005 AND t.id = ci.movie_id AND ci...
job
Select Sum(l_extendedprice * (1 - l_discount)) As revenue, l_orderkey, o_shippriority, o_orderdate From customer, orders, lineitem Where c_mktsegment = 1 AND l_orderkey = o_orderkey AND o_orderdate < DATE 1 AND l_shipdate > DATE 1 AND c_custkey = o_custkey Group By l_orderkey, o_orderdate, o_shippriority Order By reven...
tpch
WITH _q AS ( SELECT i_item_id, i_item_desc, i_current_price FROM item JOIN inventory ON i_item_sk = inv_item_sk JOIN date_dim ON d_date_sk = inv_date_sk JOIN catalog_sales ON cs_item_sk = i_item_sk WHERE d_date BETWEEN CAST('2001-07-13' AS DATE) AND (CAST('2001-07-13' AS DATE) + INTERVAL '60 days') AND i_manufact_id IN...
tpcds
WITH _q AS ( SELECT COUNT(1) FROM votes AS v, posts AS p, users AS u WHERE v.PostId = p.Id AND v.UserId = u.Id AND p.PostTypeId = 1 AND u.Reputation >= 1 ) SELECT * FROM _q;
stats
SELECT MIN(n.name) AS of_person, MIN(t.title) AS biography_movie FROM aka_name AS an, cast_info AS ci, info_type AS it, link_type AS lt, movie_link AS ml, name AS n, person_info AS pi, title AS t WHERE an.person_id = ci.person_id AND ml.linked_movie_id = t.id AND (n.gender = 'm' OR (n.gender = 'f' AND n.name LIKE 'B%')...
job
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, A...
tpcds
SELECT o_year, SUM( CASE WHEN nation = 1 THEN volume ELSE 0 END ) / SUM(volume) AS mkt_share FROM ( SELECT EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) AS volume, n2.n_name AS nation FROM part, supplier, lineitem, orders, customer, nation n1, nation n2, region WHERE r_name = 1 AND l_orde...
tpch
SELECT s_suppkey, s_phone, s_address, total_revenue, s_name FROM supplier, revenue0 WHERE s_suppkey = supplier_no AND total_revenue = ( SELECT MAX(total_revenue) FROM revenue0 ) ORDER BY s_suppkey LIMIT 10;
tpch
SELECT AVG(l_extendedprice) AS avg_price, COUNT(*) AS count_order, AVG(l_discount) AS avg_disc, SUM(l_quantity) AS sum_qty, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, SUM(l_extendedprice) AS sum_base_price, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, AVG(l_quantity) AS avg_qty, ...
tpch
Select Min(k.keyword) As movie_keyword, Min(n.name) As actor_name, Min(t.title) As marvel_movie From cast_info As ci, keyword As k, movie_keyword As mk, name As n, title As t Where n.name Like '%Hemsworth%Chris%' And k.id = mk.keyword_id And n.id = ci.person_id And t.id = mk.movie_id And t.production_year > 2010 And k....
job
select min(t.title) as movie_title from company_name as cn, keyword as k, movie_companies as mc, movie_keyword as mk, title as t where mc.movie_id = mk.movie_id AND cn.country_code ='[sm]' AND cn.id = mc.company_id AND k.keyword ='character-name-in-title' AND t.id = mk.movie_id AND mc.movie_id = t.id AND mk.keyword_id ...
job
Select Sum(ss_ext_sales_price) As sum_agg, item.i_brand As brand, item.i_brand_id As brand_id, dt.d_year From date_dim As dt Join store_sales On dt.d_date_sk = store_sales.ss_sold_date_sk Join item On store_sales.ss_item_sk = item.i_item_sk Where item.i_manufact_id = 703 And dt.d_moy = 11 Group By dt.d_year, item.i_bra...
tpcds
SELECT MIN(t.title) AS series_named_after_char, MIN(an.name) AS cool_actor_pseudonym FROM aka_name AS an, cast_info AS ci, company_name AS cn, keyword AS k, movie_companies AS mc, movie_keyword AS mk, name AS n, title AS t WHERE t.episode_nr < 100 AND ci.movie_id = mk.movie_id AND ci.movie_id = t.id AND n.id = ci.perso...
job
SELECT nation, o_year, SUM(amount) AS sum_profit FROM ( SELECT n_name AS nation, EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity AS amount FROM part, supplier, lineitem, partsupp, orders, nation WHERE p_name LIKE 1 ) AS profit AND s_suppkey = l_suppkey AND p_par...
tpch
SELECT COUNT(*) FROM postHistory AS ph, posts AS p, users AS u, badges AS b WHERE p.Score >= -7 AND ph.UserId = u.Id AND u.Reputation >= 1 AND u.Id = b.UserId AND ph.PostHistoryTypeId = 3 AND p.OwnerUserId = u.Id LIMIT 20;
stats
select min(cn.name) as movie_company, min(mi_idx.info) as rating, min(t.title) as western_violent_movie from company_name as cn, company_type as ct, info_type as it1, info_type as it2, keyword as k, kind_type as kt, movie_companies as mc, movie_info as mi, movie_info_idx as mi_idx, movie_keyword as mk, title as t where...
job
SELECT MIN(mi_idx.info) AS rating, MIN(t.title) AS northamerican_movie FROM aka_title AS at, company_name AS cn, info_type AS it1, info_type AS it2, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS mi_idx, title AS t WHERE t.id = mi.movie_id AND at.movie_id = mi.movie_id AND it2.info = 'relea...
job
SELECT MIN(t.title) AS japanese_anime_movie, MIN(an.name) AS acress_pseudonym FROM aka_name AS an, cast_info AS ci, company_name AS cn, company_type AS ct, keyword AS k, movie_companies AS mc, movie_keyword AS mk, name AS n, role_type AS rt, title AS t WHERE rt.role = 'actress' AND n.gender = 'f' AND k.keyword = 'anime...
job
Select Min(cn.name) As from_company, Min(lt.link) As link_type, Min(t.title) As western_sequel From company_name As cn, company_type As ct, info_type As it, keyword As k, link_type As lt, movie_companies As mc, movie_info As mi, movie_keyword As mk, movie_link As ml, title As t Where mk.movie_id = mc.movie_id AND k.id ...
job
SELECT ss_ticket_number, cnt, c_last_name, c_preferred_cust_flag, c_first_name, c_salutation FROM ( SELECT ss_ticket_number, ss_customer_sk, COUNT(1) AS cnt FROM store_sales JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN store ON ss_store_sk = s_store_sk JOIN household_demographics ON ss_hdemo_sk = hd_demo_sk WHERE ...
tpcds
SELECT nation, o_year, SUM(amount) AS sum_profit FROM ( SELECT n_name AS nation, EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity AS amount FROM part, supplier, lineitem, partsupp, orders, nation WHERE ps_partkey = l_partkey AND ps_suppkey = l_suppkey AND s_natio...
tpch
select supp_nation, cust_nation, l_year, sum(volume) as revenue from ( select n1.n_name as supp_nation, n2.n_name as cust_nation, EXTRACT(YEAR from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where c_custkey = o_custkey and ( (n1.n_...
tpch
SELECT promotions, total, CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100 FROM ( SELECT SUM(ss_ext_sales_price) AS promotions FROM store_sales JOIN store ON ss_store_sk = s_store_sk JOIN promotion ON ss_promo_sk = p_promo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN customer ON ss_custo...
tpcds
Select p_partkey, n_name, s_name, p_mfgr, s_address, s_acctbal, s_phone, s_comment From part, supplier, partsupp, nation, region Where p_partkey = ps_partkey And s_suppkey = ps_suppkey And p_size = 1 And p_type Like 1 And s_nationkey = n_nationkey And n_regionkey = r_regionkey And r_name = 1 And ps_supplycost = ( Selec...
tpch
Select Min(t.title) As movie_title From company_name As cn, keyword As k, movie_companies As mc, movie_keyword As mk, title As t Where cn.id = mc.company_id And t.id = mk.movie_id And mc.movie_id = mk.movie_id And k.keyword ='character-name-In-title' And mk.keyword_id = k.id And mc.movie_id = t.id And cn.country_code =...
job
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE o_orderdate >= DATE 1 AND n_regionkey = r_regionkey AND r_name = 1 AND l_suppkey = s_suppkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_custkey = o_custkey AND c_nationkey = s_nation...
tpch