instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total revenue for each genre in the year 2021?
|
CREATE TABLE MusicSales (sale_id INT,sale_date DATE,sale_amount DECIMAL(10,2),genre VARCHAR(255)); INSERT INTO MusicSales (sale_id,sale_date,sale_amount,genre) VALUES (1,'2021-01-01',15.99,'Pop'),(2,'2020-12-31',20.00,'Rock'),(3,'2021-02-14',10.99,'Jazz'),(4,'2021-03-01',12.99,'R&B'),(5,'2021-04-01',14.99,'Pop');
|
SELECT genre, SUM(sale_amount) as total_revenue FROM MusicSales WHERE YEAR(sale_date) = 2021 GROUP BY genre;
|
Find the total energy generated by renewable sources in the US
|
CREATE TABLE renewable_sources (country VARCHAR(50),energy_type VARCHAR(50),generation FLOAT); INSERT INTO renewable_sources (country,energy_type,generation) VALUES ('United States','Solar',123.45),('United States','Wind',678.90);
|
SELECT SUM(generation) FROM renewable_sources WHERE country = 'United States' AND energy_type IN ('Solar', 'Wind');
|
What is the total revenue from concert ticket sales for artists of the 'Rock' genre?
|
CREATE TABLE TicketSales (TicketSaleID INT,ConcertID INT,UserID INT,TicketPrice DECIMAL(5,2)); INSERT INTO TicketSales VALUES (1,7,20,65.50),(2,8,21,55.00),(3,9,22,70.00);
|
SELECT SUM(TicketPrice) FROM TicketSales JOIN Concerts ON TicketSales.ConcertID = Concerts.ConcertID WHERE Concerts.Genre = 'Rock';
|
What was the minimum budget allocated for military innovation by South American countries in 2019?
|
CREATE TABLE military_innovation (country VARCHAR(50),year INT,budget INT); INSERT INTO military_innovation (country,year,budget) VALUES ('Brazil',2019,5000000),('Argentina',2019,4000000),('Colombia',2019,3000000);
|
SELECT MIN(budget) FROM military_innovation WHERE country IN ('Brazil', 'Argentina', 'Colombia') AND year = 2019;
|
How many hotels have adopted AI in Africa?
|
CREATE TABLE ai_adoption (hotel_id INT,country VARCHAR(255),ai_adoption BOOLEAN); INSERT INTO ai_adoption (hotel_id,country,ai_adoption) VALUES (1,'Africa',true),(2,'Africa',false),(3,'South America',true);
|
SELECT COUNT(*) FROM ai_adoption WHERE country = 'Africa' AND ai_adoption = true;
|
Display the number of transactions for each regulatory framework in the Polkadot blockchain, sorted by the number of transactions in descending order.
|
CREATE TABLE polkadot_transactions (transaction_id INTEGER,regulatory_framework VARCHAR(20));
|
SELECT regulatory_framework, COUNT(*) FROM polkadot_transactions GROUP BY regulatory_framework ORDER BY COUNT(*) DESC;
|
Who are the chairpersons of all committees in the 'Finance' sector?
|
CREATE TABLE Committee (id INT,name VARCHAR(50),chairman INT,sector VARCHAR(20),FOREIGN KEY (chairman) REFERENCES Legislator(id)); INSERT INTO Committee (id,name,chairman,sector) VALUES (3,'Finance Committee',5,'Finance'); INSERT INTO Committee (id,name,chairman,sector) VALUES (4,'Budget Committee',6,'Finance');
|
SELECT Committee.name, Legislator.name FROM Committee INNER JOIN Legislator ON Committee.chairman = Legislator.id WHERE Committee.sector = 'Finance';
|
List the number of female and male professors in each department
|
CREATE TABLE faculty (id INT,name VARCHAR(255),gender VARCHAR(10),department VARCHAR(255)); INSERT INTO faculty (id,name,gender,department) VALUES (1,'Alice','Female','Physics'),(2,'Bob','Male','Physics'),(3,'Charlie','Non-binary','Mathematics'),(4,'Dave','Male','Mathematics'),(5,'Eve','Female','Chemistry');
|
SELECT department, gender, COUNT(*) as count FROM faculty GROUP BY department, gender;
|
What is the average digital interaction score for visitors from the LGBTQ+ community in 2020?
|
CREATE TABLE Interaction_Scores (visitor_id INT,community_name VARCHAR(100),year INT,score INT);
|
SELECT AVG(score) FROM Interaction_Scores WHERE community_name = 'LGBTQ+' AND year = 2020;
|
What is the maximum salary for each department in the company?
|
CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(20),Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (1,'IT',85000),(2,'HR',70000);
|
SELECT Department, MAX(Salary) as MaxSalary FROM Employees GROUP BY Department;
|
Insert a new record into the 'stations' table for a new 'Overground' station named 'StationD' with station_id '4'
|
CREATE TABLE stations (station_id INT,station_name VARCHAR(50),station_type VARCHAR(20)); INSERT INTO stations (station_id,station_name,station_type) VALUES (1,'StationA','Underground'),(2,'StationB','Overground'),(3,'StationC','Underground');
|
INSERT INTO stations (station_id, station_name, station_type) VALUES (4, 'StationD', 'Overground');
|
What is the total revenue generated by eco-friendly hotels in the last month?
|
CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,type TEXT,daily_rate DECIMAL(5,2),revenue INT); INSERT INTO hotels (hotel_id,hotel_name,type,daily_rate,revenue) VALUES (1,'Eco Hotel','eco',100.00,3000),(2,'Urban Resort','standard',150.00,5000),(3,'Beach Retreat','eco',120.00,4000);
|
SELECT SUM(revenue) FROM hotels WHERE type = 'eco' AND revenue BETWEEN DATE_SUB(curdate(), INTERVAL 1 MONTH) AND curdate();
|
What's the total investment amount for companies in the 'technology' sector, by year?
|
CREATE TABLE investments_sector (id INT,investment_year INT,sector VARCHAR(20),investment_amount FLOAT); INSERT INTO investments_sector (id,investment_year,sector,investment_amount) VALUES (1,2019,'technology',120000),(2,2020,'finance',185000),(3,2018,'technology',175000);
|
SELECT investment_year, SUM(investment_amount) FROM investments_sector WHERE sector = 'technology' GROUP BY investment_year;
|
What is the total number of vehicles sold in 'sales_data' view that have a speed greater than 75 mph?
|
CREATE VIEW sales_data AS SELECT id,vehicle_type,avg_speed,sales FROM vehicle_sales WHERE sales > 20000;
|
SELECT SUM(sales) FROM sales_data WHERE avg_speed > 75;
|
What is the average age of all satellites deployed by SpaceX?
|
CREATE TABLE satellites (id INT,name TEXT,country TEXT,launch_date DATE,mass FLOAT); INSERT INTO satellites (id,name,country,launch_date,mass) VALUES (1,'Starlink 1','USA','2018-11-19',470);
|
SELECT AVG(DATEDIFF('2022-10-01', launch_date)) FROM satellites WHERE country = 'USA';
|
What is the average food justice score in North America?
|
CREATE TABLE food_justice_scores_na (country VARCHAR(50),score FLOAT); INSERT INTO food_justice_scores_na (country,score) VALUES ('Canada',75.3),('US',72.5);
|
SELECT AVG(score) FROM food_justice_scores_na WHERE country IN ('Canada', 'US');
|
How many community policing meetings were held in each city in the state of Illinois in the last 6 months?
|
CREATE TABLE community_policing_il (id INT,city VARCHAR(255),meeting_date DATE);
|
SELECT city, COUNT(*) as total_meetings FROM community_policing_il WHERE meeting_date BETWEEN '2021-07-01' AND '2021-12-31' GROUP BY city;
|
What is the average cost of spacecrafts manufactured by AstroCorp that have been launched?
|
CREATE TABLE Spacecrafts (id INT,name VARCHAR(100),manufacturer VARCHAR(100),mass FLOAT,launched BOOLEAN); INSERT INTO Spacecrafts (id,name,manufacturer,mass,launched) VALUES (1,'AstroShip 1','AstroCorp',1000,true),(2,'AstroShip 2','AstroCorp',2000,false);
|
SELECT AVG(mass) FROM Spacecrafts WHERE manufacturer = 'AstroCorp' AND launched = true;
|
Delete all records from the 'Programs' table
|
CREATE TABLE Programs (program_id INT,program_name VARCHAR(50),location VARCHAR(50)); INSERT INTO Programs (program_id,program_name,location) VALUES (1,'Senior Fitness','Oakwood Community Center');
|
DELETE FROM Programs;
|
What is the minimum investment amount for the 'Latin America' region?
|
CREATE TABLE impact_investments (id INT,region VARCHAR(20),investment_year INT,investment_amount FLOAT); INSERT INTO impact_investments (id,region,investment_year,investment_amount) VALUES (1,'Latin America',2020,100000),(2,'Africa',2019,120000),(3,'Latin America',2021,150000);
|
SELECT MIN(investment_amount) FROM impact_investments WHERE region = 'Latin America';
|
Which excavation sites have more than 3 artifacts with analysis results indicating 'Presence of Organic Materials'?
|
CREATE TABLE ExcavationSites (SiteName VARCHAR(50),ArtifactCount INT); INSERT INTO ExcavationSites (SiteName,ArtifactCount) VALUES ('Site1',4),('Site2',2),('Site3',5);
|
SELECT SiteName FROM ExcavationSites WHERE ArtifactCount > 3 INTERSECT SELECT SiteName FROM (SELECT SiteName, COUNT(*) FROM ExcavationSites s JOIN Artifacts a ON s.SiteName = a.SiteName WHERE a.AnalysisResult = 'Presence of Organic Materials' GROUP BY SiteName) AS Subquery;
|
How many smart contracts have been created per month in 2021?
|
CREATE TABLE time_series (id INT,month VARCHAR(7),value INT); INSERT INTO time_series VALUES (1,'Jan-2021',500),(2,'Feb-2021',600),(3,'Mar-2021',700); CREATE TABLE smart_contract (id INT,name VARCHAR(255),time_series_id INT); INSERT INTO smart_contract VALUES (1,'Contract1',1),(2,'Contract2',2),(3,'Contract3',3);
|
SELECT EXTRACT(MONTH FROM time_series.month) AS month, COUNT(*) FROM smart_contract JOIN time_series ON smart_contract.time_series_id = time_series.id GROUP BY month ORDER BY month;
|
What is the minimum ticket price for any event in each city?
|
CREATE TABLE sports_venue (venue_id INT,event_name VARCHAR(255),price DECIMAL(5,2),city VARCHAR(255)); INSERT INTO sports_venue (venue_id,event_name,price,city) VALUES (1,'Basketball Game',120.50,'California'),(2,'Baseball Game',50.00,'New York'),(3,'Soccer Game',30.00,'California'),(4,'Hockey Game',75.00,'New York'),(5,'Golf Tournament',100.00,'Florida');
|
SELECT city, MIN(price) FROM sports_venue GROUP BY city;
|
What is the total number of employees and job applicants by gender?
|
CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10)); INSERT INTO Employees (EmployeeID,Gender) VALUES (1,'Male'),(2,'Female'),(3,'Non-binary'); CREATE TABLE Applicants (ApplicantID INT,Gender VARCHAR(10)); INSERT INTO Applicants (ApplicantID,Gender) VALUES (1,'Male'),(2,'Female'),(3,'Transgender'),(4,'Non-binary');
|
SELECT 'Employees' AS source, Gender, COUNT(*) as total FROM Employees GROUP BY Gender UNION ALL SELECT 'Applicants', Gender, COUNT(*) FROM Applicants GROUP BY Gender;
|
List all garments that are made of sustainable materials and their respective manufacturing costs.
|
CREATE TABLE garments (garment_id INT,garment_name VARCHAR(50),material VARCHAR(20),manufacturing_cost DECIMAL(10,2)); CREATE VIEW sustainable_materials AS SELECT material FROM sustainable_materials_list;
|
SELECT garment_id, garment_name, manufacturing_cost FROM garments INNER JOIN sustainable_materials ON garments.material = sustainable_materials.material;
|
List the number of cases lost by female attorneys from the 'Boston' office?
|
CREATE TABLE offices (office_id INT,office_name VARCHAR(20)); INSERT INTO offices (office_id,office_name) VALUES (1,'Boston'),(2,'New York'),(3,'Chicago'); CREATE TABLE attorneys (attorney_id INT,attorney_name VARCHAR(30),gender VARCHAR(10)); INSERT INTO attorneys (attorney_id,attorney_name,gender) VALUES (101,'John Smith','Male'),(102,'Jane Doe','Female'),(103,'Mike Johnson','Male'),(104,'Sara Brown','Female'),(105,'David Williams','Male'); CREATE TABLE cases (case_id INT,attorney_id INT,office_id INT,case_outcome VARCHAR(10)); INSERT INTO cases (case_id,attorney_id,office_id,case_outcome) VALUES (1,101,1,'Lost'),(2,102,1,'Won'),(3,103,1,'Lost'),(4,104,2,'Lost'),(5,105,3,'Won');
|
SELECT COUNT(*) FROM cases JOIN offices ON cases.office_id = offices.office_id JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE offices.office_name = 'Boston' AND attorneys.gender = 'Female' AND case_outcome = 'Lost';
|
How many visitors were there in each country in 2021?
|
CREATE TABLE country_visitors (country VARCHAR(255),visitors INT,year INT); INSERT INTO country_visitors (country,visitors,year) VALUES ('Brazil',5000000,2021),('India',10000000,2021),('Indonesia',7000000,2021),('Mexico',8000000,2021),('South Korea',9000000,2021),('United States',12000000,2021);
|
SELECT country, visitors FROM country_visitors WHERE year = 2021;
|
What is the total number of visitors to children's programs?
|
CREATE TABLE if not exists programs (id INT,name VARCHAR(255),type VARCHAR(255),visitors INT); INSERT INTO programs (id,name,type,visitors) VALUES (1,'Story Time','Children',300),(2,'Art Class','Children',250),(3,'Theater Workshop','Youth',150),(4,'Jazz Night','Adults',100);
|
SELECT SUM(visitors) FROM programs WHERE type = 'Children';
|
Delete all loans disbursed to microfinance institutions in Oceania in Q3 2021
|
CREATE SCHEMA if not exists finance;CREATE TABLE if not exists loans (id INT PRIMARY KEY,institution_name TEXT,region TEXT,amount DECIMAL(10,2),disbursal_date DATE); INSERT INTO loans (id,institution_name,region,amount,disbursal_date) VALUES (1,'ABC Microfinance','Oceania',5000.00,'2021-07-15'),(2,'DEF Microfinance','Oceania',6000.00,'2021-10-10');
|
DELETE FROM finance.loans WHERE region = 'Oceania' AND EXTRACT(QUARTER FROM disbursal_date) = 3 AND EXTRACT(YEAR FROM disbursal_date) = 2021;
|
What is the location of 'Site Charlie' in the 'mining_sites' table?
|
CREATE TABLE mining_sites (id INT,name VARCHAR(50),location VARCHAR(50),num_employees INT); INSERT INTO mining_sites (id,name,location,num_employees) VALUES (1,'Site Alpha','USA',100),(2,'Site Bravo','Canada',150),(3,'Site Charlie','Australia',200);
|
SELECT location FROM mining_sites WHERE name = 'Site Charlie';
|
What is the minimum revenue for each farm?
|
CREATE TABLE farm_revenue (id INT PRIMARY KEY,farm_id INT,year INT,revenue INT); INSERT INTO farm_revenue (id,farm_id,year,revenue) VALUES (4,3,2019,65000); INSERT INTO farm_revenue (id,farm_id,year,revenue) VALUES (5,4,2020,70000); INSERT INTO farm_revenue (id,farm_id,year,revenue) VALUES (6,4,2021,75000);
|
SELECT farm_id, MIN(revenue) FROM farm_revenue GROUP BY farm_id;
|
What is the minimum sale price for naval equipment in Japan?
|
CREATE TABLE EquipmentTypeSales (id INT PRIMARY KEY,equipment_type VARCHAR(50),country VARCHAR(50),sale_price DECIMAL(10,2));
|
SELECT MIN(sale_price) FROM EquipmentTypeSales WHERE equipment_type = 'naval' AND country = 'Japan';
|
What is the maximum number of professional development courses completed by educators?
|
CREATE TABLE educators(id INT,num_courses INT); INSERT INTO educators VALUES (1,2),(2,5),(3,3),(4,10),(5,0);
|
SELECT MAX(num_courses) FROM educators;
|
List the top 3 cities with the longest average emergency response time
|
CREATE TABLE emergency_calls (id INT,city VARCHAR(20),response_time INT); INSERT INTO emergency_calls (id,city,response_time) VALUES (1,'San Francisco',120),(2,'New York',150),(3,'Los Angeles',100);
|
SELECT city, AVG(response_time) as avg_response_time FROM emergency_calls GROUP BY city ORDER BY avg_response_time DESC LIMIT 3;
|
Which decentralized applications are available in Japan?
|
CREATE TABLE decentralized_apps (app_id INT PRIMARY KEY,app_name TEXT,location TEXT); INSERT INTO decentralized_apps (app_id,app_name,location) VALUES (5,'Curve','Japan'),(6,'Aave','United Kingdom');
|
SELECT app_name FROM decentralized_apps WHERE location = 'Japan';
|
How many community engagement events were organized in Canada in Q3 2021?
|
CREATE TABLE Community_Engagement_Events (id INT,country VARCHAR(255),quarter INT,number_of_events INT);
|
SELECT SUM(number_of_events) FROM Community_Engagement_Events WHERE country = 'Canada' AND quarter = 3;
|
What is the maximum age of athletes in the golf_players table?
|
CREATE TABLE golf_players (player_id INT,name VARCHAR(50),age INT,country VARCHAR(50)); INSERT INTO golf_players (player_id,name,age,country) VALUES (1,'Tiger Woods',46,'USA'); INSERT INTO golf_players (player_id,name,age,country) VALUES (2,'Phil Mickelson',51,'USA');
|
SELECT MAX(age) FROM golf_players;
|
What was the total quantity of products manufactured by each factory in January 2022, grouped by factory location?
|
CREATE TABLE factories (factory_id INT,factory_location VARCHAR(50)); INSERT INTO factories (factory_id,factory_location) VALUES (1,'New York'),(2,'Chicago'),(3,'Los Angeles'); CREATE TABLE manufacturing (manufacturing_id INT,factory_id INT,product_quantity INT,manufacture_date DATE); INSERT INTO manufacturing (manufacturing_id,factory_id,product_quantity,manufacture_date) VALUES (1,1,500,'2022-01-03'),(2,1,700,'2022-01-10'),(3,2,300,'2022-01-05'),(4,2,400,'2022-01-12'),(5,3,600,'2022-01-07'),(6,3,800,'2022-01-15');
|
SELECT factory_location, SUM(product_quantity) as total_quantity FROM manufacturing JOIN factories ON manufacturing.factory_id = factories.factory_id WHERE manufacture_date >= '2022-01-01' AND manufacture_date < '2022-02-01' GROUP BY factory_location;
|
Calculate the percentage of total water usage for each location in the year 2020
|
CREATE TABLE water_usage (id INT PRIMARY KEY,year INT,location VARCHAR(50),usage FLOAT); INSERT INTO water_usage (id,year,location,usage) VALUES (1,2020,'Las Vegas',3567.89),(2,2020,'New Orleans',2567.89),(3,2020,'Philadelphia',1890.12),(4,2020,'Providence',1234.56),(5,2020,'Sacramento',567.89);
|
SELECT location, ROUND(100.0 * usage / (SELECT SUM(usage) FROM water_usage WHERE year = 2020)::DECIMAL, 2) AS percentage FROM water_usage WHERE year = 2020;
|
What is the total number of satellites launched by the European Space Agency?
|
CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),LaunchDate DATETIME,Agency VARCHAR(50)); INSERT INTO Satellites (SatelliteID,Name,LaunchDate,Agency) VALUES (1,'Sat1','2020-01-01','ESA'),(2,'Sat2','2019-05-15','ESA'),(3,'Sat3','2018-09-14','NASA');
|
SELECT COUNT(*) FROM Satellites WHERE Agency = 'ESA';
|
Identify intersections with high rates of electric vehicle adoption and public transit usage in Chicago and Seattle.
|
CREATE TABLE if not exists Intersections(location CHAR(10),ev_adoption FLOAT,transit_usage INT); INSERT INTO Intersections(location,ev_adoption,transit_usage) VALUES ('Chicago_1st',0.25,1200),('Chicago_1st',0.25,1250),('Chicago_2nd',0.31,1500),('Chicago_2nd',0.31,1450),('Seattle_1st',0.28,800),('Seattle_1st',0.28,850),('Seattle_2nd',0.33,1100),('Seattle_2nd',0.33,1050);
|
SELECT location, ev_adoption, transit_usage FROM Intersections WHERE location IN ('Chicago_1st', 'Chicago_2nd', 'Seattle_1st', 'Seattle_2nd') AND ev_adoption > 0.25 AND transit_usage > 1000;
|
Find the total renewable energy consumption in Australia and Japan?
|
CREATE TABLE renewable_energy (country VARCHAR(20),consumption DECIMAL(10,2)); INSERT INTO renewable_energy (country,consumption) VALUES ('Australia',120.50),('Australia',125.00),('Japan',170.00),('Japan',175.50);
|
SELECT SUM(consumption) FROM renewable_energy WHERE country IN ('Australia', 'Japan');
|
Who are the top three intelligence agency directors with the most successful operations, and what are the names of these operations, including the countries where they took place?
|
CREATE TABLE intelligence_agency (id INT,name VARCHAR(255),director VARCHAR(255)); CREATE TABLE operation (id INT,agency_id INT,name VARCHAR(255),country VARCHAR(255),success_level INT); INSERT INTO intelligence_agency (id,name,director) VALUES (1,'CIA','James Brown'); INSERT INTO operation (id,agency_id,name,country,success_level) VALUES (1,1,'Operation Red','USA',90),(2,1,'Operation Blue','France',95);
|
SELECT i.director, o.name, o.country FROM operation o JOIN intelligence_agency i ON o.agency_id = i.id ORDER BY o.success_level DESC LIMIT 3;
|
Find the difference in the number of donors between the US and Canada.
|
CREATE TABLE donors (id INT,name TEXT,country TEXT); INSERT INTO donors (id,name,country) VALUES (1,'Alice','USA'),(2,'Bob','Canada'),(3,'Charlie','USA'),(4,'David','UK');
|
SELECT COUNT(*) FILTER (WHERE country = 'USA') - COUNT(*) FILTER (WHERE country = 'Canada') FROM donors;
|
Which smart city projects have a budget greater than $600,000?
|
CREATE TABLE IF NOT EXISTS smart_cities (project_id INT,project_name VARCHAR(255),budget FLOAT,PRIMARY KEY (project_id)); INSERT INTO smart_cities (project_id,project_name,budget) VALUES (1,'Intelligent Lighting',500000),(2,'Smart Waste Management',750000),(3,'E-Governance Services',600000);
|
SELECT * FROM smart_cities WHERE budget > 600000;
|
What is the maximum carbon offset of renewable energy projects in the Eastern region?
|
CREATE TABLE offsets (id INT,region VARCHAR(20),project VARCHAR(20),offset INT); INSERT INTO offsets (id,region,project,offset) VALUES (1,'Eastern','Wind Farm',5000); INSERT INTO offsets (id,region,project,offset) VALUES (2,'Western','Solar Farm',7000);
|
SELECT MAX(offset) FROM offsets WHERE region = 'Eastern';
|
What is the average cost of an aircraft manufactured by Manufacturer1?
|
CREATE TABLE Aircraft (aircraft_model VARCHAR(50),manufacturer VARCHAR(50),cost FLOAT); INSERT INTO Aircraft (aircraft_model,manufacturer,cost) VALUES ('ModelA','Manufacturer1',1000),('ModelB','Manufacturer1',2000),('ModelC','Manufacturer2',1500);
|
SELECT AVG(cost) as avg_cost FROM Aircraft WHERE manufacturer = 'Manufacturer1'
|
Delete the 'military_equipment' table
|
CREATE TABLE military_equipment (equipment_name VARCHAR(255),origin_country VARCHAR(255));
|
DROP TABLE military_equipment;
|
Add a new record to the "RuralInfrastructure" table for a new 'Wind Turbine' with a construction year of 2020
|
CREATE TABLE RuralInfrastructure (id INT PRIMARY KEY,type VARCHAR(255),construction_year INT);
|
INSERT INTO RuralInfrastructure (type, construction_year) VALUES ('Wind Turbine', 2020);
|
What is the average patient capacity for hospitals in the South region?
|
CREATE TABLE hospitals (id INT,region VARCHAR(255),name VARCHAR(255),patient_capacity INT); INSERT INTO hospitals (id,region,name,patient_capacity) VALUES (1,'Northeast','Hospital A',100),(2,'West','Hospital B',150),(3,'South','Hospital C',120);
|
SELECT AVG(patient_capacity) as avg_capacity FROM hospitals WHERE region = 'South';
|
What is the number of military equipment maintenance requests submitted by each unit in the Southeast region in the past month?
|
CREATE TABLE maintenance_requests (request_id INT,request_date DATE,request_type VARCHAR(255),unit VARCHAR(255),region VARCHAR(255)); INSERT INTO maintenance_requests (request_id,request_date,request_type,unit,region) VALUES (1,'2021-01-01','Equipment Maintenance','Unit A','Southeast'); INSERT INTO maintenance_requests (request_id,request_date,request_type,unit,region) VALUES (2,'2021-02-01','Facility Maintenance','Unit B','Southeast');
|
SELECT unit, COUNT(*) as total_requests FROM maintenance_requests WHERE request_type = 'Equipment Maintenance' AND region = 'Southeast' AND request_date >= DATEADD(month, -1, GETDATE()) GROUP BY unit;
|
What is the minimum number of hours of professional development completed by a teacher in the "Suburban Education" district in the last year?
|
CREATE TABLE TeacherProfessionalDevelopment (TeacherID INT,Date DATE,District VARCHAR(50),Hours INT); INSERT INTO TeacherProfessionalDevelopment (TeacherID,Date,District,Hours) VALUES (1,'2021-12-15','Suburban Education',5);
|
SELECT MIN(Hours) FROM TeacherProfessionalDevelopment WHERE District = 'Suburban Education' AND Date >= DATEADD(year, -1, GETDATE());
|
What is the average attendance at cultural events in Tokyo and Paris?
|
CREATE TABLE CulturalEvents (id INT,city VARCHAR(50),attendance INT); INSERT INTO CulturalEvents (id,city,attendance) VALUES (1,'Tokyo',200),(2,'Tokyo',300),(3,'Paris',150),(4,'Paris',250),(5,'London',350);
|
SELECT AVG(attendance) FROM CulturalEvents WHERE city IN ('Tokyo', 'Paris');
|
How many goals has Player X scored?
|
CREATE TABLE Players (player_id VARCHAR(10),goals INT); INSERT INTO Players (player_id,goals) VALUES ('Player X',25),('Player X',20),('Player X',30);
|
SELECT SUM(goals) FROM Players WHERE player_id = 'Player X';
|
What is the average financial wellbeing score of individuals in Indonesia with an income over 5,000,000 IDR?
|
CREATE TABLE individuals (individual_id INT,individual_name TEXT,income INT,financial_wellbeing_score INT,country TEXT); INSERT INTO individuals (individual_id,individual_name,income,financial_wellbeing_score,country) VALUES (1,'John Doe',6000000,7,'Indonesia'),(2,'Jane Doe',4000000,8,'Indonesia'),(3,'Alice Smith',8000000,9,'Indonesia'),(4,'Bob Johnson',3000000,6,'Indonesia');
|
SELECT AVG(financial_wellbeing_score) FROM individuals WHERE income > 5000000 AND country = 'Indonesia';
|
How many algorithmic fairness incidents were reported by each AI application?
|
CREATE TABLE IncidentByApp (id INT,app VARCHAR(255),region VARCHAR(255),incident_count INT); INSERT INTO IncidentByApp (id,app,region,incident_count) VALUES (1,'AI Writer','North America',12),(2,'AI Artist','Europe',15),(3,'AI Composer','Asia',8),(4,'AI Writer','South America',5),(5,'AI Artist','Africa',2),(6,'AI Composer','North America',10);
|
SELECT app, SUM(incident_count) as total_incidents FROM IncidentByApp GROUP BY app;
|
What is the maximum veteran unemployment rate for the last 6 months, and the date it was reported?
|
CREATE TABLE veteran_unemployment (unemployment_rate FLOAT,report_date DATE); INSERT INTO veteran_unemployment (unemployment_rate,report_date) VALUES (4.1,'2021-12-01'),(4.3,'2021-11-01'),(4.5,'2021-10-01');
|
SELECT MAX(unemployment_rate), report_date FROM veteran_unemployment WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
What is the minimum fine amount issued in traffic court in the past year, broken down by the type of violation?
|
CREATE TABLE traffic_court_records (id INT,violation_type TEXT,fine_amount DECIMAL(5,2),court_date DATE);
|
SELECT violation_type, MIN(fine_amount) FROM traffic_court_records WHERE court_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY violation_type;
|
Find the average price of organic skincare products sold in the US.
|
CREATE TABLE products (product_id INT,product_name VARCHAR(255),price DECIMAL(5,2),is_organic BOOLEAN,country VARCHAR(255)); INSERT INTO products (product_id,product_name,price,is_organic,country) VALUES (1,'Organic Facial Cleanser',19.99,true,'USA'); INSERT INTO products (product_id,product_name,price,is_organic,country) VALUES (2,'Natural Moisturizer',29.99,false,'USA');
|
SELECT AVG(price) FROM products WHERE is_organic = true AND country = 'USA';
|
How many workouts were recorded in the first half of 2021?
|
CREATE TABLE Workouts (WorkoutID INT,MemberID INT,WorkoutDate DATE,Duration INT);
|
SELECT COUNT(*) FROM Workouts WHERE MONTH(WorkoutDate) <= 6 AND YEAR(WorkoutDate) = 2021;
|
Create a new view named "vessel_summary" with columns "vessel_id", "average_speed", "total_fuel_efficiency", and "successful_inspections".
|
CREATE VIEW vessel_summary AS SELECT vessel_id,AVG(avg_speed) AS average_speed,SUM(fuel_efficiency) AS total_fuel_efficiency,COUNT(*) FILTER (WHERE result = 'PASS') AS successful_inspections FROM vessel_performance JOIN safety_records ON vessel_performance.vessel_id = safety_records.vessel_id GROUP BY vessel_id;
|
CREATE VIEW vessel_summary AS SELECT vessel_id, AVG(avg_speed) AS average_speed, SUM(fuel_efficiency) AS total_fuel_efficiency, COUNT(*) FILTER (WHERE result = 'PASS') AS successful_inspections FROM vessel_performance JOIN safety_records ON vessel_performance.vessel_id = safety_records.vessel_id GROUP BY vessel_id;
|
How many timber production sites are there in total, and what is their combined area in hectares, grouped by the sites' respective countries?
|
CREATE TABLE timber_production_3 (id INT,country VARCHAR(255),site_name VARCHAR(255),area FLOAT); INSERT INTO timber_production_3 (id,country,site_name,area) VALUES (1,'Canada','Site A',50000.0),(2,'Canada','Site B',60000.0),(3,'Brazil','Site C',70000.0),(4,'Brazil','Site D',80000.0),(5,'Indonesia','Site E',90000.0);
|
SELECT country, COUNT(*), SUM(area) FROM timber_production_3 GROUP BY country;
|
Show the number of unique tree species in the tree_inventory table that have a diameter at breast height greater than or equal to 40 inches
|
CREATE TABLE tree_inventory (id INT,species VARCHAR(50),diameter FLOAT); INSERT INTO tree_inventory (id,species,diameter) VALUES (1,'Oak',45.8),(2,'Cedar',36.2),(3,'Oak',42.1),(4,'Pine',34.6),(5,'Maple',48.9);
|
SELECT COUNT(DISTINCT species) FROM tree_inventory WHERE diameter >= 40;
|
List all climate mitigation projects in the Middle East and North Africa that started after 2017.
|
CREATE TABLE climate_mitigation (project_id INT,project_name VARCHAR(100),start_year INT,region VARCHAR(50),status VARCHAR(50));
|
SELECT project_id, project_name FROM climate_mitigation WHERE region = 'Middle East and North Africa' AND start_year > 2017 AND status = 'active';
|
What is the total number of whale sightings in the 'Atlantic Ocean'?
|
CREATE TABLE whale_sightings (id INTEGER,location TEXT,sighted INTEGER);
|
SELECT SUM(sighted) FROM whale_sightings WHERE location = 'Atlantic Ocean';
|
Which companies use a specific sustainable material (e.g., organic cotton) and have fair labor practices?
|
CREATE TABLE Companies (id INT,name VARCHAR(255),region VARCHAR(255)); INSERT INTO Companies (id,name,region) VALUES (1,'CompanyA','Asia-Pacific'),(2,'CompanyB','Europe'),(3,'CompanyC','Asia-Pacific'); CREATE TABLE Materials (id INT,company_id INT,material VARCHAR(255),quantity INT); INSERT INTO Materials (id,company_id,material,quantity) VALUES (1,1,'Organic cotton',500),(2,1,'Recycled polyester',300),(3,2,'Organic linen',400),(4,3,'Organic cotton',600),(5,3,'Tencel',700); CREATE TABLE Labor (id INT,company_id INT,fair BOOLEAN); INSERT INTO Labor (id,company_id,fair) VALUES (1,1,FALSE),(2,2,TRUE),(3,3,TRUE);
|
SELECT Companies.name FROM Companies JOIN Materials ON Companies.id = Materials.company_id JOIN Labor ON Companies.id = Labor.company_id WHERE material = 'Organic cotton' AND fair = TRUE;
|
Who are the top 5 artists with the highest total revenue in Asia in the last 5 years?
|
CREATE TABLE ArtWorkSales (artworkID INT,saleDate DATE,artistID INT,revenue DECIMAL(10,2)); CREATE TABLE Artists (artistID INT,artistName VARCHAR(50),country VARCHAR(50));
|
SELECT a.artistName, SUM(aws.revenue) as total_revenue FROM ArtWorkSales aws JOIN Artists a ON aws.artistID = a.artistID WHERE a.country = 'Asia' AND saleDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE GROUP BY a.artistName ORDER BY total_revenue DESC LIMIT 5;
|
What is the average length of songs released by artists from India?
|
CREATE TABLE Artists (ArtistID INT,ArtistName VARCHAR(100),Country VARCHAR(50)); INSERT INTO Artists (ArtistID,ArtistName,Country) VALUES (1,'A.R. Rahman','India'),(2,'Green Day','USA'); CREATE TABLE Songs (SongID INT,SongName VARCHAR(100),ArtistID INT,Length FLOAT); INSERT INTO Songs (SongID,SongName,ArtistID,Length) VALUES (1,'Jai Ho',1,3.4),(2,'American Idiot',2,4.7);
|
SELECT AVG(Length) AS AvgLength FROM Songs WHERE ArtistID IN (SELECT ArtistID FROM Artists WHERE Country = 'India');
|
What is the total landfill capacity in cubic meters for each region in Africa in 2021?
|
CREATE TABLE landfill_capacity (region VARCHAR(50),year INT,capacity FLOAT); INSERT INTO landfill_capacity (region,year,capacity) VALUES ('Northern Africa',2021,1200000.0),('Western Africa',2021,1500000.0),('Eastern Africa',2021,2000000.0),('Central Africa',2021,1800000.0),('Southern Africa',2021,1300000.0);
|
SELECT region, SUM(capacity) FROM landfill_capacity WHERE year = 2021 GROUP BY region;
|
Identify the number of users who have streamed music from both the Pop and Hip Hop genres.
|
CREATE TABLE MultiGenreUsers (UserID INT,Genre VARCHAR(20)); INSERT INTO MultiGenreUsers (UserID,Genre) VALUES (1,'Pop'),(2,'Rock'),(3,'Jazz'),(4,'Pop'),(4,'Hip Hop'),(5,'Pop');
|
SELECT COUNT(DISTINCT UserID) FROM (SELECT UserID FROM MultiGenreUsers WHERE Genre = 'Pop' INTERSECT SELECT UserID FROM MultiGenreUsers WHERE Genre = 'Hip Hop') T;
|
Which vendor has the highest total calorie count?
|
CREATE TABLE Meals (MealID INT,MealName VARCHAR(50),Vendor VARCHAR(50),Calories INT); INSERT INTO Meals (MealID,MealName,Vendor,Calories) VALUES (1,'Spaghetti Bolognese','Pasta Palace',650),(2,'Chicken Tikka Masala','Curry House',850);
|
SELECT Vendor, SUM(Calories) as TotalCalories FROM Meals GROUP BY Vendor ORDER BY TotalCalories DESC LIMIT 1;
|
Count the number of vehicles in need of maintenance for each type
|
CREATE TABLE maintenance_stats (vehicle_id INT,vehicle_type VARCHAR(10),maintenance_needed BOOLEAN); INSERT INTO maintenance_stats (vehicle_id,vehicle_type,maintenance_needed) VALUES (1,'Bus',true),(2,'Train',false),(3,'Bus',false),(4,'Tram',true);
|
SELECT vehicle_type, SUM(maintenance_needed) as number_of_vehicles_in_need_of_maintenance FROM maintenance_stats GROUP BY vehicle_type;
|
Who are the top 5 teachers with the most open pedagogy projects, and how many projects have they completed?
|
CREATE TABLE teacher_open_pedagogy (teacher_id INT,project_id INT); INSERT INTO teacher_open_pedagogy (teacher_id,project_id) VALUES (1,1001),(1,1002),(2,1003),(3,1004),(3,1005),(3,1006),(4,1007),(5,1008);
|
SELECT teacher_id, COUNT(project_id) as num_projects FROM teacher_open_pedagogy GROUP BY teacher_id ORDER BY num_projects DESC LIMIT 5;
|
What is the average number of research grants per department?
|
CREATE TABLE departments (id INT,name VARCHAR(255)); INSERT INTO departments (id,name) VALUES (1,'Biology'),(2,'Mathematics'),(3,'Sociology'); CREATE TABLE research_grants (id INT,department_id INT,amount DECIMAL(10,2)); INSERT INTO research_grants (id,department_id,amount) VALUES (1,1,50000),(2,1,75000),(3,2,30000),(4,3,100000);
|
SELECT d.name, AVG(rg.amount) FROM departments d JOIN research_grants rg ON d.id = rg.department_id GROUP BY d.name;
|
Display the number of cybersecurity vulnerabilities discovered per month and their severity in the European region
|
CREATE TABLE cybersecurity_vulnerabilities (vulnerability_type VARCHAR(255),severity INT,discovery_month INT,region VARCHAR(255)); INSERT INTO cybersecurity_vulnerabilities (vulnerability_type,severity,discovery_month,region) VALUES ('Cross-Site Scripting',4,3,'Europe'),('SQL Injection',7,2,'Europe');
|
SELECT discovery_month, AVG(severity) FROM cybersecurity_vulnerabilities WHERE region = 'Europe' GROUP BY discovery_month;
|
What is the revenue generated from virtual tours in New York and Los Angeles?
|
CREATE TABLE Cities (city_id INT,name TEXT,country TEXT); CREATE TABLE Virtual_Tours (tour_id INT,city_id INT,name TEXT,revenue FLOAT); INSERT INTO Cities (city_id,name,country) VALUES (1,'New York','USA'),(2,'Los Angeles','USA'); INSERT INTO Virtual_Tours (tour_id,city_id,name,revenue) VALUES (1,1,'Central Park',12000.00),(2,1,'Times Square',15000.00),(3,2,'Hollywood Walk of Fame',18000.00),(4,2,'Santa Monica Pier',10000.00);
|
SELECT SUM(revenue) FROM Virtual_Tours WHERE city_id IN (1, 2);
|
What is the percentage of female employees in each department in the 'workforce_diversity' table?
|
CREATE TABLE workforce_diversity (employee_id INT,name VARCHAR(50),department VARCHAR(50),gender VARCHAR(10),age INT); INSERT INTO workforce_diversity (employee_id,name,department,gender,age) VALUES (1,'John Doe','Engineering','Male',35); INSERT INTO workforce_diversity (employee_id,name,department,gender,age) VALUES (2,'Jane Smith','Operations','Female',28);
|
SELECT department, ROUND(COUNT(*) FILTER (WHERE gender = 'Female') * 100.0 / COUNT(*), 2) AS percentage FROM workforce_diversity GROUP BY department;
|
What is the minimum cost of seismic retrofits in 'California' since 2015?
|
CREATE TABLE seismic_retrofits (id INT,retrofit_number TEXT,location TEXT,cost INT,retrofit_date DATE); INSERT INTO seismic_retrofits (id,retrofit_number,location,cost,retrofit_date) VALUES (1,'CA-1234','California',300000,'2016-04-02'); INSERT INTO seismic_retrofits (id,retrofit_number,location,cost,retrofit_date) VALUES (2,'CA-5678','California',200000,'2015-10-10');
|
SELECT MIN(cost) FROM seismic_retrofits WHERE location = 'California' AND YEAR(retrofit_date) >= 2015;
|
Delete the record of 'Michael Brown' from 'clinic_CA'.
|
CREATE TABLE clinic_CA (patient_id INT,name VARCHAR(50)); INSERT INTO clinic_CA (patient_id,name) VALUES (1,'James Johnson'),(2,'Sophia Williams'),(3,'Michael Brown');
|
DELETE FROM clinic_CA WHERE name = 'Michael Brown';
|
What are the details of farmers specializing in urban agriculture?
|
CREATE TABLE Farmers (id INT,name VARCHAR(50),location VARCHAR(50),expertise VARCHAR(50)); INSERT INTO Farmers (id,name,location,expertise) VALUES (1,'Jane Doe','Canada','Urban Agriculture');
|
SELECT * FROM Farmers WHERE expertise = 'Urban Agriculture';
|
What is the total number of military aircrafts in the inventory?
|
CREATE TABLE Military_Equipment (id INT,equipment_type VARCHAR(20),quantity INT); INSERT INTO Military_Equipment (id,equipment_type,quantity) VALUES (1,'Fighter Jet',200),(2,'Transport Plane',150),(3,'Helicopter',300);
|
SELECT SUM(quantity) FROM Military_Equipment WHERE equipment_type = 'Fighter Jet' OR equipment_type = 'Transport Plane';
|
What is the average renewable energy capacity per country in the 'RenewableEnergy' table?
|
CREATE TABLE CountryRenewableEnergy (country TEXT,capacity FLOAT); INSERT INTO CountryRenewableEnergy (country,capacity) VALUES ('Country1',1200),('Country2',1500),('Country3',1800);
|
SELECT country, AVG(capacity) FROM CountryRenewableEnergy GROUP BY country;
|
What is the maximum mental health parity violation fine in each region?
|
CREATE TABLE MentalHealthParityFines (FineID INT,Region VARCHAR(255),Fine INT); INSERT INTO MentalHealthParityFines (FineID,Region,Fine) VALUES (1,'Northeast',50000),(2,'Southeast',75000),(3,'Midwest',60000),(4,'Southwest',80000),(5,'West',100000);
|
SELECT Region, MAX(Fine) as MaxFine FROM MentalHealthParityFines GROUP BY Region;
|
What is the total funding raised by startups founded by women in 2020?
|
CREATE TABLE startup (id INT,name TEXT,founder_gender TEXT,founding_year INT,funding_round_size INT); INSERT INTO startup (id,name,founder_gender,founding_year,funding_round_size) VALUES (1,'WomenStart20','Female',2020,5000000); INSERT INTO startup (id,name,founder_gender,founding_year,funding_round_size) VALUES (2,'TechStart21','Male',2021,10000000);
|
SELECT SUM(funding_round_size) FROM startup WHERE founder_gender = 'Female' AND founding_year = 2020;
|
What is the total mass of all space debris larger than 1 cm in size?
|
CREATE TABLE SpaceDebris (id INT,diameter FLOAT,mass FLOAT); INSERT INTO SpaceDebris (id,diameter,mass) VALUES (1,1.5,2.3);
|
SELECT SUM(mass) FROM SpaceDebris WHERE diameter > 1;
|
What is the average speed of electric vehicles in 'vehicle_sales' table?
|
CREATE TABLE vehicle_sales (id INT,vehicle_type VARCHAR(20),avg_speed FLOAT,sales INT); INSERT INTO vehicle_sales (id,vehicle_type,avg_speed,sales) VALUES (1,'Tesla Model 3',80.0,50000),(2,'Nissan Leaf',70.0,40000),(3,'Chevrolet Bolt',75.0,30000);
|
SELECT AVG(avg_speed) FROM vehicle_sales WHERE vehicle_type LIKE '%electric%';
|
Delete records of customers with a financial wellbeing score less than 70 from the 'customer_data' table.
|
CREATE TABLE customer_data (id INT,name VARCHAR(20),state VARCHAR(2),score INT); INSERT INTO customer_data (id,name,state,score) VALUES (1,'JohnDoe','CA',75),(2,'JaneDoe','NY',80),(3,'MikeSmith','CA',65);
|
DELETE FROM customer_data WHERE score < 70;
|
What is the monthly average closing balance per customer for the last 6 months, ordered by the most recent month?
|
CREATE TABLE customer_account (customer_id INT,account_number INT,balance DECIMAL(10,2),closing_date DATE); INSERT INTO customer_account (customer_id,account_number,balance,closing_date) VALUES (1,1001,15000,'2021-08-31'),(1,1002,20000,'2021-08-31'),(2,1003,30000,'2021-08-31');
|
SELECT customer_id, AVG(balance) as avg_balance, EXTRACT(MONTH FROM closing_date) as month FROM customer_account WHERE closing_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY customer_id, month ORDER BY month DESC;
|
What is the total amount of research funding received by each department in the past two years?
|
CREATE TABLE Departments (DepartmentID INT,Name VARCHAR(50)); INSERT INTO Departments VALUES (1,'Computer Science'); CREATE TABLE ResearchGrants (GrantID INT,DepartmentID INT,Amount DECIMAL(10,2)); INSERT INTO ResearchGrants VALUES (1,1,5000); INSERT INTO ResearchGrants VALUES (2,1,7000);
|
SELECT Departments.Name, SUM(ResearchGrants.Amount) FROM Departments INNER JOIN ResearchGrants ON Departments.DepartmentID = ResearchGrants.DepartmentID WHERE ResearchGrants.GrantID >= DATEADD(year, -2, GETDATE()) GROUP BY Departments.Name;
|
How many volunteers have joined non-profit organizations in Australia between January 1, 2020, and June 30, 2020?
|
CREATE TABLE volunteers (id INT,name TEXT,country TEXT,join_date DATE); INSERT INTO volunteers (id,name,country,join_date) VALUES (1,'David Johnson','Australia','2020-02-15'); INSERT INTO volunteers (id,name,country,join_date) VALUES (2,'Emily Brown','Australia','2020-05-28');
|
SELECT COUNT(*) FROM volunteers WHERE country = 'Australia' AND join_date BETWEEN '2020-01-01' AND '2020-06-30';
|
Which country has the highest average score in the game 'Fortnite'?
|
CREATE TABLE fortnite_scores (id INT,player TEXT,score INT,country TEXT); INSERT INTO fortnite_scores (id,player,score,country) VALUES (1,'James',85,'UK'),(2,'Peter',75,'UK'),(3,'Olivia',90,'USA'),(4,'Daniel',95,'USA'),(5,'Sophia',80,'Canada');
|
SELECT country, AVG(score) FROM fortnite_scores WHERE game = 'Fortnite' GROUP BY country ORDER BY AVG(score) DESC LIMIT 1;
|
Update the email to '[email protected]' for policy_holder_id 1 in the policy_holder table
|
CREATE TABLE policy_holder (policy_holder_id INT,first_name VARCHAR(50),last_name VARCHAR(50),email VARCHAR(50),phone VARCHAR(15),address VARCHAR(100),city VARCHAR(50),state VARCHAR(2),zip VARCHAR(10)); INSERT INTO policy_holder (policy_holder_id,first_name,last_name,email,phone,address,city,state,zip) VALUES (1,'John','Doe','[email protected]','555-888-9999','456 Elm St','Los Angeles','CA','90001');
|
UPDATE policy_holder SET email = '[email protected]' WHERE policy_holder_id = 1;
|
Delete the record for the GreenVille area from the SustainableUrbanism table.
|
CREATE TABLE SustainableUrbanism (area TEXT,green_space_percentage FLOAT,public_transportation_score INT,walkability_score INT); INSERT INTO SustainableUrbanism (area,green_space_percentage,public_transportation_score,walkability_score) VALUES ('Eastside',0.3,8,9),('Westside',0.5,7,8),('GreenVille',0.4,8,8);
|
DELETE FROM SustainableUrbanism WHERE area = 'GreenVille';
|
What is the maximum number of members in unions that are not involved in labor rights advocacy in Georgia?
|
CREATE TABLE union_advocacy_ga (id INT,union_name TEXT,state TEXT,members INT,involved_in_advocacy BOOLEAN); INSERT INTO union_advocacy_ga (id,union_name,state,members,involved_in_advocacy) VALUES (1,'Union S','Georgia',700,false),(2,'Union T','Georgia',600,true),(3,'Union U','Georgia',800,false);
|
SELECT MAX(members) FROM union_advocacy_ga WHERE state = 'Georgia' AND involved_in_advocacy = false;
|
List the names of mental health providers who serve the most community health workers who identify as part of a historically underrepresented community.
|
CREATE TABLE CommunityHealthWorker (WorkerID INT,ProviderID INT,WorkerIdentity VARCHAR(50),WorkerName VARCHAR(50)); INSERT INTO CommunityHealthWorker (WorkerID,ProviderID,WorkerIdentity,WorkerName) VALUES (1,1,'African American','John'),(2,2,'Hispanic','Jane'),(3,3,'Asian American','Jim'),(4,4,'Native American','Joan'),(5,5,'Caucasian','Jake'),(6,1,'African American','Jill'),(7,2,'Hispanic','Jeff'),(8,3,'Asian American','Jessica'),(9,4,'Native American','Jeremy'),(10,5,'Caucasian','Jamie'),(11,1,'African American','Jessica'),(12,2,'Hispanic','Jeff'),(13,3,'Asian American','Jim'),(14,4,'Native American','Joan'),(15,5,'Caucasian','Jake');
|
SELECT ProviderID, WorkerName, COUNT(*) as NumWorkers FROM CommunityHealthWorker WHERE WorkerIdentity IN ('African American', 'Hispanic', 'Asian American', 'Native American') GROUP BY ProviderID, WorkerName ORDER BY NumWorkers DESC;
|
What is the total weight of packages shipped from Canada to the United States via expedited freight?
|
CREATE TABLE packages (id INT,weight FLOAT,origin VARCHAR(50),destination VARCHAR(50),shipping_method VARCHAR(50)); INSERT INTO packages (id,weight,origin,destination,shipping_method) VALUES (1,15.3,'Canada','United States','expedited'),(2,22.1,'Mexico','Canada','standard');
|
SELECT SUM(weight) FROM packages WHERE origin = 'Canada' AND destination = 'United States' AND shipping_method = 'expedited';
|
What is the capacity of hospitals in Washington state?
|
CREATE TABLE hospitals (id INT,name TEXT,location TEXT,capacity INT); INSERT INTO hospitals (id,name,location,capacity) VALUES (1,'Hospital A','Rural Washington',50); INSERT INTO hospitals (id,name,location,capacity) VALUES (6,'Hospital F','Rural Washington',60);
|
SELECT capacity FROM hospitals WHERE location = 'Rural Washington';
|
Identify the top 3 dishes with the lowest carbohydrate content in Japanese cuisine restaurants in Tokyo, considering the month of April 2022.
|
CREATE TABLE dishes (restaurant_name TEXT,cuisine TEXT,dish TEXT,carbohydrates INTEGER,dish_date DATE); INSERT INTO dishes (restaurant_name,cuisine,dish,carbohydrates,dish_date) VALUES ('Tokyo Sushi','Japanese','Sashimi',5,'2022-04-01');
|
SELECT dish, carbohydrates FROM (SELECT dish, carbohydrates, ROW_NUMBER() OVER (PARTITION BY dish_date ORDER BY carbohydrates ASC) as rn FROM dishes WHERE restaurant_name LIKE 'Tokyo%' AND cuisine = 'Japanese' AND dish_date >= '2022-04-01' AND dish_date < '2022-05-01') t WHERE rn <= 3;
|
Calculate the average risk_score for records in the algorithmic_fairness table where the bias_level is 'medium'
|
CREATE TABLE algorithmic_fairness (id INTEGER,algorithm TEXT,bias_level TEXT,risk_score INTEGER,last_updated TIMESTAMP);
|
SELECT AVG(risk_score) FROM algorithmic_fairness WHERE bias_level = 'medium';
|
How many patients in Argentina were diagnosed with Tuberculosis in 2020?
|
CREATE TABLE Patients (ID INT,Gender VARCHAR(10),Disease VARCHAR(20),Country VARCHAR(30),Diagnosis_Date DATE); INSERT INTO Patients (ID,Gender,Disease,Country,Diagnosis_Date) VALUES (1,'Male','Tuberculosis','Argentina','2020-01-01');
|
SELECT COUNT(*) FROM Patients WHERE Disease = 'Tuberculosis' AND Country = 'Argentina' AND YEAR(Diagnosis_Date) = 2020;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.