text
stringlengths
84
1.49k
benchmark
stringclasses
4 values
SELECT COUNT(*) FROM comments AS c, posts AS p, users AS u WHERE c.CreationDate >= '2010-08-05 00:36:02'::timestamp AND p.FavoriteCount >= 0 AND p.ViewCount >= 0 AND c.UserId = u.Id AND p.CommentCount >= 0 AND u.Id = p.OwnerUserId
stats
select count(*) from postHistory as ph, posts as p, votes as v, badges as b, users as u, comments as c where u.Id = p.OwnerUserId AND p.Score <= 192 AND u.Id = b.UserId AND p.Id = ph.PostId AND p.Id = v.PostId AND p.Id = c.PostId AND p.ViewCount >= 0
stats
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_receiptdate >= DATE 1 AND l_receiptdate < DATE 1 + INTERVAL '1' YEAR AND o_orderkey = l_orderkey AND l_commitdate < l_receiptdate AND l_shipdate < l_commitdate AND l_shipmode IN (1, 1) GROUP BY l_shipmode ORDER BY l_shipmode LIMIT 500;
tpch
SELECT i_brand AS brand, i_manufact, i_manufact_id, SUM(ss_ext_sales_price) AS ext_price, i_brand_id AS brand_id FROM date_dim JOIN store_sales ON d_date_sk = ss_sold_date_sk JOIN item ON ss_item_sk = i_item_sk JOIN customer ON ss_customer_sk = c_customer_sk JOIN customer_address ON c_current_addr_sk = ca_address_sk JOIN store ON ss_store_sk = s_store_sk WHERE d_moy = 12 AND substr(ca_zip, 1, 5) <> substr(s_zip, 1, 5) AND i_manager_id = 3 AND d_year = 1999 GROUP BY i_brand, i_brand_id, i_manufact_id, i_manufact ORDER BY ext_price DESC, brand, brand_id, i_manufact_id, i_manufact LIMIT 100;
tpcds
SELECT MAX(cs_net_profit) AS catalog_sales_profit, s_store_name, s_store_id, i_item_id, MAX(sr_net_loss) AS store_returns_loss, MAX(ss_net_profit) AS store_sales_profit, i_item_desc FROM store_sales JOIN store_returns ON store_sales.ss_customer_sk = store_returns.sr_customer_sk AND store_sales.ss_item_sk = store_returns.sr_item_sk AND store_sales.ss_ticket_number = store_returns.sr_ticket_number JOIN catalog_sales ON store_returns.sr_customer_sk = catalog_sales.cs_bill_customer_sk AND store_returns.sr_item_sk = catalog_sales.cs_item_sk JOIN date_dim AS d1 ON store_sales.ss_sold_date_sk = d1.d_date_sk JOIN date_dim AS d2 ON store_returns.sr_returned_date_sk = d2.d_date_sk JOIN date_dim AS d3 ON catalog_sales.cs_sold_date_sk = d3.d_date_sk JOIN store ON store_sales.ss_store_sk = store.s_store_sk JOIN item ON store_sales.ss_item_sk = item.i_item_sk WHERE d1.d_year = 2002 AND d1.d_moy BETWEEN 5 AND 5 AND d3.d_year = 2002 AND d2.d_moy BETWEEN 5 AND 5 + 3 AND d2.d_year = 2002 AND d3.d_moy BETWEEN 5 AND 5 + 3 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;
tpcds
select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where l1.l_receiptdate > l1.l_commitdate and n_name = 1 and o_orderkey = l1.l_orderkey and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and o_orderstatus = 'F' and s_nationkey = n_nationkey and s_suppkey = l1.l_suppkey and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) group by s_name order by numwait desc, s_name limit 100
tpch
SELECT o_shippriority, SUM(l_extendedprice * (1 - l_discount)) AS revenue, o_orderdate, l_orderkey FROM customer, orders, lineitem WHERE l_orderkey = o_orderkey AND l_shipdate > DATE 1 AND o_orderdate < DATE 1 AND c_mktsegment = 1 AND c_custkey = o_custkey GROUP BY l_orderkey, o_orderdate, o_shippriority ORDER BY revenue DESC, o_orderdate LIMIT 10
tpch
select min(t.title) as movie_title from keyword as k, movie_info as mi, movie_keyword as mk, title as t where t.production_year > 2010 AND t.id = mi.movie_id AND k.id = mk.keyword_id AND mi.info in ('Sweden', 'Norway', 'Germany', 'Danish', 'Swedish', 'Danish', 'Norwegian', 'German') AND k.keyword like '%sequel%' AND mk.movie_id = mi.movie_id AND t.id = mk.movie_id
job
SELECT MIN(n.name) AS actor_name, MIN(t.title) AS marvel_movie, MIN(k.keyword) AS movie_keyword 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.id = mk.movie_id AND t.id = ci.movie_id AND k.id = mk.keyword_id AND k.keyword = 'marvel-cinematic-universe' AND n.name LIKE '%Hemsworth%Chris%' AND t.production_year > 2010
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 kt.id = t.kind_id AND at.movie_id = mc.movie_id AND t.id = mc.movie_id AND mi_idx.info < '3.5' AND it2.info = 'release dates' AND mi.info LIKE 'USA:%200%' AND t.id = at.movie_id AND t.production_year > 2000 AND cn.country_code = '[us]' AND it1.id = mi_idx.info_type_id AND mi.movie_id = mc.movie_id AND at.movie_id = mi.movie_id AND cn.id = mc.company_id AND mi_idx.movie_id = mc.movie_id AND it2.id = mi.info_type_id AND it1.info = 'rating' AND mi.movie_id = mi_idx.movie_id AND at.title LIKE '%Champion%' AND at.movie_id = mi_idx.movie_id AND t.id = mi.movie_id AND kt.kind = 'movie' AND t.id = mi_idx.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 ct.kind = 'production companies' AND ct.id = mc.company_type_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND t.id = mi_idx.movie_id AND t.id = mc.movie_id AND it.id = mi_idx.info_type_id AND it.info = 'top 250 rank' AND mc.movie_id = mi_idx.movie_id
job
SELECT cust_nation, SUM(volume) AS revenue, supp_nation, l_year 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 s_nationkey = n1.n_nationkey AND c_custkey = o_custkey AND ( (n1.n_name = 1 AND n2.n_name = 1) OR (n1.n_name = 1 AND n2.n_name = 1) ) AND o_orderkey = l_orderkey AND l_shipdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31' ) AS shipping AND s_suppkey = l_suppkey AND c_nationkey = n2.n_nationkey GROUP BY supp_nation, cust_nation, l_year ORDER BY supp_nation, cust_nation, l_year
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.country_code ='[sm]' AND k.keyword ='character-name-in-title' AND mc.movie_id = mk.movie_id AND mk.keyword_id = k.id AND cn.id = mc.company_id AND t.id = mk.movie_id AND mc.movie_id = t.id
job
SELECT SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, SUM(l_quantity) AS sum_qty, COUNT(*) AS count_order, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, AVG(l_extendedprice) AS avg_price, AVG(l_quantity) AS avg_qty, l_linestatus, l_returnflag, SUM(l_extendedprice) AS sum_base_price, AVG(l_discount) AS avg_disc FROM lineitem WHERE l_shipdate <= DATE '1998-12-01' - INTERVAL 1 DAY GROUP BY l_returnflag, l_linestatus ORDER BY l_returnflag, l_linestatus
tpch
SELECT MAX(t.title) AS movie_title FROM keyword AS k, movie_info AS mi, movie_keyword AS mk, title AS t WHERE mk.movie_id = mi.movie_id AND k.keyword LIKE '%sequel%' AND t.id = mi.movie_id AND k.id = mk.keyword_id AND t.id = mk.movie_id AND t.production_year > 2010 AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Danish', 'Swedish', 'Danish', 'Norwegian', 'German')
job
WITH year_total AS ( SELECT c_last_name AS customer_last_name, c_customer_id AS customer_id, c_login AS customer_login, 's' AS sale_type, c_birth_country AS customer_birth_country, c_email_address AS customer_email_address, 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_preferred_cust_flag AS customer_preferred_cust_flag, d_year AS dyear FROM customer JOIN store_sales ON c_customer_sk = ss_customer_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk WHERE d_year BETWEEN 2002 AND 2002 + 1 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 AS t_s_firstyear JOIN year_total AS t_s_secyear ON t_s_firstyear.customer_id = t_s_secyear.customer_id WHERE t_s_firstyear.sale_type = 's' AND t_s_secyear.sale_type = 's' AND t_s_firstyear.dyear = 2002 AND t_s_secyear.dyear = 2002 + 1 AND t_s_firstyear.year_total > 0 AND CASE WHEN t_s_firstyear.year_total > 0 THEN t_s_secyear.year_total / t_s_firstyear.year_total ELSE NULL END > 1.0 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;
tpcds
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 (n.gender = 'm' OR (n.gender = 'f' AND n.name LIKE 'B%')) AND it.id = pi.info_type_id AND lt.id = ml.link_type_id AND pi.person_id = an.person_id AND t.production_year BETWEEN 1980 AND 1995 AND ci.person_id = n.id AND an.name LIKE '%a%' AND n.id = pi.person_id AND ml.linked_movie_id = t.id AND t.id = ci.movie_id AND pi.person_id = ci.person_id AND pi.note = 'Volker Boehm' AND n.name_pcode_cf BETWEEN 'A' AND 'F' AND n.id = an.person_id AND it.info = 'mini biography' AND lt.link = 'features' AND ci.movie_id = ml.linked_movie_id
job
WITH _q AS ( 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 s_suppkey = l_suppkey AND ps_suppkey = l_suppkey AND ps_partkey = l_partkey AND p_partkey = l_partkey AND o_orderkey = l_orderkey AND s_nationkey = n_nationkey AND p_name LIKE 1 ) AS profit GROUP BY nation, o_year ORDER BY nation, o_year DESC LIMIT 1000 ) SELECT * FROM _q;
tpch
SELECT COUNT(*) FROM postHistory AS ph, posts AS p, users AS u, badges AS b WHERE u.Reputation >= 1 AND p.OwnerUserId = u.Id AND p.Score >= -7 AND ph.PostHistoryTypeId = 3 AND u.Id = b.UserId AND ph.UserId = u.Id
stats
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 t.id = mi.movie_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND ct.id = mc.company_type_id AND ct.kind = 'production companies' AND mc.movie_id = mi.movie_id AND it.info = 'bottom 10 rank' AND t.id = mc.movie_id AND it.id = mi.info_type_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%')
job
SELECT s_name, p_partkey, s_phone, s_address, n_name, s_comment, p_mfgr, s_acctbal FROM part, supplier, partsupp, nation, region WHERE p_partkey = ps_partkey AND p_size = 1 AND s_suppkey = ps_suppkey AND ps_supplycost = ( SELECT MIN(ps_supplycost) FROM partsupp, supplier, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 ) AND r_name = 1 AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND p_type LIKE 1 ORDER BY s_acctbal DESC, n_name, s_name, p_partkey LIMIT 100
tpch
Select s_name, COUNT(1) As numwait From supplier, lineitem l1, orders, nation Where Exists ( Select * From lineitem l2 Where l2.l_orderkey = l1.l_orderkey And l2.l_suppkey <> l1.l_suppkey ) And s_nationkey = n_nationkey And Not Exists ( Select * From lineitem l3 Where l3.l_orderkey = l1.l_orderkey And l3.l_suppkey <> l1.l_suppkey And l3.l_receiptdate > l3.l_commitdate ) And o_orderkey = l1.l_orderkey And s_suppkey = l1.l_suppkey And o_orderstatus = 'F' And l1.l_receiptdate > l1.l_commitdate And n_name = 1 Group By s_name Order By numwait Desc, s_name Limit 100
tpch
select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where l_shipdate > DATE 1 and c_mktsegment = 1 and l_orderkey = o_orderkey and o_orderdate < DATE 1 and c_custkey = o_custkey group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10
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 ct.id = mc.company_type_id And ml.movie_id = mc.movie_id And it.id = mi.info_type_id And t.id = ml.movie_id And mi.info Like 'USA:% 199%' And mc.note Like '%(USA)%' And lt.id = ml.link_type_id And lt.link Like '%follow%' And t.id = mc.movie_id And t.id = mk.movie_id And mc.note Not Like '%(As Metro-Goldwyn-Mayer Pictures)%' And k.keyword = ANY(ARRAY['sequel', 'revenge', 'based-On-novel']) And k.id = mk.keyword_id And mi.movie_id = t.id And mk.movie_id = mc.movie_id And it.info = 'release dates' And cn.country_code = '[us]' And mi.note Like '%internet%' And ml.movie_id = mk.movie_id And t.production_year > 1950 And cn.id = mc.company_id And ml.movie_id = mi.movie_id
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 t.id = mk.movie_id AND mc.note LIKE '%(USA)%' AND cn.country_code = '[us]' AND k.id = mk.keyword_id AND k.keyword IN ('sequel', 'revenge', 'based-on-novel') AND ml.movie_id = mk.movie_id AND mi.movie_id = t.id AND lt.link LIKE '%follow%' AND mi.info LIKE 'USA:% 199%' AND t.id = ml.movie_id AND ml.movie_id = mc.movie_id AND ml.movie_id = mi.movie_id AND mi.note LIKE '%internet%' AND it.id = mi.info_type_id AND mk.movie_id = mc.movie_id AND t.id = mc.movie_id AND lt.id = ml.link_type_id AND it.info = 'release dates' AND cn.id = mc.company_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND t.production_year > 1950 AND ct.id = mc.company_type_id
job
SELECT c_phone, c_name, c_acctbal, c_address, c_comment, SUM(l_extendedprice * (1 - l_discount)) AS revenue, n_name, c_custkey FROM customer, orders, lineitem, nation WHERE c_custkey = o_custkey AND l_orderkey = o_orderkey AND o_orderdate >= DATE 1 AND o_orderdate < DATE 1 + INTERVAL '3' MONTH AND l_returnflag = 'R' AND c_nationkey = n_nationkey GROUP BY c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment ORDER BY revenue DESC LIMIT 20
tpch
with _q as ( select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 1 and 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_type not like 1 group by p_brand, p_type, p_size order by supplier_cnt asc, p_brand, p_type, p_size ) select * from _q;
tpch
SELECT MAX(cn.name) AS from_company, MAX(lt.link) AS link_type, MAX(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 ml.movie_id = mk.movie_id AND lt.id = ml.link_type_id AND mk.movie_id = mc.movie_id AND mi.movie_id = t.id AND it.id = mi.info_type_id AND t.id = mk.movie_id AND ct.id = mc.company_type_id AND t.id = ml.movie_id AND ml.movie_id = mi.movie_id AND t.production_year > 1950 AND mi.info LIKE 'USA:% 199%' AND cn.country_code = '[us]' AND mi.note LIKE '%internet%' AND it.info = 'release dates' AND cn.id = mc.company_id AND mc.note LIKE '%(USA)%' AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND k.keyword IN ('sequel', 'revenge', 'based-on-novel') AND t.id = mc.movie_id AND ml.movie_id = mc.movie_id AND k.id = mk.keyword_id
job
SELECT s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment FROM part, supplier, partsupp, nation, region WHERE s_suppkey = ps_suppkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 AND p_partkey = ps_partkey AND ps_supplycost = ( SELECT MIN(ps_supplycost) FROM partsupp, supplier, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 ) AND p_type LIKE 1 AND p_size = 1 ORDER BY s_acctbal DESC, n_name, s_name, p_partkey LIMIT 100
tpch
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_commitdate < l_receiptdate AND l_shipdate < l_commitdate AND l_receiptdate >= DATE 1 AND l_shipmode IN (1, 1) AND l_receiptdate < DATE 1 + INTERVAL '1' YEAR AND o_orderkey = l_orderkey GROUP BY l_shipmode ORDER BY l_shipmode LIMIT 20;
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 t.id = mi.movie_id AND at.title LIKE '%Champion%' AND mi.movie_id = mc.movie_id AND mi.info LIKE 'USA:%200%' AND it2.id = mi.info_type_id AND at.movie_id = mc.movie_id AND mi_idx.info < '3.5' AND it1.id = mi_idx.info_type_id AND t.production_year > 2000 AND t.id = at.movie_id AND at.movie_id = mi.movie_id AND kt.id = t.kind_id AND t.id = mc.movie_id AND t.id = mi_idx.movie_id AND mi_idx.movie_id = mc.movie_id AND mi.movie_id = mi_idx.movie_id AND cn.id = mc.company_id AND it1.info = 'rating' AND kt.kind = 'movie' AND it2.info = 'release dates' AND cn.country_code = '[us]' AND at.movie_id = mi_idx.movie_id
job
SELECT MIN(mi_idx.info) AS rating, MIN(t.title) AS movie_title FROM info_type AS it, movie_info_idx AS mi_idx, title AS t WHERE it.id = mi_idx.info_type_id AND t.production_year >= 2000 AND t.id = mi_idx.movie_id AND t.production_year <= 2010 AND mi_idx.info > '7.0' AND it.info ='rating' LIMIT 200;
job
SELECT c_phone, c_address, n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_custkey, c_comment, c_acctbal, c_name FROM customer, orders, lineitem, nation WHERE c_custkey = o_custkey AND l_orderkey = o_orderkey AND o_orderdate >= DATE 1 AND o_orderdate < DATE 1 + INTERVAL '3' MONTH AND l_returnflag = 'R' AND c_nationkey = n_nationkey GROUP BY c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment ORDER BY revenue DESC LIMIT 20
tpch
WITH _q AS ( 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 t.id = mc.movie_id AND n1.id = ci.person_id AND n1.name LIKE '%Yo%' AND mc.note NOT LIKE '%(USA)%' AND ci.movie_id = mc.movie_id AND mc.note LIKE '%(Japan)%' AND mc.company_id = cn.id AND ci.movie_id = t.id AND an1.person_id = n1.id AND n1.name NOT LIKE '%Yu%' AND ci.note = '(voice: English version)' AND cn.country_code = '[jp]' AND an1.person_id = ci.person_id AND ci.role_id = rt.id AND rt.role = 'actress' ) SELECT * FROM _q;
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 s_suppkey = l_suppkey AND o_orderkey = l_orderkey AND ( (n1.n_name = 1 AND n2.n_name = 1) OR (n1.n_name = 1 AND n2.n_name = 1) ) AND l_shipdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31' ) AS shipping AND c_custkey = o_custkey AND c_nationkey = n2.n_nationkey AND s_nationkey = n1.n_nationkey GROUP BY supp_nation, cust_nation, l_year ORDER BY supp_nation, cust_nation, l_year
tpch
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_commitdate < l_receiptdate AND l_shipmode IN (1, 1) AND l_receiptdate >= DATE 1 AND o_orderkey = l_orderkey AND l_shipdate < l_commitdate AND l_receiptdate < DATE 1 + INTERVAL '1' YEAR GROUP BY l_shipmode ORDER BY l_shipmode LIMIT 20;
tpch
SELECT AVG(ss_sales_price) AS agg4, AVG(ss_coupon_amt) AS agg3, AVG(ss_quantity) AS agg1, i_item_id, AVG(ss_list_price) AS agg2 FROM store_sales JOIN customer_demographics ON ss_cdemo_sk = cd_demo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN item ON ss_item_sk = i_item_sk JOIN promotion ON ss_promo_sk = p_promo_sk WHERE cd_marital_status = 'D' AND d_year = 2002 AND cd_education_status = '4 yr Degree' AND cd_gender = 'M' AND (p_channel_email = 'N' OR p_channel_event = 'N') GROUP BY i_item_id ORDER BY i_item_id LIMIT 100;
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.note LIKE '%(uncredited)%' AND cn.id = mc.company_id AND ci.note LIKE '%(voice)%' AND chn.id = ci.person_role_id AND t.production_year > 2005 AND t.id = ci.movie_id AND t.id = mc.movie_id AND ci.movie_id = mc.movie_id AND cn.country_code = '[ru]' AND rt.id = ci.role_id AND rt.role = 'actor'
job
With _q As ( Select Count(*) From comments As c, votes As v, badges As b, users As u Where c.Score = 1 AND u.Id = v.UserId AND u.CreationDate >= '2010-07-20 01:27:29'::timestamp ) Select * From _q AND u.Id = c.UserId AND u.Id = b.UserId
stats
SELECT s_comment, p_partkey, n_name, s_acctbal, s_name, p_mfgr, s_address, s_phone FROM part, supplier, partsupp, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND r_name = 1 AND p_size = 1 AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND ps_supplycost = ( SELECT MIN(ps_supplycost) FROM partsupp, supplier, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 ) AND p_type LIKE 1 ORDER BY s_acctbal DESC, n_name, s_name, p_partkey LIMIT 100
tpch
SELECT AVG(cs_list_price) AS agg2, AVG(cs_coupon_amt) AS agg3, i_item_id, AVG(cs_quantity) AS agg1, AVG(cs_sales_price) AS agg4 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 = p_promo_sk WHERE d_year = 2000 AND (p_channel_email = 'N' OR p_channel_event = 'N') AND cd_gender = 'M' AND cd_education_status = 'Advanced Degree' AND cd_marital_status = 'W' GROUP BY i_item_id ORDER BY i_item_id LIMIT 100;
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 an.person_id = n.id And ci.movie_id = mc.movie_id And t.id = mc.movie_id And ci.movie_id = mk.movie_id And t.episode_nr < 100 And t.episode_nr >= 50 And mc.company_id = cn.id And an.person_id = ci.person_id And mk.keyword_id = k.id And mc.movie_id = mk.movie_id And cn.country_code = '[us]' And ci.movie_id = t.id And k.keyword = 'character-name-In-title' And t.id = mk.movie_id And n.id = ci.person_id
job
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 n.id = an.person_id AND pi.note = 'Volker Boehm' AND it.id = pi.info_type_id AND an.person_id = ci.person_id AND an.name LIKE '%a%' AND pi.person_id = ci.person_id AND ci.person_id = n.id AND pi.person_id = an.person_id AND ml.linked_movie_id = t.id AND n.name_pcode_cf BETWEEN 'A' AND 'F' AND n.id = pi.person_id AND lt.id = ml.link_type_id AND lt.link = 'features' AND t.id = ci.movie_id AND t.production_year BETWEEN 1980 AND 1995 AND ci.movie_id = ml.linked_movie_id AND (n.gender = 'm' OR (n.gender = 'f' AND n.name LIKE 'B%'))
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 ct.kind = 'production companies' AND t.id = mi.movie_id AND it.info = 'bottom 10 rank' AND it.id = mi.info_type_id AND mc.movie_id = mi.movie_id AND ct.id = mc.company_type_id AND t.id = mc.movie_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' LIMIT 50;
job
select count(*) from comments as c, posts as p, postHistory as ph, votes as v, users as u where u.Id = c.UserId AND p.AnswerCount >= 0 AND ph.UserId = v.UserId AND p.OwnerUserId = ph.UserId AND c.UserId = p.OwnerUserId AND p.Score <= 13
stats
SELECT extended_price, extended_tax, ca_city, bought_city, c_last_name, ss_ticket_number, 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 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 JOIN customer_address ON ss_addr_sk = ca_address_sk WHERE d_year IN (2001, 2000, 2001) AND s_city IN ('Clinton', 'Glendale') AND d_dow IN (6, 0) AND (hd_dep_count = 4 OR hd_vehicle_count = 4) GROUP BY ss_ticket_number, ss_customer_sk, ss_addr_sk, ca_city ) AS dn JOIN customer ON ss_customer_sk = c_customer_sk JOIN customer_address ON c_current_addr_sk = customer_address.ca_address_sk WHERE ca_city != bought_city ORDER BY c_last_name, ss_ticket_number LIMIT 100;
tpcds
select sum(l_extendedprice * l_discount) as revenue from lineitem where l_discount BETWEEN 1 - 0.01 AND 1 + 0.01 AND l_shipdate >= DATE 1 AND l_shipdate < DATE 1 + INTERVAL '1' YEAR AND l_quantity < 1
tpch
SELECT COUNT(*) FROM postHistory AS ph, posts AS p, users AS u, badges AS b WHERE p.OwnerUserId = u.Id AND u.Id = b.UserId AND ph.UserId = u.Id AND ph.PostHistoryTypeId = 3 AND p.Score >= -7 AND u.Reputation >= 1 LIMIT 10;
stats
SELECT MAX(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 mk.movie_id = mi.movie_id AND k.id = mk.keyword_id AND t.id = mi.movie_id AND t.production_year > 2000 AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German') AND t.id = mk.movie_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 r_name = 1 AND l_orderkey = o_orderkey AND s_nationkey = n2.n_nationkey AND p_type = 1 ) AS all_nations AND o_orderdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31' AND p_partkey = l_partkey AND o_custkey = c_custkey AND s_suppkey = l_suppkey AND c_nationkey = n1.n_nationkey AND n1.n_regionkey = r_regionkey GROUP BY o_year ORDER BY o_year
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 t.id = mk.movie_id AND k.keyword = 'marvel-cinematic-universe' AND n.name LIKE '%Hemsworth%Chris%' AND ci.movie_id = mk.movie_id AND k.id = mk.keyword_id AND t.id = ci.movie_id AND n.id = ci.person_id AND t.production_year > 2010
job
SELECT s_name, total_revenue, s_phone, s_suppkey, s_address FROM supplier, revenue0 WHERE s_suppkey = supplier_no AND total_revenue = ( SELECT MAX(total_revenue) FROM revenue0 ) ORDER BY s_suppkey LIMIT 500;
tpch
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 t.id = mc.movie_id AND t.id = mi.movie_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND it.info = 'bottom 10 rank' AND it.id = mi.info_type_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.movie_id = mi.movie_id AND ct.kind = 'production companies' AND ct.id = mc.company_type_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 k.id = mk.keyword_id AND t.production_year > 2005 AND t.id = mk.movie_id AND mk.movie_id = mi.movie_id AND t.id = mi.movie_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', 'Norwegian', 'German') AND k.keyword LIKE '%sequel%' LIMIT 20;
job
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, postHistory AS ph, votes AS v WHERE p.FavoriteCount >= 0 AND p.Id = c.PostId AND c.Score = 0 AND p.Id = v.PostId AND p.Id = pl.PostId AND p.Id = ph.PostId AND pl.LinkTypeId = 1
stats
select count(*) from comments as c, posts as p, postLinks as pl, postHistory as ph, votes as v, badges as b, users as u where c.UserId = u.Id and p.Id = v.PostId and b.UserId = u.Id and p.Id = c.PostId and p.Id = pl.RelatedPostId and p.Score <= 40 and pl.LinkTypeId = 1 and p.Id = ph.PostId
stats
SELECT AVG(ss_quantity), SUM(ss_ext_wholesale_cost), AVG(ss_ext_sales_price), AVG(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_sk JOIN date_dim ON d_date_sk = ss_sold_date_sk WHERE s_market_id = 10 AND d_year = 2002 AND ( (cd_marital_status = 'M' AND cd_education_status = 'College' AND ss_sales_price >= 78 AND ss_sales_price <= 126) OR (cd_marital_status = 'D' AND cd_education_status = 'Primary' AND ss_sales_price BETWEEN 69 AND 117) OR (cd_marital_status = 'D' AND cd_education_status = 'College' AND ss_sales_price BETWEEN 147 AND 164) ) AND ( (hd_dep_count = 3 AND hd_vehicle_count <= 3) OR (hd_dep_count = 2 AND hd_vehicle_count <= 2) OR (hd_dep_count = 4 AND hd_vehicle_count <= 5) ) AND ca_country = 'United States' AND ca_state IN ('OH', 'GA', 'NY');
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 t.id = mi.movie_id AND mk.movie_id = mi.movie_id AND t.production_year > 2010 AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Danish', 'Swedish', 'Danish', 'Norwegian', 'German') AND k.id = mk.keyword_id LIMIT 1000;
job
Select Min(t.title) As movie_title From keyword As k, movie_info As mi, movie_keyword As mk, title As t Where t.production_year > 2005 And mi.info In ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', 'Norwegian', 'German') And t.id = mk.movie_id And k.keyword Like '%sequel%' And k.id = mk.keyword_id And mk.movie_id = mi.movie_id And t.id = mi.movie_id
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 INNER JOIN date_dim ON ss_sold_date_sk = d_date_sk INNER JOIN store ON ss_store_sk = s_store_sk INNER JOIN household_demographics ON ss_hdemo_sk = hd_demo_sk WHERE (hd_buy_potential = '1001-5000' OR hd_buy_potential = '5001-10000') AND d_year IN (1999, 2000, 2003) AND d_dom BETWEEN 1 AND 2 AND hd_vehicle_count > 0 AND s_county IN ('Williamson County', 'Bronx County', 'Jackson County', 'Maricopa County') GROUP BY ss_ticket_number, ss_customer_sk ) AS dj INNER JOIN customer ON ss_customer_sk = c_customer_sk WHERE cnt BETWEEN 1 AND 5 ORDER BY cnt DESC LIMIT 1000;
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 l_orderkey = o_orderkey AND o_custkey = c_custkey AND c_nationkey = n1.n_nationkey AND p_type = 1 ) AS all_nations AND s_suppkey = l_suppkey AND r_name = 1 AND s_nationkey = n2.n_nationkey AND p_partkey = l_partkey AND o_orderdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31' AND n1.n_regionkey = r_regionkey GROUP BY o_year ORDER BY o_year
tpch
SELECT MIN(mi.info) AS release_date, MIN(miidx.info) AS rating, MIN(t.title) AS german_movie FROM company_name AS cn, company_type AS ct, info_type AS it, info_type AS it2, kind_type AS kt, movie_companies AS mc, movie_info AS mi, movie_info_idx AS miidx, title AS t WHERE mi.movie_id = mc.movie_id AND ct.kind = 'production companies' AND it2.id = mi.info_type_id AND it.id = miidx.info_type_id AND kt.id = t.kind_id AND it2.info = 'release dates' AND mi.movie_id = t.id AND miidx.movie_id = t.id AND it.info = 'rating' AND miidx.movie_id = mc.movie_id AND ct.id = mc.company_type_id AND mi.movie_id = miidx.movie_id AND cn.id = mc.company_id AND mc.movie_id = t.id AND kt.kind = 'movie' AND cn.country_code = '[de]'
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 mc.note LIKE '%(USA)%' AND t.production_year > 2000 AND t.id = mc.movie_id AND it.id = mi.info_type_id AND ci.movie_id = mc.movie_id AND ci.note IN ('(voice)', '(voice: Japanese version)', '(voice) (uncredited)', '(voice: English version)') AND chn.id = ci.person_role_id AND an.person_id = n.id AND mi.movie_id = ci.movie_id AND ci.person_id = an.person_id AND mi.movie_id = mc.movie_id AND n.gender = 'f' AND n.id = ci.person_id AND t.id = ci.movie_id AND cn.id = mc.company_id AND rt.role = 'actress' AND t.id = mi.movie_id AND it.info = 'release dates' AND ci.role_id = rt.id AND cn.country_code = '[us]'
job
Select Count(1) From comments As c, posts As p, postHistory As ph, votes As v, users As u Where p.Score <= 13 AND p.AnswerCount >= 0 AND ph.UserId = v.UserId AND u.Id = c.UserId AND c.UserId = p.OwnerUserId AND p.OwnerUserId = ph.UserId
stats
SELECT c_phone, c_name, c_custkey, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_address, c_comment, n_name, c_acctbal FROM customer, orders, lineitem, nation WHERE o_orderdate >= DATE 1 AND c_nationkey = n_nationkey AND o_orderdate < DATE 1 + INTERVAL '3' MONTH AND l_returnflag = 'R' AND l_orderkey = o_orderkey AND c_custkey = o_custkey GROUP BY c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment ORDER BY revenue DESC LIMIT 20
tpch
SELECT cc_manager AS manager, cc_call_center_id AS call_center, SUM(cr_net_loss) AS returns_loss, cc_name AS call_center_name 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 customer_address ON c_current_addr_sk = ca_address_sk JOIN customer_demographics ON cr_returning_cdemo_sk = cd_demo_sk JOIN household_demographics ON cr_returning_hdemo_sk = hd_demo_sk WHERE d_moy = 11 AND ca_gmt_offset = -5 AND d_year = 2001 AND ( (cd_marital_status = 'S' AND cd_education_status = '4 yr Degree') OR (hd_buy_potential LIKE '501-1000%' AND ca_gmt_offset = -5) ) GROUP BY cc_call_center_id, cc_name, cc_manager, cd_marital_status, cd_education_status ORDER BY returns_loss DESC;
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_suppkey = l_suppkey AND p_name LIKE 1 ) AS profit AND ps_partkey = l_partkey AND o_orderkey = l_orderkey AND s_suppkey = l_suppkey AND p_partkey = l_partkey AND s_nationkey = n_nationkey GROUP BY nation, o_year ORDER BY nation, o_year DESC
tpch
SELECT i_current_price, i_item_id, 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_manufact_id IN (195, 412, 338, 267) AND d_date BETWEEN CAST('2000-05-01' AS DATE) AND (CAST('2000-05-01' AS DATE) + INTERVAL '60 days') AND i_current_price BETWEEN 100 AND 100 + 30 AND inv_quantity_on_hand BETWEEN 100 AND 500 GROUP BY i_item_id, i_item_desc, i_current_price ORDER BY i_item_id;
tpcds
SELECT MIN(an.name) AS acress_pseudonym, MIN(t.title) AS japanese_anime_movie 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 t.id = mk.movie_id AND rt.role = 'actress' AND an.person_id = n.id AND t.id = ci.movie_id AND ci.movie_id = mc.movie_id AND ci.role_id = rt.id AND k.keyword = 'anime' AND n.id = ci.person_id AND t.id = mc.movie_id AND cn.country_code = '[jp]' AND t.production_year > 1990 AND cn.id = mc.company_id AND n.gender = 'f' AND ci.person_id = an.person_id AND mk.movie_id = ci.movie_id AND ci.note LIKE '%(voice: English version)%' AND ct.id = mc.company_type_id AND mc.note LIKE '%(Japan)%' AND mc.note NOT LIKE '%(USA)%' AND k.id = mk.keyword_id AND mk.movie_id = mc.movie_id
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 = t.id AND t.id = mk.movie_id AND mk.keyword_id = k.id AND cn.country_code ='[sm]' AND k.keyword ='character-name-IN-title' AND mc.movie_id = mk.movie_id AND cn.id = mc.company_id
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 t.id = mk.movie_id AND mk.keyword_id = k.id AND k.keyword ='character-name-in-title' AND mc.movie_id = t.id AND cn.id = mc.company_id AND mc.movie_id = mk.movie_id AND cn.country_code ='[sm]' LIMIT 200;
job
SELECT l_returnflag, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, SUM(l_extendedprice) AS sum_base_price, SUM(l_quantity) AS sum_qty, AVG(l_extendedprice) AS avg_price, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, COUNT(*) AS count_order, l_linestatus, AVG(l_discount) AS avg_disc, AVG(l_quantity) AS avg_qty FROM lineitem WHERE l_shipdate <= DATE '1998-12-01' - INTERVAL 1 DAY GROUP BY l_returnflag, l_linestatus ORDER BY l_returnflag, l_linestatus
tpch
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 mc.note LIKE '%(Japan)%' AND n1.name LIKE '%Yo%' AND cn.country_code = '[jp]' AND t.id = mc.movie_id AND ci.movie_id = mc.movie_id AND ci.movie_id = t.id AND an1.person_id = ci.person_id AND mc.note NOT LIKE '%(USA)%' AND an1.person_id = n1.id AND n1.id = ci.person_id AND ci.role_id = rt.id AND ci.note = '(voice: English version)' AND mc.company_id = cn.id AND rt.role = 'actress' AND n1.name NOT LIKE '%Yu%'
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 o_orderkey = l_orderkey AND ps_suppkey = l_suppkey AND s_suppkey = l_suppkey AND s_nationkey = n_nationkey AND p_partkey = l_partkey GROUP BY nation, o_year ORDER BY nation, o_year DESC
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 t.production_year > 2010 AND k.id = mk.keyword_id AND ci.movie_id = mk.movie_id AND n.id = ci.person_id AND n.name LIKE '%Downey%Robert%' AND t.id = ci.movie_id AND t.id = mk.movie_id AND k.keyword = 'marvel-cinematic-universe'
job
SELECT COUNT(1) FROM comments AS c, posts AS p, postLinks AS pl, postHistory AS ph, votes AS v WHERE p.Id = ph.PostId AND p.Id = pl.PostId AND p.FavoriteCount >= 0 AND p.Id = v.PostId AND c.Score = 0 AND p.Id = c.PostId AND pl.LinkTypeId = 1
stats
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.country_code ='[sm]' and mk.keyword_id = k.id and k.keyword ='character-name-in-title' and cn.id = mc.company_id and t.id = mk.movie_id and mc.movie_id = t.id and mc.movie_id = mk.movie_id
job
Select Count(*) From comments As c, posts As p, postHistory As ph, votes As v, users As u Where p.OwnerUserId = ph.UserId And p.Score <= 13 And u.Id = c.UserId And p.AnswerCount >= 0 And ph.UserId = v.UserId And c.UserId = p.OwnerUserId
stats
Select n_name, p_mfgr, s_phone, s_acctbal, s_name, p_partkey, s_address, 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 = ( Select Min(ps_supplycost) From partsupp, supplier, nation, region Where p_partkey = ps_partkey And s_suppkey = ps_suppkey And s_nationkey = n_nationkey And n_regionkey = r_regionkey And r_name = 1 ) Order By s_acctbal Desc, n_name, s_name, p_partkey Limit 100
tpch
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE r_name = 1 AND n_regionkey = r_regionkey AND s_nationkey = n_nationkey AND c_nationkey = s_nationkey AND l_orderkey = o_orderkey AND o_orderdate >= DATE 1 AND l_suppkey = s_suppkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_custkey = o_custkey GROUP BY n_name ORDER BY revenue DESC
tpch
SELECT AVG(ss_sales_price) AS agg4, AVG(ss_coupon_amt) AS agg3, AVG(ss_quantity) AS agg1, AVG(ss_list_price) AS agg2, i_item_id FROM store_sales JOIN customer_demographics ON ss_cdemo_sk = cd_demo_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN item ON ss_item_sk = i_item_sk JOIN promotion ON ss_promo_sk = p_promo_sk WHERE cd_gender = 'M' AND d_year = 2001 AND cd_education_status = 'Primary' AND cd_marital_status = 'D' AND (p_channel_email = 'N' OR p_channel_event = 'N') GROUP BY i_item_id ORDER BY i_item_id LIMIT 100;
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 t.production_year > 2005 AND mk.movie_id = mi.movie_id AND t.id = mi.movie_id AND k.keyword LIKE '%sequel%' AND t.id = mk.movie_id AND mi.info = ANY(ARRAY['Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', 'Norwegian', 'German'])
job
SELECT MAX(mc.note) AS production_note, MAX(t.title) AS movie_title, MAX(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 t.id = mi_idx.movie_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND it.info = 'top 250 rank' AND t.id = mc.movie_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.movie_id = mi_idx.movie_id AND ct.kind = 'production companies' AND ct.id = mc.company_type_id AND it.id = mi_idx.info_type_id LIMIT 500;
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_partkey = l_partkey AND s_nationkey = n_nationkey AND ps_partkey = l_partkey AND s_suppkey = l_suppkey AND o_orderkey = l_orderkey AND ps_suppkey = l_suppkey AND p_name LIKE 1 ) AS profit GROUP BY nation, o_year ORDER BY nation, o_year DESC
tpch
SELECT SUM(sr_return_quantity) AS store_returns_quantity, SUM(cs_quantity) AS catalog_sales_quantity, s_store_id, i_item_id, i_item_desc, s_store_name, SUM(ss_quantity) AS store_sales_quantity FROM store_sales JOIN store_returns ON ss_customer_sk = sr_customer_sk AND ss_item_sk = sr_item_sk AND ss_ticket_number = sr_ticket_number JOIN catalog_sales ON sr_customer_sk = cs_bill_customer_sk AND sr_item_sk = cs_item_sk JOIN date_dim AS d1 ON ss_sold_date_sk = d1.d_date_sk JOIN date_dim AS d2 ON sr_returned_date_sk = d2.d_date_sk JOIN date_dim AS d3 ON cs_sold_date_sk = d3.d_date_sk JOIN store ON ss_store_sk = s_store_sk JOIN item ON ss_item_sk = i_item_sk WHERE d1.d_moy = 2 AND d1.d_year = 2001 AND d2.d_moy BETWEEN 2 AND 2 + 3 AND d2.d_year = 2001 AND d3.d_moy BETWEEN 2 AND 2 + 3 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;
tpcds
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 k.keyword ='character-name-IN-title' AND mc.movie_id = t.id AND mk.keyword_id = k.id AND cn.country_code ='[sm]' AND t.id = mk.movie_id AND cn.id = mc.company_id AND mc.movie_id = mk.movie_id
job
Select Count(*) From comments As c, posts As p, postLinks As pl, postHistory As ph, votes As v, badges As b Where pl.LinkTypeId = 1 And p.Id = v.PostId And b.UserId = c.UserId And p.Id = ph.PostId And c.Score = 0 And p.Id = pl.RelatedPostId And p.Id = c.PostId
stats
SELECT p_size, p_brand, p_type, COUNT(DISTINCT ps_suppkey) AS supplier_cnt FROM partsupp, part WHERE p_partkey = ps_partkey AND p_brand <> 1 AND p_type NOT LIKE 1 AND 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%' ) GROUP BY p_brand, p_type, p_size ORDER BY supplier_cnt ASC, p_brand, p_type, p_size
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.country_code ='[sm]' AND k.keyword ='character-name-in-title' AND t.id = mk.movie_id AND mc.movie_id = mk.movie_id AND mc.movie_id = t.id AND cn.id = mc.company_id AND mk.keyword_id = k.id
job
WITH year_total AS ( SELECT c_customer_id AS customer_id, c_login AS customer_login, 's' AS sale_type, c_email_address AS customer_email_address, SUM(((ss_ext_list_price - ss_ext_wholesale_cost - ss_ext_discount_amt) + ss_ext_sales_price) / 2) AS year_total, c_last_name AS customer_last_name, c_first_name AS customer_first_name, d_year AS dyear, c_preferred_cust_flag AS customer_preferred_cust_flag, c_birth_country AS customer_birth_country FROM customer JOIN store_sales ON c_customer_sk = ss_customer_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk WHERE d_year BETWEEN 2002 AND 2002 + 1 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 AS t_s_firstyear JOIN year_total AS t_s_secyear ON t_s_firstyear.customer_id = t_s_secyear.customer_id WHERE t_s_firstyear.sale_type = 's' AND t_s_secyear.sale_type = 's' AND t_s_firstyear.dyear = 2002 AND t_s_secyear.dyear = 2002 + 1 AND t_s_firstyear.year_total > 0 AND CASE WHEN t_s_firstyear.year_total > 0 THEN t_s_secyear.year_total / t_s_firstyear.year_total ELSE NULL END > 1.0 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;
tpcds
SELECT promotions, CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100, total 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_customer_sk = c_customer_sk JOIN customer_address ON c_current_addr_sk = ca_address_sk JOIN item ON ss_item_sk = i_item_sk WHERE d_moy = 8 ) AS promotional_sales, ( SELECT SUM(ss_ext_sales_price) AS total FROM store_sales JOIN store ON ss_store_sk = s_store_sk JOIN date_dim ON ss_sold_date_sk = d_date_sk JOIN customer ON ss_customer_sk = c_customer_sk JOIN customer_address ON c_current_addr_sk = ca_address_sk JOIN item ON ss_item_sk = i_item_sk WHERE ca_gmt_offset = -7 AND i_category = 'Music' AND d_moy = 8 ) AS all_sales AND s_gmt_offset = -7 AND i_category = 'Music' AND d_year = 1998 AND d_year = 1998 AND s_gmt_offset = -7 AND ca_gmt_offset = -7 AND (p_channel_dmail = 'Y' OR p_channel_email = 'Y' OR p_channel_tv = 'Y') ORDER BY promotions, total LIMIT 100;
tpcds
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 k.keyword = 'marvel-cinematic-universe' And ci.movie_id = mk.movie_id And n.id = ci.person_id And t.id = mk.movie_id And t.production_year > 2010 And k.id = mk.keyword_id And t.id = ci.movie_id And n.name Like '%Hemsworth%Chris%'
job
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 an1.person_id = ci.person_id AND cn.country_code = '[jp]' AND an1.person_id = n1.id AND mc.note LIKE '%(Japan)%' AND mc.note NOT LIKE '%(USA)%' AND mc.company_id = cn.id AND t.id = mc.movie_id AND ci.note = '(voice: English version)' AND ci.role_id = rt.id AND n1.name LIKE '%Yo%' AND ci.movie_id = mc.movie_id AND n1.name NOT LIKE '%Yu%' AND rt.role = 'actress' AND ci.movie_id = t.id AND n1.id = ci.person_id
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 l_returnflag = 'R' and o_orderdate < DATE 1 + INTERVAL '3' MONTH and c_nationkey = n_nationkey and o_orderdate >= DATE 1 and c_custkey = o_custkey and l_orderkey = o_orderkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc limit 20
tpch
SELECT n_name, s_comment, s_name, s_phone, s_address, p_partkey, p_mfgr, s_acctbal FROM part, supplier, partsupp, nation, region WHERE s_nationkey = n_nationkey AND s_suppkey = ps_suppkey AND ps_supplycost = ( SELECT MIN(ps_supplycost) FROM partsupp, supplier, nation, region WHERE p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 1 ) AND p_type LIKE 1 AND n_regionkey = r_regionkey AND p_partkey = ps_partkey AND r_name = 1 AND p_size = 1 ORDER BY s_acctbal DESC, n_name, s_name, p_partkey LIMIT 100
tpch
Select Sum(ps_supplycost * ps_availqty) As VALUE, ps_partkey From partsupp, supplier, nation Where s_nationkey = n_nationkey And ps_suppkey = s_suppkey And n_name = 1 Group By ps_partkey Having Sum(ps_supplycost * ps_availqty) > ( Select Sum(ps_supplycost * ps_availqty) * 1 From partsupp, supplier, nation Where ps_suppkey = s_suppkey And s_nationkey = n_nationkey And n_name = 1 ) Order By VALUE Desc
tpch
select cntrycode, count(1) as numcust, sum(c_acctbal) as totacctbal from ( select SUBSTRING(c_phone from 1 FOR 2) as cntrycode, c_acctbal from customer where SUBSTRING(c_phone from 1 FOR 2) in (1, 1, 1, 1, 1, 1, 1) and not exists ( select * from orders where o_custkey = c_custkey ) ) as custsale and c_acctbal > ( select avg(c_acctbal) from customer where c_acctbal > 0.00 and SUBSTRING(c_phone from 1 FOR 2) in (1, 1, 1, 1, 1, 1, 1) ) group by cntrycode order by cntrycode
tpch
SELECT nation, SUM(amount) AS sum_profit, o_year 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_suppkey = l_suppkey AND s_suppkey = l_suppkey AND p_name LIKE 1 ) AS profit AND p_partkey = l_partkey AND o_orderkey = l_orderkey AND ps_partkey = l_partkey AND s_nationkey = n_nationkey GROUP BY nation, o_year ORDER BY nation, o_year DESC
tpch
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.id = mk.movie_id AND mk.movie_id = mi.movie_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', 'Norwegian', 'German') AND t.id = mi.movie_id AND k.id = mk.keyword_id AND t.production_year > 2005
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 ct.id = mc.company_type_id AND cn.id = mc.company_id AND rt.role = 'actor' AND t.id = ci.movie_id AND t.id = mc.movie_id AND ci.note LIKE '%(voice)%' AND chn.id = ci.person_role_id AND ci.movie_id = mc.movie_id AND rt.id = ci.role_id AND ci.note LIKE '%(uncredited)%' AND cn.country_code = '[ru]' AND t.production_year > 2005
job