instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the average age of players who prefer the 'FPS' genre in the 'player_preferences' and 'player_demographics' tables? | CREATE TABLE player_preferences (player_id INT,genre VARCHAR(50)); CREATE TABLE player_demographics (player_id INT,age INT); INSERT INTO player_preferences (player_id,genre) VALUES (1,'FPS'),(2,'RPG'),(3,'FPS'),(4,'Simulation'); INSERT INTO player_demographics (player_id,age) VALUES (1,25),(2,30),(3,35),(4,40); | SELECT AVG(age) as avg_fps_age FROM player_demographics JOIN player_preferences ON player_preferences.player_id = player_demographics.player_id WHERE genre = 'FPS'; |
What is the average humidity in New York in the past week? | CREATE TABLE Weather (location VARCHAR(50),humidity INT,timestamp TIMESTAMP); | SELECT AVG(humidity) FROM Weather WHERE location = 'New York' AND timestamp > NOW() - INTERVAL '1 week'; |
How many traffic violations were recorded in the year 2019 for both cities 'San Francisco' and 'Los Angeles'? | CREATE TABLE traffic_violations (city VARCHAR(20),year INT,violations INT); INSERT INTO traffic_violations (city,year,violations) VALUES ('San Francisco',2020,3000),('San Francisco',2019,3500),('Los Angeles',2020,4000),('Los Angeles',2019,4500); | SELECT COUNT(*) FROM traffic_violations WHERE city IN ('San Francisco', 'Los Angeles') AND year = 2019; |
What was the minimum citizen feedback score for waste management services in the capital city in 2021? | CREATE TABLE Feedback (year INT,city VARCHAR(255),service VARCHAR(255),score INT); INSERT INTO Feedback (year,city,service,score) VALUES (2021,'Capital','Waste Management',6),(2021,'Capital','Waste Management',7),(2021,'Capital','Waste Management',5),(2021,'Capital','Waste Management',6); | SELECT MIN(score) FROM Feedback WHERE year = 2021 AND city = 'Capital' AND service = 'Waste Management'; |
Delete all records of Lutetium production in 2015 by companies located in the Asia-Pacific region. | CREATE TABLE Producers (ProducerID INT PRIMARY KEY,Name TEXT,ProductionYear INT,RareEarth TEXT,Quantity INT,Location TEXT); | DELETE FROM Producers WHERE RareEarth = 'Lutetium' AND ProductionYear = 2015 AND Location LIKE '%Asia-Pacific%'; |
What is the minimum price of Holmium in Asia? | CREATE TABLE holmium_prices (region VARCHAR(255),price DECIMAL(10,2)); INSERT INTO holmium_prices (region,price) VALUES ('China',450.00),('Japan',430.00),('India',470.00); | SELECT MIN(price) FROM holmium_prices WHERE region = 'China' OR region = 'Japan' OR region = 'India'; |
What is the average monthly rent for wheelchair-accessible units across all areas? | CREATE TABLE area_units (area VARCHAR(20),wheelchair_accessible BOOLEAN,monthly_rent FLOAT); | SELECT AVG(monthly_rent) FROM area_units WHERE wheelchair_accessible = TRUE; |
What is the maximum energy efficiency rating for appliances in the United Kingdom? | CREATE TABLE uk_appliances (id INT,country VARCHAR(255),name VARCHAR(255),energy_efficiency_rating FLOAT); INSERT INTO uk_appliances (id,country,name,energy_efficiency_rating) VALUES (1,'United Kingdom','Appliance A',3.5),(2,'United Kingdom','Appliance B',4.2); | SELECT MAX(energy_efficiency_rating) FROM uk_appliances WHERE country = 'United Kingdom'; |
What is the maximum energy efficiency rating of hydroelectric dams in Canada? | CREATE TABLE hydro_dams (id INT,name TEXT,country TEXT,energy_efficiency_rating FLOAT); INSERT INTO hydro_dams (id,name,country,energy_efficiency_rating) VALUES (1,'Robert-Bourassa','Canada',0.94),(2,'Churchill Falls','Canada',0.92); | SELECT MAX(energy_efficiency_rating) FROM hydro_dams WHERE country = 'Canada'; |
How many vegan menu items are available at each restaurant? | CREATE TABLE menu_items (menu_item_id INT,item_name VARCHAR(255),category VARCHAR(255),price INT,vegan BOOLEAN); INSERT INTO menu_items (menu_item_id,item_name,category,price,vegan) VALUES (1,'Tofu Stir Fry','Entree',12,true),(2,'Chicken Caesar Salad','Salad',15,false),(3,'Veggie Burger','Entree',14,true); | SELECT category, COUNT(*) as count FROM menu_items WHERE vegan = true GROUP BY category; |
What is the average revenue for menu items in the 'Desserts' category? | CREATE TABLE menu_items (id INT,name VARCHAR(255),category VARCHAR(255),revenue INT); INSERT INTO menu_items (id,name,category,revenue) VALUES (1,'Chocolate Cake','Desserts',300),(2,'Cheesecake','Desserts',400),(3,'Ice Cream Sundae','Desserts',250); | SELECT AVG(revenue) as avg_revenue FROM menu_items WHERE category = 'Desserts'; |
Identify the top 3 countries with the most satellites in orbit. | CREATE TABLE satellites_in_orbit (satellite_id INT,name VARCHAR(100),country VARCHAR(50),launch_date DATE); | SELECT country, COUNT(*) as satellite_count FROM satellites_in_orbit GROUP BY country ORDER BY satellite_count DESC LIMIT 3; |
Insert a new record of a vulnerability assessment for a medical device with ID 5, last assessment date of 2022-01-25, and severity score of 7. | CREATE TABLE medical_devices_v2 (id INT,name VARCHAR(255),last_assessment_date DATE,severity_score INT); | INSERT INTO medical_devices_v2 (id, name, last_assessment_date, severity_score) VALUES (5, 'Medical Device 5', '2022-01-25', 7); |
List all autonomous taxis and their makes, grouped by city, in the 'taxis' table. | CREATE TABLE taxis (id INT,make VARCHAR(20),model VARCHAR(20),year INT,city VARCHAR(20),autonomous BOOLEAN); | SELECT city, make FROM taxis WHERE autonomous = TRUE GROUP BY city; |
What is the average speed of public buses in Sydney? | CREATE TABLE sydney_buses (id INT,route_id VARCHAR(20),speed INT,timestamp TIMESTAMP); | SELECT AVG(speed) FROM sydney_buses WHERE route_id IS NOT NULL; |
What is the total retail value of the "Winter 2022" collection for each manufacturer? | CREATE TABLE Winter2022 (garment_id INT,manufacturer_id INT,garment_name VARCHAR(50),retail_price DECIMAL(5,2)); INSERT INTO Winter2022 (garment_id,manufacturer_id,garment_name,retail_price) VALUES (1,100,'Wool Coat',250.00),(2,100,'Cotton Shirt',50.00),(3,200,'Denim Jeans',75.00),(4,200,'Fleece Hoodie',50.00); CREATE TABLE Manufacturers (manufacturer_id INT,manufacturer_name VARCHAR(50)); INSERT INTO Manufacturers (manufacturer_id,manufacturer_name) VALUES (100,'GreenFashions'),(200,'SustainaWear'); | SELECT m.manufacturer_name, SUM(w.retail_price) FROM Winter2022 w INNER JOIN Manufacturers m ON w.manufacturer_id = m.manufacturer_id GROUP BY m.manufacturer_name; |
Find the average age of policyholders in Texas. | CREATE TABLE policyholders (policyholder_id INT,name VARCHAR(50),age INT,gender VARCHAR(10),state VARCHAR(50)); INSERT INTO policyholders (policyholder_id,name,age,gender,state) VALUES (1,'John Doe',35,'Male','Texas'); INSERT INTO policyholders (policyholder_id,name,age,gender,state) VALUES (2,'Jane Smith',40,'Female','Texas'); | SELECT AVG(age) FROM policyholders WHERE state = 'Texas'; |
What is the average car manufacturing year for policy number 1003? | CREATE TABLE policies (policy_id INT,car_manufacture_year INT); INSERT INTO policies (policy_id,car_manufacture_year) VALUES (1001,2010),(1002,2015),(1003,2008),(1004,2012); | SELECT AVG(car_manufacture_year) FROM policies WHERE policy_id = 1003; |
What is the average number of members in unions in the USA and UK? | CREATE TABLE UnionMembers (id INT,union_name VARCHAR(50),country VARCHAR(50),member_count INT); INSERT INTO UnionMembers (id,union_name,country,member_count) VALUES (1,'United Steelworkers','USA',200000),(2,'UNITE HERE','USA',300000),(3,'TUC','UK',6000000),(4,'CUPE','Canada',650000),(5,'USW','Canada',120000); | SELECT AVG(member_count) as avg_members FROM UnionMembers WHERE country IN ('USA', 'UK'); |
List the unique types of waste generated in each area. | CREATE TABLE WasteTypes (id INT,area VARCHAR(10),waste_type VARCHAR(20)); INSERT INTO WasteTypes (id,area,waste_type) VALUES (1,'urban','Organic'),(2,'rural','Plastic'),(3,'urban','Paper'); | SELECT area, waste_type FROM WasteTypes GROUP BY area, waste_type; |
What is the average recycling rate for the world for the year 2018? | CREATE TABLE recycling_rates (country VARCHAR(50),year INT,recycling_rate FLOAT); INSERT INTO recycling_rates (country,year,recycling_rate) VALUES ('USA',2018,0.35),('Canada',2018,0.40),('China',2018,0.25),('India',2018,0.15); | SELECT AVG(recycling_rate) FROM recycling_rates WHERE year = 2018; |
List all the unique workout types in the Workout table. | CREATE TABLE Workout (WorkoutID INT,MemberID INT,WorkoutType VARCHAR(30)); INSERT INTO Workout (WorkoutID,MemberID,WorkoutType) VALUES (1,1,'Running'); INSERT INTO Workout (WorkoutID,MemberID,WorkoutType) VALUES (2,1,'Cycling'); INSERT INTO Workout (WorkoutID,MemberID,WorkoutType) VALUES (3,2,'Yoga'); | SELECT DISTINCT WorkoutType FROM Workout; |
How many creative AI applications have been developed for each industry? | CREATE TABLE creative_ai_applications (id INT,industry VARCHAR(50),application_count INT); INSERT INTO creative_ai_applications (id,industry,application_count) VALUES (1,'Entertainment',12),(2,'Art',8),(3,'Education',6); | SELECT industry, application_count FROM creative_ai_applications; |
Update the name of the project to 'Wind Power' in the 'rural_energy' table | CREATE TABLE rural_energy (id INT,project_name VARCHAR(255),country VARCHAR(255)); | UPDATE rural_energy SET project_name = 'Wind Power' WHERE id = 1; |
What is the number of community development initiatives in Kenya? | CREATE TABLE community_development_initiatives (id INT,country VARCHAR(20)); INSERT INTO community_development_initiatives (id,country) VALUES (1,'Kenya'),(2,'Tanzania'); | SELECT COUNT(*) FROM community_development_initiatives WHERE country = 'Kenya'; |
What is the earliest and latest date of successful satellite deployments by 'India'? | CREATE TABLE SatelliteDeployments (id INT,country VARCHAR(50),year INT,number_of_satellites INT,deployment_status VARCHAR(50),deployment_date DATE); | SELECT country, MIN(deployment_date) AS earliest_deployment, MAX(deployment_date) AS latest_deployment FROM SatelliteDeployments WHERE country = 'India' AND deployment_status = 'successful' GROUP BY country; |
Add a new endangered animal 'Amur Leopard' to 'Conservation Area Z' | CREATE TABLE AnimalPopulation (AnimalID INT,AnimalName TEXT,HabitatID INT,Status TEXT); INSERT INTO AnimalPopulation (AnimalID,AnimalName,HabitatID,Status) VALUES (1,'Snow Leopard',1,'Endangered'); CREATE TABLE Habitats (HabitatID INT,HabitatName TEXT,Location TEXT); INSERT INTO Habitats (HabitatID,HabitatName,Location) VALUES (1,'Conservation Area Z','Country F'); | INSERT INTO AnimalPopulation (AnimalID, AnimalName, HabitatID, Status) VALUES (3, 'Amur Leopard', 1, 'Endangered'); |
Display the vendor with the highest average price for 'Salmon' in the 'sales' table. | CREATE TABLE sales (id INT PRIMARY KEY,vendor VARCHAR(50),quantity INT,species VARCHAR(50),price DECIMAL(5,2)); INSERT INTO sales (id,vendor,quantity,species,price) VALUES (1,'Seafood Haven',20,'Salmon',15.99),(2,'Sea Bounty',30,'Tilapia',9.49),(3,'Sea Bounty',15,'Cod',14.50),(4,'Fresh Catch',25,'Salmon',17.99); | SELECT vendor, AVG(price) FROM sales WHERE species = 'Salmon' GROUP BY vendor ORDER BY AVG(price) DESC LIMIT 1; |
What is the average attendance at visual art events in Paris and Rome? | CREATE TABLE Events (event_name TEXT,city TEXT,attendees INT); INSERT INTO Events (event_name,city,attendees) VALUES ('Art Gallery','Paris',100),('Art Museum','Rome',150),('Art Exhibition','Paris',200); | SELECT AVG(attendees) FROM Events WHERE city IN ('Paris', 'Rome') AND event_name LIKE '%Art%'; |
What is the average time to complete a construction project? | CREATE TABLE project_timeline (project_id SERIAL PRIMARY KEY,start_date DATE,end_date DATE); INSERT INTO project_timeline (project_id,start_date,end_date) VALUES (1,'2021-01-01','2021-06-01'),(2,'2021-02-01','2021-08-15'),(3,'2021-03-01','2021-10-01'); | SELECT AVG(DATEDIFF('day', start_date, end_date)) FROM project_timeline; |
How many licenses were issued in each state as of 2022-01-01? | CREATE TABLE Licenses (id INT,state TEXT,issued_date DATE); INSERT INTO Licenses (id,state,issued_date) VALUES (1,'California','2021-01-01'),(2,'Oregon','2021-01-01'),(3,'Washington','2021-01-01'); | SELECT state, COUNT(*) AS num_licenses FROM Licenses WHERE issued_date <= '2022-01-01' GROUP BY state; |
What is the total billing amount for cases handled by attorneys from Texas? | CREATE TABLE AttorneyLocation (AttorneyID INT,Location VARCHAR(50)); INSERT INTO AttorneyLocation (AttorneyID,Location) VALUES (1,'New York'),(2,'Texas'),(3,'California'); | SELECT SUM(BillingAmount) FROM AttorneyBilling JOIN AttorneyLocation ON AttorneyBilling.AttorneyID = AttorneyLocation.AttorneyID WHERE Location = 'Texas'; |
Delete the data for crop A in region X in all months. | CREATE TABLE WeatherData (region TEXT,crop TEXT,month INTEGER,temperature REAL); INSERT INTO WeatherData (region,crop,month,temperature) VALUES ('X','A',6,22.5),('X','A',7,25.0),('Y','B',6,18.2); | DELETE FROM WeatherData WHERE region = 'X' AND crop = 'A'; |
Find total cost of accommodations for students with a specific accommodation. | CREATE TABLE Accommodations (id INT,student_id INT,accommodation_type VARCHAR(50),cost FLOAT); | SELECT a.accommodation_type, SUM(a.cost) as total_cost FROM Accommodations a JOIN Students s ON a.student_id = s.id WHERE s.name = 'John Doe' GROUP BY a.accommodation_type; |
What is the number of students who received accommodations by graduation year and gender? | CREATE TABLE Accommodations (StudentID INT,AccommodationType VARCHAR(50),AccommodationDate DATE); INSERT INTO Accommodations (StudentID,AccommodationType,AccommodationDate) VALUES (1,'Sign Language Interpreter','2021-01-01'); CREATE TABLE Students (StudentID INT,StudentName VARCHAR(50),GraduationYear INT,Gender VARCHAR(10)); INSERT INTO Students (StudentID,StudentName,GraduationYear,Gender) VALUES (1,'Jacob Taylor',2023,'Male'); | SELECT GraduationYear, Gender, COUNT(*) as Total FROM Accommodations JOIN Students ON Accommodations.StudentID = Students.StudentID GROUP BY GraduationYear, Gender; |
What is the total number of employees trained in disability awareness in the Pacific region? | CREATE TABLE employee_training_pacific (region VARCHAR(20),training VARCHAR(30),participants INT); INSERT INTO employee_training_pacific (region,training,participants) VALUES ('Pacific','Disability Awareness',200); INSERT INTO employee_training_pacific (region,training,participants) VALUES ('Pacific','Disability Awareness',250); INSERT INTO employee_training_pacific (region,training,participants) VALUES ('Pacific','Disability Awareness',300); | SELECT region, SUM(participants) FROM employee_training_pacific WHERE region = 'Pacific' AND training = 'Disability Awareness'; |
Count how many protected forests are in Africa? | CREATE TABLE forests (id INT,country VARCHAR(255),region VARCHAR(255),is_protected BOOLEAN); | SELECT COUNT(*) FROM forests WHERE region = 'Africa' AND is_protected = TRUE; |
What is the maximum response time for medical emergencies? | CREATE TABLE medical_responses (response_id INT,response_type TEXT,response_time FLOAT); | SELECT response_type, MAX(response_time) AS max_response_time FROM medical_responses WHERE response_type LIKE '%medical%' GROUP BY response_type; |
What is the average ticket price for performances at the 'Downtown Theater'? | CREATE TABLE DowntownTheater (show_name TEXT,date DATE,ticket_price FLOAT); INSERT INTO DowntownTheater (show_name,date,ticket_price) VALUES ('Play 1','2022-01-01',30.0),('Play 2','2022-01-02',40.0),('Concert 1','2022-01-03',50.0); | SELECT AVG(ticket_price) FROM DowntownTheater WHERE show_name = 'Downtown Theater' |
Show defense contracts for 'Blue Skies Inc.' and 'Green Horizons Inc.' in Q3 2021 | CREATE TABLE defense_contracts (company VARCHAR(255),quarter VARCHAR(10),value DECIMAL(10,2)); | SELECT company, quarter, value FROM defense_contracts WHERE company IN ('Blue Skies Inc.', 'Green Horizons Inc.') AND quarter = 'Q3 2021'; |
Update all military equipment maintenance records in the Southeast region from Q1 2022 to Q2 2022 | CREATE TABLE Equipment (ID INT,Name TEXT,MaintenanceDate DATE,Region TEXT,Quarter INT); INSERT INTO Equipment (ID,Name,MaintenanceDate,Region,Quarter) VALUES (1,'Tank A','2022-01-01','Southeast',1),(2,'Helicopter B','2022-02-01','Southeast',1); | UPDATE Equipment SET MaintenanceDate = CASE WHEN Quarter = 1 THEN DATE_ADD(MaintenanceDate, INTERVAL 1 QUARTER) ELSE MaintenanceDate END WHERE Region = 'Southeast'; |
Who are the top 3 defense diplomacy partners of 'India' in the last 3 years, based on the number of joint military exercises? | CREATE TABLE diplomacy_exercises (id INT,country1 TEXT,country2 TEXT,exercise_date DATE); INSERT INTO diplomacy_exercises (id,country1,country2,exercise_date) VALUES (1,'India','Russia','2018-01-01'); | SELECT country2, COUNT(*) AS exercise_count FROM diplomacy_exercises WHERE country1 = 'India' AND exercise_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) GROUP BY country2 ORDER BY exercise_count DESC LIMIT 3; |
List all the ports in the 'ports' table that have a crane capacity greater than 150 tons. | CREATE TABLE ports (port_id INT,port_name VARCHAR(50),crane_capacity INT); INSERT INTO ports (port_id,port_name,crane_capacity) VALUES (1,'Port of Long Beach',200),(2,'Port of Los Angeles',120),(3,'Port of Oakland',175); | SELECT port_name FROM ports WHERE crane_capacity > 150; |
Find excavation sites with no artifacts. | CREATE TABLE excavations (id INT,location VARCHAR(255)); INSERT INTO excavations (id,location) VALUES (1,'Egypt'),(2,'USA'),(3,'Mexico'); | SELECT e.id, e.location FROM excavations e LEFT JOIN artifacts a ON e.id = a.excavation_id WHERE a.id IS NULL; |
List the top 3 most common artifact types found in the 'Eastern Region'? | CREATE TABLE excavation_sites (site_id INT,site_name TEXT,region TEXT); CREATE TABLE artifacts (artifact_id INT,site_id INT,artifact_type TEXT); INSERT INTO excavation_sites (site_id,site_name,region) VALUES (1,'Site A','Eastern Region'),(2,'Site B','Western Region'),(3,'Site C','Eastern Region'); INSERT INTO artifacts (artifact_id,site_id,artifact_type) VALUES (1,1,'pottery'),(2,1,'stone'),(3,2,'metal'),(4,3,'pottery'),(5,3,'wooden'); | SELECT artifact_type, COUNT(*) as count FROM artifacts a JOIN excavation_sites e ON a.site_id = e.site_id WHERE e.region = 'Eastern Region' GROUP BY artifact_type ORDER BY count DESC LIMIT 3; |
What cybersecurity strategies were implemented in India? | CREATE TABLE cybersecurity_strategies (id INT,strategy VARCHAR(50),location VARCHAR(50),date DATE); INSERT INTO cybersecurity_strategies (id,strategy,location,date) VALUES (3,'Endpoint Security','India','2020-07-01'); | SELECT strategy FROM cybersecurity_strategies WHERE location = 'India'; |
What is the maximum number of military personnel in Africa who have received training in military technology in the past 2 years? | CREATE TABLE military_personnel (id INT,name VARCHAR(50),country VARCHAR(50),training_history TEXT); INSERT INTO military_personnel (id,name,country,training_history) VALUES (1,'Aisha Smith','Nigeria','AI training,2021'); CREATE TABLE countries (id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO countries (id,name,region) VALUES (1,'Nigeria','Africa'); | SELECT MAX(count(*)) FROM military_personnel m JOIN countries c ON m.country = c.name WHERE c.region = 'Africa' AND m.training_history LIKE '%[0-9]% training,[0-9][0-9]%' GROUP BY YEAR(SUBSTRING(m.training_history, INSTR(m.training_history, ',') + 1, 4)); |
What is the total amount donated in Q2 2022? | CREATE TABLE Donations (DonationID INT,DonorID INT,Amount FLOAT,DonationDate DATE); INSERT INTO Donations (DonationID,DonorID,Amount,DonationDate) VALUES (1,1,500.00,'2021-01-01'),(2,2,800.00,'2021-02-01'),(3,1,300.00,'2022-03-15'),(4,3,150.00,'2022-04-10'),(5,4,250.00,'2022-05-01'); | SELECT SUM(Amount) FROM Donations WHERE DATE_FORMAT(DonationDate, '%Y-%m') BETWEEN '2022-04' AND '2022-06'; |
Find the average age of non-binary employees who have completed the compliance training. | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(20),Age INT,CompletedComplianceTraining BOOLEAN); | SELECT AVG(Age) FROM Employees WHERE Gender = 'Non-binary' AND CompletedComplianceTraining = TRUE; |
What is the total number of employees who identify as a racial or ethnic minority? | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),Department VARCHAR(20),Race VARCHAR(20)); INSERT INTO Employees (EmployeeID,Gender,Department,Race) VALUES (1,'Male','IT','White'),(2,'Female','IT','Asian'),(3,'Male','HR','Black'),(4,'Female','HR','Hispanic'),(5,'Non-binary','Marketing','White'); | SELECT COUNT(*) FROM Employees WHERE Race <> 'White'; |
What is the average energy production for each source in Texas between 2021-01-01 and 2021-01-07, excluding sources with only one production record? | CREATE TABLE energy_production_3 (id INT,source VARCHAR(50),location VARCHAR(50),production_quantity INT,production_date DATE); INSERT INTO energy_production_3 (id,source,location,production_quantity,production_date) VALUES (3,'Wind','Texas',7000,'2021-01-02'); | SELECT source, AVG(production_quantity) as avg_production FROM energy_production_3 WHERE production_date BETWEEN '2021-01-01' AND '2021-01-07' AND location = 'Texas' GROUP BY source HAVING COUNT(*) > 1; |
What was the total energy storage capacity in California in 2018 and 2019? | CREATE TABLE energy_storage (region VARCHAR(255),capacity FLOAT,year INT); INSERT INTO energy_storage (region,capacity,year) VALUES ('California',1000,2018),('California',1200,2019),('Texas',1500,2018),('Texas',1800,2019); | SELECT SUM(capacity) as total_capacity, year FROM energy_storage WHERE region = 'California' GROUP BY year; |
What is the minimum and maximum technology accessibility score for organizations in the education sector? | CREATE TABLE org_accessibility (org_name TEXT,sector TEXT,tech_accessibility_score INT); INSERT INTO org_accessibility (org_name,sector,tech_accessibility_score) VALUES ('Org1','education',80),('Org2','education',90),('Org3','education',70),('Org4','education',85),('Org5','education',95); | SELECT MIN(tech_accessibility_score), MAX(tech_accessibility_score) FROM org_accessibility WHERE sector = 'education'; |
Find the number of vehicles in each maintenance category in the 'vehicle_maintenance' table. | CREATE TABLE vehicle_maintenance (vehicle_id INT,category VARCHAR(255),maintenance_date DATE); | SELECT category, COUNT(*) as num_vehicles FROM vehicle_maintenance GROUP BY category; |
List all unique route IDs and station IDs from the route_stations table | CREATE TABLE route_stations (route_id INTEGER,station_id INTEGER); INSERT INTO route_stations (route_id,station_id) VALUES (1,1); | SELECT DISTINCT route_id, station_id FROM route_stations; |
Show the number of trips taken by each passenger on the 'Red Line' | CREATE TABLE passengers (passenger_id INT,passenger_name VARCHAR(20)); CREATE TABLE passenger_trips (trip_id INT,passenger_id INT,route_id INT,trip_date DATE); | SELECT passengers.passenger_name, COUNT(passenger_trips.trip_id) FROM passengers JOIN passenger_trips ON passengers.passenger_id = passenger_trips.passenger_id WHERE passenger_trips.route_id = 1 GROUP BY passengers.passenger_id, passengers.passenger_name; |
What is the average value for each accessibility feature per route for routes in Japan? | CREATE TABLE accessibility (id INT,route_id INT,stop_id INT,feature VARCHAR(255),value DECIMAL(3,1),country VARCHAR(255)); INSERT INTO accessibility (id,route_id,stop_id,feature,value,country) VALUES (1,1,1,'Elevator',0,'Japan'); INSERT INTO accessibility (id,route_id,stop_id,feature,value,country) VALUES (2,2,2,'Stairs',10,'Japan'); | SELECT a.route_id, a.feature, AVG(a.value) AS avg_value FROM accessibility a WHERE a.country = 'Japan' GROUP BY a.route_id, a.feature; |
What is the name of the passenger who boarded the bus with the route 101 on March 15, 2021 at 10:15 AM? | CREATE TABLE RIDERS (id INT,name VARCHAR(50),boarding_time TIMESTAMP); CREATE TABLE BUS_ROUTES (route_number INT,start_time TIMESTAMP,end_time TIMESTAMP); INSERT INTO BUS_ROUTES VALUES (101,'2021-03-15 10:00:00','2021-03-15 11:00:00'); INSERT INTO RIDERS VALUES (1,'Jane Smith','2021-03-15 10:15:00'); | SELECT name FROM RIDERS WHERE boarding_time = '2021-03-15 10:15:00' AND id IN (SELECT rider_id FROM BUS_ROUTES_RIDERS WHERE route_number = 101); |
What is the total weight of non-organic fruits in the FOOD_ITEMS table? | CREATE TABLE FOOD_ITEMS (id INT,name VARCHAR(50),category VARCHAR(50),is_organic BOOLEAN,weight FLOAT); INSERT INTO FOOD_ITEMS (id,name,category,is_organic,weight) VALUES (1,'Apple','Fruit',false,0.15),(2,'Banana','Fruit',false,0.2); | SELECT SUM(weight) FROM FOOD_ITEMS WHERE is_organic = false AND category = 'Fruit'; |
What is the total number of items sold by each salesperson in the sales database? | CREATE TABLE sales (salesperson VARCHAR(20),items INT); INSERT INTO sales (salesperson,items) VALUES ('John',50),('Jane',70),('Doe',60); | SELECT salesperson, SUM(items) FROM sales GROUP BY salesperson; |
What is the minimum number of public participations in any initiative? | CREATE TABLE participations (initiative_id INT,num_participants INT); INSERT INTO participations (initiative_id,num_participants) VALUES (1,500),(2,700),(3,300),(4,800),(5,100); | SELECT MIN(num_participants) FROM participations; |
Display the names of community health workers who manage both mental health and physical health cases. | CREATE TABLE CommunityHealthWorkers (WorkerID INT,Name VARCHAR(50),Specialty VARCHAR(50)); CREATE TABLE Cases (WorkerID INT,CaseID INT,CaseType VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID,Name,Specialty) VALUES (1,'John Doe','Mental Health'); INSERT INTO CommunityHealthWorkers (WorkerID,Name,Specialty) VALUES (2,'Jane Smith','Physical Health'); INSERT INTO Cases (WorkerID,CaseID,CaseType) VALUES (1,101,'Mental Health'); INSERT INTO Cases (WorkerID,CaseID,CaseType) VALUES (2,201,'Physical Health'); INSERT INTO Cases (WorkerID,CaseID,CaseType) VALUES (1,102,'Mental Health'); INSERT INTO Cases (WorkerID,CaseID,CaseType) VALUES (2,202,'Physical Health'); | SELECT DISTINCT c.Name FROM Cases c INNER JOIN CommunityHealthWorkers h ON c.WorkerID = h.WorkerID WHERE h.Specialty = 'Mental Health' AND h.Specialty = 'Physical Health'; |
What is the total number of health equity metric evaluations conducted in 2020 and 2021? | CREATE TABLE evaluations (evaluation_id INT,evaluation_date DATE); | SELECT COUNT(*) as evaluation_count FROM evaluations WHERE evaluation_date BETWEEN '2020-01-01' AND '2021-12-31'; |
How many eco-friendly hotels are in Portugal? | CREATE TABLE eco_hotels (hotel_id INT,hotel_name TEXT,country TEXT); INSERT INTO eco_hotels (hotel_id,hotel_name,country) VALUES (1,'Green Hotel','Portugal'),(2,'Eco Lodge','Portugal'); | SELECT COUNT(*) FROM eco_hotels WHERE country = 'Portugal'; |
Top 3 countries with most hotel listings on Online Travel Agency? | CREATE TABLE ota_hotels (hotel_id INT,hotel_name TEXT,country TEXT,listings INT); INSERT INTO ota_hotels (hotel_id,hotel_name,country,listings) VALUES (1,'Hotel Royal','India',500),(2,'Palace Hotel','France',700),(3,'Beach Resort','Brazil',800),(4,'Luxury Villa','India',600),(5,'Mountain Lodge','Nepal',300); | SELECT country, SUM(listings) as total_listings FROM ota_hotels GROUP BY country ORDER BY total_listings DESC LIMIT 3; |
What is the total number of species in the Arctic biodiversity database? | CREATE TABLE ArcticBiodiversity (species VARCHAR(50),common_name VARCHAR(50)); INSERT INTO ArcticBiodiversity (species,common_name) VALUES ('Alopex lagopus','Arctic Fox'); INSERT INTO ArcticBiodiversity (species,common_name) VALUES ('Rangifer tarandus','Reindeer'); INSERT INTO ArcticBiodiversity (species,common_name) VALUES ('Ursus maritimus','Polar Bear'); | SELECT COUNT(species) FROM ArcticBiodiversity; |
Who are the top 3 medication managers with the most patients in India and South Africa? | CREATE TABLE medication_managers (id INT,name TEXT); CREATE TABLE patients (id INT,manager_id INT,state TEXT); INSERT INTO medication_managers (id,name) VALUES (1,'Dr. Ravi Patel'); INSERT INTO medication_managers (id,name) VALUES (2,'Dr. Naledi Zuma'); INSERT INTO patients (id,manager_id,state) VALUES (1,1,'India'); INSERT INTO patients (id,manager_id,state) VALUES (2,1,'South Africa'); INSERT INTO patients (id,manager_id,state) VALUES (3,2,'South Africa'); | SELECT medication_managers.name, COUNT(patients.id) AS patient_count FROM medication_managers INNER JOIN patients ON medication_managers.id = patients.manager_id WHERE patients.state IN ('India', 'South Africa') GROUP BY medication_managers.name ORDER BY patient_count DESC LIMIT 3; |
Identify the number of unique community organizations involved in each restorative justice program | CREATE TABLE community_orgs (org_id INT,program_id INT,org_name VARCHAR(50)); INSERT INTO community_orgs (org_id,program_id,org_name) VALUES (1,1,'Neighborhood Watch'),(2,1,'Community Center'),(3,2,'Youth Group'),(4,3,'Victim Support'),(5,1,'Local Nonprofit'); | SELECT program_id, COUNT(DISTINCT org_name) FROM community_orgs GROUP BY program_id; |
What is the average age of legal aid service users by gender in the 'legal_aid_users' table? | CREATE TABLE legal_aid_users (user_id INT,age INT,gender VARCHAR(10),last_access DATE); | SELECT gender, AVG(age) FROM legal_aid_users GROUP BY gender; |
What is the difference in the average duration of closed cases between attorneys in the "criminal_defense" department, ordered by the difference? | CREATE TABLE attorneys (attorney_id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO attorneys (attorney_id,name,department) VALUES (1,'John Doe','criminal_defense'); INSERT INTO attorneys (attorney_id,name,department) VALUES (2,'Jane Smith','criminal_defense'); CREATE TABLE cases (case_id INT,attorney_id INT,status VARCHAR(50),duration INT); INSERT INTO cases (case_id,attorney_id,status,duration) VALUES (1,1,'closed',25); INSERT INTO cases (case_id,attorney_id,status,duration) VALUES (2,1,'closed',30); INSERT INTO cases (case_id,attorney_id,status,duration) VALUES (3,2,'closed',40); | SELECT attorney_id, AVG(duration) - LAG(AVG(duration)) OVER (PARTITION BY attorney_id ORDER BY attorney_id) as difference FROM cases WHERE status = 'closed' GROUP BY attorney_id ORDER BY difference; |
What is the total quantity of orders from customers in the 'Asia-Pacific' region? | CREATE TABLE orders (id INT,dish_id INT,quantity INT,customer_region TEXT); INSERT INTO orders (id,dish_id,quantity,customer_region) VALUES (1,1,10,'Asia-Pacific'),(2,2,8,'Europe'),(3,3,5,'North America'),(4,1,7,'Asia-Pacific'),(5,2,9,'Europe'),(6,4,12,'South America'); | SELECT SUM(quantity) FROM orders WHERE customer_region = 'Asia-Pacific'; |
What is the earliest date of contract negotiation for each defense project in the Asia-Pacific region? | CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),StartDate DATE,EndDate DATE,Region VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,StartDate,EndDate,Region) VALUES (1,'Project A','2022-01-01','2023-12-31','Asia-Pacific'),(2,'Project B','2022-03-15','2024-02-28','Europe'),(3,'Project C','2022-06-01','2025-05-31','Asia-Pacific'),(4,'Project D','2022-10-01','2026-09-30','Americas'); | SELECT ProjectName, MIN(StartDate) AS EarliestDate FROM Projects WHERE Region = 'Asia-Pacific' GROUP BY ProjectName; |
Which defense projects have the highest geopolitical risk in the Asia-Pacific region? | CREATE TABLE defense_projects_risk (id INT,project_name VARCHAR(50),region VARCHAR(20),risk_level DECIMAL(3,2)); | SELECT project_name, risk_level FROM defense_projects_risk WHERE region = 'Asia-Pacific' AND risk_level = (SELECT MAX(risk_level) FROM defense_projects_risk WHERE region = 'Asia-Pacific'); |
List the top 3 cities with the highest number of broadband subscribers as of 2021-12-31. | CREATE TABLE subscribers (subscriber_id INT,name VARCHAR(50),city VARCHAR(50),service VARCHAR(10),start_date DATE); INSERT INTO subscribers (subscriber_id,name,city,service,start_date) VALUES (1,'John Doe','New York','broadband','2021-01-01'),(2,'Jane Smith','Los Angeles','broadband','2021-06-15'); | SELECT city, COUNT(*) AS num_subscribers FROM subscribers WHERE service = 'broadband' AND start_date <= '2021-12-31' GROUP BY city ORDER BY num_subscribers DESC LIMIT 3; |
What is the total amount donated by donors from the 'finance' sector in the year 2022? | CREATE TABLE donations (donation_id INT,donor_sector TEXT,donation_date DATE,donation_amount FLOAT); INSERT INTO donations (donation_id,donor_sector,donation_date,donation_amount) VALUES (1,'finance','2022-01-01',1000.00),(2,'finance','2022-02-01',2000.00); | SELECT SUM(donation_amount) FROM donations WHERE donor_sector = 'finance' AND YEAR(donation_date) = 2022; |
Update the donation amount to $10000 for donor_id 5, who identifies as genderqueer. | CREATE TABLE donors (donor_id INT,donation_amount DECIMAL(10,2),donation_year INT,gender VARCHAR(255)); INSERT INTO donors (donor_id,donation_amount,donation_year,gender) VALUES (1,5000.00,2020,'female'),(2,3000.00,2019,'male'),(3,7000.00,2020,'non-binary'),(4,9000.00,2021,'non-binary'),(5,8000.00,2021,'genderqueer'); | UPDATE donors SET donation_amount = 10000 WHERE donor_id = 5; |
Which organization received the most number of donations on a single day? | CREATE TABLE Donations (DonationID INT,DonationDate DATE,DonationAmount DECIMAL(10,2),OrgID INT); INSERT INTO Donations (DonationID,DonationDate,DonationAmount,OrgID) VALUES (1,'2022-01-01',500.00,1),(2,'2022-01-02',700.00,1),(3,'2022-01-01',500.00,2),(4,'2022-01-03',800.00,2),(5,'2022-01-03',300.00,2),(6,'2022-01-04',400.00,3); | SELECT OrgID, DonationDate, COUNT(*) as NumDonations FROM Donations GROUP BY OrgID, DonationDate ORDER BY OrgID, NumDonations DESC; |
What is the average number of wins for players who play "Racing Simulator 2022"? | CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Game VARCHAR(50),Wins INT); INSERT INTO Players (PlayerID,PlayerName,Game,Wins) VALUES (1,'John Doe','Racing Simulator 2022',25),(2,'Jane Smith','Racing Simulator 2022',30),(3,'Alice Johnson','Shooter Game 2022',22); | SELECT AVG(Wins) FROM Players WHERE Game = 'Racing Simulator 2022'; |
What is the average age of players who have played Fortnite and are from Asia? | CREATE TABLE Players (PlayerID INT,PlayerAge INT,Game VARCHAR(50),Continent VARCHAR(50)); INSERT INTO Players (PlayerID,PlayerAge,Game,Continent) VALUES (1,22,'Fortnite','Asia'); INSERT INTO Players (PlayerID,PlayerAge,Game,Continent) VALUES (2,25,'Fortnite','Europe'); INSERT INTO Players (PlayerID,PlayerAge,Game,Continent) VALUES (3,19,'Fortnite','Asia'); INSERT INTO Players (PlayerID,PlayerAge,Game,Continent) VALUES (4,28,'Fortnite','Asia'); | SELECT AVG(PlayerAge) as AvgAge FROM Players WHERE Game = 'Fortnite' AND Continent = 'Asia'; |
What is the average number of games played by players who joined esports events in Canada, per month? | CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Country VARCHAR(50),TotalGames INT); INSERT INTO Players (PlayerID,PlayerName,Country,TotalGames) VALUES (1,'John Doe','Canada',200); | SELECT AVG(TotalGames) FROM Players WHERE Country = 'Canada' AND PlayerID IN (SELECT PlayerID FROM EventParticipation WHERE EventCountry = 'Canada') |
Update the temperature values to Celsius for all records in 'Germany' in the month of May. | CREATE TABLE weather_stations (id INT,name TEXT,country TEXT); INSERT INTO weather_stations (id,name,country) VALUES (1,'WS1','Germany'),(2,'WS2','France'); CREATE TABLE temperature (id INT,station_id INT,timestamp TIMESTAMP,temperature FLOAT); INSERT INTO temperature (id,station_id,timestamp,temperature) VALUES (1,1,'2021-05-01 12:00:00',80),(2,1,'2021-05-01 16:00:00',85),(3,1,'2021-05-01 20:00:00',78),(4,2,'2021-05-01 12:00:00',72),(5,2,'2021-05-01 16:00:00',75),(6,2,'2021-05-01 20:00:00',70); | UPDATE temperature SET temperature = (temperature - 32) * 5/9 WHERE station_id IN (SELECT id FROM weather_stations WHERE country = 'Germany') AND EXTRACT(MONTH FROM timestamp) = 5; |
What is the total number of clean energy policies in the 'policy_database' table for countries in the 'Europe' region? | CREATE TABLE policy_database (policy_id INT,country_name VARCHAR(100),region VARCHAR(50),policy_type VARCHAR(50)); INSERT INTO policy_database (policy_id,country_name,region,policy_type) VALUES (1,'Germany','Europe','Renewable Portfolio Standard'),(2,'Canada','North America','Carbon Tax'),(3,'France','Europe','Feed-in Tariff'); | SELECT COUNT(*) FROM policy_database WHERE region = 'Europe'; |
What is the percentage of security incidents resolved within SLA for each department in the last quarter? | CREATE TABLE SecurityIncidents(id INT,department VARCHAR(50),resolved BOOLEAN,resolution_time FLOAT,incident_date DATE); | SELECT department, AVG(IF(resolved, 1, 0)) as resolved_within_sla FROM SecurityIncidents WHERE incident_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 3 MONTH) GROUP BY department; |
What is the number of shared electric scooters in Sao Paulo? | CREATE TABLE shared_escooters (scooter_id INT,registration_date TIMESTAMP,scooter_type VARCHAR(50),city VARCHAR(50)); | SELECT COUNT(*) as num_scooters FROM shared_escooters WHERE city = 'Sao Paulo'; |
How many policyholders from Brazil have an annual income greater than $50,000, and what is the average claim amount for this group? | CREATE TABLE Policyholders (PolicyholderID INT,Country VARCHAR(50),AnnualIncome DECIMAL(10,2)); INSERT INTO Policyholders VALUES (1,'Brazil',60000); INSERT INTO Policyholders VALUES (2,'Brazil',40000); INSERT INTO Policyholders VALUES (3,'Brazil',70000); INSERT INTO Policyholders VALUES (4,'Brazil',35000); CREATE TABLE Claims (PolicyholderID INT,ClaimAmount DECIMAL(10,2)); INSERT INTO Claims VALUES (1,5000); INSERT INTO Claims VALUES (2,3000); INSERT INTO Claims VALUES (3,8000); | SELECT COUNT(*) AS HighIncomePolicyholders, AVG(ClaimAmount) AS AvgClaimAmount FROM Claims JOIN Policyholders ON Claims.PolicyholderID = Policyholders.PolicyholderID WHERE Policyholders.Country = 'Brazil' AND Policyholders.AnnualIncome > 50000; |
What is the total number of policies for 'High-Risk' drivers? | CREATE TABLE policies (id INT,policy_number TEXT,driver_risk TEXT); INSERT INTO policies (id,policy_number,driver_risk) VALUES (1,'P1234','Medium-Risk'); INSERT INTO policies (id,policy_number,driver_risk) VALUES (2,'P5678','High-Risk'); INSERT INTO policies (id,policy_number,driver_risk) VALUES (3,'P9012','Low-Risk'); | SELECT COUNT(*) FROM policies WHERE driver_risk = 'High-Risk'; |
Find the maximum safety rating for members in the 'Government_Employees_Union'. | CREATE TABLE Government_Employees_Union (union_member_id INT,member_id INT,safety_rating FLOAT); INSERT INTO Government_Employees_Union (union_member_id,member_id,safety_rating) VALUES (1,101,8.50),(1,102,9.25),(1,103,9.00),(2,201,8.75),(2,202,9.50); | SELECT MAX(safety_rating) FROM Government_Employees_Union; |
Delete all exhibitions with less than 500 visitors | CREATE TABLE Exhibitions (id INT,name TEXT,visitor_count INT); | DELETE FROM Exhibitions WHERE visitor_count < 500; |
Find the top 3 contributors with the lowest recycling rate in the 'waste_contributors' table. | CREATE TABLE waste_contributors (contributor VARCHAR(20),recycling_rate FLOAT); INSERT INTO waste_contributors (contributor,recycling_rate) VALUES ('Manufacturing',0.4),('Commercial',0.38),('Residential',0.35),('Institutional',0.32),('Agricultural',0.2),('Industrial',0.15); | SELECT contributor FROM waste_contributors WHERE recycling_rate IN (SELECT MIN(recycling_rate) FROM waste_contributors) LIMIT 3; |
What is the maximum heart rate for users during morning workouts? | CREATE TABLE workouts (id INT,user_id INT,heart_rate INT,workout_time TIME); INSERT INTO workouts (id,user_id,heart_rate,workout_time) VALUES (1,1,160,'07:00:00'); | SELECT MAX(heart_rate) FROM workouts WHERE workout_time BETWEEN '06:00:00' AND '11:59:59'; |
What is the average safety score for all creative AI applications in the 'AI_Fairness' schema? | CREATE SCHEMA AI_Fairness;CREATE TABLE Creative_AI (app_id INT,safety_score FLOAT); INSERT INTO Creative_AI (app_id,safety_score) VALUES (1,0.8),(2,0.9),(3,0.7); | SELECT AVG(safety_score) FROM AI_Fairness.Creative_AI; |
List all rural infrastructure projects in Nepal and their respective start dates. | CREATE TABLE rural_infrastructure_projects (id INT,project_name VARCHAR(50),country VARCHAR(50),start_date DATE); INSERT INTO rural_infrastructure_projects (id,project_name,country,start_date) VALUES (1,'Rajiv Gandhi Rural Electrification Program','India','2010-04-01'),(2,'BharatNet Rural Broadband Initiative','India','2015-07-26'),(3,'Rural Access Program','Nepal','2007-01-01'); | SELECT project_name, start_date FROM rural_infrastructure_projects WHERE country = 'Nepal'; |
What is the total number of locations in the fish_stock table? | CREATE TABLE fish_stock (location VARCHAR(50)); INSERT INTO fish_stock (location) VALUES ('Lake Victoria'),('Lake Tanganyika'),('Pacific Ocean'); | SELECT COUNT(DISTINCT location) FROM fish_stock; |
Identify the top 3 countries with the highest percentage of attendees | CREATE TABLE attendee_info (attendee_id INT,country VARCHAR(20)); INSERT INTO attendee_info (attendee_id,country) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'),(4,'USA'),(5,'Brazil'),(6,'USA'); | SELECT country, (COUNT(attendee_id) OVER (PARTITION BY country) * 100.0 / (SELECT COUNT(attendee_id) FROM attendee_info)) AS percentage FROM attendee_info GROUP BY country ORDER BY percentage DESC LIMIT 3; |
What is the total revenue for the top 5 dispensaries in Michigan in the last year? | CREATE TABLE Dispensaries (id INT,name TEXT,state TEXT);CREATE TABLE Transactions (id INT,dispensary_id INT,transaction_value DECIMAL); | SELECT D.name, SUM(T.transaction_value) FROM Dispensaries D JOIN Transactions T ON D.id = T.dispensary_id WHERE D.state = 'Michigan' AND T.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY D.id ORDER BY SUM(T.transaction_value) DESC LIMIT 5; |
Which cultivators supply sativa strains to dispensaries in Oregon? | CREATE TABLE CultivatorData (CultivatorName VARCHAR(50),State VARCHAR(20),Strain VARCHAR(20)); INSERT INTO CultivatorData (CultivatorName,State,Strain) VALUES ('Highland Organics','Oregon','Sativa'),('Emerald Creek Farms','California','Sativa'),('Mountain High Sungrown','Oregon','Hybrid'),('Green Earth Gardens','Washington','Indica'),('Pure Green Farms','Colorado','Sativa'); | SELECT CultivatorName FROM CultivatorData WHERE State = 'Oregon' AND Strain = 'Sativa'; |
Find the attorney who has billed the most hours in the 'billing' table? | CREATE TABLE billing (attorney_id INT,client_id INT,hours FLOAT,rate FLOAT); INSERT INTO billing (attorney_id,client_id,hours,rate) VALUES (1,101,10,300),(2,102,8,350),(3,103,12,250); | SELECT attorney_id, SUM(hours) FROM billing GROUP BY attorney_id ORDER BY SUM(hours) DESC LIMIT 1; |
What is the total billing amount by practice area? | CREATE TABLE PracticeAreas (PracticeAreaID INT,PracticeArea VARCHAR(50)); INSERT INTO PracticeAreas (PracticeAreaID,PracticeArea) VALUES (1,'Criminal Law'),(2,'Family Law'),(3,'Personal Injury'),(4,'Employment Law'); | SELECT PA.PracticeArea, SUM(P.BillingAmount) AS Total_Billing_Amount FROM PracticeAreas PA INNER JOIN Precedents P ON PA.PracticeAreaID = P.PracticeAreaID GROUP BY PA.PracticeArea; |
Which clients from historically marginalized regions have paid less than the average billing rate? | CREATE TABLE Clients (id INT,name VARCHAR(50),attorney_id INT,region VARCHAR(50),paid DECIMAL(5,2)); CREATE TABLE Attorneys (id INT,billing_rate DECIMAL(5,2)); INSERT INTO Attorneys (id,billing_rate) VALUES (1,200.00),(2,300.00); INSERT INTO Clients (id,name,attorney_id,region,paid) VALUES (1,'Client1',1,'Historically Marginalized Region 1',600.00),(2,'Client2',1,'Historically Marginalized Region 1',400.00),(3,'Client3',2,'Historically Marginalized Region 2',1000.00),(4,'Client4',2,'Not Historically Marginalized Region',1200.00); | SELECT Clients.name FROM Clients INNER JOIN Attorneys ON Clients.attorney_id = Attorneys.id WHERE Clients.paid < Attorneys.billing_rate AND Clients.region IN ('Historically Marginalized Region 1', 'Historically Marginalized Region 2'); |
Calculate the total quantity of chemicals that were produced in the first quarter of 2022 and display them in alphabetical order. | CREATE TABLE manufacturing_plants (id INT PRIMARY KEY,plant_name VARCHAR(255),location VARCHAR(255),country VARCHAR(255),capacity INT,last_inspection_date DATE);CREATE TABLE production_data (id INT PRIMARY KEY,plant_id INT,chemical_name VARCHAR(255),production_date DATE,quantity INT,FOREIGN KEY (plant_id) REFERENCES manufacturing_plants(id));CREATE TABLE chemical_prices (id INT PRIMARY KEY,chemical_name VARCHAR(255),price DECIMAL(10,2),price_updated_date DATE); | SELECT chemical_name, SUM(quantity) AS total_quantity FROM production_data WHERE production_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY chemical_name ORDER BY chemical_name; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.