instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total number of donors and volunteers? | CREATE TABLE Donors (DonorID INT,Name TEXT); CREATE TABLE Volunteers (VolunteerID INT,Name TEXT); | SELECT COUNT(*) FROM Donors; SELECT COUNT(*) FROM Volunteers; |
Which genetic research projects have been completed in the UK? | CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.research (id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(255),status VARCHAR(255)); INSERT INTO biotech.research (id,name,country,status) VALUES (1,'Genome UK','UK','Ongoing'); INSERT INTO biotech.research (id,name,country,status) VALUES (2,'... | SELECT name FROM biotech.research WHERE country = 'UK' AND status = 'Completed'; |
Find the most recent mission for each spacecraft that had a female commander. | CREATE TABLE Spacecraft_Missions (id INT,spacecraft_id INT,mission_name VARCHAR(100),mission_date DATE,commander_gender VARCHAR(10)); INSERT INTO Spacecraft_Missions (id,spacecraft_id,mission_name,mission_date,commander_gender) VALUES (1,1,'Apollo 11','1969-07-16','Male'); | SELECT spacecraft_id, MAX(mission_date) as most_recent_mission FROM Spacecraft_Missions WHERE commander_gender = 'Female' GROUP BY spacecraft_id |
What are the top 5 donors by total donation amount for the year 2020, grouped by quarter? | CREATE TABLE donors (donor_id INT,donor_name VARCHAR(100),donation_amount DECIMAL(10,2),donation_date DATE); | SELECT QUARTER(donation_date) AS quarter, donor_name, SUM(donation_amount) AS total_donation FROM donors WHERE YEAR(donation_date) = 2020 GROUP BY quarter, donor_name ORDER BY total_donation DESC LIMIT 5; |
How many posts were created by users living in France, having less than 1000 followers, in the last week? | CREATE TABLE users (id INT,name TEXT,country TEXT,followers INT); INSERT INTO users (id,name,country,followers) VALUES (1,'Alice','France',700),(2,'Bob','France',600),(3,'Charlie','Germany',800); CREATE TABLE posts (id INT,user_id INT,timestamp DATETIME); INSERT INTO posts (id,user_id,timestamp) VALUES (1,1,'2022-02-01... | SELECT COUNT(posts.id) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country = 'France' AND users.followers < 1000 AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK); |
List the top 3 teams with the most wins in the NFL this season | CREATE TABLE teams (id INT PRIMARY KEY,name TEXT,conference TEXT,division TEXT,wins INT); INSERT INTO teams (id,name,conference,division,wins) VALUES (1,'Green Bay Packers','NFC','North',13),(2,'Tampa Bay Buccaneers','NFC','South',12),(3,'Arizona Cardinals','NFC','West',11),(4,'Buffalo Bills','AFC','East',11),(5,'Kansa... | SELECT name FROM teams ORDER BY wins DESC LIMIT 3; |
What is the total number of parks in the city of San Francisco? | CREATE TABLE cities (id INT,name VARCHAR(255)); INSERT INTO cities (id,name) VALUES (1,'San Francisco'); CREATE TABLE parks (id INT,city_id INT,name VARCHAR(255)); INSERT INTO parks (id,city_id,name) VALUES (1,1,'Golden Gate Park'); INSERT INTO parks (id,city_id,name) VALUES (2,1,'Golden Gate Park'); | SELECT COUNT(*) FROM parks WHERE city_id = (SELECT id FROM cities WHERE name = 'San Francisco'); |
What is the total number of hospitals and clinics in rural areas of Canada and the United States? | CREATE TABLE hospitals (id INT,name TEXT,location TEXT,country TEXT); INSERT INTO hospitals (id,name,location,country) VALUES (1,'Hospital A','Rural Canada','Canada'),(2,'Hospital B','Rural USA','USA'); CREATE TABLE clinics (id INT,name TEXT,location TEXT,country TEXT); INSERT INTO clinics (id,name,location,country) VA... | SELECT COUNT(*) FROM hospitals WHERE location LIKE '%rural%' UNION ALL SELECT COUNT(*) FROM clinics WHERE location LIKE '%rural%' |
What is the total quantity of coal mined by each region in Q1 2022? | CREATE TABLE mine_sites (site_id INT,site_name TEXT,region TEXT,product TEXT,quantity INT,mining_date DATE); INSERT INTO mine_sites (site_id,site_name,region,product,quantity,mining_date) VALUES (1,'ABC Mine','West','Coal',500,'2022-01-03'),(2,'DEF Mine','East','Coal',700,'2022-01-10'),(3,'GHI Mine','North','Coal',800,... | SELECT region, SUM(quantity) as total_qty FROM mine_sites WHERE product = 'Coal' AND mining_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY region; |
List the number of mental health parity violations by violation type in Q2 2022. | CREATE TABLE mental_health_parity_violations (id INT,state VARCHAR(50),violation_type VARCHAR(50),violation_date DATE); INSERT INTO mental_health_parity_violations (id,state,violation_type,violation_date) VALUES (1,'California','Denial of Coverage','2022-04-15'),(2,'Texas','Inadequate Facilities','2022-05-20'),(3,'New ... | SELECT violation_type, COUNT(*) as num_violations FROM mental_health_parity_violations WHERE violation_date >= '2022-04-01' AND violation_date < '2022-07-01' GROUP BY violation_type; |
What is the average price of products made in a specific country? | CREATE TABLE products(product_id INT,country_of_origin VARCHAR(50),price DECIMAL(10,2)); | SELECT AVG(price) FROM products WHERE country_of_origin = 'Brazil'; |
What is the maximum depth of all marine protected areas? | CREATE TABLE marine_protected_areas (name VARCHAR(255),depth FLOAT); INSERT INTO marine_protected_areas (name,depth) VALUES ('Deep Sea Research Area',5000); | SELECT MAX(depth) FROM marine_protected_areas; |
List members who did both yoga and zumba workouts and their total workouts. | CREATE TABLE membership_data (member_id INT,join_date DATE); CREATE TABLE workout_data (workout_id INT,member_id INT,workout_type VARCHAR(20),workout_date DATE); | SELECT m.member_id, m.join_date, COUNT(w.workout_id) as total_workouts FROM membership_data m JOIN workout_data w ON m.member_id = w.member_id WHERE w.workout_type IN ('yoga', 'zumba') GROUP BY m.member_id HAVING COUNT(DISTINCT w.workout_type) = 2; |
Insert records for new clients from the Financial Wellbeing database | CREATE TABLE financial_wellbeing_client (client_id INT PRIMARY KEY,name VARCHAR(100),age INT,income DECIMAL(10,2));CREATE TABLE financial_wellbeing_payment (payment_id INT PRIMARY KEY,client_id INT,payment_amount DECIMAL(10,2),payment_date DATE);INSERT INTO financial_wellbeing_client (client_id,name,age,income) VALUES ... | INSERT INTO financial_wellbeing_payment (payment_id, client_id, payment_amount, payment_date) SELECT payment_id, client_id, payment_amount, payment_date FROM (SELECT payment_id, client_id, 0.00 payment_amount, CURRENT_DATE payment_date FROM generate_series(1, 5) payment_id, UNNEST(ARRAY[7, 8]) client_id) new_payments W... |
Delete records related to 'NVIDIA' from the 'autonomous_driving_research' table | CREATE TABLE autonomous_driving_research (id INT,vehicle_name VARCHAR(50),research_topic VARCHAR(50)); | DELETE FROM autonomous_driving_research WHERE vehicle_name = 'NVIDIA'; |
What is the total biomass of fish by species and harvest date? | CREATE TABLE Fish (id INT PRIMARY KEY,species VARCHAR(50)); CREATE TABLE Biomass (fish_id INT,harvest_date DATE,biomass INT,FOREIGN KEY (fish_id) REFERENCES Fish(id)); | SELECT Fish.species, Biomass.harvest_date, SUM(Biomass.biomass) FROM Fish INNER JOIN Biomass ON Fish.id = Biomass.fish_id GROUP BY Fish.species, Biomass.harvest_date; |
Find the top 5 suppliers with the highest delivery frequency in the last month? | CREATE TABLE supplier_deliveries (supplier VARCHAR(50),deliveries INT,date DATE); INSERT INTO supplier_deliveries (supplier,deliveries,date) VALUES ('GreenGrowers',15,'2022-01-01'),('OrganicOrigins',20,'2022-01-02'); CREATE VIEW supplier_frequencies AS SELECT supplier,COUNT(*) as delivery_frequency FROM supplier_delive... | SELECT supplier FROM last_month_supplier_deliveries JOIN supplier_frequencies ON last_month_supplier_deliveries.supplier = supplier_frequencies.supplier GROUP BY supplier ORDER BY delivery_frequency DESC LIMIT 5; |
What is the total revenue for each mobile plan in the last quarter? | CREATE TABLE mobile_plans (id INT,name VARCHAR(255),price DECIMAL(10,2),created_at TIMESTAMP); | SELECT name, SUM(price) as total_revenue FROM mobile_plans WHERE created_at >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) GROUP BY name; |
Which countries have received the most humanitarian aid in the form of housing assistance in the last 5 years? | CREATE TABLE housing_assistance (id INT,country VARCHAR(50),aid_type VARCHAR(50),amount FLOAT,date DATE); INSERT INTO housing_assistance (id,country,aid_type,amount,date) VALUES (1,'Syria','housing',800000,'2017-01-01'); | SELECT country, SUM(amount) as total_housing_aid FROM housing_assistance WHERE aid_type = 'housing' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY country ORDER BY total_housing_aid DESC; |
What is the average funding amount for biotech startups founded by women? | CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT,name VARCHAR(100),founder_gender VARCHAR(10),funding FLOAT); INSERT INTO biotech.startups (id,name,founder_gender,funding) VALUES (1,'StartupA','Female',5000000.0),(2,'StartupB','Male',7000000.0),(3,'StartupC','Female',6000000.0); | SELECT AVG(funding) FROM biotech.startups WHERE founder_gender = 'Female'; |
Update the safety rating of the 'Corolla' model to 5 in the 'vehicle_stats' table. | CREATE TABLE vehicle_stats (id INT,car_model VARCHAR(20),MPG FLOAT,safety_rating INT); INSERT INTO vehicle_stats (id,car_model,MPG,safety_rating) VALUES (1,'Prius',50.0,5),(2,'Corolla',35.0,4),(3,'Insight',60.0,5); | UPDATE vehicle_stats SET safety_rating = 5 WHERE car_model = 'Corolla'; |
What is the contact information for the heritage site in 'Mexico'? | CREATE TABLE heritage_sites (id INT,name TEXT,location TEXT,contact_name TEXT,contact_email TEXT); INSERT INTO heritage_sites (id,name,location,contact_name,contact_email) VALUES (1,'Chichen Itza','Mexico','Pedro Sanchez','chichenitza@mail.com'); | SELECT contact_name, contact_email FROM heritage_sites WHERE location = 'Mexico'; |
How many ethical fashion brands have reduced their carbon emissions in the past year? | CREATE TABLE EthicalFashionBrands(brand VARCHAR(255),carbon_emissions INT,reduction_year INT); | SELECT brand, COUNT(*) FROM EthicalFashionBrands WHERE reduction_year = YEAR(CURRENT_DATE) - 1 GROUP BY brand HAVING COUNT(*) > 0; |
List the top 3 chemical products with the highest sales for the past 12 months, by month, for the North America region? | CREATE TABLE product (product_id INT,product_name VARCHAR(255),sales_quantity INT,sale_date DATE); CREATE TABLE region (region_id INT,region_name VARCHAR(255)); | SELECT product_name, EXTRACT(MONTH FROM sale_date) AS month, SUM(sales_quantity) AS total_sales FROM product JOIN region ON 1=1 WHERE region_name = 'North America' AND sale_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY product_name, EXTRACT(MONTH FROM sale_date) ORDER BY total_sales DESC, month, product_name LIMIT 3... |
What is the total number of streams for pop songs in Canada in Q4 of 2020? | CREATE TABLE Streaming (SongID INT,Song TEXT,Genre TEXT,Streams INT,Country TEXT,Quarter INT,Year INT); INSERT INTO Streaming (SongID,Song,Genre,Streams,Country,Quarter,Year) VALUES (1,'Shape of You','Pop',20000000,'Canada',4,2020); INSERT INTO Streaming (SongID,Song,Genre,Streams,Country,Quarter,Year) VALUES (2,'Bad G... | SELECT SUM(Streams) FROM Streaming WHERE Genre = 'Pop' AND Country = 'Canada' AND Quarter = 4 AND Year = 2020; |
How many carbon offset programs exist in the state of California? | CREATE TABLE carbon_offset_programs (program_id INT,program_name TEXT,state TEXT); INSERT INTO carbon_offset_programs (program_id,program_name,state) VALUES (1,'California Solar Initiative','California'),(2,'California Cap-and-Trade Program','California'); | SELECT COUNT(*) FROM carbon_offset_programs WHERE state = 'California'; |
What is the total quantity of sustainable materials sourced from South America? | CREATE TABLE south_america_sourcing (id INT,material VARCHAR(50),country VARCHAR(50),quantity INT); INSERT INTO south_america_sourcing (id,material,country,quantity) VALUES (1,'organic cotton','Brazil',2000); | SELECT SUM(quantity) FROM south_america_sourcing WHERE material = 'organic cotton' AND country = 'Brazil'; |
What is the latest launch date in the spacecrafts table? | CREATE TABLE spacecrafts (spacecraft_id INT,name VARCHAR(100),launch_date DATE); INSERT INTO spacecrafts (spacecraft_id,name,launch_date) VALUES (1,'Voyager 1','1977-09-05'); INSERT INTO spacecrafts (spacecraft_id,name,launch_date) VALUES (2,'Voyager 2','1977-08-20'); INSERT INTO spacecrafts (spacecraft_id,name,launch_... | SELECT MAX(launch_date) FROM spacecrafts; |
What is the total number of training hours for contractors in the North America region? | CREATE TABLE contractors (id INT,name VARCHAR(255),region VARCHAR(255),training_hours INT); INSERT INTO contractors (id,name,region,training_hours) VALUES (1,'John Doe','North America',40),(2,'Jane Smith','Europe',30),(3,'Alice Johnson','North America',50); | SELECT SUM(training_hours) as total_training_hours FROM contractors WHERE region = 'North America'; |
What is the minimum funding received by a company founded by an Indigenous person? | CREATE TABLE founders (id INT,name VARCHAR(50),ethnicity VARCHAR(20),company_id INT,founding_year INT); CREATE TABLE funding (id INT,company_id INT,amount INT); | SELECT MIN(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id WHERE founders.ethnicity = 'Indigenous'; |
What is the total biomass (in tons) of fish species in the fish_biomass table that are listed in the protected_species table? | CREATE TABLE fish_biomass (species VARCHAR(50),biomass INT); INSERT INTO fish_biomass (species,biomass) VALUES ('Tilapia',50),('Salmon',75),('Trout',60); CREATE TABLE protected_species (species VARCHAR(50)); INSERT INTO protected_species (species) VALUES ('Sturgeon'),('Salmon'); | SELECT SUM(fb.biomass) as total_biomass FROM fish_biomass fb WHERE fb.species IN (SELECT ps.species FROM protected_species ps); |
What is the average mental health score of students by race? | CREATE TABLE students (student_id INT,student_name VARCHAR(50),race VARCHAR(10),mental_health_score INT); INSERT INTO students (student_id,student_name,race,mental_health_score) VALUES (1,'John Doe','Asian',75),(2,'Jane Smith','Black',85),(3,'Alice Johnson','White',80),(4,'Bob Lee','Hispanic',88); | SELECT race, AVG(mental_health_score) as avg_score FROM students GROUP BY race; |
What is the maximum timeline for sustainable building projects in the 'sustainable_buildings' table with more than 500 workers? | CREATE TABLE sustainable_buildings (project_id INT,project_name TEXT,workers INT,timeline_days INT); | SELECT MAX(timeline_days) FROM sustainable_buildings WHERE workers > 500; |
What are the total biomass and carbon footprint for each aquaculture farm? | CREATE TABLE aquaculture_farms (id INT,farm_name VARCHAR(50),biomass DECIMAL(10,2),carbon_footprint DECIMAL(10,2)); | SELECT farm_name, SUM(biomass) as total_biomass, SUM(carbon_footprint) as total_carbon_footprint FROM aquaculture_farms GROUP BY farm_name; |
What are the total sales of cruelty-free cosmetics in Canada and the USA? | CREATE TABLE products (product_id INT,product_name VARCHAR(100),sales INT,certification VARCHAR(20)); INSERT INTO products VALUES (1,'Mascara',5000,'cruelty-free'),(2,'Lipstick',7000,'not_certified'),(3,'Foundation',6000,'cruelty-free'); CREATE TABLE regions (region_id INT,region_name VARCHAR(50)); INSERT INTO regions ... | SELECT region_name, SUM(sales) FROM products JOIN regions ON products.product_id = regions.region_id WHERE certification = 'cruelty-free' GROUP BY region_name; |
What is the average property size for co-owned properties in the Bay Area, partitioned by property type? | CREATE TABLE bay_area_properties (property_id INT,co_owned BOOLEAN,property_type VARCHAR(50),size_sqft INT); | SELECT property_type, AVG(size_sqft) AS avg_size_sqft FROM bay_area_properties WHERE co_owned = TRUE GROUP BY property_type; |
Which programs have received the most donations in 2021? | CREATE TABLE ProgramDonations (DonationID int,ProgramID int,DonationAmount numeric(10,2),DonationDate date); CREATE TABLE Programs (ProgramID int,ProgramName varchar(50),ProgramCategory varchar(50),ProgramImpactScore numeric(3,1)); INSERT INTO ProgramDonations (DonationID,ProgramID,DonationAmount,DonationDate) VALUES (... | SELECT Programs.ProgramName, SUM(ProgramDonations.DonationAmount) as TotalDonated FROM Programs INNER JOIN ProgramDonations ON Programs.ProgramID = ProgramDonations.ProgramID WHERE YEAR(DonationDate) = 2021 GROUP BY Programs.ProgramName ORDER BY TotalDonated DESC; |
What is the total number of policies and claims for each type of vehicle insurance in the state of California? | CREATE TABLE Vehicle_Insurance (Type VARCHAR(20),Policy_Count INT,Claim_Count INT); INSERT INTO Vehicle_Insurance (Type,Policy_Count,Claim_Count) VALUES ('Auto',500,300),('Motorcycle',250,120),('RV',100,50); | SELECT Type, SUM(Policy_Count) AS Total_Policies, SUM(Claim_Count) AS Total_Claims FROM Vehicle_Insurance WHERE State = 'California' GROUP BY Type; |
Find the number of unique users who have streamed hip-hop music on the 'mobile' platform. | CREATE TABLE users (id INT,name TEXT); CREATE TABLE user_actions (id INT,user_id INT,action TEXT,album_id INT); CREATE TABLE albums (id INT,title TEXT,artist_id INT,platform TEXT); CREATE VIEW hiphop_mobile_users AS SELECT DISTINCT ua.user_id FROM user_actions ua JOIN albums a ON ua.album_id = a.id WHERE a.genre = 'hip... | SELECT COUNT(DISTINCT user_id) FROM hiphop_mobile_users; |
What is the number of special dietary request orders, grouped by meal type and day of the week? | CREATE TABLE Orders (OrderID INT,CustomerID INT,OrderDate DATETIME,MealType VARCHAR(50)); CREATE TABLE Customers (CustomerID INT,Name VARCHAR(50),DietaryRestrictions VARCHAR(500)); | SELECT EXTRACT(DOW FROM Orders.OrderDate) as DayOfWeek, MealType, COUNT(*) as NumberOfOrders FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID WHERE DietaryRestrictions IS NOT NULL GROUP BY DayOfWeek, MealType; |
Identify the top 3 countries with the highest potato production in 2019, in descending order. | CREATE TABLE PotatoProduction (Country VARCHAR(50),Year INT,Production INT); | SELECT Country, Production FROM (SELECT Country, Production, ROW_NUMBER() OVER (ORDER BY Production DESC) as rank FROM PotatoProduction WHERE Year = 2019) tmp WHERE rank <= 3; |
What is the average salary for employees who joined after 2020? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,HireDate,Salary) VALUES (1,'2021-01-01',50000.00),(2,'2020-05-15',60000.00),(3,'2019-03-20',55000.00),(4,'2022-04-01',70000.00); | SELECT AVG(Salary) as AvgSalary FROM Employees WHERE YEAR(HireDate) > 2020; |
How many vegan beauty products are sold in each country? | CREATE TABLE vegan_beauty_products (country VARCHAR(255),product_count INTEGER,vegan BOOLEAN); INSERT INTO vegan_beauty_products (country,product_count,vegan) VALUES ('UK',1500,true),('Germany',2000,false),('Spain',1000,true),('Italy',1200,false); | SELECT country, SUM(product_count) as total_vegan_products FROM vegan_beauty_products WHERE vegan = true GROUP BY country; |
List the top 5 green building contractors with the highest total annual energy savings | CREATE TABLE contractors (id INT,company_name TEXT,green_building_id INT,annual_energy_savings_kWh INT); | SELECT contractors.company_name, SUM(green_buildings.annual_energy_savings_kWh) AS total_annual_energy_savings FROM contractors JOIN green_buildings ON contractors.green_building_id = green_buildings.id GROUP BY company_name ORDER BY total_annual_energy_savings DESC LIMIT 5; |
What is the minimum ESG rating for companies in the 'healthcare' sector? | CREATE TABLE company_ESG_ratings (company_id INT,sector VARCHAR(20),ESG_rating FLOAT); INSERT INTO company_ESG_ratings (company_id,sector,ESG_rating) VALUES (1,'technology',78.2),(2,'healthcare',65.3),(3,'technology',81.5),(4,'healthcare',85.7); | SELECT MIN(ESG_rating) FROM company_ESG_ratings WHERE sector = 'healthcare'; |
What is the maximum number of vessels owned by a fleet? | CREATE TABLE fleets (fleet_id INT,number_of_vessels INT); INSERT INTO fleets (fleet_id,number_of_vessels) VALUES (1,10),(2,15),(3,20); | SELECT MAX(number_of_vessels) FROM fleets; |
What is the maximum delivery time for packages shipped from Singapore to the United Kingdom? | CREATE TABLE singapore_uk_deliveries (id INT,delivery_time INT); INSERT INTO singapore_uk_deliveries (id,delivery_time) VALUES (1,6),(2,8); | SELECT MAX(delivery_time) FROM singapore_uk_deliveries; |
How many species of mammals are present in the Arctic? | CREATE TABLE arctic_mammals(id INT,name VARCHAR(50),species VARCHAR(50)); INSERT INTO arctic_mammals(id,name,species) VALUES (1,'Polar Bear','Ursus maritimus'),(2,'Arctic Fox','Vulpes lagopus'); | SELECT COUNT(DISTINCT species) num_species FROM arctic_mammals; |
What is the maximum and minimum temperature recorded in the Arctic each year? | CREATE TABLE ArcticTemperatureYearly(year INT,temperature FLOAT);INSERT INTO ArcticTemperatureYearly(year,temperature) VALUES(2017,-25.0),(2018,-30.0),(2019,-20.0),(2017,-20.0),(2018,-35.0); | SELECT year, MAX(temperature), MIN(temperature) FROM ArcticTemperatureYearly GROUP BY year; |
Display the unions involved in collective bargaining agreements, but not involved in any labor rights violations. | CREATE TABLE unions (id INT PRIMARY KEY,name VARCHAR(255)); CREATE TABLE cb_agreements (id INT PRIMARY KEY,union_id INT); CREATE TABLE reports (id INT PRIMARY KEY,violation VARCHAR(255),union_id INT); INSERT INTO unions (id,name) VALUES (1,'Union A'),(2,'Union B'),(3,'Union C'),(4,'Union D'); INSERT INTO cb_agreements ... | SELECT name FROM unions u WHERE u.id IN (SELECT union_id FROM cb_agreements) AND u.id NOT IN (SELECT union_id FROM reports); |
Find the top 5 strains with the highest total sales in Colorado dispensaries in Q2 2022. | CREATE TABLE Dispensaries (Dispensary_ID INT,Dispensary_Name TEXT,State TEXT); INSERT INTO Dispensaries (Dispensary_ID,Dispensary_Name,State) VALUES (1,'Colorado Cannabis','CO'); CREATE TABLE Sales (Sale_ID INT,Dispensary_ID INT,Strain TEXT,Total_Sales DECIMAL); INSERT INTO Sales (Sale_ID,Dispensary_ID,Strain,Total_Sal... | SELECT Strain, SUM(Total_Sales) as Total FROM Sales JOIN Dispensaries ON Sales.Dispensary_ID = Dispensaries.Dispensary_ID WHERE State = 'CO' AND QUARTER(Sale_Date) = 2 GROUP BY Strain ORDER BY Total DESC LIMIT 5; |
What is the maximum capacity of a wind farm in the 'renewable_energy' schema? | CREATE SCHEMA renewable_energy; CREATE TABLE wind_farms (id INT,name VARCHAR(100),capacity FLOAT); INSERT INTO wind_farms (id,name,capacity) VALUES (1,'Wind Farm M',100.0),(2,'Wind Farm N',110.0); | SELECT MAX(capacity) FROM renewable_energy.wind_farms; |
What is the maximum loan amount for the Islamic Microfinance Loan product? | CREATE TABLE islamic_microfinance (product VARCHAR(50),loan_amount FLOAT); INSERT INTO islamic_microfinance (product,loan_amount) VALUES ('Islamic Microenterprise Loan',2000.00),('Islamic Education Loan',5000.00),('Islamic Housing Loan',10000.00); | SELECT MAX(loan_amount) FROM islamic_microfinance WHERE product = 'Islamic Microenterprise Loan'; |
What is the average distance of routes between 'LA' and 'NY'? | CREATE TABLE Routes (id INT PRIMARY KEY,origin VARCHAR(255),destination VARCHAR(255),distance INT,duration INT); | SELECT AVG(distance) as avg_distance FROM Routes WHERE origin = 'LA' AND destination = 'NY'; |
Which countries have been targeted by cyber attacks in the last 6 months, and what was the nature of each attack? | CREATE TABLE cyber_attacks (id INT,country VARCHAR(50),date DATE,attack_type VARCHAR(50),attack_details VARCHAR(50)); INSERT INTO cyber_attacks (id,country,date,attack_type,attack_details) VALUES (1,'USA','2022-01-01','Phishing','Targeted government employees'),(2,'China','2022-01-02','Malware','Infected government sys... | SELECT country, date, attack_type, attack_details FROM cyber_attacks WHERE date BETWEEN '2022-01-01' AND '2022-06-30'; |
What is the total economic diversification investment in 'Latin America' from '2018' to '2020'? | CREATE TABLE economic_diversification(id INT,investment TEXT,location TEXT,year INT,amount INT); INSERT INTO economic_diversification (id,investment,location,year,amount) VALUES (1,'Renewable Energy Project','Latin America',2018,1000000); | SELECT SUM(amount) FROM economic_diversification WHERE location = 'Latin America' AND year BETWEEN 2018 AND 2020; |
How many security incidents were caused by each device type in the last month? | CREATE TABLE incident_devices (id INT,incident_id INT,device_type VARCHAR(255)); INSERT INTO incident_devices (id,incident_id,device_type) VALUES (1,1,'Laptop'),(2,1,'Mobile'),(3,2,'Desktop'),(4,3,'Laptop'),(5,3,'Server'),(6,4,'Mobile'),(7,4,'Tablet'),(8,5,'Server'); | SELECT device_type, COUNT(DISTINCT incident_id) as incident_count FROM incident_devices WHERE incident_date >= DATEADD(day, -30, GETDATE()) GROUP BY device_type; |
What are the names of all defense contractors operating in California and Texas? | CREATE TABLE DefenseContractors (contractor_id INT,name VARCHAR(255),state VARCHAR(255)); INSERT INTO DefenseContractors (contractor_id,name,state) VALUES (1,'Contractor X','California'),(2,'Contractor Y','Texas'),(3,'Contractor Z','New York'); | SELECT name FROM DefenseContractors WHERE state IN ('California', 'Texas'); |
What is the maximum duration of a case, for each case type? | CREATE TABLE cases (case_id INT,case_type VARCHAR(20),open_date DATE,close_date DATE); INSERT INTO cases (case_id,case_type,open_date,close_date) VALUES (1,'Civil','2022-01-10','2022-01-15'),(2,'Criminal','2022-01-12','2022-01-20'),(3,'Civil','2022-01-15','2022-01-22'); | SELECT case_type, MAX(DATEDIFF(day, open_date, close_date)) as max_duration FROM cases GROUP BY case_type; |
What is the total number of female and male members in unions located in California and New York? | CREATE TABLE union_members(id INT,name VARCHAR(50),gender VARCHAR(6),union_state VARCHAR(14));INSERT INTO union_members(id,name,gender,union_state) VALUES (1,'John Doe','Male','California'),(2,'Jane Smith','Female','New York'); | SELECT SUM(gender = 'Male') AS total_male, SUM(gender = 'Female') AS total_female FROM union_members WHERE union_state IN ('California', 'New York'); |
Identify genetic research projects that do not have a principal investigator assigned. | CREATE TABLE research_projects (id INT,name TEXT,principal_investigator TEXT); INSERT INTO research_projects (id,name,principal_investigator) VALUES (1,'Project X','Dr. Smith'); INSERT INTO research_projects (id,name,principal_investigator) VALUES (2,'Project Y',NULL); | SELECT * FROM research_projects WHERE principal_investigator IS NULL; |
What is the average production cost for Silver in Australia in 2018? | CREATE TABLE production_costs (year INT,location VARCHAR(20),material VARCHAR(20),cost FLOAT); INSERT INTO production_costs (year,location,material,cost) VALUES (2015,'Canada','Gold',500.5),(2015,'Canada','Silver',250.2),(2016,'Mexico','Gold',600.0),(2016,'Mexico','Silver',300.0),(2018,'Australia','Gold',700.0),(2018,'... | SELECT material, AVG(cost) as avg_cost FROM production_costs WHERE location = 'Australia' AND material = 'Silver' AND year = 2018; |
What is the number of patients who improved, worsened, or stayed the same, partitioned by age group in Mumbai? | CREATE TABLE patient_outcomes_mumbai (id INT,patient_id INT,outcome VARCHAR(20),age INT); INSERT INTO patient_outcomes_mumbai (id,patient_id,outcome,age) VALUES (1,1,'Improved',30),(2,2,'Unchanged',45),(3,3,'Deteriorated',25),(4,4,'Improved',50),(5,5,'Improved',35),(6,6,'Unchanged',40),(7,7,'Deteriorated',55),(8,8,'Imp... | SELECT age_group, AVG(outcome = 'Improved') * 100 AS improved, AVG(outcome = 'Unchanged') * 100 AS unchanged, AVG(outcome = 'Deteriorated') * 100 AS deteriorated FROM (SELECT patient_outcomes_mumbai.*, (age - 18) / 10 * 10 AS age_group FROM patient_outcomes_mumbai WHERE city = 'Mumbai') t GROUP BY age_group; |
Calculate attendance by age group for the 'Art of the Americas'. | CREATE TABLE attendance (id INT,age INT,event VARCHAR(50),visitors INT); INSERT INTO attendance (id,age,event,visitors) VALUES (1,18,'Art of the Americas',500),(2,25,'Art of the Americas',700),(3,35,'Art of the Americas',800); | SELECT event, AVG(age) as avg_age, COUNT(*) as total FROM attendance WHERE event = 'Art of the Americas' GROUP BY event; |
What is the maximum gas fee for smart contracts on the Binance Smart Chain, and which contract has the highest fee? | CREATE TABLE binance_smart_chain_contracts (contract_id INT,gas_fee DECIMAL(10,2),name VARCHAR(255)); INSERT INTO binance_smart_chain_contracts (contract_id,gas_fee,name) VALUES (1,0.02,'Contract1'),(2,0.04,'Contract2'),(3,0.05,'Contract3'); | SELECT MAX(gas_fee), name FROM binance_smart_chain_contracts GROUP BY name; |
How many unique strains were sold in the state of New York in Q3 2022? | CREATE TABLE sales (id INT,state VARCHAR(50),quarter VARCHAR(10),strain VARCHAR(50)); | SELECT COUNT(DISTINCT strain) FROM sales WHERE state = 'New York' AND quarter = 'Q3'; |
Update the budget for the program named 'Health' in the 'Programs' table to $20,000 | CREATE TABLE Programs (id INT PRIMARY KEY,program_name VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO Programs (id,program_name,budget) VALUES (1,'Education',10000.00),(2,'Health',15000.00); | UPDATE Programs SET budget = 20000.00 WHERE program_name = 'Health'; |
What is the average donation amount for each cause in the 'causes' table, ordered by the average donation amount in descending order? | CREATE TABLE causes (cause_id INT,cause_name TEXT,avg_donation DECIMAL(10,2)); | SELECT cause_name, AVG(avg_donation) as avg_donation_amount FROM causes GROUP BY cause_name ORDER BY avg_donation_amount DESC; |
How many veteran unemployment claims were filed in California in the last month? | CREATE TABLE veteran_unemployment (id INT,claim_date DATE,state VARCHAR(50),claim_status VARCHAR(50)); INSERT INTO veteran_unemployment (id,claim_date,state,claim_status) VALUES (1,'2022-01-05','California','Filed'),(2,'2022-02-10','Texas','Rejected'); | SELECT COUNT(*) FROM veteran_unemployment WHERE state = 'California' AND claim_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND claim_status = 'Filed'; |
How many transactions were made in each region? | CREATE TABLE regions (id INT,region_name VARCHAR(50)); INSERT INTO regions (id,region_name) VALUES (1,'Northeast'),(2,'Southeast'); CREATE TABLE transactions (region_id INT,transaction_count INT); INSERT INTO transactions (region_id,transaction_count) VALUES (1,20),(1,30),(2,10),(2,40); | SELECT r.region_name, SUM(t.transaction_count) as total_transactions FROM regions r JOIN transactions t ON r.id = t.region_id GROUP BY r.region_name; |
What is the maximum number of workplace safety violations recorded in a single workplace in the year 2019? | CREATE TABLE violations (id INT,workplace_id INT,violation_date DATE,num_violations INT); INSERT INTO violations (id,workplace_id,violation_date,num_violations) VALUES (1,1,'2019-01-01',5); INSERT INTO violations (id,workplace_id,violation_date,num_violations) VALUES (2,2,'2019-02-15',3); INSERT INTO violations (id,wor... | SELECT MAX(num_violations) FROM violations WHERE EXTRACT(YEAR FROM violation_date) = 2019; |
Add a new record for the pollution_sources table with the name 'Oceanic Plastic Pollution' in the 'Pacific Ocean' region. | CREATE TABLE pollution_sources (id INT,name VARCHAR(255),region VARCHAR(255)); | INSERT INTO pollution_sources (id, name, region) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM pollution_sources), 'Oceanic Plastic Pollution', 'Pacific Ocean'); |
What is the average hotel star rating in Tokyo, Japan? | CREATE TABLE hotels (id INT,city VARCHAR(20),country VARCHAR(20),stars INT); INSERT INTO hotels (id,city,country,stars) VALUES (1,'Tokyo','Japan',4),(2,'Tokyo','Japan',5),(3,'Osaka','Japan',3); | SELECT AVG(stars) FROM hotels WHERE city = 'Tokyo' AND country = 'Japan'; |
List volunteers from March 2022 | CREATE TABLE Volunteers(id INT PRIMARY KEY AUTO_INCREMENT,volunteer_name VARCHAR(255),hours_served INT,volunteer_date DATE) INSERT INTO Volunteers (volunteer_name,hours_served,volunteer_date) VALUES ('Juanita Flores',12,'2022-01-01') INSERT INTO Volunteers (volunteer_name,hours_served,volunteer_date) VALUES ('Mohammed ... | SELECT * FROM Volunteers WHERE volunteer_date BETWEEN '2022-03-01' AND '2022-03-31' |
What is the total revenue for events in Los Angeles, CA in the last quarter? | CREATE TABLE Events (id INT,city VARCHAR(20),country VARCHAR(20),date DATE,price DECIMAL(5,2)); INSERT INTO Events (id,city,country,date,price) VALUES (1,'Los Angeles','USA','2023-01-01',20.00),(2,'Los Angeles','USA','2023-03-15',30.00); | SELECT SUM(price) as total_revenue FROM Events WHERE city = 'Los Angeles' AND country = 'USA' AND date >= DATEADD(quarter, -1, GETDATE()); |
What is the total quantity of 'Shirts' sold by stores in 'New York' and 'California'? | CREATE TABLE stores (store_id INT,store_name VARCHAR(20),state VARCHAR(20)); CREATE TABLE sales (sale_id INT,product_type VARCHAR(20),store_id INT,quantity_sold INT); INSERT INTO stores (store_id,store_name,state) VALUES (1,'Store1','New York'),(2,'Store2','California'),(3,'Store3','Texas'); INSERT INTO sales (sale_id,... | SELECT SUM(quantity_sold) FROM sales JOIN stores ON sales.store_id = stores.store_id WHERE stores.state IN ('New York', 'California') AND product_type = 'Shirts'; |
What was the average economic diversification index for agricultural projects in Mexico? | CREATE TABLE Projects (id INT,project_id INT,project_type VARCHAR(20),economic_diversification_index DECIMAL(5,2)); INSERT INTO Projects (id,project_id,project_type,economic_diversification_index) VALUES (1,3001,'Agricultural',45.67),(2,3002,'Infrastructure',78.34),(3,3003,'Agricultural',56.89); | SELECT AVG(economic_diversification_index) FROM Projects WHERE project_type = 'Agricultural'; |
Delete records of workers from the 'mining_sites' table who have not recorded any productivity metrics. | CREATE TABLE mining_sites (site_id INT,job_title VARCHAR(20),productivity FLOAT); | DELETE FROM mining_sites WHERE productivity IS NULL; |
Which currently active project in the accessibility domain has the lowest funding amount? | CREATE TABLE accessibility_current (id INT PRIMARY KEY,project VARCHAR(100),organization VARCHAR(100),funding FLOAT,start_date DATE,end_date DATE);INSERT INTO accessibility_current (id,project,organization,funding,start_date,end_date) VALUES (1,'Accessible AI v3','Equal Tech.',400000,'2022-01-01','2023-12-31'); | SELECT project FROM accessibility_current WHERE start_date <= CURDATE() AND end_date >= CURDATE() ORDER BY funding LIMIT 1; |
What is the health equity metric for each community health worker by race? | CREATE TABLE HealthEquityMetrics (WorkerID INT,Race VARCHAR(255),MetricScore INT); INSERT INTO HealthEquityMetrics (WorkerID,Race,MetricScore) VALUES (1,'Hispanic',80),(2,'African American',85),(3,'Caucasian',90),(4,'Asian',95); | SELECT Race, AVG(MetricScore) as AvgMetricScore FROM HealthEquityMetrics GROUP BY Race; |
Show the total number of users who listened to music from female artists in the Pop genre in 2020 and 2021, along with the artists' names. | CREATE TABLE artists (id INT,name VARCHAR(100),genre VARCHAR(20),gender VARCHAR(6)); CREATE TABLE songs (id INT,artist_id INT,title VARCHAR(100),year INT,user_id INT); INSERT INTO artists (id,name,genre,gender) VALUES (1,'ArtistA','Pop','Female'); INSERT INTO artists (id,name,genre,gender) VALUES (2,'ArtistB','Pop','Fe... | SELECT artist_id, gender, genre, COUNT(DISTINCT user_id) FROM songs INNER JOIN artists ON artists.id = songs.artist_id WHERE genre = 'Pop' AND gender = 'Female' AND year BETWEEN 2020 AND 2021 GROUP BY artist_id; |
Calculate the percentage of sales from the top 5 selling products. | CREATE TABLE sales_summary (id INT,product VARCHAR(255),sales_amount DECIMAL(10,2)); INSERT INTO sales_summary (id,product,sales_amount) VALUES (1,'Lotion',500.00),(2,'Shampoo',400.00),(3,'Conditioner',350.00),(4,'Body Wash',300.00),(5,'Deodorant',250.00),(6,'Sunscreen',200.00),(7,'Hand Cream',150.00),(8,'Lip Balm',100... | SELECT ROUND(SUM(sales_amount) FILTER (WHERE id <= 5) * 100.0 / SUM(sales_amount), 2) AS top_5_percentage FROM sales_summary; |
What is the maximum number of people served by a single 'refugee_camp'? | CREATE TABLE refugee_camps (id INT,camp_name TEXT,location TEXT,population INT,food_aid_tons FLOAT); | SELECT MAX(population) FROM refugee_camps; |
Find the number of shipments and total delivery time for each warehouse? | CREATE TABLE Warehouse (id INT,location VARCHAR(255),capacity INT); INSERT INTO Warehouse (id,location,capacity) VALUES (1,'New York',500),(2,'Toronto',700),(3,'Montreal',600); CREATE TABLE Shipment (id INT,warehouse_id INT,delivery_time INT); INSERT INTO Shipment (id,warehouse_id,delivery_time) VALUES (1,1,5),(2,2,3),... | SELECT warehouse_id, COUNT(*) as num_shipments, SUM(delivery_time) as total_delivery_time FROM Shipment GROUP BY warehouse_id; |
List all astronauts who have flown on missions with spacecraft manufactured by Roscosmos and their missions. | CREATE TABLE Astronauts (AstronautID INT,Name VARCHAR(50),Manufacturer VARCHAR(50),Mission VARCHAR(50)); | SELECT Name, Mission FROM Astronauts WHERE Manufacturer = 'Roscosmos'; |
What is the average age of bridges in the state of California? | CREATE TABLE Bridges (BridgeID INT,Name TEXT,Age INT,State TEXT); INSERT INTO Bridges (BridgeID,Name,Age,State) VALUES (1,'Bridge1',25,'California'); INSERT INTO Bridges (BridgeID,Name,Age,State) VALUES (2,'Bridge2',30,'California'); | SELECT AVG(Age) FROM Bridges WHERE State = 'California'; |
List the health equity metrics that were measured in Seattle for the Asian community. | CREATE TABLE health_equity_metrics (metric_id INT,metric_name TEXT,city TEXT,community TEXT); INSERT INTO health_equity_metrics (metric_id,metric_name,city,community) VALUES (1,'Life Expectancy','Seattle','Asian'),(2,'Infant Mortality','Seattle','Hispanic'),(3,'Access to Care','New York','African American'); | SELECT metric_name FROM health_equity_metrics WHERE city = 'Seattle' AND community = 'Asian'; |
What is the total budget allocated for healthcare in the state of California in the year 2022? | CREATE TABLE healthcare_budget (budget_id INT,budget_year INT,budget_state TEXT,budget_amount FLOAT); INSERT INTO healthcare_budget (budget_id,budget_year,budget_state,budget_amount) VALUES (1,2022,'California',12000000),(2,2021,'California',11000000),(3,2022,'Texas',15000000); | SELECT SUM(budget_amount) FROM healthcare_budget WHERE budget_year = 2022 AND budget_state = 'California'; |
What are the conservation statuses of marine species in the Pacific Ocean? | CREATE TABLE PacificSpecies (species_name TEXT,conservation_status TEXT); INSERT INTO PacificSpecies (species_name,conservation_status) VALUES ('Great White Shark','Vulnerable'),('Sea Otter','Endangered'); CREATE TABLE MarineSpecies (species_name TEXT,habitat TEXT); INSERT INTO MarineSpecies (species_name,habitat) VALU... | SELECT MarineSpecies.species_name, PacificSpecies.conservation_status FROM MarineSpecies INNER JOIN PacificSpecies ON MarineSpecies.species_name = PacificSpecies.species_name; |
What is the total cost of humanitarian assistance provided by the EU to South American countries since 2016? | CREATE TABLE eu_humanitarian_assistance (donor VARCHAR(255),recipient VARCHAR(255),cost DECIMAL(10,2),assistance_date DATE); | SELECT SUM(cost) FROM eu_humanitarian_assistance WHERE donor = 'EU' AND recipient LIKE 'South America%' AND assistance_date >= '2016-01-01'; |
List all aircraft manufactured by Boeing. | CREATE TABLE aircraft (aircraft_id INT,name VARCHAR(100),manufacturer VARCHAR(100),first_flight DATE); INSERT INTO aircraft (aircraft_id,name,manufacturer,first_flight) VALUES (1,'Boeing 707','Boeing','1957-12-20'),(2,'Boeing 727','Boeing','1963-02-09'); | SELECT name FROM aircraft WHERE manufacturer = 'Boeing'; |
What is the total number of news stories published per city in the "stories" and "journalists" tables? | CREATE TABLE stories (id INT,title VARCHAR(50),publication_date DATE,journalist_id INT); INSERT INTO stories (id,title,publication_date,journalist_id) VALUES (1,'The Big Heist','2021-01-01',1),(2,'Mystery of the Lost Art','2021-02-01',2),(3,'The Unsolved Case','2021-03-01',3),(4,'The Secret Files','2021-01-01',1); CREA... | SELECT city, COUNT(DISTINCT stories.id) AS total_stories FROM stories INNER JOIN journalists ON stories.journalist_id = journalists.id GROUP BY city; |
How many VR headsets were sold in each region for the last quarter? | CREATE TABLE vr_sales (id INT,product VARCHAR(100),quantity INT,sale_date DATE,region VARCHAR(100)); INSERT INTO vr_sales (id,product,quantity,sale_date,region) VALUES (1,'Oculus Quest 2',100,'2022-04-01','North America'),(2,'HTC Vive Pro 2',50,'2022-05-01','Europe'),(3,'Valve Index',75,'2022-06-01','Asia'); | SELECT region, SUM(quantity) as total_sold FROM vr_sales WHERE sale_date >= (CURRENT_DATE - INTERVAL '3 months') GROUP BY region; |
Show the number of open data portals for each department. | CREATE TABLE departments (name VARCHAR(255),open_data_portal BOOLEAN); | SELECT name, COUNT(*) FROM departments WHERE open_data_portal = TRUE GROUP BY name; |
What is the total population of animals in the "animal_population" view that are younger than 5? | CREATE VIEW animal_population AS SELECT 'Penguin' AS species,COUNT(*) AS num_animals FROM penguins WHERE age < 5 UNION ALL SELECT 'Turtle' AS species,COUNT(*) AS num_animals FROM turtles WHERE age < 5; | SELECT SUM(num_animals) FROM animal_population; |
What is the total number of volunteers for education programs in Australia? | CREATE TABLE volunteers (volunteer_id INT,volunteer_name TEXT,program TEXT,country TEXT); INSERT INTO volunteers VALUES (1,'Alex Johnson','Education','Australia'),(2,'Emily Brown','Healthcare','Australia'),(3,'Oliver Smith','Education','Australia'); | SELECT COUNT(*) FROM volunteers WHERE program = 'Education' AND country = 'Australia'; |
What is the total property value in neighborhoods with green spaces in Barcelona? | CREATE TABLE Barcelona_Neighborhoods (Neighborhood_Name TEXT,Green_Space BOOLEAN); INSERT INTO Barcelona_Neighborhoods (Neighborhood_Name,Green_Space) VALUES ('Eixample',false),('Gracia',true),('Born',false),('Raval',false),('Sants-Montjuic',true); CREATE TABLE Barcelona_Properties (Neighborhood_Name TEXT,Property_Pric... | SELECT SUM(Barcelona_Properties.Property_Price) FROM Barcelona_Properties INNER JOIN Barcelona_Neighborhoods ON Barcelona_Properties.Neighborhood_Name = Barcelona_Neighborhoods.Neighborhood_Name WHERE Barcelona_Neighborhoods.Green_Space = true; |
Which fields have recorded a temperature lower than 13.5 degrees Celsius? | CREATE TABLE field_1 (date DATE,temperature FLOAT); INSERT INTO field_1 (date,temperature) VALUES ('2022-01-01',15.0),('2022-01-02',14.5); CREATE TABLE field_2 (date DATE,temperature FLOAT); INSERT INTO field_2 (date,temperature) VALUES ('2022-01-01',16.0),('2022-01-02',18.0); | SELECT 'field_1' AS field_name FROM field_1 WHERE temperature < 13.5 UNION SELECT 'field_2' AS field_name FROM field_2 WHERE temperature < 13.5; |
How many unique visitors attended music events in the first quarter of 2021? | CREATE TABLE MusicEvents (eventID INT,visitorID INT,eventDate DATE); INSERT INTO MusicEvents (eventID,visitorID,eventDate) VALUES (1,1,'2021-01-01'),(2,2,'2021-02-10'),(3,1,'2021-03-20'); | SELECT COUNT(DISTINCT visitorID) FROM MusicEvents WHERE eventDate >= '2021-01-01' AND eventDate < '2021-04-01'; |
Identify the number of clinical trials conducted by Asian biotech companies in the oncology department that were successful but not yet approved by the FDA between 2017 and 2020, excluding trials from South Korea. | CREATE TABLE clinical_trials (id INT,company VARCHAR(255),department VARCHAR(255),trial_status VARCHAR(255),fda_approval_date DATE,company_location VARCHAR(255)); INSERT INTO clinical_trials (id,company,department,trial_status,fda_approval_date,company_location) VALUES (1,'Asian BioTech 1','Oncology','Successful',NULL,... | SELECT COUNT(*) FROM clinical_trials WHERE department = 'Oncology' AND trial_status = 'Successful' AND fda_approval_date IS NULL AND company_location NOT IN ('South Korea') AND fda_approval_date BETWEEN '2017-01-01' AND '2020-12-31'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.