instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Retrieve distinct AI safety concerns mentioned in research by Australian and Singaporean authors. | CREATE TABLE ai_safety_research (id INT,author VARCHAR(50),country VARCHAR(50),concern VARCHAR(100)); INSERT INTO ai_safety_research (id,author,country,concern) VALUES (1,'Grace Taylor','Australia','Data Privacy'),(2,'Liam Wong','Singapore','Algorithmic Bias'); | SELECT DISTINCT concern FROM ai_safety_research WHERE country IN ('Australia', 'Singapore'); |
What is the average monthly water consumption for residential use in Los Angeles, CA, for the years 2017 and 2018, broken down by month? | CREATE TABLE la_residential_water (year INT,month INT,consumption FLOAT,city VARCHAR(255),state VARCHAR(255)); INSERT INTO la_residential_water (year,month,consumption,city,state) VALUES (2017,1,12000,'Los Angeles','CA'),(2017,2,11000,'Los Angeles','CA'),(2017,3,13000,'Los Angeles','CA'),(2018,1,14000,'Los Angeles','CA... | SELECT month, AVG(consumption) as avg_consumption FROM la_residential_water WHERE city = 'Los Angeles' AND state = 'CA' AND year IN (2017, 2018) GROUP BY month; |
How many space missions were led by countries other than the US and Russia? | CREATE TABLE space_missions (mission_id INT,mission_name VARCHAR(255),launch_country VARCHAR(50)); INSERT INTO space_missions (mission_id,mission_name,launch_country) VALUES (1,'Apollo 11','USA'),(2,'Sputnik 1','Russia'); | SELECT COUNT(*) FROM space_missions WHERE launch_country NOT IN ('USA', 'Russia'); |
What percentage of cosmetic products from India have a safety rating above 4.5? | CREATE TABLE product_safety (product_name VARCHAR(100),launch_year INT,safety_rating DECIMAL(3,2),country VARCHAR(100)); INSERT INTO product_safety (product_name,launch_year,safety_rating,country) VALUES ('Lush Cleanser',2020,4.8,'India'),('The Body Shop Moisturizer',2020,4.6,'India'),('Pacifica Serum',2019,4.9,'USA'),... | SELECT country, 100.0 * AVG(CASE WHEN safety_rating > 4.5 THEN 1 ELSE 0 END) AS pct_safety_rating FROM product_safety WHERE country = 'India' GROUP BY country; |
What is the maximum CO2 offset for carbon offset projects in a given year? | CREATE TABLE CarbonOffsetProjects (id INT,year INT,co2_offset FLOAT); INSERT INTO CarbonOffsetProjects (id,year,co2_offset) VALUES (1,2020,1000),(2,2020,2000),(3,2021,3000); | SELECT MAX(co2_offset) FROM CarbonOffsetProjects WHERE year = 2020; |
What is the total attendance at heritage sites in Asia in the last 5 years? | CREATE TABLE heritage_sites (id INT,name VARCHAR(50),location VARCHAR(50),year INT,attendance INT); INSERT INTO heritage_sites (id,name,location,year,attendance) VALUES (1,'Angkor Wat','Asia',2017,2500000),(2,'Taj Mahal','Asia',2018,3000000),(3,'Machu Picchu','South America',2019,1500000); | SELECT SUM(attendance) FROM heritage_sites WHERE location = 'Asia' AND year BETWEEN 2017 AND 2021; |
What is the average gas production for wells in the Permian Basin in 2020? | CREATE TABLE well (well_id INT,well_name TEXT,shale_play TEXT,gas_production_2020 FLOAT); INSERT INTO well (well_id,well_name,shale_play,gas_production_2020) VALUES (1,'Well A','Permian Basin',9000),(2,'Well B','Permian Basin',11000),(3,'Well C','Permian Basin',8000); | SELECT AVG(gas_production_2020) as average_gas_production FROM well WHERE shale_play = 'Permian Basin'; |
What is the policy type and number of policies issued per region for the last quarter? | CREATE TABLE Policy (PolicyId INT,PolicyType VARCHAR(50),IssueDate DATE,Region VARCHAR(50)); | SELECT Region, PolicyType, COUNT(PolicyId) FROM Policy WHERE IssueDate >= DATEADD(quarter, -1, GETDATE()) GROUP BY Region, PolicyType; |
What is the name of the artist with the highest ticket price for their exhibitions in Paris? | CREATE TABLE ArtistExhibitions (id INT,artist_id INT,city VARCHAR(20),price DECIMAL(5,2)); INSERT INTO ArtistExhibitions (id,artist_id,city,price) VALUES (1,1,'Paris',30.00),(2,1,'Rome',25.00),(3,2,'Paris',35.00),(4,2,'London',20.00); CREATE TABLE Artists (id INT,name VARCHAR(30)); INSERT INTO Artists (id,name) VALUES ... | SELECT Artists.name, ArtistExhibitions.price FROM Artists JOIN ArtistExhibitions ON Artists.id = ArtistExhibitions.artist_id WHERE city = 'Paris' ORDER BY price DESC LIMIT 1; |
What is the average lifespan of dams in the Western region that were built between 1950 and 1970, and the number of such dams? | CREATE TABLE dams (id INT PRIMARY KEY,dam_name VARCHAR(255),year_built INT,region VARCHAR(255),current_age INT); INSERT INTO dams (id,dam_name,year_built,region,current_age) VALUES (1,'Dam A',1965,'Western',56); INSERT INTO dams (id,dam_name,year_built,region,current_age) VALUES (2,'Dam B',1975,'Western',46); | SELECT AVG(current_age), COUNT(*) FROM dams WHERE region = 'Western' AND year_built BETWEEN 1950 AND 1970; |
How many unique artists are from Asia and performed at music festivals in 2020? | CREATE TABLE Artists (region VARCHAR(50),festival_performance INT); INSERT INTO Artists (region,festival_performance) VALUES ('Asia',1); INSERT INTO Artists (region,festival_performance) VALUES ('Asia',1); | SELECT COUNT(DISTINCT region) FROM Artists WHERE region = 'Asia' AND festival_performance = 1; |
How many infectious diseases have been reported in each region? | CREATE TABLE InfectiousDiseases (Id INT,Disease TEXT,Region TEXT,Date DATE); INSERT INTO InfectiousDiseases (Id,Disease,Region,Date) VALUES (1,'Measles','Region A','2022-01-01'); INSERT INTO InfectiousDiseases (Id,Disease,Region,Date) VALUES (2,'Mumps','Region A','2022-01-02'); INSERT INTO InfectiousDiseases (Id,Diseas... | SELECT Region, Disease FROM InfectiousDiseases GROUP BY Region; |
What is the average population of cities built before 1900? | CREATE TABLE cities (id INT PRIMARY KEY,name VARCHAR(255),population INT,built_year INT); INSERT INTO cities (id,name,population,built_year) VALUES (1,'CityA',120000,1950),(2,'CityB',250000,1880),(3,'CityC',50000,1985); | SELECT AVG(population) as avg_population FROM cities WHERE built_year < 1900; |
What was the total amount donated by individual donors to the 'Education' cause in '2021'? | CREATE TABLE Donations (donor_id INT,donation_amount FLOAT,donation_date DATE,cause VARCHAR(255)); INSERT INTO Donations (donor_id,donation_amount,donation_date,cause) VALUES (1,500.00,'2021-01-01','Education'),(2,300.00,'2021-02-03','Health'),(3,800.00,'2021-05-05','Education'); | SELECT SUM(donation_amount) FROM Donations WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' AND cause = 'Education'; |
What is the total production of oil and gas in the US for the years 2015 to 2018? | CREATE TABLE production (id INT,year INT,region VARCHAR(255),oil_production DECIMAL(5,2),gas_production DECIMAL(5,2)); INSERT INTO production (id,year,region,oil_production,gas_production) VALUES (1,2015,'US',1000.0,500.0),(2,2016,'US',1200.0,550.0),(3,2017,'US',1500.0,600.0),(4,2018,'US',1800.0,700.0); | SELECT SUM(oil_production + gas_production) as total_production FROM production WHERE year BETWEEN 2015 AND 2018 AND region = 'US'; |
Identify the top 3 countries with the highest total visitor count for 'Contemporary' art exhibitions. | CREATE TABLE Exhibitions (id INT,name TEXT,genre TEXT,visitor_count INT,country TEXT); | SELECT country, SUM(visitor_count) as total_visitors FROM Exhibitions WHERE genre = 'Contemporary' GROUP BY country ORDER BY total_visitors DESC LIMIT 3; |
What is the percentage of policies with a claim amount less than $2000 in the 'New York' region? | CREATE TABLE policies (id INT,policy_number INT,claim_amount INT,region TEXT); INSERT INTO policies VALUES (1,1234,5000,'New York'); INSERT INTO policies VALUES (2,5678,7000,'New York'); INSERT INTO policies VALUES (3,9012,1500,'New York'); INSERT INTO policies VALUES (4,3456,2500,'New York'); | SELECT (COUNT(*) FILTER (WHERE claim_amount < 2000)) * 100.0 / COUNT(*) FROM policies WHERE region = 'New York'; |
What is the minimum number of community health workers by state? | CREATE TABLE state_health_workers (state VARCHAR(2),num_workers INT); INSERT INTO state_health_workers (state,num_workers) VALUES ('NY',100),('CA',150),('TX',200); | SELECT state, MIN(num_workers) OVER (PARTITION BY 1) as min_workers FROM state_health_workers; |
Which fish species have the highest average weight? | CREATE TABLE Fish (FishID INT,FishSpecies VARCHAR(50),AvgWeight FLOAT); INSERT INTO Fish (FishID,FishSpecies,AvgWeight) VALUES (1,'Salmon',6.5),(2,'Tilapia',1.2),(3,'Carp',2.8),(4,'Pangasius',3.5),(5,'Tuna',15.5),(6,'Shark',18.2); | SELECT FishSpecies, AvgWeight, DENSE_RANK() OVER (ORDER BY AvgWeight DESC) as rank FROM Fish; |
Who are the community health workers located in Atlanta with more than 3 years of experience? | CREATE TABLE CommunityHealthWorkers (id INT,name VARCHAR(50),location VARCHAR(50),yearsOfExperience INT); INSERT INTO CommunityHealthWorkers (id,name,location,yearsOfExperience) VALUES (1,'Jamal Johnson','Atlanta',7),(2,'Aaliyah Brown','New York',6); | SELECT * FROM CommunityHealthWorkers WHERE location = 'Atlanta' AND yearsOfExperience > 3; |
List the total amount of waste produced by each chemical category in the waste_data table. | CREATE TABLE waste_data (chemical_name VARCHAR(255),waste_amount INT,chemical_category VARCHAR(255)); INSERT INTO waste_data (chemical_name,waste_amount,chemical_category) VALUES ('Acetone',150,'Solvent'),('Hydrochloric Acid',200,'Acid'),('Sodium Hydroxide',100,'Base'); | SELECT chemical_category, SUM(waste_amount) FROM waste_data GROUP BY chemical_category; |
List all unique genres of games from the 'Game Design' table, sorted alphabetically. | CREATE TABLE Game_Design (GameID INT,GameName VARCHAR(100),Genre VARCHAR(50),Platform VARCHAR(50)); INSERT INTO Game_Design (GameID,GameName,Genre,Platform) VALUES (1,'GameA','Action','PC'),(2,'GameB','Adventure','Console'),(3,'GameC','Action','Console'),(4,'GameD','Simulation','VR'); | SELECT DISTINCT Genre FROM Game_Design ORDER BY Genre; |
What was the total number of posts made by users in Africa in each month of 2022? | CREATE SCHEMA socialmedia;CREATE TABLE posts (id INT,user_id INT,timestamp TIMESTAMP,region VARCHAR(255));INSERT INTO posts (id,user_id,timestamp,region) VALUES (1,1,'2022-01-01 12:00:00','Africa'),(2,2,'2022-02-15 15:00:00','Africa'); | SELECT EXTRACT(MONTH FROM timestamp) AS month, COUNT(DISTINCT user_id) AS total_posts FROM socialmedia.posts WHERE region = 'Africa' GROUP BY month ORDER BY month; |
What is the average annual precipitation in regions with ongoing rural infrastructure projects? | CREATE TABLE Regions (id INT,name VARCHAR(255),avg_annual_precipitation DECIMAL(5,2)); INSERT INTO Regions (id,name,avg_annual_precipitation) VALUES (1,'R1',900.50),(2,'R2',1200.75),(3,'R3',750.23); CREATE TABLE Projects (id INT,region_id INT,project_name VARCHAR(255),start_date DATE); INSERT INTO Projects (id,region_i... | SELECT AVG(Regions.avg_annual_precipitation) FROM Regions INNER JOIN Projects ON Regions.id = Projects.region_id; |
Show the number of unique countries where the company has operated. | CREATE TABLE ports (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO ports (id,name,country) VALUES (1,'Los Angeles','USA'),(2,'Singapore','Singapore'),(3,'Rotterdam','Netherlands'),(4,'Busan','South Korea'),(5,'Hamburg','Germany'); | SELECT COUNT(DISTINCT country) FROM ports; |
Find the top 3 countries with the highest financial capability. | CREATE TABLE financial_capability (id INT,country VARCHAR(20),capability DECIMAL(3,2)); INSERT INTO financial_capability (id,country,capability) VALUES (1,'Canada',0.85),(2,'Australia',0.83),(3,'Sweden',0.82),(4,'Norway',0.81),(5,'Finland',0.80); | SELECT country, capability FROM (SELECT country, capability, ROW_NUMBER() OVER (ORDER BY capability DESC) rn FROM financial_capability) t WHERE rn <= 3; |
What is the total budget for community development initiatives in the 'communitydev' schema for each initiative type? | CREATE TABLE communitydev.initiatives (id INT,initiative_type VARCHAR(50),budget FLOAT); INSERT INTO communitydev.initiatives (id,initiative_type,budget) VALUES (1,'Education',10000),(2,'Healthcare',15000),(3,'Agriculture',20000),(4,'Education',12000),(5,'Healthcare',18000); | SELECT initiative_type, SUM(budget) FROM communitydev.initiatives GROUP BY initiative_type; |
How many active drilling rigs are there currently in the Middle East? | CREATE TABLE rigs (rig_id INT,rig_name VARCHAR(100),status VARCHAR(50),region VARCHAR(50)); INSERT INTO rigs (rig_id,rig_name,status,region) VALUES (1,'Rig X','Active','Middle East'),(2,'Rig Y','Idle','Middle East'); | SELECT COUNT(*) FROM rigs WHERE status = 'Active' AND region = 'Middle East'; |
How many polar bears are there in Canada and Russia? | CREATE TABLE polar_bear_population (country VARCHAR(255),year INT,population INT); | SELECT SUM(population) FROM polar_bear_population WHERE country IN ('Canada', 'Russia'); |
What are the top 5 most popular workout types? | CREATE TABLE workouts (id INT,user_id INT,workout_type VARCHAR(20),duration INT); INSERT INTO workouts (id,user_id,workout_type,duration) VALUES (1,101,'Treadmill',30),(2,102,'Treadmill',45),(3,103,'Treadmill',60),(4,104,'Elliptical',30),(5,105,'Yoga',60),(6,106,'Pilates',45); | SELECT workout_type, COUNT(*) as num_workouts FROM workouts GROUP BY workout_type ORDER BY num_workouts DESC LIMIT 5; |
How many distinct viewers watched episodes of shows with more than 2 seasons? | CREATE TABLE Viewership (ViewerID INT,ShowID INT,Episode INT,WatchDate DATE); INSERT INTO Viewership (ViewerID,ShowID,Episode,WatchDate) VALUES (1,1,1,'2022-01-01'); INSERT INTO Viewership (ViewerID,ShowID,Episode,WatchDate) VALUES (2,2,1,'2022-02-01'); INSERT INTO Viewership (ViewerID,ShowID,Episode,WatchDate) VALUES ... | SELECT COUNT(DISTINCT ViewerID) as DistinctViewers FROM Viewership WHERE ShowID IN (SELECT ShowID FROM Shows WHERE Seasons > 2); |
What is the total amount of donations received for the 'Community Education' project?; | CREATE TABLE donations (id INT,donor_name VARCHAR(50),donation_amount DECIMAL(10,2),project_name VARCHAR(50),donation_date DATE); INSERT INTO donations (id,donor_name,donation_amount,project_name,donation_date) VALUES (1,'John Doe',500,'Habitat Restoration','2020-01-01'); INSERT INTO donations (id,donor_name,donation_a... | SELECT SUM(donation_amount) FROM donations WHERE project_name = 'Community Education'; |
How many patients were treated in 'clinic_i' without showing improvement? | CREATE TABLE patient_improvement (patient_id INT,improvement_status VARCHAR(50),treatment_center VARCHAR(50)); INSERT INTO patient_improvement (patient_id,improvement_status,treatment_center) VALUES (9,'No Improvement','clinic_i'); | SELECT COUNT(*) FROM patient_improvement WHERE improvement_status = 'No Improvement' AND treatment_center = 'clinic_i'; |
What is the maximum number of wins by a player in esports events? | CREATE TABLE EsportsWinners (EventID INT,PlayerID INT,Wins INT); INSERT INTO EsportsWinners (EventID,PlayerID,Wins) VALUES (1,1,3),(2,2,2),(3,1,1),(4,3,4); | SELECT MAX(Wins) FROM EsportsWinners; |
What is the total distance covered by users in a specific ZIP code? | CREATE TABLE Distances (id INT,user_id INT,distance FLOAT,zip_code INT); INSERT INTO Distances (id,user_id,distance,zip_code) VALUES (1,1,5.0,12345),(2,2,7.5,67890); | SELECT SUM(distance) FROM Distances WHERE zip_code = 12345; |
Insert new record of carbon sequestration data for Brazil in 2023 | CREATE TABLE carbon_sequestration (country_code CHAR(3),year INT,sequestration FLOAT); INSERT INTO carbon_sequestration (country_code,year,sequestration) VALUES ('BRA',2021,3.5),('BRA',2020,3.3); | INSERT INTO carbon_sequestration (country_code, year, sequestration) VALUES ('BRA', 2023, 3.7); |
Which cruelty-free certified products are not vegan-friendly? | CREATE TABLE product (id INT,name VARCHAR(50),is_cruelty_free BOOLEAN,is_vegan BOOLEAN); INSERT INTO product (id,name,is_cruelty_free,is_vegan) VALUES (1,'Lipstick A',true,false),(2,'Eye Shadow B',true,true); | SELECT name FROM product WHERE is_cruelty_free = true AND is_vegan = false; |
What is the average landfill capacity in Europe in 2020?' | CREATE TABLE landfills (country VARCHAR(50),capacity INT,year INT); INSERT INTO landfills (country,capacity,year) VALUES ('Germany',20000,2020),('France',18000,2020),('UK',16000,2020),('Italy',14000,2020),('Spain',12000,2020); | SELECT AVG(capacity) as avg_capacity FROM landfills WHERE year = 2020 AND country IN ('Germany', 'France', 'UK', 'Italy', 'Spain'); |
List all products that are not certified organic or contain artificial colors. | CREATE TABLE non_organic_products AS SELECT products.product_id,products.product_name FROM products WHERE products.is_organic = false; CREATE TABLE artificial_colors (product_id INT,color_id INT,color_name TEXT); INSERT INTO artificial_colors VALUES (1,1,'ColorA'),(2,2,'ColorB'),(3,3,'ColorC'),(4,4,'ColorD'),(5,1,'Co... | SELECT products.product_id, products.product_name FROM products WHERE products.product_id NOT IN (SELECT non_organic_products.product_id FROM non_organic_products) AND products.product_id IN (SELECT artificial_colors.product_id FROM artificial_colors) |
What is the total revenue for each genre of music? | CREATE TABLE Genres (GenreID int,GenreName varchar(255)); INSERT INTO Genres (GenreID,GenreName) VALUES (1,'Pop'),(2,'Rock'),(3,'Jazz'); CREATE TABLE Sales (SongID int,GenreID int,Revenue int); INSERT INTO Sales (SongID,GenreID,Revenue) VALUES (1,1,5000),(2,2,7000),(3,3,6000); | SELECT Genres.GenreName, SUM(Sales.Revenue) as TotalRevenue FROM Genres INNER JOIN Sales ON Genres.GenreID = Sales.GenreID GROUP BY Genres.GenreName; |
What is the average daily 'screen_time' for users in each country, for the 'social_media' database, partitioned by platform and ordered by average? | CREATE TABLE social_media (id INT,user_id INT,country VARCHAR(50),platform VARCHAR(50),screen_time INT); INSERT INTO social_media (id,user_id,country,platform,screen_time) VALUES (1,1001,'India','Facebook',360); INSERT INTO social_media (id,user_id,country,platform,screen_time) VALUES (2,1002,'Canada','Instagram',420);... | SELECT country, platform, AVG(screen_time) OVER (PARTITION BY country, platform ORDER BY AVG(screen_time) DESC) as avg_screen_time FROM social_media; |
What is the maximum number of players playing a game simultaneously? | CREATE TABLE PlayerSession (SessionID INT,PlayerID INT,GameID INT,StartTime TIMESTAMP,EndTime TIMESTAMP); INSERT INTO PlayerSession (SessionID,PlayerID,GameID,StartTime,EndTime) VALUES (1,1,1,'2022-01-01 10:00:00','2022-01-01 11:00:00'),(2,2,1,'2022-01-01 10:15:00','2022-01-01 12:00:00'),(3,3,2,'2022-01-02 14:00:00','2... | SELECT GameID, MAX(COUNT(*)) FROM PlayerSession GROUP BY GameID HAVING COUNT(DISTINCT StartTime) > 1; |
What is the sum of sales for sustainable garments as a percentage of total sales in Q1 2023? | CREATE TABLE sales (product_category VARCHAR(255),sales_amount NUMERIC,sustainable BOOLEAN); INSERT INTO sales (product_category,sales_amount,sustainable) VALUES ('jeans',600,FALSE); INSERT INTO sales (product_category,sales_amount,sustainable) VALUES ('t_shirt',400,TRUE); INSERT INTO sales (product_category,sales_amou... | SELECT (SUM(CASE WHEN sustainable THEN sales_amount ELSE 0 END)/SUM(sales_amount))*100 FROM sales WHERE sale_date BETWEEN '2023-01-01' AND '2023-03-31'; |
How many energy storage facilities are there in each state in the United States? | CREATE TABLE energy_storage_facilities (id INT,state VARCHAR(255),num_facilities INT); INSERT INTO energy_storage_facilities (id,state,num_facilities) VALUES (1,'California',5),(2,'Texas',6),(3,'New York',4),(4,'Florida',3); | SELECT state, COUNT(*) FROM energy_storage_facilities GROUP BY state; |
What is the total number of articles published in a specific category for a specific language? | CREATE TABLE article_lang_category (id INT PRIMARY KEY,article_id INT,language VARCHAR(50),category VARCHAR(255),FOREIGN KEY (article_id) REFERENCES articles(id)); | SELECT language, category, COUNT(*) as total_articles FROM article_lang_category GROUP BY language, category; |
List the titles and release years of the movies produced in Germany and have a rating of 9 or higher. | CREATE TABLE movies (id INT,title VARCHAR(255),rating FLOAT,release_year INT,country VARCHAR(50)); INSERT INTO movies (id,title,rating,release_year,country) VALUES (1,'Movie1',9.5,2010,'Germany'),(2,'Movie2',8.2,2012,'Germany'),(3,'Movie3',6.8,2015,'Germany'); | SELECT title, release_year FROM movies WHERE rating >= 9 AND country = 'Germany'; |
What is the average financial wellbeing score for clients in Brazil? | CREATE TABLE financial_wellbeing (id INT,client_id INT,country VARCHAR(50),score FLOAT); INSERT INTO financial_wellbeing (id,client_id,country,score) VALUES (1,601,'Brazil',70.0),(2,602,'Brazil',80.0); | SELECT country, AVG(score) as avg_score FROM financial_wellbeing WHERE country = 'Brazil'; |
What is the monthly revenue trend for the 'Fancy Bistro'? | CREATE TABLE sales (sale_id INT,restaurant_id INT,revenue INT,sale_date DATE); INSERT INTO sales (sale_id,restaurant_id,revenue,sale_date) VALUES (1,1,500,'2022-01-01'),(2,1,700,'2022-01-02'),(3,1,600,'2022-02-01'),(4,1,800,'2022-02-02'); CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255)); INSERT INTO resta... | SELECT DATE_FORMAT(s.sale_date, '%Y-%m') AS month, SUM(s.revenue) AS monthly_revenue FROM sales s JOIN restaurants r ON s.restaurant_id = r.restaurant_id WHERE r.name = 'Fancy Bistro' GROUP BY month; |
How many ethical certifications does the 'Sustainable Fashion' brand have? | CREATE TABLE Brands (brand_id INT PRIMARY KEY,name VARCHAR(50),ethical_certifications INT); INSERT INTO Brands (brand_id,name,ethical_certifications) VALUES (1,'Sustainable Fashion',3),(2,'Eco Friendly Wear',2); | SELECT ethical_certifications FROM Brands WHERE name = 'Sustainable Fashion'; |
What is the average trip distance for bike-sharing in Paris? | CREATE TABLE bike_sharing (id INT,trip_id INT,start_time TIMESTAMP,end_time TIMESTAMP,start_station TEXT,end_station TEXT,trip_distance FLOAT); | SELECT AVG(trip_distance) FROM bike_sharing WHERE start_station = 'Paris'; |
What's the market capitalization of the digital asset named 'Asset1'? | CREATE TABLE digital_assets (id INT,name VARCHAR(255),network VARCHAR(255),market_cap DECIMAL(10,2)); INSERT INTO digital_assets (id,name,network,market_cap) VALUES (1,'Asset1','network1',500),(2,'Asset2','network2',600); | SELECT market_cap FROM digital_assets WHERE name = 'Asset1'; |
What is the total number of cases resolved by each volunteer? | CREATE TABLE volunteers (volunteer_id INT,name TEXT); INSERT INTO volunteers (volunteer_id,name) VALUES (1,'Aarav'),(2,'Bella'),(3,'Charlie'); CREATE TABLE cases (case_id INT,volunteer_id INT,date TEXT,resolved_date TEXT); INSERT INTO cases (case_id,volunteer_id,date,resolved_date) VALUES (1,1,'2022-01-01','2022-01-15'... | SELECT volunteers.name, COUNT(cases.case_id) as total_cases_resolved FROM volunteers INNER JOIN cases ON volunteers.volunteer_id = cases.volunteer_id WHERE cases.date <= cases.resolved_date GROUP BY volunteers.name; |
What is the total budget allocated for education and healthcare services in 2022? | CREATE TABLE Budget (Year INT,Service VARCHAR(20),Amount DECIMAL(10,2)); INSERT INTO Budget (Year,Service,Amount) VALUES (2022,'Education',150000.00),(2022,'Healthcare',200000.00); | SELECT SUM(Amount) FROM Budget WHERE Year = 2022 AND Service IN ('Education', 'Healthcare'); |
How many wells have been drilled in the 'Gulf of Mexico'? | CREATE TABLE wells (well_id INT,well_name VARCHAR(50),region VARCHAR(50)); INSERT INTO wells (well_id,well_name,region) VALUES (1,'Well A','Gulf of Mexico'),(2,'Well B','North Sea'); | SELECT COUNT(*) FROM wells WHERE region = 'Gulf of Mexico'; |
What was the total amount of funding received by agricultural projects in Guatemala in 2019, led by either women or Indigenous communities? | CREATE TABLE Agricultural_Projects (Project_ID INT,Project_Name TEXT,Location TEXT,Funding_Received DECIMAL,Led_By TEXT,Year INT); INSERT INTO Agricultural_Projects (Project_ID,Project_Name,Location,Funding_Received,Led_By,Year) VALUES (1,'Sustainable Farming Project','Guatemala',40000,'Women',2019),(2,'Agroforestry Pr... | SELECT SUM(Funding_Received) FROM Agricultural_Projects WHERE (Led_By = 'Women' OR Led_By = 'Indigenous') AND Year = 2019 AND Location = 'Guatemala'; |
What is the distribution of employee salaries by gender? | CREATE TABLE employees (id INT,name VARCHAR(255),gender VARCHAR(255),salary DECIMAL(10,2)); INSERT INTO employees (id,name,gender,salary) VALUES (1,'John Doe','Male',40000.00),(2,'Jane Smith','Female',45000.00),(3,'Alice Johnson','Female',80000.00),(4,'Bob Brown','Male',70000.00),(5,'Charlie Davis','Non-binary',55000.0... | SELECT gender, AVG(salary) as avg_salary, MIN(salary) as min_salary, MAX(salary) as max_salary FROM employees GROUP BY gender; |
What is the total revenue of all fair trade certified factories in Africa? | CREATE TABLE factories (id INT,name VARCHAR(50),country VARCHAR(50),certification VARCHAR(50),revenue DECIMAL(5,2)); INSERT INTO factories (id,name,country,certification,revenue) VALUES (1,'FairAF1','Kenya','Fair Trade',5000.00),(2,'GreenAF','Tanzania','B Corp',7000.00),(3,'EcoAF','Uganda','Fair Trade',6000.00); | SELECT SUM(revenue) as total_revenue FROM factories WHERE certification = 'Fair Trade' AND country IN ('Kenya', 'Tanzania', 'Uganda'); |
What is the number of patients treated for each mental health condition, and their respective percentages in the patient_treatment table? | CREATE TABLE patient_treatment (patient_id INT,condition VARCHAR(50),treatment_date DATE); INSERT INTO patient_treatment (patient_id,condition,treatment_date) VALUES (1,'Depression','2020-02-14'); INSERT INTO patient_treatment (patient_id,condition,treatment_date) VALUES (2,'Anxiety','2019-06-21'); INSERT INTO patient_... | SELECT condition, COUNT(*) AS count, ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM patient_treatment), 2) AS percentage FROM patient_treatment GROUP BY condition; |
Show all records from the accommodations table that are not elevators. | CREATE TABLE accommodations (id INT,type VARCHAR(255),description VARCHAR(255)); INSERT INTO accommodations (id,type,description) VALUES (1,'Wheelchair Ramp','Ramp with handrails and non-slip surface'); INSERT INTO accommodations (id,type,description) VALUES (2,'Elevator','Standard elevator for building access'); | SELECT * FROM accommodations WHERE type <> 'Elevator'; |
How many clean energy policies are in Texas and California | CREATE TABLE clean_energy_policies (policy_id INT,state VARCHAR(20)); INSERT INTO clean_energy_policies (policy_id,state) VALUES (1,'Texas'),(2,'California'),(3,'California'); | SELECT state, COUNT(*) FROM clean_energy_policies GROUP BY state HAVING state IN ('Texas', 'California'); |
What is the physician density in Australia? | CREATE TABLE Medical (Country TEXT,PhysicianDensity FLOAT); INSERT INTO Medical VALUES ('Australia',3.3); | SELECT PhysicianDensity FROM Medical WHERE Country = 'Australia'; |
Count the number of items in the inventory that are fair trade certified. | CREATE TABLE Inventory(item_id INT,item_name VARCHAR(50),is_fair_trade_certified BOOLEAN,quantity INT); INSERT INTO Inventory VALUES(1,'Apples',TRUE,100),(2,'Bananas',FALSE,200),(3,'Chocolate',TRUE,150); | SELECT COUNT(*) FROM Inventory WHERE is_fair_trade_certified = TRUE; |
What are the top 3 countries with the highest average consumer preference score for organic products? | CREATE TABLE products_organic_country (id INT,product_name TEXT,consumer_preference FLOAT,sourcing_country TEXT,organic BOOLEAN); INSERT INTO products_organic_country (id,product_name,consumer_preference,sourcing_country,organic) VALUES (1,'Lotion',4.3,'USA',true),(2,'Shampoo',4.1,'Canada',true),(3,'Soap',4.6,'France',... | SELECT sourcing_country, AVG(consumer_preference) AS avg_preference FROM products_organic_country WHERE organic = true GROUP BY sourcing_country ORDER BY avg_preference DESC LIMIT 3; |
List the virtual tour engagement stats for the top_5_countries with the highest number of hotels in the hotel_data table. | CREATE TABLE hotel_data (hotel_id INT,hotel_name TEXT,country TEXT,stars INT); INSERT INTO hotel_data (hotel_id,hotel_name,country,stars) VALUES (1,'Park Hotel','Switzerland',5),(2,'Four Seasons','Canada',5),(3,'The Plaza','USA',4); CREATE TABLE virtual_tour_stats (hotel_id INT,country TEXT,total_views INT); INSERT INT... | (SELECT country, total_views FROM (SELECT country, total_views, ROW_NUMBER() OVER (ORDER BY total_views DESC) as rank FROM virtual_tour_stats JOIN hotel_data ON virtual_tour_stats.hotel_id = hotel_data.hotel_id GROUP BY country) as top_5_countries WHERE rank <= 5); |
What is the maximum speed of vessels that have been inspected? | CREATE TABLE Vessel (vessel_id INT,name VARCHAR(255),type VARCHAR(255),max_speed DECIMAL(5,2)); CREATE TABLE Inspection (inspection_id INT,vessel_id INT,inspection_time TIMESTAMP); INSERT INTO Vessel (vessel_id,name,type,max_speed) VALUES (1,'Test Vessel 1','Cargo',20.5),(2,'Test Vessel 2','Tanker',15.2); INSERT INTO I... | SELECT MAX(v.max_speed) FROM Vessel v INNER JOIN Inspection i ON v.vessel_id = i.vessel_id; |
What is the total revenue generated from concert ticket sales for artists from the United States? | CREATE TABLE Artists (ArtistID INT,ArtistName VARCHAR(100),Country VARCHAR(50)); INSERT INTO Artists (ArtistID,ArtistName,Country) VALUES (1,'Taylor Swift','USA'),(2,'BTS','South Korea'); CREATE TABLE Concerts (ConcertID INT,ArtistID INT,Venue VARCHAR(100),TicketRevenue DECIMAL(10,2)); INSERT INTO Concerts (ConcertID,A... | SELECT SUM(Concerts.TicketRevenue) FROM Concerts INNER JOIN Artists ON Concerts.ArtistID = Artists.ArtistID WHERE Artists.Country = 'USA'; |
Which legal technology tools are available in the 'legal_tech' table? | CREATE TABLE legal_tech (id INT,name VARCHAR(50),type VARCHAR(30),description TEXT); INSERT INTO legal_tech (id,name,type,description) VALUES (1,'Case Management System','Software','A system for managing cases and documents within a legal organization.'); INSERT INTO legal_tech (id,name,type,description) VALUES (2,'E-D... | SELECT name FROM legal_tech; |
What was the average duration of defense projects initiated between 2015 and 2018, excluding projects that lasted more than 5 years? | CREATE TABLE Defense_Projects(id INT,project_name VARCHAR(255),start_year INT,end_year INT); INSERT INTO Defense_Projects(id,project_name,start_year,end_year) VALUES (1,'Project A',2015,2018),(2,'Project B',2016,2019),(3,'Project C',2017,2020),(4,'Project D',2018,2021),(5,'Project E',2015,2020),(6,'Project F',2016,2017... | SELECT AVG(end_year - start_year) as Average_Duration FROM Defense_Projects WHERE start_year BETWEEN 2015 AND 2018 AND end_year - start_year <= 5; |
What is the total claim amount for policies in California? | CREATE TABLE Policy (PolicyID int,PolicyType varchar(50),EffectiveDate date,RiskScore int); CREATE TABLE Claim (ClaimID int,PolicyID int,ClaimDate date,ClaimAmount int,State varchar(50)); INSERT INTO Policy (PolicyID,PolicyType,EffectiveDate,RiskScore) VALUES (1,'Auto','2020-01-01',700),(2,'Home','2019-05-05',900),(3,'... | SELECT SUM(Claim.ClaimAmount) FROM Policy INNER JOIN Claim ON Policy.PolicyID = Claim.PolicyID WHERE Claim.State = 'California'; |
Which donors contributed the most to environmental programs in 2022? | CREATE TABLE Donations (DonationID int,DonorID int,Amount decimal,DonationDate date,ProgramID int); CREATE TABLE Donors (DonorID int,DonorName varchar(50)); CREATE TABLE Programs (ProgramID int,ProgramName varchar(50)); INSERT INTO Donors (DonorID,DonorName) VALUES (1,'John Smith'); INSERT INTO Programs (ProgramID,Prog... | SELECT DonorName, SUM(Amount) as TotalDonationToEnvironment FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE ProgramID = 1 AND YEAR(DonationDate) = 2022 GROUP BY DonorName ORDER BY TotalDonationToEnvironment DESC; |
How many marine species in the Pacific Ocean are threatened by pollution? | CREATE TABLE marine_species (name VARCHAR(255),region VARCHAR(255),threatened_by_pollution BOOLEAN); INSERT INTO marine_species (name,region,threatened_by_pollution) VALUES ('Species 1','Pacific',TRUE); INSERT INTO marine_species (name,region,threatened_by_pollution) VALUES ('Species 2','Atlantic',FALSE); | SELECT COUNT(*) FROM marine_species WHERE region = 'Pacific' AND threatened_by_pollution = TRUE; |
How many fair labor practice certifications were issued in South America in the last 6 months? | CREATE TABLE certifications_sa (certification_id INT,certification_date DATE,region VARCHAR(50)); INSERT INTO certifications_sa (certification_id,certification_date,region) VALUES (1,'2021-04-15','South America'),(2,'2021-06-28','South America'),(3,'2020-12-10','South America'); | SELECT COUNT(*) FROM certifications_sa WHERE region = 'South America' AND certification_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND CURDATE(); |
List all community development initiatives and their corresponding funding sources from the 'rural_development' database | CREATE TABLE community_development (id INT,initiative VARCHAR(50),description TEXT); CREATE TABLE funding_sources (id INT,source VARCHAR(50),community_id INT); INSERT INTO community_development (id,initiative,description) VALUES (1,'Youth Center','A place for local youth to gather and learn'); INSERT INTO community_dev... | SELECT community_development.initiative, funding_sources.source FROM community_development INNER JOIN funding_sources ON community_development.id = funding_sources.community_id; |
Virtual tour engagement statistics for hotels in 'Europe'? | CREATE TABLE virtual_tours (hotel_id INT,hotel_name TEXT,region TEXT,views INT,clicks INT); INSERT INTO virtual_tours (hotel_id,hotel_name,region,views,clicks) VALUES (1,'Hotel Royal','Asia',200,50),(2,'Palace Hotel','Europe',300,80),(3,'Beach Resort','Americas',150,30),(4,'Luxury Villa','Europe',400,100),(5,'Mountain ... | SELECT region, AVG(views), AVG(clicks) FROM virtual_tours WHERE region = 'Europe' GROUP BY region; |
Calculate the average sales figure for all drugs in Oceania. | CREATE TABLE sales_figures_3 (drug_name TEXT,region TEXT,sales_value NUMERIC); INSERT INTO sales_figures_3 (drug_name,region,sales_value) VALUES ('Nexo','Australia',1200000),('RemedX','New Zealand',1000000); | SELECT AVG(sales_value) FROM sales_figures_3 WHERE region = 'Oceania'; |
Which publications about the Inca Empire were written by authors from Peru? | CREATE TABLE Publication (PublicationID INT PRIMARY KEY,Title VARCHAR(50),AuthorID INT,Year INT,Type VARCHAR(50),Country VARCHAR(50)); INSERT INTO Publication (PublicationID,Title,AuthorID,Year,Type,Country) VALUES (2,'The Incas: New Perspectives',4,2000,'Book','Peru'); | SELECT Title FROM Publication WHERE Country = 'Peru' AND Type = 'Book' AND (SELECT Specialty FROM Archaeologist WHERE Archaeologist.ArchaeologistID = Publication.AuthorID) = 'Inca Empire'; |
What is the percentage of members that are involved in labor rights advocacy in Illinois? | CREATE TABLE union_advocacy (id INT,union_name TEXT,state TEXT,involved_in_advocacy BOOLEAN); INSERT INTO union_advocacy (id,union_name,state,involved_in_advocacy) VALUES (1,'Union J','Illinois',true),(2,'Union K','Illinois',true),(3,'Union L','Illinois',false); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM union_advocacy WHERE state = 'Illinois')) AS percentage FROM union_advocacy WHERE involved_in_advocacy = true AND state = 'Illinois'; |
Which rural hospitals offer more resources (budget) than the total resources allocated to clinics? | CREATE TABLE hospitals (id INT,name TEXT,budget INT); INSERT INTO hospitals VALUES (1,'Rural Hospital A',1000000); INSERT INTO hospitals VALUES (2,'Rural Hospital B',1500000); CREATE TABLE clinics (id INT,name TEXT,budget INT); INSERT INTO clinics VALUES (1,'Rural Clinic A',300000); INSERT INTO clinics VALUES (2,'Rural... | SELECT name FROM hospitals WHERE budget > (SELECT SUM(budget) FROM clinics); |
What is the average age of players who play games with the 'open world' genre? | CREATE TABLE PlayerGenre (PlayerID INT,Age INT,Genre VARCHAR(20)); INSERT INTO PlayerGenre (PlayerID,Age,Genre) VALUES (1,25,'Racing'); INSERT INTO PlayerGenre (PlayerID,Age,Genre) VALUES (2,32,'Shooter'); INSERT INTO PlayerGenre (PlayerID,Age,Genre) VALUES (3,19,'Open World'); | SELECT AVG(Age) FROM PlayerGenre WHERE Genre = 'Open World'; |
What is the average sourcing rating of ingredients for each product category? | CREATE TABLE products (product_id INT,name VARCHAR(255),category VARCHAR(255)); CREATE TABLE ingredients (ingredient_id INT,product_id INT,name VARCHAR(255),sourcing_rating INT); INSERT INTO products (product_id,name,category) VALUES (1,'Lipstick','Lip'),(2,'Eye Shadow','Eye'),(3,'Mascara','Eye'),(4,'Foundation','Face'... | SELECT p.category, AVG(i.sourcing_rating) FROM products p JOIN ingredients i ON p.product_id = i.product_id GROUP BY p.category; |
What is the name and type of the most accurate biosensor, and the name and type of the least accurate biosensor? | CREATE TABLE biosensors (id INT,name VARCHAR(50),type VARCHAR(50),accuracy DECIMAL(3,2)); INSERT INTO biosensors (id,name,type,accuracy) VALUES (1,'Biosensor1','Glucose',0.95); INSERT INTO biosensors (id,name,type,accuracy) VALUES (2,'Biosensor2','Pressure',0.98); | SELECT name, type FROM biosensors WHERE accuracy = (SELECT MAX(accuracy) FROM biosensors) OR accuracy = (SELECT MIN(accuracy) FROM biosensors); |
Delete the artwork 'Artwork 2' and its corresponding artist. | CREATE TABLE artists (id INT,name TEXT); INSERT INTO artists (id,name) VALUES (1,'Artist 1'); CREATE TABLE artworks (id INT,title TEXT,artist_id INT); INSERT INTO artworks (id,title,artist_id) VALUES (1,'Artwork 1',1),(2,'Artwork 2',1); | DELETE a, ar FROM artworks a INNER JOIN artists ar ON a.artist_id = ar.id WHERE a.title = 'Artwork 2'; |
What is the total number of libraries in the state of New York? | CREATE TABLE states (id INT PRIMARY KEY,name TEXT); INSERT INTO states (id,name) VALUES (1,'New York'); CREATE TABLE libraries (id INT PRIMARY KEY,state_id INT,name TEXT); INSERT INTO libraries (id,state_id,name) VALUES (1,1,'New York Public Library'); INSERT INTO libraries (id,state_id,name) VALUES (2,1,'Brooklyn Publ... | SELECT COUNT(*) FROM libraries WHERE state_id = (SELECT id FROM states WHERE name = 'New York'); |
Who are the attorneys with a win rate greater than 75%? | CREATE TABLE cases (id INT,attorney_id INT,outcome VARCHAR(10)); INSERT INTO cases (id,attorney_id,outcome) VALUES (1,1001,'Positive'),(2,1001,'Positive'),(3,1002,'Negative'); CREATE TABLE attorneys (id INT,name VARCHAR(50)); INSERT INTO attorneys (id,name) VALUES (1001,'John Doe'),(1002,'Jane Smith'); | SELECT a.name FROM attorneys a INNER JOIN cases c ON a.id = c.attorney_id WHERE c.outcome = 'Positive' GROUP BY a.name HAVING COUNT(c.id) / (SELECT COUNT(*) FROM cases WHERE attorney_id = a.id) > 0.75; |
List all chemical manufacturing facilities in the African region, with their respective safety officer names and contact phone numbers. | CREATE TABLE africa_facilities (facility_id INT,facility_name TEXT,safety_officer_name TEXT,safety_officer_phone TEXT); INSERT INTO africa_facilities (facility_id,facility_name,safety_officer_name,safety_officer_phone) VALUES (1,'Facility K','Sara Njeri','+254 712 345678'),(2,'Facility L','Musa Seko','+27 81 9876543'),... | SELECT facility_name, safety_officer_name, safety_officer_phone FROM africa_facilities; |
Count the number of animals | CREATE TABLE animals (id INT PRIMARY KEY,name VARCHAR(50),species VARCHAR(50),population INT); INSERT INTO animals (id,name,species,population) VALUES (1,'Giraffe','Mammal',500); | SELECT COUNT(*) FROM animals; |
How many active oil rigs are there in the USA? | CREATE TABLE oil_rigs (country text,status text,drilling_depth real); INSERT INTO oil_rigs (country,status,drilling_depth) VALUES ('USA','active',12000),('USA','inactive',15000),('Canada','active',9000),('Mexico','inactive',8000),('Brazil','active',14000); | SELECT COUNT(*) FROM oil_rigs WHERE country = 'USA' AND status = 'active'; |
Delete all records with a donation date before January 1, 2010 in the 'donations' table. | CREATE TABLE donations (donation_id INT,donor_id INT,donation_date DATE); | DELETE FROM donations WHERE donation_date < '2010-01-01'; |
What is the maximum daily transaction volume on the Solana blockchain, and what was the date with the highest volume? | CREATE TABLE solana_transactions (transaction_date DATE,volume DECIMAL(30,0)); INSERT INTO solana_transactions (transaction_date,volume) VALUES ('2022-01-01',5000000),('2022-01-02',6000000),('2022-01-03',7000000),('2022-01-04',8000000),('2022-01-05',9000000); | SELECT MAX(volume), transaction_date FROM solana_transactions GROUP BY transaction_date; |
What is the minimum runtime of films directed by Indigenous filmmakers and released in the last decade? | CREATE TABLE movies (id INT,title VARCHAR(255),release_year INT,runtime INT,director VARCHAR(50)); INSERT INTO movies (id,title,release_year,runtime,director) VALUES (1,'Movie1',2016,105,'Director1'),(2,'Movie2',2018,120,'Director2'),(3,'Movie3',2019,95,'Director3'),(4,'Movie4',2020,110,'Director4'); | SELECT MIN(runtime) FROM movies WHERE release_year BETWEEN 2011 AND 2021 AND director LIKE '%Indigenous%'; |
What is the monthly water conservation target for each city in California? | CREATE TABLE cities (id INT,city_name VARCHAR(50),state VARCHAR(50)); INSERT INTO cities VALUES (1,'Los Angeles','California'),(2,'San Diego','California'),(3,'San Francisco','California'); CREATE TABLE targets (city_id INT,target_month INT,target_amount FLOAT); INSERT INTO targets VALUES (1,1,1200000),(1,2,1100000),(... | SELECT c.city_name, t.target_month, t.target_amount FROM cities c JOIN targets t ON c.id = t.city_id WHERE c.state = 'California'; |
What is the name of the port with UN/LOCODE 'USNYC' in the 'ports' table? | CREATE TABLE ports (port_id INT,name VARCHAR(50),un_locode VARCHAR(10)); INSERT INTO ports (port_id,name,un_locode) VALUES (1,'Port of Los Angeles','USLAX'),(2,'Port of Long Beach','USLGB'),(3,'Port of New York','USNYC'); | SELECT name FROM ports WHERE un_locode = 'USNYC'; |
What is the total revenue of organic food sales in the EU? | CREATE TABLE sales (id INT,year INT,region TEXT,revenue INT); INSERT INTO sales (id,year,region,revenue) VALUES (1,2020,'EU',100000); | SELECT SUM(revenue) FROM sales WHERE region = 'EU' AND year = 2020; |
Which ocean floor maps have been created more than once on the same day? | CREATE TABLE OceanFloorMapping (id INT PRIMARY KEY,MapName VARCHAR(100),MapDetails TEXT,MapDate DATE); INSERT INTO OceanFloorMapping (id,MapName,MapDetails,MapDate) VALUES (1,'Atlantic Ocean Floor Map','Detailed map of the Atlantic Ocean floor','2020-01-01'),(2,'Pacific Ocean Floor Map','Detailed map of the Pacific Oce... | SELECT MapName, COUNT(*) as NumberOfMaps FROM OceanFloorMapping GROUP BY MapName HAVING SUM(CASE WHEN COUNT(*) > 1 THEN 1 ELSE 0 END) > 0; |
Count of community health workers who have completed health equity metric trainings in California. | CREATE TABLE CommunityHealthWorkers (CHWId INT,Name VARCHAR(50),State VARCHAR(50)); CREATE TABLE HealthEquityMetricTrainings (HEMTrainingId INT,CHWId INT,TrainingDate DATE,State VARCHAR(50)); INSERT INTO CommunityHealthWorkers (CHWId,Name,State) VALUES (1,'Jasmine','California'),(2,'Kareem','Texas'),(3,'Leah','Californ... | SELECT COUNT(DISTINCT CHWId) FROM HealthEquityMetricTrainings WHERE State = 'California'; |
What is the total number of tourists who visited sustainable tourism destinations in Asia and Oceania in 2022? | CREATE TABLE TourismDestinations (DestinationID INT,DestinationType VARCHAR(20),Continent VARCHAR(20)); INSERT INTO TourismDestinations (DestinationID,DestinationType,Continent) VALUES (1,'SustainableTourism','Asia'),(2,'EcoTourism','Oceania'); CREATE TABLE Visitors (VisitorID INT,Nationality VARCHAR(20),DestinationID ... | SELECT COUNT(*) as Total FROM Visitors JOIN TourismDestinations ON Visitors.DestinationID = TourismDestinations.DestinationID WHERE VisitYear = 2022 AND (Continent = 'Asia' OR Continent = 'Oceania') AND DestinationType IN ('SustainableTourism', 'EcoTourism'); |
What are the names of graduate students who have not published any papers? | CREATE SCHEMA publications;CREATE TABLE student_publications(student_name TEXT,department TEXT,num_publications INTEGER);INSERT INTO student_publications(student_name,department,num_publications)VALUES('Gabby','Physics',0),('Hank','Computer Science',3); | SELECT student_name FROM publications.student_publications WHERE num_publications=0; |
What is the total number of volunteers who engaged in our programs in the last 12 months, broken down by state? | CREATE TABLE Volunteers (VolunteerID int,VolunteerName varchar(50),State varchar(50),LastEngagementDate date); | SELECT State, COUNT(*) FROM Volunteers WHERE LastEngagementDate >= DATEADD(month, -12, GETDATE()) GROUP BY State; |
Find the cities with the most shared bike trips and the most public transit trips. | CREATE TABLE shared_bikes (city VARCHAR(20),trips INT); INSERT INTO shared_bikes (city,trips) VALUES ('New York',2000000),('Los Angeles',1500000),('London',3000000),('Berlin',2500000),('Paris',1000000); CREATE TABLE public_transit (city VARCHAR(20),trips INT); INSERT INTO public_transit (city,trips) VALUES ('New York',... | SELECT city, 'shared_bikes' AS trip_type FROM shared_bikes WHERE trips = (SELECT MAX(trips) FROM shared_bikes) UNION SELECT city, 'public_transit' FROM public_transit WHERE trips = (SELECT MAX(trips) FROM public_transit); |
What is the total budget allocated for program 'Education' in 2021? | CREATE TABLE Budget (program_id INT,program_name VARCHAR(255),year INT,allocated_budget DECIMAL(10,2)); INSERT INTO Budget (program_id,program_name,year,allocated_budget) VALUES (1,'Arts',2021,2500.00),(2,'Education',2021,6000.00),(3,'Environment',2021,5000.00),(1,'Arts',2020,2000.00),(2,'Education',2020,3000.00),(3,'E... | SELECT SUM(allocated_budget) FROM Budget WHERE program_name = 'Education' AND year = 2021; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.