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
|
|---|---|---|---|---|---|---|
201
|
regional_sales
|
bird
|
How many orders have order date in 5/31/2018?
|
train
|
easy
|
select sum(iif(orderdate = '5/31/18', 1, 0)) from `sales orders`
|
202
|
regional_sales
|
bird
|
List out the name of orders which have delivery date of 6/13/2018.
|
train
|
easy
|
select distinct t from ( select iif(deliverydate = '6/13/18', ordernumber, null) as t from `sales orders` ) where t is not null
|
203
|
regional_sales
|
bird
|
How many orders placed were with more than 5 product quantities?
|
train
|
easy
|
select sum(iif(`order quantity` > 5, 1, 0)) from `sales orders`
|
204
|
regional_sales
|
bird
|
State the full name of state code "GA".
|
train
|
easy
|
SELECT t FROM (SELECT IIF(statecode = 'ga', state, NULL) AS t FROM regions) WHERE NOT t IS NULL
|
205
|
regional_sales
|
bird
|
How many states located in the Midwest region?
|
train
|
easy
|
SELECT COUNT(DISTINCT t) FROM (SELECT CASE WHEN region = 'midwest' THEN statecode ELSE NULL END AS t FROM regions) WHERE NOT t IS NULL
|
206
|
regional_sales
|
bird
|
List out the product name of order which has unit cost of 781.22.
|
train
|
hard
|
select t from ( select distinct iif(t1.`unit cost` = 781.22, t2.`product name`, null) as t from `sales orders` t1 inner join products t2 on t2.productid = t1._productid ) where t is not null
|
207
|
regional_sales
|
bird
|
State the delivery date of cookware.
|
train
|
hard
|
select t from ( select distinct iif(t2.`product name` = 'cookware', t1.deliverydate, null) as t from `sales orders` t1 inner join products t2 on t2.productid = t1._productid ) where t is not null
|
208
|
regional_sales
|
bird
|
How many furniture cushions orders which have date of order in 2018?
|
train
|
hard
|
select sum(case when t1.orderdate like '%/%/18' and t2.`product name` = 'furniture cushions' then 1 else 0 end) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid
|
209
|
regional_sales
|
bird
|
List out the name of products which have been applied 10% discount.
|
train
|
hard
|
select t from ( select distinct iif(t1.`discount applied` = 0.1, t2.`product name`, null) as t from `sales orders` t1 inner join products t2 on t2.productid = t1._productid ) where t is not null
|
210
|
regional_sales
|
bird
|
Calculate the average net profit of phones which have sales channel of distributor.
|
train
|
hard
|
select sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) / count(t1.ordernumber) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t2.`product name` = 'phones' and t1.`sales channel` = 'distributor'
|
211
|
regional_sales
|
bird
|
Calculate the average net profit of bar tools which has ordered quantity exceed 5.
|
train
|
hard
|
select sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) / count(t1.ordernumber) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t2.`product name` = 'bar tools' and t1.`order quantity` > 5
|
212
|
regional_sales
|
bird
|
List out the city name of states located in South region.
|
train
|
hard
|
select t from ( select distinct case when t1.region = 'south' then t2.`city name` end as t from regions t1 inner join `store locations` t2 on t2.statecode = t1.statecode ) where t is not null
|
213
|
regional_sales
|
bird
|
What is the region of stores which have type of "Town" in the list?
|
train
|
hard
|
select t from ( select distinct case when t2.type = 'town' then t1.region end as t from regions t1 inner join `store locations` t2 on t2.statecode = t1.statecode ) where t is not null
|
214
|
regional_sales
|
bird
|
How many orders that Medsep Group had made?
|
train
|
hard
|
select sum(case when t1.`customer names` = 'medsep group' then 1 else 0 end) from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid
|
215
|
regional_sales
|
bird
|
List out the discount levels applied for all orders from Ole Group.
|
train
|
hard
|
select t from ( select distinct case when t1.`customer names` = 'ole group' then t2.`discount applied` end as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) where t is not null
|
216
|
regional_sales
|
bird
|
State the customer name of orders which has shipped date in 7/8/2018.
|
train
|
hard
|
select t from ( select distinct case when t2.shipdate = '7/8/18' then t1.`customer names` end as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) where t is not null
|
217
|
regional_sales
|
bird
|
Among the orders placed by Ei, how many orders have quantity greater than 4?
|
train
|
hard
|
select sum(case when t1.`order quantity` > 4 and t2.`customer names` = 'ei ' then 1 else 0 end) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid
|
218
|
regional_sales
|
bird
|
Among the orders placed by Pacific Ltd, how many orders have been applied 5% discount ?
|
train
|
hard
|
select sum(case when t1.`discount applied` = 0.05 and t2.`customer names` = 'pacific ltd' then 1 else 0 end) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid
|
219
|
regional_sales
|
bird
|
What is the customer names of orders which have unit cost greater than 4000USD?
|
train
|
hard
|
select t from ( select distinct case when t2.`unit cost` > 4000 then t1.`customer names` end as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) where t is not null
|
220
|
regional_sales
|
bird
|
Please list the id and detailed position of all stores in Birmingham city.
|
train
|
easy
|
select storeid, latitude, longitude from `store locations` where `city name` = 'birmingham'
|
221
|
regional_sales
|
bird
|
Which city has the largest population?
|
train
|
hard
|
select `city name` from `store locations` order by population desc limit 1
|
222
|
regional_sales
|
bird
|
How many CDP stores are there in California?
|
train
|
easy
|
select sum(case when state = 'california' and type = 'cdp' then 1 else 0 end) from `store locations`
|
223
|
regional_sales
|
bird
|
Please give the order number and product name of the order which has the lowest unit price.
|
train
|
hard
|
select t1.ordernumber, t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where replace(t1.`unit price`, ',', '') = ( select replace(t1.`unit price`, ',', '') from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid order by replace(t1.`unit price`, ',', '') limit 1 )
|
224
|
regional_sales
|
bird
|
Which product has the highest net profit in 2019?
|
train
|
hard
|
select t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.orderdate like '%/%/19' order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') desc limit 1
|
225
|
regional_sales
|
bird
|
What is the average unit price of a Cookware product?
|
train
|
hard
|
select avg(replace(t1.`unit price`, ',', '')) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t2.`product name` = 'cookware'
|
226
|
regional_sales
|
bird
|
Please list all sale team names which had orders on 5/31/2018.
|
train
|
hard
|
select t from ( select distinct case when t1.orderdate = '5/31/18' then t2.`sales team` else null end as t from `sales orders` t1 inner join `sales team` t2 on t2.salesteamid = t1._salesteamid ) where t is not null
|
227
|
regional_sales
|
bird
|
Which sales team name has the least orders in 2019?
|
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 '%/%/19' group by t2.`sales team` order by count(t1.ordernumber) asc limit 1
|
228
|
regional_sales
|
bird
|
From 2018 to 2020, which year did the George Lewis group have the highest number of orders?
|
train
|
hard
|
select substr(t1.orderdate, -2, 2) from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.`sales team` = 'george lewis' group by substr(t1.orderdate, -2, 2) order by count(t1.ordernumber) desc limit 1
|
229
|
regional_sales
|
bird
|
What is the percentage of total orders from stores in Orange County in 2018?
|
train
|
hard
|
select cast(sum(case when t2.county = 'orange county' then 1 else 0 end) as real) * 100 / count(t1.ordernumber) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.orderdate like '%/%/18'
|
230
|
regional_sales
|
bird
|
Which order number has the highest unit price?
|
train
|
medium
|
select ordernumber from `sales orders` where replace(`unit price`, ',', '') = ( select replace(`unit price`, ',', '') from `sales orders` order by replace(`unit price`, ',', '') desc limit 1 )
|
231
|
regional_sales
|
bird
|
Which sales team id has the highest number of orders in 2018?
|
train
|
medium
|
select _salesteamid from `sales orders` where orderdate like '%/%/18' group by _salesteamid order by count(_salesteamid) desc limit 1
|
232
|
regional_sales
|
bird
|
What is the unit cost of order SO - 000103?
|
train
|
easy
|
select distinct t from ( select iif(ordernumber = 'so - 000103', `unit cost`, null) as t from `sales orders` ) where t is not null
|
233
|
regional_sales
|
bird
|
In 2020, what were the total orders of all stores in Maricopa County?
|
train
|
hard
|
select sum(case when t2.county = 'maricopa county' and orderdate like '%/%/20' then 1 else 0 end) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid
|
234
|
regional_sales
|
bird
|
What is the detailed position of the store which has order SO - 000115?
|
train
|
hard
|
select t2.latitude, t2.longitude from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.ordernumber = 'so - 000115'
|
235
|
regional_sales
|
bird
|
Please calculate the total number of orders by each city in 2019.
|
train
|
hard
|
select count(t1.ordernumber) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.orderdate like '%/%/19' group by t2.`city name` having count(t1.ordernumber)
|
236
|
regional_sales
|
bird
|
Please list the names of customers who have total orders of over 3 in 2018.
|
train
|
hard
|
select distinct iif(count(t2.customerid) > 3, t2.`customer names`, null) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where t1.orderdate like '%/%/18' group by t1._customerid having count(t2.customerid)
|
237
|
regional_sales
|
bird
|
What were the total orders of Medsep Group from 2018 to 2020?
|
train
|
hard
|
select sum(case when substr(t1.orderdate, -2) in ('18', '19', '20') and t2.`customer names` = 'medsep group' then 1 else 0 end) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid
|
238
|
regional_sales
|
bird
|
Please list the customer names whose order quantity was more than 5 on 6/1/2018.
|
train
|
hard
|
select t from ( select distinct case when sum(t1.`order quantity`) > 5 then t2.`customer names` end as t from `sales orders` t1 inner join customers t2 on t2.customerid = t1._customerid where t1.orderdate = '6/1/18' group by t1._customerid ) where t is not null
|
239
|
regional_sales
|
bird
|
What is the percentage of total orders of Stephen Payne that had a net profit of over 1000?
|
train
|
hard
|
select cast(sum(case when replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') > 1000 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 where t2.`sales team` = 'stephen payne'
|
240
|
regional_sales
|
bird
|
How many sales team were from Northeast?
|
train
|
easy
|
select sum(case when region = 'northeast' then 1 else 0 end) from `sales team`
|
241
|
regional_sales
|
bird
|
State the name of all city in Maricopa County along with its latitude and longitude.
|
train
|
easy
|
select distinct `city name`, latitude, longitude from `store locations` where county = 'maricopa county'
|
242
|
regional_sales
|
bird
|
Which order have the highest unit cost?
|
train
|
medium
|
select ordernumber from `sales orders` where replace(`unit cost`, ',', '') = ( select replace(`unit cost`, ',', '') from `sales orders` order by replace(`unit cost`, ',', '') desc limit 1 )
|
243
|
regional_sales
|
bird
|
List all the name of products with the ID of 30 to 40.
|
train
|
easy
|
select t from ( select case when productid between 30 and 40 then `product name` else null end as t from products ) where t is not null
|
244
|
regional_sales
|
bird
|
Calculate ratio between the highest unit cost and the lowest unit cost?
|
train
|
medium
|
select ( select replace(`unit cost`, ',', '') from `sales orders` where replace(`unit cost`, ',', '') = ( select replace(`unit cost`, ',', '') from `sales orders` order by replace(`unit cost`, ',', '') desc limit 1 ) order by replace(`unit cost`, ',', '') desc limit 1 ) / ( select replace(`unit cost`, ',', '') from `sales orders` where replace(`unit cost`, ',', '') = ( select replace(`unit cost`, ',', '') from `sales orders` order by replace(`unit cost`, ',', '') asc limit 1 ) order by replace(`unit cost`, ',', '') asc limit 1 )
|
245
|
regional_sales
|
bird
|
Which product was ordered the most in 2018?
|
train
|
hard
|
select t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.orderdate like '%/%/18' group by t1._productid order by count(t1._productid) desc limit 1
|
246
|
regional_sales
|
bird
|
How many products sold by Adam Hernandez?
|
train
|
hard
|
select sum(case when t2.`sales team` = 'adam hernandez' then 1 else 0 end) from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid
|
247
|
regional_sales
|
bird
|
List all orders where its products were shipped from Daly City.
|
train
|
hard
|
select t from ( select distinct case when t2.`city name` = 'daly city' then t1.ordernumber end as t from `sales orders` t1 inner join `store locations` t2 on t2.storeid = t1._storeid ) where t is not null
|
248
|
regional_sales
|
bird
|
How many orders made by Rochester Ltd?
|
train
|
hard
|
select sum(case when t1.`customer names` = 'rochester ltd' then 1 else 0 end) from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid
|
249
|
regional_sales
|
bird
|
State the order number where Qualitest ordered the highest product quantity.
|
train
|
hard
|
select t1.ordernumber from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where t2.`customer names` = 'qualitest ' order by t1.`order quantity` desc limit 1
|
250
|
regional_sales
|
bird
|
List the order for all in-store sales along with the products sold.
|
train
|
hard
|
select distinct t1.ordernumber, t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.`sales channel` = 'in-store'
|
251
|
regional_sales
|
bird
|
How many online sales were made in May 2018 where products were shipped from Norman?
|
train
|
hard
|
select sum(case when t1.orderdate like '5/%/18' and t1.`sales channel` = 'online' and t2.`city name` = 'norman' then 1 else 0 end) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid
|
252
|
regional_sales
|
bird
|
Among the products sold in Maricopa County, which was the least sold?
|
train
|
hard
|
select t1.`product name` from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid inner join `store locations` as t3 on t3.storeid = t2._storeid where t3.county = 'maricopa county' order by t2.`order quantity` asc limit 1
|
253
|
regional_sales
|
bird
|
State all the order numbers for sales team of Samuel Fowler.
|
train
|
hard
|
select t from ( select distinct case when t2.`sales team` = 'samuel fowler' then t1.ordernumber else null end as t from `sales orders` t1 inner join `sales team` t2 on t2.salesteamid = t1._salesteamid ) where t is not null
|
254
|
regional_sales
|
bird
|
Find the number of baseball ordered in December 2017.
|
train
|
hard
|
select count(t2.ordernumber) from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid where t1.`product name` = 'baseball' and t2.orderdate like '12/%/18'
|
255
|
regional_sales
|
bird
|
Find the average number of ornaments sold each month in 2018.
|
train
|
hard
|
select cast(sum(t2.`order quantity`) as real) / 12 from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid where t1.`product name` = 'ornaments' and t2.orderdate like '%/%/18'
|
256
|
regional_sales
|
bird
|
Find the percentage of products that were shipped from Burbank in 2018?
|
train
|
hard
|
select cast(sum(case when t3.`city name` = 'burbank' then t2.`order quantity` else 0 end) as real) * 100 / sum(t2.`order quantity`) from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid inner join `store locations` as t3 on t3.storeid = t2._storeid where t2.orderdate like '%/%/18'
|
257
|
regional_sales
|
bird
|
What is the difference in order number from "WARE-MKL1006" and "WARE-NBV1002"?
|
train
|
easy
|
select sum(iif(warehousecode = 'ware-mkl1006', 1, 0)) - sum(iif(warehousecode = 'ware-nbv1002', 1, 0)) as difference from `sales orders`
|
258
|
regional_sales
|
bird
|
Describe the product names delivered in 2021 for the customer "Sundial".
|
train
|
hard
|
select t from ( select distinct case when t2.deliverydate like '%/%/21' and t1.`customer names` = 'sundial ' then t3.`product name` end 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 is not null
|
259
|
regional_sales
|
bird
|
Write down the store IDs and region of the state "Michigan".
|
train
|
hard
|
select distinct t2.storeid, t1.region from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t2.state = 'michigan'
|
260
|
regional_sales
|
bird
|
Compare the total number of orders between customer "Apollo Ltd" and "Pacific Ltd".
|
train
|
hard
|
select sum(case when t2.`customer names` = 'apollo ltd' then 1 else 0 end), sum(case when t2.`customer names` = 'pacific ltd' then 1 else 0 end) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid
|
261
|
regional_sales
|
bird
|
Find the store ID with more orders between "Aurora" and "Babylon" city.
|
train
|
hard
|
select t2.storeid from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t2.`city name` = 'aurora (township)' or t2.`city name` = 'babylon (town)' group by t2.storeid order by count(t1.ordernumber) desc limit 1
|
262
|
regional_sales
|
bird
|
List down the customer names and product names of the order made by "Anthony Torres" via distributor channel.
|
train
|
hard
|
select distinct t1.`customer names`, t4.`product name` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join `sales team` as t3 on t3.salesteamid = t2._salesteamid inner join products as t4 on t4.productid = t2._productid where t3.`sales team` = 'anthony torres' and t2.`sales channel` = 'distributor'
|
263
|
regional_sales
|
bird
|
Mention the customer names and IDs which ordered total net profit of above 5000 USD through online channel.
|
train
|
hard
|
select distinct `customer names`, customerid from ( select t2.`customer names`, t2.customerid , sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) as t from `sales orders` t1 inner join customers t2 on t2.customerid = t1._customerid where t1.`sales channel` = 'online' group by t2.customerid ) where t > 5000
|
264
|
regional_sales
|
bird
|
Find the net profit of the floral products which were delivered in 2021.
|
train
|
hard
|
select sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.deliverydate like '%/%/21' and t2.`product name` = 'floral'
|
265
|
regional_sales
|
bird
|
Count the number of orders made from the store in city with population of 3000000 to 4000000.
|
train
|
hard
|
select count(t1.ordernumber) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t2.population between 3000000 and 4000000
|
266
|
regional_sales
|
bird
|
Name the products via wholesale channel of the store under Pacific/Honolulu time zone.
|
train
|
hard
|
select t from ( select distinct case when t3.`time zone` = 'pacific/honolulu' and t2.`sales channel` = 'wholesale' then t1.`product name` else null end as t from products t1 inner join `sales orders` t2 on t2._productid = t1.productid inner join `store locations` t3 on t3.storeid = t2._storeid ) where t is not null
|
267
|
regional_sales
|
bird
|
List the order numbers and product names which were ordered on 6th June, 2018.
|
train
|
hard
|
select distinct ordernumber, `product name` from ( select iif(t2.orderdate = '6/6/18', t2.ordernumber, null) as 'ordernumber' , iif(t2.orderdate = '6/6/18', t1.`product name`, null) as 'product name' from products t1 inner join `sales orders` t2 on t2._productid = t1.productid ) where ordernumber is not null and `product name` is not null
|
268
|
regional_sales
|
bird
|
Find the average yearly order by customer Weimei Corp for 2018, 2019 and 2020.
|
train
|
hard
|
select count(t1.ordernumber) / 3 from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where (t1.orderdate like '%/%/18' and t2.`customer names` = 'weimei corp') or (t1.orderdate like '%/%/19' and t2.`customer names` = 'weimei corp') or (t1.orderdate like '%/%/20' and t2.`customer names` = 'weimei corp')
|
269
|
regional_sales
|
bird
|
Calculate the average monthly order and percentage of warehouse "WARE-NMK1003" in 2019. Among them, mention number of orders for floor lamps.
|
train
|
hard
|
select cast(sum(case when t2.warehousecode = 'ware-nmk1003' then 1 else 0 end) as real) / 12 , cast(sum(case when t2.warehousecode = 'ware-nmk1003' then 1 else 0 end) as real) * 100 / count(t2.ordernumber), count(case when t1.`product name` = 'floor lamps' and t2.warehousecode = 'ware-nmk1003' then t2.`order quantity` else null end) from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid where t2.orderdate like '%/%/19'
|
270
|
regional_sales
|
bird
|
Indicate the procured dates for the customer whose ID is 11.
|
train
|
easy
|
select distinct t from ( select iif(_customerid = 11, procureddate, null) as t from `sales orders` ) where t is not null
|
271
|
regional_sales
|
bird
|
How many orders through distributor were for the minimum quantity?
|
train
|
easy
|
select sum(case when `order quantity` = 1 and `sales channel` = 'distributor' then 1 else 0 end) from `sales orders`
|
272
|
regional_sales
|
bird
|
List by ID all sales teams that have sold products at a 10% discount in store.
|
train
|
easy
|
select distinct t from ( select case when `discount applied` = '0.1' and `sales channel` = 'in-store' then _salesteamid else null end as t from `sales orders` ) where t is not null
|
273
|
regional_sales
|
bird
|
How many Borough-type stores located in the city of Brooklyn have a population of less than 3 million?
|
train
|
easy
|
select sum(case when population < 3000000 and type = 'borough' and `city name` = 'brooklyn' then 1 else 0 end) from `store locations`
|
274
|
regional_sales
|
bird
|
How many states are in the Midwest region?
|
train
|
easy
|
SELECT COUNT(DISTINCT t) FROM (SELECT CASE WHEN region = 'midwest' THEN state ELSE NULL END AS t FROM regions) WHERE NOT t IS NULL
|
275
|
regional_sales
|
bird
|
What are the top 10 products with the highest net profit?
|
train
|
hard
|
select t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid group by t1._productid order by sum(replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '')) desc limit 10
|
276
|
regional_sales
|
bird
|
Indicate the name of the customers who have placed an order of 3 units in February 2018.
|
train
|
hard
|
select t from ( select distinct case when t2.`order quantity` = 3 and t2.orderdate like '2/%/18' then t1.`customer names` end as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) where t is not null
|
277
|
regional_sales
|
bird
|
What are the names of the sales teams that have served to customer Apotheca, Ltd?
|
train
|
hard
|
select distinct t3.`sales team` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join `sales team` as t3 on t3.salesteamid = t2._salesteamid where t1.`customer names` = 'apotheca, ltd'
|
278
|
regional_sales
|
bird
|
In which regions are the stores that have shipped products through the WARE-UHY1004 warehouse?
|
train
|
hard
|
select t from ( select distinct case when t3.warehousecode = 'ware-uhy1004' then t1.region end as t from regions t1 inner join `store locations` t2 on t2.statecode = t1.statecode inner join `sales orders` t3 on t3._storeid = t2.storeid ) where t is not null
|
279
|
regional_sales
|
bird
|
List all the cities where Shawn Torres sells Audio products.
|
train
|
hard
|
select t from ( select distinct case when t4.`product name` = 'audio' and t3.`sales team` = 'shawn torres' then t1.`city name` else null end as t from `store locations` t1 inner join `sales orders` t2 on t2._storeid = t1.storeid inner join `sales team` t3 on t3.salesteamid = t2._salesteamid inner join products t4 on t4.productid = t2._productid ) where t is not null
|
280
|
regional_sales
|
bird
|
Lists the name of the product and customer who placed an order on 10/21/18 and it was delivered on 11/21/19.
|
train
|
hard
|
select t3.`product name`, 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 t2.orderdate = '10/21/18' and t2.deliverydate = '11/21/19'
|
281
|
regional_sales
|
bird
|
How many stores procured products on October 27, 2018, in the city of Oregon?
|
train
|
hard
|
select sum(case when t1.procureddate = '10/27/18' and t2.`city name` = 'orlando' then 1 else 0 end) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid
|
282
|
regional_sales
|
bird
|
What sales channels are used the most in the 3 places with the highest median income?
|
train
|
hard
|
select `sales channel` from ( select t1.`sales channel` from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid order by t2.`median income` desc limit 3 ) group by `sales channel` order by count(`sales channel`) desc limit 1
|
283
|
regional_sales
|
bird
|
List the 5 sales teams that have made sales with the highest net profits.
|
train
|
hard
|
select t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') desc limit 5
|
284
|
regional_sales
|
bird
|
What is the highest discount applied by the store located in a city of the state of Colorado whose land area is 111039036.
|
train
|
hard
|
select max(t1.`discount applied`) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t2.state = 'colorado' and t2.`land area` = 111039036
|
285
|
regional_sales
|
bird
|
How many different time zones are there in the Northeast region?
|
train
|
hard
|
select count(distinct t2.`time zone`) from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t1.region = 'northeast'
|
286
|
regional_sales
|
bird
|
What type of store is most popular in the South?
|
train
|
hard
|
select distinct case when max(t2.population) then t2.type end from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode
|
287
|
regional_sales
|
bird
|
To which region does the sales team that has used the WARE-MKL1006 warehouse the most times for its shipments belong?
|
train
|
hard
|
select t2.region from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.warehousecode = 'ware-mkl1006' group by t2.region order by count(t1.ordernumber) desc limit 1
|
288
|
regional_sales
|
bird
|
In which city is the store with the highest sales order unit price located?
|
train
|
hard
|
select t2.`city name` from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where replace(t1.`unit price`, ',', '') = ( select replace(t1.`unit price`, ',', '') from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid order by replace(t1.`unit price`, ',', '') desc limit 1 ) order by replace(t1.`unit price`, ',', '') desc limit 1
|
289
|
regional_sales
|
bird
|
How many online purchases did Ole Group make in May 2019?
|
train
|
hard
|
select sum(case when t1.`sales channel` = 'online' and t2.`customer names` = 'ole group' and t1.orderdate like '5/%/19' then 1 else 0 end) from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid
|
290
|
regional_sales
|
bird
|
How many stores with less need for products, and purchased through a distributor, are located in Washtenaw County?
|
train
|
hard
|
select sum(case when t1.`order quantity` = 1 and t1.`sales channel` = 'distributor' and t2.county = 'washtenaw county' then 1 else 0 end) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid
|
291
|
regional_sales
|
bird
|
What is the least purchased product by stores in the city of Santa Clarita?
|
train
|
hard
|
select t1.`product name` from products as t1 inner join `sales orders` as t2 on t2._productid = t1.productid inner join `store locations` as t3 on t3.storeid = t2._storeid where t3.`city name` = 'santa clarita' group by t1.`product name` order by count(t1.`product name`) asc limit 1
|
292
|
regional_sales
|
bird
|
At what Latitude and Longitude is the store that has used the WARE-PUJ1005 warehouse the fewest times?
|
train
|
hard
|
select t2.latitude, t2.longitude from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.warehousecode = 'ware-puj1005' group by t2.storeid order by count(t1.warehousecode) asc limit 1
|
293
|
regional_sales
|
bird
|
What percentage of sell orders on 04/04/2020 were for the state of New York?
|
train
|
hard
|
select cast(sum(case when t2.state = 'new york' then 1 else 0 end) as real) * 100 / count(t1.ordernumber) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.orderdate = '4/4/20'
|
294
|
regional_sales
|
bird
|
What is the average land area of the cities in which stores that purchased products for a unit price of 998.30 are located?
|
train
|
hard
|
select avg(t2.`land area`) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t1.`unit price` = '998.30'
|
295
|
regional_sales
|
bird
|
What is the average household income in cities in the state of New Hampshire where there are stores of the type city?
|
train
|
hard
|
select avg(t2.`household income`) from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t2.state = 'new hampshire' and t2.type = 'city'
|
296
|
regional_sales
|
bird
|
How many sales teams are there in the Midwest?
|
train
|
easy
|
select sum(case when region = 'midwest' then 1 else 0 end) from `sales team`
|
297
|
regional_sales
|
bird
|
Indicate order numbers with an order date after 1/1/2018.
|
train
|
easy
|
select distinct t from ( select case when orderdate > '1/1/18' then ordernumber else null end as t from `sales orders` ) where t is not null
|
298
|
regional_sales
|
bird
|
How many sales channels does the sales team have in the Midwest?
|
train
|
hard
|
select count(t1.`sales channel`) from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.region = 'midwest'
|
299
|
regional_sales
|
bird
|
Which sales team has the other with the highest unit price?
|
train
|
hard
|
select t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where replace(t1.`unit price`, ',', '') = ( select replace(t1.`unit price`, ',', '') from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid order by replace(t1.`unit price`, ',', '') desc limit 1 ) order by replace(t1.`unit price`, ',', '') desc limit 1
|
300
|
regional_sales
|
bird
|
Which regions have online sales channels that have the most discounts?
|
train
|
hard
|
select t2.region from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.`sales channel` = 'online' order by t1.`discount applied` desc limit 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.