instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What are the maximum and minimum water temperatures for marine species in the Pacific Ocean? | CREATE TABLE marine_species (id INT,name VARCHAR(50),region VARCHAR(50),water_temperature DECIMAL(5,2)); INSERT INTO marine_species (id,name,region,water_temperature) VALUES (1,'Clownfish','Pacific Ocean',28.00),(2,'Sea Otter','Pacific Ocean',10.00); | SELECT MIN(marine_species.water_temperature) AS "Minimum Water Temperature", MAX(marine_species.water_temperature) AS "Maximum Water Temperature" FROM marine_species WHERE marine_species.region = 'Pacific Ocean'; |
Find the total financial assets of Shariah-compliant institutions in Gulf Cooperation Council countries? | CREATE TABLE if not exists gcc_financial_assets (id INT,institution_name VARCHAR(100),country VARCHAR(50),is_shariah_compliant BOOLEAN,assets DECIMAL(15,2)); | SELECT SUM(assets) FROM gcc_financial_assets WHERE country IN ('Saudi Arabia', 'Kuwait', 'Bahrain', 'United Arab Emirates', 'Oman', 'Qatar') AND is_shariah_compliant = TRUE; |
What is the adoption rate of electric vehicles in the world? | CREATE TABLE EV_Adoption (id INT,country VARCHAR(50),adoption_rate FLOAT); | SELECT SUM(adoption_rate) FROM EV_Adoption; |
Identify the number of organizations in each sector that have ESG scores above 80. | CREATE TABLE org_sector_3 (id INT,org VARCHAR(100),sector VARCHAR(50),ESG_score FLOAT); INSERT INTO org_sector_3 (id,org,sector,ESG_score) VALUES (1,'Microsoft','Technology',85.0),(2,'Google','Technology',87.5),(3,'Tesla','Consumer Discretionary',82.5),(4,'Siemens','Industrials',80.0),(5,'Rolls-Royce','Industrials',81.... | SELECT sector, COUNT(*) as num_orgs FROM org_sector_3 WHERE ESG_score > 80 GROUP BY sector; |
Create a view for displaying hospital bed capacity and associated healthcare workers | CREATE TABLE hospital_bed_capacity (id INT PRIMARY KEY,hospital_name VARCHAR(255),region VARCHAR(255),total_beds INT); CREATE TABLE healthcare_workers (id INT PRIMARY KEY,worker_name VARCHAR(255),hospital_id INT,position VARCHAR(255),years_of_experience INT); | CREATE VIEW hospital_worker_capacity AS SELECT h.hospital_name, h.region, h.total_beds, w.worker_name, w.position, w.years_of_experience FROM hospital_bed_capacity h JOIN healthcare_workers w ON h.id = w.hospital_id; |
What is the minimum water flow rate (in liters per second) in the rivers of the Amazon basin in the month of June? | CREATE TABLE river_flow_rates (id INT,basin VARCHAR(255),rate_liters_per_sec INT,month INT); INSERT INTO river_flow_rates (id,basin,rate_liters_per_sec,month) VALUES (1,'Amazon',120000,6),(2,'Amazon',130000,7),(3,'Amazon',110000,8); | SELECT MIN(rate_liters_per_sec) FROM river_flow_rates WHERE basin = 'Amazon' AND month = 6; |
What is the total revenue generated from military equipment sales in each region, ranked by highest revenue? | CREATE TABLE salesperson (salesperson_id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO salesperson VALUES (1,'John Doe','East Coast'); INSERT INTO salesperson VALUES (2,'Jane Smith','West Coast'); CREATE TABLE military_equipment_sales (sale_id INT,salesperson_id INT,equipment_type VARCHAR(50),quantity INT,sale_... | SELECT s.region, SUM(mES.sale_price * mES.quantity) as total_revenue FROM military_equipment_sales mES JOIN salesperson s ON mES.salesperson_id = s.salesperson_id GROUP BY s.region ORDER BY total_revenue DESC; |
What is the total labor cost for each project? | CREATE TABLE ConstructionLabor (LaborID INT PRIMARY KEY,ProjectID INT,Hours INT,HourlyWage DECIMAL(5,2)); INSERT INTO ConstructionLabor (LaborID,ProjectID,Hours,HourlyWage) VALUES (1,1,50,50.00); | SELECT ProjectID, SUM(Hours * HourlyWage) as TotalLaborCost FROM ConstructionLabor GROUP BY ProjectID; |
What is the average sentiment score for each country in the AI safety dataset? | CREATE TABLE ai_safety (id INT,country VARCHAR,sentiment FLOAT); | SELECT country, AVG(sentiment) OVER (PARTITION BY country) FROM ai_safety; |
how_many_donors | CREATE TABLE donors (donor_id INT,donor_name TEXT); INSERT INTO donors (donor_id,donor_name) VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Alice Johnson'); | SELECT COUNT(*) FROM donors; |
Which indigenous food systems have the highest and lowest total funding in Africa? | CREATE TABLE indigenous_food_systems (id INT,name TEXT,total_funding FLOAT,region TEXT); INSERT INTO indigenous_food_systems (id,name,total_funding,region) VALUES (1,'System 1',50000.0,'Africa'),(2,'System 2',30000.0,'Africa'),(3,'System 3',70000.0,'Africa'); | SELECT name, total_funding FROM (SELECT name, total_funding, ROW_NUMBER() OVER (ORDER BY total_funding DESC) as rank FROM indigenous_food_systems WHERE region = 'Africa') as ranked_systems WHERE rank = 1 OR rank = (SELECT COUNT(*) FROM indigenous_food_systems WHERE region = 'Africa') ORDER BY total_funding; |
What is the market share of electric vehicles, partitioned by autonomous driving capability, per month? | CREATE TABLE AutonomousElectricVehicleSales (id INT,sale_date DATE,make VARCHAR(20),model VARCHAR(20),is_electric BOOLEAN,autonomy_level INT); INSERT INTO AutonomousElectricVehicleSales (id,sale_date,make,model,is_electric,autonomy_level) VALUES (1,'2022-01-01','Tesla','Model S',true,4),(2,'2022-01-01','Tesla','Model 3... | SELECT EXTRACT(MONTH FROM sale_date) AS month, autonomy_level, make, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY EXTRACT(MONTH FROM sale_date)) AS pct_market_share FROM AutonomousElectricVehicleSales WHERE is_electric = true GROUP BY month, autonomy_level, make; |
What is the maximum water consumption in a single day for the city of Chicago? | CREATE TABLE Daily_Water_Consumption (city VARCHAR(20),water_consumption FLOAT,date DATE); INSERT INTO Daily_Water_Consumption (city,water_consumption,date) VALUES ('Chicago',1500000,'2022-01-01'),('Los Angeles',2000000,'2022-01-02'),('Chicago',1700000,'2022-01-03'),('New York',1600000,'2022-01-04'); | SELECT city, MAX(water_consumption) FROM Daily_Water_Consumption WHERE city = 'Chicago'; |
Show total claim amounts and policyholder id for policyholders in Illinois | CREATE TABLE claims (policyholder_id INT,claim_amount DECIMAL(10,2),state VARCHAR(2)); INSERT INTO claims (policyholder_id,claim_amount,state) VALUES (1,500,'IL'),(2,200,'IL'),(3,800,'IL'); | SELECT policyholder_id, SUM(claim_amount) FROM claims WHERE state = 'IL' GROUP BY policyholder_id; |
What are the names of community engagement programs in Nigeria with more than 2 events in the last year and an average attendance greater than 30? | CREATE TABLE CommunityPrograms (id INT,name VARCHAR(255),country VARCHAR(255),UNIQUE (id)); CREATE TABLE Events (id INT,name VARCHAR(255),community_program_id INT,year INT,UNIQUE (id),FOREIGN KEY (community_program_id) REFERENCES CommunityPrograms(id)); CREATE TABLE Attendance (id INT,event_id INT,attendees INT,UNIQUE ... | SELECT cp.name FROM CommunityPrograms cp JOIN Events e ON cp.id = e.community_program_id JOIN Attendance a ON e.id = a.event_id WHERE cp.country = 'Nigeria' GROUP BY cp.name HAVING COUNT(DISTINCT e.id) > 2 AND AVG(a.attendees) > 30 AND e.year = 2022; |
Insert a new record for a donation of $300 made by 'David' on '2022-03-15'. | CREATE TABLE Donations (DonationID INT,DonorID INT,Amount FLOAT,DonationDate DATE); INSERT INTO Donations (DonationID,DonorID,Amount,DonationDate) VALUES (1,1,500.00,'2021-01-01'),(2,2,800.00,'2021-02-01'); | INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (3, (SELECT DonorID FROM Donors WHERE Name = 'David'), 300.00, '2022-03-15'); |
Find the number of electric vehicles in each city, for sedans and SUVs | CREATE TABLE electric_vehicles_by_type_2 (id INT PRIMARY KEY,city VARCHAR(255),type VARCHAR(255),num_vehicles INT); | CREATE VIEW electric_vehicles_by_type_city_2 AS SELECT city, type, COUNT(*) as num_vehicles FROM electric_vehicles WHERE type IN ('Sedan', 'SUV') GROUP BY city, type; SELECT * FROM electric_vehicles_by_type_city_2; |
What is the average depth of the top 3 deepest marine protected areas? | CREATE TABLE marine_protected_areas (area_name TEXT,max_depth INTEGER); INSERT INTO marine_protected_areas (area_name,max_depth) VALUES ('Sargasso Sea',7000),('Java Trench',8000),('Mariana Trench',10000),('Tonga Trench',10600),('Molucca Deep',9100); | SELECT AVG(max_depth) FROM (SELECT max_depth FROM marine_protected_areas ORDER BY max_depth DESC LIMIT 3) AS top_3_deepest; |
Add a new warehouse 'XYZ' with 3 delivery trucks | CREATE TABLE warehouse (id INT PRIMARY KEY,name VARCHAR(255),num_trucks INT); | INSERT INTO warehouse (id, name, num_trucks) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM warehouse), 'XYZ', 3); |
List the names of marine species that are found in either the Atlantic or Indian oceans, but not in both? | CREATE TABLE marine_species (id INT,name VARCHAR(50),Atlantic BOOLEAN,Indian BOOLEAN,Arctic BOOLEAN); INSERT INTO marine_species (id,name,Atlantic,Indian,Arctic) VALUES (1,'Species1',TRUE,TRUE,FALSE),(2,'Species2',TRUE,FALSE,TRUE),(3,'Species3',FALSE,TRUE,FALSE); | SELECT name FROM marine_species WHERE Atlantic = TRUE AND Indian = FALSE UNION SELECT name FROM marine_species WHERE Atlantic = FALSE AND Indian = TRUE; |
Increase the CO2 emissions reduction percentage for buildings in the city of 'San Francisco' by 2% if the current reduction is less than 15%. | CREATE TABLE smart_cities.buildings (id INT,city VARCHAR(255),co2_emissions INT,reduction_percentage DECIMAL(5,2)); CREATE VIEW smart_cities.buildings_view AS SELECT id,city,co2_emissions,reduction_percentage FROM smart_cities.buildings; | UPDATE smart_cities.buildings SET reduction_percentage = reduction_percentage + 2 FROM smart_cities.buildings_view WHERE city = 'San Francisco' AND reduction_percentage < 15; |
What is the maximum number of accommodations provided to a single student in the art department? | CREATE TABLE students (id INT,department VARCHAR(255)); INSERT INTO students (id,department) VALUES (1,'art'),(2,'science'),(3,'art'),(4,'mathematics'),(5,'art'); CREATE TABLE accommodations (id INT,student_id INT,year INT); INSERT INTO accommodations (id,student_id,year) VALUES (1,1,2018),(2,1,2019),(3,3,2018),(4,3,20... | SELECT MAX(accommodations) FROM (SELECT student_id, COUNT(*) as accommodations FROM accommodations GROUP BY student_id) as subquery WHERE student_id IN (SELECT id FROM students WHERE department = 'art'); |
List all suppliers that provide materials for the automotive industry and their corresponding contact information. | CREATE TABLE Suppliers (id INT,industry VARCHAR(255),name VARCHAR(255),email VARCHAR(255),phone VARCHAR(255)); INSERT INTO Suppliers (id,industry,name,email,phone) VALUES (1,'Automotive','ABC Supplies','abc@supplies.com','123-456-7890'),(2,'Aerospace','XYZ Supplies','xyz@supplies.com','987-654-3210'); | SELECT name, email, phone FROM Suppliers WHERE industry = 'Automotive'; |
What is the total cost of the Mars Exploration Program? | CREATE TABLE mars_exploration (id INT,mission_name VARCHAR(50),launch_date DATE,mission_cost DECIMAL(15,2)); | SELECT SUM(mission_cost) FROM mars_exploration; |
Who are the farmers who received funding from the 'Rural Development Fund' in 'Asia' and their respective funding amounts? | CREATE TABLE Rural_Development_Fund(farmer_id INT,farmer_name VARCHAR(50),country VARCHAR(50),funding FLOAT); INSERT INTO Rural_Development_Fund(farmer_id,farmer_name,country,funding) VALUES (1,'Raj Patel','India',12000),(2,'Min Jeong','South Korea',18000); | SELECT farmer_name, funding FROM Rural_Development_Fund WHERE country = 'Asia'; |
Delete all 'Agricultural' sector records from the 'rural_development' database's 'projects' table | CREATE TABLE projects (project_id INT PRIMARY KEY,project_name VARCHAR(100),sector VARCHAR(50),country VARCHAR(50),region VARCHAR(50),start_date DATE,end_date DATE); | DELETE FROM projects WHERE sector = 'Agricultural'; |
What is the minimum temperature anomaly for 'Africa'? | CREATE TABLE climate_data (region VARCHAR(255),year INT,anomaly FLOAT); INSERT INTO climate_data (region,year,anomaly) VALUES ('North America',2016,1.2),('North America',2017,1.5),('South America',2018,1.4),('Asia',2019,1.8),('Asia',2020,1.6),('Africa',2021,1.9),('Africa',2022,1.6); | SELECT MIN(anomaly) FROM climate_data WHERE region = 'Africa'; |
List all heritage sites and their respective conservation status, along with the number of artifacts in each site. | CREATE TABLE heritage_sites (id INT,name VARCHAR(50),location VARCHAR(30),status VARCHAR(20),artifacts INT); INSERT INTO heritage_sites (id,name,location,status,artifacts) VALUES (1,'Site1','NYC','Good',50),(2,'Site2','LA','Fair',75),(3,'Site3','Sydney','Poor',60); | SELECT h.status, h.name, h.location, h.artifacts FROM heritage_sites h ORDER BY h.status; |
List all the marine pollution initiatives in the 'Operations' schema's 'Pollution_Initiatives' table, along with their corresponding budgets | CREATE TABLE Operations.Pollution_Initiatives (id INT,initiative_name VARCHAR(255),budget INT); | SELECT initiative_name, budget FROM Operations.Pollution_Initiatives; |
Identify the top 2 games with the highest number of active players in the last month. | CREATE TABLE GameSessions (PlayerID INT,GameID INT,SessionDuration FLOAT,SessionDate DATE); INSERT INTO GameSessions (PlayerID,GameID,SessionDuration,SessionDate) VALUES (1,1001,50.5,'2022-02-01'),(2,1002,130.3,'2022-03-10'); | SELECT GameID, COUNT(PlayerID) as PlayerCount, RANK() OVER (ORDER BY COUNT(PlayerID) DESC) as Rank FROM GameSessions WHERE SessionDate BETWEEN DATEADD(month, -1, CURRENT_DATE) AND CURRENT_DATE GROUP BY GameID HAVING Rank <= 2; |
How many patients have been treated for Malaria in each country in Africa? | CREATE TABLE patients (id INT,name TEXT,age INT,disease TEXT,country TEXT); INSERT INTO patients (id,name,age,disease,country) VALUES (1,'John Doe',35,'Malaria','Kenya'),(2,'Jane Smith',42,'Malaria','Tanzania'),(3,'Bob Johnson',50,'Malaria','Tanzania'),(4,'Alice Williams',60,'Malaria','Kenya'),(5,'Eli Jones',25,'Typhoi... | SELECT country, COUNT(*) FROM patients WHERE disease = 'Malaria' AND country IN ('Kenya', 'Tanzania') GROUP BY country; |
What are the water consumption values for commercial users in 'WaterUsage' table? | CREATE TABLE WaterUsage (user_type VARCHAR(20),water_consumption INT); INSERT INTO WaterUsage (user_type,water_consumption) VALUES ('Residential',500),('Commercial',800),('Industrial',1200); | SELECT water_consumption FROM WaterUsage WHERE user_type = 'Commercial'; |
List the destinations that received more than 50 packages in a single day in April 2021 | CREATE TABLE Shipments (id INT,destination VARCHAR(50),packages INT,timestamp DATE); INSERT INTO Shipments (id,destination,packages,timestamp) VALUES (1,'Tokyo',55,'2021-04-01'),(2,'Seoul',60,'2021-04-02'),(3,'Beijing',45,'2021-04-03'),(4,'Shanghai',70,'2021-04-04'),(5,'Tokyo',80,'2021-04-05'); | SELECT destination FROM Shipments WHERE packages > 50 GROUP BY destination HAVING COUNT(DISTINCT timestamp) > 1; |
Find the number of animals adopted by each program, sorted by the adoption count in descending order. | CREATE TABLE animal_adoptions (id INT,program_id INT,animal_id INT); INSERT INTO animal_adoptions (id,program_id,animal_id) VALUES (1,1,101),(2,1,102),(3,2,103),(4,2,104),(5,3,105),(6,3,106),(7,3,107); | SELECT program_id, COUNT(*) AS adoptions FROM animal_adoptions GROUP BY program_id ORDER BY adoptions DESC; |
How many vulnerabilities with a severity of 'medium' were detected in the HR department in the last week? | CREATE TABLE vulnerabilities (id INT,department VARCHAR(255),severity VARCHAR(255),date DATE); INSERT INTO vulnerabilities (id,department,severity,date) VALUES (1,'Finance','medium','2022-01-01'),(2,'HR','high','2022-01-05'),(3,'IT','low','2022-01-07'),(4,'HR','medium','2022-01-04'); | SELECT COUNT(*) FROM vulnerabilities WHERE department = 'HR' AND severity = 'medium' AND date >= DATEADD(day, -7, GETDATE()); |
Find the number of users who have never attended a Zumba class? | CREATE TABLE users (id INT,name VARCHAR(255),age INT); CREATE TABLE zumba_classes (id INT,user_id INT,class_date DATE); | SELECT COUNT(DISTINCT u.id) FROM users u LEFT JOIN zumba_classes zc ON u.id = zc.user_id WHERE zc.user_id IS NULL; |
What is the sum of ESG scores for the Renewable Energy sector? | CREATE TABLE investments(id INT,sector VARCHAR(20),esg_score INT); INSERT INTO investments VALUES(1,'Tech',85),(2,'Healthcare',75),(3,'Tech',82); | SELECT SUM(esg_score) as total_esg_score FROM investments WHERE sector = 'Renewable Energy'; |
Which programs have donations but no reported outcomes? | CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(50)); CREATE TABLE Donations (DonationID INT,ProgramID INT,DonationAmount DECIMAL(10,2)); CREATE TABLE Outcomes (ProgramID INT,ProgramOutcome VARCHAR(20)); INSERT INTO Programs (ProgramID,ProgramName) VALUES (1,'Healthcare for All'),(2,'Education for All'),(3,'Ho... | SELECT Programs.ProgramName FROM Programs LEFT JOIN Outcomes ON Programs.ProgramID = Outcomes.ProgramID WHERE Outcomes.ProgramID IS NULL; |
What are the top 2 most caloric vegetarian dishes served in Australian schools? | CREATE TABLE Meals (meal_name VARCHAR(50),meal_type VARCHAR(20),country VARCHAR(50),calorie_count INT); INSERT INTO Meals (meal_name,meal_type,country,calorie_count) VALUES ('Chickpea Curry','vegetarian','Australia',700),('Lentil Soup','vegetarian','Australia',450),('Spaghetti Bolognese','non-vegetarian','Australia',85... | SELECT meal_name, calorie_count FROM Meals WHERE meal_type = 'vegetarian' AND country = 'Australia' ORDER BY calorie_count DESC LIMIT 2; |
Delete all records from the 'water_usage_history' table where the 'usage' is less than 1000 | CREATE TABLE water_usage_history (id INT PRIMARY KEY,date DATE,region VARCHAR(20),usage INT); | DELETE FROM water_usage_history WHERE usage < 1000; |
List all unique locations in 'disaster_response' table where 'Team A' has worked. | CREATE TABLE disaster_response(id INT,team VARCHAR(255),location VARCHAR(255)); INSERT INTO disaster_response(id,team,location) VALUES ('DR001','Team A','Afghanistan'),('DR002','Team B','Pakistan'),('DR003','Team C','Nepal'),('DR004','Team A','Bangladesh'); | SELECT DISTINCT location FROM disaster_response WHERE team = 'Team A'; |
What is the unemployment rate for veterans in California as of March 2022? | CREATE TABLE veteran_unemployment (state varchar(255),unemployment_date date,unemployment_rate decimal(5,2)); | SELECT unemployment_rate FROM veteran_unemployment WHERE state = 'California' AND MONTH(unemployment_date) = 3 AND YEAR(unemployment_date) = 2022; |
Create a table for storing information about climate change conferences | CREATE TABLE climate_conferences (conference_id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE); | CREATE TABLE climate_conferences (conference_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); |
What are the names and prices of all garments made from fabrics produced by suppliers from Asia? | CREATE TABLE fabrics (id INT,name VARCHAR(50),type VARCHAR(50),supplier_country VARCHAR(50)); INSERT INTO fabrics (id,name,type,supplier_country) VALUES (1,'Hemp','Natural','Nepal'); INSERT INTO fabrics (id,name,type,supplier_country) VALUES (2,'Bamboo Viscose','Semi-Synthetic','China'); | SELECT garments.name, garments.price FROM garments JOIN fabrics ON garments.fabric_id = fabrics.id WHERE fabrics.supplier_country IN ('Asia', 'Nepal', 'China'); |
Identify the common fruits grown in Thailand and Philippines. | CREATE TABLE fruits (country VARCHAR(20),fruit VARCHAR(20)); INSERT INTO fruits VALUES ('Thailand','Mango'),('Thailand','Durian'),('Thailand','Pineapple'),('Philippines','Mango'),('Philippines','Banana'),('Philippines','Papaya'); | SELECT fruit FROM fruits WHERE country = 'Thailand' INTERSECT SELECT fruit FROM fruits WHERE country = 'Philippines' |
What is the average age of farmers in 'agriculture_innovation' table, grouped by location? | CREATE TABLE agriculture_innovation (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),location VARCHAR(50)); INSERT INTO agriculture_innovation (id,name,age,gender,location) VALUES (1,'Jane',45,'Female','Rural Texas'); INSERT INTO agriculture_innovation (id,name,age,gender,location) VALUES (2,'Alice',52,'Female','Rur... | SELECT location, AVG(age) FROM agriculture_innovation GROUP BY location; |
How many suppliers are there in the 'circular_economy' schema for each region? | CREATE TABLE circular_economy.suppliers (supplier_id INT,supplier_name VARCHAR(50),region VARCHAR(50)); INSERT INTO circular_economy.suppliers (supplier_id,supplier_name,region) VALUES (1,'Supplier X','Asia'),(2,'Supplier Y','Asia'),(3,'Supplier Z','Europe'),(4,'Supplier W','Africa'); | SELECT region, COUNT(*) as total_suppliers FROM circular_economy.suppliers GROUP BY region; |
What is the total inventory cost for the gluten-free items in the inventory? | CREATE TABLE inventory (item_id INT,item_name TEXT,quantity INT,cost_per_unit DECIMAL(5,2),is_gluten_free BOOLEAN,region TEXT); INSERT INTO inventory (item_id,item_name,quantity,cost_per_unit,is_gluten_free,region) VALUES (1,'Veggie Burger',50,2.50,false,'NY'),(2,'Chicken Caesar Salad',30,3.50,false,'NY'),(3,'BBQ Ribs'... | SELECT SUM(quantity * cost_per_unit) as total_inventory_cost FROM inventory WHERE is_gluten_free = true; |
Identify suppliers with the highest and lowest quantity of organic products supplied? | CREATE TABLE Suppliers(SupplierID INT,Name VARCHAR(50),Organic BOOLEAN);CREATE TABLE Products(ProductID INT,SupplierID INT,ProductName VARCHAR(50),Quantity INT,Organic BOOLEAN);INSERT INTO Suppliers VALUES (1,'Supplier A',TRUE),(2,'Supplier B',FALSE),(3,'Organic Orchard',TRUE);INSERT INTO Products VALUES (1,1,'Apples',... | SELECT Name FROM Suppliers WHERE SupplierID IN (SELECT SupplierID FROM Products WHERE Organic = TRUE GROUP BY SupplierID HAVING MAX(Quantity) OR MIN(Quantity)); |
What is the average age of patients diagnosed with Tuberculosis in 2020 in Texas? | CREATE TABLE Patients (ID INT,Disease VARCHAR(20),Age INT,DiagnosisDate DATE,State VARCHAR(20)); INSERT INTO Patients (ID,Disease,Age,DiagnosisDate,State) VALUES (1,'Tuberculosis',34,'2020-01-15','Texas'); INSERT INTO Patients (ID,Disease,Age,DiagnosisDate,State) VALUES (2,'Tuberculosis',42,'2020-02-20','Texas'); | SELECT AVG(Age) FROM Patients WHERE Disease = 'Tuberculosis' AND YEAR(DiagnosisDate) = 2020 AND State = 'Texas'; |
What is the average viewership for sports-related TV shows? | CREATE TABLE TVShows (show_id INT,viewership INT,genre VARCHAR(255)); INSERT INTO TVShows (show_id,viewership,genre) VALUES (1,2500000,'Sports'),(2,1800000,'Action'),(3,2000000,'Sports'); | SELECT AVG(viewership) FROM TVShows WHERE genre = 'Sports'; |
What is the maximum severity score for each category of vulnerabilities, ordered by the maximum severity score in descending order? | CREATE TABLE vulnerability_categories (id INT,category VARCHAR(50),severity FLOAT); | SELECT category, MAX(severity) as max_severity FROM vulnerability_categories GROUP BY category ORDER BY max_severity DESC; |
Delete virtual tour availability for the Meiji Shrine in Tokyo | CREATE TABLE cultural_sites (site_id INT,name TEXT,city TEXT,has_virtual_tour BOOLEAN); INSERT INTO cultural_sites (site_id,name,city,has_virtual_tour) VALUES (1,'Tsukiji Fish Market','Tokyo',true),(2,'Meiji Shrine','Tokyo',true); | UPDATE cultural_sites SET has_virtual_tour = false WHERE name = 'Meiji Shrine' AND city = 'Tokyo'; |
What is the total investment amount for startups founded by underrepresented racial or ethnic groups? | CREATE TABLE startup (id INT,name TEXT,founder_race TEXT); CREATE TABLE investment (startup_id INT,investment_amount INT); INSERT INTO startup (id,name,founder_race) VALUES (1,'Theta Corp','African American'); INSERT INTO investment (startup_id,investment_amount) VALUES (1,1000000); INSERT INTO startup (id,name,founder... | SELECT SUM(i.investment_amount) FROM startup s INNER JOIN investment i ON s.id = i.startup_id WHERE s.founder_race IN ('African American', 'Latinx', 'Native American', 'Pacific Islander'); |
List the number of rural hospitals and clinics in each state, ordered by the state name. | CREATE TABLE hospitals (hospital_id INT,name TEXT,type TEXT,rural BOOLEAN); CREATE TABLE states (state_code TEXT,state_name TEXT); INSERT INTO hospitals (hospital_id,name,type,rural) VALUES (1,'Rural General Hospital','Hospital',TRUE),(2,'Rural Clinic','Clinic',TRUE); INSERT INTO states (state_code,state_name) VALUES (... | SELECT 'Hospital' as type, states.state_name, COUNT(hospitals.hospital_id) as count FROM hospitals INNER JOIN states ON TRUE WHERE hospitals.rural = TRUE GROUP BY states.state_name UNION SELECT 'Clinic' as type, states.state_name, COUNT(hospitals.hospital_id) as count FROM hospitals INNER JOIN states ON TRUE WHERE hosp... |
What is the difference in carbon pricing (in USD/ton) between countries in Europe and North America? | CREATE TABLE carbon_pricing (id INT,country VARCHAR(50),price FLOAT); INSERT INTO carbon_pricing (id,country,price) VALUES (1,'Germany',30.5),(2,'France',25.2),(3,'US',15.1),(4,'Canada',20.3); | SELECT country, price FROM carbon_pricing WHERE country IN ('Germany', 'France', 'US', 'Canada') ORDER BY country; |
What is the average revenue generated per sustainable clothing item sold? | CREATE TABLE Sales (id INT,item_name VARCHAR(50),material VARCHAR(50),revenue INT); INSERT INTO Sales (id,item_name,material,revenue) VALUES (1,'Shirt','Organic Cotton',25),(2,'Pants','Hemp',30),(3,'Jacket','Recycled Polyester',50),(4,'Shirt','Tencel',20),(5,'Skirt','Bamboo',35); | SELECT AVG(revenue) FROM Sales WHERE material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo'); |
How many female employees were hired in the last two years? | CREATE TABLE Hiring (HireID INT,EmployeeID INT,HireDate DATE); INSERT INTO Hiring (HireID,EmployeeID,HireDate) VALUES (1,5,'2021-01-01'),(2,6,'2020-06-15'),(3,7,'2019-12-20'),(4,8,'2020-02-14'); | SELECT COUNT(*) FROM Hiring JOIN Employees ON Hiring.EmployeeID = Employees.EmployeeID WHERE Employees.Gender = 'Female' AND HireDate >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); |
What is the average volume of timber harvested in Australian and New Zealand forests using sustainable practices since 2010? | CREATE TABLE timber_harvest (id INT,forest_type VARCHAR(50),region VARCHAR(50),volume FLOAT,year INT); INSERT INTO timber_harvest (id,forest_type,region,volume,year) VALUES (1,'Sustainable','Australia',1200.5,2010),(2,'Sustainable','New Zealand',800.3,2010); | SELECT AVG(volume) FROM timber_harvest WHERE forest_type = 'Sustainable' AND (region = 'Australia' OR region = 'New Zealand') AND year >= 2010; |
What is the total energy production by renewable source in Canada for the month of January 2022? | CREATE TABLE energy_production (id INT,country VARCHAR(50),source VARCHAR(50),production FLOAT,timestamp TIMESTAMP); INSERT INTO energy_production (id,country,source,production,timestamp) VALUES (1,'Canada','Wind',500.2,'2022-01-01 10:00:00'),(2,'Canada','Solar',700.3,'2022-01-02 15:00:00'); | SELECT source, SUM(production) as total_production FROM energy_production WHERE country = 'Canada' AND timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-31 23:59:59' AND source IN ('Wind', 'Solar') GROUP BY source; |
What is the minimum engagement score for users in Brazil in December 2021? | CREATE TABLE if not exists engagement (user_id INT,country VARCHAR(50),score FLOAT,month INT,year INT); INSERT INTO engagement (user_id,country,score) VALUES (1,'Brazil',10.5),(2,'Brazil',12.0); | SELECT MIN(score) FROM engagement WHERE country = 'Brazil' AND month = 12 AND year = 2021; |
What was the minimum production yield (in pounds) for the strain 'Blue Dream' in the state of California in 2021? | CREATE TABLE production (id INT,strain VARCHAR(50),state VARCHAR(50),year INT,yield FLOAT); INSERT INTO production (id,strain,state,year,yield) VALUES (1,'OG Kush','Washington',2021,3.5),(2,'Blue Dream','California',2021,4.0),(3,'Sour Diesel','California',2021,3.0); | SELECT MIN(yield) FROM production WHERE strain = 'Blue Dream' AND state = 'California' AND year = 2021; |
Find the decentralized application with the highest transaction count for each country in descending order. | CREATE TABLE Transactions (TransactionID int,DAppName varchar(50),Country varchar(50),Transactions int); INSERT INTO Transactions (TransactionID,DAppName,Country,Transactions) VALUES (1,'DApp1','USA',1000),(2,'DApp2','Canada',2000),(3,'DApp3','USA',3000); | SELECT Country, DAppName, MAX(Transactions) as MaxTransactions FROM Transactions GROUP BY Country, DAppName ORDER BY MaxTransactions DESC; |
Determine the number of unique AI safety and algorithmic fairness research papers published by each author, sorted by the total count in descending order. | CREATE TABLE author (author_id INT,author_name VARCHAR(255)); CREATE TABLE research_paper (paper_id INT,paper_title VARCHAR(255),author_id INT,category VARCHAR(255)); INSERT INTO author (author_id,author_name) VALUES (1,'Dr. Grace Hopper'); INSERT INTO research_paper (paper_id,paper_title,author_id,category) VALUES (1,... | SELECT a.author_name, COUNT(DISTINCT rp.paper_id) as paper_count FROM author a INNER JOIN research_paper rp ON a.author_id = rp.author_id WHERE rp.category IN ('AI Safety', 'Algorithmic Fairness') GROUP BY a.author_name ORDER BY paper_count DESC; |
Insert a new record into the "attractions" table with id 201, name "Sustainable Winery", city "Napa", country "USA", and type "Wine Tasting" | CREATE TABLE attractions (id INT,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50),type VARCHAR(50)); | INSERT INTO attractions VALUES (201, 'Sustainable Winery', 'Napa', 'USA', 'Wine Tasting'); |
Find the number of distinct mental health parity laws in each state. | CREATE TABLE mental_health_parity (id INT,law_name TEXT,state TEXT); INSERT INTO mental_health_parity (id,law_name,state) VALUES (1,'Parity Act 1','NY'),(2,'Parity Act 2','NY'),(3,'Parity Act 3','CA'); | SELECT state, COUNT(DISTINCT law_name) as num_laws FROM mental_health_parity GROUP BY state; |
What is the total quantity of garments supplied by companies based in Africa or South America? | CREATE TABLE Suppliers (supplier_id INT,supplier_name VARCHAR(255),country VARCHAR(255),industry VARCHAR(255)); INSERT INTO Suppliers (supplier_id,supplier_name,country,industry) VALUES (1,'ABC Inc.','USA','Textile'),(2,'XYZ Ltd.','Brazil','Garment'),(3,'LMN Corp.','China','Accessories'),(4,' DEF GmbH','Germany','Susta... | SELECT SUM(quantity) FROM (SELECT 1 AS quantity UNION ALL SELECT 0) q LEFT JOIN Suppliers s ON q.quantity = 1 WHERE s.country IN ('Africa', 'South America'); |
How many unique species are there in 'animal_population' table? | CREATE TABLE animal_population (id INT,species VARCHAR(255),population INT); | SELECT species FROM animal_population GROUP BY species; |
What are the names and average delivery times of all cargoes that were transported by the vessel 'MSC Chariot' and unloaded at the port of Oakland? | CREATE TABLE vessels(id INT,name VARCHAR(255)); INSERT INTO vessels VALUES (1,'MSC Chariot'); CREATE TABLE cargo(id INT,name VARCHAR(255),delivery_time INT,vessel_id INT,port_id INT); CREATE TABLE ports(id INT,name VARCHAR(255)); | SELECT cargo.name, AVG(cargo.delivery_time) FROM cargo INNER JOIN vessels ON cargo.vessel_id = vessels.id INNER JOIN ports ON cargo.port_id = ports.id WHERE vessels.name = 'MSC Chariot' AND ports.name = 'Oakland' GROUP BY cargo.name; |
Identify the top 5 countries with the most registered voters in the European Union. | CREATE TABLE eu_countries (id INT,country VARCHAR(255),num_registered_voters INT); INSERT INTO eu_countries (id,country,num_registered_voters) VALUES (1,'Germany',61478000); | SELECT country, num_registered_voters FROM eu_countries ORDER BY num_registered_voters DESC LIMIT 5; |
Which teachers have participated in professional development programs related to open pedagogy and what are their contact details? | CREATE TABLE teachers (teacher_id INT,teacher_name VARCHAR(50),email VARCHAR(50),phone VARCHAR(15)); INSERT INTO teachers (teacher_id,teacher_name,email,phone) VALUES (1,'John Doe','johndoe@email.com','555-123-4567'),(2,'Jane Smith','janesmith@email.com','555-987-6543'),(3,'Jim Brown','jimbrown@email.com','555-444-33... | SELECT t.teacher_name, t.email, t.phone, pd.program_name FROM teachers t JOIN professional_development pd ON t.teacher_id = pd.teacher_id WHERE pd.program_name LIKE '%open pedagogy%'; |
What is the maximum retail price of eco-friendly activewear sold in Australia? | CREATE TABLE garments (id INT,category VARCHAR(255),subcategory VARCHAR(255),sustainability VARCHAR(50),price DECIMAL(10,2),country VARCHAR(50)); INSERT INTO garments (id,category,subcategory,sustainability,price,country) VALUES (1,'Activewear','Tops','Eco-Friendly',49.99,'Australia'); INSERT INTO garments (id,category... | SELECT MAX(price) FROM garments WHERE category = 'Activewear' AND sustainability = 'Eco-Friendly' AND country = 'Australia'; |
Delete records in the safety_records table where the vessel_id is 801 and incident_type is 'Grounding' | CREATE TABLE safety_records (id INT,vessel_id INT,incident_type VARCHAR(20),resolution VARCHAR(20)); | DELETE FROM safety_records WHERE vessel_id = 801 AND incident_type = 'Grounding'; |
What is the average daily data usage for the top 10 data consuming mobile customers? | CREATE TABLE daily_data_usage(subscriber_id INT,usage FLOAT,date DATE); | SELECT subscriber_id, AVG(usage) FROM daily_data_usage WHERE date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY subscriber_id ORDER BY AVG(usage) DESC LIMIT 10; |
Insert a new record in the 'audience' table | CREATE TABLE audience (id INT,age INT,gender VARCHAR(10),location VARCHAR(100)); | INSERT INTO audience (id, age, gender, location) VALUES (1, 30, 'Female', 'New York'); |
What is the total premium amount and number of policies for policyholders who have a risk assessment score less than 60 and live in the state of Texas? | CREATE TABLE Policyholders (Id INT PRIMARY KEY,FirstName VARCHAR(50),LastName VARCHAR(50),Age INT,Gender VARCHAR(10),State VARCHAR(50)); CREATE TABLE Policies (Id INT PRIMARY KEY,PolicyholderId INT,PolicyType VARCHAR(50),CoverageAmount DECIMAL(10,2),FOREIGN KEY (PolicyholderId) REFERENCES Policyholders(Id)); CREATE TAB... | SELECT P.State, U.RiskAssessmentScore, SUM(U.Premium) as TotalPremiumAmount, COUNT(P.Id) as NumberOfPolicies FROM Policyholders P JOIN Policies PL ON P.Id = PL.PolicyholderId JOIN Underwriting U ON P.Id = U.PolicyholderId WHERE P.State = 'Texas' AND U.RiskAssessmentScore < 60 GROUP BY P.State ORDER BY TotalPremiumAmoun... |
What is the average cost of climate adaptation projects in Latin America over the last 5 years? | CREATE TABLE climate_adaptation (id INT,project_name VARCHAR(50),country VARCHAR(50),year INT,cost FLOAT); INSERT INTO climate_adaptation (id,project_name,country,year,cost) VALUES (1,'Coastal Protection','Brazil',2018,2000000); | SELECT AVG(cost) FROM climate_adaptation WHERE country LIKE '%Latin%' AND year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE); |
What is the total R&D expenditure for a specific drug in a certain year? | CREATE TABLE drugs (id INT,name VARCHAR(255),category VARCHAR(255)); CREATE TABLE rd_expenditures (id INT,drug_id INT,year INT,amount DECIMAL(10,2)); | SELECT SUM(rd_expenditures.amount) FROM rd_expenditures JOIN drugs ON rd_expenditures.drug_id = drugs.id WHERE drugs.name = 'DrugA' AND rd_expenditures.year = 2020; |
Calculate the average crop production by farmers in the 'agriculture' schema, grouped by region, for crops produced in 2022. | CREATE SCHEMA agriculture; CREATE TABLE crops (farmer_id INT,crop_production INT,crop_year INT,region VARCHAR(50)); INSERT INTO crops (farmer_id,crop_production,crop_year,region) VALUES (1,800,2022,'Asia'),(2,900,2022,'Africa'),(3,700,2021,'Europe'),(4,600,2022,'Asia'),(5,1000,2021,'Africa'); | SELECT region, AVG(crop_production) FROM agriculture.crops WHERE crop_year = 2022 GROUP BY region; |
What is the total fare collected from passengers with disabilities for bus route 101? | CREATE TABLE routes (route_id INT,route_name TEXT); INSERT INTO routes (route_id,route_name) VALUES (101,'Bus Route 101'); CREATE TABLE fare_collection (collection_id INT,passenger_type TEXT,route_id INT,fare_amount DECIMAL); INSERT INTO fare_collection (collection_id,passenger_type,route_id) VALUES (1,'Ambulatory',101... | SELECT SUM(fare_amount) FROM fare_collection JOIN routes ON fare_collection.route_id = routes.route_id WHERE passenger_type = 'Wheelchair'; |
What is the total number of home games played by each team? | CREATE TABLE teams (team_id INT,team_name VARCHAR(255)); INSERT INTO teams (team_id,team_name) VALUES (1,'Golden State Warriors'),(2,'Los Angeles Lakers'); CREATE TABLE games (game_id INT,home_team_id INT,away_team_id INT); INSERT INTO games (game_id,home_team_id,away_team_id) VALUES (1,1,2),(2,2,1),(3,1,2); | SELECT t.team_name, COUNT(CASE WHEN g.home_team_id = t.team_id THEN 1 END) as home_games_played FROM teams t INNER JOIN games g ON t.team_id IN (g.home_team_id, g.away_team_id) GROUP BY t.team_name; |
Identify the public transportation systems with the highest and lowest ridership in 2023? | CREATE TABLE Public_Transportation (Id INT,System VARCHAR(50),Ridership INT,Year INT); INSERT INTO Public_Transportation (Id,System,Ridership,Year) VALUES (1,'Tokyo Metro',5500000,2023); INSERT INTO Public_Transportation (Id,System,Ridership,Year) VALUES (2,'Paris Metro',4500000,2023); | SELECT System, Ridership FROM (SELECT System, Ridership, ROW_NUMBER() OVER (ORDER BY Ridership DESC) AS Rank, COUNT(*) OVER () AS Total FROM Public_Transportation WHERE Year = 2023) AS Subquery WHERE Rank = 1 OR Rank = Total; |
What is the total production (in tons) of organic rice in Southeast Asia? | CREATE TABLE organic_rice_production (country VARCHAR(50),crop VARCHAR(50),production FLOAT); INSERT INTO organic_rice_production (country,crop,production) VALUES ('Thailand','Rice',2500.0),('Vietnam','Rice',3000.0),('Indonesia','Rice',2000.0); | SELECT SUM(production) FROM organic_rice_production WHERE country IN ('Thailand', 'Vietnam', 'Indonesia') AND crop = 'Rice'; |
What is the maximum virtual tour engagement time for hotels in the 'Middle East' region? | CREATE TABLE virtual_tours_v2 (hotel_region VARCHAR(20),engagement_time TIME); INSERT INTO virtual_tours_v2 (hotel_region,engagement_time) VALUES ('Africa','00:10:00'),('Middle East','00:25:00'),('South America','00:15:00'); | SELECT MAX(engagement_time) FROM virtual_tours_v2 WHERE hotel_region = 'Middle East'; |
List the cruelty-free certified products and their preference data. | CREATE TABLE ConsumerPreference (ProductID INT,ConsumerID INT,Preference VARCHAR(255)); INSERT INTO ConsumerPreference (ProductID,ConsumerID,Preference) VALUES (4,6,'Likes'),(4,7,'Likes'),(5,6,'Likes'),(5,7,'Dislikes'); CREATE TABLE Product (ProductID INT,ProductName VARCHAR(255),Price DECIMAL(5,2)); INSERT INTO Produc... | SELECT P.ProductName, C.Preference FROM CrueltyFree CF INNER JOIN Product P ON CF.ProductID = P.ProductID INNER JOIN ConsumerPreference C ON P.ProductID = C.ProductID; |
What is the total number of garments produced using fair labor practices in Turkey? | CREATE TABLE Garments (garment_id INT,garment_produced_fair_labor BOOLEAN,garment_country VARCHAR(50)); | SELECT COUNT(*) AS total_garments FROM Garments WHERE garment_produced_fair_labor = TRUE AND garment_country = 'Turkey'; |
What is the average funding received by companies founded by people from underrepresented communities in the clean energy sector? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founders_underrepresented_communities BOOLEAN,funding FLOAT); | SELECT AVG(funding) FROM companies WHERE founders_underrepresented_communities = true AND industry = 'clean energy'; |
How many transactions were made by customers in the Americas region on a Wednesday? | CREATE TABLE dates (transaction_id INT,transaction_date DATE); INSERT INTO dates (transaction_id,transaction_date) VALUES (1,'2022-01-03'),(2,'2022-01-04'),(3,'2022-01-05'),(4,'2022-01-06'); CREATE TABLE customers_4 (customer_id INT,name VARCHAR(50),region VARCHAR(20)); INSERT INTO customers_4 (customer_id,name,region)... | SELECT COUNT(*) FROM transactions_5 t JOIN dates d ON t.transaction_id = d.transaction_id JOIN customers_4 c ON t.customer_id = c.customer_id WHERE EXTRACT(DAY FROM d.transaction_date) = 3 AND c.region = 'Americas'; |
List the top 5 countries with the most users who have opted in to receive push notifications, along with the total number of users in each country. | CREATE TABLE users (id INT,country VARCHAR(50),opted_in_push BOOLEAN); | SELECT country, SUM(CASE WHEN opted_in_push THEN 1 ELSE 0 END) as total_opted_in FROM users GROUP BY country ORDER BY total_opted_in DESC LIMIT 5; |
What were the average sales per drug in the West region in Q4 2021? | CREATE TABLE sales (sale_id INT,drug_id INT,region VARCHAR(255),sales_amount DECIMAL(10,2),quarter INT,year INT); | SELECT d.drug_name, AVG(s.sales_amount) as avg_sales FROM sales s JOIN drugs d ON s.drug_id = d.drug_id WHERE s.region = 'West' AND s.quarter = 4 AND s.year = 2021 GROUP BY d.drug_name; |
List the 'property_id' and 'building_type' of affordable townhouses in the 'affordable_housing' table. | CREATE TABLE affordable_housing (property_id INT,building_type VARCHAR(255),PRIMARY KEY (property_id)); INSERT INTO affordable_housing (property_id,building_type) VALUES (1,'Apartment'),(2,'Townhouse'),(3,'Single-family'),(4,'Townhouse'); | SELECT property_id, building_type FROM affordable_housing WHERE building_type = 'Townhouse' AND price < 300000; |
Who analyzed the artifacts from site 'SiteB'? | CREATE TABLE ArtifactAnalysis (AnalysisID int,ArtifactID int,AnalystName text); INSERT INTO ArtifactAnalysis (AnalysisID,ArtifactID,AnalystName) VALUES (1,2,'John Doe'); | SELECT AnalystName FROM ArtifactAnalysis INNER JOIN Artifacts ON ArtifactAnalysis.ArtifactID = Artifacts.ArtifactID WHERE Artifacts.Name = 'SiteB'; |
How many labor disputes occurred in '2022' in the 'manufacturing' schema, which resulted in a work stoppage of more than 30 days? | CREATE TABLE labor_disputes (id INT,year INT,days_of_work_stoppage INT,industry VARCHAR(255)); INSERT INTO labor_disputes (id,year,days_of_work_stoppage,industry) VALUES (1,2022,45,'manufacturing'),(2,2021,32,'manufacturing'),(3,2022,38,'retail'); | SELECT COUNT(*) FROM labor_disputes WHERE year = 2022 AND days_of_work_stoppage > 30 AND industry = 'manufacturing'; |
Count the number of unique players who have played "Astral Archers" and "Galactic Golf" in the last 30 days. | CREATE TABLE PlayerGames (PlayerID INT,Game TEXT,Date DATE); INSERT INTO PlayerGames (PlayerID,Game,Date) VALUES (1,'Astral Archers','2022-03-01'),(2,'Astral Archers','2022-03-05'),(3,'Galactic Golf','2022-03-03'); | SELECT COUNT(DISTINCT PlayerID) FROM PlayerGames WHERE Game IN ('Astral Archers', 'Galactic Golf') AND Date >= CURDATE() - INTERVAL 30 DAY; |
What is the total amount donated by new donors (those who have donated for the first time) in the year 2022? | CREATE TABLE donors (donor_id INT PRIMARY KEY,donation_amount DECIMAL(10,2),donation_date DATE,first_donation_date DATE); INSERT INTO donors (donor_id,donation_amount,donation_date,first_donation_date) VALUES (1,250,'2022-01-01','2022-01-01'),(2,750,'2022-01-03','2021-01-01'),(3,900,'2022-02-05','2022-02-05'),(4,100,'2... | SELECT SUM(donation_amount) FROM donors WHERE YEAR(donation_date) = 2022 AND YEAR(first_donation_date) = 2022; |
Delete records from the diversity_metrics table for companies founded before 2017 | CREATE TABLE company (id INT,name TEXT,founding_year INT); INSERT INTO company (id,name,founding_year) VALUES (10,'InnoGreen',2016),(11,'GreenVentures',2017),(12,'EcoPower',2015); CREATE TABLE diversity_metrics (id INT,company_id INT,diversity_score DECIMAL); INSERT INTO diversity_metrics (id,company_id,diversity_score... | WITH cte_company AS (DELETE FROM company WHERE founding_year < 2017 RETURNING id) DELETE FROM diversity_metrics WHERE company_id IN (SELECT id FROM cte_company); |
What is the minimum age requirement for medical professionals in Colombia? | CREATE TABLE professionals (id INT,name TEXT,country TEXT,age INT,profession TEXT); | SELECT MIN(age) FROM professionals WHERE country = 'Colombia'; |
List suppliers who do not provide any sustainable products. | CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),sustainable_practices BOOLEAN); CREATE TABLE products (id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(255),supplier_id INT,sustainable BOOLEAN,FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); INSERT INTO suppliers (id,name,loc... | SELECT name FROM suppliers WHERE id NOT IN (SELECT supplier_id FROM products WHERE sustainable = TRUE); |
How many returns were there from California to New York with a value greater than $100 in Q2? | CREATE TABLE returns (id INT,value FLOAT,origin VARCHAR(20),destination VARCHAR(20),returned_date DATE); INSERT INTO returns (id,value,origin,destination,returned_date) VALUES (1,120,'California','New York','2022-04-15'),(2,80,'California','New York','2022-06-01'); | SELECT COUNT(*) FROM returns WHERE origin = 'California' AND destination = 'New York' AND value > 100 AND MONTH(returned_date) BETWEEN 4 AND 6; |
Add data to the 'mitigation_projects' table | CREATE TABLE mitigation_projects (id INT PRIMARY KEY,name VARCHAR(100),location VARCHAR(50),start_date DATE,end_date DATE,budget DECIMAL(10,2)); INSERT INTO mitigation_projects (id,name,location,start_date,end_date,budget) VALUES (1,'Solar Farm','California','2020-01-01','2022-12-31',5000000.00); | INSERT INTO mitigation_projects (id, name, location, start_date, end_date, budget) VALUES (1, 'Solar Farm', 'California', '2020-01-01', '2022-12-31', 5000000.00); |