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 |
|---|---|---|---|---|---|---|
301 | regional_sales | bird | Which Apollo Ltd customer's order number has the most expensive unit price, indicating the order date? | train | hard | select t1.ordernumber, t1.orderdate from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where t2.`customer names` = 'apollo ltd' order by t1.`unit price` desc limit 1 |
302 | regional_sales | bird | Provide order number, warehouse code of customers Elorac, Corp. | train | hard | select distinct t1.ordernumber, t1.warehousecode from `sales orders` as t1 inner join customers as t2 on t2.customerid = t1._customerid where t2.`customer names` = 'elorac, corp' |
303 | regional_sales | bird | Name of customers who have ordered Cocktail Glasses by online sales channel. | train | hard | select t from ( select distinct case when t3.`product name` = 'cocktail glasses' and t2.`sales channel` = 'online' then t1.`customer names` 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 |
304 | regional_sales | bird | Which store in Arizona has the most net profit? | train | hard | select t2.storeid from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid where t2.state = 'arizona' order by t1.`unit price` - t1.`unit cost` desc limit 1 |
305 | regional_sales | bird | How much more is the Florida store's computer product unit price than the Texas store? | train | hard | select sum(case when t3.state = 'florida' then t2.`unit price` else 0 end) - sum(case when t3.state = 'texas' then t2.`unit price` else 0 end) 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 t1.`product name` = 'com... |
306 | regional_sales | bird | Among sales teams in Midwest region, which sales team has an order quantity greater than 5? | train | hard | select distinct t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t2.region = 'midwest' and t1.`order quantity` > 5 |
307 | regional_sales | bird | Please indicate store id in the state of California that have been applied 20% discount in store. | train | hard | select t from ( select distinct case when t2.state = 'california' and t1.`sales channel` = 'in-store' and t1.`discount applied` = 0.2 then t2.storeid end as t from `sales orders` t1 inner join `store locations` t2 on t2.storeid = t1._storeid ) where t is not null |
308 | regional_sales | bird | List the name of the customer with the most number of order quantity from 2018 to 2020. | train | hard | select t1.`customer names` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid where t2.orderdate like '%/%/18' or t2.orderdate like '%/%/19' or t2.orderdate like '%/%/20' order by t2.`order quantity` desc limit 1 |
309 | regional_sales | bird | Please indicate total order quantity of product Candles and calculate the percentage of such product among all the orders. | train | hard | select sum(case when t1.`product name` = 'candles' then t2.`order quantity` else 0 end), cast(sum(case when t1.`product name` = 'candles' 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 l... |
310 | regional_sales | bird | Which region is Joshua Bennet located in? | train | easy | select t from ( select distinct case when `sales team` = 'joshua bennett' then region else null end as t from `sales team` ) where t is not null |
311 | regional_sales | bird | What is the store id of the store located in the most populous county? | train | easy | select case when max(population) then storeid end from `store locations` |
312 | 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` |
313 | regional_sales | bird | What is the type of store located in the city with the highest amount of water area? | train | easy | select case when max(`water area`) then type end from `store locations` |
314 | regional_sales | bird | How many online orders were shipped during the month of June 2018? | train | easy | select sum(iif(shipdate like '6/%/18' and `sales channel` = 'online', 1, 0)) from `sales orders` |
315 | regional_sales | bird | How much is the discount applied to the order with the highest unit price? | train | medium | select `discount applied` from `sales orders` where replace(`unit price`, ',', '') = ( select replace(`unit price`, ',', '') from `sales orders` order by replace(`unit price`, ',', '') desc limit 1 ) order by replace(`unit price`, ',', '') desc limit 1 |
316 | regional_sales | bird | What is the name of the product 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 order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') desc limit 1 |
317 | regional_sales | bird | In the Northeast region, what is the average household income for each city located in the state with the highest number of stores? | train | hard | select avg(t2.`household income`) from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode where t1.region = 'northeast' group by t2.state order by count(t2.storeid) desc limit 1 |
318 | regional_sales | bird | In which region can you find the stores located in the state whose median income is no more than 30,000? | train | hard | select t from ( select distinct case when t2.`median income` < 30000 then t1.region end as t from regions t1 inner join `store locations` t2 on t2.statecode = t1.statecode ) where t is not null |
319 | regional_sales | bird | In the West, how many stores are there in the city whose land area is below 20,000,000? | train | hard | select sum(case when t1.region = 'west' and t2.`land area` < 20000000 then 1 else 0 end) from regions as t1 inner join `store locations` as t2 on t2.statecode = t1.statecode |
320 | regional_sales | bird | What is the name of the customer who purchased the product with the highest net profiit? | train | hard | select `customer names` from ( select t1.`customer names`, t2.`unit price` - t2.`unit cost` as 'net profit' from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) order by `net profit` desc limit 1 |
321 | regional_sales | bird | In 2019, how many orders were shipped by the sales team with the highest number of orders in the said year? Provide the name of the sales team. | train | hard | select count(t1.ordernumber), t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.orderdate like '%/%/19' and t1.shipdate like '%/%/19' group by t2.`sales team` order by count(t1.ordernumber) desc limit 1 |
322 | regional_sales | bird | Among the products with an order quantity of no less than 5 that was shipped in the month of May 2019, what is the name of the product with the lowest net profit? | train | hard | select t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid where t1.`order quantity` > 5 and shipdate like '5/%/19' order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') asc limit 1 |
323 | regional_sales | bird | What is the detailed coordinates of the store where the product with the 4th highest profit were purchased from? | train | hard | select t2.latitude, t2.longitude from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') desc limit 3, 1 |
324 | regional_sales | bird | How many orders were shipped by the sales team with the highest amount of shipped orders in 2020? Give the name of the said sales team. | train | hard | select count(t1.ordernumber), t2.`sales team` from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where t1.shipdate like '%/%/20' group by t2.`sales team` order by count(t1.ordernumber) desc limit 1 |
325 | regional_sales | bird | Between 2018 to 2020, what is the average amount of shipped orders per year under Carl Nguyen? | train | hard | select cast(count(t1.ordernumber) as real) / 3 from `sales orders` as t1 inner join `sales team` as t2 on t2.salesteamid = t1._salesteamid where (t2.`sales team` = 'carl nguyen' and shipdate like '%/%/18') or (t2.`sales team` = 'carl nguyen' and shipdate like '%/%/19') or (t2.`sales team` = 'carl nguyen' and shipdate l... |
326 | regional_sales | bird | What is the amount of discount applied to the product with the highest net profit and what is the name of the said product? | train | hard | select t1.`unit price` * t1.`discount applied`, t2.`product name` from `sales orders` as t1 inner join products as t2 on t2.productid = t1._productid order by replace(t1.`unit price`, ',', '') - replace(t1.`unit cost`, ',', '') desc limit 1 |
327 | regional_sales | bird | What are the names of the top 3 customers who paid the highest amount of price per order after discount? | train | hard | select `customer names` from ( select t1.`customer names` , replace(t2.`unit price`, ',', '') * t2.`order quantity` - replace(t2.`unit price`, ',', '') * t2.`discount applied` as t from customers t1 inner join `sales orders` t2 on t2._customerid = t1.customerid ) order by t desc limit 3 |
328 | regional_sales | bird | Which sales channel was most preferred in commercializing products in January 2020 based on the number of orders placed? | train | medium | select `sales channel` from `sales orders` where orderdate like '1/%/20' group by `sales channel` order by count(`sales channel`) desc limit 1 |
329 | regional_sales | bird | Name the product that was registered in the sales order 'SO - 0005951'. | train | hard | select t from ( select distinct case when t2.ordernumber = 'so - 0005951' then t1.`product name` else null end as t from products t1 inner join `sales orders` t2 on t2._productid = t1.productid ) where t is not null |
330 | regional_sales | bird | Identify the store location and sales team who processed the sales order 'SO - 0001004'. | train | hard | select t3.`sales team`, t1.`city name` from `store locations` as t1 inner join `sales orders` as t2 on t2._storeid = t1.storeid inner join `sales team` as t3 on t3.salesteamid = t2._salesteamid where t2.ordernumber = 'so - 0001004' |
331 | regional_sales | bird | Identify the top customer of the store located in Gilbert, Arizona based on net profit associated with the customer relationship in 2019. | train | hard | select t1.`customer names` from customers as t1 inner join `sales orders` as t2 on t2._customerid = t1.customerid inner join `store locations` as t3 on t3.storeid = t2._storeid where t3.`city name` = 'gilbert' and t2.procureddate like '%/%/19' order by replace(t2.`unit price`, ',', '') - replace(t2.`unit cost`, ',', ''... |
332 | regional_sales | bird | How many sales orders were processed by the store located in Chandler in 2020? | train | hard | select sum(case when t2.`city name` = 'chandler' and t1.orderdate like '%/%/20' then 1 else 0 end) from `sales orders` as t1 inner join `store locations` as t2 on t2.storeid = t1._storeid |
333 | regional_sales | bird | What is the average household income of Glendale? | train | easy | select avg(`household income`) from `store locations` where `city name` = 'glendale' |
334 | regional_sales | bird | What was the best discount applied to sales orders in 2020? | train | medium | select max(`discount applied`) from `sales orders` where orderdate like '%/%/20' |
335 | sales | bird | How many sales ids are there for customer id 80? | train | easy | SELECT COUNT(salesid) FROM sales WHERE customerid = 80 |
336 | sales | bird | Count the total quantity for sales from id 1 to 10. | train | medium | SELECT SUM(quantity) FROM sales WHERE salesid BETWEEN 1 AND 10 |
337 | sales | bird | Calculate the average quantity per sales from sales id 20 to 30. | train | medium | SELECT AVG(quantity) FROM sales WHERE salesid BETWEEN 20 AND 30 |
338 | sales | bird | List down the product id for products with the highest quantity. | train | easy | SELECT DISTINCT productid FROM sales WHERE quantity = (SELECT MAX(quantity) FROM sales) |
339 | sales | bird | How many product ids have the lowest price? | train | easy | SELECT COUNT(DISTINCT productid) FROM products WHERE price = (SELECT MAX(price) FROM products) |
340 | sales | bird | List down product names of free gifts. | train | easy | SELECT name FROM products WHERE price = 0 |
341 | sales | bird | List down the product name for products from id 1 to 10. | train | medium | SELECT name FROM products WHERE productid BETWEEN 1 AND 10 |
342 | sales | bird | What is the name of the product with the lowest quantity? | train | hard | SELECT t2.name FROM sales AS t1 INNER JOIN products AS t2 ON t1.productid = t2.productid ORDER BY t1.quantity LIMIT 1 |
343 | sales | bird | How many customer ids have purchased Hex Nut 9? | train | hard | SELECT COUNT(t1.customerid) FROM sales AS t1 INNER JOIN products AS t2 ON t1.productid = t2.productid WHERE t2.name = 'hex nut 9' |
344 | sales | bird | Calculate the total sales ids that were sales of Flat Washer 8. | train | hard | SELECT COUNT(t1.salesid) FROM sales AS t1 INNER JOIN products AS t2 ON t1.productid = t2.productid WHERE t2.name = 'flat washer 8' |
345 | sales | bird | List down all of the product names that were placed by sales person with id 10. | train | hard | SELECT DISTINCT t1.name FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t2.salespersonid = 10 |
346 | sales | bird | List down the first name of customers who placed order for product id 1. | train | hard | SELECT t1.firstname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t2.productid = t3.productid WHERE t2.productid = 1 |
347 | sales | bird | What is the last name of the customer who placed an order for sales id 178? | train | hard | SELECT t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t2.salesid = 178 |
348 | sales | bird | List down product ids that were purchased by customers called Abby. | train | hard | SELECT DISTINCT t1.productid FROM sales AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t2.firstname = 'abby' |
349 | sales | bird | Write down all of the product ids that were placed by Meander. | train | hard | SELECT DISTINCT t2.productid FROM employees AS t1 INNER JOIN sales AS t2 ON t1.employeeid = t2.salespersonid WHERE t1.firstname = 'meander' |
350 | sales | bird | What is the last name of sales person for sales id 100? | train | hard | SELECT t1.lastname FROM employees AS t1 INNER JOIN sales AS t2 ON t1.employeeid = t2.salespersonid WHERE t2.salesid = 100 |
351 | sales | bird | What is the first name of employee who handled sales for customer called Abigail? | train | hard | SELECT DISTINCT t3.firstname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid WHERE t1.firstname = 'abigail' |
352 | sales | bird | How many free gifts have customer with id 11782 received? | train | hard | SELECT COUNT(t1.productid) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t2.customerid = 11782 AND t1.price = 0 |
353 | sales | bird | What is the full name of customers who dealt with sales person with id 5? | train | hard | SELECT t1.firstname, t1.middleinitial, t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t2.salespersonid = 5 |
354 | sales | bird | List down all of the sales IDs for sales handled by sales people with first name starting with alphabet "s". | train | hard | SELECT t1.salesid FROM sales AS t1 INNER JOIN employees AS t2 ON t1.salespersonid = t2.employeeid WHERE SUBSTRING(t2.firstname, 1, 1) = 's' |
355 | sales | bird | Among customers with IDs from 1 to 100, what is the highest price of products they purchased? | train | hard | SELECT t1.price FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t2.customerid BETWEEN 1 AND 100 ORDER BY t1.price DESC LIMIT 1 |
356 | sales | bird | Among customers with the last name of Valdez, who purchased the highest quantity? | train | hard | SELECT t1.firstname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t1.lastname = 'valdez' ORDER BY t2.quantity DESC LIMIT 1 |
357 | sales | bird | Sum up the number sales ids handled by employees called Morningstar, Heather and Dean. | train | hard | SELECT SUM(IIF(t2.firstname = 'morningstar', 1, 0)) + SUM(IIF(t2.firstname = 'heather', 1, 0)) + SUM(IIF(t2.firstname = 'dean', 1, 0)) AS num FROM sales AS t1 INNER JOIN employees AS t2 ON t1.salespersonid = t2.employeeid |
358 | sales | bird | Has Alex purchased product with id 498? | train | hard | SELECT IIF(t1.productid = 498, 'yes', 'no') FROM sales AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t2.firstname = 'alex' |
359 | sales | bird | Calculate the total price of products purchased by Adam. | train | hard | SELECT SUM(t3.price * t2.quantity) FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t2.productid = t3.productid WHERE t1.firstname = 'adam' |
360 | sales | bird | Calculate the total price for products from id 400 to 500. | train | hard | SELECT SUM(t1.price * t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.productid BETWEEN 400 AND 500 |
361 | sales | bird | Calculate the total quantity of products with name starting with alphabet "c". | train | hard | SELECT SUM(t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE SUBSTRING(t1.name, 1, 1) = 'c' |
362 | sales | bird | Calculate the total quantity of products purchased by customer called Adrian. | train | hard | SELECT SUM(t2.quantity) FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t1.firstname = 'adam' |
363 | sales | bird | List the product ID of the top five products, by descending order, in terms of price. | train | hard | SELECT productid FROM products ORDER BY price DESC LIMIT 5 |
364 | sales | bird | Among the products, how many of them are freebies? | train | easy | SELECT COUNT(productid) FROM products WHERE price = 0 |
365 | sales | bird | Write down the name of products whose sale quantity is more than 950. | train | hard | SELECT DISTINCT t1.name FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t2.quantity > 950 |
366 | sales | bird | What is the full name of employee who sold 1000 units? | train | hard | SELECT DISTINCT t2.firstname, t2.middleinitial, t2.lastname FROM sales AS t1 INNER JOIN employees AS t2 ON t1.salespersonid = t2.employeeid WHERE t1.quantity = 1000 |
367 | sales | bird | Tally the product name and quantity of the first ten sales. | train | hard | SELECT t3.name, t2.quantity FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t2.productid = t3.productid WHERE t2.salesid BETWEEN 1 AND 10 |
368 | sales | bird | What is the total sales amount for Reflector? | train | hard | SELECT SUM(t1.price * t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.name = 'reflector' |
369 | sales | bird | What is the best selling colour for HL Mountain Frame, 42? | train | hard | SELECT IIF(SUM(IIF(t1.name = 'hl mountain frame - silver, 42', t2.salesid, 0)) - SUM(IIF(t1.name = 'hl mountain frame - black, 42', t2.salesid, 0)) > 0, 'silver', 'black') FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid |
370 | sales | bird | What is the difference in price between HL Mountain Frame - Black, 42 and LL Mountain Frame - Black, 42? | train | easy | SELECT (SELECT price FROM products WHERE name = 'hl mountain frame - black, 42') - (SELECT price FROM products WHERE name = 'll mountain frame - black, 42') AS num |
371 | sales | bird | Calculate the total number of sales closed by Michel E. DeFrance? | train | hard | SELECT COUNT(t1.salesid) FROM sales AS t1 INNER JOIN employees AS t2 ON t1.salespersonid = t2.employeeid WHERE t2.firstname = 'michel' AND t2.middleinitial = 'e' AND t2.lastname = 'defrance' |
372 | sales | bird | What is the average number of customers per sales person? | train | hard | SELECT CAST(COUNT(t1.customerid) AS REAL) / COUNT(t3.employeeid) FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid |
373 | sales | bird | Among all customers handled by Innes E. del Castillo, how many have purchased Short-Sleeve Classic Jersey, L? | train | hard | SELECT COUNT(t2.customerid) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid WHERE t3.firstname = 'innes' AND t3.lastname = 'del castillo' AND t1.name = 'short-sleeve classic jersey, l' AND t3.middleinitial = 'e' |
374 | sales | bird | Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48. | train | hard | SELECT DISTINCT t3.firstname, t3.middleinitial, t3.lastname FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid INNER JOIN customers AS t4 ON t2.customerid = t4.customerid WHERE t4.middleinitial = 'a' AND t4.lastname = 'white' AND t1.n... |
375 | sales | bird | How many sales people managed to sell Headlights - Weatherproof? | train | hard | SELECT COUNT(t2.salespersonid) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.name = 'headlights - weatherproof' |
376 | sales | bird | Calculate the revenue produced through sales of HL Road Frame - Red, 56. | train | hard | SELECT SUM(t2.quantity * t1.price) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.name = 'hl road frame - red, 56' |
377 | sales | bird | How many sales transactions were given by the customer named Joe L. Lopez? | train | hard | SELECT COUNT(t1.salesid) FROM sales AS t1 INNER JOIN customers AS t2 ON t1.customerid = t2.customerid WHERE t2.firstname = 'joe' AND t2.middleinitial = 'l' AND t2.lastname = 'lopez' |
378 | sales | bird | Name the customers who received 'Touring Rim' as a free gift. | train | hard | SELECT DISTINCT t1.firstname, t1.middleinitial, t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN products AS t3 ON t2.productid = t3.productid WHERE t3.name = 'touring rim' AND t3.price = 0 |
379 | sales | bird | Find the number of customers handled by each of the sales people. | train | hard | SELECT COUNT(customerid) FROM sales GROUP BY salespersonid |
380 | sales | bird | How many sales people are handling all the customers? | train | easy | SELECT COUNT(employeeid) FROM employees |
381 | sales | bird | Identify the name of the sales person with employee ID 7. | train | easy | SELECT firstname, middleinitial, lastname FROM employees WHERE employeeid = 7 |
382 | sales | bird | Name the most expensive and the least expensive products available, excluding free gifts. | train | easy | SELECT name FROM products WHERE price IN ((SELECT MAX(price) FROM products), (SELECT MIN(price) FROM products)) |
383 | sales | bird | Among all the customers who have purchased ML Bottom Bracket, identify the percentage of sales by Albert I. Ringer? | train | hard | SELECT CAST(CAST(SUM(IIF(t3.firstname = 'albert' AND t3.middleinitial = 'i' AND t3.lastname = 'ringer', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t2.customerid) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid WHERE t1.name = 'ml botto... |
384 | sales | bird | How many customers have the first name Abigail? | train | easy | SELECT COUNT(customerid) FROM customers WHERE firstname = 'abigail' |
385 | sales | bird | Indicate the quantity of Blade products sold. | train | hard | SELECT DISTINCT t2.quantity FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.name = 'blade' |
386 | sales | bird | Give the full name of the employee who has sold the most quantity. | train | hard | SELECT t1.firstname, t1.lastname FROM employees AS t1 INNER JOIN sales AS t2 ON t1.employeeid = t2.salespersonid ORDER BY t2.quantity DESC LIMIT 1 |
387 | sales | bird | List the full name of the customer who purchased the most quantity of products. | train | hard | SELECT t1.firstname, t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid ORDER BY t2.quantity DESC LIMIT 1 |
388 | sales | bird | What is the name of the product that is most sold by sale person id 20? | train | hard | SELECT t1.name FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t2.salespersonid = 20 ORDER BY t2.quantity DESC LIMIT 1 |
389 | sales | bird | List the first names of employees with trading quantity for more than 500. | train | hard | SELECT DISTINCT t1.firstname FROM employees AS t1 INNER JOIN sales AS t2 ON t1.employeeid = t2.salespersonid WHERE t2.quantity > 500 |
390 | sales | bird | List the first names of customers who have purchased products from sale person id 1. | train | hard | SELECT t1.firstname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t2.salespersonid = 1 |
391 | sales | bird | Calculate the total trading quantity of Abraham sold to Aaron Alexander. | train | hard | SELECT SUM(t2.quantity) FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid INNER JOIN employees AS t3 ON t2.salespersonid = t3.employeeid WHERE t2.salespersonid = 1 AND t1.firstname = 'aaron' AND t1.lastname = 'alexander' AND t3.firstname = 'abraham' |
392 | sales | bird | List the full names of customers who have purchased products in quantity over 600. | train | hard | SELECT t1.firstname, t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t2.quantity > 600 |
393 | sales | bird | Among the customers whose first name is Cameron, who bought the product in the most quantity? | train | hard | SELECT t1.firstname, t1.lastname FROM customers AS t1 INNER JOIN sales AS t2 ON t1.customerid = t2.customerid WHERE t1.firstname = 'cameron' ORDER BY t2.quantity DESC LIMIT 1 |
394 | sales | bird | Please provide sales ID for products named Hex Nut with a price greater than 100. | train | hard | SELECT t2.salesid FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.name LIKE 'hex nut%' AND t1.price > 100 |
395 | sales | bird | Identify customer IDs who bought products priced from 1000 to 2000. | train | hard | SELECT DISTINCT t2.customerid FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.price BETWEEN 1000 AND 2000 |
396 | sales | bird | Calculate the total quantity of products that are gifts. | train | hard | SELECT SUM(t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid WHERE t1.price = 0 |
397 | sales | bird | Calculate the quantity percentage of the gift products in the total trading quantity. | train | hard | SELECT CAST(CAST(SUM(IIF(t1.price = 0, t2.quantity, 0)) AS REAL) * 100 AS REAL) / SUM(t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid |
398 | sales | bird | Calculate the percentage of sold blades in the total number of transactions. | train | hard | SELECT CAST(CAST(SUM(IIF(t1.name = 'blade', t2.quantity, 0)) AS REAL) * 100 AS REAL) / SUM(t2.quantity) FROM products AS t1 INNER JOIN sales AS t2 ON t1.productid = t2.productid |
399 | sales | bird | How many of the employees have the last name "Ringer" ? | train | easy | SELECT COUNT(lastname) FROM employees WHERE lastname = 'ringer' |
400 | sales | bird | Among the products with product ID lower than 15, how many of them costs 10 and below? | train | medium | SELECT COUNT(productid) FROM products WHERE productid < 15 AND price <= 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.