text stringlengths 84 1.49k | benchmark stringclasses 4
values |
|---|---|
SELECT c_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_phone, c_acctbal, n_name, c_comment, c_address, 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' AN... | tpch |
WITH _q AS ( 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... | tpcds |
SELECT MIN(n.name) AS actor_name, MIN(k.keyword) AS movie_keyword, 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 = ci.movie_id AND n.id = ci.person_id AND k.keyword = 'marvel-cinematic-universe' AND n.name LIKE '%Downey%Robert%' AND t.id = mk.movi... | job |
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 o_orderkey = l_orderkey AND ps_partkey = l_partkey AND p_part... | 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 c_acctbal > ( Select Avg(c_acctbal) From customer Where c_acctbal > 0.00 And SUBSTRING(c_phone From 1... | tpch |
select count(*) from comments as c, posts as p, votes as v, users as u where p.Score >= 0 AND c.Score = 0 AND u.Id = p.OwnerUserId AND p.ViewCount >= 0 AND u.Id = c.UserId AND u.Id = v.UserId | 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 p.ViewCount >= 0 AND p.Id = v.PostId AND p.Id = ph.PostId AND p.Id = c.PostId AND u.Id = b.UserId | stats |
select count(1) from badges as b, posts as p where b.UserId = p.OwnerUserId and b.Date <= '2014-09-11 08:55:52'::timestamp and p.AnswerCount >= 0 and p.AnswerCount <= 4 LIMIT 100; | stats |
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 = mi.movie_id AND t.production_year > 2005 AND t.id = mk.movie_id AND mk.movie_id = mi.movie_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmark', 'Swedish', 'Denish', ... | job |
SELECT AVG(cs_quantity) AS agg1, i_item_id, AVG(cs_coupon_amt) AS agg3, AVG(cs_list_price) AS agg2, 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 = ... | 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 o_orderkey = l_orderkey And l_shipmode In (1... | tpch |
WITH _q AS ( 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 rt.id = ci.role_id AND t.id = ci.movie_id AND cn.id = mc.company_id AND cn.country_code... | job |
SELECT i_brand_id AS brand_id, SUM(ss_ext_sales_price) AS ext_price, i_brand AS brand, i_manufact, i_manufact_id 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 COUNT(*) AS count_order, SUM(l_extendedprice) AS sum_base_price, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, SUM(l_quantity) AS sum_qty, l_returnflag, l_linestatus, AVG(l_discount) AS avg_disc, AVG(l_extendedprice) AS avg_price, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, ... | 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 cn.country_code = '[us]' AND k.id =... | 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 mc.company_id = cn.id AND mc.movie_id = mk.movie_id AND t.episode_nr < 100 AND ci.movie_id ... | job |
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_shipmode IN (1, 1) AND l_receiptdate < DAT... | tpch |
SELECT s_name, COUNT(*) AS numwait FROM supplier, lineitem l1, orders, nation WHERE o_orderstatus = 'F' AND o_orderkey = l1.l_orderkey AND l1.l_receiptdate > l1.l_commitdate 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_commit... | tpch |
WITH _q AS ( Select Count(1) From comments As c, badges As b Where c.UserId = b.UserId AND c.Score = 0 AND b.Date <= '2014-09-11 14:33:06'::timestamp ) SELECT * FROM _q; | stats |
WITH year_total AS ( SELECT 's' AS sale_type, 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_preferred_cust_flag AS customer_preferred_cust_flag, c_email_address AS customer_email_address, c_last_name AS custo... | tpcds |
SELECT l_returnflag, AVG(l_discount) AS avg_disc, SUM(l_quantity) AS sum_qty, AVG(l_extendedprice) AS avg_price, AVG(l_quantity) AS avg_qty, l_linestatus, SUM(l_extendedprice) AS sum_base_price, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, COUNT(*) AS count_order, SUM(l_extendedprice * (1 - l_discount) * ... | tpch |
select COUNT(1) as custdist, c_count from ( select c_custkey, count(o_orderkey) as c_count from customer LEFT JOIN orders on c_custkey = o_custkey and o_comment not like 1 group by c_custkey ) as c_orders group by c_count order by custdist desc, c_count desc | tpch |
Select Count(*) From postHistory As ph, posts As p, users As u, badges As b Where ph.PostHistoryTypeId = 3 AND u.Reputation >= 1 AND p.OwnerUserId = u.Id AND u.Id = b.UserId AND ph.UserId = u.Id AND p.Score >= -7 | stats |
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_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%' ) GRO... | tpch |
SELECT i_item_id, AVG(cs_sales_price) AS agg4, AVG(cs_quantity) AS agg1, AVG(cs_coupon_amt) AS agg3, 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 COUNT(1) From comments As c, posts As p, postLinks As pl, postHistory As ph, votes As v Where c.Score = 0 AND p.Id = ph.PostId AND pl.LinkTypeId = 1 AND p.Id = c.PostId AND p.Id = v.PostId AND p.Id = pl.PostId AND p.FavoriteCount >= 0 | stats |
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 k.id = mk.keyword_id AND t.production_year > 2010 AND n.name LIKE '%Downey%Robert%' A... | 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 = ci.movie_id AND n.name LIKE '%Hemsworth%Chris%' AND n.id = ci.person_id AND t... | 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 rt.role = 'actor' AND cn.id = mc.company_id AND rt.id = ci.role_id AND t.production_year > 2005 AND ... | job |
SELECT COUNT(sr_return_quantity) AS store_returns_quantitycount, STDDEV_SAMP(cs_quantity) / AVG(cs_quantity) AS catalog_sales_quantitycov, STDDEV_SAMP(ss_quantity) / AVG(ss_quantity) AS store_sales_quantitycov, COUNT(cs_quantity) AS catalog_sales_quantitycount, i_item_id, AVG(ss_quantity) AS store_sales_quantityave, i_... | tpcds |
Select s_name, Count(*) As numwait From supplier, lineitem l1, orders, nation Where s_suppkey = l1.l_suppkey And o_orderstatus = 'F' And o_orderkey = l1.l_orderkey And s_nationkey = n_nationkey And n_name = 1 And Exists ( Select * From lineitem l2 Where l2.l_orderkey = l1.l_orderkey And l2.l_suppkey <> l1.l_suppkey ) A... | tpch |
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, votes AS v WHERE p.Id = c.PostId AND pl.PostId = v.PostId AND c.CreationDate >= '2010-08-02 23:52:10'::timestamp AND v.VoteTypeId = 2 AND c.PostId = pl.PostId AND p.Score >= -3 LIMIT 1000; | stats |
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 mc.movie_id = t.id AND it.id = miidx.info_type_... | job |
SELECT MIN(t.production_year) AS movie_year, MIN(t.title) AS movie_title, MIN(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 mc.movie_id = mi_idx.movie_id AND ct.kind = 'production companies' AND (mc.note LIKE '%(co-production)%' O... | job |
SELECT MAX(an1.name) AS actress_pseudonym, MAX(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 ci.movie_id = t.id AND ci.note = '(voice: English version)' AND ci.role_id = rt.id AND cn.country_code = '[jp]'... | job |
SELECT n_name, c_acctbal, c_custkey, c_address, SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_name, c_phone, c_comment 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 n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE l_orderkey = o_orderkey AND c_custkey = o_custkey AND l_suppkey = s_suppkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_nam... | tpch |
SELECT i_current_price, i_item_id, i_item_desc FROM item INNER JOIN inventory ON i_item_sk = inv_item_sk INNER JOIN date_dim ON d_date_sk = inv_date_sk INNER JOIN catalog_sales ON cs_item_sk = i_item_sk WHERE d_date BETWEEN CAST('2002-01-23' AS DATE) AND (CAST('2002-01-23' AS DATE) + INTERVAL '60 days') AND inv_quantit... | tpcds |
with v1 as ( select i_category, i_brand, s_store_name, s_company_name, d_year, d_moy, sum(ss_sales_price) as sum_sales, avg(sum(ss_sales_price)) OVER ( PARTITION by i_category, i_brand, s_store_name, s_company_name, d_year ) as avg_monthly_sales, RANK() OVER ( PARTITION by i_category, i_brand, s_store_name, s_company_n... | tpcds |
SELECT SUM(cs_quantity) AS catalog_sales_quantity, i_item_id, i_item_desc, s_store_name, s_store_id, SUM(sr_return_quantity) AS store_returns_quantity, 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_ti... | tpcds |
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 LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND t.id = mi_idx.movie_id AND it.info =... | 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 t.id = mi.movie_id AND mc.movie_id = mi.movie_id AND mc.note NOT LIKE '%(as Metro-Goldwyn-Mayer Pictures)%' AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND ... | job |
SELECT MIN(t.title) AS movie_title, MIN(mc.note) AS production_note, 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 = mi_idx.movie_id AND it.info = 'top 250 rank' AND ct.kind = 'production companies' AND mc.movie_id =... | job |
SELECT total, CAST(promotions AS DECIMAL(15, 4)) / CAST(total AS DECIMAL(15, 4)) * 100, 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 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 o_ord... | tpch |
SELECT MIN(n.name) AS actor_name, MIN(k.keyword) AS movie_keyword, 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 n.name LIKE '%Downey%Robert%' AND k.keyword = 'marvel-cinematic-universe' AND n.id = ci.person_id AND t.production_y... | job |
SELECT s_name, s_comment, n_name, s_address, s_phone, p_partkey, p_mfgr, s_acctbal FROM part, supplier, partsupp, nation, region WHERE p_size = 1 AND n_regionkey = r_regionkey AND r_name = 1 AND s_nationkey = n_nationkey AND p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND p_type LIKE 1 AND ps_supplycost = ( SELEC... | tpch |
SELECT SUM(l_extendedprice * (1 - l_discount)) AS revenue, o_orderdate, l_orderkey, o_shippriority FROM customer, orders, lineitem WHERE c_custkey = o_custkey AND c_mktsegment = 1 AND l_orderkey = o_orderkey AND o_orderdate < DATE 1 AND l_shipdate > DATE 1 GROUP BY l_orderkey, o_orderdate, o_shippriority ORDER BY reven... | tpch |
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 b.UserId = u.Id AND p.Id = ph.PostId AND pl.LinkTypeId = 1 AND p.Id = c.PostId AND p.Score <= 40 AND p.Id = pl.RelatedPostId AND p.Id = v.PostId | stats |
SELECT MAX(mi_idx.info) AS rating, MAX(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 it.info ='rating' AND t.production_year BETWEEN 2000 AND 2005 AND mi_idx.info > '8.0' AND t.id = mi_idx.movie_id | job |
SELECT AVG(l_discount) AS avg_disc, SUM(l_extendedprice) AS sum_base_price, l_linestatus, AVG(l_extendedprice) AS avg_price, l_returnflag, SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, SUM(l_quantity) AS sum_qty, SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, COUNT(*) AS count_order, ... | 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 t.id = mk.movie_id AND mk.keyword_id = k.id AND mc.movie_id = t.id AND cn.country_code ='[nl]' AND cn.id = mc.company_id AND mc.movie_id = mk.movie_id AND k.keyword ='character-name-in-... | 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 n1.name LIKE '%Yo%' AND rt.role = 'actress' AND mc.note LIKE '%(Japan)%' AND ci.movie_id = t.id AND an1.person_... | 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.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)%') AND ... | job |
SELECT MAX(an1.name) AS actress_pseudonym, MAX(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 = n1.id AND ci.movie_id = t.id AND n1.name NOT LIKE '%Yu%' AND cn.country_code = '[jp]' AND mc.co... | job |
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 n_name, Sum(l_extendedprice * (1 - l_discount)) As revenue From customer, orders, lineitem, supplier, nation, region Where l_orderkey = o_orderkey AND c_nationkey = s_nationkey AND o_orderdate >= DATE 1 AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_custkey = o_custkey AND l_suppkey = s_suppkey AND s_nationk... | tpch |
SELECT MAX(k.keyword) AS movie_keyword, MAX(n.name) AS actor_name, MAX(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 n.name LIKE '%Hemsworth%Chris%' AND k.keyword = 'marvel-cinematic-universe' AND n.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 s_nati... | tpch |
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 AVG(cs_coupon_amt) AS agg3, i_item_id, AVG(cs_list_price) AS agg2, AVG(cs_sales_price) AS agg4, AVG(cs_quantity) AS agg1 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 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_desc, s_store_id, 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 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 n.id = ci.person_id AND mc.movie_id = mk.movie_id AND an.person_id = n.id AND ci.movie_id =... | 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 n.id = ci.person_id AND k.id = mk.keyword_id AND k.keyword = 'marvel-cinematic-universe' AND t.id = ci.movie_... | job |
SELECT c_preferred_cust_flag, c_first_name, c_salutation, ss_ticket_number, c_last_name, 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 SUM(ss_ext_sales_price) AS ext_price, item.i_brand_id AS brand_id, item.i_brand AS brand, 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_manager_id = 67 AND dt.d_moy = 11 AND dt.d_year = 1999 GROUP BY ... | tpcds |
SELECT AVG(ss_quantity), AVG(ss_ext_sales_price), AVG(ss_ext_wholesale_cost), SUM(ss_ext_wholesale_cost) FROM store_sales INNER JOIN store ON s_store_sk = ss_store_sk INNER JOIN customer_demographics ON cd_demo_sk = ss_cdemo_sk INNER JOIN household_demographics ON hd_demo_sk = ss_hdemo_sk INNER JOIN customer_address ON... | tpcds |
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE s_nationkey = n_nationkey AND l_suppkey = s_suppkey AND c_custkey = o_custkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_nationkey = s_nationkey AND o_orderdate >= DATE 1 AND r_name ... | 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 at.movie_id = mi.movie_id AND at.movie_id = mi_idx.movie_id AND t.id =... | job |
SELECT STDDEV_SAMP(sr_return_quantity) AS store_returns_quantitystdev, AVG(sr_return_quantity) AS store_returns_quantityave, STDDEV_SAMP(ss_quantity) AS store_sales_quantitystdev, COUNT(cs_quantity) AS catalog_sales_quantitycount, i_item_desc, AVG(ss_quantity) AS store_sales_quantityave, COUNT(sr_return_quantity) AS st... | tpcds |
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.ViewCount >= 0 AND p.Id = c.PostId AND p.Id = ph.PostId AND p.Id = v.PostId AND u.Id = b.UserId AND p.Score <= 192 | stats |
WITH _q AS ( SELECT SUM(l_extendedprice * l_discount) AS revenue FROM lineitem WHERE l_discount BETWEEN 1 - 0.01 AND 1 + 0.01 AND l_quantity < 1 AND l_shipdate < DATE 1 + INTERVAL '1' YEAR AND l_shipdate >= DATE 1 ) SELECT * FROM _q; | tpch |
SELECT COUNT(*) FROM comments AS c, posts AS p, postLinks AS pl, postHistory AS ph, votes AS v, badges AS b WHERE b.UserId = c.UserId AND p.Id = pl.RelatedPostId AND p.Id = v.PostId AND p.Id = c.PostId AND c.Score = 0 AND p.Id = ph.PostId AND pl.LinkTypeId = 1 LIMIT 1000; | stats |
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 ci.note like '%(voice)%' and ci.note like '%(uncredited)%' and t.id = ci.movie_id and rt.role = 'act... | 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.kind = 'movie' AND t.production_year > 2000 AND t.id = at.movie_id ... | job |
Select p_brand, p_type, p_size, Count(Distinct ps_suppkey) As supplier_cnt From partsupp, part Where 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_type Not Like 1 AND p_partkey = ps_partkey AND p_brand <> 1 Group By p_brand... | tpch |
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 o_orderkey = l_orderkey AND l_receiptdate >=... | tpch |
select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where l1.l_receiptdate > l1.l_commitdate AND o_orderkey = l1.l_orderkey AND n_name = 1 AND exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) AND s_suppkey = l1.l_suppkey AND o_orderstatu... | tpch |
SELECT i_manufact, SUM(ss_ext_sales_price) AS ext_price, i_brand AS brand, i_brand_id AS brand_id, i_manufact_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 JO... | tpcds |
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 o_orderkey = l1.l_orderkey AND NOT EXISTS ( SELECT * FROM lineitem l3 WHERE l3.l_orderkey = l1.l_orderkey AND l... | 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 ct.id = mc.company_type_id AND it.info = 'bottom 10 rank' AND (mc.note LIKE '%(co-production)%' OR mc.note LIKE '%(presents)%') AND mc.note NOT LIKE '%(as Metr... | job |
SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) AS revenue FROM customer, orders, lineitem, supplier, nation, region WHERE l_suppkey = s_suppkey AND n_regionkey = r_regionkey AND c_nationkey = s_nationkey AND o_orderdate < DATE 1 + INTERVAL '1' YEAR AND c_custkey = o_custkey AND s_nationkey = n_nationkey AND o_o... | 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 r_name = 1 AND n_regionkey = r_regionkey AND p_size = 1 AND p_type LIKE 1 AND s_nationkey = n_nationkey AND p_partkey = ps_partkey AND s_suppkey = ps_suppkey AND ps_supplycost = ( SELEC... | tpch |
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 |
WITH year_total AS ( SELECT 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_email_address AS customer_email_address, c_login AS customer_login, c_preferred_cust_flag AS customer_preferred_cust_flag, d_year AS dyear, c_... | tpcds |
select min(t.title) as marvel_movie, min(n.name) as actor_name, 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 ci.movie_id = mk.movie_id AND t.production_year > 2010 AND t.id = ci.movie_id AND k.keyword = 'marvel-cinematic-universe' AND n.name like '... | job |
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 k.keyword = 'anime' AND mc.note NOT LIKE '%(USA)%' AND n.gend... | job |
select avg(ss_sales_price) as agg4, avg(ss_coupon_amt) as agg3, avg(ss_list_price) as agg2, i_item_id, avg(ss_quantity) as agg1 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... | 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_orderk... | tpch |
SELECT s_name, COUNT(*) AS numwait FROM supplier, lineitem l1, orders, nation WHERE o_orderstatus = 'F' AND 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 n_name = 1 AND o_orderkey = l1.l_orderkey AND NOT EXISTS ( SELECT * FROM... | 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 miidx.movie_id = t.id AND kt.kind = 'movie' AND... | job |
WITH _q AS ( SELECT COUNT(1) FROM postHistory AS ph, posts AS p, users AS u, badges AS b WHERE p.OwnerUserId = u.Id AND ph.UserId = u.Id AND ph.PostHistoryTypeId = 3 AND u.Reputation >= 1 ) SELECT * FROM _q AND u.Id = b.UserId AND p.Score >= -7 | stats |
WITH _q AS ( SELECT i_item_id, AVG(cs_quantity) AS agg1, AVG(cs_list_price) AS agg2, AVG(cs_coupon_amt) AS agg3, 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 c... | tpcds |
WITH _q AS ( 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 AN... | tpch |
SELECT SUM( CASE WHEN o_orderpriority = '1-URGENT' OR o_orderpriority = '2-HIGH' THEN 1 ELSE 0 END ) AS high_line_count, l_shipmode, 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 o_orderkey = l_orderkey AND l_shipmode IN (1... | tpch |
SELECT MIN(t.title) AS japanese_movie_dubbed, MIN(an1.name) AS actress_pseudonym 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 NOT LIKE '%(USA)%' AND t.id = mc.movie_id AND rt.role = 'actress' AND ci.movie_id = t.id AND mc.company... | 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 and o_orderdate < DATE 1 + INTERVAL '3' MONTH and l_returnflag = 'R' and c_custkey = o_custkey and c_nationkey = n_nationkey ... | tpch |
SELECT MAX(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 t.production_year > 2005 AND mk.movie_id = mi.movie_id AND t.id = mi.movie_id AND k.keyword LIKE '%sequel%' AND k.id = mk.keyword_id AND mi.info IN ('Sweden', 'Norway', 'Germany', 'Denmar... | job |
SELECT a.ca_state AS state, COUNT(*) AS cnt FROM customer_address AS a INNER JOIN customer AS c ON a.ca_address_sk = c.c_current_addr_sk INNER JOIN store_sales AS s ON c.c_customer_sk = s.ss_customer_sk INNER JOIN date_dim AS d ON s.ss_sold_date_sk = d.d_date_sk INNER JOIN item AS i ON s.ss_item_sk = i.i_item_sk WHERE ... | tpcds |
SELECT s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.