question_id
int64 1
75.7k
| db_id
stringclasses 33
values | db_name
stringclasses 4
values | question
stringlengths 19
259
| partition
stringclasses 4
values | difficulty
stringclasses 3
values | SQL
stringlengths 25
862
|
|---|---|---|---|---|---|---|
101
|
financial
|
bird
|
Name the account numbers of female clients who are oldest and have lowest average salary?
|
dev
|
medium
|
SELECT t3.account_id FROM client AS t1 INNER JOIN district AS t2 ON t1.district_id = t2.district_id INNER JOIN account AS t3 ON t2.district_id = t3.district_id INNER JOIN disp AS t4 ON t1.client_id = t4.client_id AND t4.account_id = t3.account_id WHERE t1.gender = 'f' ORDER BY t1.birth_date ASC, t2.a11 ASC LIMIT 1
|
102
|
financial
|
bird
|
How many clients who were born in 1920 stay in east Bohemia?
|
dev
|
easy
|
SELECT COUNT(t1.client_id) FROM client AS t1 INNER JOIN district AS t2 ON t1.district_id = t2.district_id WHERE STRFTIME('%y', t1.birth_date) = '1920' AND t2.a3 = 'east bohemia'
|
103
|
financial
|
bird
|
How many loan accounts are for pre-payment of duration of 24 months with weekly issuance of statement.
|
dev
|
easy
|
SELECT COUNT(t2.account_id) FROM account AS t1 INNER JOIN loan AS t2 ON t1.account_id = t2.account_id WHERE t2.duration = 24 AND t1.frequency = 'poplatek tydne'
|
104
|
financial
|
bird
|
What is the average amount of loan which are still on running contract with statement issuance after each transaction?
|
dev
|
medium
|
SELECT AVG(t2.amount) FROM account AS t1 INNER JOIN loan AS t2 ON t1.account_id = t2.account_id WHERE t2.status IN ('c', 'd') AND t1.frequency = 'poplatek po obratu'
|
105
|
financial
|
bird
|
List all ID and district for clients that can only have the right to issue permanent orders or apply for loans.
|
dev
|
medium
|
SELECT t3.client_id, t2.district_id, t2.a2 FROM account AS t1 INNER JOIN district AS t2 ON t1.district_id = t2.district_id INNER JOIN disp AS t3 ON t1.account_id = t3.account_id WHERE t3.type = 'owner'
|
106
|
financial
|
bird
|
Provide the IDs and age of the client with high level credit card, which is eligible for loans.
|
dev
|
medium
|
SELECT t1.client_id, STRFTIME('%y', CURRENT_TIMESTAMP) - STRFTIME('%y', t3.birth_date) FROM disp AS t1 INNER JOIN card AS t2 ON t2.disp_id = t1.disp_id INNER JOIN client AS t3 ON t1.client_id = t3.client_id WHERE t2.type = 'gold' AND t1.type = 'owner'
|
107
|
debit_card_specializing
|
bird
|
How many gas stations in CZE has Premium gas?
|
dev
|
easy
|
SELECT COUNT(gasstationid) FROM gasstations WHERE country = 'cze' AND segment = 'premium'
|
108
|
debit_card_specializing
|
bird
|
What is the ratio of customers who pay in EUR against customers who pay in CZK?
|
dev
|
easy
|
SELECT CAST(SUM(IIF(currency = 'eur', 1, 0)) AS REAL) / SUM(IIF(currency = 'czk', 1, 0)) AS ratio FROM customers
|
109
|
debit_card_specializing
|
bird
|
In 2012, who had the least consumption in LAM?
|
dev
|
medium
|
SELECT t1.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.segment = 'lam' AND SUBSTRING(t2.date, 1, 4) = '2012' GROUP BY t1.customerid ORDER BY SUM(t2.consumption) ASC LIMIT 1
|
110
|
debit_card_specializing
|
bird
|
What was the average monthly consumption of customers in SME for the year 2013?
|
dev
|
medium
|
SELECT CAST(AVG(t2.consumption) AS REAL) / 12 FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE SUBSTRING(t2.date, 1, 4) = '2013' AND t1.segment = 'sme'
|
111
|
debit_card_specializing
|
bird
|
Which customers, paying in CZK, consumed the most gas in 2011?
|
dev
|
medium
|
SELECT t1.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.currency = 'czk' AND t2.date BETWEEN 201101 AND 201112 GROUP BY t1.customerid ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
112
|
debit_card_specializing
|
bird
|
How many customers in KAM had a consumption of less than 30,000 for the year 2012?
|
dev
|
medium
|
SELECT COUNT(*) FROM (SELECT t2.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.segment = 'kam' AND SUBSTRING(t2.date, 1, 4) = '2012' GROUP BY t2.customerid HAVING SUM(t2.consumption) < 30000) AS t1
|
113
|
debit_card_specializing
|
bird
|
What was the difference in gas consumption between CZK-paying customers and EUR-paying customers in 2012?
|
dev
|
hard
|
SELECT SUM(IIF(t1.currency = 'czk', t2.consumption, 0)) - SUM(IIF(t1.currency = 'eur', t2.consumption, 0)) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE SUBSTRING(t2.date, 1, 4) = '2012'
|
114
|
debit_card_specializing
|
bird
|
Which year recorded the most gas use paid in EUR?
|
dev
|
easy
|
SELECT SUBSTRING(t2.date, 1, 4) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.currency = 'eur' GROUP BY SUBSTRING(t2.date, 1, 4) ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
115
|
debit_card_specializing
|
bird
|
Which segment had the least consumption?
|
dev
|
easy
|
SELECT t1.segment FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid GROUP BY t1.segment ORDER BY SUM(t2.consumption) ASC LIMIT 1
|
116
|
debit_card_specializing
|
bird
|
Which year recorded the most consumption of gas paid in CZK?
|
dev
|
medium
|
SELECT SUBSTRING(t2.date, 1, 4) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.currency = 'czk' GROUP BY SUBSTRING(t2.date, 1, 4) ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
117
|
debit_card_specializing
|
bird
|
What was the gas consumption peak month for SME customers in 2013?
|
dev
|
medium
|
SELECT SUBSTRING(t2.date, 5, 2) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE SUBSTRING(t2.date, 1, 4) = '2013' AND t1.segment = 'sme' GROUP BY SUBSTRING(t2.date, 5, 2) ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
118
|
debit_card_specializing
|
bird
|
What is the difference in the annual average consumption of the customers with the least amount of consumption paid in CZK for 2013 between SME and LAM, LAM and KAM, and KAM and SME?
|
dev
|
hard
|
SELECT CAST(SUM(IIF(t1.segment = 'sme', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid) - CAST(SUM(IIF(t1.segment = 'lam', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid), CAST(SUM(IIF(t1.segment = 'lam', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid) - CAST(SUM(IIF(t1.segment = 'kam', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid), CAST(SUM(IIF(t1.segment = 'kam', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid) - CAST(SUM(IIF(t1.segment = 'sme', t2.consumption, 0)) AS REAL) / COUNT(t1.customerid) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.currency = 'czk' AND t2.consumption = (SELECT MIN(consumption) FROM yearmonth) AND t2.date BETWEEN 201301 AND 201312
|
119
|
debit_card_specializing
|
bird
|
Which of the three segments—SME, LAM and KAM—has the biggest and lowest percentage increases in consumption paid in EUR between 2012 and 2013?
|
dev
|
hard
|
SELECT CAST(CAST((SUM(IIF(t1.segment = 'sme' AND t2.date LIKE '2013%', t2.consumption, 0)) - SUM(IIF(t1.segment = 'sme' AND t2.date LIKE '2012%', t2.consumption, 0))) AS REAL) * 100 AS REAL) / SUM(IIF(t1.segment = 'sme' AND t2.date LIKE '2012%', t2.consumption, 0)), CAST(CAST(SUM(IIF(t1.segment = 'lam' AND t2.date LIKE '2013%', t2.consumption, 0)) - SUM(IIF(t1.segment = 'lam' AND t2.date LIKE '2012%', t2.consumption, 0)) AS REAL) * 100 AS REAL) / SUM(IIF(t1.segment = 'lam' AND t2.date LIKE '2012%', t2.consumption, 0)), CAST(CAST(SUM(IIF(t1.segment = 'kam' AND t2.date LIKE '2013%', t2.consumption, 0)) - SUM(IIF(t1.segment = 'kam' AND t2.date LIKE '2012%', t2.consumption, 0)) AS REAL) * 100 AS REAL) / SUM(IIF(t1.segment = 'kam' AND t2.date LIKE '2012%', t2.consumption, 0)) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid
|
120
|
debit_card_specializing
|
bird
|
How much did customer 6 consume in total between August and November 2013?
|
dev
|
easy
|
SELECT SUM(consumption) FROM yearmonth WHERE customerid = 6 AND date BETWEEN '201308' AND '201311'
|
121
|
debit_card_specializing
|
bird
|
How many more "discount" gas stations does the Czech Republic have compared to Slovakia?
|
dev
|
easy
|
SELECT SUM(IIF(country = 'cze', 1, 0)) - SUM(IIF(country = 'svk', 1, 0)) FROM gasstations WHERE segment = 'discount'
|
122
|
debit_card_specializing
|
bird
|
How much more was customer 7 consuming in April 2013 than customer 5?
|
dev
|
easy
|
SELECT SUM(IIF(customerid = 7, consumption, 0)) - SUM(IIF(customerid = 5, consumption, 0)) FROM yearmonth WHERE date = '201304'
|
123
|
debit_card_specializing
|
bird
|
Is it true that more SMEs pay in Czech koruna than in euros? If so, how many more?
|
dev
|
easy
|
SELECT SUM(currency = 'czk') - SUM(currency = 'eur') FROM customers WHERE segment = 'sme'
|
124
|
debit_card_specializing
|
bird
|
Which LAM customer used the Euro as their currency and had the highest consumption in October 2013?
|
dev
|
medium
|
SELECT t1.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.segment = 'lam' AND t2.date = '201310' AND t1.currency = 'eur' GROUP BY t1.customerid ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
125
|
debit_card_specializing
|
bird
|
Who among KAM's customers consumed the most? How much did it consume?
|
dev
|
easy
|
SELECT t2.customerid, SUM(t2.consumption) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.segment = 'kam' GROUP BY t2.customerid ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
126
|
debit_card_specializing
|
bird
|
How much did the KAM customers consume in total in May 2013?
|
dev
|
easy
|
SELECT SUM(t2.consumption) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t2.date = '201305' AND t1.segment = 'kam'
|
127
|
debit_card_specializing
|
bird
|
How many percent of LAM customer consumed more than 46.73?
|
dev
|
medium
|
SELECT CAST(CAST(SUM(IIF(t2.consumption > 46.73, 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.customerid) FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.segment = 'lam'
|
128
|
debit_card_specializing
|
bird
|
Which country has more "value for money" gas stations? Please give a total number of "value for money" gas stations in each country.
|
dev
|
easy
|
SELECT country, (SELECT COUNT(gasstationid) FROM gasstations WHERE segment = 'value for money') FROM gasstations WHERE segment = 'value for money' GROUP BY country ORDER BY COUNT(gasstationid) DESC LIMIT 1
|
129
|
debit_card_specializing
|
bird
|
What percentage of KAM customers pay in euros?
|
dev
|
easy
|
SELECT CAST(CAST(SUM(currency = 'eur') AS REAL) * 100 AS REAL) / COUNT(customerid) FROM customers WHERE segment = 'kam'
|
130
|
debit_card_specializing
|
bird
|
In February 2012, what percentage of customers consumed more than 528.3?
|
dev
|
easy
|
SELECT CAST(CAST(SUM(IIF(consumption > 528.3, 1, 0)) AS REAL) * 100 AS REAL) / COUNT(customerid) FROM yearmonth WHERE date = '201202'
|
131
|
debit_card_specializing
|
bird
|
What percentage of Slovakian gas stations are premium?
|
dev
|
easy
|
SELECT CAST(CAST(SUM(IIF(segment = 'premium', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(gasstationid) FROM gasstations WHERE country = 'svk'
|
132
|
debit_card_specializing
|
bird
|
Which client ID consumed the most in September 2013?
|
dev
|
easy
|
SELECT t1.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t2.date = '201309' GROUP BY t1.customerid ORDER BY SUM(t2.consumption) DESC LIMIT 1
|
133
|
debit_card_specializing
|
bird
|
Which client segment consumed the least in September 2013?
|
dev
|
easy
|
SELECT t1.segment FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t2.date = '201309' GROUP BY t1.customerid ORDER BY SUM(t2.consumption) ASC LIMIT 1
|
134
|
debit_card_specializing
|
bird
|
Which SME customer consumed the least in June 2012?
|
dev
|
easy
|
SELECT t1.customerid FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t2.date = '201206' AND t1.segment = 'sme' GROUP BY t1.customerid ORDER BY SUM(t2.consumption) ASC LIMIT 1
|
135
|
debit_card_specializing
|
bird
|
What is the highest monthly consumption in the year 2012?
|
dev
|
easy
|
SELECT SUM(consumption) FROM yearmonth WHERE SUBSTRING(date, 1, 4) = '2012' GROUP BY SUBSTRING(date, 5, 2) ORDER BY SUM(consumption) DESC LIMIT 1
|
136
|
debit_card_specializing
|
bird
|
What is the biggest monthly consumption of the customers who use euro as their currency?
|
dev
|
easy
|
SELECT CAST(SUM(t2.consumption) AS REAL) / 12 AS monthlyconsumption FROM customers AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.currency = 'eur' GROUP BY t1.customerid ORDER BY monthlyconsumption DESC LIMIT 1
|
137
|
debit_card_specializing
|
bird
|
Please list the product description of the products consumed in September, 2013.
|
dev
|
easy
|
SELECT t3.description FROM transactions_1k AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t1.productid = t3.productid WHERE t2.date = '201309'
|
138
|
debit_card_specializing
|
bird
|
Please list the countries of the gas stations with transactions taken place in June, 2013.
|
dev
|
medium
|
SELECT DISTINCT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid INNER JOIN yearmonth AS t3 ON t1.customerid = t3.customerid WHERE t3.date = '201306'
|
139
|
debit_card_specializing
|
bird
|
Please list the chains of the gas stations with transactions in euro.
|
dev
|
easy
|
SELECT DISTINCT t3.chainid FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid INNER JOIN gasstations AS t3 ON t1.gasstationid = t3.gasstationid WHERE t2.currency = 'eur'
|
140
|
debit_card_specializing
|
bird
|
Please list the product description of the products bought in transactions in euro.
|
dev
|
easy
|
SELECT DISTINCT t1.productid, t3.description FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t1.productid = t3.productid WHERE t2.currency = 'eur'
|
141
|
debit_card_specializing
|
bird
|
What is the average total price of the transactions taken place in January, 2012?
|
dev
|
easy
|
SELECT AVG(amount) FROM transactions_1k WHERE date LIKE '2012-01%'
|
142
|
debit_card_specializing
|
bird
|
Among the customers who paid in euro, how many of them have a monthly consumption of over 1000?
|
dev
|
easy
|
SELECT COUNT(*) FROM yearmonth AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t2.currency = 'eur' AND t1.consumption > 1000.00
|
143
|
debit_card_specializing
|
bird
|
Please list the product descriptions of the transactions taken place in the gas stations in the Czech Republic.
|
dev
|
medium
|
SELECT DISTINCT t3.description FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid INNER JOIN products AS t3 ON t1.productid = t3.productid WHERE t2.country = 'cze'
|
144
|
debit_card_specializing
|
bird
|
Please list the disparate time of the transactions taken place in the gas stations from chain no. 11.
|
dev
|
easy
|
SELECT DISTINCT t1.time FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t2.chainid = 11
|
145
|
debit_card_specializing
|
bird
|
How many transactions taken place in the gas station in the Czech Republic are with a price of over 1000?
|
dev
|
easy
|
SELECT COUNT(t1.transactionid) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t2.country = 'cze' AND t1.price > 1000
|
146
|
debit_card_specializing
|
bird
|
Among the transactions made in the gas stations in the Czech Republic, how many of them are taken place after 2012/1/1?
|
dev
|
medium
|
SELECT COUNT(t1.transactionid) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t2.country = 'cze' AND STRFTIME('%y', t1.date) >= '2012'
|
147
|
debit_card_specializing
|
bird
|
What is the average total price of the transactions taken place in gas stations in the Czech Republic?
|
dev
|
easy
|
SELECT AVG(t1.price) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t2.country = 'cze'
|
148
|
debit_card_specializing
|
bird
|
For the customers who paid in the euro, what is their average total price of the transactions?
|
dev
|
easy
|
SELECT AVG(t1.price) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid INNER JOIN customers AS t3 ON t1.customerid = t3.customerid WHERE t3.currency = 'eur'
|
149
|
debit_card_specializing
|
bird
|
Which customer paid the most in 2012/8/25?
|
dev
|
easy
|
SELECT customerid FROM transactions_1k WHERE date = '2012-08-25' GROUP BY customerid ORDER BY SUM(price) DESC LIMIT 1
|
150
|
debit_card_specializing
|
bird
|
Which country's gas station had the first paid cusomer in 2012/8/25?
|
dev
|
easy
|
SELECT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-25' ORDER BY t1.time DESC LIMIT 1
|
151
|
debit_card_specializing
|
bird
|
What kind of currency did the customer paid at 16:25:00 in 2012/8/24?
|
dev
|
easy
|
SELECT DISTINCT t3.currency FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid INNER JOIN customers AS t3 ON t1.customerid = t3.customerid WHERE t1.date = '2012-08-24' AND t1.time = '16:25:00'
|
152
|
debit_card_specializing
|
bird
|
What segment did the customer have at 2012/8/23 21:20:00?
|
dev
|
easy
|
SELECT t2.segment FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t1.date = '2012-08-23' AND t1.time = '21:20:00'
|
153
|
debit_card_specializing
|
bird
|
How many transactions were paid in CZK in the morning of 2012/8/26?
|
dev
|
medium
|
SELECT COUNT(t1.transactionid) FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t1.date = '2012-08-26' AND t1.time < '13:00:00' AND t2.currency = 'czk'
|
154
|
debit_card_specializing
|
bird
|
For the earliest customer, what segment did he/she have?
|
dev
|
easy
|
SELECT t2.segment FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid ORDER BY date ASC LIMIT 1
|
155
|
debit_card_specializing
|
bird
|
For the deal happened at 2012/8/24 12:42:00, which country was it?
|
dev
|
easy
|
SELECT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-24' AND t1.time = '12:42:00'
|
156
|
debit_card_specializing
|
bird
|
What was the product id of the transaction happened at 2012/8/23 21:20:00?
|
dev
|
easy
|
SELECT t1.productid FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-23' AND t1.time = '21:20:00'
|
157
|
debit_card_specializing
|
bird
|
For the customer who paid 124.05 in 2012/8/24, how much did he/she spend during the January of 2012? And what is the date and expenses exactly?
|
dev
|
medium
|
SELECT t1.customerid, t2.date, t2.consumption FROM transactions_1k AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE t1.date = '2012-08-24' AND t1.price = 124.05 AND t2.date = '201201'
|
158
|
debit_card_specializing
|
bird
|
For all the transactions happened during 8:00-9:00 in 2012/8/26, how many happened in CZE?
|
dev
|
medium
|
SELECT COUNT(t1.transactionid) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-26' AND t1.time BETWEEN '08:00:00' AND '09:00:00' AND t2.country = 'cze'
|
159
|
debit_card_specializing
|
bird
|
There's one customer spent 214582.17 in the June of 2013, which currency did he/she use?
|
dev
|
easy
|
SELECT t2.currency FROM yearmonth AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t1.date = '201306' AND t1.consumption = 214582.17
|
160
|
debit_card_specializing
|
bird
|
Which country was the card owner of No.667467 in?
|
dev
|
easy
|
SELECT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.cardid = '667467'
|
161
|
debit_card_specializing
|
bird
|
What's the nationality of the customer who spent 548.4 in 2012/8/24?
|
dev
|
easy
|
SELECT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-24' AND t1.price = 548.4
|
162
|
debit_card_specializing
|
bird
|
What is the percentage of the customers who used EUR in 2012/8/25?
|
dev
|
easy
|
SELECT CAST(CAST(SUM(IIF(t2.currency = 'eur', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.customerid) FROM transactions_1k AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t1.date = '2012-08-25'
|
163
|
debit_card_specializing
|
bird
|
For the customer who paid 634.8 in 2012/8/25, what was the consumption decrease rate from Year 2012 to 2013?
|
dev
|
hard
|
SELECT CAST(SUM(IIF(SUBSTRING(date, 1, 4) = '2012', consumption, 0)) - SUM(IIF(SUBSTRING(date, 1, 4) = '2013', consumption, 0)) AS REAL) / SUM(IIF(SUBSTRING(date, 1, 4) = '2012', consumption, 0)) FROM yearmonth WHERE customerid = (SELECT t1.customerid FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.date = '2012-08-25' AND t1.price = 634.8)
|
164
|
debit_card_specializing
|
bird
|
Which gas station has the highest amount of revenue?
|
dev
|
easy
|
SELECT gasstationid FROM transactions_1k GROUP BY gasstationid ORDER BY SUM(price) DESC LIMIT 1
|
165
|
debit_card_specializing
|
bird
|
What is the percentage of "premium" against the overall segment in Country = "SVK"?
|
dev
|
easy
|
SELECT CAST(CAST(SUM(IIF(country = 'svk' AND segment = 'premium', 1, 0)) AS REAL) * 100 AS REAL) / SUM(IIF(country = 'svk', 1, 0)) FROM gasstations
|
166
|
debit_card_specializing
|
bird
|
What is the amount spent by customer "38508" at the gas stations? How much had the customer spent in January 2012?
|
dev
|
medium
|
SELECT SUM(t1.price), SUM(IIF(t3.date = '201201', t1.price, 0)) FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid INNER JOIN yearmonth AS t3 ON t1.customerid = t3.customerid WHERE t1.customerid = '38508'
|
167
|
debit_card_specializing
|
bird
|
Which are the top five best selling products? Please state the full name of them.
|
dev
|
easy
|
SELECT t2.description FROM transactions_1k AS t1 INNER JOIN products AS t2 ON t1.productid = t2.productid ORDER BY t1.amount DESC LIMIT 5
|
168
|
debit_card_specializing
|
bird
|
Who is the top spending customer and how much is the average price per single item purchased by this customer? What currency was being used?
|
dev
|
medium
|
SELECT t2.customerid, SUM(CAST(t2.price AS REAL) / t2.amount), t1.currency FROM customers AS t1 INNER JOIN transactions_1k AS t2 ON t1.customerid = t2.customerid WHERE t2.customerid = (SELECT customerid FROM yearmonth ORDER BY consumption DESC LIMIT 1) GROUP BY t2.customerid, t1.currency
|
169
|
debit_card_specializing
|
bird
|
Which country had the gas station that sold the most expensive product id No.2 for one unit?
|
dev
|
easy
|
SELECT t2.country FROM transactions_1k AS t1 INNER JOIN gasstations AS t2 ON t1.gasstationid = t2.gasstationid WHERE t1.productid = 2 ORDER BY t1.price DESC LIMIT 1
|
170
|
debit_card_specializing
|
bird
|
For all the people who paid more than 29.00 per unit of product id No.5. Give their consumption status in the August of 2012.
|
dev
|
medium
|
SELECT t2.consumption FROM transactions_1k AS t1 INNER JOIN yearmonth AS t2 ON t1.customerid = t2.customerid WHERE CAST(t1.price AS REAL) / t1.amount > 29.00 AND t1.productid = 5 AND t2.date = '201208'
|
171
|
regional_sales
|
bird
|
Which region has the most number of sales team?
|
train
|
hard
|
select region from `sales team` group by region order by count(distinct `sales team`) desc limit 1
|
172
|
regional_sales
|
bird
|
List all the customers with name containing the word 'Group'.
|
train
|
easy
|
select t from ( select iif(`customer names` like '%group%', `customer names`, null) as t from customers ) where t is not null
|
173
|
regional_sales
|
bird
|
What is the average median income for all City type of stores?
|
train
|
easy
|
select avg(`median income`) from `store locations` where type = 'city'
|
174
|
regional_sales
|
bird
|
Name the sales team and the region of order number 'SO - 000137'.
|
train
|
hard
|
select t2.`sales team`, t2.region from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.ordernumber = 'so - 000137'
|
175
|
regional_sales
|
bird
|
List all the order numbers along with its product name for each order under the sales team of 'Douglas Tucker'.
|
train
|
hard
|
select distinct t1.productid, t1.`product name` from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid inner join `sales team` as t3 on t3.salesteamid = t2._salesteamid where t3.`sales team` = 'douglas tucker'
|
176
|
regional_sales
|
bird
|
Among orders in 2020, name the customers who had the greatest discount applied for 'Cocktail Glasses'
|
train
|
hard
|
select distinct t1.`customer names` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join products as t3 on t3.productid = t2._productid where t3.`product name` = 'cocktail glasses' and substr(t2.orderdate, -2) = '20' and t2.`discount applied` = ( select t2.`discount applied` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join products as t3 on t3.productid = t2._productid where t3.`product name` = 'cocktail glasses' and t2.orderdate like '%/%/20' order by t2.`discount applied` desc limit 1 )
|
177
|
regional_sales
|
bird
|
List all the order numbers for In-Store sales and find the city where the store is located.
|
train
|
hard
|
select distinct t1.ordernumber, t2.`city name` from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.`sales channel` = 'in-store'
|
178
|
regional_sales
|
bird
|
Name the most expensive ordered? Who, when was it ordered?
|
train
|
hard
|
select t2.ordernumber, t1.`customer names`, t2.orderdate from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join products as t3 on t3.productid = t2._productid order by t2.`unit cost` desc limit 1
|
179
|
regional_sales
|
bird
|
List all the numbers ordered by 'Rochester Ltd' in 2018.
|
train
|
hard
|
select distinct t from ( select case when t1.orderdate like '%/%/18' and t2.`customer names` = 'rochester ltd' then t1.ordernumber else null end as t from `sales orders` t1 inner join customers t2 on t2.customerid = t1._customerid ) where t is not null
|
180
|
regional_sales
|
bird
|
Provide all the orders from WARE-NMK1003. Name the product and sales team for each of these order.
|
train
|
hard
|
select distinct t1.`product name`, t3.`sales team` from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid inner join `sales team` as t3 on t3.salesteamid = t2._salesteamid where t2.warehousecode = 'ware-nmk1003'
|
181
|
regional_sales
|
bird
|
List the name of all customers who had made orders online.
|
train
|
hard
|
select t from ( select case when t2.`sales channel` = 'online' then t1.`customer names` else null end as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) where t is not null
|
182
|
regional_sales
|
bird
|
Calculate the average net profit for bakeware product.
|
train
|
hard
|
select avg(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t2.`product name` = 'bakeware'
|
183
|
regional_sales
|
bird
|
Name the sales team name who had orders with the greatest net profit in 2020.
|
train
|
hard
|
select t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.orderdate like '%/%/20' group by t2.`sales team` order by sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) desc limit 1
|
184
|
regional_sales
|
bird
|
Sate the order number and calculate the net profit for each order under Joshua Bennett.
|
train
|
hard
|
select t1.ordernumber , replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.`sales team` = 'joshua bennett'
|
185
|
regional_sales
|
bird
|
Among the sales order shipped in July 2018, calculate the percentage of orders for home fragrances.
|
train
|
hard
|
select sum(case when t2.`product name` = 'home fragrances' then 1 else 0 end) * 100 / count(t1.ordernumber) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.shipdate like '7/%/18'
|
186
|
regional_sales
|
bird
|
List down the customer IDs and names that start with alphabet "W".
|
train
|
easy
|
select distinct customerid, `customer names` from customers where `customer names` like 'w%' order by `customer names` desc
|
187
|
regional_sales
|
bird
|
List down the product IDs and names that include the word "Outdoor".
|
train
|
easy
|
select productid, t from ( select productid , case when `product name` like '%outdoor%' then `product name` else null end as t from products ) where t is not null order by t desc
|
188
|
regional_sales
|
bird
|
Among the sales with 40% discount via in-store channel, how many products were shipped from warehouse code of WARE-NMK1003?
|
train
|
easy
|
select count(distinct t) from ( select case when `sales channel` = 'in-store' and warehousecode = 'ware-nmk1003' and `discount applied` = '0.4' then ordernumber else null end as t from `sales orders` ) where t is not null
|
189
|
regional_sales
|
bird
|
Mention the most populated city and median income of the store in Florida state.
|
train
|
medium
|
select `city name`, `median income` from `store locations` where state = 'florida' order by population desc limit 1
|
190
|
regional_sales
|
bird
|
Describe the ID, city and region of the stores which are in Allen country.
|
train
|
hard
|
select distinct t2.storeid, t2.`city name`, t1.region from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t2.county = 'allen county'
|
191
|
regional_sales
|
bird
|
List the ID, city, state and region for the store type which is fewer between borough and CDP.
|
train
|
hard
|
select distinct t2.storeid, t2.`city name`, t1.state, t2.type from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t2.type = 'borough' or t2.type = 'cdp'
|
192
|
regional_sales
|
bird
|
Write down the region and name of the sale team ID of 18 and compare their orders between in-store and online.
|
train
|
hard
|
select t2.region, t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.salesteamid = 18 and t1.`sales channel` = 'in-store' or t1.`sales channel` = 'online'
|
193
|
regional_sales
|
bird
|
Calculate the percentage of order via in-store channel of customer "Medline".
|
train
|
hard
|
select cast(sum(case when t1.`sales channel` = 'in-store' then 1 else 0 end) as real) * 100 / count(t1._customerid) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where t2.`customer names` = 'medline '
|
194
|
regional_sales
|
bird
|
Describe the customer names and lasting delivery periods for the product of "Bedroom Furniture" by wholesale channel in 2019.
|
train
|
hard
|
select t1.`customer names`, t2.deliverydate from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join products as t3 on t3.productid = t2._productid where t2.`sales channel` = 'wholesale' and t3.`product name` = 'bedroom furniture' and t2.orderdate like '%/%/19'
|
195
|
regional_sales
|
bird
|
Describe the customer names and product names which had over 3800 USD in net profit.
|
train
|
hard
|
select distinct `customer names`, `product name` from ( select t1.`customer names`, t3.`product name` , replace(t2.`unit price`, ',', '') - replace(t2.`unit cost`, ',', '') as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid inner join products t3 on t3.productid = t2._productid ) where t > 3800
|
196
|
regional_sales
|
bird
|
List the store located cities with regions in no water area of California state.
|
train
|
hard
|
select distinct t2.`city name` from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t2.state = 'california' and t2.`water area` = '0'
|
197
|
regional_sales
|
bird
|
Calculate the order percentage by "Carlos Miller" sales team.
|
train
|
hard
|
select cast(sum(case when t2.`sales team` = 'carlos miller' then 1 else 0 end) as real) * 100 / count(t1.ordernumber) from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid
|
198
|
regional_sales
|
bird
|
Compare the number of orders between "Platters" and "Serveware" products.
|
train
|
hard
|
select sum(case when t2.`product name` = 'platters' then 1 else 0 end) as num1 , sum(case when t2.`product name` = 'serveware' then 1 else 0 end) as num2 from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid
|
199
|
regional_sales
|
bird
|
Calculate the total net profit of the store located in highest median income city.
|
train
|
hard
|
select sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid order by t2.`median income` desc limit 1
|
200
|
regional_sales
|
bird
|
Among the sales team in South region, write down the numbers of orders made by the sales team ID of one digit.
|
train
|
hard
|
select count(t1.ordernumber) from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.region = 'south' and t2.salesteamid between 1 and 9 group by t2.salesteamid having count(t1.ordernumber)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.