instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What are the call types and dates for all calls in 'urban_police' that occurred after '2022-01-01 10:00:00'? | CREATE TABLE urban_police (id INT,call_type VARCHAR(20),call_date TIMESTAMP); INSERT INTO urban_police VALUES (1,'burglary','2022-01-02 11:00:00'); | SELECT call_type, call_date FROM urban_police WHERE call_date > '2022-01-01 10:00:00'; |
What is the maximum safety score for models developed in Oceania? | CREATE TABLE models (id INT,name TEXT,safety_score FLOAT,country TEXT); INSERT INTO models (id,name,safety_score,country) VALUES (1,'ModelA',0.85,'US'),(2,'ModelB',0.92,'Australia'); | SELECT MAX(safety_score) FROM models WHERE country = 'Australia'; |
What is the average data usage in GB for postpaid mobile customers in the Southeast region over the past year? | CREATE TABLE customers (id INT,type VARCHAR(10),region VARCHAR(10)); INSERT INTO customers (id,type,region) VALUES (1,'postpaid','Southeast'),(2,'prepaid','Southeast'); CREATE TABLE usage (customer_id INT,data_usage FLOAT,year INT); INSERT INTO usage (customer_id,data_usage,year) VALUES (1,4.5,2022),(1,4.3,2021),(1,4.7... | SELECT AVG(usage.data_usage) FROM usage JOIN customers ON usage.customer_id = customers.id WHERE customers.type = 'postpaid' AND customers.region = 'Southeast' AND usage.year = 2022; |
Calculate the total revenue of sativa-based products sold in Oregon dispensaries in Q1 2022. | CREATE TABLE products (type VARCHAR(10),category VARCHAR(10),price DECIMAL(5,2),quantity INT); INSERT INTO products (type,category,price,quantity) VALUES ('oil','sativa',70,50),('flower','sativa',100,75),('edible','sativa',60,40); CREATE TABLE dispensaries (state VARCHAR(20),sales INT); INSERT INTO dispensaries (state,... | SELECT SUM(products.price * products.quantity) FROM products JOIN dispensaries ON TRUE WHERE products.category = 'sativa' AND dispensaries.state = 'Oregon' AND time_periods.quarter = 1; |
What is the minimum donation amount and the state for that donation? | CREATE TABLE Donations (id INT,donor_name TEXT,donation_amount FLOAT,donation_date DATE,state TEXT); INSERT INTO Donations (id,donor_name,donation_amount,donation_date,state) VALUES (1,'John Doe',250,'2022-01-01','NY'),(2,'Jane Smith',125,'2022-01-02','CA'); | SELECT state, MIN(donation_amount) FROM Donations; |
What is the total volume of recycled wastewater in Mumbai, India in 2022? | CREATE TABLE wastewater_recycling_mumbai (id INT,date DATE,volume FLOAT); INSERT INTO wastewater_recycling_mumbai (id,date,volume) VALUES (1,'2022-01-01',1000000),(2,'2022-01-02',1200000); | SELECT SUM(volume) FROM wastewater_recycling_mumbai WHERE date BETWEEN '2022-01-01' AND '2022-12-31'; |
What is the minimum handling time in hours for containers at ports located in North America, for each port? | CREATE TABLE ports (port_id INT,port_name TEXT,country TEXT); INSERT INTO ports VALUES (1,'Port A','United States'),(2,'Port B','Canada'),(3,'Port C','Mexico'); CREATE TABLE cargo (cargo_id INT,port_id INT,quantity INT,handling_time INT,handling_date DATE); INSERT INTO cargo VALUES (1,1,500,20,'2022-01-01'),(2,1,600,22... | SELECT MIN(cargo.handling_time) FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'North America' GROUP BY cargo.port_id; |
Update the email of the volunteer with ID 3 to 'jane_volunteer@gmail.com'. | CREATE TABLE volunteers (id INT,name TEXT,email TEXT); INSERT INTO volunteers (id,name,email) VALUES (1,'John Doe','john.doe@example.com'),(2,'Jane Smith','jane.smith@example.com'),(3,'Alice Johnson','alice.johnson@example.com'),(4,'Bob Brown','bob.brown@example.com'); | UPDATE volunteers SET email = 'jane_volunteer@gmail.com' WHERE id = 3; |
What is the maximum CO2 emissions for each material in the 'sustainable_materials' table? | CREATE TABLE sustainable_materials (material_id INT,material TEXT,co2_emissions FLOAT); | SELECT material, MAX(co2_emissions) as max_emissions FROM sustainable_materials GROUP BY material; |
List all properties in Oakland with inclusive housing policies. | CREATE TABLE properties (property_id INT,city VARCHAR(20),inclusive BOOLEAN); INSERT INTO properties (property_id,city,inclusive) VALUES (1,'Oakland',true); INSERT INTO properties (property_id,city,inclusive) VALUES (2,'San_Francisco',false); | SELECT * FROM properties WHERE city = 'Oakland' AND inclusive = true; |
Create a table for community health workers | CREATE TABLE community_health_workers (id INT PRIMARY KEY,worker_name VARCHAR(50),language_spoken VARCHAR(20),years_of_experience INT); | CREATE TABLE community_health_workers (id INT PRIMARY KEY, worker_name VARCHAR(50), language_spoken VARCHAR(20), years_of_experience INT); |
What is the minimum fare for buses in Moscow? | CREATE TABLE if not exists bus_fares (id INT,city VARCHAR(20),min_fare DECIMAL(3,2)); INSERT INTO bus_fares (id,city,min_fare) VALUES (1,'Moscow',1.20),(2,'St. Petersburg',1.00); | SELECT min_fare FROM bus_fares WHERE city = 'Moscow'; |
Show the total revenue from concert ticket sales for each genre. | CREATE TABLE Genres (GenreID INT,GenreName VARCHAR(255)); INSERT INTO Genres (GenreID,GenreName) VALUES (1,'Pop'),(2,'Rock'),(3,'Jazz'),(4,'Hip Hop'),(5,'Country'); CREATE TABLE Concerts (ConcertID INT,GenreID INT,Venue VARCHAR(255),TicketPrice DECIMAL(5,2)); INSERT INTO Concerts (ConcertID,GenreID,Venue,TicketPrice) V... | SELECT G.GenreName, SUM(C.TicketPrice) as TotalRevenue FROM Genres G JOIN Concerts C ON G.GenreID = C.GenreID GROUP BY G.GenreName; |
List consumers who have not purchased any cruelty-free products. | CREATE TABLE purchases (purchase_id INT,consumer_id INT,product_id INT,is_cruelty_free BOOLEAN); INSERT INTO purchases (purchase_id,consumer_id,product_id,is_cruelty_free) VALUES (1,1,1,true),(2,1,2,false),(3,2,3,true),(4,3,4,false),(5,3,5,true); | SELECT DISTINCT consumer_id FROM purchases WHERE is_cruelty_free = false; |
Find the total assets of customers with a postal code starting with 'A' in the Southeast region. | CREATE TABLE Customers (CustomerID int,Name varchar(50),Age int,PostalCode varchar(10),Region varchar(50)); INSERT INTO Customers (CustomerID,Name,Age,PostalCode,Region) VALUES (1,'John Doe',35,'A1B2C3','Southeast'); | SELECT SUM(Assets) FROM (SELECT Assets FROM Accounts INNER JOIN Customers ON Accounts.CustomerID = Customers.CustomerID WHERE Customers.PostalCode LIKE 'A%' AND Customers.Region = 'Southeast') AS Subquery; |
Create a view named 'v_space_debris_summary' with debris name, launch date and type | CREATE TABLE space_debris (id INT PRIMARY KEY,debris_name VARCHAR(100),launch_date DATE,type VARCHAR(50)); | CREATE VIEW v_space_debris_summary AS SELECT id, debris_name, launch_date, type FROM space_debris; |
How many movies were released per year in the 'Animation' genre? | CREATE TABLE MOVIES (id INT,title VARCHAR(100),release_year INT,genre VARCHAR(50)); INSERT INTO MOVIES (id,title,release_year,genre) VALUES (1,'Finding Nemo',2003,'Animation'),(2,'The Incredibles',2004,'Animation'),(3,'Inside Out',2015,'Animation'); | SELECT release_year, COUNT(*) as num_movies FROM MOVIES WHERE genre = 'Animation' GROUP BY release_year; |
Who are the top 3 actors with the highest number of awards, considering awards won between 2000 and 2020? | CREATE TABLE awards (id INT,actor VARCHAR(255),award VARCHAR(255),year INT); | SELECT actor, COUNT(*) as award_count FROM awards WHERE year BETWEEN 2000 AND 2020 GROUP BY actor ORDER BY award_count DESC LIMIT 3; |
How many players joined each month in 2021? | CREATE TABLE players (player_id INT,join_date DATE); INSERT INTO players (player_id,join_date) VALUES (1,'2021-01-05'),(2,'2021-02-07'),(3,'2021-03-31'),(4,'2021-01-15'),(5,'2021-02-28'),(6,'2021-03-15'); | SELECT EXTRACT(MONTH FROM join_date) AS month, COUNT(*) AS players FROM players WHERE EXTRACT(YEAR FROM join_date) = 2021 GROUP BY month; |
What is the average number of containers handled per day by vessels in the Arabian Sea in Q3 2020? | CREATE TABLE Vessel_Stats_2 (vessel_name TEXT,location TEXT,handling_date DATE,containers_handled INTEGER); INSERT INTO Vessel_Stats_2 (vessel_name,location,handling_date,containers_handled) VALUES ('VesselE','Arabian Sea','2020-07-01',60),('VesselF','Arabian Sea','2020-07-02',70),('VesselG','Arabian Sea','2020-08-01',... | SELECT AVG(containers_handled/30.0) FROM Vessel_Stats_2 WHERE location = 'Arabian Sea' AND handling_date >= '2020-07-01' AND handling_date <= '2020-09-30'; |
What is the total quantity of fair trade certified products sold by each brand? | CREATE TABLE fair_trade_products (product_id INT,brand VARCHAR(50),quantity INT); INSERT INTO fair_trade_products (product_id,brand,quantity) VALUES (1,'Ethical Brand A',500),(2,'Ethical Brand B',700),(3,'Ethical Brand A',800),(4,'Ethical Brand C',600); | SELECT brand, SUM(quantity) FROM fair_trade_products GROUP BY brand; |
Find the total number of autonomous vehicles sold in Q1 of 2022 by manufacturer? | CREATE TABLE Autonomous_Sales (Id INT,Manufacturer VARCHAR(50),Sales INT,Quarter VARCHAR(10),Year INT); INSERT INTO Autonomous_Sales (Id,Manufacturer,Sales,Quarter,Year) VALUES (1,'Tesla',2000,'Q1',2022); INSERT INTO Autonomous_Sales (Id,Manufacturer,Sales,Quarter,Year) VALUES (2,'Waymo',1500,'Q1',2022); | SELECT Manufacturer, SUM(Sales) FROM Autonomous_Sales WHERE (Quarter = 'Q1' AND Year = 2022) AND Manufacturer IN (SELECT Manufacturer FROM Autonomous_Sales WHERE Type = 'Autonomous') GROUP BY Manufacturer; |
What is the total amount of water used by each mining site, categorized by water source, in the past year? | CREATE TABLE mining_sites (id INT,name TEXT); CREATE TABLE water_sources (id INT,site_id INT,type TEXT); CREATE TABLE water_usage (id INT,source_id INT,year INT,amount FLOAT); INSERT INTO mining_sites (id,name) VALUES (1,'Site A'),(2,'Site B'),(3,'Site C'); INSERT INTO water_sources (id,site_id,type) VALUES (1,1,'Surfa... | SELECT water_sources.type, mining_sites.name, SUM(water_usage.amount) FROM water_usage INNER JOIN water_sources ON water_usage.source_id = water_sources.id INNER JOIN mining_sites ON water_sources.site_id = mining_sites.id WHERE water_usage.year = 2021 GROUP BY water_sources.type, mining_sites.name; |
Update the sustainable_sources table to set the is_certified field to true for the source with a source_id of 25 | CREATE TABLE sustainable_sources (source_id INT,name VARCHAR(50),description TEXT,is_certified BOOLEAN); | UPDATE sustainable_sources SET is_certified = true WHERE source_id = 25; |
What is the average water usage, in cubic meters, for denim production by each manufacturer, for the year 2020? | CREATE TABLE DenimProduction (manufacturer VARCHAR(255),water_usage DECIMAL(10,2),year INT); | SELECT manufacturer, AVG(water_usage) FROM DenimProduction WHERE year = 2020 GROUP BY manufacturer; |
Which company had the most diverse founding team? | CREATE TABLE Founders (id INT,company_id INT,name VARCHAR(50),gender VARCHAR(10)); INSERT INTO Founders (id,company_id,name,gender) VALUES (1,1,'Alex','Male'),(2,1,'Bella','Female'),(3,2,'Chris','Male'),(4,2,'Dan','Male'); | SELECT company_id, COUNT(DISTINCT gender) as num_genders FROM Founders GROUP BY company_id ORDER BY num_genders DESC FETCH FIRST 1 ROW ONLY; |
What is the total number of defense contracts awarded per year? | CREATE TABLE Contracts (Year INT,Count INT); INSERT INTO Contracts (Year,Count) VALUES (2021,2000),(2022,2500); | SELECT Year, SUM(Count) FROM Contracts GROUP BY Year; |
How many students in the open pedagogy program have not visited in the past month? | CREATE TABLE open_pedagogy_students (id INT,name VARCHAR(50),last_visit DATE); | SELECT COUNT(*) FROM open_pedagogy_students WHERE last_visit < DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
List all records from the "regulatory_compliance" table. | CREATE TABLE regulatory_compliance (id INT PRIMARY KEY,vessel_id INT,regulation VARCHAR(255),compliance_date DATE,status VARCHAR(10)); | SELECT * FROM regulatory_compliance; |
What is the average mental health score for each school district? | CREATE TABLE student_mental_health_district (student_id INT,district_id INT,score INT); | SELECT d.district_name, AVG(smhd.score) as avg_score FROM student_mental_health_district smhd JOIN school_districts d ON smhd.district_id = d.district_id GROUP BY d.district_name; |
How many concerts were sold out in France? | CREATE TABLE Concerts (ConcertID INT,ArtistID INT,Venue VARCHAR(100),TicketRevenue DECIMAL(10,2),TotalTickets INT,SoldOut BOOLEAN); INSERT INTO Concerts (ConcertID,ArtistID,Venue,TicketRevenue,TotalTickets,SoldOut) VALUES (1,1,'Paris',1000000.00,2000,TRUE),(2,2,'Berlin',500000.00,1500,FALSE); | SELECT COUNT(*) FROM Concerts WHERE SoldOut = TRUE AND Country = 'France'; |
How many students are enrolled in lifelong learning courses, grouped by age group? | CREATE TABLE lifelong_learning_courses (course_id INT,course_name VARCHAR(50),student_age INT); | SELECT student_age, COUNT(*) FROM lifelong_learning_courses GROUP BY student_age; |
What is the average satisfaction score for creative AI applications, grouped by region, for applications released in 2022? | CREATE TABLE creative_ai (app_id INT,app_name TEXT,satisfaction_score INT,release_year INT,region TEXT); INSERT INTO creative_ai (app_id,app_name,satisfaction_score,release_year,region) VALUES (1,'AI Painter',85,2022,'North America'); INSERT INTO creative_ai (app_id,app_name,satisfaction_score,release_year,region) VALU... | SELECT region, AVG(satisfaction_score) as avg_satisfaction FROM creative_ai WHERE release_year = 2022 GROUP BY region; |
What is the daily water consumption trend in the 'DailyWaterUsage' table for the last 30 days? | CREATE TABLE DailyWaterUsage (ID INT,Date DATE,WaterAmount FLOAT); INSERT INTO DailyWaterUsage (ID,Date,WaterAmount) VALUES (1,'2022-07-01',12000); INSERT INTO DailyWaterUsage (ID,Date,WaterAmount) VALUES (2,'2022-07-02',15000); | SELECT Date, WaterAmount, ROW_NUMBER() OVER (ORDER BY Date DESC) as Rank FROM DailyWaterUsage WHERE Rank <= 30; |
What was the average production rate of wells drilled by "DrillerA" in the Gulf of Mexico? | CREATE TABLE wells (id INT,driller VARCHAR(255),location VARCHAR(255),production_rate FLOAT); INSERT INTO wells (id,driller,location,production_rate) VALUES (1,'DrillerA','Gulf of Mexico',1000),(2,'DrillerB','North Sea',1500),(3,'DrillerA','Gulf of Mexico',1200); | SELECT AVG(production_rate) FROM wells WHERE driller = 'DrillerA' AND location = 'Gulf of Mexico'; |
What is the total donation amount per zip code? | CREATE TABLE Donors (DonorID INT,Name VARCHAR(50),City VARCHAR(50),State VARCHAR(2),Zip VARCHAR(10),DonationAmount DECIMAL(10,2)); CREATE TABLE Grants (GrantID INT,DonorID INT,NonprofitID INT,GrantAmount DECIMAL(10,2),Date DATE); | SELECT Zip, SUM(DonationAmount) FROM Donors D INNER JOIN Grants G ON D.DonorID = G.DonorID GROUP BY Zip; |
What is the total tonnage of goods transported by vessels between Japan and South Korea? | CREATE TABLE Vessels (VesselID INT,Name TEXT,Type TEXT,MaxCapacity INT); CREATE TABLE Routes (RouteID INT,Origin TEXT,Destination TEXT); CREATE TABLE Cargo (CargoID INT,VesselID INT,RouteID INT,Date DATE,CargoWeight INT); INSERT INTO Vessels VALUES (1,'Vessel 1','Cargo',50000); INSERT INTO Routes VALUES (1,'Japan','Sou... | SELECT SUM(Cargo.CargoWeight) FROM Cargo INNER JOIN Vessels ON Cargo.VesselID = Vessels.VesselID INNER JOIN Routes ON Cargo.RouteID = Routes.RouteID WHERE Routes.Origin = 'Japan' AND Routes.Destination = 'South Korea'; |
Create a view to show the total number of employees in each department from 'employee_demographics' | CREATE TABLE employee_demographics (id INT PRIMARY KEY,employee_id INT,name VARCHAR(255),gender VARCHAR(255),department VARCHAR(255),region VARCHAR(255)); | CREATE VIEW department_employee_count AS SELECT department, COUNT(*) FROM employee_demographics GROUP BY department; |
What are the water conservation initiatives and their corresponding budgets in Texas for the year 2022? | CREATE TABLE water_conservation_initiatives (initiative VARCHAR(255),budget INT); INSERT INTO water_conservation_initiatives (initiative,budget) VALUES ('Rainwater Harvesting',10000),('Greywater Recycling',8000),('Smart Irrigation Systems',12000); CREATE TABLE texas_water_use (year INT,initiative VARCHAR(255),budget IN... | SELECT i.initiative, i.budget as conservation_budget FROM water_conservation_initiatives i INNER JOIN texas_water_use t ON i.initiative = t.initiative WHERE t.year = 2022; |
Populate 'customer_size_diversity' table with records for 3 customers | CREATE TABLE customer_size_diversity (id INT PRIMARY KEY,customer_id INT,size VARCHAR(10),height INT,weight INT); | INSERT INTO customer_size_diversity (id, customer_id, size, height, weight) VALUES (1, 1001, 'XS', 152, 45), (2, 1002, 'L', 178, 75), (3, 1003, 'XXL', 190, 110); |
What is the total budget allocated to programs in the 'Asia' region? | CREATE TABLE ProgramBudget (ProgramID INT,Region TEXT,Budget DECIMAL(10,2)); CREATE TABLE Programs (ProgramID INT,ProgramName TEXT); | SELECT SUM(ProgramBudget.Budget) FROM ProgramBudget INNER JOIN Programs ON ProgramBudget.ProgramID = Programs.ProgramID WHERE Programs.Region = 'Asia'; |
What's the average price of makeup products with parabens? | CREATE TABLE products (id INT,name TEXT,price DECIMAL,has_parabens BOOLEAN); | SELECT AVG(price) FROM products WHERE has_parabens = true; |
What is the total revenue generated from ticket sales for each sport in the 'sales' table? | CREATE TABLE sales (sale_id INT,event VARCHAR(50),sport VARCHAR(20),price DECIMAL(5,2),quantity INT); INSERT INTO sales (sale_id,event,sport,price,quantity) VALUES (1,'Game 1','Basketball',100.00,500); INSERT INTO sales (sale_id,event,sport,price,quantity) VALUES (2,'Game 2','Soccer',75.00,750); | SELECT sport, SUM(price * quantity) as total_revenue FROM sales GROUP BY sport; |
Add a new record to the 'Projects' table with the name 'Building Schools', country 'Kenya', and budget $50000 | CREATE TABLE Projects (id INT PRIMARY KEY,project_name VARCHAR(255),country VARCHAR(255),budget FLOAT); | INSERT INTO Projects (project_name, country, budget) VALUES ('Building Schools', 'Kenya', 50000); |
How many cases were lost by attorney Thompson in the last 2 years? | CREATE TABLE cases (case_id INT,attorney_name VARCHAR(255),win_status BOOLEAN,case_date DATE); INSERT INTO cases (case_id,attorney_name,win_status,case_date) VALUES (1,'Thompson',false,'2019-01-01'),(2,'Thompson',true,'2020-05-15'),(3,'Thompson',false,'2021-07-20'),(4,'Thompson',true,'2020-12-31'),(5,'Thompson',false,'... | SELECT COUNT(*) FROM cases WHERE attorney_name = 'Thompson' AND win_status = false AND case_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); |
List the names and locations of all projects in the Transportation_Infrastructure table | CREATE TABLE Transportation_Infrastructure (project_id INT,project_name VARCHAR(50),location VARCHAR(50)); | SELECT project_name, location FROM Transportation_Infrastructure; |
Delete all records of Baroque pieces sold between 1600 and 1650? | CREATE TABLE art_pieces (id INT,style VARCHAR(20),year_sold INT,price DECIMAL(10,2)); CREATE VIEW baroque_sales AS SELECT * FROM art_pieces WHERE style = 'Baroque' AND year_sold BETWEEN 1600 AND 1650; | DELETE FROM baroque_sales; |
Who is the top carbon emitter in Southeast Asia? | CREATE TABLE carbon_emissions_sea (id INT,country VARCHAR(255),emissions FLOAT); INSERT INTO carbon_emissions_sea (id,country,emissions) VALUES (1,'Indonesia',500.3),(2,'Thailand',350.2),(3,'Philippines',200.9),(4,'Malaysia',150.5); | SELECT country FROM carbon_emissions_sea WHERE emissions = (SELECT MAX(emissions) FROM carbon_emissions_sea WHERE country IN ('Southeast Asia')); |
What is the minimum flight safety score for flights operated by GlobalAirlines in Africa? | CREATE TABLE FlightSafety (flight_id INT,airline VARCHAR(255),region VARCHAR(255),safety_score INT); | SELECT MIN(safety_score) FROM FlightSafety WHERE airline = 'GlobalAirlines' AND region = 'Africa'; |
Update the mobile_plans table to add a new plan with a name "Unlimited Data Family Plan" and monthly_cost 80.00 | CREATE TABLE mobile_plans (plan_id INT,plan_name VARCHAR(50),monthly_cost DECIMAL(5,2)); | UPDATE mobile_plans SET plan_name = 'Unlimited Data Family Plan', monthly_cost = 80.00 WHERE plan_id = (SELECT MAX(plan_id) FROM mobile_plans) + 1; |
Students with poor mental health and high grades | CREATE TABLE students (id INT,name VARCHAR(50),mental_health_score INT,grade INT); INSERT INTO students (id,name,mental_health_score,grade) VALUES (1,'John Doe',55,9); | SELECT name FROM students WHERE mental_health_score < 60 AND grade > 8; |
What is the total number of employees in the mining industry, broken down by gender? | CREATE TABLE employee_data (id INT,mining_operation_id INT,gender VARCHAR(10)); | SELECT gender, COUNT(*) FROM employee_data GROUP BY gender; |
What is the total carbon pricing revenue in California in 2020? | CREATE TABLE carbon_pricing (id INT,state TEXT,year INT,revenue FLOAT); INSERT INTO carbon_pricing (id,state,year,revenue) VALUES (1,'California',2020,500.0),(2,'California',2019,400.0); | SELECT SUM(revenue) FROM carbon_pricing WHERE state = 'California' AND year = 2020; |
Which community development programs were launched in a specific year and their budgets in the 'community_development' table? | CREATE TABLE community_development (id INT,program_name VARCHAR(50),launch_year INT,budget DECIMAL(10,2)); INSERT INTO community_development (id,program_name,launch_year,budget) VALUES (1,'Youth Skills Training',2013,15000.00),(2,'Women Empowerment',2016,20000.00); | SELECT program_name, budget FROM community_development WHERE launch_year = 2013; |
How many artists in the database are from Africa? | CREATE TABLE artists (id INT,name TEXT,country TEXT); INSERT INTO artists (id,name,country) VALUES (1,'Artist A','Nigeria'),(2,'Artist B','South Africa'),(3,'Artist C','France'); | SELECT COUNT(*) FROM artists WHERE country IN ('Nigeria', 'South Africa', 'Egypt', 'Kenya'); |
How many fish were farmed in each country for the past 5 years? | CREATE TABLE Country (CountryID INT,CountryName TEXT); CREATE TABLE Farm (FarmID INT,FarmName TEXT,CountryID INT,EstablishedDate DATE); INSERT INTO Country VALUES (1,'Norway'); INSERT INTO Country VALUES (2,'Canada'); INSERT INTO Farm VALUES (1,'Farm J',1,'2017-01-01'); INSERT INTO Farm VALUES (2,'Farm K',2,'2018-01-01... | SELECT CountryName, EXTRACT(YEAR FROM DATE_ADD(EstablishedDate, INTERVAL (YEAR(CURRENT_DATE) - YEAR(EstablishedDate)) YEAR)) AS Year, COUNT(*) AS FarmCount FROM Country INNER JOIN Farm ON Country.CountryID = Farm.CountryID GROUP BY CountryName, Year; |
What is the total number of transactions and their average value for the digital asset 'Bitcoin'? | CREATE TABLE digital_assets (asset_name VARCHAR(20),transactions INT,total_value FLOAT); INSERT INTO digital_assets (asset_name,transactions,total_value) VALUES ('Bitcoin',500000,50000000); | SELECT 'Bitcoin' AS asset_name, COUNT(*) AS transactions, AVG(total_value) AS avg_value FROM digital_assets WHERE asset_name = 'Bitcoin'; |
What is the total number of 'Disaster Response' and 'Refugee Support' projects completed in 'Middle East' in each year? | CREATE TABLE Projects_Completed (id INT,location VARCHAR(50),year INT,sector VARCHAR(50),completed BOOLEAN); | SELECT year, SUM(completed) as total_completed FROM Projects_Completed WHERE location = 'Middle East' AND (sector = 'Disaster Response' OR sector = 'Refugee Support') GROUP BY year; |
What is the maximum total cost of a project in the 'Bridge_Construction' table? | CREATE TABLE Bridge_Construction (project_id INT,project_name VARCHAR(50),location VARCHAR(50),total_cost FLOAT); INSERT INTO Bridge_Construction (project_id,project_name,location,total_cost) VALUES (1,'New Bridge Construction','River Crossing',15000000.00),(2,'Bridge Rehabilitation','City Outskirts',2000000.00); | SELECT MAX(total_cost) FROM Bridge_Construction; |
Insert a new record into the algorithmic_fairness table for the 'Lorenz Curve' algorithm with a fairness score of 0.85. | CREATE TABLE algorithmic_fairness (algorithm_id INT,algorithm_name TEXT,fairness_score REAL); | INSERT INTO algorithmic_fairness (algorithm_id, algorithm_name, fairness_score) VALUES (1, 'Lorenz Curve', 0.85); |
What is the percentage of emergency incidents in rural areas that are medical emergencies? | CREATE TABLE emergency_incidents (id INT,incident_type VARCHAR(20),location VARCHAR(20),date DATE); | SELECT (COUNT(*) FILTER (WHERE incident_type = 'medical_emergency')::FLOAT / COUNT(*)::FLOAT) * 100.0 FROM emergency_incidents WHERE location = 'rural'; |
What is the total number of peacekeeping operations conducted by each region from 2017 to 2019? | CREATE TABLE PeacekeepingOperationsByRegion (Year INT,Region VARCHAR(50),Operations INT); INSERT INTO PeacekeepingOperationsByRegion (Year,Region,Operations) VALUES (2017,'Africa',20),(2017,'Europe',15),(2017,'Asia',10),(2018,'Africa',25),(2018,'Europe',20),(2018,'Asia',15),(2019,'Africa',30),(2019,'Europe',25),(2019,'... | SELECT Region, SUM(Operations) FROM PeacekeepingOperationsByRegion WHERE Year BETWEEN 2017 AND 2019 GROUP BY Region; |
What is the average carbon sequestration rate for each region? | CREATE TABLE RegionCarbonSequestration (region_id INT,sequestration_rate DECIMAL(5,2)); INSERT INTO RegionCarbonSequestration (region_id,sequestration_rate) VALUES (1,11.5),(2,13.0),(3,12.0),(4,10.5); | SELECT Rcs.region_id, AVG(Rcs.sequestration_rate) as avg_sequestration_rate FROM RegionCarbonSequestration Rcs GROUP BY Rcs.region_id; |
What is the minimum price of lutetium produced in Brazil? | CREATE TABLE lutetium_production (country VARCHAR(255),price DECIMAL(10,2)); INSERT INTO lutetium_production (country,price) VALUES ('Brazil',320.00); | SELECT MIN(price) FROM lutetium_production WHERE country = 'Brazil'; |
What are the names and ranks of all intelligence officers in the 'Intelligence' table? | CREATE TABLE Intelligence (id INT,name VARCHAR(50),rank VARCHAR(50),specialization VARCHAR(50)); INSERT INTO Intelligence (id,name,rank,specialization) VALUES (1,'Alice Johnson','Lieutenant','Cybersecurity'); INSERT INTO Intelligence (id,name,rank,specialization) VALUES (2,'Bob Brown','Commander','Signal Intelligence')... | SELECT name, rank FROM Intelligence WHERE specialization LIKE '%intelligence%'; |
Update the maximum depth of the Mariana Trench | CREATE TABLE trenches (name VARCHAR(255),ocean VARCHAR(255),max_depth INT); | UPDATE trenches SET max_depth = 36198 WHERE name = 'Mariana Trench'; |
How many food safety inspections were conducted in Canada in the last year? | CREATE TABLE Inspections (inspection_date DATE,country VARCHAR(50)); INSERT INTO Inspections (inspection_date,country) VALUES ('2021-01-01','Canada'),('2021-02-01','Canada'),('2021-03-01','Canada'); | SELECT COUNT(*) AS inspection_count FROM Inspections WHERE country = 'Canada' AND inspection_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
Find the average temperature of the 'Indian Ocean' over the last 10 years. | CREATE TABLE yearly_temps (id INTEGER,location VARCHAR(255),year INTEGER,temperature REAL); | SELECT AVG(temperature) FROM yearly_temps WHERE location = 'Indian Ocean' AND year BETWEEN (YEAR(CURRENT_DATE) - 10) AND YEAR(CURRENT_DATE); |
Which companies have manufactured satellites with the type 'Communications'? | CREATE TABLE Manufacturer (name VARCHAR(50),country VARCHAR(50),domain VARCHAR(20)); INSERT INTO Manufacturer (name,country,domain) VALUES ('Mitsubishi Heavy Industries','Japan','Aerospace'); INSERT INTO Manufacturer (name,country,domain) VALUES ('Nissan Space Agency','Japan','Aerospace'); INSERT INTO Manufacturer (nam... | SELECT m.name, m.country FROM Manufacturer m INNER JOIN Satellite s ON m.name = s.manufacturer WHERE s.type = 'Communications'; |
list the names and average temperatures for arctic weather stations with more than 500 measurements | CREATE TABLE weather_stations (station_id INT PRIMARY KEY,station_name TEXT,location TEXT); CREATE TABLE measurements (measurement_id INT PRIMARY KEY,station_id INT,temperature REAL,measurement_date DATE); INSERT INTO weather_stations (station_id,station_name,location) VALUES (1,'Station A','Arctic'); INSERT INTO measu... | SELECT w.station_name, AVG(m.temperature) FROM weather_stations w INNER JOIN measurements m ON w.station_id = m.station_id GROUP BY w.station_id HAVING COUNT(m.measurement_id) > 500; |
What is the total weight of seafood deliveries from local suppliers in the Pacific Northwest region? | CREATE TABLE Suppliers (SupplierID INT,SupplierName VARCHAR(50),Region VARCHAR(50)); INSERT INTO Suppliers (SupplierID,SupplierName,Region) VALUES (1,'Ocean Bounty','Pacific Northwest'),(2,'Green Gardens','California'),(3,'Sunrise Farms','Midwest'); CREATE TABLE Deliveries (DeliveryID INT,SupplierID INT,DeliveryDate DA... | SELECT SUM(Weight) AS TotalWeight FROM Deliveries D INNER JOIN Suppliers S ON D.SupplierID = S.SupplierID WHERE S.Region = 'Pacific Northwest' AND D.DeliveryDate >= '2022-01-01' AND D.DeliveryDate < '2022-02-01' AND S.SupplierName IN ('Ocean Bounty'); |
Add a new satellite project 'Satellite XYZ' launched by 'NASA' | CREATE TABLE satellite_projects (id INT PRIMARY KEY,name VARCHAR(255),organization VARCHAR(255),launch_date DATE); | INSERT INTO satellite_projects (id, name, organization, launch_date) VALUES (1, 'Satellite XYZ', 'NASA', '2025-04-22'); |
Delete all records from the Donors table where the Country is 'USA' | CREATE TABLE Donors (Donor_ID int,Name varchar(50),Donation_Amount int,Country varchar(50)); INSERT INTO Donors (Donor_ID,Name,Donation_Amount,Country) VALUES (1,'John Doe',7000,'USA'),(2,'Jane Smith',3000,'Canada'),(3,'Mike Johnson',4000,'USA'),(4,'Emma Wilson',8000,'Kenya'),(5,'Aisha Ahmed',6000,'USA'); | DELETE FROM Donors WHERE Country = 'USA'; |
Find the number of LEED certified buildings in California. | CREATE TABLE buildings (id INT,name TEXT,state TEXT,leed_certification TEXT); INSERT INTO buildings (id,name,state,leed_certification) VALUES (1,'Building A','Texas','Platinum'),(2,'Building B','California','Gold'),(3,'Building C','California','Platinum'),(4,'Building D','Texas','Gold'),(5,'Building E','New York','Plat... | SELECT COUNT(*) FROM buildings WHERE leed_certification IS NOT NULL AND state = 'California'; |
What is the average number of courses completed by teachers in each school? | CREATE TABLE schools (school_id INT,school_name VARCHAR(255)); CREATE TABLE teachers (teacher_id INT,school_id INT); CREATE TABLE courses (course_id INT,course_name VARCHAR(255)); CREATE TABLE teacher_courses (teacher_id INT,course_id INT); | SELECT s.school_name, AVG(tc.course_id) FROM schools s JOIN teachers t ON s.school_id = t.school_id JOIN teacher_courses tc ON t.teacher_id = tc.teacher_id GROUP BY s.school_id; |
What is the average CO2 emission per transaction for each vendor? | CREATE TABLE Vendor (VendorID INT,VendorName VARCHAR(50),CO2Emission INT); INSERT INTO Vendor (VendorID,VendorName,CO2Emission) VALUES (1,'VendorA',50),(2,'VendorB',75); | SELECT VendorName, AVG(CO2Emission) AS AvgCO2EmissionPerTransaction FROM Vendor GROUP BY VendorName; |
Count the number of excavation sites in 'Africa'. | CREATE TABLE excavation_site_continent (site_id INTEGER,site_name TEXT,country TEXT,continent TEXT); INSERT INTO excavation_site_continent (site_id,site_name,country,continent) VALUES (1,'Carthage','Tunisia','Africa'),(2,'Great Zimbabwe','Zimbabwe','Africa'),(3,'Lalibela','Ethiopia','Africa'),(4,'Meroe','Sudan','Africa... | SELECT COUNT(site_name) FROM excavation_site_continent WHERE continent = 'Africa'; |
Insert a new environmental impact assessment for 'Ammonia' in the "environmental_impact" table | CREATE TABLE environmental_impact (id INT PRIMARY KEY,chemical_name VARCHAR(255),environmental_impact VARCHAR(255),date_assessed DATE); | INSERT INTO environmental_impact (id, chemical_name, environmental_impact, date_assessed) VALUES (1, 'Ammonia', 'High greenhouse gas emissions', '2022-01-01'); |
How many accommodations were provided for students with visual impairments? | CREATE TABLE accommodation (id INT,student_id INT,type VARCHAR(255)); INSERT INTO accommodation (id,student_id,type) VALUES (1,1,'Extra Time'),(2,2,'Assistive Technology'),(3,3,'Large Print'),(4,4,'Braille'); INSERT INTO accommodation (id,student_id,type) VALUES (5,5,'Extra Time'),(6,6,'Assistive Technology'),(7,7,'Sig... | SELECT COUNT(a.id) as visual_impairment_accommodations FROM accommodation a WHERE a.type IN ('Large Print', 'Braille'); |
Find the number of satellites launched by each country between 2018 and 2020? | CREATE TABLE Satellites (id INT,name VARCHAR(100),manufacturer VARCHAR(100),launch_country VARCHAR(100),launch_date DATE); INSERT INTO Satellites (id,name,manufacturer,launch_country,launch_date) VALUES (1,'Sat1','SpaceTech','USA','2020-01-01'); INSERT INTO Satellites (id,name,manufacturer,launch_country,launch_date) V... | SELECT launch_country, COUNT(*) OVER (PARTITION BY launch_country) as count FROM Satellites WHERE EXTRACT(YEAR FROM launch_date) BETWEEN 2018 AND 2020; |
What is the total number of military personnel in each branch, by country? | CREATE TABLE military_personnel_2 (country VARCHAR(50),branch VARCHAR(50),number INT); INSERT INTO military_personnel_2 (country,branch,number) VALUES ('USA','Army',470000),('USA','Navy',325000),('USA','Air Force',322000),('Russia','Army',350000),('Russia','Navy',145000),('Russia','Air Force',165000),('China','Army',17... | SELECT country, branch, SUM(number) as total_personnel FROM military_personnel_2 GROUP BY country, branch; |
Who are the top 3 donors based on total donation amounts? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,Country TEXT); INSERT INTO Donors (DonorID,DonorName,Country) VALUES (1,'John Doe','USA'),(2,'Jane Smith','Canada'),(3,'Mary Johnson','USA'); CREATE TABLE Donations (DonationID INT,DonorID INT,Amount DECIMAL); INSERT INTO Donations (DonationID,DonorID,Amount) VALUES (1,1,... | SELECT Donors.DonorName, SUM(Donations.Amount) AS TotalDonated FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID GROUP BY Donors.DonorName ORDER BY TotalDonated DESC LIMIT 3; |
What is the average minutes used by each region? | CREATE TABLE region_minutes_usage (region VARCHAR(255),minutes_used INT); | SELECT region, AVG(minutes_used) AS avg_minutes_used FROM region_minutes_usage GROUP BY region; |
What is the average time between accidents for each aircraft type? | CREATE TABLE AircraftType (ID INT,Name VARCHAR(50)); CREATE TABLE Accidents (AircraftTypeID INT,AccidentDate DATE); | SELECT at.Name, AVG(DATEDIFF(d, a1.AccidentDate, a2.AccidentDate)) AS AvgTimeBetweenAccidents FROM Accidents a1 JOIN Accidents a2 ON a1.AircraftTypeID = a2.AircraftTypeID JOIN AircraftType at ON a1.AircraftTypeID = at.ID GROUP BY at.Name; |
What is the earliest launch date for a space mission? | CREATE TABLE missions(name TEXT,agency TEXT,launch_date TEXT); INSERT INTO missions(name,agency,launch_date) VALUES('Apollo 11','NASA','1969-07-16'),('Apollo 13','NASA','1970-04-11'),('Sputnik 1','Russia','1957-10-04'); | SELECT MIN(launch_date) FROM missions; |
Find the average budget of the departments in the 'city_expenses' database that have 'Public' in their name. | CREATE TABLE department (id INT,name VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO department (id,name,budget) VALUES (1,'Public Works',500000.00),(2,'Education',800000.00),(3,'Health',700000.00),(4,'Parks',300000.00),(5,'Libraries',600000.00),(6,'Public Safety',750000.00); | SELECT AVG(budget) FROM department WHERE name LIKE '%Public%'; |
What investments have more than one risk assessment? | CREATE TABLE risk_assessment (id INT PRIMARY KEY,investment_id INT,risk_level VARCHAR(255)); INSERT INTO risk_assessment (id,investment_id,risk_level) VALUES (1,1,'Low'),(2,1,'Medium'),(3,2,'High'); | SELECT investment_id, COUNT(*) as num_risk_assessments FROM risk_assessment GROUP BY investment_id HAVING num_risk_assessments > 1; |
How many intelligence operations were conducted per year? | CREATE TABLE IntelOps (id INT,name VARCHAR(50),agency VARCHAR(50),location VARCHAR(50),start_date DATE); INSERT INTO IntelOps (id,name,agency,location,start_date) VALUES (1,'Operation Cyclone','CIA','Afghanistan','1979-07-03'); | SELECT YEAR(start_date), COUNT(*) FROM IntelOps GROUP BY YEAR(start_date); |
Find the average total funding for biotech startups. | CREATE TABLE startups(id INT,name VARCHAR(50),sector VARCHAR(50),total_funding FLOAT);INSERT INTO startups (id,name,sector,total_funding) VALUES (1,'StartupA','Genetics',20000000);INSERT INTO startups (id,name,sector,total_funding) VALUES (2,'StartupB','Bioprocess',15000000); | SELECT AVG(total_funding) FROM startups WHERE sector = 'Bioprocess'; |
What is the maximum number of articles published in a day by "Al Jazeera" in 2022? | CREATE TABLE articles (id INT,title TEXT,publication TEXT,published_at DATE); INSERT INTO articles (id,title,publication,published_at) VALUES (1,'Article 1','Al Jazeera','2022-01-01'); INSERT INTO articles (id,title,publication,published_at) VALUES (2,'Article 2','Al Jazeera','2022-01-02'); INSERT INTO articles (id,tit... | SELECT MAX(cnt) FROM (SELECT published_at, COUNT(*) as cnt FROM articles WHERE publication = 'Al Jazeera' AND YEAR(published_at) = 2022 GROUP BY published_at) as t; |
What is the average severity of vulnerabilities in the financial sector? | CREATE TABLE vulnerabilities (id INT,sector VARCHAR(20),severity VARCHAR(10));INSERT INTO vulnerabilities (id,sector,severity) VALUES (1,'Financial','High');INSERT INTO vulnerabilities (id,sector,severity) VALUES (2,'Retail','Medium');INSERT INTO vulnerabilities (id,sector,severity) VALUES (3,'Financial','Low');INSERT ... | SELECT AVG(severity) FROM vulnerabilities WHERE sector = 'Financial'; |
list the projects in the 'resilience_standards' table that have a start date within the next 60 days and a total cost greater than $500,000, ordered by their start date. | CREATE TABLE resilience_standards (id INT,name VARCHAR(50),location VARCHAR(50),start_date DATE,completion_date DATE,total_cost FLOAT); | SELECT * FROM resilience_standards WHERE start_date >= GETDATE() AND start_date < DATEADD(day, 60, GETDATE()) AND total_cost > 500000 ORDER BY start_date; |
What is the earliest date each department submitted evidence for policy making? | CREATE TABLE PolicyEvidence (department VARCHAR(50),evidence_date DATE); INSERT INTO PolicyEvidence (department,evidence_date) VALUES ('Health','2022-02-01'),('Education','2022-03-01'),('Transportation','2022-01-01'),('Health','2022-02-15'); | SELECT department, MIN(evidence_date) AS earliest_date FROM PolicyEvidence GROUP BY department; |
Update the size diversity policy to true for all brands from India. | CREATE TABLE brands (id INT,name VARCHAR(255),country VARCHAR(255),size_diversity_policy BOOLEAN); INSERT INTO brands (id,name,country,size_diversity_policy) VALUES (1,'BrandA','USA',true),(2,'BrandB','Canada',false),(3,'BrandC','France',true),(4,'BrandD','UK',true),(5,'BrandE','India',false),(6,'BrandF','Italy',true),... | UPDATE brands SET size_diversity_policy = true WHERE country = 'India'; |
What is the minimum budget allocated for public transportation in the city of New York? | CREATE TABLE city_services (city VARCHAR(20),service VARCHAR(20),budget INT); INSERT INTO city_services (city,service,budget) VALUES ('New York','Public Transportation',2000000); | SELECT MIN(budget) FROM city_services WHERE city = 'New York' AND service = 'Public Transportation'; |
How many times has each program been offered in Chicago and how many attendees have there been on average? | CREATE TABLE program_offerings (id INT,city VARCHAR(10),program VARCHAR(15),num_offerings INT,avg_attendees FLOAT); INSERT INTO program_offerings (id,city,program,num_offerings,avg_attendees) VALUES (1,'Chicago','Program1',3,25.5),(2,'Chicago','Program2',4,18.3); | SELECT po.program, SUM(po.num_offerings), AVG(po.avg_attendees) FROM program_offerings po WHERE po.city = 'Chicago' GROUP BY po.program; |
What is the average annual budget of municipalities in each region? | CREATE TABLE Region (Id INT,Name VARCHAR(50)); INSERT INTO Region (Id,Name) VALUES (1,'RegionA'); INSERT INTO Region (Id,Name) VALUES (2,'RegionB'); CREATE TABLE Municipality (Id INT,Name VARCHAR(50),RegionId INT,AnnualBudget FLOAT); INSERT INTO Municipality (Id,Name,RegionId,AnnualBudget) VALUES (1,'MunicipalityA',1,1... | SELECT r.Name AS RegionName, AVG(m.AnnualBudget) AS AverageAnnualBudget FROM Municipality m JOIN Region r ON m.RegionId = r.Id GROUP BY r.Name; |
What is the maximum missile contract value? | CREATE TABLE contracts (id INT,category VARCHAR(255),value DECIMAL(10,2));INSERT INTO contracts (id,category,value) VALUES (1,'Aircraft',5000000.00),(2,'Missiles',2000000.00),(3,'Shipbuilding',8000000.00),(4,'Cybersecurity',3000000.00),(5,'Aircraft',6000000.00),(6,'Shipbuilding',9000000.00),(7,'Missiles',4000000.00); | SELECT MAX(value) as max_value FROM contracts WHERE category = 'Missiles'; |
Delete the space debris records with a removal_date before 2010-01-01 from the space_debris_data table | CREATE TABLE space_debris_data (debris_id INT,name VARCHAR(255),removal_date DATE); INSERT INTO space_debris_data (debris_id,name,removal_date) VALUES (1,'Debris 1','2005-05-01'),(2,'Debris 2','2012-02-25'),(3,'Debris 3','2008-09-10'); | DELETE FROM space_debris_data WHERE removal_date < '2010-01-01'; |
Which artist has created the most sculptures in our contemporary art collection? | CREATE TABLE Artworks (id INT,title VARCHAR(50),medium VARCHAR(50),artist_id INT); CREATE TABLE Artists (id INT,name VARCHAR(50),nationality VARCHAR(50)); | SELECT Artists.name, COUNT(Artworks.id) as sculpture_count FROM Artists INNER JOIN Artworks ON Artists.id = Artworks.artist_id WHERE Artworks.medium = 'Sculpture' AND Artists.nationality = 'Contemporary' GROUP BY Artists.name ORDER BY sculpture_count DESC LIMIT 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.