instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total number of electric vehicle sales in each country? | CREATE TABLE Country (country_id INT,country_name VARCHAR(50)); INSERT INTO Country (country_id,country_name) VALUES (1,'USA'); CREATE TABLE EV_Sales (sale_id INT,model VARCHAR(50),buyer_country INT,sale_date DATE); INSERT INTO EV_Sales (sale_id,model,buyer_country,sale_date) VALUES (1,'Tesla Model 3',1,'2022-08-15'); | SELECT c.country_name, COUNT(es.sale_id) as "Total Sales" FROM Country c JOIN EV_Sales es ON c.country_id = es.buyer_country GROUP BY c.country_name; |
What was the maximum age of visitors who attended the Surrealism exhibition? | CREATE TABLE Exhibitions (exhibition_id INT,name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO Exhibitions (exhibition_id,name,start_date,end_date) VALUES (1,'Impressionist','2020-05-01','2021-01-01'),(2,'Cubism','2019-08-15','2020-03-30'),(3,'Surrealism','2018-12-15','2019-09-15'); CREATE TABLE Visitors (visitor_id INT,exhibition_id INT,age INT,gender VARCHAR(50)); | SELECT MAX(age) FROM Visitors WHERE exhibition_id = 3; |
Calculate the total waste generated in 'BC' and 'Alberta' | CREATE TABLE waste_generation (id INT,province VARCHAR(20),amount INT); INSERT INTO waste_generation (id,province,amount) VALUES (1,'BC',2500),(2,'Alberta',3500); | SELECT SUM(amount) FROM waste_generation WHERE province IN ('BC', 'Alberta'); |
Determine the landfill capacity in Toronto as of 2022. | CREATE TABLE landfill_capacity(city VARCHAR(20),capacity INT,year INT); INSERT INTO landfill_capacity VALUES('Toronto',7000000,2022),('Toronto',7500000,2021),('Montreal',6000000,2022); | SELECT capacity FROM landfill_capacity WHERE city = 'Toronto' AND year = 2022; |
Show the total waste generation in Mumbai | CREATE TABLE waste_generation (id INT PRIMARY KEY,location VARCHAR(50),waste_type VARCHAR(50),quantity INT); | SELECT SUM(quantity) FROM waste_generation WHERE location = 'Mumbai'; |
What is the maximum waste generation per capita in the world? | CREATE TABLE WasteGeneration (country VARCHAR(255),waste_generation_kg_per_capita DECIMAL(5,2),region VARCHAR(255)); INSERT INTO WasteGeneration (country,waste_generation_kg_per_capita,region) VALUES ('Denmark',7.5,'Europe'),('Canada',4.8,'America'),('Japan',3.2,'Asia'); | SELECT MAX(waste_generation_kg_per_capita) FROM WasteGeneration; |
What is the drought impact in each state? | CREATE TABLE drought_impact(state VARCHAR(20),drought_impact DECIMAL(5,2)); INSERT INTO drought_impact VALUES('Florida',0.15),('California',0.20); | SELECT state, drought_impact FROM drought_impact; |
What is the minimum water usage in MWh in a single month for the industrial sector in 2020? | CREATE TABLE min_water_usage_per_month (year INT,sector VARCHAR(20),month INT,usage FLOAT); INSERT INTO min_water_usage_per_month (year,sector,month,usage) VALUES (2020,'industrial',1,5000); INSERT INTO min_water_usage_per_month (year,sector,month,usage) VALUES (2020,'industrial',2,5500); INSERT INTO min_water_usage_per_month (year,sector,month,usage) VALUES (2020,'industrial',3,6000); | SELECT MIN(usage) FROM min_water_usage_per_month WHERE year = 2020 AND sector = 'industrial'; |
What was the water usage by month for the customer with id 5? | CREATE TABLE customer_water_usage (customer_id INT,month TEXT,usage FLOAT); INSERT INTO customer_water_usage (customer_id,month,usage) VALUES (5,'Jan',120.5),(5,'Feb',110.7); | SELECT month, usage FROM customer_water_usage WHERE customer_id = 5; |
What is the total number of models developed by each researcher for explainable AI? | CREATE TABLE researchers (id INT,name TEXT); INSERT INTO researchers (id,name) VALUES (1,'Alice'),(2,'Bob'),(3,'Charlie'); CREATE TABLE models (id INT,researcher_id INT,name TEXT,domain TEXT); INSERT INTO models (id,researcher_id,name,domain) VALUES (1,1,'XAIModel1','Explainable AI'),(2,1,'XAIModel2','Explainable AI'),(3,2,'XAIModel3','Explainable AI'),(4,3,'XAIModel4','Explainable AI'); | SELECT researchers.name, COUNT(models.id) as total_models FROM researchers INNER JOIN models ON researchers.id = models.researcher_id WHERE models.domain = 'Explainable AI' GROUP BY researchers.name; |
How many rural infrastructure projects were completed in India before 2017? | CREATE TABLE projects (id INT,location VARCHAR(50),completion_date DATE); INSERT INTO projects (id,location,completion_date) VALUES (1,'India','2016-05-01'),(2,'Brazil','2017-12-31'),(3,'Ghana','2016-08-15'),(4,'India','2018-09-05'),(5,'Tanzania','2014-11-23'); | SELECT COUNT(*) FROM projects WHERE location = 'India' AND completion_date < '2017-01-01'; |
What is the total budget for economic diversification efforts in 2018? | CREATE TABLE economic_diversification (id INT,year INT,effort VARCHAR(50),budget FLOAT); INSERT INTO economic_diversification (id,year,effort,budget) VALUES (1,2018,'Tourism',200000.00),(2,2019,'Renewable Energy',800000.00),(3,2020,'Handicrafts',500000.00); | SELECT SUM(budget) FROM economic_diversification WHERE year = 2018; |
How many flight safety incidents were reported for each aircraft model in the last 6 months? | CREATE TABLE Flight_Safety (incident_id INT,incident_date DATE,aircraft_model VARCHAR(255),incident_type VARCHAR(255)); INSERT INTO Flight_Safety (incident_id,incident_date,aircraft_model,incident_type) VALUES (1,'2022-03-01','B737','Engine Failure'),(2,'2022-04-01','A320','Landing Gear Malfunction'),(3,'2022-05-01','B737','Pressurization Issue'); | SELECT aircraft_model, COUNT(*) FROM Flight_Safety WHERE incident_date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY aircraft_model; |
Insert a new record into the flight_safety table with the following details: Flight ID 30, Flight Date '2023-03-01', Carrier 'SpaceX', Event 'Emergency Landing', Outcome 'Success' | CREATE TABLE flight_safety (flight_id INT,flight_date DATE,carrier VARCHAR(255),event VARCHAR(255),outcome VARCHAR(255)); | INSERT INTO flight_safety (flight_id, flight_date, carrier, event, outcome) VALUES (30, '2023-03-01', 'SpaceX', 'Emergency Landing', 'Success'); |
What are the names of satellites launched by Indian organizations after 2010? | CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),LaunchDate DATE,CountryOfOrigin VARCHAR(50),Manufacturer VARCHAR(50)); INSERT INTO Satellites (SatelliteID,Name,LaunchDate,CountryOfOrigin,Manufacturer) VALUES (3,'GSAT-12','2011-07-15','India','ISRO'); | SELECT Name FROM Satellites WHERE CountryOfOrigin = 'India' AND LaunchDate > '2010-01-01'; |
Delete the 'Galapagos Islands' habitat record in the 'habitat_preservation' table | CREATE TABLE habitat_preservation (id INT PRIMARY KEY,location VARCHAR(50),size_acres FLOAT,preservation_status VARCHAR(50),protected_species VARCHAR(50)); | DELETE FROM habitat_preservation WHERE location = 'Galapagos Islands'; |
How many animals have been successfully relocated to their natural habitats in South America? | CREATE TABLE Relocation (AnimalID INT,AnimalName VARCHAR(50),Success INT,Location VARCHAR(50)); INSERT INTO Relocation (AnimalID,AnimalName,Success,Location) VALUES (1,'Jaguar',120,'South America'); INSERT INTO Relocation (AnimalID,AnimalName,Success,Location) VALUES (2,'Anaconda',150,'South America'); | SELECT SUM(Success) FROM Relocation WHERE Location = 'South America'; |
What was the total CO2 emissions for fish feed production in Chile in 2020? | CREATE TABLE fish_feed_production (country VARCHAR(50),year INT,co2_emissions FLOAT); | SELECT SUM(co2_emissions) FROM fish_feed_production WHERE country = 'Chile' AND year = 2020; |
What is the total funding from corporations for performing arts programs in the last 5 years? | CREATE TABLE Funding (funding_id INT,source VARCHAR(255),amount DECIMAL(10,2),date DATE); CREATE TABLE Programs (program_id INT,name VARCHAR(255),category VARCHAR(255)); | SELECT SUM(F.amount) FROM Funding F JOIN Programs P ON 1=1 WHERE F.source LIKE '%Corporation%' AND F.date >= DATE(CURRENT_DATE) - INTERVAL 5 YEAR AND P.category = 'Performing Arts'; |
What is the total number of construction workers in 'Solar Ranch'? | CREATE TABLE Construction_Workers (worker_id INT,name VARCHAR(30),hours_worked FLOAT,location VARCHAR(20)); INSERT INTO Construction_Workers VALUES (1,'Maria Garcia',150.25,'Solar Ranch'),(2,'James Brown',200.50,'Eco City'),(3,'Fatima Alvarez',300.75,'Solar Ranch'),(4,'Tariq Patel',250.50,'Solar Ranch'); | SELECT COUNT(DISTINCT worker_id) FROM Construction_Workers WHERE location = 'Solar Ranch'; |
Calculate the total billing amount for all cases in the database. | CREATE TABLE case_data (case_type VARCHAR(20),billing_amount DECIMAL(10,2)); INSERT INTO case_data (case_type,billing_amount) VALUES ('Civil',5000.00),('Criminal',3000.00),('Family',6000.00); | SELECT SUM(billing_amount) as total_billing FROM case_data; |
Find the maximum billing amount for cases with a 'Non-Precedential' precedent type? | CREATE TABLE cases (case_id INT,precedent_type VARCHAR(20),billing_amount FLOAT); INSERT INTO cases (case_id,precedent_type,billing_amount) VALUES (1,'Precedential',5000),(2,'Non-Precedential',3000),(3,'Precedential',7000),(4,'Non-Precedential',8000),(5,'Non-Precedential',9000); | SELECT MAX(billing_amount) FROM cases WHERE precedent_type = 'Non-Precedential'; |
What is the average billing rate for attorneys in a particular region? | CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY,Region VARCHAR(255),HourlyRate DECIMAL(5,2)); INSERT INTO Attorneys (AttorneyID,Region,HourlyRate) VALUES (1,'Northeast',300.00),(2,'Southeast',250.00),(3,'Northeast',350.00); | SELECT AVG(HourlyRate) FROM Attorneys WHERE Region = 'Northeast'; |
What are the names and safety scores of all green chemicals? | CREATE TABLE chemicals (id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(255),safety_score INT); | SELECT c.name, c.safety_score FROM chemicals c WHERE c.category = 'green'; |
What is the percentage of the population that has access to clean water in each continent? | CREATE TABLE water_data (id INT,country VARCHAR(50),continent CHAR(2),access_to_clean_water BOOLEAN); INSERT INTO water_data VALUES (1,'Canada','NA',true),(2,'Mexico','NA',false),(3,'Brazil','SA',true),(4,'Russia','EU',true); | SELECT continent, COUNT(*) FILTER (WHERE access_to_clean_water) * 100.0 / COUNT(*) AS percentage FROM water_data GROUP BY continent; |
Delete all companies from the 'DiverseCompanies' table that have not received any diversity recognition. | CREATE TABLE DiverseCompanies (id INT,name TEXT,country TEXT); CREATE TABLE DiversityRecognition (id INT,company_id INT,recognition_type TEXT); INSERT INTO DiverseCompanies (id,name,country) VALUES (1,'No Recognition','Brazil'); | DELETE FROM DiverseCompanies WHERE id NOT IN (SELECT company_id FROM DiversityRecognition) |
Insert a new innovation trend for "GreenTech Solutions": "Artificial Intelligence in Renewable Energy" | CREATE TABLE innovation (id INT PRIMARY KEY AUTO_INCREMENT,company_id INT,trend VARCHAR(255),impact FLOAT,innovation_date DATE); | INSERT INTO innovation (company_id, trend, impact) VALUES ((SELECT id FROM company WHERE name = 'GreenTech Solutions'), 'Artificial Intelligence in Renewable Energy', NULL); |
What is the average cost of disability-related equipment per student in the education department? | CREATE TABLE students (id INT,department VARCHAR(255)); INSERT INTO students (id,department) VALUES (1,'education'),(2,'engineering'),(3,'education'); CREATE TABLE equipment (id INT,student_id INT,cost DECIMAL(10,2)); INSERT INTO equipment (id,student_id,cost) VALUES (1,1,500.00),(2,1,200.00),(3,3,300.00),(4,3,100.00),(5,2,700.00); | SELECT AVG(e.cost) as avg_cost FROM equipment e INNER JOIN students s ON e.student_id = s.id WHERE s.department = 'education'; |
Insert new records in the marine_species table for species named 'Green Sea Turtle', 'Leatherback Sea Turtle', and 'Loggerhead Sea Turtle' with populations of 8000, 5000, and 3000 respectively | CREATE TABLE marine_species (id INT,name VARCHAR(50),population INT); | INSERT INTO marine_species (name, population) VALUES ('Green Sea Turtle', 8000), ('Leatherback Sea Turtle', 5000), ('Loggerhead Sea Turtle', 3000); |
What is the maximum depth of all marine protected areas with a conservation status of 'Least Concern'? | CREATE TABLE marine_protected_areas (id INT,name VARCHAR(255),area_size FLOAT,avg_depth FLOAT,conservation_status VARCHAR(100)); INSERT INTO marine_protected_areas (id,name,area_size,avg_depth,conservation_status) VALUES (1,'Coral Triangle',518000,-200,'Least Concern'),(2,'Great Barrier Reef',344400,-500,'Critically Endangered'),(3,'Galapagos Marine Reserve',133000,-300,'Endangered'); | SELECT MAX(avg_depth) FROM marine_protected_areas WHERE conservation_status = 'Least Concern'; |
Which organic cosmetic products were sold by suppliers with a sustainability score of 90 or higher and have a revenue of over $1000? | CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(100),product VARCHAR(100),country VARCHAR(100),sustainability_score INT); CREATE TABLE cosmetics_sales (id INT PRIMARY KEY,product VARCHAR(100),quantity INT,revenue FLOAT,supplier_id INT,FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); CREATE TABLE cosmetics (id INT PRIMARY KEY,product VARCHAR(100),organic BOOLEAN); | SELECT cs.product FROM cosmetics_sales cs JOIN suppliers s ON cs.supplier_id = s.id JOIN cosmetics c ON cs.product = c.product WHERE c.organic = TRUE AND s.sustainability_score >= 90 AND cs.revenue > 1000; |
What is the count of emergency incidents for each type, partitioned by emergency response team and ordered by the total? | CREATE TABLE emergency_incidents (id INT,incident_type VARCHAR(255),response_team VARCHAR(255),incident_count INT); INSERT INTO emergency_incidents (id,incident_type,response_team,incident_count) VALUES (1,'Medical','Team A',100),(2,'Fire','Team B',50),(3,'Rescue','Team A',80),(4,'Medical','Team B',200); | SELECT incident_type, response_team, COUNT(*) as incident_count FROM emergency_incidents GROUP BY incident_type, response_team ORDER BY incident_count DESC; |
Delete all records from the 'threat_intelligence' table for the country of Russia | threat_intelligence(threat_id,country,category,sub_category,description,threat_level) | DELETE FROM threat_intelligence WHERE country = 'Russia'; |
What is the maximum number of days of downtime experienced by military equipment in the last 6 months? | CREATE TABLE Equipment (id INT,name VARCHAR(100),downtime DECIMAL(10,2)); INSERT INTO Equipment (id,name,downtime) VALUES (1,'Tank',5),(2,'Fighter Jet',10),(3,'Helicopter',15); | SELECT MAX(downtime) FROM Equipment WHERE downtime >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
Identify the top 3 rural counties with the highest percentage of residents who have been vaccinated against influenza. | CREATE TABLE county (name VARCHAR(50),population INT,flu_vaccinations INT); INSERT INTO county (name,population,flu_vaccinations) VALUES ('Woodland',5000,3000); INSERT INTO county (name,population,flu_vaccinations) VALUES ('Prairie',6000,4500); INSERT INTO county (name,population,flu_vaccinations) VALUES ('Mountain',7000,5500); INSERT INTO county (name,population,flu_vaccinations) VALUES ('Seaside',8000,6500); | SELECT name, (flu_vaccinations * 100.0 / population) AS percentage FROM county ORDER BY percentage DESC LIMIT 3; |
How many social impact investments were made in 'Asia' in 2019? | CREATE TABLE investments (id INT,location VARCHAR(50),investment_year INT,investment_type VARCHAR(20)); INSERT INTO investments (id,location,investment_year,investment_type) VALUES (1,'Asia',2019,'social impact'),(2,'Europe',2018,'social impact'),(3,'Asia',2019,'traditional'),(4,'North America',2020,'social impact'); | SELECT COUNT(*) FROM investments WHERE location = 'Asia' AND investment_year = 2019 AND investment_type = 'social impact'; |
Identify the intelligence operations that were conducted in the last 3 months, and rank them based on their budget. | CREATE TABLE intel_ops_dates (id INT,operation VARCHAR,budget INT,op_date DATE); INSERT INTO intel_ops_dates (id,operation,budget,op_date) VALUES (1,'Operation Red Folder',5000000,'2022-04-01'),(2,'Operation Black Vault',7000000,'2022-02-15'),(3,'Operation Blue Sail',6000000,'2022-01-01'); | SELECT operation, budget, ROW_NUMBER() OVER (ORDER BY budget DESC, op_date DESC) as rank FROM intel_ops_dates WHERE op_date >= DATEADD(month, -3, GETDATE()); |
How many times has the song 'Bohemian Rhapsody' been streamed on Spotify and Apple Music? | CREATE TABLE song_streams (stream_id INT,song_title VARCHAR(100),platform VARCHAR(20),streams INT); INSERT INTO song_streams (stream_id,song_title,platform,streams) VALUES (1,'Bohemian Rhapsody','Spotify',1000000),(2,'Bohemian Rhapsody','Apple Music',500000); | SELECT SUM(s.streams) as total_streams FROM song_streams s WHERE s.song_title = 'Bohemian Rhapsody'; |
What was the total amount donated by individuals in the "Arts & Culture" program in the year 2020? | CREATE TABLE Donations (id INT,donor VARCHAR(50),program VARCHAR(50),amount DECIMAL(10,2),donation_date DATE); INSERT INTO Donations (id,donor,program,amount,donation_date) VALUES (1,'John Doe','Arts & Culture',500.00,'2020-01-01'); | SELECT SUM(amount) FROM Donations WHERE program = 'Arts & Culture' AND YEAR(donation_date) = 2020 AND donor NOT IN ('Organizations','Companies'); |
How many professional development courses were completed by teachers in the "Westside" school in 2019? | CREATE TABLE teachers (teacher_id INT,school VARCHAR(20),courses_completed INT,year INT); INSERT INTO teachers (teacher_id,school,courses_completed,year) VALUES (1,'Westside',12,2019),(2,'Westside',14,2019),(3,'Westside',9,2019); | SELECT SUM(courses_completed) FROM teachers WHERE school = 'Westside' AND year = 2019; |
Insert new teacher records for 'Arizona' and 'Nevada' who have completed their professional development | CREATE TABLE NewTeachers (TeacherID INT,State VARCHAR(10),ProfessionalDevelopment VARCHAR(10)); INSERT INTO NewTeachers (TeacherID,State,ProfessionalDevelopment) VALUES (1,'AZ','Completed'),(2,'NV','Completed'); | INSERT INTO NewTeachers (TeacherID, State, ProfessionalDevelopment) VALUES (3, 'Arizona', 'Completed'), (4, 'Nevada', 'Completed'); |
What is the total energy consumption of residential and commercial buildings in Australia in 2020? | CREATE TABLE EnergyConsumption (Sector TEXT,Year INT,Consumption NUMBER); INSERT INTO EnergyConsumption (Sector,Year,Consumption) VALUES ('Residential',2020,120000),('Commercial',2020,180000),('Industrial',2020,240000); CREATE TABLE Emissions (Sector TEXT,Year INT,Emissions NUMBER); INSERT INTO Emissions (Sector,Year,Emissions) VALUES ('Residential',2020,3000),('Commercial',2020,6000),('Industrial',2020,9000); | SELECT EnergyConsumption.Sector, SUM(EnergyConsumption.Consumption) AS Total_Energy_Consumption FROM EnergyConsumption WHERE EnergyConsumption.Sector IN ('Residential', 'Commercial') AND EnergyConsumption.Year = 2020 GROUP BY EnergyConsumption.Sector; |
What is the total installed capacity of solar farms in China and Spain? | CREATE TABLE solar_farm (id INT,country VARCHAR(20),name VARCHAR(50),capacity FLOAT); INSERT INTO solar_farm (id,country,name,capacity) VALUES (1,'China','Solarfarm 1',200.5),(2,'Spain','Solarfarm 2',100.6),(3,'China','Solarfarm 3',150.7); | SELECT SUM(capacity) FROM solar_farm WHERE country IN ('China', 'Spain'); |
What is the production quantity for 'Well B'? | CREATE TABLE well_quantities (well_name TEXT,production_quantity INT); INSERT INTO well_quantities (well_name,production_quantity) VALUES ('Well A',4000),('Well B',5000),('Well C',6000); | SELECT production_quantity FROM well_quantities WHERE well_name = 'Well B'; |
Find the number of matches played at home and away for each team, and the win/loss ratio for home and away matches, in the football_matches dataset. | CREATE TABLE football_matches (team VARCHAR(50),location VARCHAR(50),result VARCHAR(50)); | SELECT team, COUNT(location) as total_matches, SUM(CASE WHEN result = 'win' AND location = 'home' THEN 1 ELSE 0 END) as home_wins, SUM(CASE WHEN result = 'loss' AND location = 'home' THEN 1 ELSE 0 END) as home_losses, SUM(CASE WHEN result = 'win' AND location = 'away' THEN 1 ELSE 0 END) as away_wins, SUM(CASE WHEN result = 'loss' AND location = 'away' THEN 1 ELSE 0 END) as away_losses FROM football_matches GROUP BY team; |
What is the total points scored by a player? | CREATE TABLE players (player_id INT,player_name TEXT); CREATE TABLE points (point_id INT,player_id INT,points INT); | SELECT p.player_name, SUM(p.points) as total_points FROM points p GROUP BY p.player_name; |
Delete all records in the "ai_ethics" table where the "region" is "Europe" | CREATE TABLE ai_ethics (company TEXT,region TEXT,guidelines TEXT); INSERT INTO ai_ethics (company,region,guidelines) VALUES ('Microsoft','North America','Ethical AI guidelines for AI development'); INSERT INTO ai_ethics (company,region,guidelines) VALUES ('Google','Europe','AI ethical guidelines for AI usage'); INSERT INTO ai_ethics (company,region,guidelines) VALUES ('IBM','Asia','AI ethical guidelines for AI deployment'); | DELETE FROM ai_ethics WHERE region = 'Europe'; |
List all organizations that have received funding for ethical AI from government sources, but not from private sources. | CREATE TABLE organizations (org_id INT,name VARCHAR(50),gov_funding BOOLEAN,private_funding BOOLEAN); INSERT INTO organizations (org_id,name,gov_funding,private_funding) VALUES (1,'Ethical AI Corp.',TRUE,FALSE),(2,'AI for Good Inc.',FALSE,TRUE),(3,'Government AI Initiative',TRUE,FALSE),(4,'Non-profit AI',FALSE,FALSE); | SELECT name FROM organizations WHERE gov_funding = TRUE AND private_funding = FALSE; |
What is the average score for AI tools designed for social good? | CREATE TABLE ai_tools (id INT,name TEXT,type TEXT,score FLOAT); INSERT INTO ai_tools (id,name,type,score) VALUES (1,'ToolA','SocialGood',4.2),(2,'ToolB','SocialGood',4.6),(3,'ToolC','SocialGood',4.9); | SELECT AVG(score) FROM ai_tools WHERE type = 'SocialGood'; |
What is the minimum budget required for digital divide projects in Africa? | CREATE TABLE projects (id INT,name VARCHAR(50),region VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO projects (id,name,region,budget) VALUES (1,'ConnectAfrica','Africa',100000.00),(2,'DigitalDivideAfrica','Africa',200000.00); | SELECT MIN(budget) FROM projects WHERE region = 'Africa' AND name LIKE '%digital divide%'; |
What is the total number of posts created by users from Germany, grouped by age and gender? | CREATE TABLE users (user_id INT,age INT,gender VARCHAR(10),country VARCHAR(10)); INSERT INTO users (user_id,age,gender,country) VALUES (101,25,'Female','Germany'),(102,35,'Male','France'); CREATE TABLE posts (post_id INT,user_id INT,post_type VARCHAR(20)); INSERT INTO posts (post_id,user_id,post_type) VALUES (1,101,'Text'),(2,102,'Image'); | SELECT u.age, u.gender, COUNT(*) AS total_posts FROM users u INNER JOIN posts p ON u.user_id = p.user_id WHERE u.country = 'Germany' GROUP BY u.age, u.gender; |
What is the total revenue from ads targeting users interested in veganism in Q3 2022? | CREATE TABLE ads (id INT,user INT,platform VARCHAR(50),target VARCHAR(50),start_date DATE,end_date DATE,revenue DECIMAL(10,2)); | SELECT SUM(revenue) FROM ads WHERE target = 'veganism' AND platform IN ('Facebook', 'Instagram') AND start_date BETWEEN '2022-07-01' AND '2022-09-30'; |
How many unique customers made sustainable clothing purchases in Asia? | CREATE TABLE Customers (id INT,name VARCHAR(50),sustainable_purchase_date DATE,location VARCHAR(50)); INSERT INTO Customers (id,name,sustainable_purchase_date,location) VALUES (1,'Alice','2022-01-01','USA'),(2,'Bob','2022-02-15','China'),(3,'Charlie','2022-03-05','India'),(4,'David','2022-04-10','Canada'),(5,'Eve','2022-05-25','Vietnam'),(6,'Frank','2022-06-12','Mexico'); | SELECT COUNT(DISTINCT id) FROM Customers WHERE EXISTS (SELECT 1 FROM Sales WHERE Customers.id = Sales.customer_id AND material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo') AND location IN ('China', 'India', 'Vietnam')); |
Average financial wellbeing score for programs in the Southern region | CREATE TABLE financial_wellbeing_programs (id INT,score FLOAT,region VARCHAR(255)); | SELECT AVG(score) FROM financial_wellbeing_programs WHERE region = 'Southern'; |
What is the total number of Shariah-compliant financial institutions in the United Arab Emirates? | CREATE TABLE shariah_compliant_finance (id INT,institution_name VARCHAR(255),country VARCHAR(255)); INSERT INTO shariah_compliant_finance (id,institution_name,country) VALUES (1,'Dubai Islamic Bank','United Arab Emirates'),(2,'Abu Dhabi Islamic Bank','United Arab Emirates'),(3,'Emirates Islamic','United Arab Emirates'); | SELECT COUNT(*) FROM shariah_compliant_finance WHERE country = 'United Arab Emirates'; |
Show the number of volunteers for each program, grouped by program type | CREATE TABLE programs (id INT,name VARCHAR(50),type VARCHAR(20)); CREATE TABLE volunteers (id INT,program_id INT,name VARCHAR(50)); | SELECT p.type, COUNT(v.id) as num_volunteers FROM programs p JOIN volunteers v ON p.id = v.program_id GROUP BY p.type; |
Which suppliers provide the most "Free-Range Chicken" and "Grass-Fed Beef"? | CREATE TABLE Suppliers(supplier VARCHAR(20),product VARCHAR(20),quantity INT); INSERT INTO Suppliers(supplier,product,quantity) VALUES('Supplier A','Free-Range Chicken',100),('Supplier B','Grass-Fed Beef',150),('Supplier A','Grass-Fed Beef',75); | SELECT supplier, product, SUM(quantity) as total_quantity FROM Suppliers GROUP BY supplier, product ORDER BY SUM(quantity) DESC; |
What is the total weight of items shipped to South America? | CREATE TABLE ShipmentWeights(id INT,item_name VARCHAR(50),shipment_weight INT,destination_continent VARCHAR(50)); INSERT INTO ShipmentWeights(id,item_name,shipment_weight,destination_continent) VALUES (1,'Item 1',100,'South America'),(2,'Item 2',120,'South America'); | SELECT SUM(shipment_weight) FROM ShipmentWeights WHERE destination_continent = 'South America'; |
List all biotech startups that received funding in 2022 and their respective funding amounts. | CREATE TABLE biotech_startups (name TEXT,funding FLOAT,date DATE); INSERT INTO biotech_startups (name,funding,date) VALUES ('StartupA',3500000,'2022-02-28'); INSERT INTO biotech_startups (name,funding,date) VALUES ('StartupB',4500000,'2022-07-12'); | SELECT name, funding FROM biotech_startups WHERE date BETWEEN '2022-01-01' AND '2022-12-31'; |
Percentage of people living in urban areas in each Asian country in 2020. | CREATE TABLE population (id INT,country VARCHAR(50),urban BOOLEAN,year INT); INSERT INTO population (id,country,urban,year) VALUES (1,'China',true,2020),(2,'India',false,2020),(3,'Indonesia',true,2020),(4,'Pakistan',false,2020),(5,'Bangladesh',true,2020); | SELECT country, 100.0 * SUM(CASE WHEN urban = true THEN 1 ELSE 0 END) / COUNT(*) AS percentage FROM population WHERE year = 2020 GROUP BY country; |
What are the names and research interests of all faculty members who have published in the Journal of Computer Science? | CREATE TABLE Faculty (FacultyID INT,Name VARCHAR(50),ResearchInterest VARCHAR(50)); INSERT INTO Faculty VALUES (1,'John Doe','Machine Learning'); CREATE TABLE Publications (PublicationID INT,Title VARCHAR(50),FacultyID INT); INSERT INTO Publications VALUES (1,'Journal of Computer Science',1); | SELECT Faculty.Name, Faculty.ResearchInterest FROM Faculty INNER JOIN Publications ON Faculty.FacultyID = Publications.FacultyID WHERE Publications.Title = 'Journal of Computer Science'; |
Find renewable energy projects that are not located in the top 5 most populous cities in the world. | CREATE TABLE renewable_projects (project_name VARCHAR(255),city VARCHAR(255)); CREATE TABLE city_populations (city VARCHAR(255),population INT); | SELECT project_name FROM renewable_projects RP WHERE city NOT IN (SELECT city FROM (SELECT city, ROW_NUMBER() OVER (ORDER BY population DESC) as rank FROM city_populations) CP WHERE rank <= 5); |
Delete the record of the community health worker with the highest age in 'ON' province. | CREATE TABLE CommunityHealthWorkersCanada (WorkerID INT,Age INT,Gender VARCHAR(1),Province VARCHAR(2)); INSERT INTO CommunityHealthWorkersCanada (WorkerID,Age,Gender,Province) VALUES (1,35,'F','ON'),(2,40,'M','QC'),(3,45,'F','BC'),(4,50,'M','AB'),(5,55,'F','ON'); | DELETE FROM CommunityHealthWorkersCanada WHERE WorkerID = (SELECT WorkerID FROM (SELECT WorkerID, ROW_NUMBER() OVER (PARTITION BY Province ORDER BY Age DESC) rn FROM CommunityHealthWorkersCanada) t WHERE t.rn = 1 AND t.Province = 'ON'); |
Update the race of patient with ID 1 to 'Native American' in the patients table. | CREATE TABLE patients (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),race VARCHAR(20),ethnicity VARCHAR(30)); INSERT INTO patients (id,name,age,gender,race,ethnicity) VALUES (1,'John Doe',35,'Male','Caucasian','Non-Hispanic'),(2,'Jane Smith',40,'Female','African American','African American'),(3,'Maria Garcia',45,'Female','Hispanic','Hispanic'),(4,'David Kim',50,'Male','Asian','Asian'); | UPDATE patients SET race = 'Native American' WHERE id = 1; |
How many eco-friendly hotels are there in Canada? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT); CREATE TABLE eco_hotels (hotel_id INT,is_eco BOOLEAN); INSERT INTO hotels (hotel_id,hotel_name,country) VALUES (1,'Eco-Hotel','Canada'),(2,'Urban-Hotel','Canada'); INSERT INTO eco_hotels (hotel_id,is_eco) VALUES (1,true),(2,false); | SELECT COUNT(*) FROM hotels INNER JOIN eco_hotels ON hotels.hotel_id = eco_hotels.hotel_id WHERE is_eco = true AND country = 'Canada'; |
What is the average revenue generated from virtual tours in Greece in 2021? | CREATE TABLE virtual_tours_greece (site_id INT,site_name TEXT,country TEXT,year INT,revenue INT); INSERT INTO virtual_tours_greece (site_id,site_name,country,year,revenue) VALUES (1,'Acropolis','Greece',2021,4000),(2,'Parthenon','Greece',2021,6000); | SELECT AVG(revenue) FROM virtual_tours_greece WHERE country = 'Greece' AND year = 2021; |
What is the revenue generated from cultural heritage sites in Tokyo's Shibuya district? | CREATE TABLE sites (id INT,name TEXT,city TEXT,region TEXT,revenue FLOAT); INSERT INTO sites (id,name,city,region,revenue) VALUES (1,'Site1','Tokyo','Shibuya',1000.0),(2,'Site2','Tokyo','Shibuya',1200.0); | SELECT SUM(revenue) FROM sites WHERE city = 'Tokyo' AND region = 'Shibuya'; |
Show the number of heritage sites in each country, ordered by the number of heritage sites in descending order. | CREATE TABLE heritage_sites (site_id INT,site_name TEXT,country TEXT,year_listed INT); INSERT INTO heritage_sites (site_id,site_name,country,year_listed) VALUES (1,'Machu Picchu','Peru',1983),(2,'Petra','Jordan',1985); | SELECT country, COUNT(*) as num_heritage_sites FROM heritage_sites GROUP BY country ORDER BY num_heritage_sites DESC; |
What is the average number of heritage sites per country in Asia? | CREATE TABLE continents (id INT,name TEXT); INSERT INTO continents (id,name) VALUES (1,'Asia'),(2,'Africa'); CREATE TABLE countries (id INT,continent_id INT,name TEXT); INSERT INTO countries (id,continent_id,name) VALUES (1,1,'China'),(2,1,'India'),(3,2,'Nigeria'); CREATE TABLE heritage_sites (id INT,country_id INT,name TEXT); INSERT INTO heritage_sites (id,country_id,name) VALUES (1,1,'Great Wall'),(2,1,'Forbidden City'),(3,2,'Taj Mahal'),(4,3,'Zuma Rock'); | SELECT c.continent_id, AVG(COUNT(*)) FROM countries c JOIN heritage_sites hs ON c.id = hs.country_id WHERE c.continent_id = 1 GROUP BY c.continent_id; |
Identify the number of mental health conditions per patient | CREATE TABLE patients_conditions (patient_id INT,condition VARCHAR(20)); INSERT INTO patients_conditions (patient_id,condition) VALUES (1,'depression'),(1,'anxiety'); | SELECT patient_id, COUNT(condition) FROM patients_conditions GROUP BY patient_id; |
What is the average age of patients diagnosed with depression in Mexico? | CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE patients (patient_id INT,diagnosis VARCHAR(50),age INT,country VARCHAR(50)); INSERT INTO patients VALUES (1,'depression',35,'Mexico'); | SELECT AVG(age) FROM patients WHERE diagnosis = 'depression' AND country = 'Mexico'; |
What is the average age of patients who received therapy in 'clinic_a' and 'clinic_b'? | CREATE TABLE clinic_a (patient_id INT,age INT,therapy_received BOOLEAN); INSERT INTO clinic_a (patient_id,age,therapy_received) VALUES (1,35,true),(2,42,true),(3,28,false); CREATE TABLE clinic_b (patient_id INT,age INT,therapy_received BOOLEAN); INSERT INTO clinic_b (patient_id,age,therapy_received) VALUES (4,50,true),(5,32,false),(6,45,true); | SELECT AVG(age) FROM (SELECT age FROM clinic_a WHERE therapy_received = true UNION ALL SELECT age FROM clinic_b WHERE therapy_received = true) AS combined_clinics; |
What is the average rating of eco-friendly hotels in Costa Rica? | CREATE TABLE eco_hotels (hotel_id INT,name TEXT,country TEXT,rating FLOAT); INSERT INTO eco_hotels (hotel_id,name,country,rating) VALUES (1,'Hotel Aguas Claras','Costa Rica',4.6),(2,'Hotel Cascada Verde','Costa Rica',4.8); | SELECT AVG(rating) FROM eco_hotels WHERE country = 'Costa Rica'; |
Which sustainable tourism initiatives in Tokyo, Japan, were launched in the last year? | CREATE TABLE if not exists countries (country_id INT,name TEXT); INSERT INTO countries (country_id,name) VALUES (1,'Japan'); CREATE TABLE if not exists cities (city_id INT,name TEXT,country_id INT,population INT); INSERT INTO cities (city_id,name,country_id,population) VALUES (1,'Tokyo',1,9000000); CREATE TABLE if not exists tourism_initiatives (initiative_id INT,name TEXT,city_id INT,launch_date DATE,is_sustainable BOOLEAN); INSERT INTO tourism_initiatives (initiative_id,name,city_id,launch_date,is_sustainable) VALUES (1,'Green Spaces Expansion',1,'2021-04-01',TRUE),(2,'Bicycle Sharing Program',1,'2021-07-01',TRUE),(3,'Smart Public Transport',1,'2022-01-01',TRUE),(4,'Historic Building Restoration',1,'2022-03-15',FALSE); | SELECT name FROM tourism_initiatives WHERE city_id = (SELECT city_id FROM cities WHERE name = 'Tokyo' AND country_id = (SELECT country_id FROM countries WHERE name = 'Japan')) AND is_sustainable = TRUE AND launch_date >= (CURRENT_DATE - INTERVAL '1 year'); |
Insert a new record into 'customer_preferences' for customer 101 and menu item 1 with a preference score of 90 | CREATE TABLE customer_preferences (customer_id INT,item_id INT,preference_score INT); | INSERT INTO customer_preferences (customer_id, item_id, preference_score) VALUES (101, 1, 90); |
Update the quantity of 'Local Cheese' to 45 in inventory. | CREATE TABLE inventory (id INT PRIMARY KEY,product VARCHAR(100),quantity INT); INSERT INTO inventory (id,product,quantity) VALUES (1,'Fresh Mozzarella',50),(2,'Tomato Sauce',100),(3,'Romaine Lettuce',30),(4,'Free-Range Eggs',60),(5,'Local Cheese',40); | UPDATE inventory SET quantity = 45 WHERE product = 'Local Cheese'; |
What are the names and quantities of military equipment sold to India? | CREATE TABLE equipment_sales (id INT,equipment_name VARCHAR,quantity INT,country VARCHAR); | SELECT equipment_name, quantity FROM equipment_sales WHERE country = 'India'; |
Determine the total production quantity of silver for mining sites in Mexico, between the dates '2017-05-01' and '2017-09-30', having less than 40 employees. | CREATE TABLE silver_mine_2 (site_id INT,country VARCHAR(50),num_employees INT,extraction_date DATE,quantity INT); INSERT INTO silver_mine_2 (site_id,country,num_employees,extraction_date,quantity) VALUES (1,'Mexico',35,'2017-05-02',1200),(2,'Mexico',30,'2017-08-31',1800),(3,'Mexico',37,'2017-07-04',2200); | SELECT country, SUM(quantity) as total_silver_prod FROM silver_mine_2 WHERE num_employees < 40 AND country = 'Mexico' AND extraction_date >= '2017-05-01' AND extraction_date <= '2017-09-30' GROUP BY country; |
Find the number of employees by department in the mining company | CREATE TABLE department (id INT,name VARCHAR(255),employees INT); INSERT INTO department (id,name,employees) VALUES (1,'Mining',300),(2,'Engineering',250),(3,'Human Resources',50); | SELECT d.name, COUNT(d.employees) as num_employees FROM department d GROUP BY d.name; |
What is the average revenue for each genre, excluding genres with less than 3 concerts? | CREATE SCHEMA if not exists music_schema;CREATE TABLE if not exists concerts (id INT,name VARCHAR,city VARCHAR,genre VARCHAR,revenue FLOAT);INSERT INTO concerts (id,name,city,genre,revenue) VALUES (1,'Music Festival','New York','Pop',50000.00),(2,'Rock Concert','Chicago','Rock',75000.00),(3,'Jazz Festival','Los Angeles','Jazz',125000.00),(4,'Hip Hop Concert','Miami','Hip Hop',60000.00),(5,'Country Music Festival','Nashville','Country',40000.00),(6,'EDM Festival','Las Vegas','EDM',80000.00),(7,'Pop Concert','Los Angeles','Pop',70000.00),(8,'Rock Festival','Chicago','Rock',65000.00),(9,'Jazz Concert','Los Angeles','Jazz',110000.00),(10,'Hip Hop Festival','Miami','Hip Hop',75000.00); | SELECT genre, AVG(revenue) as avg_revenue FROM music_schema.concerts GROUP BY genre HAVING COUNT(*) >= 3; |
Get the average word count for articles published before 2020 in the 'news_articles' table | CREATE TABLE news_articles (article_id INT,author_name VARCHAR(50),title VARCHAR(100),published_date DATE,word_count INT); | SELECT AVG(word_count) as average_word_count FROM news_articles WHERE published_date < '2020-01-01'; |
What are the total donations received by organizations located in California, grouped by their mission areas? | CREATE TABLE organizations (id INT,name VARCHAR(100),mission_area VARCHAR(50),state VARCHAR(50)); INSERT INTO organizations VALUES (1,'Organization A','Education','California'); INSERT INTO organizations VALUES (2,'Organization B','Health','California'); CREATE TABLE donations (id INT,organization_id INT,amount DECIMAL(10,2)); INSERT INTO donations VALUES (1,1,5000); INSERT INTO donations VALUES (2,1,7500); INSERT INTO donations VALUES (3,2,10000); | SELECT o.mission_area, SUM(d.amount) as total_donations FROM organizations o INNER JOIN donations d ON o.id = d.organization_id WHERE o.state = 'California' GROUP BY o.mission_area; |
Find the total biomass of all shark species in the Southern Ocean. | CREATE TABLE shark_species (name TEXT,location TEXT,biomass REAL); INSERT INTO shark_species (name,location,biomass) VALUES ('Great White Shark','Southern Ocean','1000'),('Hammerhead Shark','Atlantic Ocean','500'); | SELECT SUM(biomass) FROM shark_species WHERE location = 'Southern Ocean'; |
Insert a new record for a donor from Mexico with an amount of 7000. | CREATE TABLE donors (id INT,name TEXT,country TEXT,amount_donated DECIMAL(10,2)); INSERT INTO donors (id,name,country,amount_donated) VALUES (1,'Alice','United States',5000.00),(2,'Bob','Canada',6000.00),(3,'Charlie','India',4000.00); | INSERT INTO donors (name, country, amount_donated) VALUES ('David', 'Mexico', 7000); |
Update the resolution to 0.45 for the satellite image with id 1 | CREATE TABLE satellite_images (id INT PRIMARY KEY,image_url TEXT,resolution FLOAT,capture_date DATE); INSERT INTO satellite_images (id,image_url,resolution,capture_date) VALUES (1,'https://example.com/image1.jpg',0.5,'2021-12-25'),(2,'https://example.com/image2.jpg',0.7,'2021-12-26'),(3,'https://example.com/image3.jpg',0.6,'2021-12-27'); | UPDATE satellite_images SET resolution = 0.45 WHERE id = 1; |
How many citizen feedback records were recorded for each city in 2020? | CREATE TABLE Feedback (CityName VARCHAR(50),FeedbackID INT,Date DATE); INSERT INTO Feedback (CityName,FeedbackID,Date) VALUES ('CityA',1,'2020-01-01'),('CityA',2,'2020-02-01'),('CityB',3,'2020-01-01'),('CityB',4,'2020-03-01'),('CityC',5,'2020-01-01'); | SELECT CityName, COUNT(*) FROM Feedback WHERE Date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY CityName; |
What is the total budget allocated for housing and transportation services in 2021 across all regions, excluding the South? | CREATE TABLE Budget (Year INT,Service VARCHAR(20),Region VARCHAR(20),Amount DECIMAL(10,2)); INSERT INTO Budget (Year,Service,Region,Amount) VALUES (2021,'Housing','Northeast',75000.00),(2021,'Transportation','South',80000.00),(2021,'Housing','West',90000.00); | SELECT SUM(Amount) FROM Budget WHERE Year = 2021 AND (Service IN ('Housing', 'Transportation') AND Region != 'South'); |
What is the total number of citizen feedback submissions received in each department in the last year, grouped by feedback type? | CREATE TABLE Feedback (Submission_Date DATE,Department VARCHAR(255),Feedback_Type VARCHAR(255),Submission_ID INT); INSERT INTO Feedback VALUES ('2022-01-01','Healthcare','Positive',1),('2022-02-01','Education','Negative',2),('2022-03-31','Healthcare','Neutral',3),('2022-04-01','Education','Positive',4),('2022-05-01','Transportation','Negative',5); | SELECT Department, Feedback_Type, COUNT(*) OVER (PARTITION BY Department, Feedback_Type) AS Total_Submissions FROM Feedback WHERE Submission_Date >= DATEADD(year, -1, GETDATE()); |
List all the Praseodymium production data from 2018 to 2020 | CREATE TABLE production_praseodymium (year INT,quantity INT); INSERT INTO production_praseodymium (year,quantity) VALUES (2015,800),(2016,900),(2017,1000),(2018,1200),(2019,1400),(2020,1600),(2021,1800); | SELECT * FROM production_praseodymium WHERE year BETWEEN 2018 AND 2020; |
What is the minimum square footage of a co-owned property in the city of Boston? | CREATE TABLE properties (id INT,city VARCHAR(20),size INT,co_owned BOOLEAN); INSERT INTO properties (id,city,size,co_owned) VALUES (1,'Boston',1100,TRUE),(2,'Boston',1300,FALSE),(3,'Boston',1500,TRUE); | SELECT MIN(size) FROM properties WHERE city = 'Boston' AND co_owned = TRUE; |
What is the average carbon offset amount for carbon offset programs in the 'Energy Production' sector? | CREATE TABLE Carbon_Offset_Programs (id INT,sector VARCHAR(20),year INT,carbon_offset_amount INT); INSERT INTO Carbon_Offset_Programs (id,sector,year,carbon_offset_amount) VALUES (1,'Transportation',2018,50000),(2,'Energy Production',2019,75000),(3,'Transportation',2020,65000),(4,'Manufacturing',2021,80000),(5,'Energy Production',2020,80000),(6,'Energy Production',2018,60000); | SELECT AVG(carbon_offset_amount) FROM Carbon_Offset_Programs WHERE sector = 'Energy Production'; |
Update the price for record with item_name 'Veggie Burger' to be 9.99 in the menu_items table | CREATE TABLE menu_items (item_name VARCHAR(255),price DECIMAL(5,2)); | UPDATE menu_items SET price = 9.99 WHERE item_name = 'Veggie Burger'; |
How many missions have been led by astronauts from underrepresented communities? | CREATE TABLE Astronauts (id INT,name VARCHAR(100),community VARCHAR(100)); CREATE TABLE Missions (id INT,leader_astronaut_id INT,name VARCHAR(100)); INSERT INTO Astronauts VALUES (1,'Alexandria Ocasio-Cortez','Latino'); INSERT INTO Missions VALUES (1,1,'Mars Mission 1'); | SELECT COUNT(*) FROM Missions INNER JOIN Astronauts ON Missions.leader_astronaut_id = Astronauts.id WHERE Astronauts.community <> 'Mainstream'; |
How many spacecraft were launched by China in each year? | CREATE TABLE spacecraft_launches (id INT,country VARCHAR(50),year INT,quantity INT); INSERT INTO spacecraft_launches (id,country,year,quantity) VALUES (1,'China',2000,1); | SELECT country, year, SUM(quantity) FROM spacecraft_launches WHERE country = 'China' GROUP BY country, year; |
What is the total number of spacecraft components produced by each manufacturer? | CREATE TABLE SpacecraftComponents (id INT,spacecraft_id INT,manufacturer TEXT,component_type TEXT); CREATE TABLE Spacecraft (id INT,name TEXT,manufacturer TEXT); | SELECT manufacturer, COUNT(*) FROM SpacecraftComponents GROUP BY manufacturer; |
How many critical vulnerabilities are in the HR department? | CREATE TABLE vulnerabilities (id INT,department VARCHAR(255),severity VARCHAR(255)); INSERT INTO vulnerabilities (id,department,severity) VALUES (1,'HR','critical'),(2,'IT','high'),(3,'HR','medium'),(4,'HR','low'); | SELECT COUNT(*) FROM vulnerabilities WHERE department = 'HR' AND severity = 'critical'; |
List all threat intelligence data related to the United States. | CREATE TABLE threat_intelligence (id INT,source VARCHAR(20),description TEXT,country VARCHAR(20)); INSERT INTO threat_intelligence (id,source,description,country) VALUES (1,'NSA','Zero-day exploit','United States'); | SELECT * FROM threat_intelligence WHERE country = 'United States'; |
List the top 5 policyholders with the highest claim amounts in Texas. | CREATE TABLE policyholders (id INT,policyholder_name TEXT,state TEXT,age INT,gender TEXT); INSERT INTO policyholders (id,policyholder_name,state,age,gender) VALUES (1,'John Doe','TX',35,'Male'); INSERT INTO policyholders (id,policyholder_name,state,age,gender) VALUES (2,'Jane Smith','TX',42,'Female'); CREATE TABLE claims (id INT,policyholder_id INT,claim_amount INT); INSERT INTO claims (id,policyholder_id,claim_amount) VALUES (1,1,500); INSERT INTO claims (id,policyholder_id,claim_amount) VALUES (2,2,2000); INSERT INTO claims (id,policyholder_id,claim_amount) VALUES (3,1,800); | SELECT policyholders.policyholder_name, SUM(claims.claim_amount) AS total_claim_amount FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'TX' GROUP BY policyholders.policyholder_name ORDER BY total_claim_amount DESC LIMIT 5; |
What is the average claim amount per region? | CREATE TABLE claims (id INT,policyholder_id INT,region VARCHAR(20),claim_amount DECIMAL(10,2)); INSERT INTO claims (id,policyholder_id,region,claim_amount) VALUES (1,1,'South',1500.00),(2,2,'West',3000.00),(3,3,'South',500.00),(4,4,'East',4500.00),(5,1,'South',2000.00); | SELECT region, AVG(claim_amount) as avg_claim_amount FROM claims GROUP BY region; |
What is the total claim amount for policy number 1001? | CREATE TABLE claims (claim_id INT,policy_id INT,claim_amount DECIMAL); INSERT INTO claims (claim_id,policy_id,claim_amount) VALUES (1,1001,2500.00),(2,1002,3000.00),(3,1003,1500.00); | SELECT SUM(claim_amount) FROM claims WHERE policy_id = 1001; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.