id int32 5 100k | domain stringclasses 100
values | sql_complexity stringclasses 4
values | sql_task_type stringclasses 2
values | question stringlengths 20 272 | context stringlengths 40 1.66k | answer stringlengths 19 735 | sql_explanation stringlengths 30 967 | 1_context_extra stringlengths 109 2.14k | 2_context_extra stringlengths 198 2.73k |
|---|---|---|---|---|---|---|---|---|---|
26,314 | cannabis industry | single join | analytics and reporting | Which strains in Colorado were sold more than 10 times in a single day before 2022-01-01? | CREATE TABLE Strains (id INT, name TEXT, origin TEXT); CREATE TABLE Sales (strain_id INT, sale_date DATE, sales_count INT); INSERT INTO Sales (strain_id, sale_date, sales_count) VALUES (1, '2021-12-25', 15); INSERT INTO Sales (strain_id, sale_date, sales_count) VALUES (2, '2021-12-30', 12); INSERT INTO Sales (strain_id... | SELECT s.name FROM Strains s JOIN Sales sub ON s.id = sub.strain_id WHERE sub.sales_count > 10 AND sub.sale_date < '2022-01-01'; | The query uses a subquery to find strains with more than 10 sales in a single day before 2022-01-01. The outer query then joins this subquery with the Strains table to retrieve strain names. | CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50), Location VARCHAR(50), Spending DECIMAL(5,2)); CREATE TABLE Materials (MaterialID INT, MaterialName VARCHAR(50), Type VARCHAR(50)); CREATE TABLE ManufacturerMaterials (ManufacturerID INT, MaterialID INT, Quantity INT); INSERT INTO Manufacturer... | CREATE TABLE Strains (id INT, name TEXT, origin TEXT); CREATE TABLE Sales (strain_id INT, sale_date DATE, sales_count INT); INSERT INTO Sales (strain_id, sale_date, sales_count) VALUES (1, '2021-12-25', 15); INSERT INTO Sales (strain_id, sale_date, sales_count) VALUES (2, '2021-12-30', 12); INSERT INTO Sales (strain_id... |
97,148 | construction | single join | analytics and reporting | What is the total number of sustainable building projects in the state of California, along with their respective timelines? | CREATE TABLE sustainable_building (id INT, project_id INT, sustainable_practice VARCHAR(255), timeline FLOAT);CREATE TABLE project (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); | SELECT sustainable_building.id, project.name, sustainable_building.sustainable_practice, sustainable_building.timeline FROM sustainable_building INNER JOIN project ON sustainable_building.project_id = project.id WHERE project.state = 'California'; | The SQL query retrieves the total number of sustainable building projects in the state of California, along with their respective timelines, by performing an inner join between the sustainable_building and project tables on their respective id and project_id columns. It filters the results for rows where the state colu... | CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, policy_start_date DATE); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_start_date) VALUES (12345, 'Auto', 50000, '2022-01-01'); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_st... | CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, policy_start_date DATE); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_start_date) VALUES (12345, 'Auto', 50000, '2022-01-01'); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_st... |
13,862 | nonprofit | multiple_joins | analytics and reporting | List the names of all non-profits and the number of volunteers they have managed in the last 6 months. | CREATE TABLE non_profit (id INT, name TEXT); INSERT INTO non_profit (id, name) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'), (3, 'Doctors Without Borders'); CREATE TABLE volunteers (id INT, name TEXT, non_profit_id INT); INSERT INTO volunteers (id, name, non_profit_id) VALUES (1, 'John Doe', 1), (2, 'J... | SELECT n.name, COUNT(v.id) as num_volunteers FROM non_profit n INNER JOIN volunteers v ON n.id = v.non_profit_id INNER JOIN volunteer_management vm ON v.id = vm.volunteer_id WHERE vm.management_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY n.id; | This query performs an inner join between the non_profit table and the volunteers table, joining on the non_profit_id. It then performs another inner join between the volunteers table and the volunteer_management table, joining on the volunteer_id. Finally, it uses the COUNT function to count the number of volunteers f... | CREATE TABLE non_profit (id INT, name TEXT); INSERT INTO non_profit (id, name) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'), (3, 'Doctors Without Borders'); CREATE TABLE volunteers (id INT, name TEXT, non_profit_id INT); INSERT INTO volunteers (id, name, non_profit_id) VALUES (1, 'John Doe', 1), (2, 'J... | CREATE TABLE non_profit (id INT, name TEXT); INSERT INTO non_profit (id, name) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'), (3, 'Doctors Without Borders'); CREATE TABLE volunteers (id INT, name TEXT, non_profit_id INT); INSERT INTO volunteers (id, name, non_profit_id) VALUES (1, 'John Doe', 1), (2, 'J... |
73,698 | transportation | single join | analytics and reporting | Identify the busiest day of the week for public transportation in New York | CREATE TABLE day_of_week (day_id int, day_name varchar(10));CREATE TABLE public_transportation (ride_id int, day_id int, num_passengers int); | SELECT day_name, AVG(num_passengers) as avg_passengers FROM day_of_week JOIN public_transportation ON day_of_week.day_id = public_transportation.day_id GROUP BY day_name ORDER BY avg_passengers DESC LIMIT 1; | This query calculates the average number of passengers for each day of the week for public transportation, groups the results by day_name, and orders them in descending order by average number of passengers. The query then returns the day with the highest average number of passengers, limited to 1 result. | CREATE TABLE day_of_week (day_id int, day_name varchar(10));CREATE TABLE public_transportation (ride_id int, day_id int, num_passengers int); CREATE TABLE ingredients (id INT, name VARCHAR(255), type VARCHAR(255), quantity INT); INSERT INTO ingredients (id, name, type, quantity) VALUES (1, 'Tomatoes', 'Vegetarian', 50)... | CREATE TABLE day_of_week (day_id int, day_name varchar(10));CREATE TABLE public_transportation (ride_id int, day_id int, num_passengers int); CREATE TABLE ingredients (id INT, name VARCHAR(255), type VARCHAR(255), quantity INT); INSERT INTO ingredients (id, name, type, quantity) VALUES (1, 'Tomatoes', 'Vegetarian', 50)... |
22,027 | arts culture | multiple_joins | analytics and reporting | How many artworks were created by female artists in Spain? | CREATE TABLE Artists (id INT, name VARCHAR(50), gender VARCHAR(6)); INSERT INTO Artists (id, name, gender) VALUES (1, 'Picasso', 'male'), (2, 'Dali', 'male'), (3, 'Miró', 'male'), (4, 'Gaudí', 'male'), (5, 'Majano', 'female'); CREATE TABLE Artworks (id INT, artist_id INT, title VARCHAR(50)); INSERT INTO Artworks (id, a... | SELECT COUNT(*) FROM Artworks JOIN Artists ON Artworks.artist_id = Artists.id JOIN Countries ON Artists.country = Countries.name WHERE Artists.gender = 'female' AND Countries.name = 'Spain'; | Count the number of artworks created by female artists in Spain by joining Artworks, Artists, and Countries tables, filtering rows with artist gender female and country Spain. | CREATE TABLE Artists (id INT, name VARCHAR(50), gender VARCHAR(6)); INSERT INTO Artists (id, name, gender) VALUES (1, 'Picasso', 'male'), (2, 'Dali', 'male'), (3, 'Miró', 'male'), (4, 'Gaudí', 'male'), (5, 'Majano', 'female'); CREATE TABLE Artworks (id INT, artist_id INT, title VARCHAR(50)); INSERT INTO Artworks (id, a... | CREATE TABLE Artists (id INT, name VARCHAR(50), gender VARCHAR(6)); INSERT INTO Artists (id, name, gender) VALUES (1, 'Picasso', 'male'), (2, 'Dali', 'male'), (3, 'Miró', 'male'), (4, 'Gaudí', 'male'), (5, 'Majano', 'female'); CREATE TABLE Artworks (id INT, artist_id INT, title VARCHAR(50)); INSERT INTO Artworks (id, a... |
29,418 | sports | basic SQL | data retrieval | List the rugby union matches that took place in 2020 | CREATE TABLE matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), sport VARCHAR(20), date DATE); | SELECT * FROM matches WHERE sport = 'Rugby Union' AND YEAR(date) = 2020; | This query lists the rugby union matches that took place in 2020 by filtering matches by sport and year. | CREATE TABLE countries (id INT, name VARCHAR(50)); INSERT INTO countries (id, name) VALUES (1, 'Brazil'), (2, 'India'), (3, 'Indonesia'), (4, 'China'), (5, 'South Africa'); CREATE TABLE post_metrics (id INT, post_id INT, user_id INT, likes INT, comments INT, country_id INT); CREATE TABLE matches (id INT, home_team VARC... | CREATE TABLE countries (id INT, name VARCHAR(50)); INSERT INTO countries (id, name) VALUES (1, 'Brazil'), (2, 'India'), (3, 'Indonesia'), (4, 'China'), (5, 'South Africa'); CREATE TABLE post_metrics (id INT, post_id INT, user_id INT, likes INT, comments INT, country_id INT); CREATE TABLE Astronauts (AstronautID INT, Ag... |
58,780 | journalism | single join | analytics and reporting | List all news categories with their respective total views, ordered by the highest number of views first | CREATE TABLE categories (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE news_views (category_id INT, view_count INT); | SELECT categories.name, SUM(news_views.view_count) as total_views FROM categories INNER JOIN news_views ON categories.id = news_views.category_id GROUP BY categories.name ORDER BY total_views DESC; | The SQL query performs an inner join on the categories and news_views tables, based on the category_id foreign key. It then groups the results by the category name, calculating the total views for each. The results are ordered by the total views in descending order. | CREATE TABLE categories (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE news_views (category_id INT, view_count INT); CREATE TABLE visual_arts_programs (program_id INT PRIMARY KEY, program_name VARCHAR(50), program_type VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE visual_arts_participants (particip... | CREATE TABLE visual_arts_programs (program_id INT PRIMARY KEY, program_name VARCHAR(50), program_type VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE visual_arts_participants (participant_id INT PRIMARY KEY, participant_name VARCHAR(50), age INT, gender VARCHAR(50), program_id INT, FOREIGN KEY (program_id) R... |
23,665 | arts and culture | aggregation | analytics and reporting | How many female and non-binary individuals attended poetry readings compared to male attendees? | CREATE TABLE poetry_readings (attendee_id INT, gender TEXT); | SELECT CASE WHEN gender IN ('Female', 'Non-binary') THEN 'Female and Non-binary' ELSE 'Male' END AS gender, COUNT(*) FROM poetry_readings GROUP BY gender; | We categorize gender as 'Female and Non-binary' and 'Male' using the CASE statement, then count the number of attendees for each gender with the COUNT() function and GROUP BY clause. | CREATE TABLE poetry_readings (attendee_id INT, gender TEXT); CREATE TABLE season_stats (id INT, team VARCHAR(50), sport VARCHAR(20), season VARCHAR(10), home_runs INT); | CREATE TABLE poetry_readings (attendee_id INT, gender TEXT); CREATE TABLE season_stats (id INT, team VARCHAR(50), sport VARCHAR(20), season VARCHAR(10), home_runs INT); CREATE TABLE Suppliers (SupplierID int, Name varchar(50), Contact varchar(50), Industry varchar(50)); INSERT INTO Suppliers (SupplierID, Name, Contact,... |
96,555 | mining industry | basic SQL | analytics and reporting | How many accidents occurred in the South American mines in the last quarter? | CREATE TABLE Mines (MineID INT, Location VARCHAR(30), LastInspection DATE); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (1, 'Peru', '2021-01-01'); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (2, 'Brazil', '2021-04-01'); | SELECT COUNT(*) FROM Mines WHERE Location LIKE 'South%' AND LastInspection >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH); | This SQL query counts the number of mines in South America and filters the results to only include mines that have been inspected in the last quarter. It then counts the number of rows returned to get the total number of accidents. | CREATE TABLE GenreSong (GenreID INT, SongID INT); CREATE TABLE Mines (MineID INT, Location VARCHAR(30), LastInspection DATE); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (1, 'Peru', '2021-01-01'); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (2, 'Brazil', '2021-04-01'); | CREATE TABLE Mines (MineID INT, Location VARCHAR(30), LastInspection DATE); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (1, 'Peru', '2021-01-01'); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (2, 'Brazil', '2021-04-01'); CREATE TABLE GenreSong (GenreID INT, SongID INT); CREATE TABLE Cloth... |
51,176 | construction | single join | analytics and reporting | List the names of contractors who have completed at least 3 projects in the last year. | CREATE TABLE Contractors (ContractorID INT, ContractorName TEXT); CREATE TABLE Projects (ProjectID INT, ContractorID INT, ProjectType TEXT, StartDate DATE, EndDate DATE); | SELECT ContractorName FROM Contractors C JOIN Projects P ON C.ContractorID = P.ContractorID GROUP BY ContractorName HAVING COUNT(P.ProjectID) >= 3; | We join the Contractors and Projects tables and group the results by contractor name. Then, we filter the results to only include contractors who have completed at least 3 projects in the last year. | CREATE TABLE Mediterranean_Pollution_Sources (source_id integer, source_name text, source_type text); CREATE TABLE Pollution_Levels (source_id integer, pollution_level integer); INSERT INTO Mediterranean_Pollution_Sources (source_id, source_name, source_type) VALUES (1, 'Ship A', 'Oil Tanker'), (2, 'Factory X', 'Chemic... | CREATE TABLE Contractors (ContractorID INT, ContractorName TEXT); CREATE TABLE Projects (ProjectID INT, ContractorID INT, ProjectType TEXT, StartDate DATE, EndDate DATE); CREATE TABLE Mediterranean_Pollution_Sources (source_id integer, source_name text, source_type text); CREATE TABLE Pollution_Levels (source_id intege... |
17,189 | precision agriculture | multiple_joins | analytics and reporting | Find the total area and average phosphorus for farms using a drip irrigation system. | CREATE TABLE farm (id INT, name VARCHAR(50), size FLOAT, irrigation_system VARCHAR(20), fertilizer VARCHAR(50), PRIMARY KEY(id)); INSERT INTO farm (id, name, size, irrigation_system, fertilizer) VALUES (1, 'Farm A', 50.3, 'drip', 'Fertilizer X'); INSERT INTO farm (id, name, size, irrigation_system, fertilizer) VALUES (... | SELECT f.irrigation_system, SUM(f.size) AS total_area, AVG(p.phosphorus) AS avg_phosphorus FROM farm f INNER JOIN phosphorus p ON f.id = p.farm_id INNER JOIN fertilizer_application a ON f.id = a.farm_id WHERE f.irrigation_system = 'drip' GROUP BY f.irrigation_system; | This query joins the farm, phosphorus, and fertilizer_application tables on their common column farm_id. It filters the results to only show farms using a drip irrigation system (f.irrigation_system = 'drip'). Then, it groups the results by irrigation system (f.irrigation_system) and calculates the total area (SUM(f.si... | CREATE TABLE States (state_id INT, state_name TEXT); CREATE TABLE Providers (provider_id INT, provider_parity_score INT, state_id INT); CREATE TABLE farm (id INT, name VARCHAR(50), size FLOAT, irrigation_system VARCHAR(20), fertilizer VARCHAR(50), PRIMARY KEY(id)); INSERT INTO farm (id, name, size, irrigation_system, f... | CREATE TABLE States (state_id INT, state_name TEXT); CREATE TABLE Providers (provider_id INT, provider_parity_score INT, state_id INT); CREATE TABLE chemical_compounds (compound_id INT, name TEXT); CREATE TABLE product_compounds (compound_id INT, product_id INT); CREATE TABLE products (product_id INT, hazardous_flag BO... |
63,451 | chemicals | basic SQL | analytics and reporting | What is the average safety violation cost per chemical plant in India? | CREATE TABLE chemical_plants (plant_id INT, plant_name VARCHAR(50), country VARCHAR(50), safety_violation_cost DECIMAL(10,2)); INSERT INTO chemical_plants (plant_id, plant_name, country, safety_violation_cost) VALUES (1, 'Plant A', 'India', 5000), (2, 'Plant B', 'India', 7000), (3, 'Plant C', 'USA', 3000); | SELECT AVG(safety_violation_cost) FROM chemical_plants WHERE country = 'India'; | Calculate the average safety violation cost for plants located in India by averaging the safety_violation_cost column values where the country is 'India'. | CREATE TABLE researcher (id INT, name VARCHAR, expertise VARCHAR, affiliation VARCHAR); INSERT INTO researcher (id, name, expertise, affiliation) VALUES (5, 'Eve', 'Explainable AI', 'UniversityC'); INSERT INTO researcher (id, name, expertise, affiliation) VALUES (6, 'Frank', 'Creative AI', 'CompanyD'); CREATE TABLE che... | CREATE TABLE researcher (id INT, name VARCHAR, expertise VARCHAR, affiliation VARCHAR); INSERT INTO researcher (id, name, expertise, affiliation) VALUES (5, 'Eve', 'Explainable AI', 'UniversityC'); INSERT INTO researcher (id, name, expertise, affiliation) VALUES (6, 'Frank', 'Creative AI', 'CompanyD'); CREATE TABLE che... |
2,566 | arts and culture | multiple_joins | analytics and reporting | What is the percentage of repeat visitors for dance performances? | CREATE TABLE Visits (visit_id INT, visitor_id INT, event_id INT, visit_date DATE); CREATE TABLE Visitors (visitor_id INT, name VARCHAR(255), birthdate DATE); CREATE TABLE Events (event_id INT, name VARCHAR(255), date DATE); | SELECT 100.0 * COUNT(DISTINCT V.visitor_id) / COUNT(DISTINCT VV.visitor_id) FROM Visits V JOIN Visitors VV ON V.visitor_id = VV.visitor_id JOIN Events E ON V.event_id = E.event_id WHERE E.name LIKE '%Dance%' AND V.visit_id <> (SELECT MIN(visit_id) FROM Visits WHERE Visitors.visitor_id = VV.visitor_id); | This query calculates the percentage of repeat visitors for dance performances by joining the Visits, Visitors, and Events tables, filtering for dance events and distinct visitors, and calculating the percentage of repeat visitors. | CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score INT); INSERT INTO manufacturers (id, name, location, sustainability_score) VALUES (1, 'Manufacturer A', 'Location A', 85); INSERT INTO manufacturers (id, name, location, sustainability_score) VALUES (2, 'Manuf... | CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score INT); INSERT INTO manufacturers (id, name, location, sustainability_score) VALUES (1, 'Manufacturer A', 'Location A', 85); INSERT INTO manufacturers (id, name, location, sustainability_score) VALUES (2, 'Manuf... |
38,269 | mining | single join | analytics and reporting | Which coal mines in China have safety scores below 75? | CREATE TABLE mine_sites (id INT, name VARCHAR, type VARCHAR, location VARCHAR, PRIMARY KEY (id)); INSERT INTO mine_sites (id, name, type, location) VALUES (1, 'Datong Coal Mine', 'Coal', 'Shanxi, China'); CREATE TABLE safety_inspections (id INT, mine_id INT, safety_score INT, PRIMARY KEY (id), FOREIGN KEY (mine_id) REF... | SELECT ms.name, si.safety_score FROM mine_sites ms JOIN safety_inspections si ON ms.id = si.mine_id WHERE ms.type = 'Coal' AND si.safety_score < 75; | This query retrieves the names of coal mines in China with safety_score less than 75 by joining the mine_sites and safety_inspections tables on the mine_id column and filtering only coal mines in China. | CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Research'); INSERT INTO Programs (ProgramID, ProgramName) VALUES (2, 'Outreach'); CREATE TABLE Supplies (SupplyID INT, SupplyName TEXT, SupplyCost DECIMAL, PurchaseDate DATE); INSERT INTO Supplies (SupplyI... | CREATE TABLE mine_sites (id INT, name VARCHAR, type VARCHAR, location VARCHAR, PRIMARY KEY (id)); INSERT INTO mine_sites (id, name, type, location) VALUES (1, 'Datong Coal Mine', 'Coal', 'Shanxi, China'); CREATE TABLE safety_inspections (id INT, mine_id INT, safety_score INT, PRIMARY KEY (id), FOREIGN KEY (mine_id) REF... |
62,643 | fashion | aggregation | analytics and reporting | What was the total energy consumption for each factory in the past 6 months, ordered from highest to lowest? | CREATE TABLE sustainability_metrics (factory_id INT, energy_consumption FLOAT, measurement_date DATE); INSERT INTO sustainability_metrics (factory_id, energy_consumption, measurement_date) VALUES (1, 25000.5, '2021-09-01'), (2, 18000.3, '2021-09-01'), (3, 22000.0, '2021-02-01'); | SELECT factory_id, SUM(energy_consumption) as six_month_energy FROM sustainability_metrics WHERE measurement_date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY factory_id ORDER BY six_month_energy DESC; | This SQL query filters the 'sustainability_metrics' table for the past 6 months, then groups the results by factory_id. It sums the energy consumption for each factory in the past 6 months and orders the result set by total energy consumption in descending order to show the highest energy consumers. | CREATE TABLE sustainability_metrics (factory_id INT, energy_consumption FLOAT, measurement_date DATE); INSERT INTO sustainability_metrics (factory_id, energy_consumption, measurement_date) VALUES (1, 25000.5, '2021-09-01'), (2, 18000.3, '2021-09-01'), (3, 22000.0, '2021-02-01'); CREATE TABLE crime_stats (location VARCH... | CREATE TABLE crime_stats (location VARCHAR(50), year INT, drug_crime_rate FLOAT); INSERT INTO crime_stats (location, year, drug_crime_rate) VALUES ('Miami', 2020, 1200), ('Miami', 2019, 1300), ('Phoenix', 2020, 1500), ('Phoenix', 2019, 1600); CREATE TABLE sustainability_metrics (factory_id INT, energy_consumption FLOAT... |
12,313 | rural development | basic SQL | analytics and reporting | What are the names and locations of rural community development initiatives in Nepal funded by international organizations? | CREATE TABLE CommunityDevelopment (id INT, initiative_name TEXT, location TEXT, funder TEXT); INSERT INTO CommunityDevelopment (id, initiative_name, location, funder) VALUES (1, 'Rural Health Care Nepal', 'Nepal', 'International Red Cross'); INSERT INTO CommunityDevelopment (id, initiative_name, location, funder) VALUE... | SELECT initiative_name, location FROM CommunityDevelopment WHERE funder != 'Government of Nepal' AND location = 'Nepal'; | This SQL query selects the initiative_name and location columns from the CommunityDevelopment table, filters the rows where the funder is not the Government of Nepal and where the location is Nepal. | CREATE TABLE CommunityDevelopment (id INT, initiative_name TEXT, location TEXT, funder TEXT); INSERT INTO CommunityDevelopment (id, initiative_name, location, funder) VALUES (1, 'Rural Health Care Nepal', 'Nepal', 'International Red Cross'); INSERT INTO CommunityDevelopment (id, initiative_name, location, funder) VALUE... | CREATE TABLE injuries (athlete_id INT, injury VARCHAR(255)); INSERT INTO injuries (athlete_id, injury) VALUES (1, 'Ankle Sprain'), (1, 'Knee Pain'), (2, 'Shoulder Dislocation'), (3, 'Ankle Sprain'), (3, 'Concussion'); CREATE TABLE attorneys (attorney_id INT, first_name VARCHAR(20)); INSERT INTO attorneys (attorney_id, ... |
41,451 | humanitarian aid | single join | analytics and reporting | What is the name and age of the youngest person who received food assistance in Afghanistan in 2021? | CREATE TABLE FoodAssistance (id INT, person_name VARCHAR(50), person_age INT, country VARCHAR(50), assistance_date DATE); INSERT INTO FoodAssistance (id, person_name, person_age, country, assistance_date) VALUES (1, 'John Doe', 25, 'Afghanistan', '2021-05-02'); CREATE TABLE People (id INT, person_name VARCHAR(50), pers... | SELECT People.person_name, MIN(FoodAssistance.person_age) AS youngest_age FROM FoodAssistance JOIN People ON FoodAssistance.person_name = People.person_name WHERE FoodAssistance.country = 'Afghanistan' AND FoodAssistance.assistance_date >= '2021-01-01' AND FoodAssistance.assistance_date <= '2021-12-31' GROUP BY People.... | This SQL query joins the FoodAssistance and People tables on the person_name column, filters for assistance in Afghanistan in 2021, and groups by person_name, selecting the minimum person_age within each group. | CREATE TABLE FoodAssistance (id INT, person_name VARCHAR(50), person_age INT, country VARCHAR(50), assistance_date DATE); INSERT INTO FoodAssistance (id, person_name, person_age, country, assistance_date) VALUES (1, 'John Doe', 25, 'Afghanistan', '2021-05-02'); CREATE TABLE People (id INT, person_name VARCHAR(50), pers... | CREATE TABLE posts (id INT, user_id INT, post_type VARCHAR(255), likes INT); CREATE TABLE households (id INT, head_of_household_gender VARCHAR(255), camp_id INT); INSERT INTO households (id, head_of_household_gender, camp_id) VALUES (1, 'Female', 1001), (2, 'Male', 1001), (3, 'Female', 1002); CREATE TABLE aid (id INT, ... |
68,340 | arts and culture | multiple_joins | analytics and reporting | What is the percentage of funding for workshops and classes from foundation sources? | CREATE TABLE funding_sources (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO funding_sources (id, name, type) VALUES (1, 'Foundation', 'foundation'), (2, 'Private', 'private'), (3, 'Corporate', 'corporate'); CREATE TABLE workshops (id INT, name VARCHAR(255), funding_source_id INT); INSERT INTO workshops (id... | SELECT (COUNT(CASE WHEN f.name = 'Foundation' AND t.type IN ('workshops', 'classes') THEN 1 END) * 100.0 / COUNT(*)) AS foundation_funding_percentage FROM funding_sources f JOIN workshops w ON f.id = w.funding_source_id JOIN classes c ON f.id = c.funding_source_id JOIN (VALUES ('workshops'), ('classes')) AS t(type) ON ... | We count the number of workshops and classes funded by foundations and divide it by the total number of workshops and classes to get the percentage of foundation funding. | CREATE TABLE Artworks (id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, artwork_id INT, gallery_id INT); CREATE TABLE Galleries (id INT, name VARCHAR(30), city VARCHAR(20)); INSERT INTO Galleries (id, name, city) VALUES (1, 'Gallery X', 'Paris'), (2, 'Gallery Y', 'Paris'), (3, 'Gallery Z', 'Paris'); CREATE... | CREATE TABLE Artworks (id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, artwork_id INT, gallery_id INT); CREATE TABLE Galleries (id INT, name VARCHAR(30), city VARCHAR(20)); INSERT INTO Galleries (id, name, city) VALUES (1, 'Gallery X', 'Paris'), (2, 'Gallery Y', 'Paris'), (3, 'Gallery Z', 'Paris'); CREATE... |
62,120 | rural health | basic SQL | analytics and reporting | What is the maximum number of patients served per medical facility in Nigeria? | CREATE TABLE medical_facilities_nigeria (id INT, name TEXT, patients INT); INSERT INTO medical_facilities_nigeria (id, name, patients) VALUES (1, 'Facility X', 5000); | SELECT MAX(patients) FROM medical_facilities_nigeria; | Find the maximum number of patients served per medical facility in Nigeria by selecting the maximum value of the 'patients' column from the 'medical_facilities_nigeria' table. | CREATE TABLE esg_factors (investment_id INT, e_score FLOAT, s_score FLOAT, g_score FLOAT); INSERT INTO esg_factors (investment_id, e_score, s_score, g_score) VALUES (13, 0.87, 0.90, 0.93), (14, 0.78, 0.82, 0.86), (15, 0.69, 0.73, 0.77), (16, 0.82, 0.86, 0.91); CREATE TABLE impact_investments (id INT, investment_name VA... | CREATE TABLE esg_factors (investment_id INT, e_score FLOAT, s_score FLOAT, g_score FLOAT); INSERT INTO esg_factors (investment_id, e_score, s_score, g_score) VALUES (13, 0.87, 0.90, 0.93), (14, 0.78, 0.82, 0.86), (15, 0.69, 0.73, 0.77), (16, 0.82, 0.86, 0.91); CREATE TABLE impact_investments (id INT, investment_name VA... |
55,625 | fine arts | basic SQL | analytics and reporting | Retrieve all exhibitions with a Surrealist theme. | CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), StartDate DATE, EndDate DATE, Theme VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Title, StartDate, EndDate, Theme) VALUES (1, 'Surrealism: The Dream World', '1936-11-12', '1937-02-28', 'Surrealism'); | SELECT Title FROM Exhibitions WHERE Theme = 'Surrealism'; | This query retrieves the titles of exhibitions with a Surrealist theme from the Exhibitions table based on the Theme column. | CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), StartDate DATE, EndDate DATE, Theme VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Title, StartDate, EndDate, Theme) VALUES (1, 'Surrealism: The Dream World', '1936-11-12', '1937-02-28', 'Surrealism'); CREATE TABLE sales (id INT, product_id INT, quant... | CREATE TABLE sales (id INT, product_id INT, quantity INT, price DECIMAL(5,2), country VARCHAR(50)); CREATE TABLE trends_2022 (id INT, product VARCHAR(20), sales INT); INSERT INTO trends_2022 (id, product, sales) VALUES (1, 'Jumpsuit', 1500); INSERT INTO trends_2022 (id, product, sales) VALUES (2, 'Tunic', 2200); CREATE... |
78,824 | rural health | multiple_joins | analytics and reporting | What is the prevalence of hypertension in rural areas, grouped by state and gender? | CREATE TABLE patients (patient_id INT, age INT, has_hypertension BOOLEAN, gender VARCHAR, state VARCHAR); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (1, 45, true, 'Female', 'California'); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (2, 50, true, 'Ma... | SELECT state, gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patients JOIN rural_areas ON patients.state = rural_areas.state) AS prevalence FROM patients JOIN rural_areas ON patients.state = rural_areas.state WHERE has_hypertension = true GROUP BY state, gender; | This query calculates the prevalence of hypertension in rural areas by joining the patients and rural_areas tables and dividing the number of patients with hypertension by the total number of patients in rural areas. The results are grouped by state and gender. | CREATE TABLE patients (patient_id INT, age INT, has_hypertension BOOLEAN, gender VARCHAR, state VARCHAR); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (1, 45, true, 'Female', 'California'); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (2, 50, true, 'Ma... | CREATE TABLE MedicalData (Id INT, Astronaut VARCHAR(50), Mission VARCHAR(50), DataPoint FLOAT); INSERT INTO MedicalData (Id, Astronaut, Mission, DataPoint) VALUES (1, 'Mark Watney', 'Ares 3', 120), (2, 'Mark Watney', 'Ares 3', 130), (3, 'Mark Watney', 'Ares 3', 110); CREATE TABLE Cultivators (CultivatorID int, Cultivat... |
34,352 | journalism | single join | analytics and reporting | What is the average number of comments on articles about education in the "LA Times"? | CREATE TABLE ArticleComments (id INT, article_id INT, comment TEXT, newspaper VARCHAR(20)); INSERT INTO ArticleComments (id, article_id, comment, newspaper) VALUES (1, 1, 'Great article!', 'LA Times'), (2, 2, 'I disagree with the author.', 'LA Times'), (3, 3, 'Very informative.', 'LA Times'); CREATE TABLE EducationArt... | SELECT AVG(COUNT(*)) FROM ArticleComments c1 JOIN ArticleComments c2 ON c1.article_id = c2.article_id GROUP BY c1.article_id HAVING c1.newspaper = 'LA Times' AND c1.publication BETWEEN '2022-01-01' AND '2022-01-31' AND c1.category = 'education'; | This query calculates the average number of comments on articles about education in the "LA Times" by filtering the "ArticleComments" and "EducationArticles" tables based on the "publication", "newspaper", and "category" columns, joining the two tables on the "article_id" column, grouping the results by the "article_id... | CREATE TABLE customer (customer_id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE debit_card (transaction_id INT, customer_id INT, value DECIMAL(10,2), timestamp TIMESTAMP, currency VARCHAR(3)); CREATE TABLE foreign_exchange (date DATE, currency VARCHAR(3), rate DECIMAL(10,4)); CREATE TABLE ArticleComments (... | CREATE TABLE ArticleComments (id INT, article_id INT, comment TEXT, newspaper VARCHAR(20)); INSERT INTO ArticleComments (id, article_id, comment, newspaper) VALUES (1, 1, 'Great article!', 'LA Times'), (2, 2, 'I disagree with the author.', 'LA Times'), (3, 3, 'Very informative.', 'LA Times'); CREATE TABLE EducationArt... |
39,665 | energy | single join | analytics and reporting | What is the average rating of appliances for each type and energy efficiency standard in the appliances and energy_efficiency_standards tables, where the year is between 2015 and 2020? | CREATE TABLE energy_efficiency_standards (id INT, standard VARCHAR(255), year INT, min_rating FLOAT); CREATE TABLE appliances (id INT, type VARCHAR(255), standard VARCHAR(255), rating FLOAT); INSERT INTO energy_efficiency_standards (id, standard, year, min_rating) VALUES (1, 'Energy Star', 2010, 0.5), (2, 'EU Energy La... | SELECT a.type, e.standard, AVG(a.rating) as avg_rating FROM appliances a INNER JOIN energy_efficiency_standards e ON a.standard = e.standard WHERE e.year BETWEEN 2015 AND 2020 GROUP BY a.type, e.standard; | This query calculates the average rating of appliances for each type and energy efficiency standard in the 'appliances' and 'energy_efficiency_standards' tables, where the standard year is between 2015 and 2020. It groups the results by appliance type and energy efficiency standard. | CREATE TABLE energy_efficiency_standards (id INT, standard VARCHAR(255), year INT, min_rating FLOAT); CREATE TABLE appliances (id INT, type VARCHAR(255), standard VARCHAR(255), rating FLOAT); INSERT INTO energy_efficiency_standards (id, standard, year, min_rating) VALUES (1, 'Energy Star', 2010, 0.5), (2, 'EU Energy La... | CREATE TABLE energy_efficiency_standards (id INT, standard VARCHAR(255), year INT, min_rating FLOAT); CREATE TABLE appliances (id INT, type VARCHAR(255), standard VARCHAR(255), rating FLOAT); INSERT INTO energy_efficiency_standards (id, standard, year, min_rating) VALUES (1, 'Energy Star', 2010, 0.5), (2, 'EU Energy La... |
65,583 | public health | aggregation | analytics and reporting | What is the minimum number of infectious disease tracking cases per month in urban areas, grouped by month? | CREATE TABLE infectious_disease_tracking_3 (id INT, location TEXT, cases_per_month INT, month TEXT); INSERT INTO infectious_disease_tracking_3 (id, location, cases_per_month, month) VALUES (1, 'Rural A', 10, 'January'), (2, 'Rural B', 15, 'February'), (3, 'Urban A', 20, 'March'), (4, 'Urban A', 5, 'April'); | SELECT month, MIN(cases_per_month) FROM infectious_disease_tracking_3 WHERE location = 'urban' GROUP BY month; | This query finds the minimum number of infectious disease tracking cases per month in urban areas, grouped by month, by filtering the 'location' column for the value 'urban', grouping by the 'month' column, and then applying the MIN aggregate function. | CREATE TABLE Astronaut_Collaboration (id INT, astronaut_id INT, collaborator_id INT, collaboration_date DATE); INSERT INTO Astronaut_Collaboration (id, astronaut_id, collaborator_id, collaboration_date) VALUES (1, 3, 4, '2021-06-23'); CREATE TABLE infectious_disease_tracking_3 (id INT, location TEXT, cases_per_month IN... | CREATE TABLE infectious_disease_tracking_3 (id INT, location TEXT, cases_per_month INT, month TEXT); INSERT INTO infectious_disease_tracking_3 (id, location, cases_per_month, month) VALUES (1, 'Rural A', 10, 'January'), (2, 'Rural B', 15, 'February'), (3, 'Urban A', 20, 'March'), (4, 'Urban A', 5, 'April'); CREATE TABL... |
95,473 | gaming | single join | analytics and reporting | What is the minimum age of players who have won in an FPS esports event? | CREATE TABLE PlayerWins (PlayerID INT, Age INT, EventID INT); INSERT INTO PlayerWins (PlayerID, Age, EventID) VALUES (1, 22, 1); CREATE TABLE EsportsEvents (EventID INT, Game VARCHAR(10)); INSERT INTO EsportsEvents (EventID, Game) VALUES (1, 'CS:GO'); | SELECT MIN(Age) FROM PlayerWins PW JOIN EsportsEvents EE ON PW.EventID = EE.EventID WHERE EE.Game LIKE '%FPS%'; | The SQL query finds the minimum age of players who have won in an FPS (First-Person Shooter) esports event. It does this by using the MIN function on the Age column, joining PlayerWins and EsportsEvents tables, filtering the data where Game contains 'FPS'. | CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, owner TEXT, ethical_manufacturing BOOLEAN); INSERT INTO factories (factory_id, name, location, owner, ethical_manufacturing) VALUES (1, 'Factory A', 'City A', 'Female', true), (2, 'Factory B', 'City B', 'Male', false), (3, 'Factory C', 'City C', 'Non-bin... | CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, owner TEXT, ethical_manufacturing BOOLEAN); INSERT INTO factories (factory_id, name, location, owner, ethical_manufacturing) VALUES (1, 'Factory A', 'City A', 'Female', true), (2, 'Factory B', 'City B', 'Male', false), (3, 'Factory C', 'City C', 'Non-bin... |
35,199 | oceans | basic SQL | analytics and reporting | What is the total number of deep-sea expeditions ('expedition') and their average budget ('budget')? | CREATE TABLE expedition (id INT, name VARCHAR(50), budget FLOAT); INSERT INTO expedition (id, name, budget) VALUES (1, 'Aurora Expedition', 5000000), (2, 'Antarctic Adventure', 7000000); | SELECT COUNT(expedition.id), AVG(expedition.budget) FROM expedition; | This query calculates the total number of deep-sea expeditions and their average budget by selecting the count and average of the 'budget' column in the 'expedition' table. | CREATE TABLE mines (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mines (id, name, location) VALUES (1, 'Big Hole', 'South Africa'); INSERT INTO mines (id, name, location) VALUES (2, 'Venetia', 'South Africa'); CREATE TABLE inspections (id INT PRIMARY KEY, mine_id INT, inspector_count INT, ... | CREATE TABLE expedition (id INT, name VARCHAR(50), budget FLOAT); INSERT INTO expedition (id, name, budget) VALUES (1, 'Aurora Expedition', 5000000), (2, 'Antarctic Adventure', 7000000); CREATE TABLE mines (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mines (id, name, location) VALUES (1, ... |
81,413 | ocean shipping | multiple_joins | analytics and reporting | List all ports and their corresponding regulatory authority for vessels flying the flag of Panama. | CREATE TABLE ports(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE vessels(id INT, name VARCHAR(255), flag VARCHAR(255), port_id INT); CREATE TABLE regulatory_authorities(id INT, name VARCHAR(255), country VARCHAR(255)); | SELECT ports.name, regulatory_authorities.name FROM ports INNER JOIN vessels ON ports.id = vessels.port_id INNER JOIN regulatory_authorities ON ports.country = regulatory_authorities.country WHERE vessels.flag = 'Panama'; | The SQL query performs inner joins on the 'ports', 'vessels', and 'regulatory_authorities' tables, using the 'id' column in the 'ports' table and the 'port_id' column in the 'vessels' table, as well as the 'country' column in the 'ports' and 'regulatory_authorities' tables. It then filters the results to only show port... | CREATE TABLE ports(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE vessels(id INT, name VARCHAR(255), flag VARCHAR(255), port_id INT); CREATE TABLE regulatory_authorities(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE production (chemical VARCHAR(20), month INT, year INT, cost FLOAT); INS... | CREATE TABLE ports(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE vessels(id INT, name VARCHAR(255), flag VARCHAR(255), port_id INT); CREATE TABLE regulatory_authorities(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE production (chemical VARCHAR(20), month INT, year INT, cost FLOAT); INS... |
39,116 | rural health | single join | analytics and reporting | What is the total number of dental visits in rural clinics in Montana in the past year? | CREATE TABLE dental_visits (visit_id INT, clinic_id INT, visit_date DATE); INSERT INTO dental_visits (visit_id, clinic_id, visit_date) VALUES (1, 1, '2022-02-01'), (2, 1, '2022-04-15'), (3, 2, '2022-03-25'), (4, 3, '2022-01-10'); CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (c... | SELECT COUNT(dv.visit_id) FROM dental_visits dv JOIN rural_clinics rc ON dv.clinic_id = rc.clinic_id WHERE rc.state = 'Montana' AND dv.visit_date BETWEEN DATEADD(year, -1, CURRENT_DATE) AND CURRENT_DATE; | Join the dental_visits and rural_clinics tables, filter Montana clinics, and calculate the total number of dental visits in the past year. | CREATE TABLE chemical_compounds (id INT, name VARCHAR(50), quantity INT);CREATE TABLE production_stages (id INT, name VARCHAR(50));CREATE TABLE plant_chemical_usage (plant_id INT, compound_id INT, stage_id INT, quantity INT); INSERT INTO manufacturing_plants (id, name) VALUES (1, 'Plant A'), (2, 'Plant B'); INSERT INTO... | CREATE TABLE dental_visits (visit_id INT, clinic_id INT, visit_date DATE); INSERT INTO dental_visits (visit_id, clinic_id, visit_date) VALUES (1, 1, '2022-02-01'), (2, 1, '2022-04-15'), (3, 2, '2022-03-25'), (4, 3, '2022-01-10'); CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (c... |
94,980 | sports entertainment | basic SQL | analytics and reporting | How many 'WNBA' and 'MLS' events were held in 'June'? | CREATE TABLE Events (event_id INT, event_name VARCHAR(255), team VARCHAR(255), month VARCHAR(255)); INSERT INTO Events VALUES (1, 'Match 1', 'WNBA', 'June'), (2, 'Match 2', 'MLS', 'June'); | SELECT COUNT(*) FROM Events WHERE (team = 'WNBA' OR team = 'MLS') AND month = 'June'; | This query calculates the number of 'WNBA' and 'MLS' events held in 'June'. It filters events by the specified teams and 'June' month and calculates the total number of events using the COUNT() function. | CREATE TABLE students (student_id INT, mental_health_score INT, improvement_1year INT); INSERT INTO students (student_id, mental_health_score, improvement_1year) VALUES (1, 60, 5), (2, 70, 10), (3, 50, 0), (4, 80, -2), (5, 40, 15); CREATE TABLE Events (event_id INT, event_name VARCHAR(255), team VARCHAR(255), month VAR... | CREATE TABLE students (student_id INT, mental_health_score INT, improvement_1year INT); INSERT INTO students (student_id, mental_health_score, improvement_1year) VALUES (1, 60, 5), (2, 70, 10), (3, 50, 0), (4, 80, -2), (5, 40, 15); CREATE TABLE volunteers (id INT, name TEXT, organization TEXT, sector TEXT); INSERT INTO... |
8,855 | sustainable energy | single join | analytics and reporting | List all the renewable energy projects in the 'West' region, along with their capacities and types. | CREATE TABLE Region (RegionID INT, RegionName VARCHAR(100)); INSERT INTO Region VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'West'); CREATE TABLE Project (ProjectID INT, ProjectName VARCHAR(100), RegionID INT); INSERT INTO Project VALUES (1, 'Solar Farm A', 4), (2, 'Wind Farm B', 4), (3, 'Hydro Plant... | SELECT ProjectName, ProjectType, Capacity FROM Project JOIN ProjectDetails ON Project.ProjectID = ProjectDetails.ProjectID WHERE RegionID = 4; | The SQL query filters the Project table based on the RegionID column, selecting only the rows where the region is 'West'. It returns the ProjectName, ProjectType, and Capacity columns for the matching rows by joining Project and ProjectDetails tables. | CREATE TABLE Region (RegionID INT, RegionName VARCHAR(100)); INSERT INTO Region VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'West'); CREATE TABLE Project (ProjectID INT, ProjectName VARCHAR(100), RegionID INT); INSERT INTO Project VALUES (1, 'Solar Farm A', 4), (2, 'Wind Farm B', 4), (3, 'Hydro Plant... | CREATE TABLE Vessels (VesselID INT, VesselName TEXT, FuelType TEXT); CREATE TABLE Ports (PortID INT, PortName TEXT, Country TEXT); CREATE TABLE Cargo (VesselID INT, PortID INT, CargoWeight INT); INSERT INTO Ports (PortID, PortName, Country) VALUES (1, 'Tokyo', 'Japan'), (2, 'Osaka', 'Japan'); INSERT INTO Vessels (Vesse... |
71,004 | legal services | basic SQL | analytics and reporting | What is the total number of cases handled by attorneys with a success rate greater than 75%? | CREATE TABLE attorney_outcomes (attorney_id INT, total_cases INT, successful_cases INT); INSERT INTO attorney_outcomes (attorney_id, total_cases, successful_cases) VALUES (1, 15, 12), (2, 10, 8), (3, 8, 6); | SELECT SUM(total_cases) FROM attorney_outcomes WHERE successful_cases / total_cases > 0.75; | The SQL query calculates the total number of cases handled by attorneys with a success rate greater than 75% from the attorney_outcomes table. | CREATE TABLE regulations (id INT, proposal TEXT, comments INT); INSERT INTO regulations (id, proposal, comments) VALUES (1, 'Regulation A', 50); INSERT INTO regulations (id, proposal, comments) VALUES (2, 'Regulation B', 100); CREATE TABLE attorney_outcomes (attorney_id INT, total_cases INT, successful_cases INT); INSE... | CREATE TABLE regulations (id INT, proposal TEXT, comments INT); INSERT INTO regulations (id, proposal, comments) VALUES (1, 'Regulation A', 50); INSERT INTO regulations (id, proposal, comments) VALUES (2, 'Regulation B', 100); CREATE TABLE attorney_outcomes (attorney_id INT, total_cases INT, successful_cases INT); INSE... |
3,879 | mental health | single join | analytics and reporting | What is the average session duration and number of sessions, grouped by patient gender? | CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (id, name, age, gender, condition) VALUES (3, 'Maria Garcia', 42, 'Female', 'Bipolar Disorder'); INSERT INTO patients (id, name, age, gender, condition) VALUES (4, 'Ahmed Khan', 30, 'Male', 'PTSD')... | SELECT gender, AVG(appointment_duration) as avg_session_duration, COUNT(*) as num_sessions FROM appointments JOIN patients ON appointments.patient_id = patients.id GROUP BY gender; | This query calculates the average session duration and number of sessions, grouped by patient gender. It uses the AVG function to calculate the average session duration, and the COUNT function to count the number of sessions. The GROUP BY clause is used to group the data by gender. The JOIN clause is used to join the a... | CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (id, name, age, gender, condition) VALUES (3, 'Maria Garcia', 42, 'Female', 'Bipolar Disorder'); INSERT INTO patients (id, name, age, gender, condition) VALUES (4, 'Ahmed Khan', 30, 'Male', 'PTSD')... | CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (id, name, age, gender, condition) VALUES (3, 'Maria Garcia', 42, 'Female', 'Bipolar Disorder'); INSERT INTO patients (id, name, age, gender, condition) VALUES (4, 'Ahmed Khan', 30, 'Male', 'PTSD')... |
12,961 | chemicals | multiple_joins | analytics and reporting | Identify the departments that have no machines and no chemicals and the employees working in those departments. | CREATE TABLE Departments (DepartmentID INT, DepartmentName VARCHAR(20)); INSERT INTO Departments (DepartmentID, DepartmentName) VALUES (5, 'Quality Control'), (6, 'Regulatory Affairs'), (7, 'Product Innovation'); CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Department VARCHAR(20)... | SELECT D.DepartmentName, Employees.FirstName, Employees.LastName FROM Departments D LEFT JOIN (Chemicals RIGHT JOIN Employees ON Chemicals.Department = Employees.Department) ON D.DepartmentName = Employees.Department WHERE Chemicals.Department IS NULL; | We select the DepartmentName column from the Departments table, the FirstName and LastName columns from the Employees table, and join the three tables on the Department column, filtering for rows where the Department has no chemicals. | CREATE TABLE Departments (DepartmentID INT, DepartmentName VARCHAR(20)); INSERT INTO Departments (DepartmentID, DepartmentName) VALUES (5, 'Quality Control'), (6, 'Regulatory Affairs'), (7, 'Product Innovation'); CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Department VARCHAR(20)... | CREATE TABLE ages (state CHAR(2), min_purchase_age INT); INSERT INTO ages (state, min_purchase_age) VALUES ('CA', 21), ('CO', 21), ('OR', 21), ('MI', 18); CREATE TABLE Departments (DepartmentID INT, DepartmentName VARCHAR(20)); INSERT INTO Departments (DepartmentID, DepartmentName) VALUES (5, 'Quality Control'), (6, 'R... |
66,310 | human resources | single join | analytics and reporting | List all training courses and the number of employees who have completed each one | CREATE TABLE training_courses(course_id INT, course_name VARCHAR(100)); INSERT INTO training_courses VALUES (1, 'SQL Fundamentals'), (2, 'Python Programming'), (3, 'Data Analysis'); | SELECT c.course_name, COUNT(tr.emp_id) as num_completions FROM training_courses c JOIN training_records tr ON c.course_id = tr.course_id GROUP BY c.course_name; | This query joins the training_courses and training_records tables on the course_id column. It groups the results by course name and calculates the number of employees who have completed each course. | CREATE TABLE supervision (student_id INT, faculty_id INT, department VARCHAR(255)); INSERT INTO supervision (student_id, faculty_id, department) VALUES (1001, 1001, 'physics'), (1002, 1002, 'physics'), (1003, 1001, 'physics'), (1004, 1003, 'biology'); CREATE TABLE faculty (id INT, name VARCHAR(255), department VARCHAR(... | CREATE TABLE training_courses(course_id INT, course_name VARCHAR(100)); INSERT INTO training_courses VALUES (1, 'SQL Fundamentals'), (2, 'Python Programming'), (3, 'Data Analysis'); CREATE TABLE supervision (student_id INT, faculty_id INT, department VARCHAR(255)); INSERT INTO supervision (student_id, faculty_id, depar... |
68,800 | blockchain | basic SQL | analytics and reporting | What is the average transaction value (in USD) for the 'Binance' platform, and what is the standard deviation? | CREATE TABLE transactions (platform VARCHAR(255), tx_value DECIMAL(10,2), tx_date DATE); INSERT INTO transactions (platform, tx_value, tx_date) VALUES ('Binance', 50.00, '2021-12-01'), ('Binance', 75.00, '2021-12-02'), ('Ethereum', 100.00, '2021-12-01'), ('Solana', 20.00, '2021-12-03'), ('Binance', 80.00, '2021-12-04')... | SELECT AVG(tx_value), STDDEV(tx_value) FROM transactions WHERE platform = 'Binance'; | This SQL query calculates the average and standard deviation of transaction values for the 'Binance' platform. It does so by selecting the average and standard deviation of the tx_value column from the transactions table, where the platform is 'Binance'. | CREATE TABLE transactions (platform VARCHAR(255), tx_value DECIMAL(10,2), tx_date DATE); INSERT INTO transactions (platform, tx_value, tx_date) VALUES ('Binance', 50.00, '2021-12-01'), ('Binance', 75.00, '2021-12-02'), ('Ethereum', 100.00, '2021-12-01'), ('Solana', 20.00, '2021-12-03'), ('Binance', 80.00, '2021-12-04')... | CREATE TABLE satellite_image (id INT, field_id INT, image_url TEXT, anomaly BOOLEAN, timestamp TIMESTAMP); CREATE TABLE field (id INT, type VARCHAR(20)); CREATE TABLE irrigation (id INT, farm_id INT, irrigation_amount INT); INSERT INTO irrigation (id, farm_id, irrigation_amount) VALUES (1, 1, 1000), (2, 2, 1500); CREAT... |
19,203 | automotive | basic SQL | data retrieval | List all auto shows in Europe. | CREATE TABLE AutoShows (Id INT, Name VARCHAR(255), Location VARCHAR(255)); INSERT INTO AutoShows (Id, Name, Location) VALUES (1, 'Auto Show 1', 'USA'), (2, 'Auto Show 2', 'Europe'), (3, 'Auto Show 3', 'Asia'); | SELECT * FROM AutoShows WHERE Location = 'Europe'; | The SQL query filters rows in the AutoShows table with the Location 'Europe' and returns all columns from the filtered rows. | CREATE TABLE AutoShows (Id INT, Name VARCHAR(255), Location VARCHAR(255)); INSERT INTO AutoShows (Id, Name, Location) VALUES (1, 'Auto Show 1', 'USA'), (2, 'Auto Show 2', 'Europe'), (3, 'Auto Show 3', 'Asia'); CREATE TABLE conferences (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), year INT); INSERT INTO c... | CREATE TABLE conferences (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), year INT); INSERT INTO conferences (id, name, location, year) VALUES (1, 'Climate Summit', 'Paris', 2015); INSERT INTO conferences (id, name, location, year) VALUES (2, 'Adaptation Conference', 'Tokyo', 2016); CREATE TABLE AutoShows (... |
33,921 | arts culture | aggregation | analytics and reporting | Which heritage sites were restored in 2020, and what was the total cost of restoration efforts? | CREATE TABLE heritage_sites (id INT, name VARCHAR(255), location VARCHAR(255), restoration_start_date DATE, restoration_end_date DATE, restoration_cost INT); | SELECT name, SUM(restoration_cost) as total_cost FROM heritage_sites WHERE restoration_end_date >= '2020-12-31' GROUP BY name; | This query selects heritage sites with a restoration end date on or after December 31, 2020, groups them by name, and then sums the restoration_cost column to find the total cost of restoration efforts for each site. | CREATE TABLE heritage_sites (id INT, name VARCHAR(255), location VARCHAR(255), restoration_start_date DATE, restoration_end_date DATE, restoration_cost INT); CREATE TABLE organization (org_id INT, org_name TEXT, state TEXT); INSERT INTO organization (org_id, org_name, state) VALUES (1, 'ABC Organization', 'California')... | CREATE TABLE heritage_sites (id INT, name VARCHAR(255), location VARCHAR(255), restoration_start_date DATE, restoration_end_date DATE, restoration_cost INT); CREATE TABLE organization (org_id INT, org_name TEXT, state TEXT); INSERT INTO organization (org_id, org_name, state) VALUES (1, 'ABC Organization', 'California')... |
12,262 | sports entertainment | basic SQL | analytics and reporting | How many fans attended football games in Los Angeles during 2022? | CREATE TABLE games (team VARCHAR(255), city VARCHAR(255), date DATE, attendance INT); INSERT INTO games (team, city, date, attendance) VALUES ('LA Rams', 'Los Angeles', '2022-09-08', 70000), ('LA Chargers', 'Los Angeles', '2022-09-11', 65000); | SELECT SUM(attendance) FROM games WHERE city = 'Los Angeles' AND YEAR(date) = 2022 AND sport = 'Football'; | This query calculates the total attendance for football games in Los Angeles during 2022 by summing the attendance column from the games table where the city is 'Los Angeles' and the year of the date is 2022. | CREATE TABLE campaigns (campaign_id INT, country VARCHAR(50)); INSERT INTO campaigns (campaign_id, country) VALUES (1, 'United States'), (2, 'Canada'), (3, 'Mexico'); CREATE TABLE games (team VARCHAR(255), city VARCHAR(255), date DATE, attendance INT); INSERT INTO games (team, city, date, attendance) VALUES ('LA Rams',... | CREATE TABLE games (team VARCHAR(255), city VARCHAR(255), date DATE, attendance INT); INSERT INTO games (team, city, date, attendance) VALUES ('LA Rams', 'Los Angeles', '2022-09-08', 70000), ('LA Chargers', 'Los Angeles', '2022-09-11', 65000); CREATE TABLE campaigns (campaign_id INT, country VARCHAR(50)); INSERT INTO c... |
21,632 | arctic research | aggregation | analytics and reporting | What are the three most common species of birds in Greenland? | CREATE TABLE greenland_birds(id INT, name VARCHAR(50), species VARCHAR(50)); INSERT INTO greenland_birds(id, name, species) VALUES (1, 'Snow Bunting', 'Plectrophenax nivalis'), (2, 'Common Raven', 'Corvus corax'), (3, 'Black-legged Kittiwake', 'Rissa tridactyla'), (4, 'Snow Bunting', 'Plectrophenax nivalis'), (5, 'Glau... | SELECT species, COUNT(*) num_occurrences FROM greenland_birds GROUP BY species ORDER BY num_occurrences DESC LIMIT 3; | Calculates the number of occurrences for each species in the greenland_birds table and returns the top three species with the highest number of occurrences. | CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT);CREATE TABLE social_media (sm_id INT, athlete_id INT, followers INT); INSERT INTO athletes (athlete_id, athlete_name, team_id) VALUES (1, 'Player1', 1), (2, 'Player2', 1); INSERT INTO social_media (sm_id, athlete_id, followers) VALUES (1, 1, ... | CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT);CREATE TABLE social_media (sm_id INT, athlete_id INT, followers INT); INSERT INTO athletes (athlete_id, athlete_name, team_id) VALUES (1, 'Player1', 1), (2, 'Player2', 1); INSERT INTO social_media (sm_id, athlete_id, followers) VALUES (1, 1, ... |
96,636 | technology | single join | analytics and reporting | What is the total number of accessible devices for people with disabilities? | CREATE TABLE devices (id INT, name VARCHAR(50), accessibility_rating INT);CREATE TABLE people (id INT, disability BOOLEAN, device_id INT); | SELECT COUNT(*) FROM devices d INNER JOIN people p ON d.id = p.device_id WHERE p.disability = true AND d.accessibility_rating > 6; | This query first joins the devices and people tables on the device_id column. It then filters the results where the person has a disability (true) and the accessibility rating of the device is greater than 6. Lastly, it counts the total number of records. | CREATE TABLE devices (id INT, name VARCHAR(50), accessibility_rating INT);CREATE TABLE people (id INT, disability BOOLEAN, device_id INT); CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE public_transportation (service_id INT, service_name VARCHAR(255), region_id INT, rating INT); CREATE TAB... | CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE public_transportation (service_id INT, service_name VARCHAR(255), region_id INT, rating INT); CREATE TABLE waste_management (service_id INT, service_name VARCHAR(255), region_id INT, rating INT); CREATE TABLE devices (id INT, name VARCHAR(50),... |
48,128 | financial services | single join | analytics and reporting | List clients with more than 10 transactions in the 'Asia' region's 'Technology' sector. | CREATE TABLE client (client_id INT, client_name VARCHAR(50), region VARCHAR(50)); CREATE TABLE transaction (transaction_id INT, client_id INT, sector VARCHAR(50), amount DECIMAL(10, 2)); INSERT INTO client (client_id, client_name, region) VALUES (1, 'John Lee', 'Asia'), (2, 'Sophia Chen', 'Asia'), (3, 'Mateo Lopez', 'E... | SELECT client_name FROM client c JOIN transaction t ON c.client_id = t.client_id WHERE c.region = 'Asia' AND sector = 'Technology' GROUP BY client_id HAVING COUNT(*) > 10; | First, we join the client and transaction tables on client_id. Then, we filter the rows for the 'Asia' region and 'Technology' sector. Next, we group the result set by client_id and use the HAVING clause to filter clients with more than 10 transactions. Lastly, we select the client_name column from the filtered result ... | CREATE TABLE Factories (id INT, risk VARCHAR, workers INT); CREATE TABLE client (client_id INT, client_name VARCHAR(50), region VARCHAR(50)); CREATE TABLE transaction (transaction_id INT, client_id INT, sector VARCHAR(50), amount DECIMAL(10, 2)); INSERT INTO client (client_id, client_name, region) VALUES (1, 'John Lee'... | CREATE TABLE Factories (id INT, risk VARCHAR, workers INT); CREATE TABLE client (client_id INT, client_name VARCHAR(50), region VARCHAR(50)); CREATE TABLE transaction (transaction_id INT, client_id INT, sector VARCHAR(50), amount DECIMAL(10, 2)); INSERT INTO client (client_id, client_name, region) VALUES (1, 'John Lee'... |
6,012 | gaming | single join | analytics and reporting | Display the PlayerName, GameName, and GameGraphics for players who play 'Galactic Conquest' | CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameName VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, GameName) VALUES (1, 'John Smith', 'Galactic Conquest'); INSERT INTO Players (PlayerID, PlayerName, GameName) VALUES (2, 'Jane Doe', 'Space Crusaders'); CREATE TABLE GameDesign (GameName VARCHAR... | SELECT p.PlayerName, gd.GameName, gd.GameGraphics FROM Players p INNER JOIN GameDesign gd ON p.GameName = gd.GameName WHERE p.GameName = 'Galactic Conquest'; | This query joins the Players table and GameDesign table on GameName, filters for records where the GameName is 'Galactic Conquest', and then selects the PlayerName, GameName, and GameGraphics columns. | CREATE TABLE WageIncreases (id INT, UnionID INT, Sector TEXT, WageIncreasePercentage DECIMAL, EffectiveDate DATE); CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameName VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, GameName) VALUES (1, 'John Smith', 'Galactic Conquest'); INSERT INTO Players (P... | CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameName VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, GameName) VALUES (1, 'John Smith', 'Galactic Conquest'); INSERT INTO Players (PlayerID, PlayerName, GameName) VALUES (2, 'Jane Doe', 'Space Crusaders'); CREATE TABLE GameDesign (GameName VARCHAR... |
61,750 | aquaculture | single join | analytics and reporting | What is the average quantity and average cost of feed supplied to each species, grouped by species and month? | CREATE TABLE FeedSupply (ID INT PRIMARY KEY, Supplier VARCHAR, SpeciesID INT, Quantity INT, DeliveryDate DATE, Cost FLOAT, FOREIGN KEY (SpeciesID) REFERENCES Species(ID)); INSERT INTO FeedSupply (ID, Supplier, SpeciesID, Quantity, DeliveryDate, Cost) VALUES (3, 'SustainableFeeds Inc.', 3, 700, '2022-04-01', 1200.00); | SELECT f.Name AS SpeciesName, f.Origin, fs.Supplier, AVG(fs.Quantity) AS AvgQuantity, AVG(fs.Cost) AS AvgCost, DATE_FORMAT(fs.DeliveryDate, '%%Y-%%m') AS Month FROM FeedSupply fs JOIN Species f ON fs.SpeciesID = f.ID GROUP BY f.Name, f.Origin, MONTH(fs.DeliveryDate), fs.Supplier; | Join FeedSupply and Species tables, group results by SpeciesName, Origin, Supplier, and month, and calculate the average Quantity and Cost. | CREATE TABLE FeedSupply (ID INT PRIMARY KEY, Supplier VARCHAR, SpeciesID INT, Quantity INT, DeliveryDate DATE, Cost FLOAT, FOREIGN KEY (SpeciesID) REFERENCES Species(ID)); INSERT INTO FeedSupply (ID, Supplier, SpeciesID, Quantity, DeliveryDate, Cost) VALUES (3, 'SustainableFeeds Inc.', 3, 700, '2022-04-01', 1200.00); C... | CREATE TABLE FeedSupply (ID INT PRIMARY KEY, Supplier VARCHAR, SpeciesID INT, Quantity INT, DeliveryDate DATE, Cost FLOAT, FOREIGN KEY (SpeciesID) REFERENCES Species(ID)); INSERT INTO FeedSupply (ID, Supplier, SpeciesID, Quantity, DeliveryDate, Cost) VALUES (3, 'SustainableFeeds Inc.', 3, 700, '2022-04-01', 1200.00); C... |
12,002 | sports entertainment | single join | analytics and reporting | Find the number of fans who attended at least one game and bought merchandise. | CREATE TABLE fans_merchandise (fan_id INT, game_id INT, merchandise_id INT); | SELECT COUNT(DISTINCT fan_id) FROM fans JOIN fans_merchandise ON fans.fan_id = fans_merchandise.fan_id; | The query calculates the number of fans who attended at least one game and bought merchandise by selecting the COUNT(DISTINCT fan_id) from fans table where fan_id is in the fans_merchandise table. | CREATE TABLE fans_merchandise (fan_id INT, game_id INT, merchandise_id INT); CREATE TABLE Astronauts (id INT, name VARCHAR(255), age INT); CREATE TABLE SpaceMissions (id INT, astronaut_id INT, mission VARCHAR(255)); CREATE TABLE MedicalRecords (id INT, astronaut_id INT, medical_condition VARCHAR(255)); | CREATE TABLE Astronauts (id INT, name VARCHAR(255), age INT); CREATE TABLE SpaceMissions (id INT, astronaut_id INT, mission VARCHAR(255)); CREATE TABLE MedicalRecords (id INT, astronaut_id INT, medical_condition VARCHAR(255)); CREATE TABLE Palestine (id INT, name TEXT, type TEXT, location TEXT); INSERT INTO Palestine (... |
32,152 | disability services | basic SQL | analytics and reporting | List all diversity training initiatives and their respective regions | CREATE TABLE inclusion_efforts (effort_id INT, effort_name VARCHAR(30), region VARCHAR(20)); INSERT INTO inclusion_efforts (effort_id, effort_name, region) VALUES (1, 'Accessible Buildings', 'North'), (2, 'Diversity Training', 'South'), (3, 'Inclusive Hiring', 'East'), (4, 'Community Outreach', 'West'), (5, 'Diversity ... | SELECT effort_name, region FROM inclusion_efforts WHERE effort_name = 'Diversity Training'; | This query selects the effort_name and region columns from the inclusion_efforts table where the effort_name is 'Diversity Training' to list all diversity training initiatives and their respective regions. | CREATE TABLE orders (id INT PRIMARY KEY, product_id INT, quantity INT, order_date DATE, price DECIMAL(5,2)); INSERT INTO orders (id, product_id, quantity, order_date, price) VALUES (1, 1, 2, '2021-06-01', 29.99), (2, 3, 1, '2021-06-03', 14.99), (3, 2, 3, '2021-06-05', 39.99); CREATE TABLE inclusion_efforts (effort_id I... | CREATE TABLE orders (id INT PRIMARY KEY, product_id INT, quantity INT, order_date DATE, price DECIMAL(5,2)); INSERT INTO orders (id, product_id, quantity, order_date, price) VALUES (1, 1, 2, '2021-06-01', 29.99), (2, 3, 1, '2021-06-03', 14.99), (3, 2, 3, '2021-06-05', 39.99); CREATE TABLE cities (id INT, name VARCHAR(2... |
12,729 | cultural preservation | single join | analytics and reporting | What is the total number of traditional art pieces preserved in each region? | CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT, ArtPieceName VARCHAR(50), RegionID INT); INSERT INTO Regions VALUES (1, 'RegionA'), (2, 'RegionB'), (3, 'RegionC'); INSERT INTO ArtPieces VALUES (1, 'ArtPieceA', 1), (2, 'ArtPieceB', 1), (3, 'ArtPieceC', 2), (4, 'ArtPie... | SELECT R.RegionName, COUNT(AP.ArtPieceID) AS TotalPieces FROM Regions R JOIN ArtPieces AP ON R.RegionID = AP.RegionID GROUP BY R.RegionName; | Join the Regions and ArtPieces tables, group by RegionName, and count the number of ArtPieceIDs for each RegionName. | CREATE TABLE ContractNegotiations (contract_id INT, contractor VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO ContractNegotiations (contract_id, contractor, start_date, end_date) VALUES (1, 'Z', '2021-01-01', '2021-12-31'); INSERT INTO ContractNegotiations (contract_id, contractor, start_date, end_date) VALU... | CREATE TABLE ContractNegotiations (contract_id INT, contractor VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO ContractNegotiations (contract_id, contractor, start_date, end_date) VALUES (1, 'Z', '2021-01-01', '2021-12-31'); INSERT INTO ContractNegotiations (contract_id, contractor, start_date, end_date) VALU... |
31,577 | healthcare | basic SQL | data retrieval | List all the trainings received by providers in 'New York' city. | CREATE TABLE ProviderTrainings (ID INT PRIMARY KEY, ProviderID INT, Training VARCHAR(50), Location VARCHAR(50), Date DATE); INSERT INTO ProviderTrainings (ID, ProviderID, Training, Location, Date) VALUES (1, 201, 'Cultural Competency', 'New York', '2019-01-01'); INSERT INTO ProviderTrainings (ID, ProviderID, Training, ... | SELECT * FROM ProviderTrainings WHERE Location = 'New York'; | This SQL query selects all columns from the ProviderTrainings table where the Location is 'New York'. It uses the = operator for comparison and * to select all columns. | CREATE TABLE City (cid INT, city_name VARCHAR(255)); INSERT INTO City (cid, city_name) VALUES (1, 'CityX'), (2, 'CityY'), (3, 'CityZ'); CREATE TABLE WasteData (wid INT, cid INT, year INT, waste_amount INT); INSERT INTO WasteData (wid, cid, year, waste_amount) VALUES (1, 3, 2018, 7000), (2, 3, 2019, 7500), (3, 3, 2021, ... | CREATE TABLE City (cid INT, city_name VARCHAR(255)); INSERT INTO City (cid, city_name) VALUES (1, 'CityX'), (2, 'CityY'), (3, 'CityZ'); CREATE TABLE WasteData (wid INT, cid INT, year INT, waste_amount INT); INSERT INTO WasteData (wid, cid, year, waste_amount) VALUES (1, 3, 2018, 7000), (2, 3, 2019, 7500), (3, 3, 2021, ... |
29,514 | music industry | single join | analytics and reporting | What is the average revenue per stream for a specific music festival? | CREATE TABLE StreamingData (StreamID INT, UserID INT, SongID INT, StreamDate DATE, Revenue DECIMAL(10,2)); INSERT INTO StreamingData VALUES (1, 1, 1001, '2022-01-01', 0.10), (2, 2, 1002, '2022-01-02', 0.15); CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), SongID INT); INSERT INTO Festivals VALUES (1,... | SELECT AVG(Revenue) FROM StreamingData JOIN Festivals ON StreamingData.SongID = Festivals.SongID WHERE Festivals.FestivalName = 'Coachella'; | This SQL query calculates the average revenue per stream for a specific music festival (Coachella). It does this by joining the StreamingData and Festivals tables on the SongID column. Then, it filters the results to only include rows where the FestivalName column in the Festivals table is 'Coachella'. Finally, it calc... | CREATE TABLE StreamingData (StreamID INT, UserID INT, SongID INT, StreamDate DATE, Revenue DECIMAL(10,2)); INSERT INTO StreamingData VALUES (1, 1, 1001, '2022-01-01', 0.10), (2, 2, 1002, '2022-01-02', 0.15); CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), SongID INT); INSERT INTO Festivals VALUES (1,... | CREATE TABLE StreamingData (StreamID INT, UserID INT, SongID INT, StreamDate DATE, Revenue DECIMAL(10,2)); INSERT INTO StreamingData VALUES (1, 1, 1001, '2022-01-01', 0.10), (2, 2, 1002, '2022-01-02', 0.15); CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), SongID INT); INSERT INTO Festivals VALUES (1,... |
2,553 | rural health | single join | analytics and reporting | What is the percentage of rural clinics in Texas that offer telehealth services? | CREATE TABLE clinic_info (clinic_id INT, state VARCHAR(2), has_telehealth BOOLEAN); INSERT INTO clinic_info (clinic_id, state, has_telehealth) VALUES (1, 'Texas', true), (2, 'Texas', true), (3, 'Oklahoma', false); CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (clinic_id, state)... | SELECT (COUNT(*) FILTER (WHERE has_telehealth = true) * 100.0 / COUNT(*)) FROM clinic_info ci JOIN rural_clinics rc ON ci.clinic_id = rc.clinic_id WHERE rc.state = 'Texas'; | Join the clinic_info and rural_clinics tables, filter Texas clinics, and calculate the percentage of rural clinics that offer telehealth services. | CREATE TABLE clinic_info (clinic_id INT, state VARCHAR(2), has_telehealth BOOLEAN); INSERT INTO clinic_info (clinic_id, state, has_telehealth) VALUES (1, 'Texas', true), (2, 'Texas', true), (3, 'Oklahoma', false); CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (clinic_id, state)... | CREATE TABLE clients (id INT, registered_date DATE);CREATE TABLE investments (id INT, client_id INT, investment_date DATE); INSERT INTO clients (id, registered_date) VALUES (1, '2020-01-01'), (2, '2019-01-01'), (3, '2018-01-01'), (4, '2017-01-01'), (5, '2016-01-01'); INSERT INTO investments (id, client_id, investment_d... |
7,374 | human resources | multiple_joins | analytics and reporting | List all employees and their corresponding job titles, with department names included | CREATE TABLE job_titles(job_id INT, job_title VARCHAR(50)); INSERT INTO job_titles VALUES (1, 'Manager'), (2, 'Developer'), (3, 'Associate'); | SELECT e.emp_id, e.hire_date, j.job_title, d.dept_name FROM employees e JOIN departments d ON e.dept_id = d.dept_id JOIN job_titles j ON e.job_id = j.job_id; | This query joins the employees, departments, and job_titles tables on the appropriate columns. It returns a result set with the employee ID, hire date, job title, and department name. | CREATE TABLE Ingredients (item VARCHAR(50), cost DECIMAL(10,2)); CREATE TABLE job_titles(job_id INT, job_title VARCHAR(50)); INSERT INTO job_titles VALUES (1, 'Manager'), (2, 'Developer'), (3, 'Associate'); | CREATE TABLE Ingredients (item VARCHAR(50), cost DECIMAL(10,2)); CREATE TABLE job_titles(job_id INT, job_title VARCHAR(50)); INSERT INTO job_titles VALUES (1, 'Manager'), (2, 'Developer'), (3, 'Associate'); CREATE TABLE exploration (exploration_id INT, exploration_name VARCHAR(255), location VARCHAR(255), cost FLOAT, r... |
97,812 | food service | multiple_joins | analytics and reporting | Which organic suppliers have never provided ingredients to restaurants located in a coastal city? | CREATE TABLE suppliers (supplier_id INT, organic BOOLEAN); CREATE TABLE ingredients (ingredient_id INT, supplier_id INT, restaurant_id INT, is_organic BOOLEAN); CREATE TABLE restaurants (restaurant_id INT, city VARCHAR(255)); INSERT INTO suppliers VALUES (1, true); INSERT INTO suppliers VALUES (2, false); INSERT INTO i... | SELECT s.supplier_id FROM suppliers s LEFT JOIN ingredients i ON s.supplier_id = i.supplier_id RIGHT JOIN restaurants r ON i.restaurant_id = r.restaurant_id WHERE s.organic = true AND r.city NOT LIKE '%coast%' GROUP BY s.supplier_id HAVING COUNT(i.ingredient_id) = 0; | This query performs a left join between the suppliers and ingredients tables and a right join between the ingredients and restaurants tables, allowing it to identify organic suppliers who have not provided ingredients to coastal restaurants. It then filters the data to only include organic suppliers and restaurants tha... | CREATE TABLE mining_permits (id INT, state VARCHAR(255), year INT, assessment_score INT); CREATE TABLE suppliers (supplier_id INT, organic BOOLEAN); CREATE TABLE ingredients (ingredient_id INT, supplier_id INT, restaurant_id INT, is_organic BOOLEAN); CREATE TABLE restaurants (restaurant_id INT, city VARCHAR(255)); INSE... | CREATE TABLE mining_permits (id INT, state VARCHAR(255), year INT, assessment_score INT); CREATE TABLE matches (id INT, team1 INT, team2 INT, location TEXT, date DATE, status TEXT); CREATE TABLE suppliers (supplier_id INT, organic BOOLEAN); CREATE TABLE ingredients (ingredient_id INT, supplier_id INT, restaurant_id INT... |
16,717 | ocean shipping | single join | analytics and reporting | How many crew members are there on each ship, broken down by position? | CREATE TABLE ship (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), length INT, port_id INT, FOREIGN KEY (port_id) REFERENCES port(id)); INSERT INTO ship VALUES (1, 'Sea Giant', 'Container', 300, 1); INSERT INTO ship VALUES (2, 'Ocean Titan', 'Tanker', 400, 2); CREATE TABLE crew (id INT PRIMARY KEY, ship_id INT,... | SELECT s.name as ship_name, c.position as position, COUNT(*) as crew_count FROM crew c JOIN ship s ON c.ship_id = s.id GROUP BY s.name, c.position; | The SQL query counts the number of crew members for each ship and position by grouping the records by ship name and position. It uses the GROUP BY clause to group the records by ship name and position, and the COUNT function to count the number of crew members for each group. The query uses the JOIN clause to combine t... | CREATE TABLE ship (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), length INT, port_id INT, FOREIGN KEY (port_id) REFERENCES port(id)); INSERT INTO ship VALUES (1, 'Sea Giant', 'Container', 300, 1); INSERT INTO ship VALUES (2, 'Ocean Titan', 'Tanker', 400, 2); CREATE TABLE crew (id INT PRIMARY KEY, ship_id INT,... | CREATE TABLE coal_depletion (site_id INT, amount FLOAT); CREATE TABLE gold_depletion (site_id INT, amount FLOAT); INSERT INTO coal_depletion (site_id, amount) VALUES (1, 200), (2, 300), (3, 150); INSERT INTO gold_depletion (site_id, amount) VALUES (1, 50), (2, 75), (3, 100); CREATE TABLE ship (id INT PRIMARY KEY, name ... |
78,967 | fine arts | multiple_joins | analytics and reporting | List all artworks that were exhibited in more than one gallery, along with the names of the galleries and the total number of exhibitions. | CREATE TABLE Artworks (id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, artwork_id INT, gallery_id INT); CREATE TABLE Galleries (id INT, name VARCHAR(30)); | SELECT a.title, GROUP_CONCAT(g.name) as gallery_names, COUNT(DISTINCT e.gallery_id) as num_exhibitions FROM Artworks a JOIN Exhibitions e ON a.id = e.artwork_id JOIN Galleries g ON e.gallery_id = g.id GROUP BY a.title HAVING num_exhibitions > 1; | This query lists all artworks that were exhibited in more than one gallery. It joins the Artworks, Exhibitions, and Galleries tables on their respective IDs, groups the data by artwork title, concatenates the names of the galleries where each artwork was exhibited, and counts the distinct number of exhibitions for each... | CREATE TABLE training_costs (id INT, hire_id INT, cost FLOAT); INSERT INTO training_costs (id, hire_id, cost) VALUES (1, 1, 500.00), (2, 2, 700.00), (3, 3, 400.00); CREATE TABLE Artworks (id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, artwork_id INT, gallery_id INT); CREATE TABLE Galleries (id INT, name ... | CREATE TABLE training_costs (id INT, hire_id INT, cost FLOAT); INSERT INTO training_costs (id, hire_id, cost) VALUES (1, 1, 500.00), (2, 2, 700.00), (3, 3, 400.00); CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), EmployeeCount INT); INSERT INTO Brands (BrandID, BrandName, EmployeeCount) VALUES (1, 'Brand1', 50... |
44,245 | insurance | basic SQL | analytics and reporting | What is the maximum claim amount in the last 30 days? | CREATE TABLE claims (id INT, policyholder_id INT, claim_amount FLOAT, claim_date DATE); INSERT INTO claims (id, policyholder_id, claim_amount, claim_date) VALUES (1, 1, 500, '2021-01-01'), (2, 1, 300, '2021-02-01'), (3, 2, 800, '2021-03-01'), (4, 2, 1200, '2021-05-15'), (5, 3, 900, '2021-05-10'), (6, 4, 1600, '2021-05-... | SELECT MAX(claim_amount) FROM claims WHERE claim_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY); | The SQL query calculates the maximum claim amount in the last 30 days. It selects the maximum 'claim_amount' column in the 'claims' table where the 'claim_date' column is greater than or equal to 30 days before the current date. | CREATE TABLE farmer (farmer_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); CREATE TABLE country (country_id INT, name VARCHAR(50), description TEXT); CREATE TABLE location (location_id INT, name VARCHAR(50), country_id INT); CREATE TABLE claims (id INT, policyholder_id INT, claim_amount F... | CREATE TABLE farmer (farmer_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); CREATE TABLE country (country_id INT, name VARCHAR(50), description TEXT); CREATE TABLE location (location_id INT, name VARCHAR(50), country_id INT); CREATE TABLE claims (id INT, policyholder_id INT, claim_amount F... |
97,220 | defense | single join | analytics and reporting | Which countries have participated in both peacekeeping operations and defense diplomacy events? | CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), operation VARCHAR(255)); CREATE TABLE defense_diplomacy (id INT, country VARCHAR(255), event VARCHAR(255)); | SELECT country FROM peacekeeping_operations pkops INNER JOIN defense_diplomacy ddip ON pkops.country = ddip.country GROUP BY country HAVING COUNT(DISTINCT pkops.operation) > 0 AND COUNT(DISTINCT ddip.event) > 0; | This SQL query performs an inner join on the peacekeeping_operations and defense_diplomacy tables, based on their country columns. It then groups the result by country and filters for countries with a count of distinct operations and events greater than 0. It returns a list of countries that have participated in both p... | CREATE TABLE Sales (sale_id INT PRIMARY KEY, menu_item VARCHAR(50), sale_quantity INT, sale_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50)); CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), operation VARCHAR(255)); CREATE TABLE defense_diplomacy (id ... | CREATE TABLE Sales (sale_id INT PRIMARY KEY, menu_item VARCHAR(50), sale_quantity INT, sale_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50)); CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), operation VARCHAR(255)); CREATE TABLE defense_diplomacy (id ... |
70,612 | humanitarian aid | basic SQL | analytics and reporting | Which education resources were distributed in South Sudan in Q4 2021? | CREATE TABLE education_resources (id INT, resource TEXT, quantity INT, country TEXT, quarter INT, year INT); INSERT INTO education_resources (id, resource, quantity, country, quarter, year) VALUES (1, 'Textbooks', 500, 'South Sudan', 4, 2021), (2, 'School Supplies', 300, 'South Sudan', 4, 2021), (3, 'Laptops', 200, 'So... | SELECT DISTINCT resource FROM education_resources WHERE country = 'South Sudan' AND quarter = 4 AND year = 2021; | The SQL query selects the DISTINCT resource column from the education_resources table, filters for records with country 'South Sudan', quarter 4, and year 2021. This returns the distinct education resources distributed in South Sudan in Q4 2021. | CREATE TABLE education_resources (id INT, resource TEXT, quantity INT, country TEXT, quarter INT, year INT); INSERT INTO education_resources (id, resource, quantity, country, quarter, year) VALUES (1, 'Textbooks', 500, 'South Sudan', 4, 2021), (2, 'School Supplies', 300, 'South Sudan', 4, 2021), (3, 'Laptops', 200, 'So... | CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), Impact varchar(50), Country varchar(50)); INSERT INTO Programs (ProgramID, ProgramName, Impact, Country) VALUES (1, 'Feeding America', 'High', 'United States'); INSERT INTO Programs (ProgramID, ProgramName, Impact, Country) VALUES (2, 'Habitat for Humanity'... |
22,779 | forestry | multiple_joins | analytics and reporting | List the total timber volume and carbon sequestration rate for each country with wildlife sanctuaries, sorted by the total timber volume in descending order. | CREATE TABLE country (country_id INT, country_name TEXT, PRIMARY KEY (country_id)); CREATE TABLE timber (timber_id INT, country_id INT, year INT, volume INT, PRIMARY KEY (timber_id), FOREIGN KEY (country_id) REFERENCES country(country_id)); CREATE TABLE wildlife (wildlife_id INT, country_id INT, species_count INT, PRIM... | SELECT c.country_name, SUM(t.volume) AS total_timber_volume, AVG(cs.rate) AS avg_carbon_sequestration_rate FROM country c INNER JOIN timber t ON c.country_id = t.country_id INNER JOIN wildlife w ON c.country_id = w.country_id INNER JOIN carbon_sequestration cs ON c.country_id = cs.country_id GROUP BY c.country_name HAV... | We join the country, timber, wildlife, and carbon_sequestration tables based on their respective country IDs. We filter the results to only include countries with wildlife sanctuaries by using the HAVING clause. We then group the results by country name and calculate the total timber volume using the SUM function and t... | CREATE TABLE country (country_id INT, country_name TEXT, PRIMARY KEY (country_id)); CREATE TABLE timber (timber_id INT, country_id INT, year INT, volume INT, PRIMARY KEY (timber_id), FOREIGN KEY (country_id) REFERENCES country(country_id)); CREATE TABLE wildlife (wildlife_id INT, country_id INT, species_count INT, PRIM... | CREATE TABLE country (country_id INT, country_name TEXT, PRIMARY KEY (country_id)); CREATE TABLE timber (timber_id INT, country_id INT, year INT, volume INT, PRIMARY KEY (timber_id), FOREIGN KEY (country_id) REFERENCES country(country_id)); CREATE TABLE wildlife (wildlife_id INT, country_id INT, species_count INT, PRIM... |
70,920 | humanitarian aid | basic SQL | analytics and reporting | Who are the contacts for the 'community development' sector in Asia? | CREATE TABLE contacts (id INT, name TEXT, sector TEXT, region TEXT, email TEXT); INSERT INTO contacts (id, name, sector, region, email) VALUES (1, 'John Doe', 'community development', 'Asia', 'john.doe@example.com'); INSERT INTO contacts (id, name, sector, region, email) VALUES (2, 'Jane Doe', 'refugee support', 'Afric... | SELECT name, email FROM contacts WHERE sector = 'community development' AND region = 'Asia'; | This SQL query retrieves the names and emails of the contacts for the 'community development' sector in Asia. It filters the contacts table to only include rows where the sector is 'community development' and the region is 'Asia', then returns the name and email for these rows. | CREATE TABLE EmployeeDemographics (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(20)); CREATE TABLE JobHistory (EmployeeID INT, JobStartDate DATE); INSERT INTO EmployeeDemographics (EmployeeID, Gender, JobTitle) VALUES (1, 'Female', 'Software Engineer'), (2, 'Male', 'Project Manager'); INSERT INTO JobHistory (Em... | CREATE TABLE EmployeeDemographics (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(20)); CREATE TABLE JobHistory (EmployeeID INT, JobStartDate DATE); INSERT INTO EmployeeDemographics (EmployeeID, Gender, JobTitle) VALUES (1, 'Female', 'Software Engineer'), (2, 'Male', 'Project Manager'); INSERT INTO JobHistory (Em... |
54,625 | space exploration | multiple_joins | analytics and reporting | Show the spacecraft involved in research projects that have not yet started and their respective principal investigators. | CREATE TABLE Spacecraft (id INT PRIMARY KEY, name VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (6, 'Artemis III', 'NASA', '2024-07-01'); CREATE TABLE Research_Projects (id INT PRIMARY KEY, name VARCHAR(100), field VARCHAR(100), start_dat... | SELECT s.name AS spacecraft_name, r.name AS research_project, a.name AS principal_investigator FROM Spacecraft s INNER JOIN Research_Projects r ON s.id = r.id INNER JOIN Astronauts a ON r.principal_investigator_id = a.id WHERE r.start_date > CURDATE(); | Join Spacecraft, Research_Projects, and Astronauts tables based on their relationships, filter by start_date greater than the current date, and select required columns. | CREATE TABLE reservoirs (reservoir_id INT PRIMARY KEY, reservoir_name VARCHAR(100), max_water_depth FLOAT, country VARCHAR(50)); CREATE TABLE Spacecraft (id INT PRIMARY KEY, name VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (6, 'Artemis ... | CREATE TABLE reservoirs (reservoir_id INT PRIMARY KEY, reservoir_name VARCHAR(100), max_water_depth FLOAT, country VARCHAR(50)); CREATE TABLE Spacecraft (id INT PRIMARY KEY, name VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (6, 'Artemis ... |
44,311 | human resources | single join | analytics and reporting | Who are the recruiters that have hired the most employees in the HR department? | CREATE TABLE Employees (Employee_ID INT PRIMARY KEY, First_Name VARCHAR(30), Last_Name VARCHAR(30), Department VARCHAR(30), Recruiter_ID INT); CREATE TABLE Recruiters (Recruiter_ID INT PRIMARY KEY, First_Name VARCHAR(30), Last_Name VARCHAR(30)); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Rec... | SELECT Recruiters.First_Name, Recruiters.Last_Name, COUNT(*) as Number_of_Hires FROM Employees INNER JOIN Recruiters ON Employees.Recruiter_ID = Recruiters.Recruiter_ID WHERE Department = 'HR' GROUP BY Recruiter_ID ORDER BY Number_of_Hires DESC; | This SQL query identifies the recruiters that have hired the most employees in the HR department. | CREATE TABLE Employees (Employee_ID INT PRIMARY KEY, First_Name VARCHAR(30), Last_Name VARCHAR(30), Department VARCHAR(30), Recruiter_ID INT); CREATE TABLE Recruiters (Recruiter_ID INT PRIMARY KEY, First_Name VARCHAR(30), Last_Name VARCHAR(30)); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Rec... | CREATE TABLE RecreationCenters (center VARCHAR(50), state VARCHAR(20), score INT); INSERT INTO RecreationCenters (center, state, score) VALUES ('CenterA', 'Texas', 8), ('CenterB', 'Texas', 9), ('CenterC', 'Florida', 7); CREATE TABLE Deliveries (DeliveryID int, Vendor varchar(50), Destination varchar(50), Units int); IN... |
21,640 | music | multiple_joins | analytics and reporting | List the artists who have released music on both "Record Label A" and "Record Label B" platforms. | CREATE TABLE Artist (ArtistID INT, ArtistName VARCHAR(255)); CREATE TABLE Label (LabelID INT, LabelName VARCHAR(255)); CREATE TABLE Releases (ReleaseID INT, ArtistID INT, LabelID INT); INSERT INTO Artist VALUES (1, 'Artist A'); INSERT INTO Artist VALUES (2, 'Artist B'); INSERT INTO Label VALUES (1, 'Record Label A'); I... | SELECT ArtistName FROM Artist a JOIN Releases r1 ON a.ArtistID = r1.ArtistID JOIN Label l1 ON r1.LabelID = l1.LabelID JOIN Releases r2 ON a.ArtistID = r2.ArtistID JOIN Label l2 ON r2.LabelID = l2.LabelID WHERE l1.LabelName = 'Record Label A' AND l2.LabelName = 'Record Label B'; | The SQL query joins the Artist, Releases, and Label tables twice to find artists who have released music on both "Record Label A" and "Record Label B". The query uses the WHERE clause to filter the results based on the LabelName. | CREATE TABLE Artist (ArtistID INT, ArtistName VARCHAR(255)); CREATE TABLE Label (LabelID INT, LabelName VARCHAR(255)); CREATE TABLE Releases (ReleaseID INT, ArtistID INT, LabelID INT); INSERT INTO Artist VALUES (1, 'Artist A'); INSERT INTO Artist VALUES (2, 'Artist B'); INSERT INTO Label VALUES (1, 'Record Label A'); I... | CREATE TABLE month (month_id INT, month_name TEXT); CREATE TABLE professional_development (professional_development_id INT, month_id INT, num_hours INT); INSERT INTO month (month_id, month_name) VALUES (1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, ... |
37,653 | food service | multiple_joins | analytics and reporting | Determine the percentage of revenue from plant-based menu items per location. | CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location1'), (2, 'Location2'); CREATE TABLE Menu_Items (Item_ID INT, Item_Name TEXT, Item_Revenue DECIMAL, Is_Plant_Based BOOLEAN); INSERT INTO Menu_Items (Item_ID, Item_Name, Item_Revenue, Is_Pl... | SELECT L.Location_Name, (SUM(CASE WHEN MI.Is_Plant_Based THEN RBI.Revenue ELSE 0 END) / SUM(RBI.Revenue)) * 100 as Plant_Based_Percentage_Revenue FROM Revenue_By_Item RBI JOIN Menu_Items MI ON RBI.Item_ID = MI.Item_ID JOIN Locations L ON MI.Location_ID = L.Location_ID GROUP BY L.Location_Name; | This query calculates the percentage of revenue from plant-based menu items per location by joining the Revenue_By_Item table with the Menu_Items table and the Locations table on the Item_ID and Location_ID columns, respectively. The results are then grouped by Location_Name and the SUM function with a CASE statement i... | CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location1'), (2, 'Location2'); CREATE TABLE Menu_Items (Item_ID INT, Item_Name TEXT, Item_Revenue DECIMAL, Is_Plant_Based BOOLEAN); INSERT INTO Menu_Items (Item_ID, Item_Name, Item_Revenue, Is_Pl... | CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location1'), (2, 'Location2'); CREATE TABLE Menu_Items (Item_ID INT, Item_Name TEXT, Item_Revenue DECIMAL, Is_Plant_Based BOOLEAN); INSERT INTO Menu_Items (Item_ID, Item_Name, Item_Revenue, Is_Pl... |
74,073 | maritime | single join | analytics and reporting | List all accidents for vessels from Indonesia, if any. | CREATE TABLE Accidents (Id INT, VesselId INT, Date DATE, Injuries INT); INSERT INTO Accidents (Id, VesselId, Date, Injuries) VALUES (2, 2, '2021-02-01', 2); | SELECT V.Name, A.Date, A.Injuries FROM Vessels V INNER JOIN Accidents A ON V.Id = A.VesselId WHERE V.Flag = 'Indonesia'; | The SQL query uses an inner join to combine the Vessels and Accidents tables on the VesselId column, then filters for rows where the Flag is 'Indonesia'. It returns the Name column from the Vessels table and the Date and Injuries columns from the Accidents table. | CREATE TABLE Accidents (Id INT, VesselId INT, Date DATE, Injuries INT); INSERT INTO Accidents (Id, VesselId, Date, Injuries) VALUES (2, 2, '2021-02-01', 2); CREATE TABLE training_sessions (session_id INT, session_name VARCHAR(50), completed_by_worker INT); INSERT INTO training_sessions (session_id, session_name, comple... | CREATE TABLE training_sessions (session_id INT, session_name VARCHAR(50), completed_by_worker INT); INSERT INTO training_sessions (session_id, session_name, completed_by_worker) VALUES (1, 'Cultural Competency 101', 120), (2, 'Advanced Cultural Competency', 80); CREATE TABLE content_lang (content_id INT, content_langua... |
65,796 | logistics | basic SQL | analytics and reporting | What is the average volume of warehouses in Canada? | CREATE TABLE canada_warehouses (id INT, volume FLOAT); INSERT INTO canada_warehouses (id, volume) VALUES (1, 1600), (2, 1900); | SELECT AVG(volume) FROM canada_warehouses; | Calculate the average volume of warehouses in Canada by filtering the canada_warehouses table and then applying the AVG function on the volume column. | CREATE TABLE AccidentYears (YearID int, Year int); CREATE TABLE AccidentReports (ReportID int, AccidentYearID int, AccidentDate date); INSERT INTO AccidentYears VALUES (1, 2010), (2, 2011), (3, 2012), (4, 2015), (5, 2019); INSERT INTO AccidentReports VALUES (1, 1, '2010-01-01'), (2, 1, '2011-05-15'), (3, 3, '2012-03-12... | CREATE TABLE AccidentYears (YearID int, Year int); CREATE TABLE AccidentReports (ReportID int, AccidentYearID int, AccidentDate date); INSERT INTO AccidentYears VALUES (1, 2010), (2, 2011), (3, 2012), (4, 2015), (5, 2019); INSERT INTO AccidentReports VALUES (1, 1, '2010-01-01'), (2, 1, '2011-05-15'), (3, 3, '2012-03-12... |
53,789 | journalism | multiple_joins | analytics and reporting | List all journalists who have published articles on a specific topic | CREATE TABLE journalists (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE articles (id INT PRIMARY KEY, title TEXT NOT NULL, author_id INT, published_at DATE); CREATE TABLE articles_topics (article_id INT, topic_id INT); CREATE TABLE topics (id INT PRIMARY KEY, name TEXT NOT NULL); | SELECT journalists.name FROM journalists INNER JOIN articles ON journalists.id = articles.author_id INNER JOIN articles_topics ON articles.id = articles_topics.article_id INNER JOIN topics ON articles_topics.topic_id = topics.id WHERE topics.name = 'specific_topic'; | The SQL query performs three inner joins, connecting the journalists, articles, articles_topics, and topics tables. It then filters the results to only include journalists who have published articles on a specific topic. | CREATE TABLE journalists (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE articles (id INT PRIMARY KEY, title TEXT NOT NULL, author_id INT, published_at DATE); CREATE TABLE articles_topics (article_id INT, topic_id INT); CREATE TABLE topics (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE Customers (Custome... | CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50), TotalAssets DECIMAL(18,2));CREATE TABLE Investments (CustomerID INT, InvestmentType VARCHAR(10), Market VARCHAR(10));INSERT INTO Customers VALUES (1,'John Doe',50000.00),(2,'Jane Smith',75000.00);INSERT INTO Investments VALUES (1,'Stocks','US'),(1,'Stocks','Cana... |
98,294 | fine arts | single join | analytics and reporting | Find the artist with the greatest difference between the earliest and latest creation years. | CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), BirthYear INT);CREATE TABLE Paintings (PaintingID INT, PaintingName VARCHAR(50), ArtistID INT, CreationYear INT); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 1881); INSERT INTO Paintings VALUES (1, 'Guernica', 1, 1937); | SELECT ArtistName, MAX(CreationYear) - MIN(CreationYear) as YearsSpanned FROM Artists a JOIN Paintings p ON a.ArtistID = p.ArtistID GROUP BY ArtistName ORDER BY YearsSpanned DESC LIMIT 1; | This query first joins the Artists and Paintings tables based on their relationships. It then groups by artist name and calculates the difference between the latest and earliest creation years for each artist. Finally, it orders by the years spanned in descending order and limits the result to a single record, returnin... | CREATE TABLE policyholders (policyholder_id INT, name VARCHAR(50)); INSERT INTO policyholders (policyholder_id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE policies (policy_id INT, policyholder_id INT, category VARCHAR(10)); INSERT INTO policies (policy_id, policyholder_id, category) VALUES (1, 1, 'au... | CREATE TABLE policyholders (policyholder_id INT, name VARCHAR(50)); INSERT INTO policyholders (policyholder_id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE policies (policy_id INT, policyholder_id INT, category VARCHAR(10)); INSERT INTO policies (policy_id, policyholder_id, category) VALUES (1, 1, 'au... |
91,640 | marine biology | basic SQL | analytics and reporting | Which estuary in Europe has the lowest salinity?" | CREATE TABLE estuaries (id INT, name TEXT, location TEXT, salinity FLOAT, area_size FLOAT); INSERT INTO estuaries (id, name, location, salinity, area_size) VALUES (1, 'Gironde Estuary', 'Europe', 0.5, 665); | SELECT name, MIN(salinity) FROM estuaries WHERE location = 'Europe'; | This SQL query retrieves the name (name) and the lowest salinity (MIN(salinity)) from the estuaries table, filtered by the location 'Europe' (WHERE location = 'Europe'). | CREATE TABLE estuaries (id INT, name TEXT, location TEXT, salinity FLOAT, area_size FLOAT); INSERT INTO estuaries (id, name, location, salinity, area_size) VALUES (1, 'Gironde Estuary', 'Europe', 0.5, 665); CREATE TABLE Equipment (EID INT, Type VARCHAR(50), VendorID INT, MaintenanceCost INT); INSERT INTO Equipment (EID... | CREATE TABLE Equipment (EID INT, Type VARCHAR(50), VendorID INT, MaintenanceCost INT); INSERT INTO Equipment (EID, Type, VendorID, MaintenanceCost) VALUES (1, 'Tank', 1, 10000), (2, 'Fighter Jet', 1, 20000), (3, 'Helicopter', 2, 15000); CREATE TABLE Vendors (VID INT, Name VARCHAR(100)); INSERT INTO Vendors (VID, Name) ... |
83,076 | artificial intelligence | basic SQL | data retrieval | Which AI conferences have been held in Canada? | CREATE TABLE ai_conferences(id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); INSERT INTO ai_conferences (id, name, location) VALUES (1, 'NeurIPS', 'USA'), (2, 'ICML', 'Canada'), (3, 'AAAI', 'Australia'); | SELECT * FROM ai_conferences WHERE location = 'Canada'; | This query selects all columns from the 'ai_conferences' table where the 'location' column value is 'Canada'. | CREATE TABLE ai_conferences(id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); INSERT INTO ai_conferences (id, name, location) VALUES (1, 'NeurIPS', 'USA'), (2, 'ICML', 'Canada'), (3, 'AAAI', 'Australia'); CREATE TABLE policies (policy_id INT, policyholder_id INT, policy_start_date DATE, policy_end_date DATE)... | CREATE TABLE ai_conferences(id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); INSERT INTO ai_conferences (id, name, location) VALUES (1, 'NeurIPS', 'USA'), (2, 'ICML', 'Canada'), (3, 'AAAI', 'Australia'); CREATE TABLE policies (policy_id INT, policyholder_id INT, policy_start_date DATE, policy_end_date DATE)... |
50,375 | defense security | basic SQL | analytics and reporting | What is the name and year of all national security strategies implemented before 2015 in the 'Strategy' table? | CREATE TABLE Strategy (id INT, name VARCHAR(50), year INT, continent VARCHAR(50)); INSERT INTO Strategy (id, name, year, continent) VALUES (1, 'National Security Strategy 2010', 2010, 'North America'); INSERT INTO Strategy (id, name, year, continent) VALUES (2, 'National Security Strategy 2015', 2015, 'Europe'); | SELECT name, year FROM Strategy WHERE year < 2015; | This SQL query selects the 'name' and 'year' columns from the 'Strategy' table where the 'year' column is less than 2015. | CREATE TABLE investigative_journalists (id INT, name VARCHAR(50), country VARCHAR(50), years_of_experience INT); INSERT INTO investigative_journalists (id, name, country, years_of_experience) VALUES (1, 'John Doe', 'USA', 10), (2, 'Jane Smith', 'Canada', 12), (3, 'Pedro Martinez', 'Mexico', 8), (4, 'Rajesh Patel', 'Ind... | CREATE TABLE Strategy (id INT, name VARCHAR(50), year INT, continent VARCHAR(50)); INSERT INTO Strategy (id, name, year, continent) VALUES (1, 'National Security Strategy 2010', 2010, 'North America'); INSERT INTO Strategy (id, name, year, continent) VALUES (2, 'National Security Strategy 2015', 2015, 'Europe'); CREATE... |
90,217 | museums | basic SQL | analytics and reporting | What is the total entry fee collected in Beijing for exhibitions with an entry fee above 10? | CREATE TABLE Exhibitions (exhibition_id INT, location VARCHAR(20), entry_fee INT); INSERT INTO Exhibitions (exhibition_id, location, entry_fee) VALUES (1, 'Beijing', 12), (2, 'Beijing', 20), (3, 'Beijing', 30); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT); INSERT INTO Visitors (visitor_id, exhibition_id) V... | SELECT SUM(entry_fee) FROM Exhibitions WHERE location = 'Beijing' AND entry_fee > 10; | The SQL query filters the results for Beijing exhibitions with an entry fee above 10, calculates the total entry fee for each exhibition, and returns the total entry fee. | CREATE TABLE Exhibitions (exhibition_id INT, location VARCHAR(20), entry_fee INT); INSERT INTO Exhibitions (exhibition_id, location, entry_fee) VALUES (1, 'Beijing', 12), (2, 'Beijing', 20), (3, 'Beijing', 30); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT); INSERT INTO Visitors (visitor_id, exhibition_id) V... | CREATE TABLE health_equity_metrics (metric_id INT, metric_name VARCHAR(50), state VARCHAR(20)); INSERT INTO health_equity_metrics (metric_id, metric_name, state) VALUES (1, 'Metric 1', 'New York'), (2, 'Metric 2', 'New York'), (3, 'Metric 1', 'Florida'), (4, 'Metric 4', 'Florida'), (5, 'Metric 3', 'California'), (6, 'M... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 16