instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
List all erbium production quantities for each year in Brazil. | CREATE TABLE erbium_production (country VARCHAR(20),quantity INT,year INT); INSERT INTO erbium_production (country,quantity,year) VALUES ('Brazil',1200,2018),('Brazil',1300,2019),('Brazil',1400,2020); | SELECT country, year, quantity FROM erbium_production WHERE country = 'Brazil'; |
Which countries have rare earth element reserves greater than 2000? | CREATE TABLE country_reserves (country VARCHAR(50),reserves INT); INSERT INTO country_reserves (country,reserves) VALUES ('China',44000),('USA',1300),('Australia',3800),('India',674),('Brazil',220); | SELECT country FROM country_reserves WHERE reserves > 2000; |
List the total number of products for each supplier. | CREATE TABLE product (product_id INT,name VARCHAR(255),quantity INT,supplier_id INT); INSERT INTO product (product_id,name,quantity,supplier_id) VALUES (1,'Organic Cotton T-Shirt',30,1),(2,'Polyester Hoodie',20,2),(3,'Bamboo Socks',50,1); | SELECT supplier_id, COUNT(*) FROM product GROUP BY supplier_id; |
What is the distribution of space debris by mass in the space_debris_by_mass table? | CREATE TABLE space_debris_by_mass (id INT,mass_range VARCHAR(20),mass FLOAT); INSERT INTO space_debris_by_mass (id,mass_range,mass) VALUES (1,'< 100 kg',50),(2,'100-500 kg',300),(3,'500-1000 kg',500),(4,'> 1000 kg',3500); | SELECT mass_range, SUM(mass) FROM space_debris_by_mass GROUP BY mass_range; |
What is the total number of satellites launched by China? | CREATE TABLE satellites_by_country (id INT,name VARCHAR(50),type VARCHAR(50),launch_date DATE,orbit VARCHAR(50),country VARCHAR(50),number_of_satellites INT); | SELECT SUM(number_of_satellites) FROM satellites_by_country WHERE country = 'China'; |
Which companies have launched satellites into geostationary orbit? | CREATE TABLE geostationary_orbit (id INT,company VARCHAR(255),satellite_name VARCHAR(255)); INSERT INTO geostationary_orbit (id,company,satellite_name) VALUES (1,'Boeing','Intelsat 901'),(2,'Lockheed Martin','DirecTV 1'),(3,'Space Systems/Loral','EchoStar 19'),(4,'Airbus Defence and Space','Eutelsat 172B'); | SELECT DISTINCT company FROM geostationary_orbit WHERE orbit = 'geostationary'; |
What is the total duration of all space missions | CREATE TABLE SpaceMissions (id INT,mission_name VARCHAR(30),duration INT); INSERT INTO SpaceMissions (id,mission_name,duration) VALUES (1,'Mars Exploration',400); INSERT INTO SpaceMissions (id,mission_name,duration) VALUES (2,'Asteroid Survey',250); INSERT INTO SpaceMissions (id,mission_name,duration) VALUES (3,'Space Station Maintenance',300); | SELECT SUM(duration) FROM SpaceMissions; |
How many fans are from each state? | CREATE TABLE fans (fan_id INT,state VARCHAR(255)); INSERT INTO fans (fan_id,state) VALUES (1,'Texas'),(2,'California'),(3,'Texas'),(4,'New York'),(5,'California'),(6,'California'),(7,'Texas'),(8,'Texas'),(9,'New York'),(10,'New York'); | SELECT state, COUNT(*) as fan_count FROM fans GROUP BY state; |
Show the number of unique athletes who have participated in each sport. | CREATE TABLE Sports (sport_id INT,sport_name VARCHAR(50)); CREATE TABLE Athlete_Events (athlete_id INT,sport_id INT,event_id INT,year INT,participation_type VARCHAR(50)); | SELECT sport_name, COUNT(DISTINCT athlete_id) as unique_athletes FROM Athlete_Events GROUP BY sport_name; |
List all users who have accessed both systems S007 and S008. | CREATE TABLE user_access (id INT,user_id VARCHAR(10),system_accessed VARCHAR(5)); INSERT INTO user_access (id,user_id,system_accessed) VALUES (1,'u101','S007'),(2,'u102','S008'),(3,'u101','S008'),(4,'u103','S007'),(5,'u103','S008'); | SELECT user_id FROM user_access WHERE system_accessed = 'S007' INTERSECT SELECT user_id FROM user_access WHERE system_accessed = 'S008'; |
What is the number of multimodal trips in Tokyo involving public transportation and bikes? | CREATE TABLE multimodal_trips (trip_id INT,leg_start_time TIMESTAMP,leg_end_time TIMESTAMP,leg_distance FLOAT,mode VARCHAR(50),city VARCHAR(50)); | SELECT COUNT(*) as num_trips FROM multimodal_trips WHERE city = 'Tokyo' AND (mode = 'public transportation' OR mode = 'bike'); |
What is the total sales revenue for each category of garments in the South America region in Q1 2022? | CREATE TABLE sales_category (sale_id INT,garment_category VARCHAR(50),sale_date DATE,total_sales DECIMAL(10,2),region VARCHAR(50)); | SELECT garment_category, SUM(total_sales) FROM sales_category WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND region = 'South America' GROUP BY garment_category; |
What is the percentage of unions with collective bargaining agreements in the Midwest region? | CREATE TABLE collective_bargaining (bargaining_id INT,union_name VARCHAR(50),contract_start_date DATE,contract_end_date DATE,region VARCHAR(50));CREATE VIEW union_region AS SELECT DISTINCT union_name,region FROM collective_bargaining; | SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM union_region) as percentage FROM union_region ur WHERE ur.region = 'Midwest' AND EXISTS (SELECT 1 FROM collective_bargaining cb WHERE cb.union_name = ur.union_name); |
What is the minimum safety rating of SUVs in the United Kingdom? | CREATE TABLE SafetyTesting (Id INT,VehicleType VARCHAR(50),Country VARCHAR(50),Rating INT); INSERT INTO SafetyTesting (Id,VehicleType,Country,Rating) VALUES (1,'SUV','United Kingdom',4),(2,'Sedan','United Kingdom',5); | SELECT MIN(Rating) FROM SafetyTesting WHERE VehicleType = 'SUV' AND Country = 'United Kingdom'; |
Which autonomous vehicles have driven more than 1000 miles in a single test? | CREATE TABLE Autonomous_Testing (id INT PRIMARY KEY,vehicle_id INT,test_type VARCHAR(50),date DATE,miles_driven INT); CREATE TABLE Vehicles (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),year INT,type VARCHAR(50)); | SELECT v.make, v.model, at.miles_driven FROM Vehicles v INNER JOIN Autonomous_Testing at ON v.id = at.vehicle_id WHERE at.miles_driven > 1000; |
How many water treatment plants in the 'Urban' region have a total water treatment capacity of over 50,000 cubic meters? | CREATE TABLE WaterTreatmentPlants (id INT,plant_name VARCHAR(50),region VARCHAR(50),total_capacity INT); INSERT INTO WaterTreatmentPlants (id,plant_name,region,total_capacity) VALUES (1,'Plant A','Urban',60000),(2,'Plant B','Rural',35000),(3,'Plant C','Urban',45000); | SELECT COUNT(*) FROM WaterTreatmentPlants WHERE region = 'Urban' AND total_capacity > 50000; |
What is the average heart rate of users aged 25-30, during their spin class sessions? | CREATE TABLE users (id INT,age INT,gender VARCHAR(10)); INSERT INTO users (id,age,gender) VALUES (1,27,'Female'),(2,31,'Male'); CREATE TABLE spin_classes (id INT,user_id INT,heart_rate INT); INSERT INTO spin_classes (id,user_id,heart_rate) VALUES (1,1,150),(2,1,160),(3,2,145),(4,2,135); | SELECT AVG(heart_rate) FROM spin_classes INNER JOIN users ON spin_classes.user_id = users.id WHERE users.age BETWEEN 25 AND 30; |
Which 'Strength' workouts were done by members aged 30 or older? | CREATE TABLE Workouts (WorkoutID INT,WorkoutName VARCHAR(20),Category VARCHAR(10)); INSERT INTO Workouts (WorkoutID,WorkoutName,Category) VALUES (1,'Treadmill','Cardio'),(2,'Yoga','Strength'),(3,'Cycling','Cardio'),(4,'Push-ups','Strength'),(5,'Squats','Strength'); CREATE TABLE Members (MemberID INT,Age INT,MembershipType VARCHAR(10)); INSERT INTO Members (MemberID,Age,MembershipType) VALUES (1,35,'Premium'),(2,28,'Basic'),(3,45,'Premium'),(4,22,'Basic'),(5,55,'Premium'); | SELECT Workouts.WorkoutName FROM Workouts INNER JOIN Members ON TRUE WHERE Workouts.Category = 'Strength' AND Members.Age >= 30; |
List the top 5 models with the highest explainability scores and their development team names. | CREATE TABLE ModelExplainabilityScores (ModelID INT,ExplainabilityScore INT,TeamID INT); CREATE TABLE TeamNames (TeamID INT,TeamName VARCHAR(50)); | SELECT ModelExplainabilityScores.ModelID, MAX(ModelExplainabilityScores.ExplainabilityScore) AS MaxExplainabilityScore, TeamNames.TeamName FROM ModelExplainabilityScores INNER JOIN TeamNames ON ModelExplainabilityScores.TeamID = TeamNames.TeamID GROUP BY ModelExplainabilityScores.TeamID ORDER BY MaxExplainabilityScore DESC, TeamNames.TeamName DESC LIMIT 5; |
What are the AI safety principles and their corresponding descriptions? | CREATE TABLE ai_safety_principles (principle_id INTEGER,principle_name TEXT,principle_description TEXT); | SELECT principle_name, principle_description FROM ai_safety_principles; |
What is the total number of AI models developed in North America with an explainability score below 70? | CREATE TABLE na_models (model_name TEXT,region TEXT,explainability_score INTEGER); INSERT INTO na_models (model_name,region,explainability_score) VALUES ('Model1','North America',75),('Model2','North America',65),('Model3','North America',80); | SELECT SUM(incident_count) FROM na_models WHERE region = 'North America' AND explainability_score < 70; |
What is the average annual income for farmers in the 'rural_development' database? | CREATE TABLE farmers (id INT,name TEXT,annual_income FLOAT,location TEXT); INSERT INTO farmers (id,name,annual_income,location) VALUES (1,'John Doe',35000,'Rural Area A'); INSERT INTO farmers (id,name,annual_income,location) VALUES (2,'Jane Smith',40000,'Rural Area B'); | SELECT AVG(annual_income) FROM farmers; |
What is the average age of engines still in service for each engine type? | CREATE TABLE Engine (id INT,aircraft_id INT,engine_type VARCHAR(255),hours_since_last_service INT,manufacture_year INT); INSERT INTO Engine (id,aircraft_id,engine_type,hours_since_last_service,manufacture_year) VALUES (1,1,'GE90-115B',500,2000); INSERT INTO Engine (id,aircraft_id,engine_type,hours_since_last_service,manufacture_year) VALUES (2,2,'CFM56-5B',1000,1995); INSERT INTO Engine (id,aircraft_id,engine_type,hours_since_last_service,manufacture_year) VALUES (3,1,'GE90-115B',700,2002); | SELECT engine_type, AVG(YEAR(CURRENT_DATE) - manufacture_year) as avg_age FROM Engine GROUP BY engine_type; |
What is the total number of satellites deployed by SpaceComm in the Middle East? | CREATE TABLE SatelliteDeployment (satellite_id INT,company VARCHAR(255),region VARCHAR(255)); | SELECT COUNT(*) FROM SatelliteDeployment WHERE company = 'SpaceComm' AND region = 'Middle East'; |
Calculate the average weight of adult seals in the 'Antarctic Ocean' sanctuary. | CREATE TABLE seals (seal_id INT,seal_name VARCHAR(50),age INT,weight FLOAT,sanctuary VARCHAR(50)); INSERT INTO seals (seal_id,seal_name,age,weight,sanctuary) VALUES (1,'Seal_1',12,200,'Antarctic Ocean'); INSERT INTO seals (seal_id,seal_name,age,weight,sanctuary) VALUES (2,'Seal_2',8,180,'Antarctic Ocean'); | SELECT AVG(weight) FROM seals WHERE sanctuary = 'Antarctic Ocean' AND age >= 18; |
How many animals of each species are currently in rehabilitation centers? | CREATE TABLE RehabilitationCenters (id INT,animal_id INT,species VARCHAR(255),condition VARCHAR(255)); INSERT INTO RehabilitationCenters (id,animal_id,species,condition) VALUES (1,1,'Lion','Critical'),(2,2,'Elephant','Stable'),(3,3,'Tiger','Critical'); | SELECT species, COUNT(*) FROM RehabilitationCenters WHERE condition = 'Stable' GROUP BY species; |
What is the average water temperature for each species in the 'fish_tanks' table? | CREATE TABLE fish_tanks (tank_id INT,species VARCHAR(255),water_temperature DECIMAL(5,2)); INSERT INTO fish_tanks (tank_id,species,water_temperature) VALUES (1,'Tilapia',26.5),(2,'Salmon',12.0),(3,'Tilapia',27.3),(4,'Catfish',24.6),(5,'Salmon',12.5); | SELECT species, AVG(water_temperature) as avg_temp FROM fish_tanks GROUP BY species; |
What is the minimum water temperature in saltwater aquaculture facilities in the Mediterranean region? | CREATE TABLE saltwater_aquaculture (id INT,name TEXT,location TEXT,water_temperature FLOAT); INSERT INTO saltwater_aquaculture (id,name,location,water_temperature) VALUES (1,'Facility A','Mediterranean',21.5),(2,'Facility B','Mediterranean',22.2),(3,'Facility C','Indian Ocean',28.0); | SELECT MIN(water_temperature) FROM saltwater_aquaculture WHERE location = 'Mediterranean'; |
What is the total revenue generated from the 'Art Classes'? | CREATE TABLE sales (id INT,class_id INT,amount DECIMAL(10,2)); CREATE TABLE classes (id INT,name VARCHAR(255)); INSERT INTO sales (id,class_id,amount) VALUES (1,1,100); INSERT INTO sales (id,class_id,amount) VALUES (2,1,200); INSERT INTO classes (id,name) VALUES (1,'Art Classes'); | SELECT SUM(amount) FROM sales s JOIN classes c ON s.class_id = c.id WHERE c.name = 'Art Classes'; |
List the names and release dates of all movies that were released in the same month as a Marvel movie. | CREATE TABLE movies (id INT,movie_name VARCHAR(50),genre VARCHAR(20),release_date DATE); | SELECT m1.movie_name, m1.release_date FROM movies m1 INNER JOIN movies m2 ON MONTH(m1.release_date) = MONTH(m2.release_date) AND YEAR(m1.release_date) = YEAR(m2.release_date) WHERE m2.genre = 'Marvel'; |
What is the total amount of chemical waste produced by each plant in January 2020? | CREATE TABLE Plant (id INT,name VARCHAR(255)); INSERT INTO Plant (id,name) VALUES (1,'Plant A'),(2,'Plant B'); CREATE TABLE Waste (plant_id INT,date DATE,amount INT); INSERT INTO Waste (plant_id,date,amount) VALUES (1,'2020-01-01',100),(1,'2020-01-02',120),(2,'2020-01-01',150),(2,'2020-01-02',140); | SELECT p.name, SUM(w.amount) as total_waste FROM Waste w JOIN Plant p ON w.plant_id = p.id WHERE w.date BETWEEN '2020-01-01' AND '2020-01-31' GROUP BY p.name; |
Which climate finance initiatives were inserted into the 'climate_finance' table in 2019? | CREATE TABLE climate_finance (initiative_name TEXT,year INTEGER,amount FLOAT); INSERT INTO climate_finance (initiative_name,year,amount) VALUES ('Green Grants',2019,50000.0),('Climate Innovation Fund',2020,100000.0),('Renewable Energy Loans',2018,75000.0); | SELECT initiative_name FROM climate_finance WHERE year = 2019; |
What is the most common type of medical equipment across hospitals? | CREATE TABLE medical_equipment (id INT,hospital_name TEXT,location TEXT,equipment TEXT,quantity INT,last_updated_date DATE); INSERT INTO medical_equipment (id,hospital_name,location,equipment,quantity,last_updated_date) VALUES (1,'NY Presbyterian','NYC','Ventilators',80,'2021-03-31'); INSERT INTO medical_equipment (id,hospital_name,location,equipment,quantity,last_updated_date) VALUES (2,'Stanford Hospital','Palo Alto','Ventilators',90,'2021-03-31'); | SELECT equipment, MAX(quantity) as max_quantity FROM medical_equipment GROUP BY equipment ORDER BY max_quantity DESC LIMIT 1; |
What is the minimum and maximum funding amount for companies founded by people from underrepresented communities? | CREATE TABLE companies (id INT,name TEXT,founding_date DATE,founder_community TEXT); INSERT INTO companies (id,name,founding_date,founder_community) VALUES (1,'CleanTech','2011-02-14','Underrepresented'); INSERT INTO companies (id,name,founding_date,founder_community) VALUES (2,'CodeUp','2016-08-07','Not Underrepresented'); CREATE TABLE funds (company_id INT,funding_amount INT); INSERT INTO funds (company_id,funding_amount) VALUES (1,300000); INSERT INTO funds (company_id,funding_amount) VALUES (2,800000); | SELECT MIN(funds.funding_amount), MAX(funds.funding_amount) FROM companies JOIN funds ON companies.id = funds.company_id WHERE companies.founder_community = 'Underrepresented'; |
What are the names of startups that have been acquired and have a female founder? | CREATE TABLE acquisition (id INT,startup_name TEXT,acquired_by TEXT,female_founder BOOLEAN); INSERT INTO acquisition (id,startup_name,acquired_by,female_founder) VALUES (1,'Acme Inc.','Google',true),(2,'Beta Corp.','Microsoft',false),(3,'Charlie Ltd.','Facebook',true); | SELECT startup_name FROM acquisition WHERE female_founder = true; |
How would you insert a new record for a 'Green Thumbs' community garden in the 'Bronx', with an initial water usage of 100 cubic meters? | CREATE TABLE community_gardens (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),water_usage DECIMAL(10,2)); | INSERT INTO community_gardens (id, name, location, water_usage) VALUES (2, 'Green Thumbs', 'Bronx, NY, USA', 100.00); |
What is the average area (in hectares) of agroecological projects in 'Asia'? | CREATE TABLE agroecological_projects (id INT,name TEXT,location TEXT,area_ha FLOAT); INSERT INTO agroecological_projects (id,name,location,area_ha) VALUES (1,'Project A','Asia',1.5),(2,'Project B','Asia',2.2),(3,'Project C','Africa',3); | SELECT AVG(area_ha) FROM agroecological_projects WHERE location = 'Asia'; |
What is the yield of the top 5 crops in 2021? | CREATE TABLE CropYield (id INT,crop TEXT,year INT,yield REAL); | SELECT crop, yield FROM (SELECT crop, yield, ROW_NUMBER() OVER (PARTITION BY crop ORDER BY yield DESC) as rn FROM CropYield WHERE year = 2021) sub WHERE rn <= 5; |
Which regions have the most successful food justice initiatives? | CREATE TABLE initiatives (region VARCHAR(255),success_score INT); INSERT INTO initiatives (region,success_score) VALUES ('Region4',82),('Region5',91),('Region6',78); CREATE VIEW food_justice_initiatives AS SELECT * FROM initiatives WHERE success_score > 75; | SELECT region FROM food_justice_initiatives |
How many 'DigitalAccessibilityEvents' were held in the 'Fall' semester in the 'DigitalAccessibilityEvents' table? | CREATE TABLE DigitalAccessibilityEvents (event_id INT,event_name VARCHAR(255),event_date DATE); INSERT INTO DigitalAccessibilityEvents (event_id,event_name,event_date) VALUES (1001,'WebAccessibilityWorkshop','2022-09-15'),(1002,'AccessibleDocumentTraining','2022-12-01'),(1003,'ScreenReaderBasics','2022-10-10'); | SELECT COUNT(*) FROM DigitalAccessibilityEvents WHERE MONTH(event_date) BETWEEN 9 AND 12; |
How many students with physical disabilities have not received any accommodations in the last year? | CREATE TABLE Accommodations (id INT,student VARCHAR(255),date DATE); CREATE TABLE Students (id INT,name VARCHAR(255),age INT,disability VARCHAR(255)); | SELECT COUNT(*) FROM Students LEFT JOIN Accommodations ON Students.id = Accommodations.student WHERE disability = 'physical disability' AND date IS NULL; |
What is the total number of disability accommodations requested and approved by month? | CREATE TABLE Accommodation_Requests (Request_ID INT,Request_Date DATE,Accommodation_Type VARCHAR(50),Request_Status VARCHAR(10)); | SELECT DATE_PART('month', Request_Date) as Month, COUNT(*) as Total_Requests FROM Accommodation_Requests WHERE Request_Status = 'Approved' GROUP BY Month ORDER BY Month; |
Find the number of marine species and total population in the Indian Ocean. | CREATE TABLE marine_species (id INT,name VARCHAR(50),region VARCHAR(50),population INT); INSERT INTO marine_species (id,name,region,population) VALUES (1,'Whale Shark','Indian Ocean',10000); CREATE TABLE regions (id INT,name VARCHAR(50)); | SELECT regions.name, COUNT(marine_species.name), SUM(marine_species.population) FROM marine_species INNER JOIN regions ON marine_species.region = regions.name WHERE regions.name = 'Indian Ocean'; |
Which decentralized applications had a cumulative transaction volume greater than $10 million in the first half of 2021 in the XYZ blockchain? | CREATE TABLE XYZ_transaction (transaction_hash VARCHAR(255),block_number INT,transaction_index INT,from_address VARCHAR(255),to_address VARCHAR(255),value DECIMAL(18,2),timestamp TIMESTAMP,miner VARCHAR(255)); CREATE TABLE XYZ_contract (contract_address VARCHAR(255),contract_name VARCHAR(255),creator_address VARCHAR(255),creation_timestamp TIMESTAMP); | SELECT contract_name, SUM(value) AS cumulative_volume FROM XYZ_transaction t JOIN XYZ_contract c ON t.to_address = c.contract_address WHERE timestamp BETWEEN '2021-01-01 00:00:00' AND '2021-06-30 23:59:59' GROUP BY contract_name HAVING SUM(value) > 10000000; |
Display the total timber volume and revenue generated from timber sales for each company in the last 3 years, grouped by company, and sorted by the total timber volume in descending order. | CREATE TABLE company (company_id INT,company_name TEXT,PRIMARY KEY (company_id)); CREATE TABLE sale (sale_id INT,company_id INT,year INT,revenue INT,timber_volume INT,PRIMARY KEY (sale_id),FOREIGN KEY (company_id) REFERENCES company(company_id)); | SELECT c.company_name, SUM(s.revenue) AS total_revenue, SUM(s.timber_volume) AS total_timber_volume FROM company c INNER JOIN sale s ON c.company_id = s.company_id WHERE s.year BETWEEN (SELECT MAX(year) - 2 FROM sale) AND (SELECT MAX(year) FROM sale) GROUP BY c.company_name ORDER BY total_timber_volume DESC; |
Get the cruelty-free certification status for a list of products. | CREATE TABLE Product (ProductID INT,ProductName VARCHAR(50)); INSERT INTO Product (ProductID,ProductName) VALUES (101,'Lipstick'),(102,'Eyeshadow'),(103,'Blush'),(104,'Foundation'),(105,'Mascara'); CREATE TABLE CrueltyFreeCertification (ProductID INT,CertificationDate DATE,Certified BOOLEAN); INSERT INTO CrueltyFreeCertification (ProductID,CertificationDate,Certified) VALUES (101,'2021-08-01',TRUE),(102,'2021-07-15',FALSE),(104,'2021-06-30',TRUE),(105,'2021-05-10',TRUE); | SELECT p.ProductID, p.ProductName, cfc.Certified FROM Product p LEFT JOIN CrueltyFreeCertification cfc ON p.ProductID = cfc.ProductID; |
What is the quarterly sales trend of natural cosmetics in France and Germany? | CREATE TABLE sales (product_id INT,sale_date DATE,region VARCHAR(50),sales INT); INSERT INTO sales (product_id,sale_date,region,sales) VALUES (1,'2021-01-01','France',500),(2,'2021-01-01','Germany',800); | SELECT region, EXTRACT(QUARTER FROM sale_date) AS quarter, SUM(sales) AS quarterly_sales FROM sales WHERE product_category = 'Natural' AND region IN ('France', 'Germany') GROUP BY region, quarter ORDER BY quarter; |
What is the total revenue of Korean skincare products in Q2 2022? | CREATE TABLE Cosmetics_Sales (SaleID int,ProductName varchar(100),SaleDate date,QuantitySold int,Price decimal(5,2),Country varchar(50)); INSERT INTO Cosmetics_Sales (SaleID,ProductName,SaleDate,QuantitySold,Price,Country) VALUES (3,'Korean BB Cream','2022-04-15',150,19.99,'South Korea'); INSERT INTO Cosmetics_Sales (SaleID,ProductName,SaleDate,QuantitySold,Price,Country) VALUES (4,'Korean Face Mask','2022-05-20',200,12.99,'South Korea'); | SELECT SUM(QuantitySold * Price) FROM Cosmetics_Sales WHERE Country = 'South Korea' AND SaleDate >= '2022-04-01' AND SaleDate <= '2022-06-30'; |
How many artists are from each country? | CREATE TABLE artists (id INT,name VARCHAR(50),country VARCHAR(20)); INSERT INTO artists (id,name,country) VALUES (1,'Artist 1','USA'),(2,'Artist 2','Canada'),(3,'Artist 3','Mexico'),(4,'Artist 4','USA'),(5,'Artist 5','Canada'); | SELECT country, COUNT(*) FROM artists GROUP BY country; |
Which artists have performed at Jazzville during 2020? | CREATE TABLE Artists (ArtistID int,ArtistName varchar(100)); INSERT INTO Artists (ArtistID,ArtistName) VALUES (1,'John Coltrane'),(2,'Miles Davis'); CREATE TABLE Venues (VenueID int,VenueName varchar(100)); INSERT INTO Venues (VenueID,VenueName) VALUES (1,'Jazzville'); CREATE TABLE Performances (PerformanceID int,ArtistID int,VenueID int,PerformanceDate date); INSERT INTO Performances (PerformanceID,ArtistID,VenueID,PerformanceDate) VALUES (1,1,1,'2020-01-01'),(2,2,1,'2019-12-31'); | SELECT Artists.ArtistName FROM Artists INNER JOIN Performances ON Artists.ArtistID = Performances.ArtistID INNER JOIN Venues ON Performances.VenueID = Venues.VenueID WHERE Venues.VenueName = 'Jazzville' AND YEAR(PerformanceDate) = 2020; |
What is the maximum budget spent on peacekeeping operations by each department? | CREATE TABLE DepartmentPeacekeeping (id INT,department VARCHAR(50),budget INT); | SELECT department, MAX(budget) FROM DepartmentPeacekeeping GROUP BY department; |
Add a new circular economy record with ID 4, name 'Circular Economy D', type 'Recycling' | CREATE SCHEMA manufacturing;CREATE TABLE circular_economy (id INT PRIMARY KEY,name TEXT,type TEXT);INSERT INTO circular_economy (id,name,type) VALUES (1,'Circular Economy A','Reuse'); INSERT INTO circular_economy (id,name,type) VALUES (2,'Circular Economy B','Reduce'); INSERT INTO circular_economy (id,name,type) VALUES (3,'Circular Economy C','Repurpose'); | INSERT INTO circular_economy (id, name, type) VALUES (4, 'Circular Economy D', 'Recycling'); |
What is the number of days where waste production was over 500? | CREATE TABLE waste (factory VARCHAR(50),date DATE,waste_amount INT); INSERT INTO waste (factory,date,waste_amount) VALUES ('factory1','2021-01-01',500),('factory1','2021-01-02',600); | SELECT COUNT(*) FROM waste WHERE waste_amount > 500; |
What is the most common diagnosis in 'RuralHealthFacility3'? | CREATE TABLE RuralHealthFacility3 (id INT,name TEXT,diagnosis TEXT); INSERT INTO RuralHealthFacility3 (id,name,diagnosis) VALUES (1,'Alice Johnson','Diabetes'),(2,'Bob Brown','Asthma'),(3,'Charlie Green','Diabetes'); | SELECT diagnosis, COUNT(*) AS count FROM RuralHealthFacility3 GROUP BY diagnosis ORDER BY count DESC LIMIT 1; |
Update the investment amount to 25000 for the 'clean_water_access' investment with id 2. | CREATE TABLE water_investments (id INT,investment_type VARCHAR(20),investment_amount FLOAT); INSERT INTO water_investments (id,investment_type,investment_amount) VALUES (1,'clean_water_access',30000),(2,'clean_water_access',20000),(3,'clean_water_access',28000); | UPDATE water_investments SET investment_amount = 25000 WHERE id = 2 AND investment_type = 'clean_water_access'; |
Delete volunteers who haven't donated in the last 6 months. | CREATE TABLE volunteers (id INT,name VARCHAR(255),last_donation_date DATE); INSERT INTO volunteers (id,name,last_donation_date) VALUES (1,'Alice','2021-01-01'),(2,'Bob','2021-06-01'),(3,'Charlie',NULL); | DELETE FROM volunteers WHERE last_donation_date IS NULL OR last_donation_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
What is the least common type of open pedagogy resource used by students in the "Brookside" school district? | CREATE TABLE resources (resource_id INT,district VARCHAR(20),type VARCHAR(20)); INSERT INTO resources (resource_id,district,type) VALUES (1,'Brookside','Video'),(2,'Brookside','Article'),(3,'Brookside','Video'),(4,'Lakeside','Podcast'),(5,'Brookside','Podcast'); | SELECT type, COUNT(*) FROM resources WHERE district = 'Brookside' GROUP BY type ORDER BY COUNT(*) ASC LIMIT 1; |
What is the total number of professional development programs completed by teachers in the 'Education' database? | CREATE TABLE teacher_development (teacher_id INT,program_completed INT); INSERT INTO teacher_development (teacher_id,program_completed) VALUES (101,3),(102,1),(103,2),(104,0),(105,1); | SELECT SUM(program_completed) FROM teacher_development; |
List all carbon pricing policies in the 'carbon_pricing' schema? | CREATE SCHEMA carbon_pricing;CREATE TABLE carbon_policies (policy_name VARCHAR(50),policy_type VARCHAR(50));INSERT INTO carbon_pricing.carbon_policies (policy_name,policy_type) VALUES ('ETS','Cap-and-Trade'),('CarbonTax','Tax'); | SELECT policy_name, policy_type FROM carbon_pricing.carbon_policies; |
What is the total installed capacity of wind energy generators in the 'renewables' schema, grouped by manufacturer and ordered by capacity in descending order, with a minimum capacity of 50 MW? | CREATE SCHEMA renewables; CREATE TABLE wind_energy (id INT,manufacturer VARCHAR(50),capacity FLOAT); INSERT INTO wind_energy (id,manufacturer,capacity) VALUES (1,'Vestas',75.5),(2,'Siemens Gamesa',80.2),(3,'GE Renewable Energy',65.8),(4,'Goldwind',52.1),(5,'Enercon',70.6); | SELECT manufacturer, SUM(capacity) as total_capacity FROM renewables.wind_energy GROUP BY manufacturer HAVING total_capacity >= 50 ORDER BY total_capacity DESC; |
How many wells are in the 'Well_Status' table with a status of 'Active'? | CREATE TABLE Well_Status (Well_ID VARCHAR(10),Status VARCHAR(10)); INSERT INTO Well_Status (Well_ID,Status) VALUES ('W001','Active'),('W002','Inactive'); | SELECT COUNT(*) FROM Well_Status WHERE Status = 'Active'; |
List all unique fields from the 'geology' and 'infrastructure' tables. | CREATE TABLE geology (well_id INT,rock_type VARCHAR(50)); CREATE TABLE infrastructure (well_id INT,platform_type VARCHAR(50)); | SELECT field FROM (SELECT 'geology' as table_name, column_name as field FROM information_schema.columns WHERE table_name = 'geology' UNION ALL SELECT 'infrastructure' as table_name, column_name as field FROM information_schema.columns WHERE table_name = 'infrastructure') as subquery; |
What is the average age of children in the refugee_support program who have been relocated to France? | CREATE TABLE refugee_support (child_id INT,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); INSERT INTO refugee_support (child_id,name,age,gender,country) VALUES (1,'John Doe',12,'Male','Syria'),(2,'Jane Doe',15,'Female','Afghanistan'); | SELECT AVG(age) FROM refugee_support WHERE country = 'France'; |
How many digital divide initiatives were completed in the last 3 years in Asia? | CREATE TABLE Digital_Divide_Initiatives_Year (Year INT,Initiatives INT); | SELECT SUM(Initiatives) FROM Digital_Divide_Initiatives_Year WHERE Year BETWEEN 2019 AND 2021; |
What is the minimum fare for a route in the 'north' region with wheelchair accessibility? | CREATE TABLE Routes (id INT,region VARCHAR(10),wheelchair_accessible BOOLEAN,fare DECIMAL(5,2)); INSERT INTO Routes (id,region,wheelchair_accessible,fare) VALUES (1,'north',true,10.00),(2,'north',true,15.00),(3,'south',true,7.00); | SELECT MIN(Routes.fare) FROM Routes WHERE Routes.region = 'north' AND Routes.wheelchair_accessible = true; |
What was the total revenue for each vehicle type in January 2021? | CREATE TABLE vehicle_maintenance (id INT,vehicle_type VARCHAR(20),maintenance_date DATE,cost FLOAT); INSERT INTO vehicle_maintenance (id,vehicle_type,maintenance_date,cost) VALUES (1,'Bus','2021-01-05',500),(2,'Tram','2021-01-07',800),(3,'Train','2021-01-09',1200); | SELECT vehicle_type, SUM(cost) as total_revenue FROM vehicle_maintenance WHERE maintenance_date BETWEEN '2021-01-01' AND '2021-01-31' GROUP BY vehicle_type; |
Which sustainable material has the highest average order quantity? | CREATE TABLE materials (id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO materials (id,name,type) VALUES (1,'cotton','sustainable'),(2,'polyester','unsustainable'); CREATE TABLE order_items (id INT,material_id INT,order_quantity INT); INSERT INTO order_items (id,material_id,order_quantity) VALUES (1,1,100),(2,2,150); | SELECT AVG(order_quantity) FROM order_items INNER JOIN materials ON order_items.material_id = materials.id WHERE materials.type = 'sustainable' GROUP BY materials.name ORDER BY AVG(order_quantity) DESC LIMIT 1; |
Create a new table 'sustainability_metrics' to store the percentage of eco-friendly materials and water usage for each country | CREATE TABLE materials (material_id INT PRIMARY KEY,eco_friendly BOOLEAN,country VARCHAR(100),water_usage INT); | CREATE TABLE sustainability_metrics (country VARCHAR(100) PRIMARY KEY, eco_friendly_percentage DECIMAL(5, 2), water_usage_avg INT); |
What was the average financial wellbeing score for customers of InclusiveFinance in Q3 2021? | CREATE TABLE InclusiveFinance (id INT,customer_id INT,score INT,score_date DATE); INSERT INTO InclusiveFinance (id,customer_id,score,score_date) VALUES (1,3001,80,'2021-07-01'); | SELECT AVG(score) FROM InclusiveFinance WHERE QUARTER(score_date) = 3 AND YEAR(score_date) = 2021; |
How many volunteers signed up in each region in 2021? | CREATE TABLE volunteers (id INT,name TEXT,region TEXT,signup_date DATE); INSERT INTO volunteers (id,name,region,signup_date) VALUES (1,'Alice','North','2021-02-03'),(2,'Bob','South','2021-05-05'),(3,'Charlie','East','2020-12-12'); | SELECT region, COUNT(*) FROM volunteers WHERE YEAR(signup_date) = 2021 GROUP BY region; |
What is the success rate of CRISPR gene editing for gene 'XYZ'? | CREATE TABLE crispr (experiment_id INT,gene_name VARCHAR(10),success_rate FLOAT); INSERT INTO crispr (experiment_id,gene_name,success_rate) VALUES (1,'XYZ',0.85),(2,'XYZ',0.92),(3,'XYZ',0.78); | SELECT AVG(success_rate) FROM crispr WHERE gene_name = 'XYZ' |
Insert a new student into the graduate_students table | CREATE TABLE graduate_students (id INT,name TEXT,department TEXT); INSERT INTO graduate_students (id,name,department) VALUES (1,'Alice','CS'),(2,'Bob','Physics'); | INSERT INTO graduate_students (id, name, department) VALUES (3, 'Charlie', 'Math'); |
How many mental health parity complaints were filed by race in the last 6 months? | CREATE TABLE mental_health_parity_complaints (complaint_id INT,complaint_date DATE,race VARCHAR(20)); INSERT INTO mental_health_parity_complaints (complaint_id,complaint_date,race) VALUES (1,'2021-07-01','Asian'),(2,'2021-03-15','Black'),(3,'2021-01-01','Hispanic'); | SELECT race, COUNT(*) as num_complaints FROM mental_health_parity_complaints WHERE complaint_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY race; |
What is the average number of virtual tours taken per user in Europe? | CREATE TABLE user_activity(activity_id INT,user_id INT,site_name TEXT,region TEXT,num_tours INT); | SELECT region, AVG(num_tours) FROM (SELECT user_id, region, AVG(num_tours) AS num_tours FROM user_activity WHERE region = 'Europe' GROUP BY user_id, region) subquery GROUP BY region; |
What is the total number of sustainable tourism certifications issued in Brazil? | CREATE TABLE TourismCertifications (certification_id INT,certification_name TEXT,country TEXT,sustainability_focus TEXT); INSERT INTO TourismCertifications (certification_id,certification_name,country,sustainability_focus) VALUES (1,'Brazil Eco-Travel','Brazil','Sustainable Tourism'); INSERT INTO TourismCertifications (certification_id,certification_name,country,sustainability_focus) VALUES (2,'Green Tourism Brazil','Brazil','Sustainable Tourism'); | SELECT COUNT(*) FROM TourismCertifications WHERE country = 'Brazil' AND sustainability_focus = 'Sustainable Tourism'; |
What is the average rating of hotels that have a spa and a gym? | CREATE TABLE hotel_ratings (id INT,hotel_id INT,rating INT); INSERT INTO hotel_ratings (id,hotel_id,rating) VALUES (1,101,4); INSERT INTO hotel_amenities (id,hotel_id,amenity) VALUES (1,101,'Spa'),(2,101,'Gym'); | SELECT AVG(hr.rating) as avg_rating FROM hotel_ratings hr INNER JOIN hotel_amenities ha ON hr.hotel_id = ha.hotel_id WHERE ha.amenity IN ('Spa', 'Gym') GROUP BY hr.hotel_id; |
What is the number of language preservation programs in African countries? | CREATE TABLE LanguagePreservationPrograms (country VARCHAR(50),programs INT); INSERT INTO LanguagePreservationPrograms (country,programs) VALUES ('Nigeria',20),('Kenya',30),('Egypt',25),('SouthAfrica',35),('Ethiopia',22); | SELECT COUNT(programs) FROM LanguagePreservationPrograms WHERE country IN ('Nigeria', 'Kenya', 'Egypt', 'SouthAfrica', 'Ethiopia') AND region = 'Africa'; |
What are the names and maintenance frequencies (in years) for each dam in the 'dams' and 'dam_maintenance_frequencies' tables? | CREATE TABLE dams (id INT,name VARCHAR(255),location VARCHAR(255)); CREATE TABLE dam_maintenance_frequencies (dam_id INT,frequency INT); | SELECT d.name, dmf.frequency as maintenance_frequency FROM dams d INNER JOIN dam_maintenance_frequencies dmf ON d.id = dmf.dam_id; |
What is the average construction cost for bridges in California? | CREATE TABLE Bridge (id INT,name TEXT,location TEXT,cost FLOAT,build_date DATE); INSERT INTO Bridge (id,name,location,cost,build_date) VALUES (1,'Golden Gate Bridge','San Francisco,CA',1500000000,'1937-05-27'); | SELECT AVG(cost) FROM Bridge WHERE location LIKE '%CA%' AND type = 'Bridge'; |
What is the minimum 'resilience_score' of bridges in the 'South America' region that were built before 1990? | CREATE TABLE bridges (id INT,name TEXT,region TEXT,resilience_score FLOAT,year_built INT); INSERT INTO bridges (id,name,region,resilience_score,year_built) VALUES (1,'Golden Gate Bridge','West Coast',85.2,1937),(2,'Brooklyn Bridge','East Coast',76.3,1883),(3,'Bay Bridge','West Coast',90.1,1936),(4,'Chenab Bridge','South Asia',89.6,2010),(5,'Maputo Bay Bridge','Africa',72.8,1982),(6,'Sydney Harbour Bridge','Oceania',87.3,1932),(7,'Millau Viaduct','Europe',95.1,2004),(8,'Gran Puente Centenario','South America',83.5,1976); | SELECT MIN(resilience_score) FROM bridges WHERE region = 'South America' AND year_built < 1990; |
What is the total number of bridges and tunnels in the Southeast and their respective average maintenance costs? | CREATE TABLE BridgeTunnel (id INT,type VARCHAR(10),region VARCHAR(20),cost FLOAT); INSERT INTO BridgeTunnel (id,type,region,cost) VALUES (1,'Bridge','Southeast',20000.0),(2,'Tunnel','Southeast',50000.0),(3,'Bridge','Southeast',30000.0); | SELECT type, COUNT(*), AVG(cost) as avg_cost FROM BridgeTunnel WHERE region = 'Southeast' GROUP BY type; |
Show the number of cases by justice category and resolution status for 2021 | CREATE TABLE CasesByJusticeCategory (Year INT,Category TEXT,Resolution TEXT,Cases INT); INSERT INTO CasesByJusticeCategory (Year,Category,Resolution,Cases) VALUES (2021,'Civil','Resolved',100),(2021,'Civil','Unresolved',50),(2021,'Criminal','Resolved',200),(2021,'Criminal','Unresolved',100); | SELECT Category, Resolution, SUM(Cases) FROM CasesByJusticeCategory WHERE Year = 2021 GROUP BY Category, Resolution; |
What is the maximum number of court cases resolved through restorative justice in Australia? | CREATE TABLE cases (case_id INT,case_type VARCHAR(20),resolution_date DATE,country VARCHAR(20)); INSERT INTO cases (case_id,case_type,resolution_date,country) VALUES (1,'Restorative Justice','2021-01-01','Australia'); INSERT INTO cases (case_id,case_type,resolution_date,country) VALUES (2,'Traditional','2020-01-01','Australia'); | SELECT case_type, MAX(case_id) FROM cases WHERE country = 'Australia' AND case_type = 'Restorative Justice'; |
Delete the 'OceanFloorMapping' table record for the 'Mariana Trench' | CREATE TABLE OceanFloorMapping (id INT,location VARCHAR(50),depth INT); INSERT INTO OceanFloorMapping (id,location,depth) VALUES (1,'Mariana Trench',10000),(2,'Sunda Trench',8000),(3,'Philippine Trench',6500),(4,'Kermadec Trench',10000),(5,'Tonga Trench',10820); | DELETE FROM OceanFloorMapping WHERE location = 'Mariana Trench'; |
How many times has the most popular burger been sold? | CREATE TABLE menu (menu_id INT,menu_name TEXT,menu_type TEXT,price DECIMAL,daily_sales INT); CREATE TABLE burger_sales (burger_id INT,burger_name TEXT,total_sales INT); | SELECT MAX(total_sales) FROM burger_sales; |
What is the total cost of vegetarian meals served in the month of September 2021? | CREATE TABLE Menu (menu_id INT,menu_name VARCHAR(20),is_vegetarian BOOLEAN); INSERT INTO Menu (menu_id,menu_name,is_vegetarian) VALUES (1,'Breakfast',TRUE),(2,'Lunch',FALSE),(3,'Dinner',FALSE); CREATE TABLE Menu_Orders (order_id INT,menu_id INT,order_date DATE); INSERT INTO Menu_Orders (order_id,menu_id,order_date) VALUES (1,1,'2021-09-01'),(2,2,'2021-09-02'),(3,1,'2021-09-03'),(4,3,'2021-09-04'); CREATE TABLE Inventory (inventory_id INT,menu_id INT,inventory_cost FLOAT); INSERT INTO Inventory (inventory_id,menu_id,inventory_cost) VALUES (1,1,5.0),(2,2,3.5),(3,1,8.0),(4,3,7.0); | SELECT SUM(Inventory.inventory_cost) FROM Inventory INNER JOIN Menu ON Inventory.menu_id = Menu.menu_id INNER JOIN Menu_Orders ON Inventory.menu_id = Menu_Orders.menu_id WHERE Menu.is_vegetarian = TRUE AND MONTH(Menu_Orders.order_date) = 9 AND YEAR(Menu_Orders.order_date) = 2021; |
Which mining sites have experienced a significant increase in water usage over the past year? | CREATE TABLE mining_sites (id INT,name VARCHAR(255),water_usage INT); INSERT INTO mining_sites (id,name,water_usage) VALUES (1,'Site A',1000),(2,'Site B',1200),(3,'Site C',800); CREATE TABLE water_usage_history (site_id INT,date DATE,water_used INT); INSERT INTO water_usage_history (site_id,date,water_used) VALUES (1,'2021-01-01',50),(1,'2021-02-01',60),(2,'2021-01-01',40),(2,'2021-02-01',70),(3,'2021-01-01',80),(3,'2021-02-01',90); | SELECT ms.name, (ms.water_usage - SUM(wuh.water_used)) AS water_usage_diff FROM mining_sites ms JOIN water_usage_history wuh ON ms.id = wuh.site_id WHERE wuh.date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY ms.name HAVING water_usage_diff < 0; |
How many customer complaints were received for mobile and broadband services in each state? | CREATE TABLE complaints (complaint_id INT,service VARCHAR(10),state VARCHAR(25)); INSERT INTO complaints (complaint_id,service,state) VALUES (1,'Mobile','California'),(2,'Broadband','Texas'); | SELECT service, state, COUNT(*) FROM complaints GROUP BY service, state; |
What is the number of concerts with more than 10,000 attendees and featuring artists from underrepresented communities? | CREATE TABLE Concerts (concert_id INT,concert_name TEXT,attendees INT,artist_id INT); INSERT INTO Concerts (concert_id,concert_name,attendees,artist_id) VALUES (1,'Lollapalooza',30000,1),(2,'Bonnaroo',25000,2),(3,'Firefly',15000,3); CREATE TABLE Artists (artist_id INT,artist_name TEXT,underrepresented_community BOOLEAN); INSERT INTO Artists (artist_id,artist_name,underrepresented_community) VALUES (1,'Billie Eilish',TRUE),(2,'Taylor Swift',FALSE),(3,'Bad Bunny',TRUE); | SELECT COUNT(c.concert_id) FROM Concerts c JOIN Artists a ON c.artist_id = a.artist_id WHERE c.attendees > 10000 AND a.underrepresented_community = TRUE; |
What is the total revenue for concerts held in Canada? | CREATE TABLE concerts (id INT PRIMARY KEY,artist_id INT,venue INT,date DATE,revenue DECIMAL(10,2)); INSERT INTO concerts (id,artist_id,venue,date,revenue) VALUES (1,101,201,'2022-06-01',50000.00),(2,102,202,'2022-07-01',75000.00),(3,103,203,'2022-08-01',60000.00); CREATE TABLE venues (id INT PRIMARY KEY,venue_name VARCHAR(255),city VARCHAR(255),country VARCHAR(255),capacity INT); INSERT INTO venues (id,venue_name,city,country,capacity) VALUES (201,'The Forum','Los Angeles','USA',18000),(202,'Scotiabank Arena','Toronto','Canada',19000),(203,'O2 Arena','London','UK',20000); | SELECT SUM(revenue) FROM concerts c INNER JOIN venues v ON c.venue = v.id WHERE v.country = 'Canada'; |
What is the minimum donation amount for each month? | CREATE TABLE donations (id INT,date DATE,amount FLOAT); INSERT INTO donations (id,date,amount) VALUES (1,'2022-01-01',100.00),(2,'2022-02-01',200.00),(3,'2022-01-15',50.00); | SELECT EXTRACT(MONTH FROM date), MIN(amount) FROM donations GROUP BY EXTRACT(MONTH FROM date); |
Delete all the transactions for the 'VIP' type that occurred before 2020-01-01 from the 'transactions' table. | CREATE TABLE transactions (transaction_id INT,player_id INT,transaction_type VARCHAR(10),transaction_date DATE,amount DECIMAL(5,2)); INSERT INTO transactions VALUES (1,100,'VIP','2019-12-31',100); INSERT INTO transactions VALUES (2,101,'VIP','2020-02-01',200); INSERT INTO transactions VALUES (3,102,'VIP','2019-12-30',150); | DELETE FROM transactions WHERE transaction_type = 'VIP' AND transaction_date < '2020-01-01'; |
How many distinct mining locations supplied Dysprosium to the European market in 2018? | CREATE TABLE supply (element VARCHAR(10),year INT,location VARCHAR(10),quantity INT); INSERT INTO supply (element,year,location,quantity) VALUES ('Dysprosium',2018,'Mine A',250),('Dysprosium',2018,'Mine B',300),('Dysprosium',2018,'Mine C',350); | SELECT COUNT(DISTINCT location) FROM supply WHERE element = 'Dysprosium' AND year = 2018; |
Display the names and average co-owner percentages for all properties in the 'property_coownership' table where the co-owner percentage is greater than 60. | CREATE TABLE property_coownership (property_id INT,owner VARCHAR(255),percentage INT); INSERT INTO property_coownership (property_id,owner,percentage) VALUES (1,'Mohammed',70),(1,'Fatima',30),(2,'Jamal',65),(2,'Aisha',35),(3,'Ali',75),(3,'Khadija',25); | SELECT owner, AVG(percentage) FROM property_coownership WHERE percentage > 60 GROUP BY owner; |
How many properties have more than 3 co-owners in the co-ownership program? | CREATE TABLE extended_co_ownership (property_id INT,co_owner_count INT); INSERT INTO extended_co_ownership (property_id,co_owner_count) VALUES (1001,2),(1002,3),(1003,1),(1004,5),(1005,4),(1006,2); | SELECT COUNT(*) FROM extended_co_ownership WHERE co_owner_count > 3; |
How many products were sold by women-owned businesses in Africa in Q3 2021? | CREATE TABLE ProductSales (product_id INT,sale_date DATE,women_owned_business BOOLEAN); | SELECT COUNT(*) FROM ProductSales WHERE sale_date BETWEEN '2021-07-01' AND '2021-09-30' AND women_owned_business = TRUE AND country = 'Africa'; |
List the names and total sales of vendors in the circular supply chain with sales over $10,000. | CREATE TABLE vendors (vendor_id INT,vendor_name TEXT); INSERT INTO vendors (vendor_id,vendor_name) VALUES (1,'Green Vendors'); CREATE TABLE sales (sale_id INT,sale_date DATE,vendor_id INT,amount DECIMAL(5,2)); INSERT INTO sales (sale_id,sale_date,vendor_id,amount) VALUES (1,'2022-01-01',1,12000); | SELECT vendors.vendor_name, SUM(sales.amount) FROM vendors JOIN sales ON vendors.vendor_id = sales.vendor_id GROUP BY vendors.vendor_name HAVING SUM(sales.amount) > 10000; |
Show total research funding for each astrophysics project. | CREATE TABLE astrophysics_projects (project_id INT,name VARCHAR(50),research_funding DECIMAL(10,2)); | SELECT name, SUM(research_funding) FROM astrophysics_projects GROUP BY name; |
What is the success rate of missions launched by SpaceCorp? | CREATE TABLE space_missions (mission_id INT,mission_name VARCHAR(50),launch_date DATE,return_date DATE,mission_company VARCHAR(50)); | SELECT 100.0 * SUM(CASE WHEN return_date IS NOT NULL THEN 1 ELSE 0 END) / COUNT(*) AS success_rate FROM space_missions WHERE mission_company = 'SpaceCorp'; |
What is the maximum distance traveled by an electric vehicle in a single trip, grouped by vehicle model? | CREATE TABLE Trips (trip_id INT,vehicle_id INT,distance FLOAT); CREATE TABLE ElectricVehicleModels (vehicle_id INT,vehicle_model TEXT); | SELECT evm.vehicle_model, MAX(trips.distance) AS max_distance_traveled FROM Trips trips INNER JOIN ElectricVehicleModels evm ON trips.vehicle_id = evm.vehicle_id GROUP BY 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.