instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
Identify the top 5 threat actors by the number of successful attacks in the last month. | CREATE TABLE threat_actors (actor_id INT PRIMARY KEY,actor_name VARCHAR(100),num_successful_attacks INT); INSERT INTO threat_actors (actor_id,actor_name,num_successful_attacks) VALUES (1,'APT28',150),(2,'Lazarus Group',120),(3,'APT33',80),(4,'Carbanak Group',75),(5,'Cozy Bear',60); | SELECT actor_name, num_successful_attacks FROM threat_actors WHERE attack_date BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE() GROUP BY actor_name ORDER BY COUNT(*) DESC FETCH FIRST 5 ROWS ONLY; |
What is the minimum wage for 'temporary' workers in the 'logistics' sector, and how many such workers are there? | CREATE TABLE employee_records (id INT,employment_type VARCHAR(10),sector VARCHAR(20),wage FLOAT); INSERT INTO employee_records (id,employment_type,sector,wage) VALUES (1,'temporary','logistics',14.00),(2,'permanent','logistics',18.00),(3,'temporary','logistics',13.50),(4,'permanent','logistics',20.00); | SELECT MIN(wage), COUNT(*) FROM employee_records WHERE employment_type = 'temporary' AND sector = 'logistics'; |
What is the average speed for vessels in the Mediterranean? | CREATE TABLE Vessels (VesselID varchar(10),Region varchar(10),Speed int); INSERT INTO Vessels (VesselID,Region,Speed) VALUES ('VesselD','Mediterranean',20),('VesselE','Mediterranean',25); | SELECT AVG(Speed) FROM Vessels WHERE Region = 'Mediterranean'; |
What is the total metal waste generation in Rio de Janeiro in 2021? | CREATE TABLE waste_generation (city VARCHAR(50),waste_type VARCHAR(50),generation_quantity INT,generation_date DATE); INSERT INTO waste_generation (city,waste_type,generation_quantity,generation_date) VALUES ('Rio de Janeiro','Metal',900,'2021-01-01'),('Rio de Janeiro','Organic',1200,'2021-01-01'),('Rio de Janeiro','Glass',700,'2021-01-01'); | SELECT SUM(generation_quantity) FROM waste_generation WHERE city = 'Rio de Janeiro' AND waste_type = 'Metal' AND generation_date >= '2021-01-01' AND generation_date <= '2021-12-31'; |
How much water is used in the agricultural sector in Texas? | CREATE TABLE water_usage_tx (sector VARCHAR(20),usage FLOAT); INSERT INTO water_usage_tx (sector,usage) VALUES ('Industrial',1100),('Agriculture',4000),('Domestic',900); | SELECT usage FROM water_usage_tx WHERE sector = 'Agriculture'; |
What is the maximum daily water consumption for the water treatment plant with ID 8 in the state of Washington in 2022? | CREATE TABLE water_treatment_plant (plant_id INT,state VARCHAR(50),year INT,month INT,day INT,water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id,state,year,month,day,water_consumption) VALUES (8,'Washington',2022,1,1,12345.6),(8,'Washington',2022,1,2,23456.7),(8,'Washington',2022,1,3,34567.8); | SELECT MAX(water_consumption) as max_water_consumption FROM water_treatment_plant WHERE plant_id = 8 AND state = 'Washington' AND year = 2022; |
What is the maximum daily water usage in MWh for the industrial sector in October 2021? | CREATE TABLE max_daily_water_usage (year INT,month INT,sector VARCHAR(20),day INT,usage FLOAT); INSERT INTO max_daily_water_usage (year,month,sector,day,usage) VALUES (2021,10,'industrial',1,8000); INSERT INTO max_daily_water_usage (year,month,sector,day,usage) VALUES (2021,10,'industrial',2,8500); INSERT INTO max_daily_water_usage (year,month,sector,day,usage) VALUES (2021,10,'industrial',3,9000); | SELECT MAX(usage) FROM max_daily_water_usage WHERE year = 2021 AND month = 10 AND sector = 'industrial'; |
What is the total distance covered in miles by users during their workouts in the month of May 2022? | CREATE TABLE Workouts (UserID INT,Distance FLOAT,WorkoutDate DATE); INSERT INTO Workouts (UserID,Distance,WorkoutDate) VALUES (1,3.5,'2022-05-01'),(1,2.8,'2022-05-03'),(2,4.2,'2022-05-02'),(2,5.1,'2022-05-04'); | SELECT SUM(Distance) FROM Workouts WHERE WorkoutDate BETWEEN '2022-05-01' AND '2022-05-31'; |
What is the total number of 'Strength Training' sessions? | CREATE TABLE Workouts (WorkoutID INT,WorkoutType VARCHAR(20),MemberID INT); INSERT INTO Workouts (WorkoutID,WorkoutType,MemberID) VALUES (1,'Strength Training',1),(2,'Yoga',2),(3,'Strength Training',3); | SELECT COUNT(*) FROM Workouts WHERE WorkoutType = 'Strength Training'; |
Minimum safety score for AI models developed in Q3 2021. | CREATE TABLE ai_safety (model_name TEXT,safety_score INTEGER,quarter TEXT); INSERT INTO ai_safety (model_name,safety_score,quarter) VALUES ('ModelA',88,'Q3'),('ModelB',92,'Q2'),('ModelC',75,'Q3'); | SELECT MIN(safety_score) FROM ai_safety WHERE quarter = 'Q3' AND YEAR(STR_TO_DATE(quarter, '%Y-%q')) = 2021; |
Who are the manufacturers with the highest number of overdue maintenance for electrical components? | CREATE TABLE Equipment (EquipmentID INT,EquipmentName VARCHAR(50),Type VARCHAR(50),Manufacturer VARCHAR(50)); INSERT INTO Equipment (EquipmentID,EquipmentName,Type,Manufacturer) VALUES (1,'Component1','Electrical','Manufacturer1'); CREATE TABLE Maintenance (EquipmentID INT,EquipmentName VARCHAR(50),Manufacturer VARCHAR(50),LastMaintenance DATE,NextMaintenance DATE); INSERT INTO Maintenance (EquipmentID,EquipmentName,Manufacturer,LastMaintenance,NextMaintenance) VALUES (1,'Component1','Manufacturer1','2021-12-01','2022-06-01'); | SELECT M.Manufacturer, COUNT(*) AS OverdueCount FROM Equipment E JOIN Maintenance M ON E.EquipmentID = M.EquipmentID WHERE DATEDIFF(day, M.NextMaintenance, GETDATE()) > 0 GROUP BY M.Manufacturer ORDER BY OverdueCount DESC; |
Add a new record to the "events" table | CREATE TABLE events (event_id INT PRIMARY KEY,event_name VARCHAR(100),event_location VARCHAR(100),start_time DATETIME,end_time DATETIME,attendance INT); | INSERT INTO events (event_id, event_name, event_location, start_time, end_time, attendance) VALUES (5001, 'Art Exhibition', 'Museum of Modern Art', '2022-09-01 10:00:00', '2022-09-01 17:00:00', 300); |
How many events have been held in each country, in the past three years, broken down by event type? | CREATE TABLE events (event_id INT,event_location VARCHAR(50),event_date DATE,event_type VARCHAR(20)); INSERT INTO events (event_id,event_location,event_date,event_type) VALUES (1,'USA','2021-01-01','Concert'); INSERT INTO events (event_id,event_location,event_date,event_type) VALUES (2,'Canada','2021-03-15','Theater'); INSERT INTO events (event_id,event_location,event_date,event_type) VALUES (3,'France','2020-10-10','Exhibition'); | SELECT SUBSTRING(event_location, 1, INSTR(event_location, '-') - 1) as country, event_type, COUNT(*) as num_events FROM events WHERE event_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY country, event_type; |
What is the average age of attendees for music concerts? | CREATE TABLE events (event_id INT PRIMARY KEY,event_name VARCHAR(50),event_type VARCHAR(50),attendance INT,city VARCHAR(50)); CREATE TABLE audience (audience_id INT PRIMARY KEY,audience_name VARCHAR(50),age INT,gender VARCHAR(50),event_id INT,FOREIGN KEY (event_id) REFERENCES events(event_id)); | SELECT AVG(audience.age) AS avg_age FROM events INNER JOIN audience ON events.event_id = audience.event_id WHERE events.event_type = 'Music Concert'; |
What is the total donation amount by month for the year 2020, in descending order? | CREATE TABLE Donations (id INT,donor_name VARCHAR(100),donation_amount DECIMAL(10,2),donation_date DATE,event_id INT); | SELECT DATE_TRUNC('month', donation_date) as donation_month, SUM(donation_amount) as total_donations FROM Donations WHERE donation_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY donation_month ORDER BY total_donations DESC; |
What is the maximum hourly wage for each labor category in the construction industry? | CREATE TABLE labor_statistics (id INT,industry VARCHAR(255),category VARCHAR(255),title VARCHAR(255),hourly_wage DECIMAL(5,2)); | SELECT industry, category, MAX(hourly_wage) as max_hourly_wage FROM labor_statistics WHERE industry = 'construction' GROUP BY industry, category; |
Delete sales records for IL dispensaries from January 2022? | CREATE TABLE sales (id INT,dispensary_id INT,quantity INT,month TEXT,year INT); INSERT INTO sales (id,dispensary_id,quantity,month,year) VALUES (1,1,25,'January',2022),(2,2,30,'January',2022); CREATE TABLE dispensaries (id INT,name TEXT,state TEXT); INSERT INTO dispensaries (id,name,state) VALUES (1,'Dispensary A','Illinois'),(2,'Dispensary B','Illinois'); | DELETE s FROM sales s JOIN dispensaries d ON s.dispensary_id = d.id WHERE d.state = 'Illinois' AND s.month = 'January' AND s.year = 2022; |
How many dispensaries in Michigan have a loyalty program? | CREATE TABLE dispensaries (id INT,name VARCHAR(50),state VARCHAR(50),loyalty_program BOOLEAN); | SELECT COUNT(*) FROM dispensaries WHERE state = 'MI' AND loyalty_program = TRUE; |
What is the average billing amount for cases handled by female attorneys? | CREATE TABLE attorneys (attorney_id INT,name TEXT,gender TEXT); INSERT INTO attorneys (attorney_id,name,gender) VALUES (1,'Jane Smith','Female'),(2,'Bob Johnson','Male'); CREATE TABLE cases (case_id INT,attorney_id INT,billing_amount INT); INSERT INTO cases (case_id,attorney_id,billing_amount) VALUES (1,1,5000),(2,1,7000),(3,2,6000); | SELECT AVG(billing_amount) FROM cases WHERE attorney_id IN (SELECT attorney_id FROM attorneys WHERE gender = 'Female') |
What is the total billing amount for cases in the 'Criminal Law' category? | CREATE TABLE Cases (CaseID INT,CaseType VARCHAR(255),BillingAmount DECIMAL); | SELECT SUM(BillingAmount) FROM Cases WHERE CaseType = 'Criminal Law'; |
What is the total billing amount for cases won by the top 3 attorneys? | CREATE TABLE attorneys (id INT,name VARCHAR(50),total_billing_amount DECIMAL(10,2)); CREATE TABLE cases (id INT,attorney_id INT,case_outcome VARCHAR(10)); | SELECT SUM(total_billing_amount) FROM (SELECT attorney_id, SUM(billing_amount) AS total_billing_amount FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE case_outcome = 'won' GROUP BY attorney_id ORDER BY total_billing_amount DESC LIMIT 3); |
Delete records in 'chemical_usage' table where 'usage_date' is before '2022-01-01' | CREATE TABLE chemical_usage (id INT,chemical_name VARCHAR(50),usage_quantity INT,usage_date DATE); | DELETE FROM chemical_usage WHERE usage_date < '2022-01-01'; |
What is the average temperature reading for all chemical storage tanks in the past month? | CREATE TABLE chemical_storage_tanks (tank_id INT,temperature FLOAT,reading_date DATE); INSERT INTO chemical_storage_tanks (tank_id,temperature,reading_date) VALUES (1,25.6,'2022-01-01'),(2,24.3,'2022-01-01'); | SELECT AVG(temperature) FROM chemical_storage_tanks WHERE reading_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
Add a new record for a non-binary founder from India to the "company_founding_data" table | CREATE TABLE company_founding_data (id INT PRIMARY KEY,company_id INT,founder_id INT,founder_name VARCHAR(50),founder_gender VARCHAR(10)); INSERT INTO company_founding_data (id,company_id,founder_id,founder_name,founder_gender) VALUES (1,1001,1,'John Doe','male'),(2,1002,2,'Jane Smith','female'),(3,1003,3,'Alice Johnson','female'); | INSERT INTO company_founding_data (id, company_id, founder_id, founder_name, founder_gender) VALUES (4, 1004, 4, 'Alex Khan', 'non-binary'); |
Insert a new decentralized application into the decentralized_applications table with the given details. | CREATE TABLE decentralized_applications (app_id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(50),launch_date DATETIME); | INSERT INTO decentralized_applications (app_id, name, category, launch_date) VALUES (6, 'App6', 'Gaming', '2022-04-01 10:00:00'); |
What is the maximum consumer preference score for vegan cosmetics? | CREATE TABLE Brands (BrandName VARCHAR(50),Vegan BOOLEAN,ConsumerPreferenceScore INT); INSERT INTO Brands (BrandName,Vegan,ConsumerPreferenceScore) VALUES ('Pacifica',TRUE,88),('NYX',FALSE,82),('e.l.f.',TRUE,79); | SELECT MAX(ConsumerPreferenceScore) FROM Brands WHERE Vegan = TRUE; |
What is the total revenue for cosmetics products that are not cruelty-free? | CREATE TABLE product (product_id INT,name TEXT,price FLOAT,cruelty_free BOOLEAN); CREATE TABLE sales (sale_id INT,product_id INT,quantity INT); | SELECT SUM(price * quantity) FROM product INNER JOIN sales ON product.product_id = sales.product_id WHERE cruelty_free = FALSE; |
How many military equipment maintenance requests were submitted per month in 2020? | CREATE TABLE maintenance (request_id INT,request_date DATE,equipment_type VARCHAR(255)); INSERT INTO maintenance (request_id,request_date,equipment_type) VALUES (1,'2020-02-12','tank'),(2,'2020-04-15','plane'),(3,'2019-10-27','ship'); | SELECT EXTRACT(MONTH FROM request_date) AS month, COUNT(*) AS num_requests FROM maintenance WHERE request_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY month; |
What is the average time to resolve maintenance requests for military equipment, by equipment type, for the year 2021? | CREATE TABLE MaintenanceRequests (id INT,EquipmentType VARCHAR(50),RequestDate DATE,ResolutionDate DATE); INSERT INTO MaintenanceRequests (id,EquipmentType,RequestDate,ResolutionDate) VALUES (1,'Tank','2021-01-01','2021-01-05'),(2,'Helicopter','2021-02-01','2021-02-10'),(3,'Tank','2021-03-01','2021-03-03'); | SELECT EquipmentType, AVG(DATEDIFF(ResolutionDate, RequestDate)) as AverageResolutionTime FROM MaintenanceRequests WHERE RequestDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY EquipmentType; |
What is the total number of veterans employed in the defense industry by region? | CREATE TABLE Veteran_Employment (id INT,region VARCHAR(50),industry VARCHAR(50),employed_count INT); | SELECT region, SUM(employed_count) FROM Veteran_Employment WHERE industry = 'defense' GROUP BY region; |
What is the total number of defense diplomacy events in which each country has participated, ranked from highest to lowest? | CREATE TABLE defense_diplomacy_4 (id INT,year INT,country VARCHAR(255),event VARCHAR(255)); INSERT INTO defense_diplomacy_4 (id,year,country,event) VALUES (1,2015,'USA','Event1'),(2,2016,'China','Event2'),(3,2017,'Russia','Event3'),(4,2018,'India','Event4'),(5,2019,'Germany','Event5'),(6,2015,'Brazil','Event6'),(7,2016,'South Africa','Event7'),(8,2017,'Canada','Event8'),(9,2018,'Japan','Event9'),(10,2019,'France','Event10'); | SELECT country, COUNT(event) AS total_events FROM defense_diplomacy_4 GROUP BY country ORDER BY total_events DESC; |
What was the total military spending by NATO members in 2020? | CREATE TABLE nato_spending (country VARCHAR(50),year INT,amount FLOAT); INSERT INTO nato_spending (country,year,amount) VALUES ('USA',2020,778000000),('UK',2020,592000000),('Germany',2020,528000000),('France',2020,507000000),('Italy',2020,275000000),('Canada',2020,242000000); | SELECT SUM(amount) FROM nato_spending WHERE year = 2020 AND country IN ('USA', 'UK', 'Germany', 'France', 'Italy', 'Canada', 'Belgium', 'Netherlands', 'Norway', 'Spain', 'Turkey'); |
List the number of vessels and their total cargo handling volume for each country in the 'fleet_management' and 'port_operations' schemas. | CREATE TABLE fleet_management.vessels (id INT,name VARCHAR(50),year_built INT,country VARCHAR(50)); CREATE TABLE port_operations.cargo_handling (id INT,port_id INT,volume INT,vessel_id INT); CREATE TABLE port_operations.ports (id INT,name VARCHAR(50),location VARCHAR(50),country VARCHAR(50)); | SELECT fm.country, COUNT(fm.id), SUM(co.volume) FROM fleet_management.vessels fm INNER JOIN port_operations.cargo_handling co ON fm.id = co.vessel_id INNER JOIN port_operations.ports p ON co.port_id = p.id GROUP BY fm.country; |
Get top 3 states with highest prevalence | CREATE TABLE if not exists 'disease_data' (id INT,state TEXT,disease TEXT,prevalence INT,PRIMARY KEY(id)); | SELECT state, AVG(prevalence) AS 'Avg Prevalence' FROM 'disease_data' GROUP BY state ORDER BY 'Avg Prevalence' DESC LIMIT 3; |
What is the total number of hospital beds and their distribution across rural and urban areas in Alaska? | CREATE TABLE hospitals(id INT,name TEXT,location TEXT,num_beds INT); INSERT INTO hospitals(id,name,location,num_beds) VALUES (1,'Hospital A','Alaska Rural',50),(2,'Hospital B','Alaska Rural',75),(3,'Hospital C','Alaska Urban',200),(4,'Hospital D','Alaska Urban',300); | SELECT location, SUM(num_beds) as total_beds, AVG(num_beds) as avg_beds FROM hospitals GROUP BY location; |
Update the 'equipment_status' to 'Active' for the record with 'equipment_id' 2 in the 'military_equipment' table | CREATE TABLE military_equipment (equipment_id INT PRIMARY KEY,equipment_name VARCHAR(100),equipment_type VARCHAR(50),equipment_status VARCHAR(20)); INSERT INTO military_equipment (equipment_id,equipment_name,equipment_type,equipment_status) VALUES (1,'F-16 Fighting Falcon','Aircraft','Inactive'),(2,'M1 Abrams','Tank','Retired'),(3,'Tomahawk Cruise Missile','Missile','Active'); | UPDATE military_equipment SET equipment_status = 'Active' WHERE equipment_id = 2; |
What is the total budget allocated for military technology research and development from 2019 to 2022? | CREATE TABLE rnd_budget_history (fiscal_year INT,amount INT,category TEXT);INSERT INTO rnd_budget_history (fiscal_year,amount,category) VALUES (2019,2000000,'Military Technology Research and Development');INSERT INTO rnd_budget_history (fiscal_year,amount,category) VALUES (2020,2500000,'Military Technology Research and Development');INSERT INTO rnd_budget_history (fiscal_year,amount,category) VALUES (2021,3000000,'Military Technology Research and Development');INSERT INTO rnd_budget_history (fiscal_year,amount,category) VALUES (2022,3500000,'Military Technology Research and Development'); | SELECT SUM(amount) FROM rnd_budget_history WHERE category = 'Military Technology Research and Development' AND fiscal_year BETWEEN 2019 AND 2022; |
How many streams of Country music were there in the United States in February 2021? | CREATE TABLE streams (song_id INT,stream_date DATE,genre VARCHAR(20),country VARCHAR(20),revenue DECIMAL(10,2)); INSERT INTO streams (song_id,stream_date,genre,country,revenue) VALUES (12,'2021-02-28','Country','USA',6.00); | SELECT COUNT(*) FROM streams WHERE genre = 'Country' AND country = 'USA' AND stream_date BETWEEN '2021-02-01' AND '2021-02-28'; |
How many wells were drilled in the Eagle Ford Shale and Bakken Formation? | CREATE TABLE wells (id INT,region VARCHAR(255),well_type VARCHAR(255),num_drilled INT); INSERT INTO wells (id,region,well_type,num_drilled) VALUES (1,'Eagle Ford Shale','Oil',2000),(2,'Eagle Ford Shale','Gas',1500),(3,'Bakken Formation','Oil',1000),(4,'Bakken Formation','Gas',1200); | SELECT SUM(num_drilled) as total_wells FROM wells WHERE region IN ('Eagle Ford Shale', 'Bakken Formation'); |
Delete records of athletes who haven't participated in any games | CREATE TABLE athletes (athlete_id INT,name VARCHAR(50),sport VARCHAR(50)); INSERT INTO athletes (athlete_id,name,sport) VALUES (1,'John Doe','Basketball'),(2,'Jane Smith','Soccer'); CREATE TABLE games (game_id INT,athlete_id INT,points INT); INSERT INTO games (game_id,athlete_id,points) VALUES (1,1,20),(2,1,30),(3,NULL,10); | DELETE FROM athletes WHERE athlete_id NOT IN (SELECT athlete_id FROM games WHERE athlete_id IS NOT NULL); |
List the players and their average points per game in the "nba_games" table | CREATE TABLE nba_games (player VARCHAR(255),points INTEGER,games_played INTEGER); | SELECT player, AVG(points) as avg_points_per_game FROM nba_games GROUP BY player; |
How many natural disasters were reported in South America in the year 2020? | CREATE TABLE disasters (id INT,type TEXT,location TEXT,year INT); INSERT INTO disasters (id,type,location,year) VALUES (1,'Flood','South America',2020),(2,'Earthquake','Asia',2019),(3,'Tornado','North America',2020); | SELECT COUNT(*) FROM disasters WHERE location = 'South America' AND year = 2020; |
List the top 2 sectors with the highest donation amounts in the 'Asia' region for the year 2018, ordered by the donation amount in descending order. | CREATE TABLE Donors (donor_id INT,donor_name VARCHAR(255),donation_amount INT,sector VARCHAR(255),region VARCHAR(255),donation_date DATE); INSERT INTO Donors (donor_id,donor_name,donation_amount,sector,region,donation_date) VALUES (1,'DonorA',100000,'Health','Asia','2018-01-01'); | SELECT sector, SUM(donation_amount) AS total_donation FROM Donors WHERE region = 'Asia' AND donation_date >= '2018-01-01' AND donation_date < '2019-01-01' GROUP BY sector ORDER BY total_donation DESC LIMIT 2; |
List the digital divide projects led by historically underrepresented communities in the technology for social good domain. | CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),LeaderCommunity VARCHAR(50),Domain VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,LeaderCommunity,Domain) VALUES (1,'Bridging the Gap','Historically Underrepresented Community 1','Social Good'); INSERT INTO Projects (ProjectID,ProjectName,LeaderCommunity,Domain) VALUES (2,'Tech4All','Historically Underrepresented Community 2','Social Good'); | SELECT ProjectName FROM Projects WHERE LeaderCommunity LIKE '%Historically Underrepresented%' AND Domain = 'Social Good'; |
What are the ethical AI principles for the technology projects in India? | CREATE TABLE EthicalAI (principle_id INT,principle_name VARCHAR(50),project_location VARCHAR(20)); INSERT INTO EthicalAI (principle_id,principle_name,project_location) VALUES (1,'Fairness','India'),(2,'Accountability','India'),(3,'Transparency','India'),(4,'Data Minimization','India'),(5,'Explainability','India'),(6,'Human Oversight','India'); | SELECT principle_name FROM EthicalAI WHERE project_location = 'India'; |
What is the average budget allocated to ethical AI initiatives by companies in the technology sector? | CREATE TABLE company_tech (name TEXT,budget INTEGER); INSERT INTO company_tech (name,budget) VALUES ('TechCo',500000),('EthicalAI',700000),('GoodTech',600000); | SELECT AVG(budget) FROM company_tech WHERE name IN ('TechCo', 'EthicalAI', 'GoodTech') AND budget > 0; |
What is the minimum salary of employees in the Social Good team? | CREATE TABLE salaries (id INT,employee_id INT,team VARCHAR(50),salary FLOAT); INSERT INTO salaries (id,employee_id,team,salary) VALUES (1,1,'Social Good',60000.00),(2,2,'Ethical AI',65000.00),(3,3,'Social Good',58000.00); | SELECT MIN(salary) FROM salaries WHERE team = 'Social Good'; |
How many circular economy initiatives were implemented in Q1 2022? | CREATE TABLE circular_economy_initiatives (initiative_id INT PRIMARY KEY,initiative_date DATE); | SELECT COUNT(*) FROM circular_economy_initiatives WHERE initiative_date >= '2022-01-01' AND initiative_date < '2022-04-01'; |
Update the customer_sizes table to change the size to 'Small' for the customer_id 1002 | CREATE TABLE customer_sizes (customer_id INT PRIMARY KEY,size VARCHAR(255)); INSERT INTO customer_sizes (customer_id,size) VALUES (1001,'Medium'),(1002,'Large'),(1003,'Small'); | UPDATE customer_sizes SET size = 'Small' WHERE customer_id = 1002; |
What is the total amount donated for each program, ordered by the total amount in descending order? | CREATE TABLE Donations (DonationID INT,DonorID INT,Program TEXT,Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID,DonorID,Program,Amount) VALUES (1,1,'ProgramA',100.00),(2,1,'ProgramB',200.00),(3,2,'ProgramA',50.00); | SELECT Program, SUM(Amount) AS TotalDonated FROM Donations GROUP BY Program ORDER BY TotalDonated DESC; |
Determine the average calorie count for vegetarian dishes | CREATE TABLE menu_items (item_id INT,item_name VARCHAR(50),is_vegetarian BOOLEAN,calorie_count INT); | SELECT AVG(calorie_count) as avg_calories FROM menu_items WHERE is_vegetarian = TRUE; |
How many units of each product were sold in the "East" region? | CREATE TABLE Sales(region VARCHAR(20),product VARCHAR(20),quantity INT); INSERT INTO Sales(region,product,quantity) VALUES('East','Organic Apples',50),('West','Organic Apples',75),('East','Bananas',30); | SELECT region, product, SUM(quantity) as total_quantity FROM Sales GROUP BY region, product HAVING region = 'East'; |
How many pallets are stored in each warehouse in France? | CREATE TABLE Inventory (id INT,warehouse_id INT,pallets INT); INSERT INTO Inventory (id,warehouse_id,pallets) VALUES (1,1,100),(2,1,200),(3,2,150); CREATE TABLE Warehouses (id INT,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50)); INSERT INTO Warehouses (id,name,city,country) VALUES (1,'Warehouse A','City A','France'),(2,'Warehouse B','City B','Country B'); | SELECT w.name, SUM(i.pallets) FROM Inventory i JOIN Warehouses w ON i.warehouse_id = w.id WHERE w.country = 'France' GROUP BY w.id; |
What is the total number of packages shipped from the 'Paris' warehouse to 'Berlin' in February 2021, if available, having a weight greater than 15 kg? | CREATE TABLE warehouse (id INT,name VARCHAR(20)); CREATE TABLE shipment (id INT,warehouse_id INT,delivery_location VARCHAR(20),shipped_date DATE,weight FLOAT); INSERT INTO warehouse (id,name) VALUES (1,'Seattle'),(2,'NY'),(3,'LA'),(4,'Paris'); INSERT INTO shipment (id,warehouse_id,delivery_location,shipped_date,weight) VALUES (1,4,'Berlin','2021-02-02',18.5),(2,4,'Berlin','2021-02-05',12.2),(3,2,'LA','2021-03-25',12.2); | SELECT COUNT(*) AS total_packages FROM shipment WHERE warehouse_id = 4 AND delivery_location = 'Berlin' AND shipped_date >= '2021-02-01' AND shipped_date < '2021-03-01' AND weight > 15; |
Who is the principal investigator for the 'Genetic Diversity in Amazon Rainforest' study? | CREATE SCHEMA if not exists genetics; USE genetics; CREATE TABLE if not exists genetic_research (id INT PRIMARY KEY,study_name VARCHAR(255),principal_investigator VARCHAR(255)); INSERT INTO genetic_research (id,study_name,principal_investigator) VALUES (1,'Genetic Diversity in Amazon Rainforest','Dr. Carlos Mendoza'),(2,'Genome Analysis in Andean Potatoes','Dr. Maria Paz'),(3,'CRISPR in Tropical Plants','Dr. Eduardo Lopez'); | SELECT principal_investigator FROM genetics.genetic_research WHERE study_name = 'Genetic Diversity in Amazon Rainforest'; |
List the unique types of smart city technologies that have been implemented in the top 3 most populous countries in the world. | CREATE TABLE smart_city_tech (tech_type VARCHAR(255),country VARCHAR(255)); CREATE TABLE country_populations (country VARCHAR(255),population INT); | SELECT DISTINCT tech_type FROM smart_city_tech SCT WHERE country IN (SELECT country FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY population DESC) as rank FROM country_populations) CP WHERE rank <= 3); |
Add a new column "total_revenue" to the "hotel_reviews" table | CREATE TABLE hotel_reviews (hotel_id INT,review_date DATE,review_score INT); | ALTER TABLE hotel_reviews ADD total_revenue FLOAT; |
What is the number of patients who improved by treatment type? | CREATE TABLE treatment_improvement (patient_id INT,therapy_type VARCHAR(50),improvement BOOLEAN); INSERT INTO treatment_improvement (patient_id,therapy_type,improvement) VALUES (1,'CBT',TRUE); | SELECT therapy_type, SUM(improvement) FROM treatment_improvement GROUP BY therapy_type; |
What is the number of patients who received therapy in the last 6 months in Texas? | CREATE TABLE patient (patient_id INT,age INT,gender VARCHAR(50),state VARCHAR(50),registration_date DATE); INSERT INTO patient (patient_id,age,gender,state,registration_date) VALUES (1,35,'Female','Texas','2020-06-15'); INSERT INTO patient (patient_id,age,gender,state,registration_date) VALUES (2,42,'Male','California','2021-01-01'); CREATE TABLE treatment (treatment_id INT,patient_id INT,treatment_name VARCHAR(50),duration INT,treatment_date DATE); INSERT INTO treatment (treatment_id,patient_id,treatment_name,duration,treatment_date) VALUES (1,1,'CBT',12,'2021-02-01'); INSERT INTO treatment (treatment_id,patient_id,treatment_name,duration,treatment_date) VALUES (2,2,'DBT',16,'2020-12-15'); | SELECT COUNT(DISTINCT patient.patient_id) FROM patient INNER JOIN treatment ON patient.patient_id = treatment.patient_id WHERE patient.state = 'Texas' AND treatment.treatment_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
How many international tourists visited Portugal in 2020, broken down by continent? | CREATE TABLE international_tourists(tourist_id INT,country TEXT,arrival_year INT,continent TEXT);INSERT INTO international_tourists (tourist_id,country,arrival_year,continent) VALUES (1,'Spain',2020,'Europe'),(2,'France',2020,'Europe'),(3,'Brazil',2020,'South America'),(4,'United States',2020,'North America'),(5,'China',2020,'Asia'); | SELECT continent, COUNT(*) FROM international_tourists WHERE arrival_year = 2020 GROUP BY continent; |
Which destinations had a decrease in visitors from 2022 to 2023? | CREATE TABLE if not exists VisitorStatisticsByYear (Year INT,Destination VARCHAR(50),Visitors INT); INSERT INTO VisitorStatisticsByYear (Year,Destination,Visitors) VALUES (2022,'Paris',1250000),(2023,'Paris',1230000),(2022,'Rome',920000),(2023,'Rome',910000); | SELECT a.Destination, (b.Visitors - a.Visitors) AS VisitorChange FROM VisitorStatisticsByYear a, VisitorStatisticsByYear b WHERE a.Destination = b.Destination AND a.Year = 2022 AND b.Year = 2023; |
What are the names of all victims who have participated in restorative justice programs in the state of New York? | CREATE TABLE restorative_justice_programs (victim_name TEXT,program_state TEXT); INSERT INTO restorative_justice_programs (victim_name,program_state) VALUES ('Sarah Lee','New York'); | SELECT victim_name FROM restorative_justice_programs WHERE program_state = 'New York'; |
How many unique genres are associated with media published in each country? | CREATE TABLE media (id INT,title VARCHAR(50),location VARCHAR(50),genre VARCHAR(50)); INSERT INTO media (id,title,location,genre) VALUES (1,'Article 1','USA','News'),(2,'Article 2','Canada','Entertainment'),(3,'News 1','USA','Politics'),(4,'News 2','Canada','Sports'); | SELECT location, COUNT(DISTINCT genre) FROM media GROUP BY location; |
How many gluten-free menu items were sold in the second quarter of 2022? | CREATE TABLE menus (menu_id INT,menu_name TEXT,type TEXT,price DECIMAL,quarter DATE); INSERT INTO menus (menu_id,menu_name,type,price,quarter) VALUES (1,'Quinoa Salad','Vegetarian',12.99,'2022-01-01'),(2,'Chicken Caesar Wrap','Gluten-free',10.99,'2022-02-15'); | SELECT COUNT(*) FROM menus WHERE type = 'Gluten-free' AND quarter = '2022-02-15'; |
What is the total quantity of organic items sold? | CREATE TABLE supplier_data_2 (supplier_id INT,location_id INT,item_id INT,quantity_sold INT,is_organic BOOLEAN); INSERT INTO supplier_data_2 (supplier_id,location_id,item_id,quantity_sold,is_organic) VALUES (1,1,1,30,TRUE),(2,2,3,70,FALSE); | SELECT SUM(quantity_sold) FROM supplier_data_2 WHERE is_organic = TRUE; |
What is the total revenue generated from 4G and 5G services for customers in North America, broken down by service type and state? | CREATE TABLE subscribers (id INT,service VARCHAR(20),state VARCHAR(20),revenue DECIMAL(10,2)); | SELECT service, state, SUM(revenue) FROM subscribers WHERE service IN ('4G', '5G') AND state IS NOT NULL GROUP BY service, state; |
What are the total ticket sales for all concerts in the United States and Canada? | CREATE TABLE concerts (id INT,country VARCHAR(255),city VARCHAR(255),artist_name VARCHAR(255),tier VARCHAR(255),price DECIMAL(10,2),num_tickets INT); | SELECT SUM(price * num_tickets) FROM concerts WHERE country IN ('United States', 'Canada'); |
What was the average donation amount by age group in 2021? | CREATE TABLE DonorAge (DonorID int,DonorAge int); INSERT INTO DonorAge (DonorID,DonorAge) VALUES (1,30); INSERT INTO DonorAge (DonorID,DonorAge) VALUES (2,40); CREATE TABLE DonationsByAge (DonationID int,DonorID int,DonationAmount int); INSERT INTO DonationsByAge (DonationID,DonorID,DonationAmount) VALUES (1,1,50); INSERT INTO DonationsByAge (DonationID,DonorID,DonationAmount) VALUES (2,2,100); | SELECT AVG(DonationAmount) as AverageDonation, CASE WHEN DonorAge < 30 THEN 'Under 30' WHEN DonorAge BETWEEN 30 AND 50 THEN '30-50' ELSE 'Over 50' END as AgeGroup FROM DonationsByAge DBA JOIN DonorAge DA ON DBA.DonorID = DA.DonorID WHERE DonationDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY AgeGroup; |
How many marine protected areas exist in the Indian Ocean as of 2022? | CREATE TABLE protected_areas (id INT,ocean VARCHAR(50),year INT,num_areas INT); INSERT INTO protected_areas (id,ocean,year,num_areas) VALUES (1,'Indian Ocean',2018,123),(2,'Indian Ocean',2019,156),(3,'Indian Ocean',2022,NULL); | SELECT num_areas FROM protected_areas WHERE ocean = 'Indian Ocean' AND year = 2022; |
How many donations have been made to organizations focused on education by donors from the US and Canada in the last 12 months? | CREATE TABLE donors (id INT,name VARCHAR(255),country VARCHAR(255));CREATE TABLE donations (id INT,donor_id INT,cause_id INT,amount DECIMAL(10,2),donation_date DATE);CREATE TABLE causes (id INT,name VARCHAR(255),category VARCHAR(255));CREATE VIEW v_us_canada AS SELECT 'US' AS country UNION ALL SELECT 'Canada'; | SELECT COUNT(*) FROM donations d INNER JOIN donors dn ON d.donor_id = dn.id INNER JOIN causes c ON d.cause_id = c.id INNER JOIN v_us_canada v ON dn.country = v.country WHERE d.donation_date >= DATE_SUB(NOW(), INTERVAL 12 MONTH) AND c.category = 'education'; |
What is the average level achieved per hour played for players in the "Cybernetic Pioneers" game? | CREATE TABLE PioneerStats (PlayerID INT,GameName VARCHAR(20),Level INT,Playtime FLOAT); INSERT INTO PioneerStats (PlayerID,GameName,Level,Playtime) VALUES (3001,'Cybernetic Pioneers',10,20.5),(3002,'Cybernetic Pioneers',25,40.2),(3003,'Cybernetic Pioneers',18,15.6); | SELECT AVG(Level * 1.0 / Playtime) FROM PioneerStats WHERE GameName = 'Cybernetic Pioneers'; |
What is the total revenue generated from esports events in Asia in 2022? | CREATE TABLE EsportsEvents (EventID INT PRIMARY KEY,EventType VARCHAR(20),Region VARCHAR(10),Revenue INT,EventYear INT); INSERT INTO EsportsEvents (EventID,EventType,Region,Revenue,EventYear) VALUES (1,'Tournament','Asia',500000,2022); INSERT INTO EsportsEvents (EventID,EventType,Region,Revenue,EventYear) VALUES (2,'Exhibition','NA',300000,2021); | SELECT SUM(Revenue) FROM EsportsEvents WHERE EventType = 'Tournament' AND Region = 'Asia' AND EventYear = 2022; |
Identify the top 3 mining companies with the highest total production of Praseodymium in 2021 and their respective production amounts. | CREATE TABLE Company (Name TEXT,Location TEXT,Established INT); INSERT INTO Company (Name,Location,Established) VALUES ('Delta Minerals','Brazil',2000),('Epsilon Ore','South Africa',2010),('Zeta Extraction','Canada',2005),('Eta Mines','Russia',2008); CREATE TABLE ProductionCompany (Year INT,Company TEXT,Element TEXT,Quantity INT); INSERT INTO ProductionCompany (Year,Company,Element,Quantity) VALUES (2021,'Delta Minerals','Praseodymium',1000),(2021,'Epsilon Ore','Praseodymium',1400),(2021,'Zeta Extraction','Praseodymium',1800),(2021,'Eta Mines','Praseodymium',1100); | SELECT Company, SUM(Quantity) FROM ProductionCompany WHERE Element = 'Praseodymium' AND Year = 2021 GROUP BY Company ORDER BY SUM(Quantity) DESC FETCH FIRST 3 ROWS ONLY; |
List the names, addresses, and housing affordability scores of properties in Los Angeles with sustainable urbanism certifications, and show only those with scores below 60. | CREATE TABLE properties (property_id INT,name VARCHAR(255),address VARCHAR(255),city VARCHAR(255),sustainable_urbanism_certified BOOLEAN,housing_affordability_score INT); INSERT INTO properties (property_id,name,address,city,sustainable_urbanism_certified,housing_affordability_score) VALUES (1,'Green Living','123 Main St','Los Angeles',true,85),(2,'Eco Haven','456 Oak St','Los Angeles',false,60),(3,'Sustainable Suites','789 Pine St','Los Angeles',true,55); | SELECT name, address, housing_affordability_score FROM properties WHERE city = 'Los Angeles' AND sustainable_urbanism_certified = true AND housing_affordability_score < 60; |
What is the minimum property tax for properties with more than 3 bedrooms in Vancouver? | CREATE TABLE buildings (id INT,city VARCHAR,size INT,num_bedrooms INT,property_tax DECIMAL); | SELECT MIN(property_tax) FROM buildings WHERE city = 'Vancouver' AND num_bedrooms > 3; |
Get the number of renewable energy projects in Australia for each project type. | CREATE TABLE renewable_projects (id INT PRIMARY KEY,project_name VARCHAR(255),project_location VARCHAR(255),project_type VARCHAR(255),capacity_mw FLOAT); | SELECT project_type, COUNT(*) FROM renewable_projects WHERE project_location = 'Australia' GROUP BY project_type; |
How many electric vehicles were sold in Texas in 2021? | CREATE TABLE electric_vehicles (id INT,year INT,state VARCHAR(255),sales INT); INSERT INTO electric_vehicles (id,year,state,sales) VALUES (1,2020,'California',50000),(2,2021,'California',60000),(3,2021,'Texas',70000); | SELECT SUM(sales) FROM electric_vehicles WHERE state = 'Texas' AND year = 2021; |
Update the inventory count of 'Impossible Burger' to 25 in the menu_items table | CREATE TABLE menu_items (item_id INT,item_name TEXT,category TEXT,price DECIMAL(5,2),inventory_count INT); | UPDATE menu_items SET inventory_count = 25 WHERE item_name = 'Impossible Burger'; |
Display the number of times each consumer education event was attended, along with the event location and capacity. | CREATE TABLE events (event_id INT,event_name VARCHAR(255),event_location VARCHAR(255),event_capacity INT);CREATE TABLE attendees (attendee_id INT,FK_event_id REFERENCES events(event_id)); | SELECT e.event_location, e.event_name, COUNT(a.attendee_id) as attendance_count FROM events e JOIN attendees a ON e.event_id = a.event_id GROUP BY e.event_id, e.event_location, e.event_name; |
What is the daily sales trend for the top 5 retailers in the last week? | CREATE TABLE Retailer (id INT,name VARCHAR(255)); CREATE TABLE Sales (id INT,retailer_id INT,sale_date DATE,revenue FLOAT); | SELECT r.name, sale_date, SUM(revenue) as daily_sales FROM Sales s JOIN Retailer r ON s.retailer_id = r.id WHERE retailer_id IN (SELECT id FROM Retailer ORDER BY SUM(revenue) DESC LIMIT 5) AND sale_date >= (CURRENT_DATE - INTERVAL '1 week') GROUP BY ROLLUP(r.name, sale_date) ORDER BY r.name, sale_date DESC; |
What is the average altitude of all geostationary satellites? | CREATE TABLE geostationary_satellites (id INT,name VARCHAR(50),type VARCHAR(50),altitude INT); INSERT INTO geostationary_satellites (id,name,type,altitude) VALUES (1,'Sat1','Communication',35786),(2,'Sat2','Weather',35800),(3,'Sat3','Observation',35790),(4,'Sat4','Communication',35780),(5,'Sat5','Weather',35810); | SELECT AVG(altitude) FROM geostationary_satellites; |
What is the total cost of all space missions per space agency in the space_missions and space_agencies table? | CREATE TABLE space_agencies (id INT,agency_name VARCHAR(50),country VARCHAR(50)); CREATE TABLE space_missions (id INT,mission_name VARCHAR(50),launch_date DATE,scheduled_date DATE,agency_id INT,cost FLOAT); INSERT INTO space_agencies VALUES (1,'NASA','USA'); INSERT INTO space_missions VALUES (1,'Artemis I','2022-08-29','2022-06-29',1,2400000000); | SELECT agency_name, SUM(cost) OVER (PARTITION BY agency_id) FROM space_agencies sa JOIN space_missions sm ON sa.id = sm.agency_id; |
What is the total number of satellites launched by India and the USA? | CREATE TABLE satellite_launches (id INT,launch_year INT,country VARCHAR(50),satellites INT); INSERT INTO satellite_launches (id,launch_year,country,satellites) VALUES (1,2010,'India',5),(2,2010,'USA',10),(3,2011,'India',7),(4,2011,'USA',15); | SELECT SUM(satellites) FROM satellite_launches WHERE country IN ('India', 'USA'); |
Show the number of athletes with mental health scores above 90 | CREATE TABLE athlete_wellbeing (athlete_id INT,name VARCHAR(100),mental_health_score INT,physical_health_score INT); INSERT INTO athlete_wellbeing (athlete_id,name,mental_health_score,physical_health_score) VALUES (1,'John Doe',80,85),(2,'Jane Smith',95,90),(3,'Mary Johnson',90,95); | SELECT COUNT(*) FROM athlete_wellbeing WHERE mental_health_score > 90; |
What is the maximum ticket price for any event in the 'sports_venue' table? | CREATE TABLE sports_venue (venue_id INT,event_name VARCHAR(255),price DECIMAL(5,2)); INSERT INTO sports_venue (venue_id,event_name,price) VALUES (1,'Basketball Game',120.50),(2,'Baseball Game',35.00),(3,'Football Game',75.00),(4,'Hockey Game',90.00); | SELECT MAX(price) FROM sports_venue; |
What is the total number of tickets sold for each game? | CREATE TABLE games (game_id INT,team_id INT,game_date DATE); INSERT INTO games (game_id,team_id,game_date) VALUES (1,1,'2021-01-01'),(2,1,'2021-01-03'),(3,2,'2021-01-02'),(4,2,'2021-01-04'); | SELECT g.game_date, t.team_name, COUNT(ts.ticket_id) as total_tickets_sold FROM games g JOIN teams t ON g.team_id = t.team_id JOIN ticket_sales ts ON g.game_date = ts.sale_date GROUP BY g.game_date, t.team_name; |
What is the maximum number of simultaneous login attempts allowed by the corporate security policy? | CREATE TABLE security_policies (id INT,policy_name VARCHAR(255),max_simultaneous_logins INT); INSERT INTO security_policies (id,policy_name,max_simultaneous_logins) VALUES (1,'corporate',3); | SELECT MAX(max_simultaneous_logins) FROM security_policies WHERE policy_name = 'corporate'; |
What is the total number of high-severity vulnerabilities for each software vendor in the last 6 months? | create table vulnerabilities (id int,vendor varchar(255),severity int,date date); insert into vulnerabilities values (1,'Microsoft',7,'2022-01-01'); insert into vulnerabilities values (2,'Microsoft',5,'2022-01-05'); insert into vulnerabilities values (3,'Google',8,'2022-01-10'); insert into vulnerabilities values (4,'IBM',2,'2022-04-15'); insert into vulnerabilities values (5,'IBM',9,'2022-07-01'); | SELECT vendor, COUNT(*) FROM vulnerabilities WHERE severity >= 7 AND date >= '2022-01-01' GROUP BY vendor; |
What is the total number of electric vehicles in the ev_charging_stations table for each city? | CREATE TABLE ev_charging_stations (city VARCHAR(20),year INT,num_chargers INT); INSERT INTO ev_charging_stations (city,year,num_chargers) VALUES ('City A',2020,500),('City A',2021,600),('City B',2020,300),('City B',2021,350),('City C',2020,400),('City C',2021,450); | SELECT city, SUM(num_chargers) FROM ev_charging_stations GROUP BY city; |
Create a table named 'manufacturing_regions' to store garment manufacturing regions | CREATE TABLE manufacturing_regions (id INT PRIMARY KEY,region VARCHAR(100),country VARCHAR(100),manufacturing_volume INT); | CREATE TABLE manufacturing_regions (id INT PRIMARY KEY, region VARCHAR(100), country VARCHAR(100), manufacturing_volume INT); |
Calculate the average claim amount for policyholders living in 'TX'. | CREATE TABLE Policyholders (PolicyholderID INT,Name VARCHAR(50),Age INT,Gender VARCHAR(10),State VARCHAR(2)); CREATE TABLE Claims (ClaimID INT,PolicyholderID INT,Amount DECIMAL(10,2),ClaimDate DATE); INSERT INTO Policyholders (PolicyholderID,Name,Age,Gender,State) VALUES (1,'Aisha Brown',68,'Female','NY'); INSERT INTO Policyholders (PolicyholderID,Name,Age,Gender,State) VALUES (2,'Brian Green',55,'Male','CA'); INSERT INTO Policyholders (PolicyholderID,Name,Age,Gender,State) VALUES (3,'Charlotte Lee',72,'Female','TX'); INSERT INTO Claims (ClaimID,PolicyholderID,Amount,ClaimDate) VALUES (1,1,500,'2021-01-01'); INSERT INTO Claims (ClaimID,PolicyholderID,Amount,ClaimDate) VALUES (2,3,1000,'2021-02-01'); | SELECT AVG(Claims.Amount) FROM Policyholders JOIN Claims ON Policyholders.PolicyholderID = Claims.PolicyholderID WHERE Policyholders.State = 'TX'; |
How many electric and hybrid vehicles were sold in total worldwide in 2021? | CREATE TABLE Global_Sales (id INT,vehicle_type TEXT,quantity INT,year INT); INSERT INTO Global_Sales (id,vehicle_type,quantity,year) VALUES (1,'Electric',1200,2021); INSERT INTO Global_Sales (id,vehicle_type,quantity,year) VALUES (2,'Hybrid',1500,2021); | SELECT SUM(quantity) FROM Global_Sales WHERE vehicle_type IN ('Electric', 'Hybrid') AND year = 2021; |
Insert a new safety test result for 'Tesla Model 3' into the 'SafetyTestResults' table. | CREATE TABLE SafetyTestResults (Id INT,Vehicle VARCHAR(50),Test VARCHAR(50),Score INT); | INSERT INTO SafetyTestResults (Id, Vehicle, Test, Score) VALUES (1, 'Tesla Model 3', 'Crash Test', 93); |
List the safe AI practices from the 'safe_ai_practices' view. | CREATE VIEW safe_ai_practices AS SELECT * FROM ai_safety_guidelines WHERE category = 'Safe Practices'; | SELECT * FROM safe_ai_practices; |
What is the total number of AI safety incidents for each type of incident, sorted by the number of incidents in descending order? | CREATE TABLE incidents (id INT,model_id INT,incident_type VARCHAR(255)); INSERT INTO incidents (id,model_id,incident_type) VALUES (1,1,'Unintended Consequences'),(2,2,'Lack of Robustness'),(3,1,'Lack of Robustness'),(4,3,'Unintended Consequences'),(5,1,'Bias'),(6,2,'Bias'),(7,3,'Bias'),(8,1,'Explainability'),(9,2,'Explainability'),(10,3,'Explainability'); | SELECT incident_type, COUNT(*) as incident_count FROM incidents GROUP BY incident_type ORDER BY incident_count DESC; |
What are the names of all the farmers who have adopted precision agriculture techniques in the 'rural_development' schema? | CREATE TABLE farmers (id INT,name VARCHAR(50),technique VARCHAR(50)); INSERT INTO farmers (id,name,technique) VALUES (1,'John Doe','Precision Agriculture'); | SELECT name FROM rural_development.farmers WHERE technique = 'Precision Agriculture'; |
Which visual art genres have the highest average attendee age? | CREATE TABLE VisualArtEvents (id INT,title VARCHAR(50),genre VARCHAR(50)); INSERT INTO VisualArtEvents (id,title,genre) VALUES (1,'Modern Art Exhibition','Modern Art'); INSERT INTO VisualArtEvents (id,title,genre) VALUES (2,'Classic Art Exhibition','Classic Art'); CREATE TABLE VisualArtAttendees (id INT,event_id INT,age INT,gender VARCHAR(10)); INSERT INTO VisualArtAttendees (id,event_id,age,gender) VALUES (1,1,45,'Female'); INSERT INTO VisualArtAttendees (id,event_id,age,gender) VALUES (2,2,35,'Male'); | SELECT genre, AVG(age) FROM VisualArtAttendees GROUP BY genre ORDER BY AVG(age) DESC; |
What is the minimum cost of sustainable construction materials in the 'materials' table? | CREATE TABLE materials (material_name VARCHAR(30),is_sustainable BOOLEAN,cost FLOAT); INSERT INTO materials (material_name,is_sustainable,cost) VALUES ('Recycled Steel',TRUE,120); INSERT INTO materials (material_name,is_sustainable,cost) VALUES ('Reclaimed Wood',TRUE,150); | SELECT MIN(cost) FROM materials WHERE is_sustainable = TRUE; |
What is the total number of electricians and plumbers in the construction labor force? | CREATE TABLE LaborStats (StatID INT,StatName TEXT,TotalEmployees INT); INSERT INTO LaborStats VALUES (1,'Electricians',400000),(2,'Plumbers',300000); | SELECT SUM(TotalEmployees) FROM LaborStats WHERE StatName IN ('Electricians', 'Plumbers'); |
Which engineers worked on the 'Wind Turbines' project? | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Position VARCHAR(50),Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,FirstName,LastName,Position,Department) VALUES (2,'Jane','Smith','Engineer','Construction'); CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),StartDate DATE,EndDate DATE,Department VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,StartDate,EndDate,Department) VALUES (2,'Wind Turbines','2022-04-01','2022-10-31','Construction'); | SELECT Employees.FirstName, Employees.LastName FROM Employees INNER JOIN Projects ON Employees.Department = Projects.Department WHERE Employees.Position = 'Engineer' AND Projects.ProjectName = 'Wind Turbines'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.