instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Find the average water consumption per organic cotton farming in Bangladesh. | CREATE TABLE organic_cotton_farming (id INT,water_usage DECIMAL,country VARCHAR(20)); INSERT INTO organic_cotton_farming (id,water_usage,country) VALUES (1,1500.00,'India'),(2,1750.00,'Bangladesh'),(3,1800.00,'India'); | SELECT AVG(water_usage) FROM organic_cotton_farming WHERE country = 'Bangladesh'; |
What is the total number of employees who identify as a racial or ethnic minority in the human resources department? | CREATE TABLE EmployeeDiversity (EmployeeID INT,Identity VARCHAR(50),Department VARCHAR(50)); INSERT INTO EmployeeDiversity (EmployeeID,Identity,Department) VALUES (1,'Asian','Human Resources'),(2,'White','Marketing'); | SELECT COUNT(*) FROM EmployeeDiversity WHERE Identity <> 'White' AND Department = 'Human Resources'; |
Delete records of citizens who have not provided any feedback in the last 1 year from the "citizen_feedback" table | CREATE TABLE citizen_feedback (citizen_id INT,feedback TEXT,feedback_date DATE); | DELETE FROM citizen_feedback WHERE feedback IS NULL AND feedback_date < (SELECT DATE(NOW()) - INTERVAL 1 YEAR); |
What is the total climate adaptation funding for Small Island Developing States (SIDS) in 2020, excluding projects in the Caribbean? | CREATE TABLE climate_adaptation_funding (year INT,country VARCHAR(50),project_type VARCHAR(50),region VARCHAR(50),amount DECIMAL(10,2)); INSERT INTO climate_adaptation_funding (year,country,project_type,region,amount) VALUES (2020,'Fiji','Coastal Protection','SIDS',300000.00),(2020,'Barbados','Water Management','Caribbean',250000.00),(2020,'Mauritius','Agriculture Adaptation','SIDS',400000.00); | SELECT SUM(amount) FROM climate_adaptation_funding WHERE year = 2020 AND region = 'SIDS' AND country NOT IN ('Barbados', 'Cuba', 'Jamaica', 'Haiti', 'Dominican Republic'); |
What is the average number of posts per user in the 'social_media' database? | CREATE TABLE users (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,location VARCHAR(50)); CREATE TABLE posts (id INT,user_id INT,content TEXT,timestamp TIMESTAMP); | SELECT AVG(COUNT(posts.id)) AS avg_posts_per_user FROM users LEFT JOIN posts ON users.id = posts.user_id GROUP BY users.id; |
Determine the average population size of mammals in wildlife preserves. | CREATE TABLE wildlife_preserves (id INT,name VARCHAR(255),country VARCHAR(255),area_size FLOAT); | SELECT AVG(population_size) as avg_mammal_population FROM animal_population WHERE animal_type = 'Mammal' AND habitat IN (SELECT name FROM wildlife_preserves); |
How many basketball games were won by teams with a win rate greater than 60%? | CREATE TABLE teams (id INT,name VARCHAR(50),sport VARCHAR(20),wins INT,losses INT); | SELECT COUNT(*) FROM teams WHERE (wins / (wins + losses)) > 0.6 AND sport = 'Basketball'; |
What is the average communication score for climate adaptation projects in each continent? | CREATE TABLE climate_projects (id INT,continent TEXT,project_type TEXT,communication_score FLOAT); | SELECT continent, AVG(communication_score) FROM climate_projects WHERE project_type = 'adaptation' GROUP BY continent; |
List the top 3 best-selling garment types in France in Q3 2020. | CREATE TABLE garment_sales (garment_type VARCHAR(255),geography VARCHAR(255),sales_quantity INT,quarter INT,year INT); INSERT INTO garment_sales (garment_type,geography,sales_quantity,quarter,year) VALUES ('T-Shirt','France',1200,3,2020),('Jeans','France',800,3,2020),('Hoodie','France',1500,3,2020); | SELECT garment_type, SUM(sales_quantity) AS total_quantity FROM garment_sales WHERE geography = 'France' AND quarter = 3 AND year = 2020 GROUP BY garment_type ORDER BY total_quantity DESC LIMIT 3; |
What is the average energy efficiency rating for renewable energy projects in 'Urban Area X'? | CREATE TABLE renewable_projects (project_id INT,project_name TEXT,location TEXT,energy_efficiency_rating FLOAT); INSERT INTO renewable_projects (project_id,project_name,location,energy_efficiency_rating) VALUES (1,'Solar Farm A','Rural Region Y',0.23),(2,'Wind Farm B','Rural Region X',0.35),(3,'Hydro Plant C','Rural Region Y',0.42),(4,'Solar Farm D','Urban Area X',0.50); | SELECT AVG(energy_efficiency_rating) as avg_rating FROM renewable_projects WHERE location = 'Urban Area X'; |
How many 'Sustainable Material' garments are produced in 'South America'? | CREATE TABLE sustainable_garments(garment VARCHAR(20),material VARCHAR(20),region VARCHAR(20)); INSERT INTO sustainable_garments VALUES('Skirts','Sustainable Material','South America'); | SELECT COUNT(*) FROM sustainable_garments WHERE material = 'Sustainable Material' AND region = 'South America'; |
Find the total number of transactions and their sum for all customers in Germany on the last day of each month in the year 2022. | CREATE TABLE transactions (id INT,account_id INT,transaction_date DATE,transaction_amount DECIMAL(10,2)); CREATE TABLE customers (id INT,name VARCHAR(100),age INT,gender VARCHAR(10),city VARCHAR(50),state VARCHAR(50)); | SELECT COUNT(t.id) as total_transactions, SUM(t.transaction_amount) as total_amount FROM transactions t JOIN customers c ON t.account_id = c.id WHERE c.state = 'Germany' AND MONTH(t.transaction_date) = MONTH(CURRENT_DATE - INTERVAL (DAY(CURRENT_DATE) - 1) DAY) AND YEAR(t.transaction_date) = 2022; |
How many wildlife sightings were recorded in 2021, separated by location, for the species 'Polar Bear'? | CREATE TABLE WildlifeSightings (Location VARCHAR(255),Date DATE,Species VARCHAR(255),Quantity INT); INSERT INTO WildlifeSightings (Location,Date,Species,Quantity) VALUES ('Tundra National Park','2021-01-01','Polar Bear',1),('Arctic Circle','2021-01-01','Arctic Fox',2); | SELECT Location, SUM(Quantity) FROM WildlifeSightings WHERE Species = 'Polar Bear' AND YEAR(Date) = 2021 GROUP BY Location; |
What is the average age of female patients who have been diagnosed with diabetes in the rural area of "West Virginia"? | CREATE TABLE patient (patient_id INT,patient_name TEXT,age INT,gender TEXT,diagnosis TEXT,location TEXT); INSERT INTO patient (patient_id,patient_name,age,gender,diagnosis,location) VALUES (1,'Jane Doe',65,'Female','Diabetes','West Virginia'); | SELECT AVG(age) FROM patient WHERE diagnosis = 'Diabetes' AND gender = 'Female' AND location = 'West Virginia'; |
Count how many rural hospitals were built before 2000? | CREATE TABLE hospitals (id INT,name VARCHAR(50),location VARCHAR(50),build_year INT); | SELECT COUNT(*) FROM hospitals WHERE location LIKE '%rural%' AND build_year < 2000; |
What is the average billing rate for attorneys in the LA office? | CREATE TABLE attorneys (id INT,name VARCHAR(255),office VARCHAR(255),billing_rate FLOAT); INSERT INTO attorneys (id,name,office,billing_rate) VALUES (1,'Brown','NY',300.00),(2,'Smith','NY',350.00),(3,'Johnson','LA',400.00); | SELECT AVG(billing_rate) FROM attorneys WHERE office = 'LA'; |
Update the due date of the milestone 'System Integration' for project '123' | CREATE TABLE project_milestones (project_id INT,milestone VARCHAR(50),due_date DATE); INSERT INTO project_milestones (project_id,milestone,due_date) VALUES (123,'Requirements Gathering','2022-01-01'),(123,'System Design','2022-02-01'),(123,'System Integration','2022-03-01'),(456,'Requirements Gathering','2022-04-01'),(456,'System Design','2022-05-01'); | UPDATE project_milestones SET due_date = '2022-04-01' WHERE project_id = 123 AND milestone = 'System Integration'; |
What is the total funding per biotech startup and their corresponding quartile, ordered by total funding? | CREATE SCHEMA if not exists funding_data;CREATE TABLE if not exists funding_data.startups (id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(255),year INT,funding DECIMAL(10,2)); INSERT INTO funding_data.startups (id,name,country,year,funding) VALUES (1,'StartupA','Brazil',2018,500000.00),(2,'StartupB','Canada',2020,300000.00),(3,'StartupC','India',2019,700000.00),(4,'StartupD','Nigeria',2021,400000.00); | SELECT name, funding, NTILE(4) OVER (ORDER BY funding DESC) AS quartile FROM funding_data.startups; |
What was the total rural infrastructure expenditure in Asia in 2018? | CREATE TABLE rural_infrastructure (country VARCHAR(50),project VARCHAR(50),expenditure FLOAT); INSERT INTO rural_infrastructure (country,project,expenditure) VALUES ('India','Road Construction',500000),('China','Electrification',700000),('Nepal','Bridge Building',300000),('Bangladesh','Water Supply',400000),('Pakistan','School Construction',600000); | SELECT SUM(expenditure) as total_expenditure FROM rural_infrastructure WHERE country IN ('India', 'China', 'Nepal', 'Bangladesh', 'Pakistan') AND YEAR(project) = 2018; |
What is the difference between the highest and lowest creativity scores for models in the 'Art' sector? | CREATE TABLE creativity_scores (model_name TEXT,sector TEXT,creativity_score FLOAT); INSERT INTO creativity_scores (model_name,sector,creativity_score) VALUES ('ModelX','Art',0.95),('ModelY','Art',0.87),('ModelZ','Art',0.92); | SELECT MAX(creativity_score) - MIN(creativity_score) FROM creativity_scores WHERE sector = 'Art'; |
What is the average transaction amount for customers in the United Kingdom? | CREATE TABLE customers (customer_id INT,name TEXT,country TEXT); INSERT INTO customers (customer_id,name,country) VALUES (1,'John Doe','UK'),(2,'Jane Smith','Canada'); CREATE TABLE transactions (transaction_id INT,customer_id INT,amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id,customer_id,amount) VALUES (1,1,100.00),(2,1,200.00),(3,2,50.00); | SELECT AVG(amount) FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE customers.country = 'UK'; |
Which manufacturers have launched the most satellites? | CREATE TABLE satellites (satellite_id INT,model VARCHAR(100),manufacturer VARCHAR(100)); INSERT INTO satellites (satellite_id,model,manufacturer) VALUES (1,'SatModel A','Galactic Inc.'); INSERT INTO satellites (satellite_id,model,manufacturer) VALUES (2,'SatModel B','Cosmic Corp.'); INSERT INTO satellites (satellite_id,model,manufacturer) VALUES (3,'SatModel C','Galactic Inc.'); | SELECT manufacturer, COUNT(*) FROM satellites GROUP BY manufacturer ORDER BY COUNT(*) DESC; |
Find the total population of tigers in each country | CREATE TABLE if not exists animal_population (id INT,animal VARCHAR(255),country VARCHAR(255),population INT); INSERT INTO animal_population (id,animal,country,population) VALUES (1,'Tiger','India',2500),(2,'Tiger','Bangladesh',150); | SELECT country, SUM(population) FROM animal_population WHERE animal = 'Tiger' GROUP BY country; |
How many heritage sites are in the 'heritage_sites' table? | CREATE TABLE heritage_sites (id INT,name VARCHAR(50),location VARCHAR(50),type VARCHAR(50)); INSERT INTO heritage_sites (id,name,location,type) VALUES (1,'Petra','Jordan','Historic Site'),(2,'Machu Picchu','Peru','Historic Site'); | SELECT COUNT(*) FROM heritage_sites; |
What is the total volume of recycled water in Hyderabad, India in 2020? | CREATE TABLE WastewaterTreatment_Hyderabad (id INT,year INT,volume INT); INSERT INTO WastewaterTreatment_Hyderabad (id,year,volume) VALUES (1,2018,12000000),(2,2019,12500000),(3,2020,13000000); | SELECT SUM(volume) FROM WastewaterTreatment_Hyderabad WHERE year = 2020; |
Show the number of employees in each department for each company | CREATE TABLE company_departments (id INT,company VARCHAR(255),department VARCHAR(255),num_employees INT); INSERT INTO company_departments (id,company,department,num_employees) VALUES (1,'Acme Inc','Engineering',150),(2,'Acme Inc','Marketing',50),(3,'Acme Inc','Sales',75),(4,'Beta Corp','Engineering',200),(5,'Beta Corp','Marketing',80),(6,'Beta Corp','Sales',100),(7,'Gamma Inc','Engineering',100),(8,'Gamma Inc','Marketing',30),(9,'Gamma Inc','Sales',40); | SELECT company, department, num_employees FROM company_departments; |
Update the mental health parity data to reflect the correct number of mental health visits for patient 5. | CREATE TABLE MentalHealthParity (PatientID int,MentalHealthVisits int); INSERT INTO MentalHealthParity (PatientID,MentalHealthVisits) VALUES (1,5),(2,3),(3,6),(4,4),(5,8),(6,7); | UPDATE MentalHealthParity SET MentalHealthVisits = 7 WHERE PatientID = 5; |
Update the investment amounts for all organizations in the Climate Change sector to 0.9 times their current value. | CREATE TABLE investments (investment_id INT,investor_id INT,org_id INT,investment_amount INT); INSERT INTO investments (investment_id,investor_id,org_id,investment_amount) VALUES (1,1,13,25000),(2,2,14,35000),(3,1,15,45000),(4,3,16,30000),(5,2,15,50000),(6,4,17,70000),(7,4,18,80000); CREATE TABLE organizations (org_id INT,org_name TEXT,focus_topic TEXT); INSERT INTO organizations (org_id,org_name,focus_topic) VALUES (13,'Org 13','Education'),(14,'Org 14','Healthcare'),(15,'Org 15','Education'),(16,'Org 16','Renewable Energy'),(17,'Org 17','Climate Change'),(18,'Org 18','Social Equality'); | UPDATE investments SET investment_amount = investments.investment_amount * 0.9 WHERE investments.org_id IN (SELECT organizations.org_id FROM organizations WHERE organizations.focus_topic = 'Climate Change'); |
What is the total quantity of products sold by each brand, ordered by the total quantity in descending order? | CREATE TABLE brands (brand_id INT,brand_name VARCHAR(255)); INSERT INTO brands VALUES (1,'BrandA'),(2,'BrandB'),(3,'BrandC'); CREATE TABLE sales (sale_id INT,brand_id INT,product_id INT,quantity INT); INSERT INTO sales VALUES (1,1,1,100),(2,1,2,200),(3,2,3,50),(4,3,4,300),(5,1,5,150); | SELECT brand_id, brand_name, SUM(quantity) as total_quantity FROM sales JOIN brands ON sales.brand_id = brands.brand_id GROUP BY brand_id, brand_name ORDER BY total_quantity DESC; |
Which defense projects had the longest timelines in 2021? | CREATE TABLE DefenseProjects (id INT PRIMARY KEY,project_name VARCHAR(50),start_date DATE,end_date DATE); | SELECT project_name, DATEDIFF(end_date, start_date) AS timeline_length FROM DefenseProjects WHERE start_date >= '2021-01-01' AND end_date < '2022-01-01' ORDER BY timeline_length DESC; |
What is the total number of donors who made a donation in the last year? | CREATE TABLE Donors (donor_id INT,donor_name VARCHAR(255),donation_total DECIMAL(10,2)); CREATE TABLE Donations (donation_id INT,donor_id INT,donation_amount DECIMAL(10,2),donation_date DATE); | SELECT COUNT(DISTINCT donor_id) FROM Donations WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
How many employees work in the manufacturing sector in India and the USA? | CREATE TABLE employee_data (country VARCHAR(50),industry VARCHAR(50),num_employees INT); INSERT INTO employee_data (country,industry,num_employees) VALUES ('India','Manufacturing',46200000),('USA','Manufacturing',12730000); | SELECT country, SUM(num_employees) FROM employee_data WHERE country IN ('India', 'USA') GROUP BY country; |
What is the total number of labor rights violations for unions in the manufacturing industry, grouped by the union's name? | CREATE TABLE union_manufacturing (union_id INT,union_name TEXT,industry TEXT,violations INT); INSERT INTO union_manufacturing (union_id,union_name,industry,violations) VALUES (1,'Union R','Manufacturing',30),(2,'Union S','Manufacturing',20),(3,'Union T','Manufacturing',40); | SELECT union_name, SUM(violations) FROM union_manufacturing WHERE industry = 'Manufacturing' GROUP BY union_name; |
Show the number of autonomous and electric buses in the 'public_transportation' table | CREATE TABLE transportation.public_transportation (vehicle_type VARCHAR(50),country VARCHAR(50),autonomous_vehicle BOOLEAN,electric_vehicle BOOLEAN); | SELECT SUM(CASE WHEN vehicle_type = 'bus' AND autonomous_vehicle = TRUE THEN 1 ELSE 0 END) AS autonomous_buses, SUM(CASE WHEN vehicle_type = 'bus' AND electric_vehicle = TRUE THEN 1 ELSE 0 END) AS electric_buses FROM transportation.public_transportation; |
Calculate the total energy consumption (in kWh) by each production line in the 'Factory' location for the year 2021. | CREATE TABLE EnergyConsumption (ProductionLineID INT,EnergyConsumption DECIMAL(10,2),Date DATE); INSERT INTO EnergyConsumption (ProductionLineID,EnergyConsumption,Date) VALUES (1,1200.50,'2021-01-01'),(2,1800.25,'2021-01-01'),(1,1250.00,'2021-02-01'),(2,1850.75,'2021-02-01'); | SELECT ProductionLineID, SUM(EnergyConsumption) FROM EnergyConsumption WHERE Date >= '2021-01-01' AND Date < '2022-01-01' GROUP BY ProductionLineID; |
Which textile supplier has the highest CO2 emissions? | CREATE TABLE supplier_emissions (supplier_id INT,supplier_emissions_kg INT,supplier_name TEXT); | SELECT supplier_name, MAX(supplier_emissions_kg) AS max_emissions FROM supplier_emissions |
What is the average lifespan (in years) of a satellite in low Earth orbit? | CREATE TABLE satellites (id INT,name VARCHAR(255),launch_date DATE,decommission_date DATE,orbit VARCHAR(255)); | SELECT AVG(lifespan) FROM (SELECT name, (JULIANDAY(decommission_date) - JULIANDAY(launch_date)) / 365.25 as lifespan FROM satellites WHERE orbit = 'low Earth orbit') as subquery; |
List the case numbers, client addresses, and total billing amount for cases with the word 'divorce' in the case name, in the state of New York, ordered by the total billing amount in descending order. | CREATE TABLE Cases (CaseID INT,CaseName VARCHAR(255),ClientAddress VARCHAR(255),AttorneyID INT); INSERT INTO Cases (CaseID,CaseName,ClientAddress,AttorneyID) VALUES (1,'Smith v. Johnson - Divorce','123 Main St,New York,NY',1); CREATE TABLE Billing (BillingID INT,CaseID INT,Amount DECIMAL(10,2)); | SELECT Cases.CaseID, Cases.ClientAddress, SUM(Billing.Amount) FROM Cases INNER JOIN Billing ON Cases.CaseID = Billing.CaseID WHERE Cases.CaseName LIKE '%divorce%' AND Cases.AttorneyID IN (SELECT AttorneyID FROM Attorneys WHERE State = 'New York') GROUP BY Cases.CaseID, Cases.ClientAddress ORDER BY SUM(Billing.Amount) DESC; |
What is the difference in temperature between the surface and the ocean floor, for each monitoring station? | CREATE TABLE temperature (station VARCHAR(50),depth FLOAT,temperature FLOAT); INSERT INTO temperature VALUES ('Station 1',0,20.5),('Station 1',1000,5.6),('Station 2',0,21.3),('Station 2',1000,6.4); | SELECT station, temperature - LAG(temperature) OVER (PARTITION BY station ORDER BY depth) as temperature_difference FROM temperature; |
What is the average fare for a route in the 'east' 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),(4,'east',true,12.00),(5,'east',true,13.00); | SELECT AVG(Routes.fare) FROM Routes WHERE Routes.region = 'east' AND Routes.wheelchair_accessible = true; |
What is the average rent for inclusive housing units in Paris? | CREATE TABLE units (id INT,city VARCHAR,inclusive_housing BOOLEAN,rent DECIMAL); | SELECT AVG(rent) FROM units WHERE city = 'Paris' AND inclusive_housing = TRUE; |
What was the total R&D expenditure for the top 2 countries in 2022? | CREATE TABLE rd_expenditures (country VARCHAR(255),amount FLOAT,year INT); INSERT INTO rd_expenditures (country,amount,year) VALUES ('USA',60000,2022),('Germany',32000,2022),('Japan',45000,2022),('India',20000,2022),('Brazil',25000,2022); | SELECT SUM(amount) as total_expenditure FROM (SELECT country, SUM(amount) as amount FROM rd_expenditures WHERE year = 2022 GROUP BY country ORDER BY amount DESC LIMIT 2); |
What is the number of cases resolved through restorative justice in California in the past year? | CREATE TABLE cases (case_id INT,resolution_type VARCHAR(30),date DATE); INSERT INTO cases (case_id,resolution_type,date) VALUES (1,'Restorative Justice','2021-01-01'),(2,'Prosecution','2020-12-01'); CREATE TABLE offenders (offender_id INT,case_id INT); INSERT INTO offenders (offender_id,case_id) VALUES (1,1),(2,2); | SELECT COUNT(*) FROM cases INNER JOIN offenders ON cases.case_id = offenders.case_id WHERE resolution_type = 'Restorative Justice' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
Create a view for displaying daily COVID-19 testing data by hospital | CREATE TABLE covid_testing (id INT PRIMARY KEY,hospital_id INT,test_date DATE,tests_conducted INT); | CREATE VIEW daily_hospital_covid_testing AS SELECT hospital_id, test_date, tests_conducted FROM covid_testing ORDER BY hospital_id, test_date; |
Find the companies that have the same industry and total funding as the company with the maximum number of investment rounds. | CREATE TABLE Companies (id INT,name TEXT,industry TEXT,total_funding FLOAT,num_investments INT); INSERT INTO Companies (id,name,industry,total_funding,num_investments) VALUES (1,'Acme Inc','Software',2500000,2),(2,'Beta Corp','Software',5000000,1),(3,'Gamma Startup','Hardware',1000000,3),(4,'Delta LLC','Hardware',2000000,1),(5,'Epsilon Ltd','Consumer Products',3000000,2),(6,'Zeta PLC','Consumer Products',3000000,3); | SELECT c1.id, c1.name, c1.industry, c1.total_funding, c1.num_investments FROM Companies c1 INNER JOIN (SELECT industry, total_funding, MAX(num_investments) AS max_investments FROM Companies GROUP BY industry) c2 ON c1.industry = c2.industry AND c1.total_funding = c2.total_funding AND c1.num_investments = c2.max_investments; |
Add a new mining site in Australia with the name "New Horizon" and coordinates (123.45, -67.89). | CREATE TABLE mining_sites (id INT PRIMARY KEY,name VARCHAR(50),latitude DECIMAL(9,6),longitude DECIMAL(9,6)); | INSERT INTO mining_sites (name, latitude, longitude) VALUES ('New Horizon', 123.45, -67.89); |
What was the total CO2 emissions (in tonnes) from agrochemicals in the Americas in 2019? | CREATE TABLE agrochemicals (id INT,name VARCHAR(255),location VARCHAR(255),emissions_tonnes FLOAT,date DATE); | SELECT SUM(emissions_tonnes) FROM agrochemicals WHERE YEAR(date) = 2019 AND location LIKE '%Americas%'; |
Identify the top 3 countries with the most companies founded | CREATE TABLE company_founding(id INT PRIMARY KEY,company_name VARCHAR(100),founder_country VARCHAR(50)); INSERT INTO company_founding VALUES (1,'Acme Inc','India'); INSERT INTO company_founding VALUES (2,'Beta Corp','USA'); INSERT INTO company_founding VALUES (3,'Charlie LLC','Canada'); INSERT INTO company_founding VALUES (4,'Delta Inc','India'); INSERT INTO company_founding VALUES (5,'Echo Inc','USA'); INSERT INTO company_founding VALUES (6,'Foxtrot Corp','Brazil'); | SELECT founder_country, COUNT(*) as company_count FROM company_founding GROUP BY founder_country ORDER BY company_count DESC LIMIT 3; |
What is the minimum height of players in the basketball team 'Los Angeles Lakers'? | CREATE TABLE players (player_name TEXT,team TEXT,height FLOAT); INSERT INTO players (player_name,team,height) VALUES ('Charlie Davis','Los Angeles Lakers',200.66); INSERT INTO players (player_name,team,height) VALUES ('Diana Williams','Los Angeles Lakers',192.02); | SELECT MIN(height) FROM players WHERE team = 'Los Angeles Lakers'; |
Identify the top 2 virtual tour cities with the most clicks in 'Australia'. | CREATE TABLE virtual_tours (id INT,city TEXT,views INT,clicks INT); INSERT INTO virtual_tours (id,city,views,clicks) VALUES (1,'Sydney',100,50),(2,'Melbourne',150,75),(3,'Brisbane',200,100); | SELECT city, SUM(clicks) as total_clicks FROM virtual_tours WHERE city IN ('Sydney', 'Melbourne', 'Brisbane') GROUP BY city ORDER BY total_clicks DESC LIMIT 2; |
What is the total number of volunteers for each organization, and the total hours they have contributed? | CREATE TABLE organizations (org_id INT,org_name TEXT);CREATE TABLE volunteers (vol_id INT,org_id INT,hours_contributed INT,volunteer_name TEXT); INSERT INTO organizations VALUES (1,'Habitat for Humanity'); INSERT INTO organizations VALUES (2,'Red Cross'); INSERT INTO volunteers VALUES (1,1,10,'John Doe'); INSERT INTO volunteers VALUES (2,1,15,'Jane Smith'); INSERT INTO volunteers VALUES (3,2,20,'Mary Johnson'); | SELECT organizations.org_name, SUM(volunteers.hours_contributed) AS total_hours, COUNT(DISTINCT volunteers.vol_id) AS total_volunteers FROM organizations INNER JOIN volunteers ON organizations.org_id = volunteers.org_id GROUP BY organizations.org_name; |
What is the distribution of collective bargaining agreements by industry? | CREATE TABLE Collective_Bargaining (industry VARCHAR(20),agreement BOOLEAN); INSERT INTO Collective_Bargaining (industry,agreement) VALUES ('Manufacturing',true),('Manufacturing',false),('Service',true); | SELECT industry, SUM(agreement) as total_agreements FROM Collective_Bargaining GROUP BY industry; |
Add a new record to the 'Trend' table for the 'Animal Print' trend | CREATE TABLE Trend (id INT PRIMARY KEY,name VARCHAR(50),popularity_score INT); | INSERT INTO Trend (id, name, popularity_score) VALUES (20, 'Animal Print', 90); |
What are the names and ages of community health workers who speak English? | CREATE TABLE community_health_workers (id INT,name VARCHAR(50),age INT,language VARCHAR(20)); INSERT INTO community_health_workers (id,name,age,language) VALUES (1,'John Doe',45,'English'),(2,'Jane Smith',35,'Spanish'),(3,'Alice Johnson',40,'Spanish'),(4,'Bob Brown',50,'English'); | SELECT name, age FROM community_health_workers WHERE language = 'English'; |
What is the average temperature change in the US and Canada from 2010 to 2020, and which regions had the highest increase? | CREATE TABLE weather_us (region VARCHAR(255),year INT,avg_temp FLOAT);CREATE TABLE weather_canada (region VARCHAR(255),year INT,avg_temp FLOAT); | SELECT w1.region, AVG(w1.avg_temp - w2.avg_temp) AS temp_change FROM weather_us w1 INNER JOIN weather_canada w2 ON w1.region = w2.region WHERE w1.year BETWEEN 2010 AND 2020 GROUP BY w1.region ORDER BY temp_change DESC; |
What is the number of community engagement events in South American countries for language preservation? | CREATE TABLE CommunityEngagement (country VARCHAR(50),events INT); INSERT INTO CommunityEngagement (country,events) VALUES ('Brazil',50),('Argentina',30),('Colombia',40),('Peru',60),('Chile',70); | SELECT SUM(events) FROM CommunityEngagement WHERE country IN ('Brazil', 'Argentina', 'Colombia', 'Peru', 'Chile') AND region = 'South America' AND prompt_type = 'language preservation'; |
How many agroecology projects are there in Africa? | CREATE TABLE agroecology_projects (id INT PRIMARY KEY,name VARCHAR(100),location VARCHAR(100),farm_id INT,FOREIGN KEY (farm_id) REFERENCES farmers(id)); INSERT INTO agroecology_projects (id,name,location,farm_id) VALUES (1,'Zimbabwe Agroecology Project','Zimbabwe',1),(2,'Kenya Agroecology Learning Network','Kenya',2),(3,'Senegal Agroecology Initiative','Senegal',3); | SELECT COUNT(*) FROM agroecology_projects ap WHERE ap.location IN ('Zimbabwe', 'Kenya', 'Senegal'); |
Get the average age and number of artifacts analyzed by archaeologists of each gender in the 'archaeologists' and 'artifact_analysis' tables. | CREATE TABLE archaeologists (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); CREATE TABLE artifact_analysis (id INT,archaeologist_id INT,artifact_id INT,analysis_date DATE); | SELECT archaeologists.gender, AVG(archaeologists.age), COUNT(artifact_analysis.archaeologist_id) FROM archaeologists LEFT JOIN artifact_analysis ON archaeologists.id = artifact_analysis.archaeologist_id GROUP BY archaeologists.gender; |
What is the number of HIV diagnoses for each race in the hiv_diagnoses table? | CREATE TABLE hiv_diagnoses (race TEXT,num_diagnoses INT); INSERT INTO hiv_diagnoses (race,num_diagnoses) VALUES ('White',5000),('Black',8000),('Hispanic',6000),('Asian',3000),('Other',2000); | SELECT race, num_diagnoses FROM hiv_diagnoses; |
What is the average quantity of sustainable material used per fair-trade certified supplier? | CREATE TABLE Suppliers (SupplierID INT,SupplierName VARCHAR(50),Country VARCHAR(50),Certification VARCHAR(50),Material VARCHAR(50),Quantity INT); INSERT INTO Suppliers (SupplierID,SupplierName,Country,Certification,Material,Quantity) VALUES (1,'Supplier A','Vietnam','Fair Trade','Organic Cotton',5000),(2,'Supplier B','Bangladesh','Fair Trade','Organic Cotton',4000),(3,'Supplier C','Vietnam','Certified Organic','Organic Cotton',3000),(4,'Supplier D','India','Fair Trade','Recycled Polyester',6000),(5,'Supplier E','China','Certified Organic','Recycled Polyester',4000),(6,'Supplier F','Indonesia','Fair Trade','Hemp',7000),(7,'Supplier G','India','Certified Organic','Hemp',5000); | SELECT AVG(Quantity) AS AverageQuantity FROM Suppliers WHERE Certification = 'Fair Trade'; |
List all drugs that were approved in 2018 and have sales revenue greater than $100,000 in Q3 2019? | CREATE TABLE drug_approval (drug VARCHAR(50),year INT,status VARCHAR(50)); INSERT INTO drug_approval (drug,year,status) VALUES ('DrugX',2018,'Approved'),('DrugY',2017,'Approved'),('DrugZ',2018,'Approved'); CREATE TABLE sales (drug VARCHAR(50),quarter VARCHAR(5),year INT,revenue INT); INSERT INTO sales (drug,quarter,year,revenue) VALUES ('DrugX','Q3',2019,120000),('DrugY','Q3',2019,70000),('DrugZ','Q3',2019,110000); | SELECT sales.drug FROM sales INNER JOIN drug_approval ON sales.drug = drug_approval.drug WHERE sales.quarter = 'Q3' AND sales.year = 2019 AND sales.revenue > 100000 AND drug_approval.year = 2018 AND drug_approval.status = 'Approved'; |
What is the maximum number of peacekeepers deployed by any country in a single operation since 2000? | CREATE TABLE peacekeeping_personnel (operation_name VARCHAR(255),country VARCHAR(255),personnel INT,deployment_date DATE); | SELECT MAX(personnel) FROM peacekeeping_personnel WHERE deployment_date >= '2000-01-01' GROUP BY operation_name ORDER BY MAX(personnel) DESC LIMIT 1; |
What is the average number of goals scored by each team in the UEFA Champions League? | CREATE TABLE Teams (TeamID INT,TeamName VARCHAR(100),Goals INT); INSERT INTO Teams (TeamID,TeamName,Goals) VALUES (1,'Barcelona',12),(2,'Real Madrid',15),(3,'Bayern Munich',18); | SELECT TeamName, AVG(Goals) as AvgGoals FROM Teams GROUP BY TeamName; |
What is the average billing rate for attorneys in the New York office? | CREATE TABLE attorneys (attorney_id INT,office_location VARCHAR(255),billing_rate DECIMAL(5,2)); INSERT INTO attorneys (attorney_id,office_location,billing_rate) VALUES (1,'Los Angeles',300),(2,'New York',450),(3,'Los Angeles',350); | SELECT AVG(billing_rate) FROM attorneys WHERE office_location = 'New York'; |
What is the total number of alternative sentencing programs offered in the state of Texas? | CREATE TABLE alternative_sentencing (id INT PRIMARY KEY,state VARCHAR(255),program_name VARCHAR(255),program_type VARCHAR(255)); INSERT INTO alternative_sentencing (id,state,program_name,program_type) VALUES (1,'Texas','Community Service','Alternative Sentencing'),(2,'Texas','Probation','Alternative Sentencing'); | SELECT COUNT(*) FROM alternative_sentencing WHERE state = 'Texas' AND program_type = 'Alternative Sentencing'; |
Which artifact types are present at excavation sites dated between 1950 and 1990? | CREATE TABLE ArtifactsDates (ArtifactID INT,Date DATE); INSERT INTO ArtifactsDates (ArtifactID,Date) VALUES (1,'1955-01-01'),(2,'1960-01-01'),(3,'1970-01-01'),(4,'1980-01-01'),(5,'1990-01-01'); | SELECT ArtifactType FROM Artifacts a JOIN ArtifactsDates d ON a.ArtifactID = d.ArtifactID WHERE d.Date BETWEEN '1950-01-01' AND '1990-01-01' GROUP BY ArtifactType; |
What is the average monthly bill for postpaid mobile customers in the 'North East' region? | CREATE TABLE bills (id INT,subscriber_id INT,amount DECIMAL(10,2),billing_period DATE,type VARCHAR(10),region VARCHAR(10)); INSERT INTO bills (id,subscriber_id,amount,billing_period,type,region) VALUES (1,1,50.00,'2022-01-01','postpaid','North East'),(2,2,60.00,'2022-01-01','postpaid','North East'),(3,3,40.00,'2022-01-01','prepaid','North East'); | SELECT AVG(bills.amount) AS avg_monthly_bill FROM bills WHERE bills.type = 'postpaid' AND bills.region = 'North East'; |
Delete all records in the 'suppliers' table with a 'country' of 'China' and a 'supplier_name' starting with 'Lee' | CREATE TABLE suppliers (supplier_id INT,supplier_name VARCHAR(255),city VARCHAR(255),country VARCHAR(255)); | DELETE FROM suppliers WHERE country = 'China' AND supplier_name LIKE 'Lee%'; |
How many marine species are there in the 'Southern Ocean'? | CREATE TABLE marine_species_count (id INTEGER,name VARCHAR(255),species VARCHAR(255),ocean VARCHAR(255)); | SELECT COUNT(*) FROM marine_species_count WHERE ocean = 'Southern Ocean'; |
What is the average number of posts per day for the 'social_media' table, assuming the 'post_date' column is of type DATE? | CREATE TABLE social_media (user_id INT,post_id INT,post_date DATE); | SELECT AVG(COUNT(*)) FROM social_media GROUP BY post_date; |
What is the average cost of forest management practices in 'Region1'? | CREATE TABLE Forest_Management_4 (ID INT,Region VARCHAR(50),Practice VARCHAR(50),Cost FLOAT); INSERT INTO Forest_Management_4 (ID,Region,Practice,Cost) VALUES (1,'Region1','Practice1',1000),(2,'Region1','Practice2',1200),(3,'Region2','Practice3',1500); | SELECT AVG(Cost) FROM Forest_Management_4 WHERE Region = 'Region1'; |
What is the breakdown of the budget allocated for accessibility improvements in each school? | CREATE TABLE AccessibilityImprovements (SchoolName VARCHAR(255),Year INT,Budget DECIMAL(10,2)); INSERT INTO AccessibilityImprovements (SchoolName,Year,Budget) VALUES ('SchoolA',2020,50000.00),('SchoolB',2020,75000.00),('SchoolC',2019,60000.00); | SELECT SchoolName, SUM(Budget) as TotalBudget FROM AccessibilityImprovements WHERE SchoolName IN (SELECT SchoolName FROM Schools WHERE Type = 'School') GROUP BY SchoolName; |
What is the maximum cargo weight handled by the vessels that docked in the port of San Francisco in the last year? | CREATE TABLE Vessels (ID INT,Name TEXT,CargoWeight INT,DockedAt DATETIME); INSERT INTO Vessels (ID,Name,CargoWeight,DockedAt) VALUES (1,'Vessel1',5000,'2022-01-01 10:00:00'),(2,'Vessel2',6000,'2022-01-05 14:30:00'); CREATE TABLE Ports (ID INT,Name TEXT); INSERT INTO Ports (ID,Name) VALUES (1,'Oakland'),(2,'San_Francisco'); | SELECT MAX(CargoWeight) FROM Vessels WHERE DockedAt >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND Ports.Name = 'San_Francisco'; |
What is the total prize money won by teams from South Korea in esports events? | CREATE TABLE teams (id INT,name VARCHAR(50),country VARCHAR(50),prize_money_won DECIMAL(10,2)); INSERT INTO teams (id,name,country,prize_money_won) VALUES (1,'Team1','South Korea',70000.00),(2,'Team2','USA',35000.00),(3,'Team3','South Korea',80000.00); | SELECT SUM(prize_money_won) FROM teams WHERE country = 'South Korea'; |
What is the average depth of all marine protected areas in the Pacific region, excluding areas with an average depth of more than 3000 meters? | CREATE TABLE marine_protected_areas (id INT,name TEXT,region TEXT,avg_depth FLOAT); INSERT INTO marine_protected_areas (id,name,region,avg_depth) VALUES (1,'MPA 1','Pacific',2500),(2,'MPA 2','Pacific',2800),(3,'MPA 3','Pacific',1800); | SELECT AVG(avg_depth) FROM marine_protected_areas WHERE region = 'Pacific' AND avg_depth < 3000; |
What is the average dissolved oxygen level for all fish farms in Chile? | CREATE TABLE fish_farms (id INT,name TEXT,country TEXT,dissolved_oxygen FLOAT); INSERT INTO fish_farms (id,name,country,dissolved_oxygen) VALUES (1,'Farm G','Chile',6.5); INSERT INTO fish_farms (id,name,country,dissolved_oxygen) VALUES (2,'Farm H','Chile',7.1); INSERT INTO fish_farms (id,name,country,dissolved_oxygen) VALUES (3,'Farm I','Chile',6.9); | SELECT AVG(dissolved_oxygen) FROM fish_farms WHERE country = 'Chile'; |
List all electric vehicle charging stations in the state of New York, along with their locations. | CREATE TABLE ev_charging_stations (id INT,station_name VARCHAR(50),state VARCHAR(50),location VARCHAR(50)); INSERT INTO ev_charging_stations (id,station_name,state,location) VALUES (1,'New York City EV Charging','New York','Manhattan'); | SELECT station_name, location FROM ev_charging_stations WHERE state = 'New York'; |
Calculate average flight hours of aircraft | CREATE TABLE aircraft (aircraft_id INT,name VARCHAR(50),status VARCHAR(20),flight_hours INT); INSERT INTO aircraft (aircraft_id,name,status,flight_hours) VALUES (1,'B747','active',15000),(2,'A320','active',12000); | SELECT AVG(flight_hours) AS avg_flight_hours FROM aircraft; |
What is the count of employees who identify as neurodivergent in the IT department? | CREATE TABLE Employees (EmployeeID INT,Diversity VARCHAR(20),Department VARCHAR(30)); INSERT INTO Employees (EmployeeID,Diversity,Department) VALUES (8,'Neurodivergent','IT'),(9,'Neurotypical','IT'); | SELECT COUNT(*) FROM Employees WHERE Diversity = 'Neurodivergent'; |
How many investigative journalism projects have been completed in each region, in total and by their completion status? | CREATE TABLE InvestigativeProjects (ProjectID INT,Region VARCHAR(50),CompletionStatus VARCHAR(50)); INSERT INTO InvestigativeProjects (ProjectID,Region,CompletionStatus) VALUES (1,'Northeast','Completed'),(2,'Southeast','In Progress'),(3,'Midwest','Completed'); | SELECT Region, COUNT(*) as TotalProjects, SUM(CASE WHEN CompletionStatus = 'Completed' THEN 1 ELSE 0 END) as CompletedProjects, SUM(CASE WHEN CompletionStatus = 'In Progress' THEN 1 ELSE 0 END) as InProgressProjects FROM InvestigativeProjects GROUP BY Region; |
What is the total installed capacity of solar power plants in GW, grouped by country? | CREATE TABLE SolarPlant (country VARCHAR(50),installed_capacity FLOAT); | SELECT country, SUM(installed_capacity) FROM SolarPlant GROUP BY country; |
List all suppliers that provide both organic cotton and recycled polyester. | CREATE TABLE suppliers (id INT,name TEXT,products TEXT); INSERT INTO suppliers (id,name,products) VALUES (1,'Supplier X','organic cotton,recycled polyester'),(2,'Supplier Y','conventional cotton,linen'),(3,'Supplier Z','recycled polyester,hemp'); | SELECT name FROM suppliers WHERE products LIKE '%organic cotton%' AND products LIKE '%recycled polyester%'; |
What is the total carbon pricing revenue for California in 2022? | CREATE TABLE carbon_pricing_CA (state VARCHAR(255),year INT,revenue FLOAT); INSERT INTO carbon_pricing_CA (state,year,revenue) VALUES ('California',2022,12.5); | SELECT revenue FROM carbon_pricing_CA WHERE state = 'California' AND year = 2022; |
What is the total quantity of recycled materials used in European products in Q3 2021? | CREATE TABLE materials (material_id INT,name VARCHAR(255),type VARCHAR(255),recycled_content DECIMAL(5,2));CREATE TABLE products (product_id INT,name VARCHAR(255),material_id INT,quantity INT);INSERT INTO materials (material_id,name,type,recycled_content) VALUES (1,'Recycled Cotton','Recycled',1.00),(2,'Organic Cotton','Sustainable',0.00),(3,'Recycled Polyester','Recycled',1.00);INSERT INTO products (product_id,name,material_id,quantity) VALUES (1,'Eco T-Shirt',1,50),(2,'Organic T-Shirt',2,30),(3,'Recycled Jacket',3,20); | SELECT SUM(products.quantity) as total_quantity FROM materials JOIN products ON materials.material_id = products.material_id WHERE materials.type = 'Recycled' AND QUARTER(products.dates) = 3 AND YEAR(products.dates) = 2021; |
What is the total military spending for countries with a population over 100 million? | CREATE TABLE Country (Name VARCHAR(50),Population INT,MilitarySpending NUMERIC(18,2)); INSERT INTO Country (Name,Population,MilitarySpending) VALUES ('China',1430000000,250000),('India',1366000000,66000),('United States',331000000,770000),('Indonesia',273000000,8000),('Pakistan',225000000,11000); | SELECT Name, MilitarySpending FROM Country WHERE Population > 100000000; |
What is the average quantity (in kg) of copper extracted per hour for all mining projects in Africa? | CREATE TABLE productivity (project_id INT,mineral TEXT,quantity INT,extraction_hours INT); INSERT INTO productivity (project_id,mineral,quantity,extraction_hours) VALUES (1,'gold',1200,200),(2,'copper',1500,300); | SELECT AVG(quantity/extraction_hours) FROM productivity WHERE mineral = 'copper' AND EXISTS (SELECT 1 FROM projects WHERE projects.id = productivity.project_id AND projects.continent = 'Africa'); |
What is the total number of satellites launched by each country in the SpaceRadar table? | CREATE TABLE SpaceRadar (id INT,country VARCHAR(50),year INT,satellites INT); INSERT INTO SpaceRadar (id,country,year,satellites) VALUES (1,'USA',2000,10),(2,'China',2005,8),(3,'Russia',1995,12); | SELECT country, SUM(satellites) AS total_satellites FROM SpaceRadar GROUP BY country; |
What is the average safety score of creative AI applications developed by women in the US? | CREATE TABLE creative_ai_applications (app_id INT,app_name TEXT,safety_score DECIMAL(3,2),developer_id INT,developer_country TEXT); INSERT INTO creative_ai_applications (app_id,app_name,safety_score,developer_id,developer_country) VALUES (1,'AI Painter',8.5,1001,'USA'),(2,'AI Music Composer',9.1,1002,'Canada'),(3,'AI Poet',7.8,1003,'USA'); CREATE TABLE developers (developer_id INT,developer_name TEXT,developer_gender TEXT,developer_country TEXT); INSERT INTO developers (developer_id,developer_name,developer_gender,developer_country) VALUES (1001,'Alice','Female','USA'),(1002,'Bob','Male','Canada'),(1003,'Charlie','Female','USA'); | SELECT AVG(safety_score) FROM creative_ai_applications caa JOIN developers d ON caa.developer_id = d.developer_id WHERE d.developer_gender = 'Female' AND d.developer_country = 'USA'; |
What is the total humanitarian assistance provided by the European Union in 2019? | CREATE TABLE humanitarian_assistance (id INT,donor VARCHAR(50),funds DECIMAL(10,2),year INT); INSERT INTO humanitarian_assistance (id,donor,funds,year) VALUES (1,'European Union',20000000.00,2019); INSERT INTO humanitarian_assistance (id,donor,funds,year) VALUES (2,'USA',15000000.00,2019); INSERT INTO humanitarian_assistance (id,donor,funds,year) VALUES (3,'Germany',8500000.00,2019); | SELECT SUM(funds) as total_humanitarian_assistance FROM humanitarian_assistance WHERE donor = 'European Union' AND year = 2019; |
List all unique risk assessment scores used for policyholders in 'CityA'. | CREATE TABLE Policyholders (PolicyID INT,RiskAssessmentScore INT,City VARCHAR(20)); INSERT INTO Policyholders (PolicyID,RiskAssessmentScore,City) VALUES (1,200,'CityA'),(2,300,'CityA'),(3,200,'CityB'); | SELECT DISTINCT RiskAssessmentScore FROM Policyholders WHERE City = 'CityA'; |
Which heritage sites have the highest community engagement budgets? | CREATE TABLE HeritageSites (id INT,name VARCHAR(255),continent VARCHAR(255)); INSERT INTO HeritageSites (id,name,continent) VALUES (1,'Taj Mahal','Asia'),(2,'Christ the Redeemer','South America'),(3,'Angkor Wat','Asia'); CREATE TABLE Budget (id INT,heritage_site VARCHAR(255),budget FLOAT); INSERT INTO Budget (id,heritage_site,budget) VALUES (1,'Taj Mahal',5000000),(2,'Christ the Redeemer',2000000),(3,'Angkor Wat',3000000); | SELECT HeritageSites.name, Budget.budget FROM HeritageSites INNER JOIN Budget ON HeritageSites.name = Budget.heritage_site ORDER BY Budget.budget DESC; |
Calculate the percentage of systems impacted by each threat type in the last 30 days. | CREATE TABLE Systems (Id INT,Threat VARCHAR(255),Timestamp DATETIME); INSERT INTO Systems (Id,Threat,Timestamp) VALUES (1,'Ransomware','2022-01-01 10:00:00'),(2,'Spyware','2022-01-02 12:00:00'),(3,'Ransomware','2022-01-03 14:00:00'); | SELECT Threat, COUNT(DISTINCT Id) as SystemCount, 100.0 * COUNT(DISTINCT Id) / (SELECT COUNT(DISTINCT Id) FROM Systems WHERE Timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY)) as Percentage FROM Systems WHERE Timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY) GROUP BY Threat; |
Minimum drug approval time for Cardiovascular drugs | CREATE TABLE drug_approval (approval_id INT,drug_name TEXT,disease_area TEXT,approval_date DATE); INSERT INTO drug_approval (approval_id,drug_name,disease_area,approval_date) VALUES (1,'DrugG','Cardiovascular','2015-01-01'),(2,'DrugH','Oncology','2018-01-01'); | SELECT MIN(DATEDIFF('2022-01-01', approval_date)) FROM drug_approval WHERE disease_area = 'Cardiovascular'; |
List all the textile suppliers that provide both organic cotton and hemp? | CREATE TABLE TextileSuppliers (SupplierID INT,SupplierName TEXT,Material TEXT); INSERT INTO TextileSuppliers (SupplierID,SupplierName,Material) VALUES (1,'GreenFields','Organic Cotton'),(2,'NaturalFibers','Hemp'),(3,'EcoWeaves','Organic Cotton'),(4,'SustainableHarvest','Bamboo'),(5,'PureTextiles','Organic Cotton,Hemp'); | SELECT DISTINCT SupplierName FROM TextileSuppliers WHERE Material IN ('Organic Cotton', 'Hemp') GROUP BY SupplierName HAVING COUNT(DISTINCT Material) = 2; |
Insert a new record in the fabrics table for material 'hemp', country 'Canada' and quantity 400 | CREATE TABLE fabrics (id INT PRIMARY KEY,material VARCHAR(255),country VARCHAR(255),quantity INT); INSERT INTO fabrics (id,material,country,quantity) VALUES (1,'cotton','Bangladesh',500),(2,'silk','China',300),(3,'wool','Australia',700); | INSERT INTO fabrics (material, country, quantity) VALUES ('hemp', 'Canada', 400); |
What is the minimum maintenance cost for military aircrafts in South America? | CREATE TABLE Military_Aircrafts_2 (id INT,country VARCHAR(50),type VARCHAR(50),maintenance_cost FLOAT); | SELECT MIN(maintenance_cost) FROM Military_Aircrafts_2 WHERE country = 'South America'; |
What is the total production cost for each aircraft model by year? | CREATE TABLE AircraftProductionCost (id INT,model VARCHAR(255),year INT,quantity INT,unit_cost DECIMAL(5,2)); INSERT INTO AircraftProductionCost (id,model,year,quantity,unit_cost) VALUES (1,'F-15',2019,100,120.50),(2,'F-16',2020,200,145.20),(3,'F-35',2021,300,189.90); | SELECT model, year, SUM(quantity * unit_cost) AS total_cost FROM AircraftProductionCost GROUP BY model, year; |
List all climate finance initiatives in Africa that were successful. | CREATE TABLE climate_finance (region VARCHAR(255),initiative_status VARCHAR(255)); INSERT INTO climate_finance VALUES ('Africa','successful'); | SELECT * FROM climate_finance WHERE region = 'Africa' AND initiative_status = 'successful'; |
Find the maximum price of locally sourced items in the inventory. | CREATE TABLE Inventory(item_id INT,item_name VARCHAR(50),is_locally_sourced BOOLEAN,price DECIMAL(5,2)); INSERT INTO Inventory VALUES(1,'Apples',TRUE,0.99),(2,'Bananas',FALSE,1.49),(3,'Carrots',TRUE,1.25); | SELECT MAX(price) FROM Inventory WHERE is_locally_sourced = TRUE; |
Find the total number of mobile customers who have a data usage less than 2 GB. | CREATE TABLE mobile_customers (customer_id INT,data_usage FLOAT); INSERT INTO mobile_customers (customer_id,data_usage) VALUES (1,3.5),(2,4.2),(3,1.9),(4,1.7),(5,1.8); | SELECT COUNT(*) FROM mobile_customers WHERE data_usage < 2; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.