instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
Calculate the average hotel occupancy rate in South America for the last 2 years. | CREATE TABLE hotel_stats (year INT,continent TEXT,occupancy DECIMAL(5,2)); INSERT INTO hotel_stats (year,continent,occupancy) VALUES (2020,'South America',0.65),(2021,'South America',0.72),(2022,'South America',0.75); | SELECT AVG(occupancy) as avg_occupancy FROM hotel_stats WHERE continent = 'South America' AND year >= (SELECT MAX(year) - 2); |
What is the total number of species in the Atlantic ocean? | CREATE TABLE species (species_id INT,name TEXT,location TEXT); INSERT INTO species (species_id,name,location) VALUES (1,'Starfish','Atlantic'),(2,'Jellyfish','Atlantic'); | SELECT COUNT(*) FROM species WHERE location = 'Atlantic' |
What is the average number of posts per day for a given user? | CREATE TABLE posts (id INT,user_id INT,timestamp TIMESTAMP); INSERT INTO posts (id,user_id,timestamp) VALUES (1,1,'2022-01-01 10:00:00'),(2,1,'2022-01-02 12:00:00'),(3,1,'2022-01-03 14:00:00'),(4,2,'2022-01-01 10:00:00'),(5,2,'2022-01-02 12:00:00'); | SELECT user_id, AVG(1.0 * COUNT(DISTINCT DATE(timestamp))) AS avg_posts_per_day FROM posts GROUP BY user_id; |
How many energy storage projects are there in the 'energy_storage' schema, grouped by technology type and ordered by the count in descending order? | CREATE SCHEMA energy_storage; CREATE TABLE storage_projects (id INT,technology VARCHAR(50),status VARCHAR(50)); INSERT INTO storage_projects (id,technology,status) VALUES (1,'Lithium-ion','Operational'),(2,'Flow','Operational'),(3,'Lead-acid','Operational'),(4,'Lithium-ion','Under Construction'),(5,'Flow','Under Construction'),(6,'Lead-acid','Under Construction'),(7,'Sodium-ion','Operational'),(8,'Sodium-ion','Under Construction'); | SELECT technology, COUNT(*) as count FROM energy_storage.storage_projects GROUP BY technology ORDER BY count DESC; |
What was the total budget allocated for public safety in 2020 and 2021, and which year had a higher allocation? | CREATE TABLE BudgetAllocations (Year INT,Service TEXT,Amount INT); INSERT INTO BudgetAllocations (Year,Service,Amount) VALUES (2020,'PublicSafety',10000000),(2021,'PublicSafety',11000000); | SELECT Year, SUM(Amount) FROM BudgetAllocations WHERE Service = 'PublicSafety' GROUP BY Year HAVING Year IN (2020, 2021) ORDER BY SUM(Amount) DESC LIMIT 1; |
What is the percentage of community health workers who have received cultural competency training in each state? | CREATE TABLE cultural_competency_training (worker_id INT,state VARCHAR(2),received_training BOOLEAN); INSERT INTO cultural_competency_training (worker_id,state,received_training) VALUES (1,'CA',TRUE),(2,'NY',FALSE),(3,'TX',TRUE); | SELECT c.state, (COUNT(*) FILTER (WHERE c.received_training = TRUE)) * 100.0 / COUNT(*) as pct_trained FROM cultural_competency_training c GROUP BY c.state; |
What is the total number of primary care physicians and specialists in the South region? | CREATE TABLE physicians (name VARCHAR(255),specialty VARCHAR(255),region VARCHAR(255)); INSERT INTO physicians (name,specialty,region) VALUES ('Dr. A','Primary Care','South'),('Dr. B','Specialist','South'),('Dr. C','Primary Care','South'),('Dr. D','Specialist','South'),('Dr. E','Primary Care','North'),('Dr. F','Specialist','North'); | SELECT specialty, COUNT(*) FROM physicians WHERE region = 'South' GROUP BY specialty; |
What was the total donation amount from new donors in Q1 2022? | CREATE TABLE donors (donor_id INT,donation_date DATE,amount DECIMAL(10,2)); INSERT INTO donors VALUES (1,'2022-01-01',50.00),(2,'2022-01-15',100.00),(3,'2022-03-01',200.00); | SELECT SUM(amount) FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' AND donor_id NOT IN (SELECT donor_id FROM donors WHERE donation_date < '2022-01-01'); |
Identify the top 5 cities with the highest number of registered users in the "MediaEthics" database. | CREATE TABLE UserLocations (UserID INT,City VARCHAR(255)); INSERT INTO UserLocations (UserID,City) VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'),(4,'Houston'),(5,'Phoenix'); | SELECT City, COUNT(*) FROM UserLocations GROUP BY City ORDER BY COUNT(*) DESC LIMIT 5; |
What is the total number of green building projects in Texas? | CREATE TABLE green_buildings (id INT,project_name VARCHAR(50),state VARCHAR(50)); INSERT INTO green_buildings (id,project_name,state) VALUES (1,'Greenville Project','Texas'); INSERT INTO green_buildings (id,project_name,state) VALUES (2,'Austin Green Towers','Texas'); | SELECT COUNT(*) FROM green_buildings WHERE state = 'Texas' AND project_name LIKE '%green%' |
Which age group made the most donations in 2021? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,Age INT,DonationCount INT,DonationYear INT); INSERT INTO Donors (DonorID,DonorName,Age,DonationCount,DonationYear) VALUES (1,'John Doe',35,2,2021),(2,'Jane Smith',40,1,2021),(3,'Alice Johnson',28,3,2021),(4,'Bob Brown',45,1,2021),(5,'Charlie Davis',32,2,2021); | SELECT Age, SUM(DonationCount) FROM Donors WHERE DonationYear = 2021 GROUP BY Age ORDER BY SUM(DonationCount) DESC; |
What is the average number of likes on posts containing the hashtag "#nature" in the past week? | CREATE TABLE posts (id INT,user VARCHAR(255),content TEXT,likes INT,timestamp TIMESTAMP); | SELECT AVG(likes) FROM posts WHERE hashtags LIKE '%#nature%' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW(); |
What is the maximum number of tickets sold for any single Basketball game? | CREATE TABLE games_sales (id INT,game_id INT,sport VARCHAR(50),sales INT); INSERT INTO games_sales (id,game_id,sport,sales) VALUES (1,1,'Basketball',500); INSERT INTO games_sales (id,game_id,sport,sales) VALUES (2,2,'Basketball',700); | SELECT MAX(sales) FROM games_sales WHERE sport = 'Basketball'; |
What is the average number of disability-related accommodations provided per student with a disability by ethnicity? | CREATE TABLE Students_With_Disabilities (id INT,student_id INT,disability_type VARCHAR(50),ethnicity VARCHAR(50),num_accommodations INT); INSERT INTO Students_With_Disabilities (id,student_id,disability_type,ethnicity,num_accommodations) VALUES (1,4001,'Learning Disability','Hispanic',2),(2,4002,'Mobility Impairment','African American',1),(3,4003,'Visual Impairment','Asian',3),(4,4004,'Hearing Impairment','Native American',2); | SELECT AVG(Students_With_Disabilities.num_accommodations) as average_accommodations, Students_With_Disabilities.ethnicity FROM Students_With_Disabilities GROUP BY Students_With_Disabilities.ethnicity; |
What are the names of all explainable AI models that use decision trees? | CREATE TABLE Explainable_AI (model_name TEXT,technique TEXT,algorithm TEXT); INSERT INTO Explainable_AI VALUES ('ALEX','Decision Tree','Random Forest'); | SELECT model_name FROM Explainable_AI WHERE technique = 'Decision Tree'; |
What is the total number of police officers in each division and their respective ranks? | CREATE TABLE division (division_id INT,division_name VARCHAR(255)); INSERT INTO division (division_id,division_name) VALUES (1,'Patrol'),(2,'Investigations'),(3,'Special Operations'); CREATE TABLE police_officers (officer_id INT,division_id INT,officer_name VARCHAR(255),officer_rank VARCHAR(255)); | SELECT division_id, COUNT(*), officer_rank FROM police_officers GROUP BY division_id, officer_rank; |
How many volunteers signed up for programs in Texas in the third quarter of 2019? | CREATE TABLE Volunteers (VolunteerID INT,VolunteerName VARCHAR(100),Program VARCHAR(50),SignUpDate DATE); CREATE TABLE Community (CommunityID INT,CommunityName VARCHAR(50),State VARCHAR(50)); | SELECT COUNT(*) FROM Volunteers INNER JOIN Community ON Volunteers.Program = Community.CommunityName WHERE Community.State = 'Texas' AND QUARTER(SignUpDate) = 3; |
What is the average number of weapons for each naval vessel? | CREATE TABLE NavalVessels (ID INT,Name VARCHAR(50),NumWeapons INT); | SELECT AVG(NumWeapons) FROM NavalVessels; |
Find the destination in Africa with the highest increase in tourists from 2019 to 2020 | CREATE TABLE tourism_stats (destination VARCHAR(255),year INT,visitors INT); INSERT INTO tourism_stats (destination,year,visitors) VALUES ('City D',2019,600000),('City D',2020,800000),('City E',2019,750000),('City E',2020,700000),('City F',2019,850000),('City F',2020,950000); | SELECT destination, (visitors - (SELECT visitors FROM tourism_stats t2 WHERE t2.destination = t1.destination AND t2.year = 2019)) AS diff FROM tourism_stats t1 WHERE year = 2020 ORDER BY diff DESC LIMIT 1; |
What is the average water consumption of manufacturing processes using organic cotton? | CREATE TABLE OrganicCottonManufacturing (id INT,water_consumption DECIMAL); INSERT INTO OrganicCottonManufacturing (id,water_consumption) VALUES (1,1800),(2,1900),(3,1850),(4,1700),(5,1950); | SELECT AVG(water_consumption) FROM OrganicCottonManufacturing; |
How many startups founded by women in the healthcare sector have never received funding? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_year INT,founder_gender TEXT); INSERT INTO companies (id,name,industry,founding_year,founder_gender) VALUES (9,'HealthCareSolutions','Healthcare',2022,'Female'); INSERT INTO companies (id,name,industry,founding_year,founder_gender) VALUES (10,'GreenInno','GreenTech',2020,'Male'); | SELECT COUNT(*) FROM companies WHERE founder_gender = 'Female' AND industry = 'Healthcare' AND id NOT IN (SELECT company_id FROM funding_records); |
List the species that exist in both the Arctic and Antarctic oceans. | CREATE TABLE arctic_species (id INT,species VARCHAR(255)); INSERT INTO arctic_species VALUES (1,'Polar Bear'); INSERT INTO arctic_species VALUES (2,'Narwhal'); CREATE TABLE antarctic_species (id INT,species VARCHAR(255)); INSERT INTO antarctic_species VALUES (1,'Penguin'); INSERT INTO antarctic_species VALUES (2,'Polar Bear'); | SELECT species FROM arctic_species WHERE species IN (SELECT species FROM antarctic_species); |
What is the average salary for employees in the Sales department who have completed diversity training? | CREATE TABLE Employees (EmployeeID INT,EmployeeName VARCHAR(20),Department VARCHAR(20),Salary INT); INSERT INTO Employees (EmployeeID,EmployeeName,Department,Salary) VALUES (1,'Ava Jones','Sales',50000),(2,'Brian Kim','Marketing',60000),(3,'Carlos Lopez','Sales',55000); | SELECT AVG(Salary) FROM Employees e JOIN Training t ON e.EmployeeID = t.EmployeeID WHERE e.Department = 'Sales' AND t.TrainingType = 'Diversity'; |
What is the change in mental health score from the beginning to the end of the school year for each student? | CREATE TABLE student_mental_health_year (student_id INT,date DATE,score INT); | SELECT student_id, LAG(score) OVER (PARTITION BY student_id ORDER BY date) as beginning_score, score as end_score, score - LAG(score) OVER (PARTITION BY student_id ORDER BY date) as change FROM student_mental_health_year WHERE EXTRACT(MONTH FROM date) IN (5, 6, 7) AND EXTRACT(YEAR FROM date) = 2022; |
List all unique train routes in Tokyo with more than 1000 riders per day | CREATE TABLE tokyo_train (route_id INT,num_riders INT,route_name VARCHAR(255)); | SELECT DISTINCT route_id, route_name FROM tokyo_train WHERE num_riders > 1000; |
Which countries have the highest cybersecurity budgets? | CREATE TABLE CountryCybersecurity (country TEXT,budget INTEGER); INSERT INTO CountryCybersecurity (country,budget) VALUES ('USA',20000000),('China',15000000),('Russia',10000000),('India',5000000),('Germany',7000000); | SELECT country, budget FROM CountryCybersecurity ORDER BY budget DESC LIMIT 3; |
What is the number of rural health centers in Alaska and Hawaii? | CREATE TABLE health_centers (id INT,name TEXT,location TEXT); INSERT INTO health_centers (id,name,location) VALUES (1,'Health Center A','Rural Alaska'); INSERT INTO health_centers (id,name,location) VALUES (2,'Health Center B','Urban Alaska'); INSERT INTO health_centers (id,name,location) VALUES (3,'Health Center C','Rural Hawaii'); | SELECT COUNT(*) FROM health_centers WHERE location IN ('Rural Alaska', 'Rural Hawaii'); |
What is the total funding raised by startups with at least one female founder in the fintech sector? | CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_gender TEXT,funding FLOAT); INSERT INTO startups(id,name,industry,founder_gender,funding) VALUES (1,'WomenInFinance','Fintech','Female',5000000); | SELECT SUM(funding) FROM startups WHERE industry = 'Fintech' AND founder_gender = 'Female'; |
Create a view named 'older_farmers' with farmers older than 45 | CREATE TABLE farmers (id INT PRIMARY KEY,name VARCHAR(50),age INT,gender VARCHAR(10),location VARCHAR(50)); INSERT INTO farmers (id,name,age,gender,location) VALUES (1,'John Doe',35,'Male','USA'); INSERT INTO farmers (id,name,age,gender,location) VALUES (2,'Jane Smith',40,'Female','Canada'); | CREATE VIEW older_farmers AS SELECT * FROM farmers WHERE age > 45; |
Find the number of wells drilled in Texas and Oklahoma | CREATE TABLE wells (id INT,state VARCHAR(10),well_type VARCHAR(10),num_drilled INT); INSERT INTO wells (id,state,well_type,num_drilled) VALUES (1,'Texas','Oil',250),(2,'Oklahoma','Gas',180); | SELECT SUM(num_drilled) FROM wells WHERE state IN ('Texas', 'Oklahoma'); |
How many health insurance policies are there in the 'North' region? | CREATE TABLE HealthPolicies (PolicyID int,Region varchar(10)); INSERT INTO HealthPolicies (PolicyID,Region) VALUES (1,'North'); INSERT INTO HealthPolicies (PolicyID,Region) VALUES (2,'South'); INSERT INTO HealthPolicies (PolicyID,Region) VALUES (3,'North'); | SELECT COUNT(*) FROM HealthPolicies WHERE Region = 'North'; |
Find the average age of bridges in each state | CREATE TABLE Bridges (bridge_id int,bridge_name varchar(255),year int,location varchar(255)); | SELECT state, AVG(YEAR(CURRENT_DATE) - year) AS avg_age FROM Bridges GROUP BY state; |
What is the total number of donations and their average amount for each month? | CREATE TABLE Donations (DonationID INT,DonationDate DATE); CREATE TABLE DonationDetails (DonationID INT,Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID,DonationDate) VALUES (1,'2021-01-01'),(2,'2021-01-15'),(3,'2021-02-03'),(4,'2021-02-28'),(5,'2021-03-12'),(6,'2021-03-25'); INSERT INTO DonationDetails (DonationID,Amount) VALUES (1,500),(2,1000),(3,750),(4,250),(5,300),(6,800); | SELECT EXTRACT(MONTH FROM dd.DonationDate) as Month, COUNT(dd.DonationID) as NumDonations, AVG(dd.Amount) as AvgDonation FROM Donations dd JOIN DonationDetails dd2 ON dd.DonationID = dd2.DonationID GROUP BY Month; |
What is the number of marine species with a conservation status of 'Critically Endangered' or 'Extinct'? | CREATE TABLE marine_species (id INT,species_name VARCHAR(255),conservation_status VARCHAR(100)); INSERT INTO marine_species (id,species_name,conservation_status) VALUES (1,'Vaquita','Critically Endangered'),(2,'Yangtze Finless Porpoise','Endangered'),(3,'Blue Whale','Vulnerable'),(4,'Leatherback Sea Turtle','Vulnerable'),(5,'Giant Pacific Octopus','Least Concern'),(6,'Passenger Pigeon','Extinct'); | SELECT COUNT(*) FROM marine_species WHERE conservation_status IN ('Critically Endangered', 'Extinct'); |
List all the unique machines used in the mining operations | CREATE TABLE Machines (id INT,name VARCHAR(255),mining_site_id INT); INSERT INTO Machines (id,name,mining_site_id) VALUES (1,'Machine A',1),(2,'Machine B',1),(3,'Machine C',2); | SELECT DISTINCT name FROM Machines; |
How many construction laborers are there in Texas? | CREATE TABLE labor_statistics (state VARCHAR(20),occupation VARCHAR(20),number_of_employees INT); INSERT INTO labor_statistics (state,occupation,number_of_employees) VALUES ('Texas','Construction laborer',15000); INSERT INTO labor_statistics (state,occupation,number_of_employees) VALUES ('California','Construction laborer',12000); | SELECT SUM(number_of_employees) FROM labor_statistics WHERE state = 'Texas' AND occupation = 'Construction laborer'; |
Identify dishes that need sustainable sourcing improvements in 'vegan' and 'gluten-free' categories. | CREATE TABLE dishes (id INT,name TEXT,category TEXT,sustainable_sourcing INT); INSERT INTO dishes (id,name,category,sustainable_sourcing) VALUES (1,'Falafel','vegan',5),(2,'Quinoa Salad','vegan',8),(3,'Pizza','non-vegan',3),(4,'Pasta','gluten-free',2); | SELECT name, category FROM dishes WHERE sustainable_sourcing < 5 AND category IN ('vegan', 'gluten-free'); |
Update the records in the ethical_manufacturing table with the correct 'Fair Trade' certification status for 'ManufacturerD'. | CREATE TABLE ethical_manufacturing (manufacturer_id INT,certification_status TEXT); INSERT INTO ethical_manufacturing (manufacturer_id,certification_status) VALUES (1,'Fair Trade Pending'),(2,'Not Certified'),(3,'Fair Trade Certified'),(4,'ManufacturerD'); | UPDATE ethical_manufacturing SET certification_status = 'Fair Trade Certified' WHERE manufacturer_id = (SELECT manufacturer_id FROM manufacturers WHERE manufacturer_name = 'ManufacturerD'); |
How many government transparency initiatives were launched in the state of California in the year 2019? | CREATE TABLE government_transparency_initiatives (initiative_id INT,launch_year INT,state VARCHAR(20)); INSERT INTO government_transparency_initiatives (initiative_id,launch_year,state) VALUES (1,2017,'California'),(2,2016,'Texas'),(3,2015,'California'),(4,2018,'California'),(5,2017,'New York'),(6,2020,'California'),(7,2019,'California'),(8,2019,'Texas'),(9,2020,'New York'); | SELECT COUNT(*) FROM government_transparency_initiatives WHERE launch_year = 2019 AND state = 'California'; |
How many startups have been founded by people from each continent? | CREATE TABLE companies (id INT,name TEXT,founder_continent TEXT); | SELECT founder_continent, COUNT(*) as num_startups FROM companies GROUP BY founder_continent; |
How many products does each supplier provide for ethical labor practices, by category? | CREATE TABLE Suppliers (id INT,supplier VARCHAR(255),category VARCHAR(255)); INSERT INTO Suppliers (id,supplier,category) VALUES (1,'Supplier1','Clothing'),(2,'Supplier2','Electronics'),(3,'Supplier3','Food'),(4,'Supplier4','Furniture'); CREATE TABLE EthicalProducts (id INT,supplier_id INT,product VARCHAR(255),ethical BOOLEAN); INSERT INTO EthicalProducts (id,supplier_id,product,ethical) VALUES (1,1,'T-Shirt',true),(2,1,'Jeans',true),(3,2,'Smartphone',true),(4,2,'Headphones',true),(5,3,'Apples',true),(6,3,'Bananas',true),(7,4,'Table',false),(8,4,'Chair',false); | SELECT s.category, e.supplier, COUNT(e.product) AS product_count FROM EthicalProducts e JOIN Suppliers s ON e.supplier_id = s.id WHERE e.ethical = true GROUP BY s.category, e.supplier; |
Create a table for storing information about medical facilities in the 'disaster_response' schema. | CREATE TABLE medical_facilities (facility_id INT,facility_name VARCHAR(255),facility_type VARCHAR(255),location VARCHAR(255),capacity INT); | CREATE TABLE medical_facilities (facility_id INT, facility_name VARCHAR(255), facility_type VARCHAR(255), location VARCHAR(255), capacity INT); |
How many size 30 jeans were sold in the last month? | CREATE TABLE sales_data (sale_id INT,jean_size INT,sale_date DATE); INSERT INTO sales_data (sale_id,jean_size,sale_date) VALUES (1,28,'2022-06-03'),(2,30,'2022-06-15'),(3,32,'2022-06-27'),(4,26,'2022-07-08'),(5,30,'2022-07-15'); | SELECT COUNT(*) FROM sales_data WHERE jean_size = 30 AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
Remove any duplicate records from the forest_plot table. | CREATE TABLE forest_plot (id INT PRIMARY KEY,size FLOAT,species_id INT,FOREIGN KEY (species_id) REFERENCES species(id)); | DELETE FROM forest_plot fp USING (SELECT MIN(id) as id, size, species_id FROM forest_plot GROUP BY size, species_id HAVING COUNT(*) > 1) dup WHERE fp.id = dup.id; |
Delete the rural infrastructure project with ID 2 from the 'infrastructure_projects' table. | CREATE TABLE infrastructure_projects(id INT,province TEXT,project_name TEXT,completion_status TEXT); INSERT INTO infrastructure_projects (id,province,project_name,completion_status) VALUES (1,'Gauteng','Water Purification Plant','completed'); INSERT INTO infrastructure_projects (id,province,project_name,completion_status) VALUES (2,'KwaZulu-Natal','Road Construction','in progress'); | DELETE FROM infrastructure_projects WHERE id = 2; |
What is the total number of transparency reports published by each agency in the last 12 months? | CREATE TABLE agency_data (agency VARCHAR(255),reports INT,month INT,year INT); INSERT INTO agency_data VALUES ('Agency A',10,1,2022),('Agency A',12,2,2022),('Agency B',15,1,2022),('Agency B',18,2,2022); | SELECT agency, SUM(reports) FROM agency_data WHERE month BETWEEN (SELECT EXTRACT(MONTH FROM NOW()) - 12) AND EXTRACT(MONTH FROM NOW()) AND year = EXTRACT(YEAR FROM NOW()) GROUP BY agency; |
What is the average number of military bases in each African country? | CREATE TABLE MilitaryBases (Country VARCHAR(50),NumberOfBases INT); INSERT INTO MilitaryBases (Country,NumberOfBases) VALUES ('Egypt',30),('Algeria',25),('South Africa',20),('Morocco',15),('Sudan',10); | SELECT AVG(NumberOfBases) FROM MilitaryBases WHERE Country IN ('Egypt', 'Algeria', 'South Africa', 'Morocco', 'Sudan'); |
Compute the average rare earth element price by refinery and quarter. | CREATE TABLE price (id INT,refinery_id INT,date DATE,price FLOAT); INSERT INTO price (id,refinery_id,date,price) VALUES (1,1,'2021-01-01',100.0),(2,1,'2021-02-01',120.0),(3,2,'2021-01-01',150.0),(4,2,'2021-02-01',180.0); | SELECT refinery_id, QUARTER(date) AS quarter, AVG(price) AS avg_price FROM price GROUP BY refinery_id, quarter; |
List all smart city projects in the state of New York, including their start dates and the names of the companies responsible for their implementation. | CREATE TABLE smart_city (project_name TEXT,state TEXT,start_date DATE,company TEXT); INSERT INTO smart_city (project_name,state,start_date,company) VALUES ('Smart Grid Project','New York','2020-01-01','TechCo'); | SELECT project_name, state, start_date, company FROM smart_city WHERE state = 'New York'; |
Insert new vegan cosmetic products into the Products table. | CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),IsVegan BOOLEAN,IsCrueltyFree BOOLEAN); INSERT INTO Products (ProductID,ProductName,IsVegan,IsCrueltyFree) VALUES (1,'Lip Balm',true,true),(2,'Face Cream',false,true),(3,'Moisturizer',false,true); | INSERT INTO Products (ProductID, ProductName, IsVegan, IsCrueltyFree) VALUES (4, 'Vegan Lipstick', true, true), (5, 'Vegan Mascara', true, true), (6, 'Vegan Eyeshadow', true, true); |
List the Green Buildings in the 'sustainable_buildings' schema with a Gold LEED certification. | CREATE SCHEMA IF NOT EXISTS sustainable_buildings;CREATE TABLE IF NOT EXISTS sustainable_buildings.green_buildings (id INT,name VARCHAR(50),certification VARCHAR(20));INSERT INTO sustainable_buildings.green_buildings (id,name,certification) VALUES (1,'Green Building A','Platinum'),(2,'Green Building B','Gold'),(3,'Green Building C','Silver'); | SELECT name FROM sustainable_buildings.green_buildings WHERE certification = 'Gold'; |
Which rural hospitals have the highest readmission rates for diabetes patients? | CREATE TABLE hospitals (id INT,name VARCHAR(255),rural_designation VARCHAR(50),state_id INT); INSERT INTO hospitals (id,name,rural_designation,state_id) VALUES (1,'Hospital A','Rural',1); CREATE TABLE readmissions (id INT,hospital_id INT,diabetes BOOLEAN,readmission BOOLEAN); INSERT INTO readmissions (id,hospital_id,diabetes,readmission) VALUES (1,1,true,true); | SELECT h.name, ROUND(COUNT(r.id) * 100.0 / (SELECT COUNT(*) FROM readmissions r WHERE r.hospital_id = h.id AND r.diabetes = true), 2) AS readmission_percentage FROM hospitals h JOIN readmissions r ON h.id = r.hospital_id WHERE h.rural_designation = 'Rural' AND r.diabetes = true GROUP BY h.name ORDER BY readmission_percentage DESC; |
Delete all records of cultural heritage sites in Greece. | CREATE TABLE heritage_sites (id INT,name TEXT,country TEXT,type TEXT); INSERT INTO heritage_sites (id,name,country,type) VALUES (1,'Acropolis of Athens','Greece','cultural'); INSERT INTO heritage_sites (id,name,country,type) VALUES (2,'Parthenon','Greece','cultural'); | DELETE FROM heritage_sites WHERE country = 'Greece' AND type = 'cultural'; |
What is the difference in the number of satellites launched by the US and the European Union? | CREATE TABLE satellites (id INT,country VARCHAR(255),launch_date DATE); | SELECT US_launches - EU_launches AS difference FROM (SELECT COUNT(*) AS US_launches FROM satellites WHERE country = 'US') AS subquery1, (SELECT COUNT(*) AS EU_launches FROM satellites WHERE country = 'European Union') AS subquery2; |
List all the unique programs with a program impact score greater than 4? | CREATE TABLE programs_impact (program TEXT,impact_score DECIMAL); INSERT INTO programs_impact (program,impact_score) VALUES ('Program A',4.2),('Program B',3.5),('Program C',5.0),('Program D',4.5); | SELECT program FROM programs_impact WHERE impact_score > 4; |
List all mental health parity regulations that have been implemented in New York and Florida since 2010. | CREATE TABLE mental_health_parity (id INT,regulation VARCHAR(100),state VARCHAR(20),implementation_date DATE); INSERT INTO mental_health_parity (id,regulation,state,implementation_date) VALUES (1,'Regulation 1','New York','2011-01-01'),(2,'Regulation 2','Florida','2012-01-01'); | SELECT regulation, state, implementation_date FROM mental_health_parity WHERE state IN ('New York', 'Florida') AND implementation_date >= '2010-01-01'; |
Identify the top 3 most common last names of donors | CREATE TABLE donors (id INT,last_name VARCHAR,first_name VARCHAR,city VARCHAR); INSERT INTO donors VALUES (1,'Smith','John','NYC') | SELECT d.last_name, COUNT(*) AS count FROM donors d GROUP BY d.last_name ORDER BY count DESC LIMIT 3; |
Which countries have the highest average sustainable timber harvest volume, in cubic meters, per timber production facility? | CREATE TABLE country_harvest (id INT,country VARCHAR(255),facility_name VARCHAR(255),avg_vol_cubic_meters FLOAT); | SELECT country, AVG(avg_vol_cubic_meters) FROM country_harvest GROUP BY country ORDER BY AVG(avg_vol_cubic_meters) DESC LIMIT 1; |
What is the average response time for disaster relief in Asia in 2019? | CREATE TABLE disasters (disaster_id INT,disaster_name TEXT,disaster_type TEXT,response_time INT,year INT,region TEXT); INSERT INTO disasters (disaster_id,disaster_name,disaster_type,response_time,year,region) VALUES (1,'Floods','natural disaster',72,2019,'Asia'); | SELECT AVG(response_time) as avg_response_time FROM disasters WHERE disaster_type = 'natural disaster' AND year = 2019 AND region = 'Asia'; |
What is the minimum number of visits for any exhibition? | CREATE TABLE ExhibitionStats (exhibition_id INT,min_visits INT,max_visits INT); INSERT INTO ExhibitionStats (exhibition_id,min_visits,max_visits) VALUES (1,1000,2000),(2,1500,2500),(3,2000,3000); | SELECT MIN(min_visits) FROM ExhibitionStats; |
What is the maximum number of working hours per week for factories in Bangladesh? | CREATE TABLE Factories (factory_id INT,factory_location VARCHAR(50),factory_working_hours INT); | SELECT MAX(factory_working_hours) AS max_working_hours FROM Factories WHERE factory_location = 'Bangladesh'; |
What is the percentage of community health workers who have completed cultural competency training in each region? | CREATE TABLE regions (region_id INT,region_name VARCHAR(50)); INSERT INTO regions (region_id,region_name) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'Southwest'),(5,'West'); CREATE TABLE community_health_workers (worker_id INT,worker_name VARCHAR(50),region_id INT); 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); | SELECT r.region_name, 100.0 * COUNT(chw.worker_id) / (SELECT COUNT(*) FROM community_health_workers chw2 WHERE chw2.region_id = r.region_id) as completion_rate FROM regions r JOIN community_health_workers chw ON r.region_id = chw.region_id JOIN training_sessions ts ON chw.worker_id = ts.completed_by_worker AND ts.session_id = (SELECT MAX(session_id) FROM training_sessions) GROUP BY r.region_name; |
What is the percentage of players who have played a game on each platform, and the percentage of players who have played VR games on each platform? | CREATE TABLE players (id INT,platform VARCHAR(20));CREATE TABLE games (id INT,player_id INT,game_type VARCHAR(10));CREATE TABLE vr_games (id INT,player_id INT,last_played DATE); | SELECT p.platform, 100.0 * COUNT(DISTINCT g.player_id) / COUNT(DISTINCT p.id) AS players_with_games_percentage, 100.0 * COUNT(DISTINCT v.player_id) / COUNT(DISTINCT p.id) AS vr_players_percentage FROM players p LEFT JOIN games g ON p.id = g.player_id LEFT JOIN vr_games v ON p.id = v.player_id GROUP BY p.platform; |
Delete the record for the author 'John Doe' from the 'authors' table | CREATE TABLE authors (author_id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50)); | DELETE FROM authors WHERE first_name = 'John' AND last_name = 'Doe'; |
What is the total donation amount for the 'Education' program and total volunteer hours for the 'Animal Welfare' program? | CREATE TABLE donations (id INT,program VARCHAR(255),amount DECIMAL(10,2)); INSERT INTO donations (id,program,amount) VALUES (1,'Animal Welfare',500.00),(2,'Education',1000.00); CREATE TABLE volunteers (id INT,program VARCHAR(255),hours INT); INSERT INTO volunteers (id,program,hours) VALUES (1,'Animal Welfare',20),(2,'Education',30); | SELECT SUM(d.amount) FROM donations d WHERE d.program = 'Education'; SELECT SUM(v.hours) FROM volunteers v WHERE v.program = 'Animal Welfare'; |
What is the maximum budget spent on a single AI project? | CREATE TABLE ai_projects_budget (project_name TEXT,budget INTEGER); INSERT INTO ai_projects_budget (project_name,budget) VALUES ('ProjectA',1000000),('ProjectB',2000000),('ProjectC',3000000),('ProjectD',4000000); | SELECT MAX(budget) FROM ai_projects_budget; |
How many AI safety incidents were recorded for each month in the 'safety_incidents' table? | CREATE TABLE safety_incidents (incident_date DATE,incident_type VARCHAR(20),incident_count INT); INSERT INTO safety_incidents (incident_date,incident_type,incident_count) VALUES ('2022-01-01','autonomous_vehicle',3),('2022-01-05','AI_assistant',1),('2022-02-10','autonomous_vehicle',2); | SELECT DATE_FORMAT(incident_date, '%Y-%m') as month, SUM(incident_count) as total_incidents FROM safety_incidents GROUP BY month; |
What is the number of shared electric cars in Singapore and Hong Kong? | CREATE TABLE shared_cars (id INT,city VARCHAR(50),car_count INT,timestamp TIMESTAMP); | SELECT city, SUM(car_count) FROM shared_cars WHERE city IN ('Singapore', 'Hong Kong') GROUP BY city; |
What is the average frame rate of each game on high-end graphics cards? | CREATE TABLE GamePerformance (GameID INT,GraphicsCard VARCHAR(100),FrameRate FLOAT); INSERT INTO GamePerformance (GameID,GraphicsCard,FrameRate) VALUES (1,'GraphicsCardA',60.5),(2,'GraphicsCardB',70.2),(3,'GraphicsCardA',65.1); | SELECT GameID, AVG(FrameRate) as AvgFrameRate FROM GamePerformance WHERE GraphicsCard IN ('GraphicsCardA', 'GraphicsCardB') GROUP BY GameID; |
How many Green Building projects were completed in the last 12 months? | CREATE TABLE project (id INT,name VARCHAR(255),start_date DATE,end_date DATE,is_green BOOLEAN); INSERT INTO project (id,name,start_date,end_date,is_green) VALUES (1,'Sample Project 1','2020-01-01','2020-06-01',true),(2,'Sample Project 2','2019-08-15','2020-02-28',false); | SELECT COUNT(*) as green_building_projects_completed FROM project WHERE is_green = true AND end_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH); |
What is the average citizen feedback score for public services in rural areas? | CREATE TABLE Feedback (Area TEXT,Service TEXT,Score INTEGER); INSERT INTO Feedback (Area,Service,Score) VALUES ('Rural','Education',80),('Rural','Healthcare',75),('Urban','Education',85),('Urban','Healthcare',82); | SELECT AVG(Score) FROM Feedback WHERE Area = 'Rural'; |
How many unique visitors who identify as 'Non-binary' have attended events in the 'Film' category, and what is their average age? | CREATE TABLE Visitors (VisitorID INT,Age INT,Gender VARCHAR(20));CREATE TABLE Events (EventID INT,EventName VARCHAR(20),EventCategory VARCHAR(20));CREATE TABLE VisitorAttendance (VisitorID INT,EventID INT); | SELECT AVG(V.Age) AS Avg_Age, COUNT(DISTINCT VA.VisitorID) AS Num_Unique_Visitors FROM Visitors V INNER JOIN VisitorAttendance VA ON V.VisitorID = VA.VisitorID INNER JOIN Events E ON VA.EventID = E.EventID WHERE V.Gender = 'Non-binary' AND E.EventCategory = 'Film'; |
What is the average energy consumption per virtual tour in Portugal? | CREATE TABLE VirtualTours (id INT,country VARCHAR(20),energy INT); INSERT INTO VirtualTours (id,country,energy) VALUES (1,'Portugal',50),(2,'Spain',60); | SELECT AVG(energy) FROM VirtualTours WHERE country = 'Portugal'; |
What was the total investment (in USD) in solar energy projects in New York in 2021? | CREATE TABLE solar_energy_projects (project_id INT,state VARCHAR(20),year INT,investment FLOAT); | SELECT SUM(investment) FROM solar_energy_projects WHERE state = 'New York' AND year = 2021; |
How many policy advocacy events were held in each region? | CREATE TABLE Advocacy(advocacy_id INT,region TEXT);CREATE TABLE Policy_Advocacy(policy_id INT,advocacy_id INT); | SELECT a.region, COUNT(pa.policy_id) FROM Advocacy a INNER JOIN Policy_Advocacy pa ON a.advocacy_id = pa.advocacy_id GROUP BY a.region; |
List all food justice organizations and their respective contact information. | CREATE TABLE orgs (id INT,name TEXT,contact_name TEXT,contact_email TEXT,contact_phone TEXT,type TEXT); INSERT INTO orgs (id,name,contact_name,contact_email,contact_phone,type) VALUES (1,'Seeds of Hope','John Doe','[email protected]','555-555-5555','Food Justice'); INSERT INTO orgs (id,name,contact_name,contact_email,contact_phone,type) VALUES (2,'Harvest Together','Jane Smith','[email protected]','555-555-5556','Food Justice'); | SELECT name, contact_name, contact_email, contact_phone FROM orgs WHERE type = 'Food Justice'; |
What is the total value of defense contracts awarded to General Dynamics in Q3 2020? | CREATE TABLE contract (id INT,company VARCHAR(255),value FLOAT,year INT,quarter INT); INSERT INTO contract (id,company,value,year,quarter) VALUES (1,'General Dynamics',20000000,2020,3); | SELECT SUM(value) FROM contract WHERE company = 'General Dynamics' AND year = 2020 AND quarter = 3; |
Find the top 5 most sold products in the circular supply chain in 2021. | CREATE TABLE Products (productID int,productName varchar(255),circularSupplyChain varchar(5)); INSERT INTO Products VALUES (1,'ProductA','Y'); CREATE TABLE Sales (saleID int,productID int,quantity int,date datetime); INSERT INTO Sales VALUES (1,1,50,'2021-01-01'); | SELECT P.productName, SUM(S.quantity) as total_sold FROM Products P INNER JOIN Sales S ON P.productID = S.productID WHERE P.circularSupplyChain = 'Y' AND YEAR(S.date) = 2021 GROUP BY P.productID ORDER BY total_sold DESC LIMIT 5; |
Find the clients who have taken out the most socially responsible loans. | CREATE TABLE socially_responsible_loans(client_id INT,country VARCHAR(25));INSERT INTO socially_responsible_loans(client_id,country) VALUES (1,'Malaysia'),(2,'UAE'),(3,'Indonesia'),(4,'Saudi Arabia'),(1,'Malaysia'),(2,'UAE'),(7,'Indonesia'),(8,'Saudi Arabia'),(1,'Malaysia'),(2,'UAE'); | SELECT client_id, COUNT(*) as num_loans FROM socially_responsible_loans GROUP BY client_id ORDER BY num_loans DESC; |
What is the average financial capability score for clients in each region? | CREATE TABLE client (id INT,name VARCHAR(50),region VARCHAR(50),score INT); INSERT INTO client (id,name,region,score) VALUES (1,'John','Africa',60),(2,'Jane','Asia',70),(3,'Jim','Europe',80),(4,'Joan','America',90); | SELECT region, AVG(score) as avg_score FROM client GROUP BY region; |
How many donation records were deleted in the last month? | CREATE TABLE donations (id INT,donor_name TEXT,amount DECIMAL,donation_date DATE); INSERT INTO donations (id,donor_name,amount,donation_date) VALUES (1,'John Doe',50.00,'2022-01-01'); INSERT INTO donations (id,donor_name,amount,donation_date) VALUES (2,'Jane Smith',100.00,'2022-02-01'); | SELECT COUNT(*) FROM (SELECT * FROM donations WHERE DATE(donation_date) < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) FOR UPDATE) AS deleted_donations; |
What is the total number of fire stations in the city of Los Angeles? | CREATE TABLE fire_stations (id INT,city VARCHAR(255),number_of_stations INT); INSERT INTO fire_stations (id,city,number_of_stations) VALUES (1,'Los_Angeles',100),(2,'San_Francisco',80); | SELECT SUM(number_of_stations) FROM fire_stations WHERE city = 'Los_Angeles'; |
Calculate the average tree height per region. | CREATE TABLE tree_data (region VARCHAR(255),species VARCHAR(255),height INTEGER); | SELECT region, AVG(height) FROM tree_data GROUP BY region; |
What is the maximum salary paid to a worker in the 'quality control' department? | CREATE TABLE departments (department_id INT,department VARCHAR(20));CREATE TABLE worker_salaries (worker_id INT,department_id INT,salary INT); | SELECT MAX(worker_salaries.salary) FROM worker_salaries INNER JOIN departments ON worker_salaries.department_id = departments.department_id WHERE departments.department = 'quality control'; |
How many AI safety research papers have been published in each quarter? | CREATE TABLE quarter (quarter VARCHAR(10),papers INTEGER); INSERT INTO quarter (quarter,papers) VALUES ('Q1 2021',50),('Q2 2021',75),('Q3 2021',80),('Q4 2021',90),('Q1 2022',100),('Q2 2022',120); | SELECT quarter, papers FROM quarter; |
What is the average explainability score for models from the UK? | CREATE TABLE explainability (model_id INT,name VARCHAR(255),country VARCHAR(255),score FLOAT); INSERT INTO explainability (model_id,name,country,score) VALUES (1,'Model1','UK',0.85),(2,'Model2','UK',0.92),(3,'Model3','Canada',0.78),(4,'Model4','USA',0.88),(5,'Model5','UK',0.90); | SELECT AVG(score) FROM explainability WHERE country = 'UK'; |
What is the total number of military personnel by region and type of operation? | CREATE TABLE military_personnel (personnel_id INT,country VARCHAR(50),region VARCHAR(50),operation_type VARCHAR(50),num_personnel INT); INSERT INTO military_personnel (personnel_id,country,region,operation_type,num_personnel) VALUES (1,'United States','North America','Peacekeeping',500),(2,'Canada','North America','Humanitarian Assistance',700),(3,'Argentina','South America','Peacekeeping',350); | SELECT mp.region, mp.operation_type, SUM(mp.num_personnel) as total_personnel FROM military_personnel mp GROUP BY mp.region, mp.operation_type; |
What is the average annual climate finance committed by each country for adaptation projects? | CREATE TABLE country (country_code VARCHAR(3),country_name VARCHAR(50)); INSERT INTO country VALUES ('USA','United States'),('CHN','China'),('IND','India'); CREATE TABLE project (project_id INT,project_name VARCHAR(50),country_code VARCHAR(3),mitigation BOOLEAN); INSERT INTO project VALUES (1,'Solar Farm','USA',false),(2,'Wind Turbines','CHN',false),(3,'Energy Efficiency','IND',true); CREATE TABLE finance (project_id INT,year INT,amount INT); INSERT INTO finance VALUES (1,2020,500000),(2,2020,1000000),(3,2020,200000),(1,2019,600000),(2,2019,800000),(3,2019,300000); | SELECT c.country_name, AVG(f.amount/5) FROM country c JOIN project p ON c.country_code = p.country_code JOIN finance f ON p.project_id = f.project_id WHERE p.adaptation = true GROUP BY c.country_name; |
Update the gender of the mining engineer with ID 1 to Female. | CREATE TABLE mine_operators (id INT PRIMARY KEY,name VARCHAR(50),role VARCHAR(50),gender VARCHAR(10),years_of_experience INT); INSERT INTO mine_operators (id,name,role,gender,years_of_experience) VALUES (1,'John Doe','Mining Engineer','Male',7); | UPDATE mine_operators SET gender = 'Female' WHERE id = 1; |
Which retailers have purchased garments with a sustainability score above 8.5 in the last week? | CREATE TABLE retailers (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255)); INSERT INTO retailers (id,name,location) VALUES (1,'Eco Fashion','London,UK'); CREATE TABLE purchases (id INT PRIMARY KEY,retailer_id INT,manufacturer_id INT,date DATE,sustainability_score FLOAT,FOREIGN KEY (retailer_id) REFERENCES retailers(id),FOREIGN KEY (manufacturer_id) REFERENCES manufacturers(id)); INSERT INTO purchases (id,retailer_id,manufacturer_id,date,sustainability_score) VALUES (1,1,1,'2022-05-05',9.1); | SELECT r.name, p.sustainability_score FROM retailers r JOIN purchases p ON r.id = p.retailer_id WHERE p.sustainability_score > 8.5 AND p.date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND CURDATE(); |
What are the top 3 smart contract categories with the most contracts? | CREATE TABLE smart_contracts (id INT,category VARCHAR(255),name VARCHAR(255)); INSERT INTO smart_contracts (id,category,name) VALUES (1,'DeFi','Compound'),(2,'DEX','Uniswap'),(3,'DeFi','Aave'),(4,'NFT','CryptoKitties'),(5,'DEX','SushiSwap'),(6,'DeFi','MakerDAO'),(7,'Gaming','Axie Infinity'),(8,'Insurance','Nexus Mutual'),(9,'Oracle','Chainlink'); | SELECT category, COUNT(*) as total FROM smart_contracts GROUP BY category ORDER BY total DESC LIMIT 3; |
How many donors from the 'Mid West' region made donations larger than $100? | CREATE TABLE Donors (id INT,name TEXT,region TEXT,donation FLOAT); INSERT INTO Donors (id,name,region,donation) VALUES (1,'Carol','Mid West',120.5),(2,'Dave','South East',75.2); | SELECT COUNT(*) FROM Donors WHERE region = 'Mid West' AND donation > 100; |
Find the number of unique volunteers and donors who have participated in each program. | CREATE TABLE Programs (id INT,name TEXT); INSERT INTO Programs (id,name) VALUES (1,'Youth Education'),(2,'Women Empowerment'),(3,'Clean Water'),(4,'Refugee Support'); CREATE TABLE Volunteers (id INT,program INT,hours INT); INSERT INTO Volunteers (id,program,hours) VALUES (1,1,20),(2,2,30),(3,3,15),(4,4,25); CREATE TABLE Donors (id INT,program INT,amount DECIMAL(10,2)); INSERT INTO Donors (id,program,amount) VALUES (1,1,100),(2,2,150),(3,3,75),(5,4,200); | SELECT Programs.name, COUNT(DISTINCT Volunteers.id) + COUNT(DISTINCT Donors.id) as total_participants FROM Programs LEFT JOIN Volunteers ON Programs.id = Volunteers.program FULL OUTER JOIN Donors ON Programs.id = Donors.program GROUP BY Programs.name; |
What is the total budget allocated for disability accommodations and support programs in '2019'? | CREATE TABLE DisabilityAccommodations (year INT,budget DECIMAL(5,2)); INSERT INTO DisabilityAccommodations (year,budget) VALUES (2018,500000.00),(2019,750000.00); CREATE TABLE DisabilitySupportPrograms (year INT,budget DECIMAL(5,2)); INSERT INTO DisabilitySupportPrograms (year,budget) VALUES (2018,550000.00),(2019,800000.00); | SELECT SUM(DisabilityAccommodations.budget) + SUM(DisabilitySupportPrograms.budget) FROM DisabilityAccommodations, DisabilitySupportPrograms WHERE DisabilityAccommodations.year = 2019 AND DisabilitySupportPrograms.year = 2019; |
What is the average height of athletes in the 'baseball_players' table? | CREATE TABLE baseball_players (player_id INT,name VARCHAR(50),height DECIMAL(3,2),position VARCHAR(20),team VARCHAR(30)); | SELECT AVG(height) FROM baseball_players; |
How many cultural competency trainings have been attended by community health workers in each region? | CREATE TABLE CommunityHealthWorkers (CHW_ID INT,CHW_Name TEXT,Region TEXT); INSERT INTO CommunityHealthWorkers (CHW_ID,CHW_Name,Region) VALUES (1,'John Doe','New York'),(2,'Jane Smith','California'); CREATE TABLE CulturalCompetencyTrainings (Training_ID INT,CHW_ID INT,Training_Type TEXT); INSERT INTO CulturalCompetencyTrainings (Training_ID,CHW_ID,Training_Type) VALUES (1,1,'Cultural Competency Training 1'),(2,1,'Cultural Competency Training 2'),(3,2,'Cultural Competency Training 3'); | SELECT c.Region, COUNT(cc.CHW_ID) as Number_of_Trainings FROM CommunityHealthWorkers c INNER JOIN CulturalCompetencyTrainings cc ON c.CHW_ID = cc.CHW_ID GROUP BY c.Region; |
What is the total revenue generated by the hotels table for each continent? | CREATE TABLE hotels (id INT,hotel_name VARCHAR(50),country VARCHAR(50),continent VARCHAR(50),revenue INT); | SELECT continent, SUM(revenue) FROM hotels GROUP BY continent; |
Delete all records with 'incomplete' status in the 'ai_research_projects' table | CREATE TABLE ai_research_projects (id INT PRIMARY KEY,project_name VARCHAR(50),status VARCHAR(20)); | DELETE FROM ai_research_projects WHERE status = 'incomplete'; |
What is the employment rate for veterans in the defense industry in the state of New York in Q1 2022? | CREATE TABLE veteran_employment (employment_id INT,industry TEXT,state TEXT,employment_rate FLOAT,quarter TEXT); INSERT INTO veteran_employment (employment_id,industry,state,employment_rate,quarter) VALUES (1,'Defense','New York',0.85,'Q1 2022'),(2,'Defense','California',0.82,'Q1 2022'); | SELECT employment_rate FROM veteran_employment WHERE industry = 'Defense' AND state = 'New York' AND quarter = 'Q1 2022'; |
What are the names of the agricultural innovation projects in the 'rural_infrastructure' table that have a budget less than 150000? | CREATE TABLE rural_infrastructure (id INT,name VARCHAR(50),type VARCHAR(50),budget FLOAT); INSERT INTO rural_infrastructure (id,name,type,budget) VALUES (1,'Solar Irrigation','Agricultural Innovation',150000.00),(2,'Wind Turbines','Rural Infrastructure',200000.00); | SELECT name FROM rural_infrastructure WHERE type = 'Agricultural Innovation' AND budget < 150000; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.