instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What was the total cost of sustainable building projects in Texas in 2019? | CREATE TABLE Sustainable_Projects (id INT,project_cost FLOAT,year INT,state VARCHAR(20)); INSERT INTO Sustainable_Projects (id,project_cost,year,state) VALUES (1,7000000,2019,'Texas'); | SELECT SUM(project_cost) FROM Sustainable_Projects WHERE year = 2019 AND state = 'Texas'; |
Update the price of all skincare products with natural ingredients to be 5% lower? | CREATE TABLE products(product_id INT,category VARCHAR(255),has_natural_ingredients BOOLEAN,price DECIMAL(5,2));INSERT INTO products (product_id,category,has_natural_ingredients,price) VALUES (1,'Cleanser',true,19.99),(2,'Toner',false,12.99),(3,'Serum',true,35.99),(4,'Moisturizer',false,24.99); | UPDATE products SET price = price * 0.95 WHERE category = 'skincare' AND has_natural_ingredients = true; |
What is the total production of electric vehicles in South America? | CREATE TABLE factories (id INT,name VARCHAR(50),location VARCHAR(50),type VARCHAR(50),production_count INT); INSERT INTO factories (id,name,location,type,production_count) VALUES (1,'Factory A','South America','Electric Vehicle',1500),(2,'Factory B','Europe','Combustion Engine',1200),(3,'Factory C','Asia','Electric Vehicle',1800); | SELECT SUM(production_count) FROM factories WHERE location = 'South America' AND type = 'Electric Vehicle'; |
What are the total recycled volumes for each recycling facility and each recycled rare earth element, ordered in descending order based on the total recycled volume? | CREATE TABLE recycling_facilities (id INT PRIMARY KEY,name TEXT,location TEXT,recycling_volume INT); CREATE TABLE recycled_elements (id INT PRIMARY KEY,recycling_facility_id INT,element TEXT,recycled_volume INT); | SELECT rf.name, r.element, SUM(r.recycled_volume) as total_recycled_volume FROM recycling_facilities rf JOIN recycled_elements r ON rf.id = r.recycling_facility_id GROUP BY rf.name, r.element ORDER BY total_recycled_volume DESC; |
What is the total mass (in kg) of spacecraft that have been to Saturn? | CREATE TABLE spacecrafts (spacecraft_id INT,name TEXT,mass_kg INT); INSERT INTO spacecrafts (spacecraft_id,name,mass_kg) VALUES (1,'Cassini',2125),(2,'Pioneer 11',258),(3,'Voyager 1',825),(4,'Voyager 2',825),(5,'Galileo',2223); CREATE TABLE spacecraft_missions (spacecraft_id INT,mission_id INT); INSERT INTO spacecraft_missions (spacecraft_id,mission_id) VALUES (1,1),(1,2),(1,3),(2,4),(3,5),(3,6),(4,7),(4,8),(5,9); CREATE TABLE space_missions (mission_id INT,name TEXT,destination TEXT); INSERT INTO space_missions (mission_id,name,destination) VALUES (1,'Saturn Orbiter','Saturn'),(2,'Saturn Probe 1','Saturn'),(3,'Saturn Probe 2','Saturn'),(4,'Ganymede Flyby','Jupiter'),(5,'Heliosphere Probe','Outer Solar System'),(6,'Neptune Flyby','Neptune'),(7,'Uranus Flyby','Uranus'),(8,'Neptune Orbiter','Neptune'),(9,'Jupiter Orbiter','Jupiter'); | SELECT SUM(mass_kg) FROM spacecrafts sc JOIN spacecraft_missions sm ON sc.spacecraft_id = sm.spacecraft_id JOIN space_missions s ON sm.mission_id = s.mission_id WHERE s.destination = 'Saturn'; |
What is the number of patients and their respective genders in remote areas of Arizona? | CREATE TABLE patients(id INT,name TEXT,location TEXT,gender TEXT); INSERT INTO patients(id,name,location,gender) VALUES (1,'Patient A','Arizona Remote','Female'),(2,'Patient B','Arizona Remote','Male'),(3,'Patient C','Arizona Urban','Female'),(4,'Patient D','Arizona Urban','Non-binary'); | SELECT COUNT(*) as patient_count, gender FROM patients WHERE location LIKE '%Arizona Remote%' GROUP BY gender; |
Find the total number of transactions per month for the last year. | CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_date DATE); INSERT INTO transactions (transaction_id,customer_id,transaction_date) VALUES (1,1,'2021-01-01'); INSERT INTO transactions (transaction_id,customer_id,transaction_date) VALUES (2,2,'2021-02-01'); | SELECT DATEPART(YEAR, transaction_date) as year, DATEPART(MONTH, transaction_date) as month, COUNT(*) as total_transactions FROM transactions WHERE transaction_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY DATEPART(YEAR, transaction_date), DATEPART(MONTH, transaction_date); |
Which ingredients are used in more than two vegan dishes? | CREATE TABLE ingredients (id INT,name VARCHAR(255)); INSERT INTO ingredients (id,name) VALUES (1,'Tomatoes'),(2,'Onions'),(3,'Garlic'),(4,'Cheese'),(5,'Tofu'); CREATE TABLE dishes (id INT,name VARCHAR(255),is_vegan BOOLEAN); INSERT INTO dishes (id,name,is_vegan) VALUES (1,'Pizza Margherita',false),(2,'Vegan Tacos',true),(3,'Chana Masala',true); CREATE TABLE dish_ingredients (dish_id INT,ingredient_id INT); INSERT INTO dish_ingredients (dish_id,ingredient_id) VALUES (1,1),(1,2),(1,3),(2,2),(2,3),(2,5),(3,2),(3,3),(3,5); | SELECT ingredient.name FROM ingredients INNER JOIN dish_ingredients ON ingredients.id = dish_ingredients.ingredient_id INNER JOIN dishes ON dish_ingredients.dish_id = dishes.id WHERE dishes.is_vegan = true GROUP BY ingredient.id HAVING COUNT(dish_ingredients.dish_id) > 2; |
What is the average number of art programs organized per year by cultural organizations in Canada, partitioned by province? | CREATE TABLE canada_cultural_orgs (id INT,org_name TEXT,year INT,province TEXT,num_art_progs INT); INSERT INTO canada_cultural_orgs (id,org_name,year,province,num_art_progs) VALUES (1,'Toronto Art Gallery',2015,'Ontario',12),(2,'Montreal Museum',2016,'Quebec',15),(3,'Vancouver Art Museum',2017,'British Columbia',18); | SELECT province, AVG(num_art_progs) as avg_art_progs_per_year FROM (SELECT province, YEAR(date) as year, num_art_progs FROM canada_cultural_orgs WHERE date BETWEEN '2015-01-01' AND '2022-12-31' GROUP BY province, year, num_art_progs) subquery GROUP BY province; |
How many museums are there in total in France and Germany? | CREATE TABLE Museums (name VARCHAR(255),country VARCHAR(255),num_museums INT); | SELECT SUM(num_museums) FROM Museums WHERE country IN ('France', 'Germany'); |
List all the fish species with their minimum and maximum stocking densities. | CREATE TABLE fish_species (id INT,species VARCHAR(255),stocking_density FLOAT); INSERT INTO fish_species (id,species,stocking_density) VALUES (1,'Salmon',12.5),(2,'Tilapia',8.0),(3,'Carp',18.0),(4,'Trout',15.0); | SELECT species, MIN(stocking_density) AS min_density, MAX(stocking_density) AS max_density FROM fish_species GROUP BY species; |
What is the average energy efficiency (kWh/m2/day) of solar power projects in the 'USA' and 'Canada'? | CREATE TABLE solar_projects (project_id INT,project_name TEXT,country TEXT,efficiency_kwh FLOAT); INSERT INTO solar_projects (project_id,project_name,country,efficiency_kwh) VALUES (1,'Solar Farm 1','USA',0.18),(2,'Solar Farm 2','Canada',0.20),(3,'Solar Farm 3','Mexico',0.19); | SELECT AVG(efficiency_kwh) FROM solar_projects WHERE country IN ('USA', 'Canada'); |
Delete museums with attendance under 5000 in the 'Museums' table | CREATE TABLE Museums (Name VARCHAR(50),Attendance INT,Year INT); INSERT INTO Museums (Name,Attendance,Year) | DELETE FROM Museums WHERE Attendance < 5000 |
What is the average CO2 reduction achieved by clean energy policies in Spain? | CREATE TABLE co2_reduction (id INT,country VARCHAR(50),policy_id INT,reduction FLOAT); | SELECT AVG(reduction) FROM co2_reduction WHERE country = 'Spain'; |
What was the total cost of all economic diversification efforts in the Amazon rainforest in 2021? | CREATE TABLE economic_diversification (id INT,location VARCHAR(50),cost FLOAT,initiative_type VARCHAR(50),start_date DATE); INSERT INTO economic_diversification (id,location,cost,initiative_type,start_date) VALUES (1,'Amazon Rainforest',100000.00,'Eco-tourism','2021-01-01'); | SELECT SUM(cost) FROM economic_diversification WHERE location = 'Amazon Rainforest' AND start_date >= '2021-01-01' AND start_date < '2022-01-01' AND initiative_type = 'Eco-tourism'; |
Insert a new music album with a rating of 9.2 for artist 'Kendrick Lamar' from the United States | CREATE TABLE music_albums (id INT,title VARCHAR(100),rating DECIMAL(3,2),artist VARCHAR(100),production_country VARCHAR(50)); | INSERT INTO music_albums (id, title, rating, artist, production_country) VALUES (1, 'NewAlbum', 9.2, 'Kendrick Lamar', 'United States'); |
What is the total quantity of recycled paper used in manufacturing in Q2 2021? | CREATE TABLE manufacturing_materials (id INT,material VARCHAR(50),quantity_used INT,use_date DATE); INSERT INTO manufacturing_materials (id,material,quantity_used,use_date) VALUES (1,'Recycled Paper',3000,'2021-04-15'),(2,'Organic Cotton',2500,'2021-03-27'),(3,'Bamboo',4000,'2021-05-08'); | SELECT SUM(quantity_used) FROM manufacturing_materials WHERE material = 'Recycled Paper' AND QUARTER(use_date) = 2 AND YEAR(use_date) = 2021; |
Find the total production volume for each well, for the 'Oil' production type, ordered by the total production volume in descending order. | CREATE TABLE production (production_id INT,well_id INT,production_date DATE,production_type TEXT,production_volume INT); INSERT INTO production (production_id,well_id,production_date,production_type,production_volume) VALUES (1,1,'2018-01-01','Oil',100),(2,1,'2018-01-02','Gas',50),(3,2,'2019-05-03','Oil',150),(4,3,'2020-02-04','Oil',200),(5,3,'2020-02-05','Gas',75); | SELECT well_id, SUM(production_volume) as total_oil_production FROM production WHERE production_type = 'Oil' GROUP BY well_id ORDER BY total_oil_production DESC; |
What is the most expensive vegan entrée? | CREATE TABLE menus (menu_id INT,menu_name VARCHAR(50),category VARCHAR(50),price DECIMAL(5,2)); INSERT INTO menus (menu_id,menu_name,category,price) VALUES (1,'Quinoa Salad','Vegetarian',9.99),(2,'Margherita Pizza','Non-Vegetarian',12.99),(3,'Chickpea Curry','Vegan',10.99),(4,'Tofu Stir Fry','Vegan',11.99),(5,'Steak','Non-Vegetarian',25.99),(6,'Vegan Lasagna','Vegan',15.99); | SELECT menu_name, MAX(price) FROM menus WHERE category = 'Vegan' AND menu_name LIKE '%entrée%'; |
Display the makes and models of electric vehicles in the 'green_vehicles' table with a range greater than 250 miles | CREATE TABLE green_vehicles (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),year INT,type VARCHAR(50),range INT); | SELECT make, model FROM green_vehicles WHERE type = 'Electric' AND range > 250; |
Insert a new record into the 'animal_population' table for the 'elephants' in the 'Amboseli National Park' with a population of 120 | CREATE TABLE animal_population (id INT,animal_type VARCHAR(20),habitat_name VARCHAR(30),population INT); | INSERT INTO animal_population (id, animal_type, habitat_name, population) VALUES (1, 'elephants', 'Amboseli National Park', 120); |
What is the total cost of 'Mars Rover' missions? | CREATE TABLE ProjectCosts (project VARCHAR(50),cost FLOAT); INSERT INTO ProjectCosts (project,cost) VALUES ('Ares',2000),('Artemis',1500),('Mars Rover',2500),('Curiosity',1800); | SELECT SUM(cost) FROM ProjectCosts WHERE project LIKE '%Mars Rover%'; |
What was the average rental duration for adaptive bikes in February 2022? | CREATE TABLE bike_share (bike_id INT,bike_type VARCHAR(255),rental_start_time TIMESTAMP,rental_end_time TIMESTAMP); INSERT INTO bike_share (bike_id,bike_type,rental_start_time,rental_end_time) VALUES (6,'Adaptive','2022-02-01 10:00:00','2022-02-01 12:00:00'); | SELECT AVG(TIMESTAMPDIFF(SECOND, rental_start_time, rental_end_time)) AS avg_rental_duration FROM bike_share WHERE bike_type = 'Adaptive' AND rental_start_time >= '2022-02-01' AND rental_start_time < '2022-03-01'; |
Count the number of unique IP addresses in the 'traffic' table that belong to the 'darknet' network | CREATE TABLE traffic (ip_address VARCHAR(15),timestamp TIMESTAMP,network VARCHAR(255)); INSERT INTO traffic (ip_address,timestamp,network) VALUES ('192.168.1.1','2022-01-01 12:00:00','Internal'),('10.0.0.1','2022-01-01 13:00:00','Darknet'),('172.16.1.1','2022-01-01 14:00:00','Internal'); | SELECT COUNT(DISTINCT ip_address) as unique_darknet_ips FROM traffic WHERE network = 'Darknet'; |
What is the total quantity of sustainable materials used in production by month? | CREATE TABLE production (item_name VARCHAR(255),material VARCHAR(255),quantity INT,production_date DATE); INSERT INTO production (item_name,material,quantity,production_date) VALUES ('T-Shirt','Organic Cotton',10,'2022-01-01'),('Shirt','Organic Cotton',15,'2022-01-05'),('Pants','Organic Cotton',20,'2022-01-10'),('T-Shirt','Recycled Polyester',12,'2022-02-01'),('Shirt','Recycled Polyester',18,'2022-02-05'),('Pants','Hemp',25,'2022-03-01'); | SELECT material, SUM(quantity), DATE_FORMAT(production_date, '%Y-%m') as Month FROM production GROUP BY material, Month ORDER BY Month ASC; |
What is the total number of electric vehicle charging stations in 'Berlin' and 'Paris' combined? | CREATE TABLE charging_stations (id INT,city TEXT,count INT); INSERT INTO charging_stations (id,city,count) VALUES (1,'Berlin',50),(2,'Paris',75); | SELECT SUM(count) FROM charging_stations WHERE city IN ('Berlin', 'Paris'); |
What is the total revenue generated from mobile and broadband plans in Q2 2022? | CREATE TABLE mobile_plans (plan_name TEXT,monthly_cost FLOAT,data_allowance INT); CREATE TABLE broadband_plans (plan_name TEXT,monthly_cost FLOAT,speed INT); | SELECT SUM(monthly_cost) FROM (SELECT * FROM mobile_plans UNION ALL SELECT * FROM broadband_plans) WHERE start_date >= '2022-04-01' AND start_date < '2022-07-01'; |
What is the average number of streams for hip hop artists in the USA? | CREATE TABLE Streaming (id INT,artist VARCHAR(50),streams INT,country VARCHAR(50),genre VARCHAR(50)); INSERT INTO Streaming (id,artist,streams,country,genre) VALUES (1,'Sia',1000000,'Australia','Pop'),(2,'Taylor Swift',2000000,'USA','Pop'),(3,'Kendrick Lamar',1500000,'USA','Hip Hop'),(4,'Kylie Minogue',1800000,'Australia','Pop'); | SELECT AVG(streams) FROM Streaming WHERE country = 'USA' AND genre = 'Hip Hop'; |
How many circular economy initiatives were implemented in India between 2015 and 2020? | CREATE TABLE initiative_type (initiative_type_id INT,initiative_type VARCHAR(50)); INSERT INTO initiative_type (initiative_type_id,initiative_type) VALUES (1,'Waste to Energy'),(2,'Recycling'),(3,'Composting'),(4,'Reduce'),(5,'Reuse'); CREATE TABLE initiative (initiative_id INT,initiative_type_id INT,year INT,country VARCHAR(50)); INSERT INTO initiative (initiative_id,initiative_type_id,year,country) VALUES (1,1,2015,'India'),(2,2,2016,'India'),(3,3,2017,'India'),(4,4,2018,'India'),(5,5,2019,'India'),(6,1,2020,'India'); | SELECT COUNT(*) FROM initiative i JOIN initiative_type it ON i.initiative_type_id = it.initiative_type_id WHERE i.country = 'India' AND i.year BETWEEN 2015 AND 2020; |
Show the total number of wells for each location from the 'Wells' table | CREATE TABLE Wells (WellName VARCHAR(20),Location VARCHAR(30)); | SELECT Location, COUNT(*) FROM Wells GROUP BY Location; |
List all ingredients sourced from organic farms in the United States. | CREATE TABLE ingredients (ingredient_id INT,ingredient_name TEXT,is_organic BOOLEAN,country TEXT); INSERT INTO ingredients (ingredient_id,ingredient_name,is_organic,country) VALUES (1,'Rose Water',true,'USA'),(2,'Aloe Vera',false,'Mexico'),(3,'Shea Butter',true,'Ghana'); | SELECT ingredient_name FROM ingredients WHERE is_organic = true AND country = 'USA'; |
Update the 'finance_sources' table, changing 'type' to 'public' for any record where 'region' is 'Africa' | CREATE TABLE finance_sources (id INT,region VARCHAR(255),type VARCHAR(255)); | UPDATE finance_sources SET type = 'public' WHERE region = 'Africa'; |
Delete the entry with ethic_id 1 from the 'media_ethics' table | CREATE TABLE media_ethics (ethic_id INT PRIMARY KEY,ethic_name VARCHAR(255),description TEXT,source VARCHAR(255)); | DELETE FROM media_ethics WHERE ethic_id = 1; |
What is the distribution of astronauts' ages? | CREATE TABLE Astronauts (AstronautID INT,Age INT,Gender VARCHAR(10),Name VARCHAR(50),Nationality VARCHAR(50)); | SELECT Age, COUNT(*) FROM Astronauts GROUP BY Age; |
What is the total number of sustainable building projects in the 'sustainable_buildings' table with a timeline of more than 365 days? | CREATE TABLE sustainable_buildings (project_id INT,project_name TEXT,timeline_days INT); | SELECT COUNT(*) FROM sustainable_buildings WHERE timeline_days > 365; |
Identify the number of unique passengers who have traveled on each route during the month of March 2023 | CREATE TABLE passengers (passenger_id INT,passenger_name VARCHAR(20)); CREATE TABLE passenger_trips (trip_id INT,passenger_id INT,route_id INT,trip_date DATE); | SELECT routes.route_name, COUNT(DISTINCT passengers.passenger_id) FROM passengers JOIN passenger_trips ON passengers.passenger_id = passenger_trips.passenger_id JOIN routes ON passenger_trips.route_id = routes.route_id WHERE passenger_trips.trip_date BETWEEN '2023-03-01' AND '2023-03-31' GROUP BY routes.route_id, routes.route_name; |
How many farmers in the 'Southern Africa' region are involved in the production of 'Quinoa' and 'Amaranth'? | CREATE TABLE Farmers (farmer_id INT,region VARCHAR(20),crop VARCHAR(30)); INSERT INTO Farmers (farmer_id,region,crop) VALUES (1,'Southern Africa','Quinoa'),(2,'Southern Africa','Amaranth'); | SELECT COUNT(DISTINCT farmer_id) as num_farmers FROM Farmers f WHERE f.region = 'Southern Africa' AND f.crop IN ('Quinoa', 'Amaranth'); |
Update the revenue data for a specific restaurant | CREATE TABLE revenue (restaurant_id INT,revenue_date DATE,total_revenue DECIMAL(10,2)); | UPDATE revenue SET total_revenue = 5000.00 WHERE restaurant_id = 789 AND revenue_date = '2022-02-15'; |
What is the maximum price of upcycled products? | CREATE TABLE products (product_id INT,product_name TEXT,price DECIMAL,upcycled BOOLEAN); INSERT INTO products (product_id,product_name,price,upcycled) VALUES (1,'ProductX',15.99,true),(2,'ProductY',12.49,false),(3,'ProductZ',25.99,true); | SELECT MAX(price) FROM products WHERE upcycled = true; |
Update the interest rate for a Shariah-compliant mortgage to 4.5%. | CREATE TABLE mortgages (id INT,mortgage_type VARCHAR(255),interest_rate DECIMAL(10,2)); INSERT INTO mortgages (id,mortgage_type,interest_rate) VALUES (1,'Shariah-compliant',4.25),(2,'Conventional',5.00); | UPDATE mortgages SET interest_rate = 4.5 WHERE mortgage_type = 'Shariah-compliant'; |
What is the average sustainable urbanism score and total property price for properties in the "SustainableCity" schema, grouped by property type? | CREATE TABLE Property (id INT,property_type VARCHAR(20),price FLOAT,sustainable_score INT,city VARCHAR(20)); INSERT INTO Property (id,property_type,price,sustainable_score,city) VALUES (1,'Apartment',500000,85,'SustainableCity'),(2,'House',700000,70,'SustainableCity'),(3,'Condo',300000,90,'SustainableCity'); | SELECT Property.property_type, AVG(Property.sustainable_score) AS avg_sustainable_score, SUM(Property.price) AS total_price FROM Property WHERE Property.city = 'SustainableCity' GROUP BY Property.property_type; |
Which vessels in the 'vessel_performance' table have an average speed greater than 15 knots? | CREATE TABLE vessel_performance (id INT,vessel_name VARCHAR(50),average_speed DECIMAL(5,2)); | SELECT vessel_name FROM vessel_performance WHERE average_speed > 15; |
What is the total number of male and female members? | CREATE TABLE membership (id INT,member_id INT,gender VARCHAR(10)); INSERT INTO membership (id,member_id,gender) VALUES (1,401,'male'),(2,402,'female'),(3,403,'male'),(4,404,'non-binary'); | SELECT SUM(gender = 'male') AS male_count, SUM(gender = 'female') AS female_count FROM membership; |
What is the average threat intelligence report value in the last quarter for the 'Cyber' sector? | CREATE TABLE Threat_Intel (id INT,report_number VARCHAR(50),report_date DATE,report_value FLOAT,sector VARCHAR(50)); | SELECT AVG(report_value) FROM Threat_Intel WHERE report_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND sector = 'Cyber'; |
Update the funding amount for 'Startup C' to 28000000. | CREATE TABLE biotech_startups (id INT,name VARCHAR(100),location VARCHAR(100),funding FLOAT); INSERT INTO biotech_startups (id,name,location,funding) VALUES (1,'Startup A','India',12000000); INSERT INTO biotech_startups (id,name,location,funding) VALUES (2,'Startup B','India',18000000); INSERT INTO biotech_startups (id,name,location,funding) VALUES (3,'Startup C','India',20000000); | UPDATE biotech_startups SET funding = 28000000 WHERE name = 'Startup C'; |
List all creative AI applications with a safety rating below 60 in the 'ai_applications' table. | CREATE TABLE ai_applications (app_id INT,app_name TEXT,safety_rating FLOAT); | SELECT app_id, app_name FROM ai_applications WHERE safety_rating < 60; |
Who worked on the 'Solar Farm' project and how many hours did they spend? | CREATE TABLE Green_Buildings (Project_ID INT,Project_Name VARCHAR(255),State VARCHAR(255),Labor_Cost DECIMAL(10,2)); CREATE TABLE Workers (Worker_ID INT,Worker_Name VARCHAR(255),Project_ID INT,Hours_Worked DECIMAL(10,2)); INSERT INTO Green_Buildings (Project_ID,Project_Name,State,Labor_Cost) VALUES (1,'Solar Farm','California',150000.00); INSERT INTO Workers (Worker_ID,Worker_Name,Project_ID,Hours_Worked) VALUES (1,'John Doe',1,100.00),(2,'Jane Smith',1,120.00); | SELECT Worker_Name, Hours_Worked FROM Green_Buildings gb JOIN Workers w ON gb.Project_ID = w.Project_ID WHERE gb.Project_Name = 'Solar Farm'; |
What is the average carbon offset (in metric tons) per Green building in the United Kingdom? | CREATE TABLE carbon_offsets_2 (project_id INT,project_name TEXT,country TEXT,offset_metric_tons FLOAT); INSERT INTO carbon_offsets_2 (project_id,project_name,country,offset_metric_tons) VALUES (1,'Green Building A','UK',150),(2,'Green Building B','UK',200); | SELECT country, AVG(offset_metric_tons) FROM carbon_offsets_2 WHERE country = 'UK'; |
How many smart contracts are there in the 'Avalanche' network? | CREATE TABLE avalanche_smart_contracts (id INT,name VARCHAR(255),network VARCHAR(255)); INSERT INTO avalanche_smart_contracts (id,name,network) VALUES (1,'SC1','avalanche'),(2,'SC2','avalanche'); | SELECT COUNT(*) FROM avalanche_smart_contracts WHERE network = 'avalanche'; |
Identify the indigenous languages in South America with the highest and lowest number of native speakers, ordered by speaker count. | CREATE TABLE Languages (Language VARCHAR(255),Country VARCHAR(255),NativeSpeakers INT); | SELECT Language, NativeSpeakers FROM (SELECT Language, Country, NativeSpeakers, ROW_NUMBER() OVER (ORDER BY NativeSpeakers DESC) AS Rank, COUNT(*) OVER () AS TotalRows FROM Languages WHERE Country = 'South America') AS LanguageRanks WHERE Rank = 1 OR Rank = TotalRows; |
How many goals has 'Lionel Messi' scored in the 'La Liga'? | CREATE TABLE players (player_id INT,player_name TEXT,team TEXT,goals_scored INT); INSERT INTO players (player_id,player_name,team,goals_scored) VALUES (1,'Lionel Messi','Barcelona',456); | SELECT SUM(goals_scored) FROM players WHERE player_name = 'Lionel Messi' AND team = 'Barcelona'; |
Create a new table for storing concert ticket sales data, with columns for concert_id, artist_name, city, and revenue. | CREATE SCHEMA music; USE music; | CREATE TABLE concert_ticket_sales (concert_id INT, artist_name VARCHAR(255), city VARCHAR(255), revenue FLOAT); |
What are the earliest cybersecurity strategies per category since 2010? | CREATE TABLE Cybersecurity (id INT,title VARCHAR(50),category VARCHAR(50),description TEXT,date DATE); INSERT INTO Cybersecurity (id,title,category,description,date) VALUES (1,'Zero Trust Architecture','Network Security','Description...','2021-03-01'); | SELECT category, MIN(date) FROM Cybersecurity WHERE title NOT LIKE '%Vulnerability%' AND date >= '2010-01-01' GROUP BY category; |
What is the average number of goals scored by players from the La Liga in soccer games, excluding players with less than 15 games played? | CREATE TABLE La_Liga_Teams (Team VARCHAR(50),Goals INT); INSERT INTO La_Liga_Teams (Team,Goals) VALUES ('Real Madrid',83),('Barcelona',75),('Atletico Madrid',67); | SELECT AVG(Goals) FROM La_Liga_Teams WHERE Goals > (SELECT AVG(Goals) FROM La_Liga_Teams) GROUP BY Goals HAVING COUNT(*) >= 15; |
What is the average rating for movies and TV shows in the horror genre? | CREATE TABLE Movies (id INT,title VARCHAR(255),genre VARCHAR(50),rating DECIMAL(2,1)); CREATE TABLE TVShows (id INT,title VARCHAR(255),genre VARCHAR(50),rating DECIMAL(2,1)); | SELECT 'Movies' AS Type, AVG(rating) AS Average_Rating FROM Movies WHERE genre = 'horror' UNION ALL SELECT 'TV Shows' AS Type, AVG(rating) AS Average_Rating FROM TVShows WHERE genre = 'horror'; |
What is the total number of electric vehicles in 'tokyo' and 'seoul'? | CREATE TABLE if not exists cities (city varchar(20)); INSERT INTO cities (city) VALUES ('tokyo'),('seoul'); CREATE TABLE if not exists vehicle_counts (city varchar(20),vehicle_type varchar(20),count int); INSERT INTO vehicle_counts (city,vehicle_type,count) VALUES ('tokyo','electric',1500),('seoul','electric',2000); | SELECT city, SUM(count) as total_count FROM vehicle_counts WHERE vehicle_type = 'electric' AND city IN ('tokyo', 'seoul') GROUP BY city; |
Update the type of 'VesselE' to 'Bulk Carrier'. | CREATE TABLE Vessels (Id INT,Name VARCHAR(50),Type VARCHAR(50),MaxSpeed DECIMAL(5,2)); INSERT INTO Vessels VALUES (1,'VesselA','Cargo',25.5),(2,'VesselB','Tanker',18.3),(3,'VesselE','Unknown',22.6); | UPDATE Vessels SET Type = 'Bulk Carrier' WHERE Name = 'VesselE'; |
What was the average number of daily active users in the 'gaming' interest group for the last 7 days? | CREATE SCHEMA userdata; CREATE TABLE user_interests(user_id INT,interest_group VARCHAR(255),daily_active_users INT); INSERT INTO user_interests (user_id,interest_group,daily_active_users) VALUES (1,'gaming',1000); INSERT INTO user_interests (user_id,interest_group,daily_active_users) VALUES (2,'gaming',1200); | SELECT AVG(daily_active_users) FROM userdata.user_interests WHERE interest_group = 'gaming' AND daily_active_users >= (SELECT AVG(daily_active_users) FROM userdata.user_interests WHERE interest_group = 'gaming') AND post_date >= (SELECT CURDATE() - INTERVAL 7 DAY); |
Count artworks by medium for impressionist artists | CREATE TABLE Artists (ArtistID INT PRIMARY KEY,ArtistName VARCHAR(255),ArtistStyle VARCHAR(255)); INSERT INTO Artists (ArtistID,ArtistName,ArtistStyle) VALUES (1,'Claude Monet','Impressionist'),(2,'Pierre-Auguste Renoir','Impressionist'),(3,'Edgar Degas','Impressionist'),(4,'Gustav Klimt','Art Nouveau'),(5,'Jackson Pollock','Abstract Expressionism'); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY,ArtistID INT,ArtworkTitle VARCHAR(255),ArtworkMedium VARCHAR(255)); INSERT INTO Artworks (ArtworkID,ArtistID,ArtworkTitle,ArtworkMedium) VALUES (1,1,'Water Lilies','Oil'),(2,1,'Impression Sunrise','Oil'),(3,2,'Dance at Le Moulin de la Galette','Oil'),(4,2,'Luncheon of the Boating Party','Oil'),(5,3,'Ballet Rehearsal','Pastel'),(6,3,'The Starry Night Over the Rhone','Oil'),(7,4,'The Kiss','Gold'),(8,5,'No. 5,1948','Enamel'); | SELECT a.ArtistStyle, aw.ArtworkMedium, COUNT(aw.ArtworkID) AS ArtworkCount FROM Artists a JOIN Artworks aw ON a.ArtistID = aw.ArtistID WHERE a.ArtistStyle = 'Impressionist' GROUP BY a.ArtistStyle, aw.ArtworkMedium; |
What is the number of members in the 'UNITE HERE' union? | CREATE TABLE if not exists unions (id INT,union_name VARCHAR,number_of_members INT); INSERT INTO unions (id,union_name,number_of_members) VALUES (1,'Teamsters',1500000),(2,'SEIU',2000000),(3,'UFW',50000),(4,'UNITE HERE',300000),(5,'Local 1199',400000),(6,'USW',500000); | SELECT SUM(number_of_members) FROM unions WHERE union_name = 'UNITE HERE'; |
What is the total number of travel advisories issued in the last 12 months? | CREATE TABLE travel_advisories (id INT,country VARCHAR(255),issued_date DATE); INSERT INTO travel_advisories (id,country,issued_date) VALUES (1,'France','2022-02-01'),(2,'Germany','2022-03-15'),(3,'Italy','2021-06-01'); | SELECT COUNT(*) FROM travel_advisories WHERE issued_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH); |
Compare the water conservation initiatives between urban and rural areas in Colorado. | CREATE TABLE colorado_water_conservation(area VARCHAR(20),initiatives VARCHAR(50)); INSERT INTO colorado_water_conservation VALUES ('Urban','Xeriscaping,Smart Irrigation'),('Rural','Well Maintenance,Rainwater Harvesting'); | SELECT initiatives FROM colorado_water_conservation WHERE area = 'Urban' INTERSECT SELECT initiatives FROM colorado_water_conservation WHERE area = 'Rural'; |
What are the top three countries with the highest marine litter generation in the Mediterranean Sea? | CREATE TABLE MarineLitter (country VARCHAR(50),litter_kg_yr INT,region VARCHAR(50),PRIMARY KEY(country)); INSERT INTO MarineLitter (country,litter_kg_yr,region) VALUES ('CountryA',1256,'Mediterranean Sea'),('CountryB',1567,'Mediterranean Sea'),('CountryC',1890,'Mediterranean Sea'),('CountryD',987,'Mediterranean Sea'); | SELECT MarineLitter.country, MarineLitter.litter_kg_yr FROM MarineLitter WHERE MarineLitter.region = 'Mediterranean Sea' ORDER BY MarineLitter.litter_kg_yr DESC LIMIT 3; |
What is the total capacity of renewable energy projects in a given state? | CREATE TABLE State (state_id INT,state_name VARCHAR(50)); CREATE TABLE Project (project_id INT,project_name VARCHAR(50),project_capacity INT,state_id INT); | SELECT State.state_name, SUM(Project.project_capacity) as total_capacity FROM State JOIN Project ON State.state_id = Project.state_id GROUP BY State.state_name; |
Calculate the total calories consumed per customer for the 'Brighton Bites' restaurant in Brighton, UK in the month of February 2022, ordered by consumption. | CREATE TABLE customer_meals (customer_id INTEGER,restaurant_name TEXT,city TEXT,calories INTEGER,meal_date DATE); INSERT INTO customer_meals (customer_id,restaurant_name,city,calories,meal_date) VALUES (1,'Brighton Bites','Brighton',1000,'2022-02-01'); | SELECT customer_id, SUM(calories) as total_calories FROM customer_meals WHERE restaurant_name = 'Brighton Bites' AND city = 'Brighton' AND meal_date >= '2022-02-01' AND meal_date < '2022-03-01' GROUP BY customer_id ORDER BY total_calories DESC; |
Which movies have a higher IMDb rating than the average IMDb rating for all movies? | CREATE TABLE IMdb_Ratings (movie_id INT,rating DECIMAL(3,1)); INSERT INTO IMdb_Ratings (movie_id,rating) VALUES (1,9.0),(2,8.8),(3,8.9),(4,7.5); | SELECT movie_id FROM IMdb_Ratings WHERE rating > (SELECT AVG(rating) FROM IMdb_Ratings); |
What is the average number of peacekeeping operations conducted by the African Union in the last 5 years? | CREATE SCHEMA if not exists defense; CREATE TABLE if not exists au_peacekeeping_operations (id INT PRIMARY KEY,year INT,operation_count INT); INSERT INTO defense.au_peacekeeping_operations (id,year,operation_count) VALUES (1,2017,4),(2,2018,5),(3,2019,7),(4,2020,10),(5,2021,12); | SELECT AVG(operation_count) FROM defense.au_peacekeeping_operations WHERE year BETWEEN 2017 AND 2021; |
How many unique sustainable fabric types were sourced from Africa in the past 6 months? | CREATE TABLE sourcing (id INT,fabric_type TEXT,quantity INT,country TEXT,sourcing_date DATE); INSERT INTO sourcing (id,fabric_type,quantity,country,sourcing_date) VALUES (1,'organic cotton',500,'Kenya','2021-06-01'),(2,'recycled polyester',300,'Egypt','2021-07-15'),(3,'hemp',700,'Morocco','2021-08-09'); CREATE TABLE fabric_types (id INT,fabric_type TEXT); INSERT INTO fabric_types (id,fabric_type) VALUES (1,'organic cotton'),(2,'recycled polyester'),(3,'hemp'); | SELECT COUNT(DISTINCT fabric_type) FROM sourcing JOIN fabric_types ON sourcing.fabric_type = fabric_types.fabric_type WHERE country LIKE 'Africa%' AND sourcing_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
Which mining operations have a labor productivity lower than 100? | CREATE TABLE productivity (id INT,mining_operation TEXT,productivity FLOAT); INSERT INTO productivity (id,mining_operation,productivity) VALUES (1,'Operation A',120.5); INSERT INTO productivity (id,mining_operation,productivity) VALUES (2,'Operation B',90.3); | SELECT mining_operation FROM productivity WHERE productivity < 100; |
How many manned space missions have been flown by NASA? | CREATE TABLE Space_Missions (ID INT,Agency VARCHAR(50),Name VARCHAR(50),Manned BOOLEAN); INSERT INTO Space_Missions (ID,Agency,Name,Manned) VALUES (1,'NASA','Apollo 11',1),(2,'NASA','Skylab 2',1),(3,'NASA','Apollo-Soyuz',1),(4,'NASA','Space Shuttle Challenger',1),(5,'NASA','Mars Science Laboratory',0); | SELECT COUNT(*) FROM Space_Missions WHERE Agency = 'NASA' AND Manned = 1; |
What is the minimum score in the 'RacingGame' table? | CREATE TABLE RacingGame (GameID INT,PlayerID INT,Score INT); INSERT INTO RacingGame (GameID,PlayerID,Score) VALUES (3001,4,50),(3002,5,60),(3003,6,70); | SELECT MIN(Score) FROM RacingGame; |
Which suppliers have a sustainability score greater than 70 and are located in 'Brazil'? | CREATE TABLE supplier (id INT PRIMARY KEY,company_name VARCHAR(100),country VARCHAR(50),sustainability_score INT); INSERT INTO supplier (id,company_name,country,sustainability_score) VALUES (1,'Green Textiles Inc.','USA',85),(2,'Sustainable Fabrics Pvt Ltd.','India',82),(3,'EcoFabrics Ltda.','Brazil',75); | SELECT company_name, sustainability_score FROM supplier WHERE country = 'Brazil' AND sustainability_score > 70; |
Delete an employee record from the "employees" table | CREATE TABLE employees (id INT,first_name VARCHAR(50),last_name VARCHAR(50),department VARCHAR(50),job_title VARCHAR(50),hire_date DATE); | DELETE FROM employees WHERE id = 101; |
What is the maximum offshore oil production in the South China Sea for 2017? | CREATE TABLE south_china_sea_platforms (platform_id INT,platform_name VARCHAR(50),location VARCHAR(50),operational_status VARCHAR(15)); INSERT INTO south_china_sea_platforms VALUES (1,'CNOOC 1','South China Sea','Active'); INSERT INTO south_china_sea_platforms VALUES (2,'PetroVietnam 1','South China Sea','Active'); CREATE TABLE offshore_oil_production (platform_id INT,year INT,production FLOAT); INSERT INTO offshore_oil_production VALUES (1,2017,1200000); INSERT INTO offshore_oil_production VALUES (1,2017,1300000); INSERT INTO offshore_oil_production VALUES (2,2017,1000000); INSERT INTO offshore_oil_production VALUES (2,2017,1100000); | SELECT MAX(production) FROM offshore_oil_production WHERE year = 2017 AND location = 'South China Sea'; |
What is the total mass of space debris in LEO, GEO, and HEO orbits? | CREATE TABLE space_debris (debris_id INT,orbit_type VARCHAR(255),mass FLOAT); INSERT INTO space_debris (debris_id,orbit_type,mass) VALUES (1,'LEO',1000.00); INSERT INTO space_debris (debris_id,orbit_type,mass) VALUES (2,'GEO',2000.00); INSERT INTO space_debris (debris_id,orbit_type,mass) VALUES (3,'HEO',3000.00); | SELECT orbit_type, SUM(mass) FROM space_debris GROUP BY orbit_type; |
What is the total weight of organic_produce in the warehouse table? | CREATE TABLE warehouse (item_name TEXT,item_type TEXT,weight INTEGER); INSERT INTO warehouse (item_name,item_type,weight) VALUES ('Carrots','organic_produce',500),('Potatoes','organic_produce',800),('Broccoli','organic_produce',300); | SELECT SUM(weight) FROM warehouse WHERE item_type = 'organic_produce'; |
How many wind energy projects in the 'renewables' schema have an installed capacity greater than 150 MW? | CREATE SCHEMA if not exists renewables; CREATE TABLE if not exists renewables.wind_projects (project_id int,name varchar(255),location varchar(255),installed_capacity float); INSERT INTO renewables.wind_projects (project_id,name,location,installed_capacity) VALUES (1,'Wind Project 1','Country A',120.0),(2,'Wind Project 2','Country B',180.0),(3,'Wind Project 3','Country C',220.0); | SELECT COUNT(*) FROM renewables.wind_projects WHERE installed_capacity > 150.0; |
What is the average prize pool for esports events? | CREATE TABLE EsportsEvents (EventID INT,EventName VARCHAR(50),PrizePool DECIMAL(10,2)); INSERT INTO EsportsEvents (EventID,EventName,PrizePool) VALUES (1,'The International',40000000.00),(2,'League of Legends World Championship',24000000.00),(3,'Major League Gaming',1000000.00); | SELECT AVG(PrizePool) FROM EsportsEvents; |
What are the top 5 countries with the highest number of security incidents in the last month? | CREATE TABLE security_incidents (id INT,country VARCHAR(50),incident_count INT,incident_date DATE); INSERT INTO security_incidents (id,country,incident_count,incident_date) VALUES (1,'USA',150,'2022-01-01'),(2,'Canada',80,'2022-01-02'),(3,'Mexico',120,'2022-01-03'); CREATE TABLE countries (id INT,name VARCHAR(50)); INSERT INTO countries (id,name) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'),(4,'Brazil'),(5,'Argentina'); | SELECT c.name, SUM(si.incident_count) as total_incidents FROM security_incidents si JOIN countries c ON si.country = c.name WHERE si.incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY c.name ORDER BY total_incidents DESC LIMIT 5; |
What was the production cost for the 'Sustainable Solutions' plant in the last quarter? | CREATE TABLE Plants (id INT,name VARCHAR(255)); INSERT INTO Plants (id,name) VALUES (3,'Sustainable Solutions'); CREATE TABLE Production (id INT,plant_id INT,cost DECIMAL(10,2),production_date DATE); INSERT INTO Production (id,plant_id,cost,production_date) VALUES (4,3,15000,'2021-04-01'); INSERT INTO Production (id,plant_id,cost,production_date) VALUES (5,3,18000,'2021-07-01'); | SELECT SUM(cost) FROM Production WHERE plant_id = 3 AND production_date BETWEEN '2021-04-01' AND '2021-06-30'; |
What is the total weight of cargo handled by each vessel? | CREATE TABLE vessels (id INT,name VARCHAR(255),port_id INT); CREATE TABLE cargo (id INT,vessel_id INT,weight INT); INSERT INTO vessels (id,name,port_id) VALUES (1,'Vessel A',1),(2,'Vessel B',1),(3,'Vessel C',2); INSERT INTO cargo (id,vessel_id,weight) VALUES (1,1,5000),(2,1,7000),(3,2,3000),(4,3,4000); | SELECT vessels.name, SUM(cargo.weight) as total_weight FROM vessels INNER JOIN cargo ON vessels.id = cargo.vessel_id GROUP BY vessels.id; |
Find the unique investment strategies with the highest returns, excluding strategies that have had less than 5 transactions. | CREATE TABLE InvestmentStrategies (StrategyID INT,StrategyName VARCHAR(100),Returns DECIMAL(10,2),Transactions INT); INSERT INTO InvestmentStrategies (StrategyID,StrategyName,Returns,Transactions) VALUES (1,'Growth',12.5,7); INSERT INTO InvestmentStrategies (StrategyID,StrategyName,Returns,Transactions) VALUES (2,'Value',10.2,3); INSERT INTO InvestmentStrategies (StrategyID,StrategyName,Returns,Transactions) VALUES (3,'Dividend',9.1,12); INSERT INTO InvestmentStrategies (StrategyID,StrategyName,Returns,Transactions) VALUES (4,'Index',8.8,4); | SELECT StrategyName, Returns FROM InvestmentStrategies WHERE Transactions >= 5 GROUP BY StrategyName, Returns ORDER BY Returns DESC; |
What was the average price of cannabis edibles in Colorado in Q3 2022? | CREATE TABLE Dispensaries (id INT,name TEXT,state TEXT);CREATE TABLE Sales (id INT,dispensary_id INT,price DECIMAL,sale_date DATE,product_type TEXT); INSERT INTO Dispensaries (id,name,state) VALUES (1,'Dispensary A','Colorado'); INSERT INTO Sales (id,dispensary_id,price,sale_date,product_type) VALUES (1,1,30,'2022-07-01','edibles'); | SELECT AVG(s.price) FROM Dispensaries d INNER JOIN Sales s ON d.id = s.dispensary_id WHERE d.state = 'Colorado' AND s.product_type = 'edibles' AND s.sale_date BETWEEN '2022-07-01' AND '2022-09-30'; |
How many urban refugees have been supported by 'World Aid' in the 'Asia' region with over 40 years of age, in the last 3 years? | CREATE TABLE refugee (id INT,name VARCHAR(255),age INT,location VARCHAR(255),supported_by VARCHAR(255),support_date DATE); INSERT INTO refugee (id,name,age,location,supported_by,support_date) VALUES (1,'John Doe',45,'Asia','World Aid','2020-01-01'); | SELECT COUNT(*) FROM refugee WHERE location = 'Asia' AND supported_by = 'World Aid' AND age > 40 AND support_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 YEAR) AND CURDATE(); |
How many farms are there in each country? | CREATE TABLE FarmCount (country VARCHAR(50),num_farms INT); INSERT INTO FarmCount (country,num_farms) VALUES ('USA',5000),('Canada',4000),('Mexico',3000); | SELECT country, num_farms FROM FarmCount; |
Update the status of contract negotiation with an ID of 2 to 'completed' | CREATE TABLE contract_negotiations(id INT,status VARCHAR(50)); INSERT INTO contract_negotiations VALUES (1,'pending'),(2,'in progress'),(3,'cancelled'); | UPDATE contract_negotiations SET status = 'completed' WHERE id = 2; |
What is the total duration of yoga workouts for users from India? | CREATE TABLE activities (id INT,user_id INT,activity VARCHAR(50),duration INT); INSERT INTO activities (id,user_id,activity,duration) VALUES (1,1,'Yoga',60); INSERT INTO activities (id,user_id,activity,duration) VALUES (2,2,'Running',45); INSERT INTO activities (id,user_id,activity,duration) VALUES (3,3,'Yoga',90); INSERT INTO activities (id,user_id,activity,duration) VALUES (4,4,'Cycling',75); INSERT INTO activities (id,user_id,activity,duration) VALUES (5,5,'Yoga',45); | SELECT SUM(duration) as total_yoga_duration FROM activities WHERE activity = 'Yoga' AND user_id IN (SELECT id FROM users WHERE country = 'India'); |
Who was the first astronaut to walk on the moon? | CREATE TABLE Astronauts (id INT PRIMARY KEY,name VARCHAR(255),mission VARCHAR(255)); CREATE TABLE SpaceMissions (id INT PRIMARY KEY,name VARCHAR(255),moon_walk BOOLEAN); CREATE TABLE AstronautMissions (id INT PRIMARY KEY,astronaut_id INT,mission_id INT,FOREIGN KEY (astronaut_id) REFERENCES Astronauts(id),FOREIGN KEY (mission_id) REFERENCES SpaceMissions(id)); | SELECT a.name FROM Astronauts a JOIN AstronautMissions am ON a.id = am.astronaut_id JOIN SpaceMissions m ON am.mission_id = m.id WHERE m.moon_walk = TRUE LIMIT 1; |
What is the minimum and maximum property price for each type? | CREATE TABLE property (id INT,price FLOAT,type VARCHAR(20)); | SELECT type, MIN(price) AS "Min Price", MAX(price) AS "Max Price" FROM property GROUP BY type; |
What is the average distance of bike-sharing trips in New York? | CREATE TABLE bike_sharing (id INT,distance FLOAT,city VARCHAR(20)); INSERT INTO bike_sharing (id,distance,city) VALUES (1,3.2,'New York'); | SELECT AVG(distance) FROM bike_sharing WHERE city = 'New York'; |
Find the minimum price of plus size clothing | CREATE TABLE products (id INT,category VARCHAR(50),subcategory VARCHAR(50),is_plus_size BOOLEAN,price DECIMAL(5,2)); INSERT INTO products (id,category,subcategory,is_plus_size,price) VALUES (1,'Clothing','Tops',FALSE,19.99),(2,'Clothing','Pants',TRUE,49.99),(3,'Clothing','Dresses',FALSE,69.99),(4,'Clothing','Jackets',TRUE,89.99),(5,'Clothing','Skirts',FALSE,39.99); | SELECT MIN(price) FROM products WHERE category = 'Clothing' AND is_plus_size = TRUE; |
Calculate the average number of emergency supplies distributed in the last month for each country? | CREATE TABLE Emergency_Supplies (id INT PRIMARY KEY,supply VARCHAR(255),country_id INT,quantity INT,supply_date DATE); INSERT INTO Emergency_Supplies (id,supply,country_id,quantity,supply_date) VALUES (1,'Tents',1,100,'2021-01-01'),(2,'Food',2,200,'2021-02-01'); | SELECT country_id, AVG(quantity) FROM Emergency_Supplies WHERE EXTRACT(MONTH FROM supply_date) = EXTRACT(MONTH FROM CURRENT_DATE - INTERVAL '1' MONTH) GROUP BY country_id; |
What is the total waste generation for each industry across all regions? | CREATE TABLE Waste_Generation_All (industry VARCHAR(20),region VARCHAR(20),waste_quantity INT); INSERT INTO Waste_Generation_All (industry,region,waste_quantity) VALUES ('Manufacturing','North',1000),('Manufacturing','South',1500),('Retail','North',500),('Retail','East',700),('Agriculture','West',2000); | SELECT industry, SUM(waste_quantity) FROM Waste_Generation_All GROUP BY industry; |
Which projects were completed in the 'Electrical Engineering' department between January 2022 and June 2022? | CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),StartDate DATE,EndDate DATE,Department VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,StartDate,EndDate,Department) VALUES (4,'Electrical Grid','2022-01-15','2022-06-30','Electrical Engineering'); | SELECT Projects.ProjectName FROM Projects WHERE Projects.Department = 'Electrical Engineering' AND Projects.StartDate BETWEEN '2022-01-01' AND '2022-06-30' AND Projects.EndDate BETWEEN '2022-01-01' AND '2022-06-30'; |
How many new oil wells were added to the 'OIL_WELLS' table in 2021? | CREATE TABLE OIL_WELLS (WELL_NAME VARCHAR(255),DRILL_DATE DATE); | SELECT COUNT(*) FROM OIL_WELLS WHERE DRILL_DATE BETWEEN '2021-01-01' AND '2021-12-31'; |
What are the names of clients who have borrowed from both socially responsible and conventional lending programs? | CREATE TABLE socially_responsible_borrowers(client_id INT,program_type VARCHAR(25));CREATE TABLE conventional_borrowers(client_id INT,program_type VARCHAR(25));INSERT INTO socially_responsible_borrowers(client_id,program_type) VALUES (1,'SRI'),(2,'SRI'),(3,'CONVENTIONAL');INSERT INTO conventional_borrowers(client_id,program_type) VALUES (1,'CONVENTIONAL'),(3,'CONVENTIONAL'),(4,'CONVENTIONAL'); | SELECT sr.client_id FROM socially_responsible_borrowers sr JOIN conventional_borrowers cb ON sr.client_id = cb.client_id WHERE sr.program_type = 'SRI' AND cb.program_type = 'CONVENTIONAL'; |
What is the average donation amount and the average number of volunteers for each program? | CREATE TABLE programs (id INT,name TEXT); CREATE TABLE volunteers (id INT,program_id INT); CREATE TABLE donors (id INT,volunteer_id INT,donation_amount FLOAT); | SELECT p.name as program, AVG(d.donation_amount) as avg_donation, AVG(v.id) as avg_volunteers FROM programs p LEFT JOIN volunteers v ON p.id = v.program_id LEFT JOIN donors d ON v.id = d.volunteer_id GROUP BY p.name; |
How many trains are in operation in Tokyo? | CREATE TABLE train_lines (line_id INT,city VARCHAR(50)); INSERT INTO train_lines (line_id,city) VALUES (1,'Tokyo'),(2,'Osaka'); CREATE TABLE trains (train_id INT,line_id INT,status VARCHAR(10)); INSERT INTO trains (train_id,line_id,status) VALUES (1,1,'operational'),(2,1,'maintenance'),(3,2,'operational'); | SELECT COUNT(*) FROM trains WHERE status = 'operational' AND line_id IN (SELECT line_id FROM train_lines WHERE city = 'Tokyo'); |
What is the sum of all donations and investments for each sector in the 'sectors' table, ordered by the sum of all contributions in descending order? | CREATE TABLE sectors (sector_id INT,sector_name TEXT,total_donations DECIMAL(10,2),total_investments DECIMAL(10,2)); | SELECT sector_name, SUM(total_donations) + SUM(total_investments) as total_contributions FROM sectors GROUP BY sector_name ORDER BY total_contributions DESC; |
Which restorative justice events occurred in California in 2021? | CREATE TABLE public.restorative_justice (id serial PRIMARY KEY,location text,date date,agreement text[]); INSERT INTO public.restorative_justice (location,date,agreement) VALUES ('California','2021-03-01',ARRAY['Apology','Community_Service']),('Texas','2021-04-01',ARRAY['Restitution','Mediation']); | SELECT location, agreement FROM public.restorative_justice WHERE date::text LIKE '2021-%' AND location = 'California'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.