problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: From 2018 to 2020, which year did the George Lewis group have the highest number of orders?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the percentage of total orders from stores in Orange County in 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Which order number has the highest unit price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Price`, ',', '') = ( SELECT REPLACE(`Unit Price`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Price`, ',', '') DESC LIMIT 1 ) |
Write SQL query to solve given problem: Which sales team id has the highest number of orders in 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT _SalesTeamID FROM `Sales Orders` WHERE OrderDate LIKE '%/%/18' GROUP BY _SalesTeamID ORDER BY COUNT(_SalesTeamID) DESC LIMIT 1 |
Write SQL query to solve given problem: What is the unit cost of order SO - 000103?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT DISTINCT T FROM ( SELECT IIF(OrderNumber = 'SO - 000103', `Unit Cost`, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL |
Write SQL query to solve given problem: In 2020, what were the total orders of all stores in Maricopa County?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the detailed position of the store which has order SO - 000115?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Please calculate the total number of orders by each city in 2019.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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) |
Write SQL query to solve given problem: Please list the names of customers who have total orders of over 3 in 2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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) |
Write SQL query to solve given problem: What were the total orders of Medsep Group from 2018 to 2020?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Please list the customer names whose order quantity was more than 5 on 6/1/2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the percentage of total orders of Stephen Payne that had a net profit of over 1000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: How many sales team were from Northeast?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(CASE WHEN Region = 'Northeast' THEN 1 ELSE 0 END) FROM `Sales Team` |
Write SQL query to solve given problem: Which order have the highest unit cost?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 ) |
Write SQL query to solve given problem: List all the name of products with the ID of 30 to 40.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Calculate ratio between the highest unit cost and the lowest unit cost?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 ) |
Write SQL query to solve given problem: Which product was ordered the most in 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many products sold by Adam Hernandez?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many orders made by Rochester Ltd?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: State the order number where Qualitest ordered the highest product quantity.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many online sales were made in May 2018 where products were shipped from Norman?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Among the products sold in Maricopa County, which was the least sold?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Find the number of baseball ordered in December 2017.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Find the average number of ornaments sold each month in 2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Find the percentage of products that were shipped from Burbank in 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: What is the difference in order number from "WARE-MKL1006" and "WARE-NBV1002"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(IIF(WarehouseCode = 'WARE-MKL1006', 1, 0)) - SUM(IIF(WarehouseCode = 'WARE-NBV1002', 1, 0)) AS difference FROM `Sales Orders` |
Write SQL query to solve given problem: Describe the product names delivered in 2021 for the customer "Sundial".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Compare the total number of orders between customer "Apollo Ltd" and "Pacific Ltd".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Find the store ID with more orders between "Aurora" and "Babylon" city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Mention the customer names and IDs which ordered total net profit of above 5000 USD through online channel.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Find the net profit of the floral products which were delivered in 2021.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Count the number of orders made from the store in city with population of 3000000 to 4000000.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: List the order numbers and product names which were ordered on 6th June, 2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Find the average yearly order by customer Weimei Corp for 2018, 2019 and 2020.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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') |
Write SQL query to solve given problem: Calculate the average monthly order and percentage of warehouse "WARE-NMK1003" in 2019. Among them, mention number of orders for floor lamps.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Indicate the procured dates for the customer whose ID is 11.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT DISTINCT T FROM ( SELECT IIF(_CustomerID = 11, ProcuredDate, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL |
Write SQL query to solve given problem: How many orders through distributor were for the minimum quantity?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(CASE WHEN `Order Quantity` = 1 AND `Sales Channel` = 'Distributor' THEN 1 ELSE 0 END) FROM `Sales Orders` |
Write SQL query to solve given problem: List by ID all sales teams that have sold products at a 10% discount in store.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many Borough-type stores located in the city of Brooklyn have a population of less than 3 million?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(CASE WHEN Population < 3000000 AND Type = 'Borough' AND `City Name` = 'Brooklyn' THEN 1 ELSE 0 END) FROM `Store Locations` |
Write SQL query to solve given problem: What are the top 10 products with the highest net profit?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Indicate the name of the customers who have placed an order of 3 units in February 2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Lists the name of the product and customer who placed an order on 10/21/18 and it was delivered on 11/21/19.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: How many stores procured products on October 27, 2018, in the city of Oregon?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What sales channels are used the most in the 3 places with the highest median income?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: List the 5 sales teams that have made sales with the highest net profits.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the highest discount applied by the store located in a city of the state of Colorado whose land area is 111039036.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: To which region does the sales team that has used the WARE-MKL1006 warehouse the most times for its shipments belong?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: In which city is the store with the highest sales order unit price located?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many online purchases did Ole Group make in May 2019?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How many stores with less need for products, and purchased through a distributor, are located in Washtenaw County?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the least purchased product by stores in the city of Santa Clarita?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: At what Latitude and Longitude is the store that has used the WARE-PUJ1005 warehouse the fewest times?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What percentage of sell orders on 04/04/2020 were for the state of New York?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: What is the average land area of the cities in which stores that purchased products for a unit price of 998.30 are located?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: How many sales teams are there in the Midwest?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(CASE WHEN Region = 'Midwest' THEN 1 ELSE 0 END) FROM `Sales Team` |
Write SQL query to solve given problem: Indicate order numbers with an order date after 1/1/2018.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Which sales team has the other with the highest unit price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Which regions have online sales channels that have the most discounts?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Which Apollo Ltd customer's order number has the most expensive unit price, indicating the order date?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Which store in Arizona has the most net profit?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: How much more is the Florida store's computer product unit price than the Texas store?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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` = 'Computers' |
Write SQL query to solve given problem: Among sales teams in Midwest region, which sales team has an order quantity greater than 5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Please indicate store id in the state of California that have been applied 20% discount in store.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: List the name of the customer with the most number of order quantity from 2018 to 2020.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Please indicate total order quantity of product Candles and calculate the percentage of such product among all the orders.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 Locations` AS T3 ON T3.StoreID = T2._StoreID |
Write SQL query to solve given problem: How many sales teams are there in the Midwest?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(CASE WHEN Region = 'Midwest' THEN 1 ELSE 0 END) FROM `Sales Team` |
Write SQL query to solve given problem: How many online orders were shipped during the month of June 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT SUM(IIF(ShipDate LIKE '6/%/18' AND `Sales Channel` = 'Online', 1, 0)) FROM `Sales Orders` |
Write SQL query to solve given problem: How much is the discount applied to the order with the highest unit price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the name of the product with the highest net profit?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: In the Northeast region, what is the average household income for each city located in the state with the highest number of stores?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: In which region can you find the stores located in the state whose median income is no more than 30,000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: In the West, how many stores are there in the city whose land area is below 20,000,000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the name of the customer who purchased the product with the highest net profiit?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What is the detailed coordinates of the store where the product with the 4th highest profit were purchased from?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Between 2018 to 2020, what is the average amount of shipped orders per year under Carl Nguyen?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 LIKE '%/%/20') |
Write SQL query to solve given problem: What is the amount of discount applied to the product with the highest net profit and what is the name of the said product?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What are the names of the top 3 customers who paid the highest amount of price per order after discount?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Which sales channel was most preferred in commercializing products in January 2020 based on the number of orders placed?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT `Sales Channel` FROM `Sales Orders` WHERE OrderDate LIKE '1/%/20' GROUP BY `Sales Channel` ORDER BY COUNT(`Sales Channel`) DESC LIMIT 1 |
Write SQL query to solve given problem: Name the product that was registered in the sales order 'SO - 0005951'.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: Identify the store location and sales team who processed the sales order 'SO - 0001004'.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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' |
Write SQL query to solve given problem: Identify the top customer of the store located in Gilbert, Arizona based on net profit associated with the customer relationship in 2019.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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`, ',', '') DESC LIMIT 1 |
Write SQL query to solve given problem: How many sales orders were processed by the store located in Chandler in 2020?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | 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 |
Write SQL query to solve given problem: What was the best discount applied to sales orders in 2020?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | regional_sales | SELECT MAX(`Discount Applied`) FROM `Sales Orders` WHERE OrderDate LIKE '%/%/20' |
Write SQL query to solve given problem: What is the most consecutive games tied by Ebbsfleet as an away team in the 2008 season?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT COUNT(*) FROM matchs WHERE season = 2008 AND AwayTeam = 'Ebbsfleet' AND FTR = 'D' |
Write SQL query to solve given problem: Of all the divisions in the world, what percentage of them belong to England?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT CAST(COUNT(CASE WHEN country = 'England' THEN division ELSE NULL END) AS REAL) * 100 / COUNT(division) FROM divisions |
Write SQL query to solve given problem: What percentage of games won, games lost and games drawn does Cittadella have as a home team in total?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT CAST(COUNT(CASE WHEN FTR = 'H' THEN 1 ELSE NULL END) / COUNT(HomeTeam) AS REAL) * 100, CAST(COUNT(CASE WHEN FTR = 'A' THEN 1 ELSE NULL END) AS REAL) / COUNT(HomeTeam), CAST(COUNT(CASE WHEN FTR = 'D' THEN 1 ELSE NULL END) AS REAL) / COUNT(HomeTeam) FROM matchs WHERE HomeTeam = 'Cittadella' |
Write SQL query to solve given problem: Of all the teams that played as a team away against Caen in the 2010 season, which one has the highest winning percentage?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT AwayTeam FROM matchs WHERE HomeTeam = 'Caen' AND season = 2010 AND FTR = 'A' GROUP BY AwayTeam ORDER BY COUNT(AwayTeam) DESC LIMIT 1 |
Write SQL query to solve given problem: What percentage of matches played on 2005/07/30 belong to the F1 division?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT CAST(SUM(CASE WHEN Div = 'F1' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(Div) FROM matchs WHERE Date = '2005-07-30' |
Write SQL query to solve given problem: What percentage of all tied games did the Sassuolo team play in?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT CAST(SUM(CASE WHEN HomeTeam = 'Sassuolo' OR AwayTeam = 'Sassuolo' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(FTR) FROM matchs WHERE FTR = 'D' |
Write SQL query to solve given problem: What is the percentage whereby the away team scored 2 goals during the 2017 seasons?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT CAST(SUM(CASE WHEN FTAG = 2 THEN 1 ELSE 0 END) / COUNT(FTAG) AS REAL) * 100 FROM matchs WHERE season = 2017 |
Write SQL query to solve given problem: What is the name of all the teams that played in the EFL League One division?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT T1.HomeTeam,T1.AwayTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div=T2.division WHERE T2.name = 'EFL League One' and T1.Div = 'E2' |
Write SQL query to solve given problem: How many teams playing in divisions in Greece have ever scored 4 or more goals?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT COUNT(DISTINCT CASE WHEN T1.FTHG >= 4 THEN HomeTeam ELSE NULL end) + COUNT(DISTINCT CASE WHEN T1.FTAG >= 4 THEN AwayTeam ELSE NULL end) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.country = 'Greece' |
Write SQL query to solve given problem: How many matches played in the 2019 season of Scottish Championship league were ended with an equal result of 2-2?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2019 AND T2.name = 'Scottish Championship' AND T1.FTAG = 2 AND T1.FTHG = 2 |
Write SQL query to solve given problem: Which 2 Scottish teams scored 10 goals playing as a local team and in which seasons?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.country = 'Scotland' AND T1.FTHG = 10 |
Write SQL query to solve given problem: From the Spanish LaLiga division in the 2017 season, which team won the most times as a local team and by what percentage?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT T1.HomeTeam HWHT , CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(HomeTeam) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga' AND T2.country = 'Spain' AND T1.season = 2017 |
Write SQL query to solve given problem: How many teams that played in the 2012 season belong to any of the English divisions and what percentage play in each of the divisions?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT ( SELECT COUNT(T1.Div) AS total FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 ) AS num , CASE WHEN 1 THEN T.result END AS percentage FROM ( SELECT 100.0 * COUNT(T1.Div) / ( SELECT COUNT(T1.Div) FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 ) AS result FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 GROUP BY T2.division ) AS T |
Write SQL query to solve given problem: What is the highest final-time score across all divisions in the 2021 season? Which team was the team that made up that score?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | european_football_1 | SELECT ( SELECT MAX(MAX(FTAG), MAX(FTHG)) FROM matchs WHERE season = 2021 ) AS T1, AwayTeam FROM matchs WHERE season = 2021 AND FTHG = T1 OR FTAG = T1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.