instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total grant amount awarded to minority serving institutions in 2021? | CREATE TABLE grants (id INT,institution_type VARCHAR(255),year INT,amount DECIMAL(10,2)); INSERT INTO grants (id,institution_type,year,amount) VALUES (1,'Minority Serving Institution',2021,75000),(2,'Research University',2021,150000),(3,'Liberal Arts College',2020,90000); | SELECT SUM(amount) FROM grants WHERE institution_type = 'Minority Serving Institution' AND year = 2021; |
What is the minimum budget (in USD) for smart city projects in the 'SmartCityProjects' table? | CREATE TABLE SmartCityProjects (id INT,projectName VARCHAR(50),budget DECIMAL(10,2),startDate DATE); INSERT INTO SmartCityProjects (id,projectName,budget,startDate) VALUES (1,'Intelligent Lighting System',8000000.50,'2021-01-01'),(2,'Smart Waste Management',5000000.00,'2021-05-15'),(3,'Advanced Traffic Management',12000000.25,'2022-03-20'); | SELECT MIN(budget) FROM SmartCityProjects; |
What is the sum of energy consumption in each continent? | CREATE TABLE energy_consumption (id INT,location VARCHAR(50),amount INT); INSERT INTO energy_consumption (id,location,amount) VALUES (1,'North America',12000),(2,'South America',15000),(3,'Europe',10000),(4,'Asia',18000),(5,'Africa',8000),(6,'Australia',9000); | SELECT substring(location, 1, 2) AS continent, SUM(amount) FROM energy_consumption GROUP BY continent; |
Which community health workers received more than two types of trainings? | CREATE TABLE CommunityHealthWorkerTrainings (WorkerID INT,Training VARCHAR(50)); INSERT INTO CommunityHealthWorkerTrainings (WorkerID,Training) VALUES (1,'Cultural Competency'),(2,'Mental Health First Aid'),(3,'Crisis Prevention'),(4,'Cultural Competency'),(5,'Motivational Interviewing'),(1,'Language Access'),(6,'Cultural Competency'),(7,'Mental Health First Aid'),(8,'Crisis Prevention'),(9,'Cultural Competency'),(10,'Motivational Interviewing'),(11,'Cultural Competency'),(12,'Mental Health First Aid'),(13,'Crisis Prevention'),(14,'Cultural Competency'),(15,'Motivational Interviewing'); | SELECT WorkerID FROM (SELECT WorkerID, COUNT(DISTINCT Training) as NumTrainings FROM CommunityHealthWorkerTrainings GROUP BY WorkerID) as distinct_trainings WHERE NumTrainings > 2; |
Name the top 3 countries with the most cultural heritage sites. | CREATE TABLE countries (country_id INT,country_name VARCHAR(255),region VARCHAR(255)); CREATE TABLE sites (site_id INT,site_name VARCHAR(255),country_name VARCHAR(255)); INSERT INTO countries (country_id,country_name,region) VALUES (1,'Egypt','Africa'); INSERT INTO sites (site_id,site_name,country_name) VALUES (1,'Pyramids of Giza','Egypt'); | SELECT country_name, COUNT(*) AS site_count FROM sites JOIN countries ON sites.country_name = countries.country_name WHERE region = 'Africa' GROUP BY country_name ORDER BY site_count DESC LIMIT 3; |
Show the number of virtual tours offered in each country. | CREATE TABLE virtual_tours (tour_id INT,country VARCHAR(50),tour_type VARCHAR(50)); | SELECT country, COUNT(tour_id) AS num_virtual_tours FROM virtual_tours GROUP BY country; |
How many virtual tours were engaged in the last month, by country? | CREATE TABLE virtual_tours (tour_id INT,tour_name TEXT,engagement INT,country TEXT); INSERT INTO virtual_tours (tour_id,tour_name,engagement,country) VALUES (1,'Tour A',250,'USA'),(2,'Tour B',300,'Canada'); | SELECT country, SUM(engagement) FROM virtual_tours WHERE engagement >= DATEADD(month, -1, GETDATE()) GROUP BY country; |
What is the average hotel rating for the 'luxury' hotels in the 'New York' region? | CREATE TABLE hotels (id INT,name VARCHAR(255),rating FLOAT,category VARCHAR(255),city VARCHAR(255)); INSERT INTO hotels (id,name,rating,category,city) VALUES (1,'Hotel 1',4.5,'luxury','New York'); INSERT INTO hotels (id,name,rating,category,city) VALUES (2,'Hotel 2',4.7,'luxury','New York'); | SELECT AVG(rating) FROM hotels WHERE category = 'luxury' AND city = 'New York'; |
Update the preservation status of heritage sites based on the data in the PreservationStatus table. | CREATE TABLE HeritageSites (site_id INT,site_name VARCHAR(20),site_type VARCHAR(20),preservation_status VARCHAR(10)); CREATE TABLE PreservationStatus (site_id INT,status_name VARCHAR(20),status_date DATE); | UPDATE HeritageSites hs SET hs.preservation_status = (SELECT status_name FROM PreservationStatus WHERE hs.site_id = PreservationStatus.site_id AND status_date = (SELECT MAX(status_date) FROM PreservationStatus WHERE site_id = PreservationStatus.site_id)) WHERE EXISTS (SELECT 1 FROM PreservationStatus WHERE HeritageSites.site_id = PreservationStatus.site_id); |
Find the maximum pollution level in the Mediterranean Sea. | CREATE TABLE Pollution_Monitoring (monitoring_location text,monitoring_date date,pollution_level numeric); | SELECT MAX(pollution_level) FROM Pollution_Monitoring WHERE monitoring_location LIKE '%Mediterranean%'; |
Identify the species unique to 'MarineResearchAreaA' and 'MarineResearchAreaB' | CREATE TABLE ResearchAreaSpecies (area VARCHAR(255),species VARCHAR(255)); INSERT INTO ResearchAreaSpecies (area,species) VALUES ('MarineResearchAreaA','Coral'),('MarineResearchAreaA','Starfish'),('MarineResearchAreaB','Jellyfish'); | (SELECT species FROM ResearchAreaSpecies WHERE area = 'MarineResearchAreaA' EXCEPT SELECT species FROM ResearchAreaSpecies WHERE area = 'MarineResearchAreaB') UNION (SELECT species FROM ResearchAreaSpecies WHERE area = 'MarineResearchAreaB' EXCEPT SELECT species FROM ResearchAreaSpecies WHERE area = 'MarineResearchAreaA'); |
Who are the directors who have directed the most movies? | CREATE TABLE movies (id INT,title VARCHAR(255),director_id INT); CREATE VIEW movies_per_director AS SELECT director_id as id,COUNT(*) as movies_count FROM movies GROUP BY director_id; INSERT INTO movies (id,title,director_id) VALUES (1,'Movie1',1),(2,'Movie2',2),(3,'Movie3',1),(4,'Movie4',3),(5,'Movie5',2); CREATE TABLE directors (id INT,name VARCHAR(255)); INSERT INTO directors (id,name) VALUES (1,'Director1'),(2,'Director2'),(3,'Director3'); | SELECT directors.name, movies_per_director.movies_count FROM directors JOIN movies_per_director ON directors.id = movies_per_director.id ORDER BY movies_count DESC; |
Delete all defense project timelines with Nigeria. | CREATE TABLE DefenseProjectTimelines (id INT PRIMARY KEY,project_name VARCHAR(50),negotiation_start_date DATE,negotiation_end_date DATE,country VARCHAR(50)); INSERT INTO DefenseProjectTimelines (id,project_name,negotiation_start_date,negotiation_end_date,country) VALUES (1,'S-400 Missile Defense System','2016-01-01','2018-01-01','Nigeria'),(2,'AK-12 Assault Rifle','2017-01-01','2019-01-01','Nigeria'); | DELETE FROM DefenseProjectTimelines WHERE country = 'Nigeria'; |
What is the total value of defense contracts signed with the Russian government in 2019? | CREATE TABLE DefenseContracts (id INT PRIMARY KEY,year INT,government VARCHAR(50),contract_value FLOAT); INSERT INTO DefenseContracts (id,year,government,contract_value) VALUES (1,2019,'Russian Government',5000000); INSERT INTO DefenseContracts (id,year,government,contract_value) VALUES (2,2019,'Russian Government',3000000); | SELECT SUM(contract_value) FROM DefenseContracts WHERE year = 2019 AND government = 'Russian Government'; |
What is the total value of military equipment sales by country for the year 2020, ordered from highest to lowest? | CREATE TABLE Military_Equipment_Sales (sale_id INT,sale_value FLOAT,sale_year INT,country VARCHAR(50)); | SELECT country, SUM(sale_value) as total_sales FROM Military_Equipment_Sales WHERE sale_year = 2020 GROUP BY country ORDER BY total_sales DESC; |
Delete all records of mining projects in Australia that were completed before 2015-01-01? | CREATE TABLE projects (id INT,name TEXT,continent TEXT,start_date DATE,end_date DATE); INSERT INTO projects (id,name,continent,start_date,end_date) VALUES (1,'Australia Coal','Australia','2010-01-01','2014-12-31'),(2,'Australia Iron Ore','Australia','2016-01-01','2019-12-31'); | DELETE FROM projects WHERE continent = 'Australia' AND end_date < '2015-01-01'; |
Find the name and productivity of the top 3 bauxite mines in India? | CREATE TABLE mine (id INT,name TEXT,location TEXT,mineral TEXT,productivity INT); INSERT INTO mine (id,name,location,mineral,productivity) VALUES (1,'NALCO','India','Bauxite',2000),(2,'Hindalco','India','Bauxite',1800),(3,'Vedanta','India','Bauxite',1600); | SELECT name, productivity FROM mine WHERE mineral = 'Bauxite' AND location = 'India' ORDER BY productivity DESC LIMIT 3; |
What is the total CO2 emissions per site for Mexican mining operations in 2018? | CREATE TABLE EnvironmentalImpact (Site VARCHAR(255),CO2Emissions INT,WaterUsage INT,WasteGeneration INT,ReportDate DATE,Country VARCHAR(255)); | SELECT Site, SUM(CO2Emissions) as TotalCO2Emissions FROM EnvironmentalImpact WHERE ReportDate BETWEEN '2018-01-01' AND '2018-12-31' AND Country = 'Mexico' GROUP BY Site; |
What is the average monthly data usage for postpaid mobile customers in each city? | CREATE TABLE mobile_customers (customer_id INT,name VARCHAR(50),data_usage FLOAT,city VARCHAR(50)); INSERT INTO mobile_customers (customer_id,name,data_usage,city) VALUES (1,'John Doe',3.5,'Seattle'); INSERT INTO mobile_customers (customer_id,name,data_usage,city) VALUES (2,'Jane Smith',4.2,'Seattle'); INSERT INTO mobile_customers (customer_id,name,data_usage,city) VALUES (3,'Bob Johnson',3.8,'New York'); INSERT INTO mobile_customers (customer_id,name,data_usage,city) VALUES (4,'Alice Williams',4.5,'New York'); | SELECT city, AVG(data_usage) FROM mobile_customers WHERE plan_type = 'postpaid' GROUP BY city; |
Which mobile subscribers have used more than twice the average monthly data usage? | CREATE TABLE subscribers(id INT,monthly_data_usage DECIMAL(5,2)); INSERT INTO subscribers(id,monthly_data_usage) VALUES (1,3.5),(2,4.2),(3,5.0),(4,2.0),(5,6.0); | SELECT id, monthly_data_usage FROM subscribers WHERE monthly_data_usage > 2*(SELECT AVG(monthly_data_usage) FROM subscribers); |
Find the top 3 genres with the highest revenue in 2022 for streaming services in the USA. | CREATE TABLE streaming_services (service_id INT,service_name VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO streaming_services (service_id,service_name,revenue) VALUES (1,'StreamingCo',5000000.00); CREATE TABLE genre_sales (sale_id INT,service_id INT,genre VARCHAR(255),sales DECIMAL(10,2)); INSERT INTO genre_sales (sale_id,service_id,genre,sales) VALUES (1,1,'Rock',150000.00); | SELECT genre, SUM(sales) as total_sales FROM genre_sales gs JOIN streaming_services s ON gs.service_id = s.service_id WHERE s.service_country = 'USA' AND s.service_year = 2022 GROUP BY genre ORDER BY total_sales DESC LIMIT 3; |
How many unique volunteers have participated in events held in the Pacific region in 2019? | CREATE TABLE events (event_id INT PRIMARY KEY,region VARCHAR(50),num_volunteers INT); INSERT INTO events (event_id,region,num_volunteers) VALUES (1,'Pacific',50),(2,'Atlantic',75),(3,'Pacific',80); | SELECT COUNT(DISTINCT region) FROM events WHERE region = 'Pacific' AND YEAR(event_date) = 2019; |
Show the number of unique donors for each cause area, excluding any duplicates. | CREATE TABLE donations (id INT,donor_id INT,amount INT); CREATE TABLE donors (id INT,name VARCHAR(30),cause_area VARCHAR(20)); INSERT INTO donors (id,name,cause_area) VALUES (1,'Sana','education'),(2,'Jamal','health'),(3,'Lila','health'),(4,'Hamza','education'); INSERT INTO donations (id,donor_id,amount) VALUES (1,1,500),(2,1,500),(3,2,700),(4,3,800),(5,4,500); | SELECT cause_area, COUNT(DISTINCT donor_id) FROM donations JOIN donors ON donations.donor_id = donors.id GROUP BY cause_area; |
Who has donated from 'IL'? | CREATE TABLE donors_3 (id INT PRIMARY KEY,name VARCHAR(50),age INT,city VARCHAR(50),state VARCHAR(50)); INSERT INTO donors_3 (id,name,age,city,state) VALUES (1,'John Doe',35,'New York','NY'),(2,'Jane Smith',40,'Buffalo','NY'),(3,'Mike Johnson',50,'Boston','MA'),(4,'Emily Davis',30,'Chicago','IL'); | SELECT donors_3.name FROM donors_3 INNER JOIN donations_5 ON donors_3.id = donations_5.donor_id WHERE donations_5.state = 'IL'; |
What is the total number of underwater archaeological sites in the Mediterranean Sea? | CREATE TABLE underwater_sites (name VARCHAR(255),location VARCHAR(255),type VARCHAR(255)); | SELECT COUNT(*) FROM underwater_sites WHERE location = 'Mediterranean Sea' AND type = 'archaeological site'; |
What is the number of players in the "Underground Fighters" game who have never lost a match? | CREATE TABLE MatchRecords (PlayerID INT,GameName VARCHAR(20),Wins INT,Losses INT); INSERT INTO MatchRecords (PlayerID,GameName,Wins,Losses) VALUES (5001,'Underground Fighters',18,0),(5002,'Underground Fighters',12,2),(5003,'Underground Fighters',20,1); | SELECT COUNT(*) FROM MatchRecords WHERE GameName = 'Underground Fighters' AND Losses = 0; |
List all players who have achieved Master rank or higher in the game's ranking system. | CREATE TABLE Players (id INT,game_id INT,rank ENUM('Bronze','Silver','Gold','Platinum','Diamond','Master','Grandmaster','Challenger')); INSERT INTO Players (id,game_id,rank) VALUES (1,1,'Gold'),(2,1,'Platinum'),(3,1,'Diamond'),(4,1,'Master'),(5,1,'Grandmaster'),(6,1,'Bronze'),(7,1,'Challenger'),(8,1,'Silver'); | SELECT * FROM Players WHERE rank IN ('Master', 'Grandmaster', 'Challenger'); |
Which countries have the highest adoption rate of VR technology in gaming? | CREATE TABLE gaming_vr (country VARCHAR(50),adoption_rate DECIMAL(5,2)); INSERT INTO gaming_vr (country,adoption_rate) VALUES ('United States',0.25),('Japan',0.18),('South Korea',0.32); | SELECT country, adoption_rate FROM gaming_vr ORDER BY adoption_rate DESC LIMIT 1; |
What are the total water consumption from rare earth element production in each country? | CREATE TABLE water_consumption (country VARCHAR(50),consumption INT); INSERT INTO water_consumption (country,consumption) VALUES ('China',25000),('USA',7000),('Australia',4000),('India',1000),('Brazil',500); | SELECT country, SUM(consumption) FROM water_consumption GROUP BY country; |
How many electric vehicles were sold in California in 2020 and 2021? | CREATE TABLE electric_vehicles (id INT,year INT,state VARCHAR(255),sales INT); INSERT INTO electric_vehicles (id,year,state,sales) VALUES (1,2020,'California',50000),(2,2021,'California',60000); | SELECT SUM(sales) FROM electric_vehicles WHERE state = 'California' AND year IN (2020, 2021); |
What is the average energy efficiency rating for buildings in different climate zones? | CREATE TABLE building_energy_zone1 (zone VARCHAR(255),efficiency FLOAT); INSERT INTO building_energy_zone1 (zone,efficiency) VALUES ('Zone 1 - Cold',0.7),('Zone 1 - Cold',0.75),('Zone 1 - Cold',0.8); CREATE TABLE building_energy_zone2 (zone VARCHAR(255),efficiency FLOAT); INSERT INTO building_energy_zone2 (zone,efficiency) VALUES ('Zone 2 - Mixed',0.65),('Zone 2 - Mixed',0.7),('Zone 2 - Mixed',0.75); | SELECT zone, AVG(efficiency) AS avg_efficiency FROM building_energy_zone1 GROUP BY zone UNION ALL SELECT zone, AVG(efficiency) AS avg_efficiency FROM building_energy_zone2 GROUP BY zone; |
What is the earliest installation date for solar panels in Italy? | CREATE TABLE solar_panels_italy (id INT,installation_date DATE); INSERT INTO solar_panels_italy (id,installation_date) VALUES (1,'2018-01-01'),(2,'2019-01-01'),(3,'2020-01-01'); | SELECT MIN(installation_date) as earliest_date FROM solar_panels_italy; |
Insert a new record into the sustainable_sourcing table with the following data: restaurant_id = 103, ingredient = 'Quinoa', sourcing_percentage = 95 | CREATE TABLE sustainable_sourcing (id INT PRIMARY KEY,restaurant_id INT,ingredient VARCHAR(50),sourcing_percentage DECIMAL(5,2)); | INSERT INTO sustainable_sourcing (restaurant_id, ingredient, sourcing_percentage) VALUES (103, 'Quinoa', 95); |
What was the average daily revenue for each cuisine type in the first quarter of 2022? | CREATE TABLE daily_revenue (date DATE,cuisine VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO daily_revenue (date,cuisine,revenue) VALUES ('2022-01-01','Italian',150.00),('2022-01-01','Mexican',120.00),('2022-01-02','Italian',170.00),('2022-01-02','Mexican',140.00); | SELECT cuisine, AVG(revenue) as avg_daily_revenue FROM daily_revenue WHERE date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY cuisine; |
How many space missions have been successful versus unsuccessful? | CREATE TABLE space_missions (mission TEXT,outcome TEXT); INSERT INTO space_missions (mission,outcome) VALUES ('Mission 1','Success'),('Mission 2','Failure'),('Mission 3','Success'),('Mission 4','Success'),('Mission 5','Failure'),('Mission 6','Failure'),('Mission 7','Success'); | SELECT outcome, COUNT(*) FROM space_missions GROUP BY outcome; |
Drop the 'autonomous_vehicles_view' | CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY,manufacturer VARCHAR(255),model VARCHAR(255),year INT,type VARCHAR(255),price FLOAT); | DROP VIEW autonomous_vehicles_view; |
Find the total number of trips made by shared autonomous vehicles in Seattle | CREATE TABLE shared_vehicles (id INT,vehicle_type VARCHAR(20),is_autonomous BOOLEAN,trip_count INT); INSERT INTO shared_vehicles (id,vehicle_type,is_autonomous,trip_count) VALUES (1,'ebike',false,1200),(2,'escooter',false,800),(3,'car',true,1500); CREATE TABLE city_data (city VARCHAR(20),has_autonomous_vehicles BOOLEAN); INSERT INTO city_data (city,has_autonomous_vehicles) VALUES ('Seattle',true),('Denver',false),('Portland',true); | SELECT SUM(trip_count) FROM shared_vehicles WHERE is_autonomous = true AND vehicle_type != 'ebike' AND vehicle_type != 'escooter' AND city IN (SELECT city FROM city_data WHERE has_autonomous_vehicles = true AND city = 'Seattle'); |
What is the average fuel efficiency of hybrid cars in Seoul? | CREATE TABLE hybrid_cars (car_id INT,fuel_efficiency INT); INSERT INTO hybrid_cars (car_id,fuel_efficiency) VALUES (1,40),(2,45),(3,50),(4,55); | SELECT AVG(fuel_efficiency) as avg_efficiency FROM hybrid_cars; |
Find the percentage of transactions in which a garment was sold at full price, per city. | CREATE TABLE Stores (StoreID INT,City VARCHAR(50)); INSERT INTO Stores VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'); CREATE TABLE Transactions (TransactionID INT,StoreID INT,FullPrice BOOLEAN); INSERT INTO Transactions VALUES (1,1,TRUE),(2,1,FALSE),(3,2,TRUE),(4,3,FALSE),(5,1,TRUE); | SELECT City, 100.0 * SUM(FullPrice) / COUNT(*) AS Full_Price_Percentage FROM Stores JOIN Transactions ON Stores.StoreID = Transactions.StoreID GROUP BY City; |
What is the total revenue for the 't-shirt' garment type? | CREATE TABLE sales (id INT,garment_type VARCHAR(20),color VARCHAR(20),price DECIMAL(10,2),quantity INT); | SELECT SUM(price * quantity) AS total_revenue FROM sales WHERE garment_type = 't-shirt'; |
Which sustainable fabric type has the highest order quantity? | CREATE TABLE orders (id INT,fabric_id INT,type VARCHAR(255),order_quantity INT); INSERT INTO orders (id,fabric_id,type,order_quantity) VALUES | SELECT type, MAX(order_quantity) FROM orders WHERE type LIKE '%Sustainable%' GROUP BY type; |
Alter the 'policyholders' table to add a new column 'zip_code' | CREATE TABLE policyholders (policyholder_id INT PRIMARY KEY,name VARCHAR(100),age INT,gender VARCHAR(10),city VARCHAR(50),state VARCHAR(50)); | ALTER TABLE policyholders ADD COLUMN zip_code VARCHAR(10); |
Update the address of policyholder with ID 3 to '123 Main St, San Francisco, CA'. | CREATE TABLE policyholders (id INT,name TEXT,address TEXT,state TEXT,policy_type TEXT); INSERT INTO policyholders (id,name,address,state,policy_type) VALUES (3,'Sophia Garcia','456 Elm St,Los Angeles,CA','California','Life'),(4,'Daniel Kim','789 Oak St,San Jose,CA','California','Health'); | UPDATE policyholders SET address = '123 Main St, San Francisco, CA' WHERE policyholders.id = 3; |
Insert data into 'waste_types' table | CREATE TABLE waste_types (id INT PRIMARY KEY,waste_type VARCHAR(255)); INSERT INTO waste_types (id,waste_type) VALUES (1,'Plastic'); | INSERT INTO waste_types (id, waste_type) VALUES (2, 'Paper'); |
How many drought impacts were reported for the Greenville Wastewater Treatment Plant in the month of January 2022? | CREATE TABLE WastewaterTreatmentFacilities (FacilityID INT,FacilityName VARCHAR(255),Address VARCHAR(255),City VARCHAR(255),State VARCHAR(255),ZipCode VARCHAR(10)); INSERT INTO WastewaterTreatmentFacilities (FacilityID,FacilityName,Address,City,State,ZipCode) VALUES (1,'Blue Ridge Wastewater Treatment Plant','1200 W Main St','Blue Ridge','GA','30513'),(2,'Greenville Wastewater Treatment Plant','450 Powerhouse Rd','Greenville','SC','29605'); CREATE TABLE DroughtImpact (ImpactID INT,FacilityID INT,ImpactDate DATE,ImpactDescription VARCHAR(255)); INSERT INTO DroughtImpact (ImpactID,FacilityID,ImpactDate,ImpactDescription) VALUES (1,1,'2022-01-01','Reduced flow due to drought conditions'),(2,1,'2022-01-05','Operational changes to conserve water'),(3,2,'2022-01-10','Water restriction measures in place'); | SELECT COUNT(*) FROM DroughtImpact WHERE FacilityID = 2 AND ImpactDate BETWEEN '2022-01-01' AND '2022-01-31'; |
How many water treatment plants are there in the province of Ontario, Canada? | CREATE TABLE water_treatment_plants_ontario (id INT,province VARCHAR); INSERT INTO water_treatment_plants_ontario (id,province) VALUES (1,'Ontario'),(2,'Quebec'),(3,'Ontario'),(4,'British Columbia'); | SELECT COUNT(*) FROM water_treatment_plants_ontario WHERE province = 'Ontario'; |
What is the average monthly water consumption per capita in urban areas? | CREATE TABLE urban_areas (id INT,city VARCHAR(50),population INT,monthly_consumption FLOAT); INSERT INTO urban_areas (id,city,population,monthly_consumption) VALUES (1,'New York',8500000,1200000000),(2,'Los Angeles',4000000,600000000); | SELECT AVG(monthly_consumption / population) FROM urban_areas; |
How many users have a heart rate over 120 BPM for more than 30 minutes in a workout session? | CREATE TABLE WorkoutData (UserID INT,WorkoutDate DATE,Duration INT,AvgHeartRate INT); INSERT INTO WorkoutData (UserID,WorkoutDate,Duration,AvgHeartRate) VALUES (1,'2022-01-01',60,100),(2,'2022-01-02',45,130),(3,'2022-01-03',30,125); | SELECT COUNT(*) FROM (SELECT UserID, SUM(Duration) FROM WorkoutData WHERE AvgHeartRate > 120 GROUP BY UserID) AS HighHR; |
What is the maximum, minimum, and average creativity score for AI-generated artworks in the 'creative_ai' table, grouped by artwork type? | CREATE TABLE creative_ai (artwork_type VARCHAR(20),creativity_score FLOAT); INSERT INTO creative_ai (artwork_type,creativity_score) VALUES ('painting',0.85),('sculpture',0.91),('painting',0.78),('music',0.95); | SELECT artwork_type, MIN(creativity_score) as min_score, MAX(creativity_score) as max_score, AVG(creativity_score) as avg_score FROM creative_ai GROUP BY artwork_type; |
Identify the number of agricultural innovation initiatives for historically underrepresented communities. | CREATE TABLE Communities (id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO Communities (id,name,type) VALUES (1,'C1','Historically Underrepresented'),(2,'C2','Mainstream'),(3,'C3','Historically Underrepresented'); CREATE TABLE Innovations (id INT,community_id INT,innovation_name VARCHAR(255),date DATE); INSERT INTO Innovations (id,community_id,innovation_name,date) VALUES (1,1,'Solar-Powered Irrigation','2021-03-01'),(2,3,'Drought-Resistant Crops','2020-09-15'),(3,2,'Precision Agriculture','2019-07-01'); | SELECT COUNT(Innovations.id) FROM Innovations INNER JOIN Communities ON Innovations.community_id = Communities.id WHERE Communities.type = 'Historically Underrepresented'; |
Display the total number of community education programs in the year 2021. | CREATE TABLE education_programs (program_date DATE,program_type VARCHAR(50)); | SELECT COUNT(*) FROM education_programs WHERE EXTRACT(YEAR FROM program_date) = 2021 AND program_type = 'community education program'; |
Update the population of 'Tiger' in the 'animal_population' table to 600. | CREATE TABLE animal_population (id INT,species VARCHAR(255),population INT); INSERT INTO animal_population (id,species,population) VALUES (1,'Tiger',500),(2,'Elephant',2000),(3,'Lion',800); | UPDATE animal_population SET population = 600 WHERE species = 'Tiger'; |
Which education programs have an instructor named 'Jane Smith'? | CREATE TABLE education_programs (id INT,program_name VARCHAR(50),instructor VARCHAR(50),start_date DATE,end_date DATE,enrollment INT); INSERT INTO education_programs (id,program_name,instructor,start_date,end_date,enrollment) VALUES (5,'Bird Identification and Monitoring','Jane Smith','2022-04-01','2022-05-31',25); INSERT INTO education_programs (id,program_name,instructor,start_date,end_date,enrollment) VALUES (6,'Wildlife Identification and Tracking','John Doe','2022-06-01','2022-08-31',30); | SELECT program_name FROM education_programs WHERE instructor = 'Jane Smith'; |
Calculate the average phosphorus level for fish farming in Scotland? | CREATE TABLE scotland_fish_farming (site_id INT,site_name TEXT,phosphorus FLOAT,country TEXT); INSERT INTO scotland_fish_farming (site_id,site_name,phosphorus,country) VALUES (1,'Site I',0.25,'Scotland'),(2,'Site J',0.32,'Scotland'),(3,'Site K',0.28,'Scotland'); | SELECT AVG(phosphorus) FROM scotland_fish_farming; |
What is the total amount of funding received by art programs in the 'Rural' areas? | CREATE SCHEMA if not exists arts_culture; CREATE TABLE if not exists arts_culture.programs(program_id INT,program_name VARCHAR(50),location VARCHAR(20)); CREATE TABLE if not exists arts_culture.funding(funding_id INT,program_id INT,amount INT); | SELECT SUM(funding.amount) FROM arts_culture.funding JOIN arts_culture.programs ON funding.program_id = programs.program_id WHERE programs.location = 'Rural'; |
Which regions had the highest number of first-time visitors to the theatre in 2022? | CREATE TABLE TheatreVisits (ID INT,VisitDate DATE,VisitorID INT,Region VARCHAR(50)); CREATE TABLE FirstTimeVisitors (ID INT,VisitorID INT,FirstVisit DATE); | SELECT r.Region, COUNT(DISTINCT v.VisitorID) as FirstTimeVisitorsCount FROM TheatreVisits v JOIN FirstTimeVisitors f ON v.VisitorID = f.VisitorID JOIN (SELECT DISTINCT Region FROM TheatreVisits WHERE VisitDate >= '2022-01-01' AND VisitDate < '2023-01-01') r ON v.Region = r.Region WHERE f.FirstVisit >= '2022-01-01' AND f.FirstVisit < '2023-01-01' GROUP BY r.Region ORDER BY FirstTimeVisitorsCount DESC; |
What is the total budget for all TV shows released in 2018? | CREATE TABLE Shows (id INT,title VARCHAR(255),type VARCHAR(10),release_year INT,budget DECIMAL(10,2)); INSERT INTO Shows (id,title,type,release_year,budget) VALUES (1,'Show1','Series',2018,2000000.00); INSERT INTO Shows (id,title,type,release_year,budget) VALUES (2,'Show2','Movie',2020,700000.00); | SELECT SUM(budget) FROM Shows WHERE type = 'Series' AND release_year = 2018; |
Show the construction labor statistics for the last quarter, for the Western region, and rank the statistics by their employee counts in descending order. | CREATE TABLE LaborStatsByQuarter (StatID int,Region varchar(20),Quarter int,Employees int); INSERT INTO LaborStatsByQuarter (StatID,Region,Quarter,Employees) VALUES (1,'Western',3,2500),(2,'Central',4,3000),(3,'Western',4,2800); | SELECT Region, Employees, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY Employees DESC) as rn FROM LaborStatsByQuarter WHERE Region = 'Western' AND Quarter IN (3, 4); |
What is the total area of sustainable building projects in the state of Texas that were completed before 2020? | CREATE TABLE sustainable_building_projects (project_id INT,project_name VARCHAR(100),state VARCHAR(50),completion_year INT,area DECIMAL(10,2)); INSERT INTO sustainable_building_projects (project_id,project_name,state,completion_year,area) VALUES (1,'GreenTowers','California',2021,50000),(2,'EcoHQ','Texas',2020,40000),(3,'SolarVilla','Washington',2019,30000); | SELECT SUM(area) FROM sustainable_building_projects WHERE state = 'Texas' AND completion_year < 2020; |
What are the top 5 states with the most dispensaries? | CREATE TABLE DispensariesByState (State TEXT,DispensaryCount INTEGER); INSERT INTO DispensariesByState (State,DispensaryCount) VALUES ('California',1000),('Colorado',750),('Oregon',550),('Washington',400),('Nevada',350); | SELECT State, DispensaryCount FROM DispensariesByState ORDER BY DispensaryCount DESC LIMIT 5; |
Add new record ('Magnesium Sulfate', 150, '2022-07-01') to 'chemical_usage' table | CREATE TABLE chemical_usage (id INT,chemical_name VARCHAR(50),usage_quantity INT,usage_date DATE); | INSERT INTO chemical_usage (chemical_name, usage_quantity, usage_date) VALUES ('Magnesium Sulfate', 150, '2022-07-01'); |
Insert a new record into the "chemicals" table | CREATE TABLE chemicals (id INT PRIMARY KEY,chemical_name VARCHAR(255),formula VARCHAR(255),hazard_level INT); | INSERT INTO chemicals (id, chemical_name, formula, hazard_level) VALUES (1, 'Ammonia', 'NH3', 2); |
List the names and capacities of all tanks located in the Northern region. | CREATE TABLE Tanks (name VARCHAR(20),capacity INT,location VARCHAR(20)); INSERT INTO Tanks (name,capacity,location) VALUES ('Tank1',50000,'Northern'),('Tank2',75000,'Southern'); | SELECT name, capacity FROM Tanks WHERE location = 'Northern'; |
What is the average safety score for chemical plants located in the United States, grouped by state, where the total number of safety inspections is greater than 10? | CREATE TABLE chemical_plants (plant_id INT,plant_name TEXT,location TEXT,safety_score INT,num_inspections INT); INSERT INTO chemical_plants (plant_id,plant_name,location,safety_score,num_inspections) VALUES (1,'Plant A','US-NY',95,12),(2,'Plant B','US-NY',92,8),(3,'Plant C','US-CA',88,15),(4,'Plant D','US-CA',90,7),(5,'Plant E','MX-MX',85,9); | SELECT location, AVG(safety_score) as avg_safety_score FROM chemical_plants WHERE location LIKE 'US-%' GROUP BY location HAVING SUM(num_inspections) > 10; |
Which adaptation projects in the 'climate_adaptation' table have a budget over 100000? | CREATE TABLE climate_adaptation (project_name TEXT,budget INTEGER); INSERT INTO climate_adaptation (project_name,budget) VALUES ('Green Roofs',50000),('Coastal Wetlands Restoration',120000),('Urban Forest Expansion',200000); | SELECT project_name FROM climate_adaptation WHERE budget > 100000; |
What is the infant mortality rate in Brazil? | CREATE TABLE Mortality (Country TEXT,Type TEXT,Rate INT); INSERT INTO Mortality (Country,Type,Rate) VALUES ('Brazil','Infant',20),('Brazil','Child',30),('Brazil','Maternal',40); | SELECT Rate FROM Mortality WHERE Country = 'Brazil' AND Type = 'Infant'; |
What is the total funding amount for startups founded by women in the transportation sector? | CREATE TABLE funding(startup_id INT,funding_amount DECIMAL(10,2)); INSERT INTO funding(startup_id,funding_amount) VALUES (1,200000.00); CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_gender TEXT); INSERT INTO startups(id,name,industry,founder_gender) VALUES (1,'TransportationWomen','Transportation','Female'); | SELECT SUM(funding_amount) FROM funding JOIN startups ON startups.id = funding.startup_id WHERE startups.industry = 'Transportation' AND startups.founder_gender = 'Female'; |
What is the average yield per acre for each crop type in urban agriculture? | CREATE TABLE crop_types (crop_type TEXT,acres NUMERIC,yield NUMERIC); INSERT INTO crop_types (crop_type,acres,yield) VALUES ('Wheat',2.1,13000),('Rice',3.5,18000),('Corn',4.2,25000),('Soybeans',2.9,16000),('Wheat',2.5,14000); | SELECT crop_type, AVG(yield/acres) as avg_yield_per_acre FROM crop_types GROUP BY crop_type; |
What is the average budget spent on disability support programs per university department? | CREATE TABLE Disability_Support_Data (Program_ID INT,Program_Name VARCHAR(50),Budget DECIMAL(10,2),Department VARCHAR(50)); | SELECT Department, AVG(Budget) as Avg_Budget FROM Disability_Support_Data GROUP BY Department; |
Identify smart contracts with an average gas usage above 50000 in the 'SmartContracts' table, partitioned by contract creator and ordered by the highest average gas usage in descending order. | CREATE TABLE SmartContracts (contract_address VARCHAR(40),contract_creator VARCHAR(40),gas_used INT,num_transactions INT); INSERT INTO SmartContracts (contract_address,contract_creator,gas_used,num_transactions) VALUES ('0x123','Alice',60000,10),('0x456','Bob',45000,15),('0x789','Alice',55000,12); | SELECT contract_creator, contract_address, AVG(gas_used) as avg_gas_usage, RANK() OVER (PARTITION BY contract_creator ORDER BY AVG(gas_used) DESC) as rank FROM SmartContracts GROUP BY contract_creator, contract_address HAVING avg_gas_usage > 50000 ORDER BY contract_creator, rank; |
What are the names and countries of origin for developers who have created more than 3 smart contracts? | CREATE TABLE Developers (DeveloperId INT,DeveloperName VARCHAR(50),Country VARCHAR(50)); CREATE TABLE SmartContracts (ContractId INT,ContractName VARCHAR(50),DeveloperId INT); INSERT INTO Developers (DeveloperId,DeveloperName,Country) VALUES (1,'Carla','Mexico'); INSERT INTO Developers (DeveloperId,DeveloperName,Country) VALUES (2,'Deepak','India'); INSERT INTO SmartContracts (ContractId,ContractName,DeveloperId) VALUES (1,'ContractA',1); INSERT INTO SmartContracts (ContractId,ContractName,DeveloperId) VALUES (2,'ContractB',1); INSERT INTO SmartContracts (ContractId,ContractName,DeveloperId) VALUES (3,'ContractC',1); INSERT INTO SmartContracts (ContractId,ContractName,DeveloperId) VALUES (4,'ContractD',2); | SELECT d.DeveloperName, d.Country FROM Developers d INNER JOIN SmartContracts sc ON d.DeveloperId = sc.DeveloperId GROUP BY d.DeveloperId, d.DeveloperName, d.Country HAVING COUNT(sc.ContractId) > 3; |
Who are the top 3 developers with the most decentralized applications on the blockchain platform? | CREATE TABLE developers (id INT,developer_name VARCHAR(50),developer_location VARCHAR(30)); CREATE TABLE dapps (id INT,dapp_name VARCHAR(50),dapp_category VARCHAR(30),dapp_platform VARCHAR(20),developer_id INT); INSERT INTO developers (id,developer_name,developer_location) VALUES (1,'John Doe','USA'); INSERT INTO dapps (id,dapp_name,dapp_category,dapp_platform,developer_id) VALUES (6,'Dapp 1','Category 1','Platform 1',1); INSERT INTO dapps (id,dapp_name,dapp_category,dapp_platform,developer_id) VALUES (7,'Dapp 2','Category 2','Platform 2',1); INSERT INTO developers (id,developer_name,developer_location) VALUES (2,'Jane Smith','Canada'); INSERT INTO dapps (id,dapp_name,dapp_category,dapp_platform,developer_id) VALUES (8,'Dapp 3','Category 3','Platform 3',2); | SELECT d.developer_name, COUNT(*) as dapp_count FROM developers d JOIN dapps da ON d.id = da.developer_id GROUP BY d.developer_name ORDER BY dapp_count DESC LIMIT 3; |
What is the average carbon sequestration rate for each tree species? | CREATE TABLE TreeSpecies (id INT,name VARCHAR(255)); INSERT INTO TreeSpecies (id,name) VALUES (1,'Oak'),(2,'Pine'),(3,'Maple'),(4,'Birch'); CREATE TABLE CarbonSequestration (species_id INT,sequestration_rate DECIMAL(5,2)); INSERT INTO CarbonSequestration (species_id,sequestration_rate) VALUES (1,12.5),(2,15.0),(3,10.5),(4,13.0),(1,13.0),(2,14.5),(3,11.0),(4,12.5); | SELECT Ts.id, Ts.name, AVG(Cs.sequestration_rate) as avg_sequestration_rate FROM CarbonSequestration Cs JOIN TreeSpecies Ts ON Cs.species_id = Ts.id GROUP BY Ts.id, Ts.name; |
Determine the most frequently purchased product by customers from the UK. | CREATE TABLE customer_purchases (customer_id INT,product_name VARCHAR(50),purchase_date DATE,country VARCHAR(50)); INSERT INTO customer_purchases (customer_id,product_name,purchase_date,country) VALUES (1,'Lipstick','2021-01-01','US'),(2,'Mascara','2021-01-05','US'),(3,'Lipstick','2021-01-10','CA'),(4,'Lipstick','2021-01-15','UK'),(5,'Foundation','2021-01-20','US'),(6,'Moisturizer','2021-02-01','UK'); | SELECT product_name, COUNT(*) as purchase_count FROM customer_purchases WHERE country = 'UK' GROUP BY product_name ORDER BY purchase_count DESC LIMIT 1; |
What is the average rating of halal-certified makeup products in Malaysia? | CREATE TABLE cosmetics (product_id INT,product_name VARCHAR(100),rating DECIMAL(2,1),is_halal_certified BOOLEAN,product_type VARCHAR(50)); | SELECT AVG(rating) FROM cosmetics WHERE is_halal_certified = TRUE AND product_type = 'makeup' AND country = 'Malaysia'; |
How many community policing events were held in the "north" region in 2020 and 2021, with more than 50 attendees? | CREATE TABLE community_policing_events (id INT,event_date DATE,location VARCHAR(20),attendees INT); | SELECT COUNT(*) FROM community_policing_events WHERE location = 'north' AND EXTRACT(YEAR FROM event_date) IN (2020, 2021) AND attendees > 50; |
Update the 'aid' value for 'Yemen' in the year 2018 to 1500000.00 in the 'humanitarian_assistance' table | CREATE TABLE humanitarian_assistance (id INT PRIMARY KEY,country VARCHAR(50),year INT,aid FLOAT,organization VARCHAR(50)); | WITH cte AS (UPDATE humanitarian_assistance SET aid = 1500000.00 WHERE country = 'Yemen' AND year = 2018 RETURNING *) INSERT INTO humanitarian_assistance SELECT * FROM cte; |
What is the maximum number of humanitarian assistance missions conducted by a single unit in a year? | CREATE TABLE HumanitarianAssistance (Year INT,Unit VARCHAR(50),Missions INT); INSERT INTO HumanitarianAssistance (Year,Unit,Missions) VALUES (2018,'Unit A',12),(2018,'Unit B',15),(2018,'Unit C',18); | SELECT Unit, MAX(Missions) FROM HumanitarianAssistance GROUP BY Unit; |
Update status to 'in-transit' for cargo records that have been at the destination for less than a week | CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.cargo (id INT,status VARCHAR(255),arrived_at DATE); | UPDATE ocean_shipping.cargo SET status = 'in-transit' WHERE arrived_at > DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND status = 'delivered'; |
List the names of all companies in the renewable energy sector that have implemented industry 4.0 technologies in Africa. | CREATE TABLE companies (id INT,name TEXT,country TEXT,industry TEXT,industry_4_0 BOOLEAN); INSERT INTO companies (id,name,country,industry,industry_4_0) VALUES (1,'GHI Corp','South Africa','Renewable Energy',TRUE),(2,'JKL Inc','Egypt','Oil and Gas',FALSE),(3,'MNO Co','Nigeria','Renewable Energy',FALSE); | SELECT name FROM companies WHERE industry = 'Renewable Energy' AND country IN ('South Africa', 'Egypt', 'Nigeria') AND industry_4_0 = TRUE; |
What is the total age of 'stone' artifacts in 'american_archaeology'? | CREATE TABLE american_archaeology (id INT,site_name VARCHAR(50),artifact_name VARCHAR(50),age INT,material VARCHAR(20)); | SELECT SUM(age) FROM american_archaeology WHERE material = 'stone'; |
What is the total healthcare expenditure for rural county 'Adirondacks'? | CREATE TABLE healthcare_expenditure (county TEXT,expenditure INTEGER); INSERT INTO healthcare_expenditure (county,expenditure) VALUES ('Adirondacks',500000),('Adirondacks',600000),('Adirondacks',700000); | SELECT SUM(expenditure) FROM healthcare_expenditure WHERE county = 'Adirondacks'; |
What was the percentage of total budget spent on programs with positive outcomes in 2021? | CREATE TABLE Programs (program_id INT,program_name VARCHAR(50),budget DECIMAL(10,2),outcome VARCHAR(10)); CREATE TABLE Outcomes (outcome_id INT,program_id INT,outcome_date DATE); | SELECT 100.0 * SUM(CASE WHEN outcome = 'positive' THEN budget ELSE 0 END) / SUM(budget) AS percentage FROM Programs WHERE program_id IN (SELECT program_id FROM Outcomes WHERE YEAR(outcome_date) = 2021); |
Delete all the student records with a mental health score below 70? | CREATE TABLE students (student_id INT,student_name VARCHAR(50),mental_health_score INT); INSERT INTO students (student_id,student_name,mental_health_score) VALUES (1,'John Doe',75),(2,'Jane Doe',80),(3,'Mike Johnson',85),(4,'Sara Connor',65); | DELETE FROM students WHERE mental_health_score < 70; |
What is the average number of professional development courses completed by teachers in each department? | CREATE TABLE teacher_professional_development (teacher_id INT,department VARCHAR(255),course_completed INT); INSERT INTO teacher_professional_development (teacher_id,department,course_completed) VALUES (1,'Math',3),(2,'Science',2),(3,'English',5),(4,'Math',4),(5,'Science',1),(6,'English',4); | SELECT department, AVG(course_completed) FROM teacher_professional_development GROUP BY department; |
What is the average salary for new hires in the last 3 months, segmented by department? | CREATE TABLE NewHires (EmployeeID INT,Department VARCHAR(20),Salary DECIMAL(10,2),HireDate DATE); INSERT INTO NewHires (EmployeeID,Department,Salary,HireDate) VALUES (1,'Marketing',80000.00,'2022-01-01'),(2,'IT',90000.00,'2022-02-15'); | SELECT Department, AVG(Salary) FROM NewHires WHERE HireDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY Department; |
Find the number of wells drilled in the year 2020 in Texas | CREATE TABLE wells (id INT,well_name VARCHAR(255),location VARCHAR(255),drill_year INT,company VARCHAR(255)); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (1,'Well001','Texas',2020,'CompanyA'); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (2,'Well002','Colorado',2019,'CompanyB'); | SELECT COUNT(*) FROM wells WHERE drill_year = 2020 AND location = 'Texas'; |
Show the number of games won by each team in the current season, sorted by the number of wins in descending order. | CREATE TABLE teams (team_id INT,team_name VARCHAR(100),city VARCHAR(50),league VARCHAR(50),division VARCHAR(50),games_played INT,at_bats INT,hits INT,home_runs INT,rbi INT,wins INT); INSERT INTO teams (team_id,team_name,city,league,division,games_played,at_bats,hits,home_runs,rbi,wins) VALUES (1,'Red Sox','Boston','AL','East',120,450,120,25,75,60); INSERT INTO teams (team_id,team_name,city,league,division,games_played,at_bats,hits,home_runs,rbi,wins) VALUES (2,'Yankees','New York','AL','East',130,500,145,30,80,70); | SELECT team_name, SUM(wins) as wins FROM teams WHERE league = 'AL' AND DATE_PART('year', game_date) = EXTRACT(YEAR FROM NOW()) GROUP BY team_name ORDER BY wins DESC; |
How many employees are there in the Ethical AI team who joined after 2021-06-01? | CREATE TABLE employee_roster (id INT,name VARCHAR(50),team VARCHAR(50),join_date DATE); INSERT INTO employee_roster (id,name,team,join_date) VALUES (1,'Jack','Ethical AI','2021-07-15'),(2,'Kate','Data Science','2022-04-01'),(3,'Luke','Ethical AI','2021-05-20'); | SELECT COUNT(*) FROM employee_roster WHERE team = 'Ethical AI' AND join_date > '2021-06-01'; |
Insert a new record for a developer who works on a digital divide project | CREATE TABLE developers (id INT,name VARCHAR(50),salary FLOAT,project VARCHAR(50)); | INSERT INTO developers (id, name, salary, project) VALUES (3, 'Charlie', 90000.0, 'Digital Divide'); |
What is the total number of ethical AI certifications issued by country? | CREATE TABLE EthicalAICertifications (CertificationID INT PRIMARY KEY,CountryName VARCHAR(100),CertificationCount INT); INSERT INTO EthicalAICertifications (CertificationID,CountryName,CertificationCount) VALUES (1,'USA',500),(2,'Canada',300),(3,'Mexico',200); | SELECT CountryName, SUM(CertificationCount) as TotalCertifications FROM EthicalAICertifications GROUP BY CountryName; |
Insert a new accessible vehicle in the 'yellow' line. | CREATE TABLE vehicles (line VARCHAR(10),type VARCHAR(20),accessibility BOOLEAN); | INSERT INTO vehicles (line, type, accessibility) VALUES ('yellow', 'bus', TRUE); |
Update the name of the passenger with the id 3 to 'Emily Lee'. | CREATE TABLE PASSENGERS (id INT,name VARCHAR(50)); INSERT INTO PASSENGERS VALUES (3,'James Brown'); | UPDATE PASSENGERS SET name = 'Emily Lee' WHERE id = 3; |
How many consumers are aware of circular economy principles? | CREATE TABLE consumers (id INT,aware_of_circular_economy BOOLEAN); INSERT INTO consumers (id,aware_of_circular_economy) VALUES (1,true),(2,false),(3,true),(4,true); | SELECT COUNT(*) FROM consumers WHERE aware_of_circular_economy = true; |
What is the total quantity of sustainable raw materials consumed by factories in Africa? | CREATE TABLE SustainableRawMaterials (id INT,material VARCHAR(50),quantity INT); INSERT INTO SustainableRawMaterials (id,material,quantity) VALUES (1,'Organic Cotton',5000),(2,'Reclaimed Wood',2000),(3,'Regenerated Leather',3000); CREATE TABLE AfricanFactories (id INT,factory_name VARCHAR(50),material VARCHAR(50),quantity INT); INSERT INTO AfricanFactories (id,factory_name,material,quantity) VALUES (1,'GreenFactory','Organic Cotton',2000),(2,'EcoTextiles','Reclaimed Wood',1000),(3,'SustainableWeaves','Regenerated Leather',1500); | SELECT SUM(AfricanFactories.quantity) FROM SustainableRawMaterials INNER JOIN AfricanFactories ON SustainableRawMaterials.material = AfricanFactories.material; |
How many posts were made by users in the "Asia-Pacific" region in the last week? | CREATE TABLE posts (id INT,user_id INT,region VARCHAR(20),post_date DATE); INSERT INTO posts (id,user_id,region,post_date) VALUES (1,1,'Asia-Pacific','2022-01-01'),(2,2,'Europe','2022-02-01'),(3,3,'Asia-Pacific','2022-03-01'),(4,4,'North America','2022-04-01'),(5,5,'Asia-Pacific','2022-06-01'); | SELECT COUNT(*) FROM posts WHERE region = 'Asia-Pacific' AND post_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK); |
What is the total advertising spend by companies from Mexico, in March 2022? | CREATE TABLE companies (id INT,name TEXT,country TEXT); INSERT INTO companies (id,name,country) VALUES (1,'Empresa1','Mexico'),(2,'Empresa2','Mexico'),(3,'Company3','Canada'),(4,'Firma4','Spain'); CREATE TABLE ad_spend (company_id INT,amount DECIMAL,date DATE); INSERT INTO ad_spend (company_id,amount,date) VALUES (1,1500,'2022-03-01'),(1,1200,'2022-03-05'),(2,1800,'2022-03-03'),(3,800,'2022-03-04'),(4,1000,'2022-03-04'); | SELECT SUM(ad_spend.amount) FROM ad_spend JOIN companies ON ad_spend.company_id = companies.id WHERE companies.country = 'Mexico' AND ad_spend.date >= '2022-03-01' AND ad_spend.date <= '2022-03-31'; |
How many customers prefer size 12 and above in women's clothing from Canada? | CREATE TABLE CanadianSizes (CustomerID INT,Country VARCHAR(255),PreferredSize INT); INSERT INTO CanadianSizes (CustomerID,Country,PreferredSize) VALUES (1,'CA',16),(2,'CA',14),(3,'CA',18),(4,'CA',12),(5,'CA',10); | SELECT COUNT(*) FROM CanadianSizes WHERE Country = 'CA' AND PreferredSize >= 12; |
What are the financial wellbeing programs in the United States and the United Kingdom? | CREATE TABLE fwp_programs (program_name TEXT,country TEXT); INSERT INTO fwp_programs (program_name,country) VALUES ('US Financial Wellbeing','USA'),('UK Financial Capability','UK'),('Global Financial Literacy','Global'); | SELECT program_name FROM fwp_programs WHERE country IN ('USA', 'UK'); |
What is the total financial impact of each program? | CREATE TABLE program_financials (id INT,program_id INT,amount DECIMAL(10,2)); | SELECT pf.program_id, SUM(pf.amount) as total_financial_impact FROM program_financials pf GROUP BY pf.program_id; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.