instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total number of digital divide initiatives in Asia? | CREATE TABLE digital_divide_initiatives (initiative_id INT,region VARCHAR(20),type VARCHAR(20)); INSERT INTO digital_divide_initiatives (initiative_id,region,type) VALUES (1,'Asia','education'),(2,'Europe','infrastructure'),(3,'North America','policy'); | SELECT COUNT(*) FROM digital_divide_initiatives WHERE region = 'Asia'; |
What is the total fare collected for each bus route? | CREATE TABLE bus_routes (route_id INT,route_name TEXT); CREATE TABLE fares (fare_id INT,route_id INT,fare DECIMAL); INSERT INTO bus_routes VALUES (1,'Route 1'),(2,'Route 2'),(3,'Route 3'); INSERT INTO fares VALUES (1,1,2.00),(2,1,2.00),(3,2,2.50),(4,3,3.00),(5,3,3.00); | SELECT bus_routes.route_name, SUM(fares.fare) AS total_fare FROM bus_routes INNER JOIN fares ON bus_routes.route_id = fares.route_id GROUP BY bus_routes.route_id; |
How many sustainable material products are supplied by each supplier? | CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),sustainable_materials BOOLEAN); CREATE TABLE products (id INT PRIMARY KEY,name VARCHAR(50),supplier_id INT,price DECIMAL(5,2)); INSERT INTO suppliers (id,name,country,sustainable_materials) VALUES (1,'Green Textiles','India',true),(2,'EcoWeave','Nepal',true),(3,'Fair Fabrics','Bangladesh',false); INSERT INTO products (id,name,supplier_id,price) VALUES (1,'Organic Cotton Shirt',1,29.99),(2,'Hemp Pants',1,39.99),(3,'Bamboo Tote Bag',2,14.99),(4,'Polyester Scarf',3,9.99); | SELECT s.name AS supplier_name, COUNT(p.id) AS product_count FROM suppliers s LEFT JOIN products p ON s.id = p.supplier_id AND s.sustainable_materials = true GROUP BY s.name; |
Calculate the average number of likes received by posts containing the hashtag '#bookreviews' in 'France', per day. | CREATE TABLE posts (id INT,date DATE,likes INT,content TEXT); CREATE TABLE hashtags (id INT,post_id INT,hashtag TEXT); | SELECT AVG(likes / DATEDIFF('2023-03-01', date)) AS avg_likes_per_day |
What is the total number of ad impressions and clicks for users in Europe, broken down by ad category? | CREATE TABLE ad_data (id INT,user_id INT,ad_category VARCHAR(50),impressions INT,clicks INT); INSERT INTO ad_data (id,user_id,ad_category,impressions,clicks) VALUES (1,1,'Social Media',50,10),(2,2,'E-commerce',100,20),(3,3,'Entertainment',75,15); CREATE TABLE users (id INT,country VARCHAR(50),continent VARCHAR(50)); INSERT INTO users (id,country,continent) VALUES (1,'Germany','Europe'),(2,'France','Europe'),(3,'Spain','Europe'); | SELECT users.continent, ad_category, SUM(impressions) as total_impressions, SUM(clicks) as total_clicks FROM ad_data JOIN users ON ad_data.user_id = users.id WHERE users.continent = 'Europe' GROUP BY users.continent, ad_category; |
Remove customers not interested in sustainable fashion | CREATE TABLE CustomerPreferences (CustomerID INT,PrefersSustainable BOOLEAN); INSERT INTO CustomerPreferences (CustomerID,PrefersSustainable) VALUES (1,TRUE),(2,FALSE),(3,TRUE); | DELETE FROM CustomerPreferences WHERE PrefersSustainable = FALSE; |
Calculate the number of new donors each quarter in the past year, and the total amount donated by new donors each quarter. | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationDate DATE,Amount DECIMAL(10,2)); | SELECT DATEPART(quarter, DonationDate) AS Quarter, DATEPART(year, DonationDate) AS Year, COUNT(DISTINCT DonorID) AS NewDonors, SUM(Amount) AS TotalDonated FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE()) GROUP BY DATEPART(quarter, DonationDate), DATEPART(year, DonationDate); |
List all programs that have had a volunteer from each country? | CREATE TABLE Volunteer (VolunteerID int,VolunteerName varchar(50),Country varchar(50)); CREATE TABLE VolunteerProgram (ProgramID int,VolunteerID int,ProgramLocation varchar(50)); | SELECT ProgramLocation FROM VolunteerProgram JOIN Volunteer ON VolunteerProgram.VolunteerID = Volunteer.VolunteerID GROUP BY ProgramLocation; |
List all suppliers who provide products to 'Organic Foods' store in the 'StoreSuppliers' table | CREATE TABLE StoreSuppliers (store VARCHAR(255),supplier VARCHAR(255)); INSERT INTO StoreSuppliers (store,supplier) VALUES ('Organic Foods','Supplier A'),('Organic Foods','Supplier B'),('Health Foods','Supplier C'); | SELECT supplier FROM StoreSuppliers WHERE store = 'Organic Foods'; |
List Canadian biotech companies working on gene therapy. | CREATE TABLE company_can (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),industry VARCHAR(255)); INSERT INTO company_can (id,name,location,industry) VALUES (1,'GeneTech','Toronto,Canada','Biotech'); CREATE TABLE research_can (id INT PRIMARY KEY,company_id INT,research_area VARCHAR(255)); INSERT INTO research_can (id,company_id,research_area) VALUES (1,1,'Gene Therapy'); | SELECT c.name FROM company_can c JOIN research_can r ON c.id = r.company_id WHERE c.location = 'Toronto, Canada' AND r.research_area = 'Gene Therapy'; |
What is the total number of public hospitals in India, excluding private hospitals? | CREATE TABLE hospitals_data (id INT,type TEXT,country TEXT); INSERT INTO hospitals_data (id,type,country) VALUES (1,'public','India'),(2,'private','India'),(3,'public','India'),(4,'private','India'),(5,'public','India'); | SELECT COUNT(*) FROM hospitals_data WHERE type = 'public' AND country = 'India'; |
List the top 3 most popular online travel agencies in Canada by bookings. | CREATE TABLE otas (ota_id INT,ota_name TEXT,country TEXT,bookings INT); INSERT INTO otas (ota_id,ota_name,country,bookings) VALUES (1,'OTA A','Canada',1500),(2,'OTA B','Canada',2000),(3,'OTA C','Canada',1800),(4,'OTA D','USA',2500); | SELECT ota_name, bookings FROM otas WHERE country = 'Canada' ORDER BY bookings DESC LIMIT 3; |
What is the market share of Hotel Chain C in South America? | CREATE TABLE market_share_2 (hotel_chain VARCHAR(255),region VARCHAR(255),market_share FLOAT); INSERT INTO market_share_2 (hotel_chain,region,market_share) VALUES ('Hotel Chain A','South America',0.35),('Hotel Chain B','South America',0.42),('Hotel Chain C','South America',0.23); | SELECT market_share * 100 FROM market_share_2 WHERE hotel_chain = 'Hotel Chain C'; |
What is the total number of bookings for each type of room in the 'Room_Bookings' table? | CREATE TABLE Room_Bookings (room_type VARCHAR(50),bookings INT); INSERT INTO Room_Bookings (room_type,bookings) VALUES ('Standard Room',200),('Deluxe Room',300),('Suite',400); | SELECT room_type, SUM(bookings) FROM Room_Bookings GROUP BY room_type; |
What is the total revenue for each hotel in the americas schema for February? | CREATE SCHEMA americas; CREATE TABLE americas.hotel_revenue (hotel_id INT,hotel_name VARCHAR(50),revenue INT,date DATE); | SELECT hotel_name, SUM(revenue) FROM americas.hotel_revenue WHERE date_trunc('month', date) = '2023-02-01'::DATE GROUP BY hotel_name; |
Who are the researchers from the 'University of Anchorage'? | CREATE TABLE researchers (id INT,name VARCHAR(255),affiliation VARCHAR(255),years_of_experience INT); INSERT INTO researchers (id,name,affiliation,years_of_experience) VALUES (1,'Alice','University of Anchorage',10); INSERT INTO researchers (id,name,affiliation,years_of_experience) VALUES (2,'Bob','Norwegian Polar Institute',15); | SELECT name, affiliation FROM researchers WHERE affiliation = 'University of Anchorage'; |
What indigenous languages are spoken in South American countries? | CREATE TABLE IndigenousLanguages (id INT,language VARCHAR(255),country VARCHAR(255)); INSERT INTO IndigenousLanguages (id,language,country) VALUES (1,'Quechua','Peru'),(2,'Aymara','Bolivia'),(3,'Guarani','Paraguay'); | SELECT IndigenousLanguages.language FROM IndigenousLanguages WHERE IndigenousLanguages.country IN ('Peru', 'Bolivia', 'Paraguay', 'Colombia', 'Argentina'); |
What is the average age of psychiatrists who have treated mental health patients in Europe, ordered by the number of patients treated? | CREATE TABLE psychiatrists (id INT,name TEXT,age INT,country TEXT,patients INT); INSERT INTO psychiatrists (id,name,age,country,patients) VALUES (1,'Alex Doe',50,'UK',50),(2,'Jane Smith',45,'France',75),(3,'Alice Johnson',55,'Germany',60),(4,'Bob Brown',60,'Italy',40); | SELECT AVG(age) as avg_age FROM (SELECT age, ROW_NUMBER() OVER (PARTITION BY country ORDER BY patients DESC) as rn FROM psychiatrists WHERE country IN ('UK', 'France', 'Germany', 'Italy')) t WHERE rn = 1; |
What is the sum of all dam construction costs in Spain? | CREATE TABLE Dam (id INT,name TEXT,location TEXT,cost FLOAT,build_date DATE); INSERT INTO Dam (id,name,location,cost,build_date) VALUES (1,'El Cuerzo Dam','Spain',250000000,'1991-01-01'); | SELECT SUM(cost) FROM Dam WHERE location = 'Spain'; |
Find the number of visitors who visited 'eco_tourism_spots' more than once. | CREATE TABLE eco_tourism_spots (visitor_id INT,spot_name VARCHAR(50)); INSERT INTO eco_tourism_spots (visitor_id,spot_name) VALUES (1,'Rainforest'),(1,'Mountains'),(2,'Ocean'),(3,'Desert'),(3,'Rainforest'); | SELECT COUNT(DISTINCT visitor_id) FROM eco_tourism_spots WHERE visitor_id IN (SELECT visitor_id FROM eco_tourism_spots GROUP BY visitor_id HAVING COUNT(*) > 1); |
How many sustainable tourism certifications were issued in Egypt in the last 3 years? | CREATE TABLE certifications (id INT,country VARCHAR(50),cert_date DATE); INSERT INTO certifications (id,country,cert_date) VALUES (1,'Egypt','2021-01-01'),(2,'Egypt','2020-12-10'),(3,'Egypt','2019-07-20'),(4,'Egypt','2022-02-15'); | SELECT COUNT(*) FROM certifications WHERE country = 'Egypt' AND cert_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR); |
What is the minimum age of tourists visiting New York from the UK in 2022? | CREATE TABLE tourism_data (id INT,name VARCHAR(50),country VARCHAR(50),age INT,destination VARCHAR(50),visit_year INT); INSERT INTO tourism_data (id,name,country,age,destination,visit_year) VALUES (1,'Alice Brown','UK',25,'New York',2022),(2,'Charlie Davis','UK',30,'New York',2022),(3,'Oliver Johnson','UK',NULL,'New York',2022); | SELECT MIN(age) FROM tourism_data WHERE country = 'UK' AND destination = 'New York' AND age IS NOT NULL AND visit_year = 2022; |
What is the maximum number of users for each media platform in the last week? | CREATE TABLE Users (user_id INT,platform VARCHAR(50),registration_date DATE,daily_usage INT); INSERT INTO Users (user_id,platform,registration_date,daily_usage) VALUES (1,'Platform1','2022-01-01',10),(2,'Platform2','2022-02-15',7),(3,'Platform1','2022-03-01',15); | SELECT platform, MAX(daily_usage) FROM Users WHERE registration_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY platform; |
What is the total revenue generated by each category? | CREATE TABLE menus (menu_id INT,menu_name TEXT,category TEXT,price DECIMAL(5,2)); INSERT INTO menus (menu_id,menu_name,category,price) VALUES (1,'Classic Burger','Beef',7.99),(2,'Veggie Burger','Vegetarian',6.99),(3,'Tofu Wrap','Vegan',5.99); | SELECT category, SUM(price) as total_revenue FROM menus GROUP BY category; |
What is the total reclamation cost and number of employees for mines in the South America region with more than 300 employees? | CREATE TABLE production_data (id INT PRIMARY KEY,mine_id INT,year INT,monthly_production INT);CREATE TABLE reclamation_data (id INT PRIMARY KEY,mine_id INT,year INT,reclamation_cost INT);CREATE TABLE mine_employees (id INT PRIMARY KEY,mine_id INT,employee_id INT,employment_start_date DATE,employment_end_date DATE);CREATE TABLE employee_demographics (id INT PRIMARY KEY,employee_id INT,gender VARCHAR(255),ethnicity VARCHAR(255));CREATE VIEW employee_stats AS SELECT mine_id,COUNT(employee_id) as employee_count FROM mine_employees GROUP BY mine_id;CREATE VIEW operation_duration AS SELECT mine_id,COUNT(DISTINCT year) as operation_years FROM production_data GROUP BY mine_id; | SELECT r.mine_id, SUM(r.reclamation_cost) as total_reclamation_cost, e.employee_count FROM reclamation_data r JOIN employee_stats e ON r.mine_id = e.mine_id WHERE r.mine_id IN (SELECT mine_id FROM employee_stats WHERE employee_count > 300) AND e.mine_id IN (SELECT mine_id FROM employee_stats WHERE employee_count > 300) AND r.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5) GROUP BY r.mine_id; |
What is the total number of mobile and broadband customers in the state of Florida? | CREATE TABLE customer_counts (id INT,location VARCHAR(50),service VARCHAR(50)); INSERT INTO customer_counts (id,location,service) VALUES (1,'Florida','mobile'),(2,'Texas','broadband'),(3,'Florida','mobile'),(4,'California','mobile'); | SELECT COUNT(*) FROM customer_counts WHERE location = 'Florida'; |
Show the top 3 cities with the highest total ticket sales. | CREATE TABLE concerts (id INT,country VARCHAR(255),city VARCHAR(255),artist_name VARCHAR(255),tier VARCHAR(255),price DECIMAL(10,2),num_tickets INT); CREATE VIEW city_sales AS SELECT city,SUM(price * num_tickets) AS total_sales FROM concerts GROUP BY city; | SELECT city, total_sales FROM city_sales ORDER BY total_sales DESC LIMIT 3; |
Insert a new record into the 'Donors' table | CREATE TABLE Donors (DonorID INT PRIMARY KEY,FirstName VARCHAR(50),LastName VARCHAR(50),Email VARCHAR(100)); | INSERT INTO Donors (DonorID, FirstName, LastName, Email) VALUES (101, 'Jamie', 'Bautista', '[email protected]'); |
What is the total amount donated to climate change mitigation in Brazil? | CREATE TABLE Donations (donation_id INT,donor_id INT,cause TEXT,amount DECIMAL); CREATE TABLE Donors (donor_id INT,donor_name TEXT,country TEXT); | SELECT SUM(amount) FROM Donations JOIN Donors ON Donations.donor_id = Donors.donor_id WHERE cause = 'climate change mitigation' AND country = 'Brazil'; |
What is the average performance score for each player by game category? | CREATE TABLE PlayerPerformance (PlayerID INT,GameID INT,GameCategory VARCHAR(50),PerformanceScore INT); | SELECT p.GameCategory, AVG(pp.PerformanceScore) as AvgScore FROM PlayerPerformance pp JOIN Games g ON pp.GameID = g.GameID GROUP BY p.GameCategory; |
Show the minimum and maximum playtime for multiplayer games, ordered by the number of players in descending order. | CREATE TABLE Players (PlayerID INT,Name VARCHAR(100),Country VARCHAR(50),TotalHoursPlayed INT,Platform VARCHAR(50)); INSERT INTO Players VALUES (1,'John Johnson','Brazil',70,'PC'); INSERT INTO Players VALUES (2,'Anna Lee','Russia',80,'Console'); CREATE TABLE GameDesign (GameID INT,GameName VARCHAR(100),Multiplayer BIT); INSERT INTO GameDesign VALUES (1,'GameX',1); INSERT INTO GameDesign VALUES (2,'GameY',0); | SELECT MIN(P.TotalHoursPlayed) as MinPlaytime, MAX(P.TotalHoursPlayed) as MaxPlaytime, COUNT(DISTINCT P.PlayerID) as Players FROM Players P JOIN GameDesign GD ON P.PlayerID = GD.GameID WHERE GD.Multiplayer = 1 GROUP BY GD.GameID ORDER BY Players DESC; |
What was the production of Lutetium in 2019 and 2021? | CREATE TABLE production_data (year INT,element VARCHAR(10),quantity INT); INSERT INTO production_data (year,element,quantity) VALUES (2018,'Lutetium',10),(2019,'Lutetium',12),(2020,'Lutetium',14),(2021,'Lutetium',16); | SELECT quantity FROM production_data WHERE element = 'Lutetium' AND year IN (2019, 2021); |
Delete properties from the 'properties' table that are not located in 'Vancouver' or 'Toronto'. | CREATE TABLE properties (id INT,city VARCHAR(50)); INSERT INTO properties (id,city) VALUES (1,'Vancouver'),(2,'Toronto'),(3,'Montreal'); | DELETE FROM properties WHERE city NOT IN ('Vancouver', 'Toronto'); |
Find properties with size greater than 1500 sq ft in urban_properties table. | CREATE TABLE urban_properties (id INT,size FLOAT,location VARCHAR(255)); INSERT INTO urban_properties (id,size,location) VALUES (1,1200.0,'San Francisco'),(2,1800.0,'New York'),(3,1300.0,'Los Angeles'); | SELECT * FROM urban_properties WHERE size > 1500; |
How many carbon offset programs were implemented in 'Country Z' each year? | CREATE TABLE carbon_offset_programs (program_id INT,country VARCHAR(255),start_year INT,end_year INT); INSERT INTO carbon_offset_programs (program_id,country,start_year,end_year) VALUES (1,'Country Z',2010,2015),(2,'Country Z',2015,2020),(3,'Country X',2018,2023); | SELECT start_year, COUNT(*) as num_programs FROM carbon_offset_programs WHERE country = 'Country Z' GROUP BY start_year; |
What is the maximum revenue for restaurants serving Japanese food? | CREATE TABLE Restaurants (id INT,name TEXT,type TEXT,revenue FLOAT); INSERT INTO Restaurants (id,name,type,revenue) VALUES (1,'Restaurant A','Italian',5000.00),(2,'Restaurant B','Japanese',7000.00),(3,'Restaurant C','Japanese',10000.00); | SELECT MAX(revenue) FROM Restaurants WHERE type = 'Japanese'; |
Delete countries with no satellites from the countries table | CREATE TABLE satellites (id INT,name VARCHAR(255),international_designator VARCHAR(20),country VARCHAR(50)); CREATE TABLE countries (id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO countries (id,name,region) VALUES (1,'USA','North America'),(2,'Russia','Europe'),(3,'China','Asia'),(4,'Antarctica','Antarctica'); INSERT INTO satellites (id,name,country,international_designator) VALUES (1,'Spitzer Space Telescope','USA','979F'),(2,'Lomonosov','Russia','C345D'),(3,'Tiangong-1','China','A666F'); | DELETE FROM countries WHERE id NOT IN (SELECT country FROM satellites); |
What is the average age of athletes in the MLB who have participated in the Home Run Derby? | CREATE TABLE IF NOT EXISTS athletes (id INT,name VARCHAR(50),age INT,sport VARCHAR(50),derby BOOLEAN); | SELECT AVG(age) FROM athletes WHERE sport = 'MLB' AND derby = true; |
What is the average CO2 emission of ride-hailing vehicles in San Francisco? | CREATE TABLE SFRideHailing (id INT,company VARCHAR(20),co2_emission DECIMAL(5,2)); | SELECT AVG(co2_emission) FROM SFRideHailing WHERE company = 'Uber'; |
Determine the percentage of autonomous vehicles in the 'inventory' table, partitioned by location. | CREATE TABLE inventory (vehicle_type VARCHAR(10),inventory_location VARCHAR(10),quantity_on_hand INT); | SELECT inventory_location, 100.0 * AVG(CASE WHEN vehicle_type LIKE '%Autonomous%' THEN 1.0 ELSE 0.0 END) AS autonomy_percentage FROM inventory GROUP BY inventory_location; |
Find the top 3 most visited exhibitions by visitors from the Asia-Pacific region. | CREATE TABLE Exhibition (id INT,name VARCHAR(100),Visitor_id INT); CREATE TABLE Visitor (id INT,name VARCHAR(100),country VARCHAR(50)); INSERT INTO Exhibition (id,name,Visitor_id) VALUES (1,'Ancient Civilizations',1),(2,'Modern Art',2),(3,'Nature Photography',3); INSERT INTO Visitor (id,name,country) VALUES (1,'James Bond','Singapore'),(2,'Maria Garcia','Australia'),(3,'Anna Kim','South Korea'); | SELECT Exhibition.name FROM Exhibition JOIN Visitor ON Exhibition.Visitor_id = Visitor.id WHERE Visitor.country IN ('Singapore', 'Australia', 'South Korea') GROUP BY Exhibition.name ORDER BY COUNT(DISTINCT Exhibition.Visitor_id) DESC LIMIT 3; |
List all wastewater treatment plants in California that were built before 1990. | CREATE TABLE wastewater_plants (id INT,name VARCHAR(50),state VARCHAR(20),build_year INT); INSERT INTO wastewater_plants (id,name,state,build_year) VALUES (1,'Plant A','California',1985),(2,'Plant B','California',1995),(3,'Plant C','Texas',1988); | SELECT name FROM wastewater_plants WHERE state = 'California' AND build_year < 1990; |
What is the total amount of water wasted per drought category in California for the year 2019? | CREATE TABLE drought_impact (category VARCHAR(20),region VARCHAR(20),wastewater_volume FLOAT,year INT); INSERT INTO drought_impact (category,region,wastewater_volume,year) VALUES ('severe','California',1500000,2019); INSERT INTO drought_impact (category,region,wastewater_volume,year) VALUES ('moderate','California',1000000,2019); | SELECT category, SUM(wastewater_volume) FROM drought_impact WHERE region = 'California' AND year = 2019 GROUP BY category; |
How many algorithmic fairness incidents were reported in North America in the last week? | CREATE TABLE fairness_incidents (incident_id INT,incident_date DATE,region TEXT); INSERT INTO fairness_incidents (incident_id,incident_date,region) VALUES (1,'2022-09-15','North America'),(2,'2022-09-11','North America'),(3,'2022-09-01','North America'); | SELECT COUNT(*) FROM fairness_incidents WHERE region = 'North America' AND incident_date >= '2022-09-08' AND incident_date < '2022-09-15'; |
What is the average satisfaction score for explainable AI models developed in the last 3 years? | CREATE TABLE explainable_ai (model_name TEXT,satisfaction_score INTEGER,date DATE); INSERT INTO explainable_ai (model_name,satisfaction_score,date) VALUES ('Model1',80,'2020-01-01'),('Model2',85,'2019-04-03'),('Model3',90,'2021-05-22'); | SELECT AVG(satisfaction_score) FROM explainable_ai WHERE date >= DATE('now', '-3 year'); |
Delete all flight safety records for a specific aircraft | CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.flight_safety (id INT,incident VARCHAR(255),incident_date DATE,aircraft_id INT);INSERT INTO aerospace.flight_safety (id,incident,incident_date,aircraft_id) VALUES (1,'Inc1','2017-01-01',1),(2,'Inc2','2018-01-01',1); | DELETE FROM aerospace.flight_safety WHERE aircraft_id = 1; |
How many 'endangered_species' are there in each 'habitat_type' in the 'habitat_preservation' table? | CREATE TABLE endangered_species_new(id INT,animal_name VARCHAR(50),conservation_status VARCHAR(50),habitat_type VARCHAR(50)); INSERT INTO endangered_species_new(id,animal_name,conservation_status,habitat_type) VALUES (1,'Amur Leopard','Critically Endangered','Rainforest'),(2,'Black Rhino','Critically Endangered','Savannah'),(3,'Bengal Tiger','Endangered','Rainforest'); CREATE TABLE habitat_preservation_new(id INT,habitat_name VARCHAR(50),habitat_area FLOAT,habitat_type VARCHAR(50)); INSERT INTO habitat_preservation_new(id,habitat_name,habitat_area,habitat_type) VALUES (1,'Rainforest',10000,'Rainforest'),(2,'Mangrove Forest',1200,'Coastal'),(3,'Coral Reef',300,'Marine'); | SELECT hp.habitat_type, COUNT(es.id) FROM endangered_species_new es JOIN habitat_preservation_new hp ON es.habitat_type = hp.habitat_type GROUP BY hp.habitat_type; |
What is the total number of animals in the rehabilitation center and habitat preservation program? | CREATE TABLE animals_total (animal_id INT,location VARCHAR(50)); INSERT INTO animals_total (animal_id,location) VALUES (1,'Rehabilitation Center'),(2,'Habitat Preservation'),(3,'Rehabilitation Center'),(4,'Habitat Preservation'); | SELECT COUNT(*) FROM animals_total WHERE location IN ('Rehabilitation Center', 'Habitat Preservation'); |
What is the total funding received by cultural programs for women and non-binary individuals? | CREATE TABLE Funding (program TEXT,amount INT); INSERT INTO Funding (program,amount) VALUES ('Women in Art',50000),('Non-Binary Dance Troupe',75000),('Female Composers Initiative',25000); | SELECT SUM(amount) FROM Funding WHERE program LIKE '%Women%' OR program LIKE '%Non-binary%'; |
What is the maximum production budget of Marvel movies? | CREATE TABLE Marvel_Movies (title TEXT,budget INTEGER); INSERT INTO Marvel_Movies (title,budget) VALUES ('Movie1',150000000),('Movie2',200000000),('Movie3',250000000),('Movie4',300000000),('Movie5',350000000),('Movie6',400000000); | SELECT MAX(budget) FROM Marvel_Movies; |
What is the total marketing budget for each music artist in the pop genre? | CREATE TABLE music_artists (id INT,artist VARCHAR(255),genre VARCHAR(255),marketing_budget INT); INSERT INTO music_artists (id,artist,genre,marketing_budget) VALUES (1,'Artist1','Pop',2000000),(2,'Artist2','Pop',3000000),(3,'Artist3','Rock',1500000); | SELECT genre, artist, SUM(marketing_budget) AS total_marketing_budget FROM music_artists WHERE genre = 'Pop' GROUP BY genre, artist; |
How many building permits were issued in California in the last year? | CREATE TABLE Building_Permits (id INT,permit_date DATE,state TEXT); | SELECT COUNT(*) FROM Building_Permits WHERE state = 'California' AND permit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
List all the strains and their average potency for growers located in Colorado with a social equity score above 80? | CREATE TABLE growers (grower_id INT,name VARCHAR(255),state VARCHAR(255),social_equity_score INT); INSERT INTO growers (grower_id,name,state,social_equity_score) VALUES (1,'Grower X','CO',85),(2,'Grower Y','CO',70),(3,'Grower Z','WA',82); CREATE TABLE strains (strain_id INT,name VARCHAR(255),potency DECIMAL(3,2),grower_id INT); INSERT INTO strains (strain_id,name,potency,grower_id) VALUES (1,'Strain A',22.5,1),(2,'Strain B',28.0,1),(3,'Strain C',19.0,2),(4,'Strain D',30.0,3); | SELECT s.name, AVG(s.potency) as avg_potency FROM strains s INNER JOIN growers g ON s.grower_id = g.grower_id WHERE g.state = 'CO' AND g.social_equity_score > 80 GROUP BY s.name; |
What is the total billing amount for cases in the year 2020? | CREATE TABLE cases (case_id INT,case_year INT,billing_amount INT); | SELECT SUM(billing_amount) FROM cases WHERE case_year = 2020; |
Find the number of chemicals with safety inspections in the last 3 months. | CREATE TABLE safety_inspections (id INT PRIMARY KEY,chemical_id INT,inspection_date DATE); INSERT INTO safety_inspections (id,chemical_id,inspection_date) VALUES (1,1,'2022-03-15'); | SELECT COUNT(DISTINCT chemical_id) FROM safety_inspections WHERE inspection_date >= DATEADD(month, -3, GETDATE()); |
How many climate mitigation initiatives were launched in Southeast Asia between 2015 and 2020 that involved women-led organizations? | CREATE TABLE climate_initiatives (initiative VARCHAR(50),region VARCHAR(50),start_year INT,end_year INT,gender_focus BOOLEAN); INSERT INTO climate_initiatives (initiative,region,start_year,end_year,gender_focus) VALUES ('Initiative A','Southeast Asia',2015,2020,TRUE); INSERT INTO climate_initiatives (initiative,region,start_year,end_year,gender_focus) VALUES ('Initiative B','Southeast Asia',2016,2021,FALSE); INSERT INTO climate_initiatives (initiative,region,start_year,end_year,gender_focus) VALUES ('Initiative C','Southeast Asia',2017,2022,TRUE); INSERT INTO climate_initiatives (initiative,region,start_year,end_year,gender_focus) VALUES ('Initiative D','Southeast Asia',2018,2023,FALSE); | SELECT COUNT(*) FROM climate_initiatives WHERE region = 'Southeast Asia' AND start_year BETWEEN 2015 AND 2020 AND gender_focus = TRUE; |
What is the minimum R&D expenditure for drugs approved in 2022? | CREATE TABLE drug_approval (drug_name TEXT,approval_year INTEGER); | SELECT MIN(expenditure) FROM rd_expenditure INNER JOIN drug_approval a ON rd_expenditure.drug_name = a.drug_name WHERE a.approval_year = 2022; |
What is the average number of tests performed per day in laboratories in the state of Texas? | CREATE TABLE laboratories (name TEXT,state TEXT,tests_performed INTEGER,tests_per_day INTEGER); INSERT INTO laboratories (name,state,tests_performed,tests_per_day) VALUES ('Quest Diagnostics','Texas',12000,400),('LabCorp','Texas',10000,333),('BioReference Laboratories','Texas',8000,267); | SELECT AVG(tests_per_day) FROM laboratories WHERE state = 'Texas'; |
Find the farm in the African region with the highest yield per acre for any crop, and display the farm name, crop, and yield per acre. | CREATE TABLE Farm (id INT,name TEXT,crop TEXT,yield_per_acre FLOAT,region TEXT); INSERT INTO Farm (id,name,crop,yield_per_acre,region) VALUES (1,'Mwangi Farm','Cassava',250,'African'),(2,'Sisi Farm','Sorghum',180,'African'),(3,'Kofi Farm','Maize',220,'African'); | SELECT name, crop, yield_per_acre FROM (SELECT name, crop, yield_per_acre, RANK() OVER (PARTITION BY region ORDER BY yield_per_acre DESC) as rn FROM Farm WHERE region = 'African') x WHERE rn = 1; |
What is the name of the farms with a size greater than 150 acres located in 'Texas'? | CREATE TABLE farms (id INT PRIMARY KEY,name VARCHAR(50),size INT,location VARCHAR(50)); INSERT INTO farms (id,name,size,location) VALUES (1,'Smith Farms',200,'Texas'),(2,'Johnson Farms',100,'California'); | SELECT name FROM farms WHERE size > 150 AND location = 'Texas' |
What is the total revenue generated from the sale of crops in 'Autumnfield'? | CREATE TABLE farmers (id INT,name VARCHAR(50),location VARCHAR(50),crops VARCHAR(50)); CREATE TABLE crops (id INT,name VARCHAR(50),yield INT); CREATE TABLE sales (id INT,farmer_id INT,crop_name VARCHAR(50),quantity INT,price DECIMAL(5,2)); CREATE VIEW sales_view AS SELECT farmer_id,crop_name,SUM(quantity * price) AS revenue FROM sales GROUP BY farmer_id,crop_name; INSERT INTO farmers VALUES (1,'Jane Doe','Autumnfield','Potatoes'); INSERT INTO crops VALUES (1,'Potatoes',100); INSERT INTO sales VALUES (1,1,'Potatoes',50,2.50); | SELECT SUM(revenue) FROM sales_view INNER JOIN farmers ON sales_view.farmer_id = farmers.id WHERE farmers.location = 'Autumnfield'; |
What is the total hectares of forests in each country? | CREATE TABLE Forests (id INT PRIMARY KEY,name VARCHAR(255),hectares DECIMAL(5,2),country VARCHAR(255)); INSERT INTO Forests (id,name,hectares,country) VALUES (1,'Greenwood',520.00,'Canada'); CREATE TABLE Countries (code CHAR(2),name VARCHAR(255),population INT); INSERT INTO Countries (code,name,population) VALUES ('CA','Canada',37410003); | SELECT Forests.country, SUM(Forests.hectares) as total_hectares FROM Forests GROUP BY Forests.country; |
For each ingredient, list the number of vegan cosmetic products that source it, ranked in descending order. | CREATE TABLE ingredients (ingredient_id INT,ingredient_name VARCHAR(50)); CREATE TABLE vegan_products (product_id INT,ingredient_id INT,is_vegan BOOLEAN); | SELECT i.ingredient_name, COUNT(vp.product_id) as vegan_product_count FROM ingredients i JOIN vegan_products vp ON i.ingredient_id = vp.ingredient_id WHERE vp.is_vegan = true GROUP BY i.ingredient_name ORDER BY vegan_product_count DESC; |
What is the total number of crime incidents reported in the state of Texas in 2020? | CREATE TABLE crime_data (id INT,state VARCHAR(50),year INT,incidents INT); INSERT INTO crime_data (id,state,year,incidents) VALUES (1,'Texas',2020,10000); INSERT INTO crime_data (id,state,year,incidents) VALUES (2,'Texas',2019,9000); | SELECT SUM(incidents) FROM crime_data WHERE state = 'Texas' AND year = 2020; |
Identify the artist with the most works in the 'Modern Art' gallery. | CREATE TABLE Art (artist TEXT,gallery TEXT,piece_name TEXT); INSERT INTO Art (artist,gallery,piece_name) VALUES ('Picasso','Modern Art','Guernica'); INSERT INTO Art (artist,gallery,piece_name) VALUES ('Van Gogh','Modern Art','Starry Night'); INSERT INTO Art (artist,gallery,piece_name) VALUES ('Matisse','Modern Art','The Dance'); INSERT INTO Art (artist,gallery,piece_name) VALUES ('Dali','Surrealism','Persistence of Memory'); | SELECT artist, COUNT(piece_name) AS piece_count FROM Art WHERE gallery = 'Modern Art' GROUP BY artist ORDER BY piece_count DESC LIMIT 1; |
List all artists who have exhibited at the Louvre Museum in Paris. | CREATE TABLE artists (name VARCHAR(255),exhibitions VARCHAR(255)); INSERT INTO artists (name,exhibitions) VALUES ('Vincent van Gogh','Louvre Museum,Paris'),('Pablo Picasso','Louvre Museum,Paris'),('Claude Monet','Louvre Museum,Paris'); | SELECT name FROM artists WHERE exhibitions LIKE '%Louvre Museum, Paris%'; |
What is the maximum cost of a defense contract in Japan? | CREATE TABLE defense_contracts (id INT,country VARCHAR(50),cost FLOAT); INSERT INTO defense_contracts (id,country,cost) VALUES (1,'Japan',1750000),(2,'Japan',700000),(3,'Japan',1100000); | SELECT MAX(cost) FROM defense_contracts WHERE country = 'Japan'; |
Delete records of military equipment older than 10 years from the 'equipment' table | CREATE TABLE equipment (id INT PRIMARY KEY,name VARCHAR(100),type VARCHAR(50),acquisition_date DATE); | DELETE FROM equipment WHERE acquisition_date < DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR); |
What military innovations were introduced by the US Navy between 2015 and 2020? | CREATE TABLE military_innovations (id INT,innovation_name VARCHAR(255),innovation_type VARCHAR(255),introducing_military VARCHAR(255),introduction_date DATE); INSERT INTO military_innovations (id,innovation_name,innovation_type,introducing_military,introduction_date) VALUES (1,'Electromagnetic Railgun','Weapon','US Navy','2016-01-01'); | SELECT innovation_name FROM military_innovations WHERE introducing_military = 'US Navy' AND introduction_date BETWEEN '2015-01-01' AND '2020-12-31'; |
What is the total production output for factories in the 'renewable energy' sector, grouped by country? | CREATE TABLE factory (id INT,name TEXT,sector TEXT,country TEXT); INSERT INTO factory (id,name,sector,country) VALUES (1,'FactoryA','automotive','France'),(2,'FactoryB','renewable energy','Spain'),(3,'FactoryC','electronics','Germany'),(4,'FactoryD','renewable energy','France'),(5,'FactoryE','renewable energy','Germany'); CREATE TABLE production (factory_id INT,output REAL); INSERT INTO production (factory_id,output) VALUES (1,1000),(1,1200),(2,1500),(3,1800),(4,2000),(4,2500),(5,3000); | SELECT factory.country, SUM(production.output) FROM production INNER JOIN factory ON production.factory_id = factory.id WHERE factory.sector = 'renewable energy' GROUP BY factory.country; |
What is the average investment amount for strategies in the 'Affordable Housing' sector? | CREATE TABLE investment_amounts (strategy VARCHAR(50),investment_amount FLOAT); INSERT INTO investment_amounts (strategy,investment_amount) VALUES ('Microfinance',50000),('Sustainable Agriculture',75000),('Green Energy',100000),('Affordable Housing',80000); | SELECT AVG(investment_amount) FROM investment_amounts WHERE strategy IN (SELECT strategy FROM strategies WHERE investments.sector = 'Affordable Housing'); |
Who are the top 3 artists with the highest revenue from digital music sales? | CREATE TABLE MusicSales (SaleID INT,ArtistName VARCHAR(20),Genre VARCHAR(10),SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID,ArtistName,Genre,SalesAmount) VALUES (1,'Ella Fitzgerald','Jazz',12.99),(2,'The Beatles','Rock',15.00),(3,'Ariana Grande','Pop',19.45),(4,'Billie Eilish','Pop',11.99); | SELECT ArtistName, SUM(SalesAmount) as TotalRevenue FROM MusicSales GROUP BY ArtistName ORDER BY TotalRevenue DESC LIMIT 3; |
Delete the 'Racial Bias in Education' open pedagogy resource. | CREATE TABLE open_pedagogy_resources (resource_name VARCHAR(50),topic VARCHAR(50)); | DELETE FROM open_pedagogy_resources WHERE resource_name = 'Racial Bias in Education'; |
What is the production count for well 'E05' in 'Amazon Rainforest'? | CREATE TABLE wells (well_id VARCHAR(10),well_location VARCHAR(20)); INSERT INTO wells (well_id,well_location) VALUES ('E05','Amazon Rainforest'); CREATE TABLE production (well_id VARCHAR(10),production_count INT); INSERT INTO production (well_id,production_count) VALUES ('E05',9000); | SELECT production_count FROM production WHERE well_id = 'E05'; |
How many supplies were sent to each country in 2020? | CREATE TABLE countries (id INT,name VARCHAR(255)); CREATE TABLE supplies (id INT,country_id INT,sent_date DATE,quantity INT); | SELECT countries.name, COUNT(supplies.id) FROM supplies JOIN countries ON supplies.country_id = countries.id WHERE supplies.sent_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY supplies.country_id; |
What is the total number of relief_operations in 'relief_ops' table for 'Asia' in Q1 2022? | CREATE TABLE relief_ops (operation_id INT,operation_type VARCHAR(50),operation_date DATE,region VARCHAR(50)); INSERT INTO relief_ops (operation_id,operation_type,operation_date,region) VALUES (1,'food distribution','2022-01-01','Asia'),(2,'medical aid','2022-01-02','Asia'); | SELECT COUNT(operation_id) FROM relief_ops WHERE EXTRACT(QUARTER FROM operation_date) = 1 AND region = 'Asia'; |
What's the average budget for accessible technology projects in Africa? | CREATE TABLE Accessible_Tech_Projects (ID INT,Project_Name VARCHAR(100),Location VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO Accessible_Tech_Projects (ID,Project_Name,Location,Budget) VALUES (1,'Tech4All','Africa',150000.00),(2,'AI4Good','Asia',200000.00),(3,'EqualWeb','Europe',120000.00); | SELECT AVG(Budget) FROM Accessible_Tech_Projects WHERE Location = 'Africa'; |
Which bus had the highest fare collection on April 1st, 2021? | CREATE SCHEMA trans schemas.trans; CREATE TABLE bus_routes (route_id INT,fare FLOAT,bus_number INT,date DATE); INSERT INTO bus_routes (route_id,fare,bus_number,date) VALUES (201,1.75,1201,'2021-04-01'),(201,1.75,1201,'2021-04-01'),(202,2.25,1202,'2021-04-01'),(203,1.50,1203,'2021-04-01'); | SELECT bus_number, MAX(fare) FROM bus_routes WHERE date = '2021-04-01' GROUP BY bus_number; |
Identify the total quantity of 'hemp' material sold by all suppliers, excluding 'GreenFabrics'. | CREATE TABLE HempSales (SaleID INT,SupplierName TEXT,Material TEXT,Quantity INT); INSERT INTO HempSales (SaleID,SupplierName,Material,Quantity) VALUES (1,'StandardTextiles','Hemp',25),(2,'GreenFabrics','Hemp',35),(3,'EcoWeave','Hemp',45); | SELECT SUM(Quantity) FROM HempSales WHERE SupplierName != 'GreenFabrics' AND Material = 'Hemp'; |
Update the customer_sizes table to change the size to 'Medium' for the customer_id 1001 | CREATE TABLE customer_sizes (customer_id INT PRIMARY KEY,size VARCHAR(255)); INSERT INTO customer_sizes (customer_id,size) VALUES (1001,'Large'),(1002,'Small'),(1003,'Medium'); | UPDATE customer_sizes SET size = 'Medium' WHERE customer_id = 1001; |
Identify the client with the highest balance in the Shariah-compliant finance database, and show their balance and name. | CREATE TABLE shariah_compliant_finance (client_id INT,name TEXT,balance DECIMAL(10,2)); INSERT INTO shariah_compliant_finance (client_id,name,balance) VALUES (3,'Ali',25000.50),(4,'Fatima',30000.75); | SELECT client_id, name, balance FROM shariah_compliant_finance ORDER BY balance DESC LIMIT 1; |
What is the total amount spent on each program type in the year 2019, sorted by the total amount spent in descending order? | CREATE TABLE Programs (ProgramType TEXT,Budget DECIMAL(10,2)); CREATE TABLE Spending (SpendingID INT,ProgramType TEXT,SpendingDate DATE,Amount DECIMAL(10,2)); | SELECT P.ProgramType, SUM(S.Amount) as TotalSpending FROM Spending S JOIN Programs P ON S.ProgramType = P.ProgramType WHERE YEAR(SpendingDate) = 2019 GROUP BY P.ProgramType ORDER BY TotalSpending DESC; |
What is the total number of hours volunteered per week, and how many volunteers volunteered during each week? | CREATE TABLE volunteer_hours (id INT,volunteer_id INT,hours DECIMAL,week INT); INSERT INTO volunteer_hours (id,volunteer_id,hours,week) VALUES (1,1,5.0,1),(2,2,10.0,1),(3,3,7.5,1),(4,1,4.0,2),(5,3,8.0,2); | SELECT SUM(hours), COUNT(DISTINCT volunteer_id) FROM volunteer_hours GROUP BY week; |
How much of each food category is supplied daily? | CREATE TABLE DailySupply (SupplyDate DATE,Category TEXT,Quantity INT); | SELECT Category, AVG(Quantity) AS DailyQuantity FROM DailySupply GROUP BY Category; |
What is the average daily calorie intake per person for each country in the 'Europe' region? | CREATE TABLE Countries (CountryID INT,CountryName VARCHAR(50),Region VARCHAR(50),Population INT); INSERT INTO Countries (CountryID,CountryName,Region,Population) VALUES (1,'France','Europe',67062000),(2,'Germany','Europe',83166711),(3,'Spain','Europe',47351567); CREATE TABLE Meals (MealID INT,CountryID INT,MealDate DATE,Calories INT); INSERT INTO Meals (MealID,CountryID,MealDate,Calories) VALUES (1,1,'2022-01-01',3500),(2,1,'2022-01-02',3000),(3,2,'2022-01-01',4000),(4,2,'2022-01-02',3500),(5,3,'2022-01-01',2500),(6,3,'2022-01-02',3000); | SELECT C.CountryName, AVG(M.Calories/C.Population) AS AvgDailyCalories FROM Meals M INNER JOIN Countries C ON M.CountryID = C.CountryID WHERE C.Region = 'Europe' GROUP BY C.CountryName; |
What is the average serving size of dishes that meet the daily recommended intake of protein? | CREATE TABLE dishes (dish_id INT,name VARCHAR(50),protein INT,serving_size INT); INSERT INTO dishes (dish_id,name,protein,serving_size) VALUES (1,'Chicken and Quinoa Bowl',30,400),(2,'Tuna Salad',40,300),(3,'Black Bean Burger',25,250); | SELECT AVG(serving_size) FROM dishes WHERE protein >= (SELECT serving_size * 0.3) GROUP BY protein HAVING COUNT(*) > 0; |
List all warehouse management transactions for 'Warehouse3' with their corresponding statuses and dates. | CREATE TABLE Warehouses (WarehouseID INT,WarehouseName VARCHAR(20)); INSERT INTO Warehouses (WarehouseID,WarehouseName) VALUES (1,'Warehouse1'),(2,'Warehouse2'),(3,'Warehouse3'); CREATE TABLE WarehouseManagementTransactions (TransactionID INT,WarehouseID INT,TransactionStatus VARCHAR(20),TransactionDate DATE); INSERT INTO WarehouseManagementTransactions (TransactionID,WarehouseID,TransactionStatus,TransactionDate) VALUES (1,3,'Received','2022-01-01'),(2,3,'Stored','2022-01-02'); | SELECT WarehouseManagementTransactions.TransactionID, WarehouseManagementTransactions.TransactionStatus, WarehouseManagementTransactions.TransactionDate FROM Warehouses JOIN WarehouseManagementTransactions ON Warehouses.WarehouseID = WarehouseManagementTransactions.WarehouseID WHERE Warehouses.WarehouseName = 'Warehouse3'; |
What is the maximum funding for a biosensor technology startup in Canada? | CREATE SCHEMA biosensors; CREATE TABLE biosensors.startups (id INT,name VARCHAR(100),country VARCHAR(50),funding FLOAT); INSERT INTO biosensors.startups (id,name,country,funding) VALUES (1,'StartupC','Canada',8000000.00); INSERT INTO biosensors.startups (id,name,country,funding) VALUES (2,'StartupD','Canada',12000000.00); | SELECT MAX(funding) FROM biosensors.startups WHERE country = 'Canada'; |
Which departments have no reported cases of fraud, displayed in alphabetical order? | CREATE TABLE government_departments (dept_name TEXT,fraud_cases INT); INSERT INTO government_departments (dept_name,fraud_cases) VALUES ('Department A',0),('Department B',3),('Department C',0),('Department D',2),('Department E',1); | SELECT dept_name FROM government_departments WHERE fraud_cases = 0 ORDER BY dept_name ASC; |
How many articles were published by each author in the last year? | CREATE TABLE if NOT EXISTS authors (author_id INT,author_name VARCHAR(50)); CREATE TABLE if NOT EXISTS articles (article_id INT,author_id INT,publication_date DATE); INSERT INTO authors (author_id,author_name) VALUES (1,'John Doe'),(2,'Jane Doe'); INSERT INTO articles (article_id,author_id,publication_date) VALUES (1,1,'2021-01-01'),(2,2,'2020-12-31'); | SELECT authors.author_name, COUNT(articles.article_id) as num_articles FROM authors INNER JOIN articles ON authors.author_id = articles.author_id WHERE articles.publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY authors.author_name; |
List the top 3 graduate programs with the highest enrollment of underrepresented students, along with the number of underrepresented students enrolled in each program. | CREATE TABLE Graduate_Programs (program VARCHAR(50),enrollment INT,underrepresented_student BOOLEAN); INSERT INTO Graduate_Programs (program,enrollment,underrepresented_student) VALUES ('Computer Science',150,true),('Mathematics',120,true),('Physics',180,false),('Chemistry',100,true),('Biology',200,true); | SELECT program, SUM(underrepresented_student) as underrepresented_enrollment FROM Graduate_Programs WHERE underrepresented_student = true GROUP BY program ORDER BY underrepresented_enrollment DESC LIMIT 3; |
What is the maximum capacity of smart city technology adoptions in the city of Beijing? | CREATE TABLE smart_city_tech_adoptions (id INT,name TEXT,city TEXT,capacity INT); INSERT INTO smart_city_tech_adoptions (id,name,city,capacity) VALUES (1,'Tech Adoption 1','Beijing',10000); INSERT INTO smart_city_tech_adoptions (id,name,city,capacity) VALUES (2,'Tech Adoption 2','Beijing',15000); INSERT INTO smart_city_tech_adoptions (id,name,city,capacity) VALUES (3,'Tech Adoption 3','New York',20000); | SELECT MAX(capacity) FROM smart_city_tech_adoptions WHERE city = 'Beijing'; |
What is the minimum installation cost (in USD) of electric vehicle charging stations in urban areas, grouped by station type and year, where the minimum cost is greater than 5,000 USD? | CREATE TABLE ev_charging_stations_urban (station_id INT,station_type VARCHAR(50),year INT,installation_cost INT); | SELECT station_type, year, MIN(installation_cost) FROM ev_charging_stations_urban GROUP BY station_type, year HAVING MIN(installation_cost) > 5000; |
What is the total cost of renewable energy projects in the European region? | CREATE TABLE renewable_energy_projects (project_id INT,project_name VARCHAR(50),region VARCHAR(20),cost DECIMAL(10,2)); INSERT INTO renewable_energy_projects (project_id,project_name,region,cost) VALUES (1,'Wind Farm','Europe',15000000.00),(2,'Solar Park','Asia',20000000.00),(3,'Geothermal Plant','Africa',12000000.00); | SELECT SUM(cost) FROM renewable_energy_projects WHERE region = 'Europe'; |
What is the total number of community health workers serving Indigenous communities in Canada? | CREATE TABLE community_health_workers (id INT,name TEXT,community TEXT); INSERT INTO community_health_workers (id,name,community) VALUES (1,'John Doe','First Nations'); INSERT INTO community_health_workers (id,name,community) VALUES (2,'Jane Smith','Inuit'); INSERT INTO community_health_workers (id,name,community) VALUES (3,'Maria Garcia','Métis'); INSERT INTO community_health_workers (id,name,community) VALUES (4,'David Kim','First Nations'); | SELECT COUNT(*) FROM community_health_workers WHERE community IN ('First Nations', 'Inuit', 'Métis'); |
What is the average rating of eco-friendly hotels in Spain? | CREATE TABLE eco_hotels (hotel_id INT,hotel_name TEXT,country TEXT,rating FLOAT); INSERT INTO eco_hotels (hotel_id,hotel_name,country,rating) VALUES (1,'Eco Hotel Madrid','Spain',4.3),(2,'Green Vila','Spain',4.6); | SELECT AVG(rating) FROM eco_hotels WHERE country = 'Spain'; |
What is the total revenue generated by sustainable accommodations in each region? | CREATE TABLE accommodation (id INT,name TEXT,region TEXT,sustainable INT,price INT); INSERT INTO accommodation (id,name,region,sustainable,price) VALUES (1,'Eco Retreat','North America',1,100); INSERT INTO accommodation (id,name,region,sustainable,price) VALUES (2,'Sustainable Resort','South America',1,150); | SELECT region, SUM(price) as total_revenue FROM accommodation WHERE sustainable = 1 GROUP BY region; |
What is the total revenue generated from cultural heritage sites in Tokyo? | CREATE TABLE cultural_sites (id INT,name TEXT,city TEXT,revenue FLOAT); INSERT INTO cultural_sites (id,name,city,revenue) VALUES (1,'Temple of Gold','Tokyo',1000000.00),(2,'Shrine of Silver','Tokyo',1200000.00),(3,'Museum of History','Tokyo',800000.00); | SELECT SUM(revenue) FROM cultural_sites WHERE city = 'Tokyo'; |
What is the average rating of hotels in the United States that offer AI-powered services? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,ai_services BOOLEAN,rating FLOAT); INSERT INTO hotels (hotel_id,hotel_name,country,ai_services,rating) VALUES (1,'The Smart Hotel','USA',true,4.5),(2,'The Classic Inn','USA',false,4.2),(3,'Innovative Resort','USA',true,4.8); | SELECT AVG(rating) FROM hotels WHERE ai_services = true AND country = 'USA'; |
Identify the artworks with the earliest creation year for each art movement. | CREATE TABLE Movements (MovementID INT,Name VARCHAR(50),OriginYear INT); INSERT INTO Movements (MovementID,Name,OriginYear) VALUES (1,'Impressionism',1874); INSERT INTO Movements (MovementID,Name,OriginYear) VALUES (2,'Cubism',1907); | SELECT A.Title, M.Name FROM Artworks A JOIN Movements M ON A.ArtMovement = M.Name WHERE A.Year = (SELECT MIN(Year) FROM Artworks WHERE ArtMovement = M.Name) GROUP BY M.Name; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.