instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average salary of employees in the IT department hired after January 2020? | CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(50),Gender VARCHAR(10),Salary FLOAT,HireDate DATE); INSERT INTO Employees (EmployeeID,Department,Gender,Salary,HireDate) VALUES (1,'IT','Male',85000,'2021-04-20'),(2,'HR','Female',75000,'2019-12-15'),(3,'IT','Female',80000,'2020-01-08'),(4,'IT','Male',90000,'202... | SELECT AVG(Salary) FROM Employees WHERE Department = 'IT' AND HireDate > '2020-01-01'; |
What is the average age of patients diagnosed with diabetes in rural areas? | CREATE TABLE patients (id INT,age INT,diagnosis VARCHAR(20),location VARCHAR(20)); INSERT INTO patients (id,age,diagnosis,location) VALUES (1,50,'diabetes','rural'),(2,45,'diabetes','rural'),(3,60,'not diabetes','urban'); | SELECT AVG(age) FROM patients WHERE diagnosis = 'diabetes' AND location = 'rural'; |
What is the average points scored by players from India in a single game? | CREATE TABLE games (id INT,player TEXT,country TEXT,points_scored INT); INSERT INTO games (id,player,country,points_scored) VALUES (1,'Raj Singh','IND',12),(2,'Priya Patel','IND',16),(3,'Amit Kumar','IND',10); | SELECT AVG(points_scored) FROM games WHERE country = 'IND'; |
What is the average size, in hectares, of community development initiatives in Kenya that were completed after 2015? | CREATE TABLE community_development_initiatives (id INT,country VARCHAR(255),size_ha FLOAT,completion_date DATE); INSERT INTO community_development_initiatives (id,country,size_ha,completion_date) VALUES (1,'Kenya',50.2,'2016-03-01'),(2,'Kenya',32.1,'2017-08-15'),(3,'Tanzania',45.6,'2018-09-22'); | SELECT AVG(size_ha) FROM community_development_initiatives WHERE country = 'Kenya' AND completion_date >= '2015-01-01'; |
Identify the bridges in the transportation division that require maintenance in the next 6 months and display their maintenance schedule. | CREATE TABLE bridges (id INT,name VARCHAR(50),division VARCHAR(50),maintenance_date DATE); INSERT INTO bridges (id,name,division,maintenance_date) VALUES (1,'Bridge A','Transportation','2024-02-01'),(2,'Bridge B','Transportation','2023-07-15'),(3,'Bridge C','Transportation','2025-03-20'); | SELECT name, maintenance_date FROM bridges WHERE division = 'Transportation' AND maintenance_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH); |
What are the names and transaction counts of decentralized applications in the 'DeFi' category? | CREATE TABLE dapps (name VARCHAR(255),category VARCHAR(50),transaction_count INT); INSERT INTO dapps (name,category,transaction_count) VALUES ('App1','DeFi',500),('App2','Gaming',200),('App3','DeFi',800); | SELECT name, transaction_count FROM dapps WHERE category = 'DeFi'; |
What is the maximum transaction value for 'Wrapped Ether' smart contract on the 'Binance Smart Chain'? | CREATE TABLE bsc_smart_contracts (contract_id INT,contract_address VARCHAR(40),network VARCHAR(20)); INSERT INTO bsc_smart_contracts (contract_id,contract_address,network) VALUES (1,'0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c','Binance Smart Chain'); CREATE TABLE bsc_smart_contract_transactions (transaction_id INT,cont... | SELECT MAX(t.value) as max_value FROM bsc_smart_contracts c JOIN bsc_smart_contract_transactions t ON c.contract_id = t.contract_id WHERE c.contract_address = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' AND c.network = 'Binance Smart Chain' AND c.contract_name = 'Wrapped Ether'; |
Find the number of artworks by each artist in the 'Artworks' table | CREATE TABLE Artworks (Artist VARCHAR(50),Artwork VARCHAR(50),Year INT); INSERT INTO Artworks | SELECT Artist, COUNT(Artwork) as ArtworkCount FROM Artworks GROUP BY Artist |
What is the most frequently used boarding station for each route? | CREATE TABLE Stations (StationID INT,StationName VARCHAR(50),RouteID INT,IsStart VARCHAR(50)); INSERT INTO Stations (StationID,StationName,RouteID,IsStart) VALUES (1,'StationA',1,'true'),(2,'StationB',1,'false'),(3,'StationC',1,'false'),(4,'StationD',2,'true'),(5,'StationE',2,'false'),(6,'StationF',3,'true'),(7,'Statio... | SELECT RouteID, StationName FROM Stations S1 WHERE IsStart = 'true' AND NOT EXISTS (SELECT * FROM Stations S2 WHERE S2.RouteID = S1.RouteID AND S2.IsStart = 'true' AND S2.StationID > S1.StationID); |
What is the total number of patients treated with CBT and medication in California? | CREATE TABLE mental_health_conditions (patient_id INT,condition VARCHAR(50),state VARCHAR(50)); INSERT INTO mental_health_conditions (patient_id,condition,state) VALUES (1,'Anxiety','California'),(2,'Depression','California'); CREATE TABLE treatment_approaches (patient_id INT,approach VARCHAR(50),duration INT); INSERT ... | SELECT SUM(duration) FROM (SELECT duration FROM treatment_approaches WHERE approach IN ('CBT', 'Medication') AND patient_id IN (SELECT patient_id FROM mental_health_conditions WHERE state = 'California') GROUP BY patient_id) AS subquery; |
How many public transportation systems support multimodal travel in New York? | CREATE TABLE multimodal_systems (id INT,city VARCHAR(20),num_systems INT); INSERT INTO multimodal_systems (id,city,num_systems) VALUES (1,'New York',3),(2,'Chicago',2); | SELECT num_systems FROM multimodal_systems WHERE city = 'New York'; |
What is the maximum water depth for shrimp farms in Vietnam? | CREATE TABLE shrimp_farms (id INT,name TEXT,country TEXT,water_depth FLOAT); INSERT INTO shrimp_farms (id,name,country,water_depth) VALUES (1,'Farm R','Vietnam',6.2); INSERT INTO shrimp_farms (id,name,country,water_depth) VALUES (2,'Farm S','Vietnam',7.5); INSERT INTO shrimp_farms (id,name,country,water_depth) VALUES (... | SELECT MAX(water_depth) FROM shrimp_farms WHERE country = 'Vietnam'; |
How many cases were won by attorneys who identify as female? | CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY,Gender VARCHAR(6),Name VARCHAR(255)); INSERT INTO Attorneys (AttorneyID,Gender,Name) VALUES (1,'Female','Sarah Johnson'),(2,'Male','Daniel Lee'),(3,'Non-binary','Jamie Taylor'); CREATE TABLE CaseOutcomes (CaseID INT PRIMARY KEY,AttorneyID INT,Outcome VARCHAR(10)); INSE... | SELECT COUNT(*) FROM CaseOutcomes JOIN Attorneys ON CaseOutcomes.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.Gender = 'Female' AND Outcome = 'Won'; |
What is the maximum water temperature in the Arctic ocean? | CREATE TABLE temperature (temp_id INT,location TEXT,temperature FLOAT); INSERT INTO temperature (temp_id,location,temperature) VALUES (1,'Arctic',25.7); | SELECT MAX(temperature) FROM temperature WHERE location = 'Arctic' |
What is the total area of forests in the temperate region that have been certified as sustainable by the Forest Stewardship Council (FSC)? | CREATE TABLE forest (id INT,name TEXT,region TEXT,is_fsc_certified BOOLEAN); | SELECT SUM(area_sqkm) FROM forest WHERE region = 'temperate' AND is_fsc_certified = TRUE; |
Delete inactive broadband subscribers who haven't used the service in the last 6 months? | CREATE TABLE broadband_subscribers (subscriber_id INT,last_usage DATE); INSERT INTO broadband_subscribers (subscriber_id,last_usage) VALUES (1,'2021-06-01'),(2,'2021-02-15'),(3,'2021-01-05'),(4,'2021-07-20'); | DELETE FROM broadband_subscribers WHERE last_usage < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
What is the average duration of residential permits issued in 2021? | CREATE TABLE ProjectTimeline (permit_id INT,project_type VARCHAR(255),duration INT,issue_year INT); INSERT INTO ProjectTimeline (permit_id,project_type,duration,issue_year) VALUES (1,'residential',120,2021),(2,'commercial',180,2022); | SELECT AVG(duration) FROM ProjectTimeline WHERE project_type = 'residential' AND issue_year = 2021; |
Determine the average stocking density of fish farms in Japan and South Korea. | CREATE TABLE farm_asia (farm_id INT,country VARCHAR(255),density FLOAT); INSERT INTO farm_asia (farm_id,country,density) VALUES (1,'Japan',50),(2,'Japan',60),(3,'South Korea',70),(4,'South Korea',80); | SELECT AVG(density) FROM farm_asia WHERE country IN ('Japan', 'South Korea'); |
Insert new labor productivity data | CREATE TABLE productivity (id INT PRIMARY KEY,company VARCHAR(100),value DECIMAL(5,2)); | INSERT INTO productivity (company, value) VALUES ('Teck Resources', 320); |
What is the maximum container size of cargo ships from South American countries that docked at the Port of Rotterdam? | CREATE TABLE ports (port_id INT,port_name VARCHAR(100),country VARCHAR(100)); INSERT INTO ports (port_id,port_name,country) VALUES (1,'Port of Rotterdam','Netherlands'); CREATE TABLE cargo_ships (ship_id INT,ship_name VARCHAR(100),port_id INT,container_size INT); INSERT INTO cargo_ships (ship_id,ship_name,port_id,conta... | SELECT MAX(container_size) FROM cargo_ships WHERE country = 'South America' AND port_id = 1; |
What is the total number of transactions and their combined value for digital assets with a market cap greater than $1 billion? | CREATE TABLE digital_assets (asset_id INT,name VARCHAR(255),market_cap DECIMAL(18,2)); INSERT INTO digital_assets (asset_id,name,market_cap) VALUES (1,'Bitcoin',1000000000000.00),(2,'Ethereum',300000000000.00); CREATE TABLE transactions (transaction_id INT,asset_id INT,value DECIMAL(18,2)); INSERT INTO transactions (tr... | SELECT SUM(value) AS total_value, COUNT(*) AS total_transactions FROM transactions JOIN digital_assets ON transactions.asset_id = digital_assets.asset_id WHERE digital_assets.market_cap > 1000000000; |
Average revenue of Cubism paintings sold worldwide since 2010? | CREATE TABLE ArtSales (id INT,painting_name VARCHAR(50),price FLOAT,sale_date DATE,painting_style VARCHAR(20),sale_location VARCHAR(30)); INSERT INTO ArtSales (id,painting_name,price,sale_date,painting_style,sale_location) VALUES (1,'Painting1',9000,'2011-01-01','Cubism','USA'); | SELECT AVG(price) FROM ArtSales WHERE painting_style = 'Cubism' AND sale_date >= '2010-01-01'; |
How many patients were treated with CBT in Canada in 2019? | CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE treatments (patient_id INT,treatment_type VARCHAR(50),treatment_date DATE,country VARCHAR(50)); INSERT INTO treatments VALUES (1,'CBT','2019-01-01','Canada'); | SELECT COUNT(*) FROM treatments WHERE treatment_type = 'CBT' AND country = 'Canada' AND treatment_date LIKE '2019%'; |
Which sustainable food trends have gained popularity in the UK in the last 5 years? | CREATE TABLE FoodTrends (trend_name VARCHAR(50),year_of_introduction INT,popularity_score INT,country VARCHAR(50)); INSERT INTO FoodTrends (trend_name,year_of_introduction,popularity_score,country) VALUES ('Vertical Farming',2016,80,'UK'),('Plant-based Meat Substitutes',2017,85,'UK'),('Zero-waste Grocery Stores',2018,7... | SELECT trend_name, year_of_introduction, popularity_score FROM FoodTrends WHERE country = 'UK' AND year_of_introduction >= 2016; |
Insert new defense project record for 'Project X' in the Middle East on 2023-02-15 with a budget of $25 million. | CREATE TABLE DefenseProjects (id INT,project_name VARCHAR(100),region VARCHAR(50),start_date DATE,end_date DATE,budget FLOAT); | INSERT INTO DefenseProjects (project_name, region, start_date, end_date, budget) VALUES ('Project X', 'Middle East', '2023-02-15', '2023-12-31', 25000000); |
What is the average carbon offset for initiatives in the 'carbon_offset_initiatives' table? | CREATE TABLE carbon_offset_initiatives (initiative_id INT,location TEXT,carbon_offset_tons FLOAT); INSERT INTO carbon_offset_initiatives (initiative_id,location,carbon_offset_tons) VALUES (1,'Toronto',500),(2,'Montreal',700),(3,'Vancouver',300); | SELECT AVG(carbon_offset_tons) FROM carbon_offset_initiatives; |
What is the total number of volunteers for the 'Education' department in the 'Volunteers' table? | CREATE TABLE Volunteers (id INT,department VARCHAR(20),registered_date DATE); INSERT INTO Volunteers (id,department,registered_date) VALUES (1,'Animals','2021-01-01'),(2,'Education','2021-02-01'); | SELECT COUNT(*) FROM Volunteers WHERE department = 'Education' |
Insert a new record into the Games table with the title 'CyberSphere', genre 'Action', and platform 'PC'. | CREATE TABLE Games (GameID INT,Title VARCHAR(50),Genre VARCHAR(20),Platform VARCHAR(10)); | INSERT INTO Games (GameID, Title, Genre, Platform) VALUES (1, 'CyberSphere', 'Action', 'PC'); |
What is the average billing amount per case, by attorney? | CREATE TABLE Cases (CaseID INT,CaseType VARCHAR(50)); INSERT INTO Cases (CaseID,CaseType) VALUES (1,'Civil'); INSERT INTO Cases (CaseID,CaseType) VALUES (2,'Criminal'); CREATE TABLE CaseBilling (CaseBillingID INT,CaseID INT,BillingID INT); INSERT INTO CaseBilling (CaseBillingID,CaseID,BillingID) VALUES (1,1,1); INSERT ... | SELECT AT.Name, AVG(B.Amount) AS AvgBillingPerCase FROM Attorneys AT JOIN Assignments A ON AT.AttorneyID = A.AttorneyID JOIN CaseBilling CB ON A.AssignmentID = CB.AssignmentID JOIN Billing B ON CB.BillingID = B.BillingID JOIN Cases C ON CB.CaseID = C.CaseID GROUP BY AT.Name; |
Show the total fare collected from the payments table, grouped by vehicle type from the vehicles table | CREATE TABLE payments (payment_id INT,payment_amount DECIMAL(5,2),vehicle_id INT); INSERT INTO payments (payment_id,payment_amount,vehicle_id) VALUES (1,2.75,1000),(2,3.50,1001),(3,2.50,1000),(4,4.25,1003),(5,1.75,1002),(6,3.00,1001); CREATE TABLE vehicles (vehicle_id INT,vehicle_type VARCHAR(50)); INSERT INTO vehicles... | SELECT v.vehicle_type, SUM(p.payment_amount) FROM payments p JOIN vehicles v ON p.vehicle_id = v.vehicle_id GROUP BY v.vehicle_type; |
What is the average citizen satisfaction score for CityH? | CREATE TABLE City_Satisfaction (City VARCHAR(20),Satisfaction_Score INT); INSERT INTO City_Satisfaction (City,Satisfaction_Score) VALUES ('CityH',7); INSERT INTO City_Satisfaction (City,Satisfaction_Score) VALUES ('CityH',8); INSERT INTO City_Satisfaction (City,Satisfaction_Score) VALUES ('CityH',6); | SELECT City, AVG(Satisfaction_Score) AS 'Average Citizen Satisfaction Score' FROM City_Satisfaction WHERE City = 'CityH' GROUP BY City; |
What is the average production of wells in the South China Sea? | CREATE TABLE wells (well_id INT,name VARCHAR(50),location VARCHAR(50),production FLOAT); INSERT INTO wells (well_id,name,location,production) VALUES (1,'D1','South China Sea',7000),(2,'D2','South China Sea',6000),(3,'D3','South China Sea',8000); | SELECT AVG(production) FROM wells WHERE location = 'South China Sea'; |
Identify the top 3 provinces with the highest budget allocation for education and infrastructure? | CREATE TABLE provinces (province_name VARCHAR(255),budget INT); INSERT INTO provinces (province_name,budget) VALUES ('Ontario',7000000),('Quebec',6000000),('British Columbia',5000000); CREATE TABLE services (service_name VARCHAR(255),province_name VARCHAR(255),budget INT); INSERT INTO services (service_name,province_na... | SELECT province_name, budget FROM (SELECT province_name, SUM(budget) AS budget FROM services WHERE service_name IN ('education', 'infrastructure') GROUP BY province_name ORDER BY budget DESC) AS subquery LIMIT 3; |
What is the average duration of films in the drama and action genres? | CREATE TABLE FilmLength (genre VARCHAR(20),duration INT); INSERT INTO FilmLength (genre,duration) VALUES ('Drama',120),('Drama',150),('Action',80),('Action',90); | SELECT AVG(duration) FROM FilmLength WHERE genre IN ('Drama', 'Action'); |
What are the average population sizes of animals in the 'animal_population' table that are also present in the 'endangered_animals' table? | CREATE TABLE animal_population (id INT,animal_name VARCHAR(50),population INT); CREATE TABLE endangered_animals (id INT,animal_name VARCHAR(50)); | SELECT AVG(a.population) FROM animal_population a INNER JOIN endangered_animals e ON a.animal_name = e.animal_name; |
What is the total number of mining accidents by year? | CREATE TABLE mining_accidents (accident_id INT,accident_date DATE,accident_type VARCHAR(50),method_id INT); INSERT INTO mining_accidents (accident_id,accident_date,accident_type,method_id) VALUES (1,'2020-01-01','Equipment Failure',1),(2,'2020-03-15','Gas Explosion',2),(3,'2019-12-31','Fire',3); | SELECT YEAR(accident_date), COUNT(*) FROM mining_accidents GROUP BY YEAR(accident_date); |
What is the maximum environmental impact score for a mine site in Q2 2022? | CREATE TABLE environmental_impact_q2 (site_id INT,impact_score INT,impact_date DATE); INSERT INTO environmental_impact_q2 (site_id,impact_score,impact_date) VALUES (1,65,'2022-04-10'),(2,75,'2022-05-22'),(3,80,'2022-06-30'); | SELECT MAX(impact_score) FROM environmental_impact_q2 WHERE impact_date BETWEEN '2022-04-01' AND '2022-06-30'; |
Update the amount of climate finance for a specific record in the climate_finance table. | CREATE TABLE climate_finance (id INT,project_location VARCHAR(20),finance_type VARCHAR(20),amount INT,finance_year INT); INSERT INTO climate_finance (id,project_location,finance_type,amount,finance_year) VALUES (1,'Africa','Government Grants',500000,2015); | UPDATE climate_finance SET amount = 600000 WHERE id = 1; |
How many streams did the 2021 album release 'Sour' by Olivia Rodrigo receive in its first week? | CREATE TABLE sour_streams (week INT,streams_in_week INT); INSERT INTO sour_streams (week,streams_in_week) VALUES (1,250000),(2,230000),(3,220000); | SELECT streams_in_week FROM sour_streams WHERE week = 1; |
What is the total number of peacekeeping operations in each continent, ordered by the number of operations in descending order? | CREATE TABLE peacekeeping_operations_continents (id INT,operation VARCHAR(50),continent VARCHAR(50)); INSERT INTO peacekeeping_operations_continents (id,operation,continent) VALUES (1,'Operation United Nations Mission in South Sudan','Africa'),(2,'Operation United Nations Assistance Mission in Somalia','Africa'),(3,'Op... | SELECT continent, COUNT(operation) as total_operations FROM peacekeeping_operations_continents GROUP BY continent ORDER BY total_operations DESC; |
What is the average investment amount in the gender diversity category for the past year? | CREATE TABLE investments (id INT,category VARCHAR(255),date DATE,amount FLOAT); INSERT INTO investments (id,category,date,amount) VALUES (1,'gender diversity','2021-02-15',10000),(2,'renewable energy','2020-12-21',15000),(3,'gender diversity','2021-04-03',13000); | SELECT AVG(amount) FROM investments WHERE category = 'gender diversity' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
What is the total number of containers loaded on vessels in February 2022? | CREATE TABLE vessel_loading (vessel_type VARCHAR(50),loading_date DATE,total_containers INT); INSERT INTO vessel_loading VALUES ('VesselA','2022-02-01',500),('VesselA','2022-02-02',600),('VesselB','2022-02-01',700),('VesselB','2022-02-02',800),('VesselC','2022-02-01',800),('VesselC','2022-02-02',900); | SELECT vessel_type, SUM(total_containers) FROM vessel_loading WHERE EXTRACT(MONTH FROM loading_date) = 2 AND EXTRACT(YEAR FROM loading_date) = 2022 GROUP BY vessel_type; |
Find policyholders in 'GA' who have not filed any claims. | CREATE TABLE Policyholders (PolicyID INT,PolicyholderName TEXT,State TEXT); INSERT INTO Policyholders (PolicyID,PolicyholderName,State) VALUES (1,'John Smith','GA'),(2,'Jane Doe','NY'); CREATE TABLE Claims (ClaimID INT,PolicyID INT,ClaimAmount INT); INSERT INTO Claims (ClaimID,PolicyID,ClaimAmount) VALUES (1,1,5000),(2... | SELECT Policyholders.* FROM Policyholders LEFT JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Claims.PolicyID IS NULL AND Policyholders.State = 'GA'; |
What is the daily revenue for tram rides in Madrid? | CREATE TABLE tram_rides(ride_date DATE,revenue FLOAT); INSERT INTO tram_rides (ride_date,revenue) VALUES ('2022-01-01',3000),('2022-01-02',3200); | SELECT ride_date, SUM(revenue) AS daily_revenue FROM tram_rides GROUP BY ride_date; |
What are the top 3 countries with the highest military expenditure as a percentage of GDP? | CREATE TABLE MilitaryExpenditure (id INT,country VARCHAR(255),military_expenditure DECIMAL(10,2),gdp DECIMAL(10,2)); INSERT INTO MilitaryExpenditure (id,country,military_expenditure,gdp) VALUES (1,'Country1',0.15,50000000),(2,'Country2',0.20,60000000),(3,'Country3',0.10,40000000),(4,'Country4',0.12,45000000); | SELECT country FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY (military_expenditure / gdp) DESC) AS rank FROM MilitaryExpenditure) AS ranked_military_expenditure WHERE rank <= 3; |
What was the average energy efficiency rating in North America in 2021? | CREATE TABLE energy_efficiency (year INT,region VARCHAR(255),rating FLOAT); INSERT INTO energy_efficiency (year,region,rating) VALUES (2021,'North America',80),(2021,'South America',70),(2022,'North America',85); | SELECT AVG(rating) FROM energy_efficiency WHERE year = 2021 AND region = 'North America' |
How many wastewater treatment plants are there in Region1 with a capacity greater than 50000? | CREATE TABLE WastewaterTreatmentPlants (Id INT,Name VARCHAR(100),Location VARCHAR(100),Capacity INT,AnnualTreatmentVolume INT); INSERT INTO WastewaterTreatmentPlants (Id,Name,Location,Capacity,AnnualTreatmentVolume) VALUES (1,'Plant A','City1',50000,45000); INSERT INTO WastewaterTreatmentPlants (Id,Name,Location,Capaci... | SELECT COUNT(*) FROM WastewaterTreatmentPlants WHERE Location = 'Region1' AND Capacity > 50000; |
How many garment factories in Ethiopia use renewable energy? | CREATE TABLE RenewableEnergy (factory VARCHAR(50),energy_source VARCHAR(50)); INSERT INTO RenewableEnergy VALUES ('Factory1','Renewable'),('Factory2','Non-Renewable'),('Factory3','Renewable'),('Factory4','Non-Renewable'); | SELECT COUNT(*) FROM RenewableEnergy WHERE energy_source = 'Renewable' AND factory LIKE '%Ethiopia%'; |
Add new indigenous community record | indigenous_communities (community_id,community_name,location_id,population,language_family) | INSERT INTO indigenous_communities (community_id, community_name, location_id, population, language_family) |
Find the average funding amount for companies founded in Canada, excluding companies that have received funding from crowdfunding platforms. | CREATE TABLE Companies (id INT,name TEXT,country TEXT); INSERT INTO Companies (id,name,country) VALUES (1,'Eh Inc','Canada'); INSERT INTO Companies (id,name,country) VALUES (2,'Maple Co','Canada'); CREATE TABLE Funding (id INT,company_id INT,investor_type TEXT,amount INT); INSERT INTO Funding (id,company_id,investor_ty... | SELECT AVG(Funding.amount) FROM Companies INNER JOIN Funding ON Companies.id = Funding.company_id WHERE Companies.country = 'Canada' AND Funding.investor_type != 'Crowdfunding' |
What are the top 3 most popular sustainable fabrics among customers in South America? | CREATE TABLE SustainableFabrics (fabric_id INT,fabric_name VARCHAR(50),source_country VARCHAR(50),price DECIMAL(5,2),popularity INT); INSERT INTO SustainableFabrics (fabric_id,fabric_name,source_country,price,popularity) VALUES (1,'Organic Cotton','Brazil',3.50,100),(2,'Recycled Polyester','Argentina',4.25,75),(3,'Tenc... | SELECT fabric_name, popularity FROM SustainableFabrics WHERE source_country = 'South America' ORDER BY popularity DESC LIMIT 3; |
What is the most popular public transportation mode in Berlin? | CREATE TABLE public_transportation (transport_mode VARCHAR(50),trips INT); | SELECT transport_mode, MAX(trips) FROM public_transportation WHERE transport_mode LIKE '%Berlin%' GROUP BY transport_mode; |
What is the total budget for projects in the transportation category? | CREATE TABLE projects (id INT,name VARCHAR(255),category VARCHAR(255),budget FLOAT); INSERT INTO projects (id,name,category,budget) VALUES (1,'Road Reconstruction','Transportation',500000.00); | SELECT SUM(budget) FROM projects WHERE category = 'Transportation'; |
How many defense diplomacy events occurred in South America in 2017? | CREATE TABLE DefenseDiplomacy (id INT PRIMARY KEY,event VARCHAR(100),country VARCHAR(50),year INT,participants INT); INSERT INTO DefenseDiplomacy (id,event,country,year,participants) VALUES (1,'Joint Military Exercise','Colombia',2017,12); | SELECT COUNT(*) FROM DefenseDiplomacy WHERE country LIKE '%South America%' AND year = 2017; |
What is the total transaction value by currency for each day in the past month? | CREATE TABLE transactions (transaction_id INT,customer_id INT,amount DECIMAL(10,2),transaction_date DATE,currency VARCHAR(50)); CREATE VIEW daily_transactions AS SELECT transaction_date,SUM(amount) as total_amount FROM transactions WHERE transaction_date >= DATE_SUB(CURRENT_DATE,INTERVAL 1 MONTH) GROUP BY transaction_d... | SELECT dt.transaction_date, t.currency, SUM(t.amount) as currency_total FROM daily_transactions dt INNER JOIN transactions t ON dt.transaction_date = t.transaction_date GROUP BY dt.transaction_date, t.currency; |
What is the total budget allocated to rural hospitals and clinics in Canada, grouped by province? | CREATE TABLE hospitals_canada (id INT,name TEXT,budget INT,province TEXT); INSERT INTO hospitals_canada VALUES (1,'Rural Hospital A',1000000,'Alberta'); INSERT INTO hospitals_canada VALUES (2,'Rural Hospital B',1500000,'British Columbia'); CREATE TABLE clinics_canada (id INT,name TEXT,budget INT,province TEXT); INSERT ... | SELECT province, SUM(budget) FROM hospitals_canada GROUP BY province UNION SELECT province, SUM(budget) FROM clinics_canada GROUP BY province; |
What is the success rate of support groups in Australia? | CREATE TABLE patients (patient_id INT,age INT,gender TEXT,country TEXT); INSERT INTO patients (patient_id,age,gender,country) VALUES (1,35,'Male','Australia'); INSERT INTO patients (patient_id,age,gender,country) VALUES (2,42,'Female','Australia'); CREATE TABLE treatments (treatment_id INT,patient_id INT,treatment_type... | SELECT ROUND(100.0 * COUNT(CASE WHEN outcome = 'Success' THEN 1 END) / COUNT(*), 2) AS success_rate FROM treatments JOIN patients ON patients.patient_id = treatments.patient_id WHERE patients.country = 'Australia' AND treatments.treatment_type = 'Support Group'; |
How many companies were founded by individuals who identify as LGBTQIA+ each year? | CREATE TABLE Companies (id INT,name VARCHAR(50),industry VARCHAR(50),country VARCHAR(50),founding_year INT,founder_lgbtqia VARCHAR(10)); INSERT INTO Companies (id,name,industry,country,founding_year,founder_lgbtqia) VALUES (1,'TechFair','Tech','USA',2019,'Yes'); INSERT INTO Companies (id,name,industry,country,founding_... | SELECT founding_year, COUNT(*) as lgbtqia_count FROM Companies WHERE founder_lgbtqia = 'Yes' GROUP BY founding_year; |
What is the average risk score for investments in the healthcare sector? | CREATE TABLE investments (sector VARCHAR(50),risk_score INT); INSERT INTO investments (sector,risk_score) VALUES ('Education',3),('Healthcare',4),('Housing',2),('Employment',5),('Criminal Justice',3); | SELECT AVG(risk_score) as avg_risk_score FROM investments WHERE sector = 'Healthcare'; |
What is the average investment size in the poverty reduction sector? | CREATE TABLE investments (id INT,sector VARCHAR(20),amount DECIMAL(10,2)); INSERT INTO investments (id,sector,amount) VALUES (1,'education',15000.00),(2,'poverty reduction',18000.00),(3,'education',22000.00); | SELECT AVG(amount) FROM investments WHERE sector = 'poverty reduction'; |
How many unique volunteers worked on the 'Food Security' and 'Environment' programs? | CREATE TABLE volunteers (id INT,program VARCHAR(255)); INSERT INTO volunteers (id,program) VALUES (1,'Food Security'),(2,'Education'),(3,'Environment'); | SELECT COUNT(DISTINCT id) FROM volunteers WHERE program IN ('Food Security', 'Environment'); |
Delete the record for circular economy initiative in Paris in 2017. | CREATE TABLE circular_economy (city VARCHAR(255),year INT,initiative VARCHAR(255)); INSERT INTO circular_economy (city,year,initiative) VALUES ('Paris',2017,'Glass waste recycling program'); | DELETE FROM circular_economy WHERE city = 'Paris' AND year = 2017; |
What is the total tonnage of cargo transported by the 'Cargo Master' vessel in the current year? | CREATE TABLE vessels (id INT,name TEXT,type TEXT);CREATE TABLE cargoes (id INT,vessel_id INT,tonnage INT); INSERT INTO vessels (id,name,type) VALUES (1,'Cargo Master','Cargo Ship'); INSERT INTO cargoes (id,vessel_id,tonnage) VALUES (1,1,10000),(2,1,15000); | SELECT SUM(cargoes.tonnage) FROM cargoes JOIN vessels ON cargoes.vessel_id = vessels.id WHERE vessels.name = 'Cargo Master' AND YEAR(cargoes.id) = YEAR(CURRENT_DATE); |
What is the average biomass of fish for each farming location? | CREATE TABLE farm_locations (location VARCHAR,fish_id INT); CREATE TABLE fish_stock (fish_id INT,species VARCHAR,biomass FLOAT); INSERT INTO farm_locations (location,fish_id) VALUES ('Location A',1),('Location B',2),('Location A',3),('Location C',4); INSERT INTO fish_stock (fish_id,species,biomass) VALUES (1,'Tilapia',... | SELECT f.location, AVG(fs.biomass) FROM farm_locations f JOIN fish_stock fs ON f.fish_id = fs.fish_id GROUP BY f.location; |
Delete an organization and all associated volunteers | CREATE TABLE organization (org_id INT,org_name TEXT); INSERT INTO organization (org_id,org_name) VALUES (1,'Volunteers Inc'); INSERT INTO organization (org_id,org_name) VALUES (2,'Helping Hands'); CREATE TABLE volunteer (vol_id INT,vol_name TEXT,org_id INT,vol_email TEXT); INSERT INTO volunteer (vol_id,vol_name,org_id,... | DELETE FROM volunteer WHERE org_id = 1; DELETE FROM organization WHERE org_id = 1; |
Identify dishes with an average price above the overall average price. | CREATE TABLE menu(dish VARCHAR(255),category VARCHAR(255),price DECIMAL(5,2)); INSERT INTO menu(dish,category,price) VALUES ('Tofu Stir Fry','Starter',9.99),('Lentil Soup','Starter',7.99),('Chickpea Curry','Main',12.99),('Tofu Curry','Main',13.99),('Quinoa Salad','Side',6.99); | SELECT dish, category, price FROM menu WHERE price > (SELECT AVG(price) FROM menu); |
Determine the percentage of time vessels with diesel engines spend idling | CREATE TABLE VESSEL_OPERATION (id INT,vessel_name VARCHAR(50),propulsion VARCHAR(50),status VARCHAR(50),timestamp TIMESTAMP); | SELECT 100.0 * COUNT(CASE WHEN propulsion = 'diesel' AND status = 'idle' THEN 1 END) / COUNT(*) FROM VESSEL_OPERATION WHERE propulsion = 'diesel'; |
List all the sustainable tourism activities in Portugal and their local economic impact. | CREATE TABLE SustainableTourismActivities (activity_id INT,activity_name TEXT,country TEXT,local_economic_impact FLOAT); INSERT INTO SustainableTourismActivities (activity_id,activity_name,country,local_economic_impact) VALUES (1,'Biking Tour','Portugal',12000.0),(2,'Hiking Adventure','Portugal',15000.0); | SELECT * FROM SustainableTourismActivities WHERE country = 'Portugal'; |
What are the sales figures for cruelty-free certified cosmetics in the UK market? | CREATE TABLE products (product_id INT,product_name VARCHAR(100),sales INT,certification VARCHAR(20)); INSERT INTO products (product_id,product_name,sales,certification) VALUES (1,'Lipstick A',5000,'cruelty-free'),(2,'Mascara B',7000,'not_certified'),(3,'Foundation C',8000,'cruelty-free'); CREATE TABLE countries (countr... | SELECT sales FROM products WHERE certification = 'cruelty-free' AND country_code = 'UK'; |
How many traffic accidents occurred in New York in 2021? | CREATE TABLE traffic_accidents (id INT,accident_date DATE,city VARCHAR(50)); INSERT INTO traffic_accidents (id,accident_date,city) VALUES (1,'2021-03-15','New York'),(2,'2021-06-20','New York'); | SELECT COUNT(*) FROM traffic_accidents WHERE accident_date >= '2021-01-01' AND accident_date < '2022-01-01' AND city = 'New York'; |
What's the maximum donation amount given by a visitor from 'Asia'? | CREATE TABLE Donations (DonationID INT,VisitorID INT,Amount DECIMAL(10,2)); | SELECT MAX(d.Amount) FROM Donations d JOIN Visitors v ON d.VisitorID = v.VisitorID WHERE v.Country IN (SELECT CountryName FROM Countries WHERE Region = 'Asia'); |
What is the average playtime of 'Cosmic Racers' for players aged 25 or older? | CREATE TABLE GamePlay (PlayerID INT,GameName VARCHAR(255),Playtime INT); INSERT INTO GamePlay (PlayerID,GameName,Playtime) VALUES (1,'Cosmic Racers',120); INSERT INTO GamePlay (PlayerID,GameName,Playtime) VALUES (2,'Cosmic Racers',180); CREATE TABLE Players (PlayerID INT,PlayerAge INT,GameName VARCHAR(255)); INSERT INT... | SELECT AVG(GamePlay.Playtime) FROM GamePlay JOIN Players ON GamePlay.PlayerID = Players.PlayerID WHERE Players.PlayerAge >= 25 AND GamePlay.GameName = 'Cosmic Racers'; |
What is the total value of investments in the real estate sector? | CREATE TABLE investments (id INT,investor_id INT,sector VARCHAR(20),value FLOAT); INSERT INTO investments (id,investor_id,sector,value) VALUES (1,1,'Real Estate',50000.0),(2,2,'Real Estate',75000.0),(3,3,'Technology',60000.0); | SELECT SUM(value) FROM investments WHERE sector = 'Real Estate'; |
Which freight forwarders have not had any shipments in the last 60 days? | CREATE TABLE freight_forwarders (freight_forwarder_id INT,name VARCHAR(50));CREATE TABLE forwarder_shipments (shipment_id INT,freight_forwarder_id INT,ship_date DATE); INSERT INTO freight_forwarders (freight_forwarder_id,name) VALUES (1,'ABC Logistics'),(2,'XYZ Shipping'),(3,'123 Cargo'); INSERT INTO forwarder_shipment... | SELECT name FROM freight_forwarders LEFT JOIN forwarder_shipments ON freight_forwarders.freight_forwarder_id = forwarder_shipments.freight_forwarder_id WHERE forwarder_shipments.ship_date IS NULL OR forwarder_shipments.ship_date < DATE(NOW()) - INTERVAL 60 DAY; |
What is the water demand and water price by city, and how many water treatment plants serve each city? | CREATE TABLE if not exists water_demand (id INT PRIMARY KEY,city VARCHAR(50),water_demand FLOAT); CREATE TABLE if not exists water_price (id INT PRIMARY KEY,city VARCHAR(50),price FLOAT); CREATE TABLE if not exists water_treatment_plants (id INT PRIMARY KEY,city VARCHAR(50),num_treatment_plants INT); CREATE VIEW if not... | SELECT wdp.city, AVG(wdp.water_demand) as avg_water_demand, AVG(wdp.price) as avg_price, wt.num_treatment_plants FROM water_demand_price wdp JOIN water_treatment_plants wt ON wdp.city = wt.city GROUP BY wt.city; |
Identify the spacecraft that have not visited any planet? | CREATE TABLE SpacecraftVisits (spacecraft_id INT,planet VARCHAR(50),visit_date DATE); CREATE TABLE Spacecraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50)); INSERT INTO Spacecraft (id,name,manufacturer) VALUES (1,'Voyager 1','SpaceCorp'),(2,'Cassini','NASA'),(3,'InSight','JPL'),(4,'Perseverance','NASA'); | SELECT Spacecraft.name FROM Spacecraft LEFT JOIN SpacecraftVisits ON Spacecraft.id = SpacecraftVisits.spacecraft_id WHERE SpacecraftVisits.planet IS NULL; |
Show the average amount spent by fans in each city | fan_stats; fan_demographics | SELECT city, AVG(total_spent) as avg_spent FROM fan_stats INNER JOIN fan_demographics ON fan_stats.fan_id = fan_demographics.id GROUP BY city; |
List all mines in Peru that mined silver in 2019 | CREATE TABLE mining_operations (id INT,mine_name TEXT,location TEXT,material TEXT,quantity INT,date DATE); INSERT INTO mining_operations (id,mine_name,location,material,quantity,date) VALUES (2,'Silver Ridge','Peru','silver',5000,'2019-01-01'); | SELECT DISTINCT mine_name FROM mining_operations WHERE material = 'silver' AND location = 'Peru' AND date = '2019-01-01'; |
What is the total cargo capacity for all vessels in the 'vessels' table that have an even ID? | CREATE TABLE vessels (vessel_id INT,vessel_name VARCHAR(50),registry VARCHAR(50),capacity INT); INSERT INTO vessels (vessel_id,vessel_name,registry,capacity) VALUES (1,'CSCL Globe','China',197500),(2,'OOCL Hong Kong','Hong Kong',210000),(3,'MSC Maya','Panama',192240); | SELECT SUM(capacity) FROM vessels WHERE MOD(vessel_id, 2) = 0; |
Get the number of pallets for the 'XYZ' warehouse | CREATE TABLE warehouse (id INT PRIMARY KEY,name VARCHAR(255),num_pallets INT); INSERT INTO warehouse (id,name,num_pallets) VALUES (1,'ABC'),(2,'XYZ'),(3,'GHI'); | SELECT num_pallets FROM warehouse WHERE name = 'XYZ'; |
Count the number of cases lost by attorneys specialized in criminal law in California. | CREATE TABLE Attorneys (AttorneyID INT,Specialization VARCHAR(255),State VARCHAR(255)); INSERT INTO Attorneys (AttorneyID,Specialization,State) VALUES (1,'Criminal Law','California'); INSERT INTO Attorneys (AttorneyID,Specialization,State) VALUES (2,'Civil Law','California'); INSERT INTO Attorneys (AttorneyID,Specializ... | SELECT COUNT(*) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.Specialization = 'Criminal Law' AND Attorneys.State = 'California' AND Outcome = 'Lost'; |
What is the total budget allocation per citizen in Moscow? | CREATE TABLE budget_moscow (region VARCHAR(20),budget DECIMAL(10,2)); INSERT INTO budget_moscow VALUES ('Moscow',500000.00); CREATE TABLE population (region VARCHAR(20),citizens INT); INSERT INTO population VALUES ('Moscow',12000000); | SELECT region, (SUM(budget) / (SELECT citizens FROM population WHERE region = 'Moscow')) as avg_allocation_per_citizen FROM budget_moscow GROUP BY region; |
What is the percentage of uninsured individuals in each county, in New Mexico? | CREATE TABLE healthcare_access_nm (id INT,county VARCHAR(50),insured BOOLEAN,population INT); INSERT INTO healthcare_access_nm (id,county,insured,population) VALUES (1,'Bernalillo',false,400000); INSERT INTO healthcare_access_nm (id,county,insured,population) VALUES (2,'Santa Fe',true,200000); INSERT INTO healthcare_ac... | SELECT county, (SUM(CASE WHEN insured = false THEN population ELSE 0 END) / SUM(population)) * 100 as uninsured_percentage FROM healthcare_access_nm WHERE state = 'NM' GROUP BY county; |
What was the local economic impact of virtual tourism in Q2 2022 in Africa? | CREATE TABLE Region (RegionID int,RegionName varchar(50)); INSERT INTO Region (RegionID,RegionName) VALUES (1,'Africa'),(2,'Europe'),(3,'Asia'); CREATE TABLE VirtualTourism (VTID int,RegionID int,Revenue int,Quarter varchar(10),Year int); CREATE TABLE LocalEconomy (LEID int,RegionID int,Impact int); INSERT INTO Virtual... | SELECT LocalEconomy.Impact FROM LocalEconomy JOIN Region ON LocalEconomy.RegionID = Region.RegionID JOIN VirtualTourism ON Region.RegionID = VirtualTourism.RegionID WHERE VirtualTourism.Quarter = 'Q2' AND VirtualTourism.Year = 2022 AND Region.RegionName = 'Africa'; |
What is the maximum monthly data usage for prepaid mobile customers in the state of New York? | CREATE TABLE mobile_subscribers (subscriber_id INT,data_usage FLOAT,state VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id,data_usage,state) VALUES (1,3.5,'New York'),(2,4.2,'New York'),(3,3.8,'California'); | SELECT MAX(data_usage) FROM mobile_subscribers WHERE state = 'New York' AND subscription_type = 'prepaid'; |
Calculate the average sale price for each cuisine | CREATE TABLE sales (sale_id INT,dish_id INT,sale_price DECIMAL(5,2),country VARCHAR(255)); INSERT INTO sales (sale_id,dish_id,sale_price,country) VALUES (1,1,9.99,'USA'),(2,3,7.99,'Mexico'),(3,2,12.99,'USA'),(4,3,11.99,'Mexico'),(5,1,10.99,'USA'); CREATE TABLE dishes (dish_id INT,dish_name VARCHAR(255),cuisine VARCHAR(... | SELECT c.cuisine, AVG(s.sale_price) as avg_sale_price FROM sales s INNER JOIN dishes d ON s.dish_id = d.dish_id INNER JOIN (SELECT cuisine FROM dishes GROUP BY cuisine) c ON d.cuisine = c.cuisine GROUP BY c.cuisine; |
List the types of fish and their quantities that are farmed in each country using sustainable methods, excluding fish from Canada. | CREATE TABLE FarmI (species VARCHAR(20),country VARCHAR(20),quantity INT,farming_method VARCHAR(20)); INSERT INTO FarmI (species,country,quantity,farming_method) VALUES ('Salmon','Canada',7000,'Sustainable'); INSERT INTO FarmI (species,country,quantity,farming_method) VALUES ('Trout','Canada',4000,'Sustainable'); INSER... | SELECT country, species, SUM(quantity) FROM FarmI WHERE farming_method = 'Sustainable' AND country != 'Canada' GROUP BY country, species; |
What is the number of drugs approved in each market that have R&D expenditures greater than 5000000? | CREATE TABLE r_and_d_expenditures (drug_name TEXT,expenditures INTEGER); INSERT INTO r_and_d_expenditures (drug_name,expenditures) VALUES ('DrugA',5000000); INSERT INTO r_and_d_expenditures (drug_name,expenditures) VALUES ('DrugB',6000000); INSERT INTO r_and_d_expenditures (drug_name,expenditures) VALUES ('DrugC',40000... | SELECT drug_approval.market, COUNT(DISTINCT drug_approval.drug_name) FROM drug_approval JOIN r_and_d_expenditures ON drug_approval.drug_name = r_and_d_expenditures.drug_name WHERE r_and_d_expenditures.expenditures > 5000000 GROUP BY drug_approval.market; |
Add a new author, 'Sofia Rodriguez', to the 'authors' table | CREATE TABLE authors (author_id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50)); | INSERT INTO authors (first_name, last_name) VALUES ('Sofia', 'Rodriguez'); |
How many test flights were conducted by Blue Origin in 2019? | CREATE TABLE Test_Flights (id INT,name VARCHAR(50),manufacturer VARCHAR(50),test_date DATE); INSERT INTO Test_Flights (id,name,manufacturer,test_date) VALUES (1,'New Shepard','Blue Origin','2019-01-11'),(2,'New Glenn','Blue Origin','2020-01-11'),(3,'Test Flight','NASA','2021-01-11'); | SELECT COUNT(*) FROM Test_Flights WHERE manufacturer = 'Blue Origin' AND YEAR(test_date) = 2019; |
For each store, what is the percentage of garments sold that are from a specific category (e.g., 'Tops')? | CREATE TABLE ProductCategories (ProductID INT,Category VARCHAR(50)); INSERT INTO ProductCategories (ProductID,Category) VALUES (1,'Tops'),(2,'Bottoms'),(3,'Accessories'); | SELECT StoreID, (SUM(CASE WHEN Category = 'Tops' THEN QuantitySold ELSE 0 END) * 100.0 / SUM(QuantitySold)) AS PercentageOfTopsSold FROM Sales JOIN ProductCategories ON Sales.ProductID = ProductCategories.ProductID GROUP BY StoreID; |
What is the success rate of each space agency in terms of successful space missions? | CREATE TABLE SpaceAgencies (id INT,name VARCHAR(255),successful_missions INT,total_missions INT); INSERT INTO SpaceAgencies (id,name,successful_missions,total_missions) VALUES (1,'NASA',100,105); INSERT INTO SpaceAgencies (id,name,successful_missions,total_missions) VALUES (2,'ESA',80,85); | SELECT name, (successful_missions * 100 / total_missions) AS success_rate FROM SpaceAgencies; |
What is the average sea surface temperature in the South Pacific Ocean in the last 5 years? | CREATE TABLE sea_temperature (id INT,year INT,month INT,region TEXT,temperature FLOAT); INSERT INTO sea_temperature (id,year,month,region,temperature) VALUES (1,2017,1,'South Pacific Ocean',27.2); INSERT INTO sea_temperature (id,year,month,region,temperature) VALUES (2,2017,2,'South Pacific Ocean',27.5); | SELECT AVG(temperature) FROM sea_temperature WHERE region = 'South Pacific Ocean' AND year BETWEEN 2017 AND 2021; |
Get the names of publishers with more than 500 articles in 2021 and their respective counts. | CREATE TABLE publisher_counts (publisher TEXT,article_count INT); | SELECT publisher, article_count FROM publisher_counts WHERE article_count > 500 AND YEAR(publisher_counts.publisher) = 2021; |
What is the total billing amount for cases with a verdict of 'Not Guilty' in the year 2021? | CREATE TABLE cases (case_id INT,verdict TEXT,billing_amount INT,case_year INT); | SELECT SUM(billing_amount) FROM cases WHERE verdict = 'Not Guilty' AND case_year = 2021; |
What is the maximum temperature recorded by each space probe during its mission? | CREATE TABLE space_probes (id INT,probe_name VARCHAR(255),mission_duration INT,max_temperature FLOAT); INSERT INTO space_probes (id,probe_name,mission_duration,max_temperature) VALUES (1,'SpaceProbe1',365,200.0),(2,'SpaceProbe2',730,300.0); | SELECT probe_name, MAX(max_temperature) FROM space_probes GROUP BY probe_name; |
How many visitors attended events in the last 3 months from 'CityY'? | CREATE TABLE Visitors (visitor_id INT,name VARCHAR(255),birthdate DATE,city VARCHAR(255)); CREATE TABLE Visits (visit_id INT,visitor_id INT,event_id INT,visit_date DATE); CREATE TABLE Events (event_id INT,name VARCHAR(255),date DATE); | SELECT COUNT(DISTINCT V.visitor_id) FROM Visitors V JOIN Visits IV ON V.visitor_id = IV.visitor_id JOIN Events E ON IV.event_id = E.event_id WHERE V.city = 'CityY' AND E.date >= DATE(CURRENT_DATE) - INTERVAL 3 MONTH; |
What is the total value of defense contracts signed by company 'ABC Corp' in Q2 2020? | CREATE TABLE defense_contracts (contract_id INT,company VARCHAR(255),value FLOAT,date DATE); INSERT INTO defense_contracts (contract_id,company,value,date) VALUES (1,'ABC Corp',500000,'2020-01-01'); INSERT INTO defense_contracts (contract_id,company,value,date) VALUES (2,'XYZ Inc',750000,'2020-01-05'); | SELECT SUM(value) FROM defense_contracts WHERE company = 'ABC Corp' AND date BETWEEN '2020-04-01' AND '2020-06-30'; |
Update the landfill capacity for Texas in 2022 to 5000. | CREATE TABLE landfill_capacity(year INT,state VARCHAR(255),capacity INT); INSERT INTO landfill_capacity VALUES (2021,'Texas',4000),(2022,'Texas',0); | UPDATE landfill_capacity SET capacity = 5000 WHERE year = 2022 AND state = 'Texas'; |
Update the status of all return shipments to 'delivered' | CREATE TABLE return_shipments (id INT PRIMARY KEY,status VARCHAR(255)); INSERT INTO return_shipments (id,status) VALUES (1,'pending'),(2,'processing'); | UPDATE return_shipments SET status = 'delivered' WHERE status IN ('pending', 'processing'); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.