text stringlengths 84 1.49k | benchmark stringclasses 4
values |
|---|---|
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_partkey = l_partkey AND s_nation... | tpch |
Select Min(t.title) As movie_title, Min(mi_idx.info) As rating From info_type As it, movie_info_idx As mi_idx, title As t Where t.id = mi_idx.movie_id And it.info ='rating' And t.production_year >= 2000 And it.id = mi_idx.info_type_id And t.production_year <= 2010 And mi_idx.info > '7.0' | 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 c_nationkey = n_nationkey AND o_orderdate >= DATE 1 AND l_orderkey = o_orderkey AND o_orderdate < DATE 1 + INTERVAL '3' MONTH AND l_returnflag = 'R... | tpch |
SELECT cnt, c_salutation, c_first_name, c_preferred_cust_flag, c_last_name, ss_ticket_number 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 =... | tpcds |
SELECT i_item_id, AVG(cs_quantity) AS agg1, AVG(cs_coupon_amt) AS agg3, AVG(cs_sales_price) AS agg4, AVG(cs_list_price) AS agg2 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 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.id = mi.movie_id AND k.keyword LIKE '%sequel%' AND t.id = mk.movie_id AND mk.movie_id = mi.movie_id AND t.production_year > 2005 AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmar... | job |
SELECT * FROM ( SELECT AVG(ss_list_price) AS b1_lp, COUNT(ss_list_price) AS b1_cnt, COUNT(DISTINCT ss_list_price) AS b1_cntd FROM store_sales WHERE (ss_list_price BETWEEN 77 AND 77 + 10 OR ss_coupon_amt BETWEEN 1614 AND 1614 + 1000 OR ss_wholesale_cost BETWEEN 88 AND 88 + 20) ) AS b3 AND (ss_list_price BETWEEN 28 AND 2... | tpcds |
SELECT COUNT(*) FROM comments AS c, postHistory AS ph, votes AS v, users AS u WHERE v.UserId = ph.UserId AND ph.UserId = c.UserId AND u.Views >= 0 AND u.UpVotes <= 123 AND u.Id = v.UserId AND u.DownVotes >= 0 LIMIT 10; | stats |
select count(*) from comments as c, postHistory as ph, badges as b, votes as v, users as u where u.Id = b.UserId and u.UpVotes = 0 and ph.PostHistoryTypeId = 12 and v.UserId = c.UserId and ph.UserId = v.UserId and b.UserId = ph.UserId | stats |
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 rt.role = 'actress' AND ci.role_id = rt.id AND mc.note NOT LIKE '%(USA)%' AND n1.id = ci... | 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 it.id = mi_idx.info_type_id AND it.inf... | 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 ct.id = mc.company_type_id AND it.id = mi_idx.i... | 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 it.info = 'top 250 rank' AND it.id = mi_idx.info_type_id AND (mc.note LIKE '%(co-production)%' OR mc.note ... | 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 t.id = mc.movie_id AND mc.note not like '%(USA)%' AND cn.country_code = '[jp]' AND mc.note like '%(Japan)%' AND... | job |
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.id = mk.keyword_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', 'Norwegian', 'German') AND t.id = mi.movie_id AND t.production_year > 2005 AND k... | 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.id = mc.company_type_id AND t.id = mc.movie_id AND it.info = 'top 250 rank' AND (mc.note like '%(co-pro... | 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 mc.movie_id = t.id AND k.keyword ='character-name-In-title' AND cn.country_code ='[sm]' AND mc.movie_id = mk.movie_id AND mk.keyword_id = k.id AND cn.id = mc.comp... | 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 n1.n_regionkey = r_re... | 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.id = mi.movie_id AND t.id = mk.movie_id AND k.keyword Like '%sequel%' AND t.production_year > 2000 AND k.id = mk.keyword_id AND mk.movie_id = mi.movie_id AND mi.info In ('Sweden', 'Norway', 'Germany', 'Denmar... | job |
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_qoy = 1 AND d_year = 2002 AND (SUBSTR(ca_zip, 1, 5) in ( '85669', '86197', '88274', '83405', '86475',... | tpcds |
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE l_orderkey = o_orderkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND o_orderdate >= DATE 1 AND s_nationkey = n_nationkey AND c_custkey = o_custkey AND c_nationkey = s_nationkey AND n_reg... | 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 = mi.movie_id AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND it.info = 'bottom 10 rank' AND it.id = mi.info_type_id AND mc.movie_id = mi.movie_id AND ... | 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 it2.info = 'release dates' AND cn.country_code = '[us]' AND it2.id = m... | job |
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 p.Id = ph.PostId AND b.UserId = u.Id AND c.UserId = u.Id AND pl.LinkTypeId = 1 AND p.Id = c.PostId AND p.Id = v.PostId AND p.Score <= 40 AND p.Id = pl.RelatedPostId | stats |
SELECT SUM(l_extendedprice) AS sum_base_price, AVG(l_discount) AS avg_disc, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, l_returnflag, COUNT(*) AS count_order, AVG(l_extendedprice) AS avg_price, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, l_linestatus, SUM(l_quantity) AS sum_qty, ... | 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 k.keyword ='character-name-IN-title' AND mk.keyword_id = k.id AND t.id = mk.movie_id AND cn.country_code ='[sm]' AND cn.id = mc.company_id AND mc.movie_id = t.id AND mc.movie_id = mk.mo... | job |
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE r_name = 1 AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND l_orderkey = o_orderkey AND c_custkey = o_custkey AND l_suppkey = s_suppkey AND o_orderdate >= DATE 1 AND c_nationkey = s_nationke... | tpch |
SELECT SUM(l_quantity) AS sum_qty, AVG(l_discount) AS avg_disc, AVG(l_extendedprice) AS avg_price, COUNT(*) AS count_order, l_returnflag, SUM(l_extendedprice) AS sum_base_price, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, l_linestatus, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, ... | tpch |
SELECT AVG(cs_sales_price) AS agg4, AVG(cs_coupon_amt) AS agg3, i_item_id, AVG(cs_quantity) AS agg1, AVG(cs_list_price) AS agg2 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 i_item_desc, s_store_id, MAX(ss_net_profit) AS store_sales_profit, MAX(cs_net_profit) AS catalog_sales_profit, MAX(sr_net_loss) AS store_returns_loss, s_store_name, i_item_id 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 n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_nationkey = s_nationkey AND n_regionkey = r_regionkey AND l_suppkey = s_suppkey AND s_nationkey = n_nationkey AND o_orderdate >= DATE 1 AND l_o... | tpch |
SELECT c_first_name, c_salutation, ss_ticket_number, c_last_name, cnt, c_preferred_cust_flag 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 =... | 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 cn.country_code ='[sm]' AND cn.id = mc.company_id AND k.keyword ='character-name-IN-title' AND mk.keyword_id = k.id AND mc.movie_id = mk.movie_id AND mc.movie_id = t.id AND t.id = mk.mo... | job |
SELECT AVG(l_quantity) AS avg_qty, SUM(l_quantity) AS sum_qty, AVG(l_extendedprice) AS avg_price, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, AVG(l_discount) AS avg_disc, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, l_linestatus, l_returnflag, SUM(l_extendedprice) AS sum_base_pric... | tpch |
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 it.id = mi_idx.info_type_id AND it.info = 'top 250 rank' AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pi... | 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 ci.movie_id = mk.movie_id AND k.id = mk.keyword_id AND t.id = mk.movie_id AND n.id = ci.person_id AND n.name Like '%Downey%Robert%' AND t.i... | 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_orde... | tpch |
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 s_store_id, SUM(sr_return_quantity) AS store_returns_quantity, i_item_id, i_item_desc, SUM(ss_quantity) AS store_sales_quantity, s_store_name, SUM(cs_quantity) AS catalog_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_ti... | 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 rt.role = 'actress' AND an1.person_id = ci.person_id AND an1.person_id = n1.id AND n1.name NOT LIKE '%Yu%' AND ... | 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 k.id = mk.keyword_id And t.id = mk.movie_id And ci.movie_id = mk.movie_id And n.name Like '%Hemsworth%Chris%' And t... | job |
SELECT c_custkey, SUM(l_quantity), o_orderdate, c_name, o_totalprice, o_orderkey 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 |
WITH year_total AS ( SELECT c_last_name AS customer_last_name, c_birth_country AS customer_birth_country, d_year AS dyear, c_preferred_cust_flag AS customer_preferred_cust_flag, 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_e... | tpcds |
SELECT p_mfgr, s_phone, s_comment, s_name, p_partkey, s_acctbal, s_address, n_name 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 l_returnflag, COUNT(*) AS count_order, SUM(l_quantity) AS sum_qty, AVG(l_quantity) AS avg_qty, l_linestatus, AVG(l_extendedprice) AS avg_price, SUM(l_extendedprice) AS sum_base_price, AVG(l_discount) AS avg_disc, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, SUM(l_extendedprice * (1 - l_discount) * ... | tpch |
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 chn.id = ci.person_role_id AND ci.movie_id = mc.movie_id AND ct.id = mc.company_type_id AND rt.id = ... | job |
SELECT SUM(l_extendedprice) / 7.0 AS avg_yearly FROM lineitem, part WHERE p_partkey = l_partkey AND l_quantity < ( SELECT 0.2 * AVG(l_quantity) FROM lineitem WHERE l_partkey = p_partkey ) AND p_brand = 1 AND p_container = 1 LIMIT 500; | tpch |
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 s_phone, total_revenue, s_suppkey, s_name, s_address FROM supplier, revenue0 WHERE s_suppkey = supplier_no AND total_revenue = ( SELECT MAX(total_revenue) FROM revenue0 ) ORDER BY s_suppkey | tpch |
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_nationkey = n_nationkey AND s_suppkey = ps_suppkey AND r_name = 1 AND n_regionkey = r_regionkey AND ps_supplycost = ( SELECT MIN(ps_supplycost) FROM partsupp, supplier, nation, region... | tpch |
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 (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.note NOT LIKE '%(as Metro-Goldwyn... | job |
Select extended_price, ss_ticket_number, c_first_name, list_price, ca_city, extended_tax, c_last_name, bought_city 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 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 n.name LIKE '%Hemsworth%Chris%' AND n.id = ci.person_id AND k.keyword = 'marvel-cinematic-universe' AND k.id =... | job |
WITH year_total AS ( SELECT 's' AS sale_type, 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, c_email_address AS customer_email_address, c_last_name AS customer_last_name, c_first_name AS customer_fir... | tpcds |
select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_nationkey = n_nationkey AND o_orderkey = l1.l_orderkey AND o_orderstatus = 'F' AND s_suppkey = l1.l_suppkey AND l1.l_receiptdate > l1.l_commitdate AND not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l... | tpch |
SELECT SUM(ss_quantity) AS store_sales_quantity, i_item_desc, i_item_id, SUM(sr_return_quantity) AS store_returns_quantity, s_store_name, s_store_id, SUM(cs_quantity) AS catalog_sales_quantity FROM store_sales INNER JOIN store_returns ON ss_customer_sk = sr_customer_sk AND ss_item_sk = sr_item_sk AND ss_ticket_number =... | tpcds |
Select Count(*) From postHistory As ph, posts As p, users As u, badges As b Where ph.PostHistoryTypeId = 3 And u.Id = b.UserId And ph.UserId = u.Id And p.Score >= -7 And p.OwnerUserId = u.Id And u.Reputation >= 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 t.id = mk.movie_id AND cn.country_code ='[de]' AND k.keyword ='character-name-in-title' AND mc.movie_id = t.id AND mk.keyword_id = k.id AND cn.id = mc.company_id AND mc.movie_id = mk.mo... | job |
SELECT p_mfgr, s_phone, s_comment, p_partkey, n_name, s_address, s_acctbal, s_name FROM part, supplier, partsupp, nation, region WHERE 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... | tpch |
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 ct.kind = 'production companies' AND ct.id = mc.company_type_id AND it.info = 'top 250 rank' AND t.id = mi... | 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 cn.country_code = '[ru]' AND ct.id = mc.company_type_id AND t.production_year > 2005 AND ci.note LIK... | 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_partkey = l_partkey... | tpch |
SELECT s_name, COUNT(*) AS numwait FROM supplier, lineitem l1, orders, nation WHERE n_name = 1 AND EXISTS ( SELECT * FROM lineitem l2 WHERE l2.l_orderkey = l1.l_orderkey AND l2.l_suppkey != l1.l_suppkey ) AND l1.l_receiptdate > l1.l_commitdate AND o_orderkey = l1.l_orderkey AND s_suppkey = l1.l_suppkey AND o_orderstatu... | tpch |
SELECT cnt, c_salutation, c_preferred_cust_flag, ss_ticket_number, c_first_name, c_last_name 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 STDDEV_SAMP(sr_return_quantity) AS store_returns_quantitystdev, AVG(cs_quantity) AS catalog_sales_quantityave, STDDEV_SAMP(ss_quantity) / AVG(ss_quantity) AS store_sales_quantitycov, i_item_id, STDDEV_SAMP(cs_quantity) / AVG(cs_quantity) AS catalog_sales_quantitycov, i_item_desc, STDDEV_SAMP(sr_return_quantity) ... | tpcds |
SELECT STDDEV_SAMP(cs_quantity) / AVG(cs_quantity) AS catalog_sales_quantitycov, AVG(sr_return_quantity) AS store_returns_quantityave, STDDEV_SAMP(ss_quantity) AS store_sales_quantitystdev, STDDEV_SAMP(ss_quantity) / AVG(ss_quantity) AS store_sales_quantitycov, COUNT(ss_quantity) AS store_sales_quantitycount, i_item_id... | 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 n.gender = 'f' AND it.info = 'release dates' AND mi.movie_id = ci.movie_i... | 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 mi_idx.movie_id = mc.movie_id AND kt.id = t.kind_id AND at.movie_id = ... | job |
WITH year_total AS ( SELECT c_login AS customer_login, c_last_name AS customer_last_name, c_first_name AS customer_first_name, c_preferred_cust_flag AS customer_preferred_cust_flag, c_email_address AS customer_email_address, c_birth_country AS customer_birth_country, c_customer_id AS customer_id, 's' AS sale_type, d_ye... | tpcds |
Select Avg(l_discount) As avg_disc, Sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) As sum_charge, Sum(l_quantity) As sum_qty, Sum(l_extendedprice * (1 - l_discount)) As sum_disc_price, Avg(l_quantity) As avg_qty, Avg(l_extendedprice) As avg_price, l_returnflag, l_linestatus, Count(*) As count_order, Sum(l_extend... | 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 = v.PostId AND p.AnswerCount >= 0 AND p.Id = c.PostId AND u.Id = p.OwnerUserId AND p.Id = pl.PostId AND p.Id = ph.PostId AND p.PostTypeId = 1 LIMIT 500; | stats |
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 > 2000 AND k.keyword LIKE '%sequel%' AND k.id = mk.keyword_id AND mi.info = ANY(ARRAY['Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German']) AND t.id = mi.movie... | job |
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_type Not Like 1 And p_size = ANY(ARRAY[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 B... | tpch |
SELECT SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_comment, c_custkey, c_phone, c_acctbal, c_address, n_name, 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' AN... | tpch |
SELECT c_comment, c_address, c_phone, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_acctbal, c_custkey, n_name, 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' AN... | tpch |
SELECT c_name, o_orderkey, c_custkey, SUM(l_quantity), o_orderdate, o_totalprice 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 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 JOIN store_returns ON store_sales.ss_customer_sk = store_returns.sr_customer_sk AND store_sales.ss_item_sk = store_return... | tpcds |
Select Count(*) From comments As c, posts As p, postLinks As pl, postHistory As ph, votes As v Where p.Id = ph.PostId AND p.FavoriteCount >= 0 AND pl.LinkTypeId = 1 AND p.Id = v.PostId AND p.Id = pl.PostId AND c.Score = 0 AND p.Id = c.PostId | stats |
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 ci.role_id = rt.id AND t.production_year > 1990 AND mc.note N... | job |
SELECT ss_ticket_number, c_first_name, c_last_name, cnt, c_preferred_cust_flag, c_salutation 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 max(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 mk.keyword_id = k.id and t.id = mk.movie_id and cn.id = mc.company_id and k.keyword ='character-name-in-title' and cn.country_code ='[sm]' and mc.movie_id ... | job |
Select i_brand_id As brand_id, i_brand As brand, 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 Where d_moy = 11 AND i_manager_id = 84 AND d_year = 2000 Group By i_brand, i_brand_id Order By ext_price Desc, brand_id Limi... | tpcds |
SELECT c_preferred_cust_flag, c_first_name, ss_ticket_number, c_salutation, cnt, c_last_name 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 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 = 2001 and (SUBSTR(ca_zip, 1, 5) in ( '85669', '86197', '88274', '83405', '86475', '85392', '854... | 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 = mi.movie_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Danish', 'Norwegian', 'German') AND k.keyword LIKE '%sequel%' AND t.production_year > 2000 AND k.id = mk.keyword_id AND t... | job |
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(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 t.production_year > 2010 AND ci.movie_id = mk.movie_id AND t.id = ci.movie_id AND t.id = mk.movie_id AN... | 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 t.id = mc.movie_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND ct.id = mc.company_type_... | job |
SELECT 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, l_shipmode FROM orders, lineitem WHERE l_shipmode IN (1, 1) AND l_shipdate < l_comm... | tpch |
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_orderk... | tpch |
SELECT AVG(ss_quantity), AVG(ss_ext_sales_price), AVG(ss_ext_wholesale_cost), 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 p_brand, p_size, COUNT(DISTINCT ps_suppkey) AS supplier_cnt, p_type FROM partsupp, part WHERE ps_suppkey NOT IN ( SELECT s_suppkey FROM supplier WHERE s_comment LIKE '%Customer%Complaints%' ) AND p_brand <> 1 AND p_partkey = ps_partkey AND p_type NOT LIKE 1 AND p_size IN (1, 1, 1, 1, 1, 1, 1, 1) GROUP BY p_brand... | tpch |
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.production_year > 2005 AND ci.note LIKE '%(uncredited)%' AND ci.note LIKE '%(voice)%' AND ct.id = ... | 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 o_orderkey = l_orderkey AND p_name LIKE 1 ) AS profit AND p_p... | tpch |
select sum(l_extendedprice * (1 - l_discount)) as revenue, n_name from customer, orders, lineitem, supplier, nation, region where o_orderdate >= DATE 1 AND l_orderkey = o_orderkey AND c_custkey = o_custkey AND n_regionkey = r_regionkey AND l_suppkey = s_suppkey AND s_nationkey = n_nationkey AND c_nationkey = s_nationke... | tpch |
SELECT l_linestatus, l_returnflag, AVG(l_quantity) AS avg_qty, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, AVG(l_discount) AS avg_disc, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, COUNT(*) AS count_order, SUM(l_extendedprice) AS sum_base_price, SUM(l_quantity) AS sum_qty, AVG(l_e... | tpch |
WITH year_total AS ( SELECT c_customer_id AS customer_id, c_first_name AS customer_first_name, c_preferred_cust_flag AS customer_preferred_cust_flag, c_last_name AS customer_last_name, SUM(((ss_ext_list_price - ss_ext_wholesale_cost - ss_ext_discount_amt) + ss_ext_sales_price) / 2) AS year_total, c_birth_country AS cus... | tpcds |
SELECT s_store_id, SUM(ss_quantity) AS store_sales_quantity, s_store_name, SUM(sr_return_quantity) AS store_returns_quantity, i_item_desc, i_item_id, SUM(cs_quantity) AS catalog_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_ti... | tpcds |
select sum(ss_ext_sales_price) as ext_price, dt.d_year, item.i_brand_id as brand_id, item.i_brand as brand 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 = 95 and dt.d_moy = 12 and dt.d_year = 19... | 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 rt.role = 'actress' AND an.person_id = n.id AND n.id = ci.per... | job |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.