instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Calculate the average carbon sequestration for forests planted after a certain year | CREATE TABLE forests (id INT,name VARCHAR(50),hectares DECIMAL(5,2),year_planted INT,avg_carbon_sequestration DECIMAL(5,2),PRIMARY KEY (id)); INSERT INTO forests (id,name,hectares,year_planted,avg_carbon_sequestration) VALUES (1,'Forest A',123.45,1990,2.5),(2,'Forest B',654.32,2005,3.2),(3,'Forest C',456.78,2010,3.8),(... | SELECT AVG(f.avg_carbon_sequestration) FROM forests f WHERE f.year_planted > 1999; |
What is the minimum water salinity (in ppt) in fish farms located in Africa, with a water depth greater than 5 meters and a water temperature below 28 degrees Celsius? | CREATE TABLE fish_farms (id INT,name VARCHAR(255),region VARCHAR(255),water_salinity FLOAT,water_depth FLOAT,water_temperature FLOAT); INSERT INTO fish_farms (id,name,region,water_salinity,water_depth,water_temperature) VALUES (1,'Farm G','Africa',20.5,7.6,26.2),(2,'Farm H','Africa',22.3,6.1,27.8),(3,'Farm I','Africa',... | SELECT MIN(water_salinity) FROM fish_farms WHERE region = 'Africa' AND water_depth > 5 AND water_temperature < 28; |
List the names of ports where the Kota Pertama has docked. | CREATE TABLE Ports (PortID INT,PortName VARCHAR(100),City VARCHAR(100),Country VARCHAR(100)); INSERT INTO Ports (PortID,PortName,City,Country) VALUES (1,'Port of Singapore','Singapore','Singapore'); INSERT INTO Ports (PortID,PortName,City,Country) VALUES (2,'Port of Rotterdam','Rotterdam','Netherlands'); CREATE TABLE... | SELECT Ports.PortName FROM Ports INNER JOIN Vessels ON Ports.PortID = Vessels.PortID WHERE Vessels.VesselName = 'Kota Pertama'; |
What is the average population of animals in the wildlife_habitat table for the species 'Raccoon'? | CREATE TABLE wildlife_habitat (id INT,species VARCHAR(255),population INT); INSERT INTO wildlife_habitat (id,species,population) VALUES (1,'Bear',35),(2,'Deer',78),(3,'Raccoon',42); | SELECT AVG(population) FROM wildlife_habitat WHERE species = 'Raccoon'; |
What is the average horsepower for sports cars produced in Italy? | CREATE TABLE vehicles (vehicle_id INT,model VARCHAR(20),manufacture VARCHAR(20),horsepower INT); CREATE VIEW sports_cars AS SELECT vehicle_id,horsepower FROM vehicles WHERE manufacture = 'Italy' AND vehicle_type = 'sports_car'; | SELECT AVG(horsepower) FROM sports_cars; |
What is the total amount of socially responsible loans issued by financial institutions in the Asia-Pacific region? | CREATE TABLE loans (id INT,amount DECIMAL(10,2),issuance_date DATE,institution_id INT,is_socially_responsible BOOLEAN); INSERT INTO loans (id,amount,issuance_date,institution_id,is_socially_responsible) VALUES (1,10000,'2022-01-01',1,true); CREATE TABLE financial_institutions (id INT,name VARCHAR(50),region VARCHAR(20)... | SELECT SUM(loans.amount) FROM loans INNER JOIN financial_institutions ON loans.institution_id = financial_institutions.id WHERE loans.is_socially_responsible = true AND financial_institutions.region = 'Asia-Pacific'; |
Which causes received the most donations from female donors? | CREATE TABLE Donors (DonorID INT,DonorName VARCHAR(50),DonationAmount DECIMAL(10,2),Gender VARCHAR(10),CauseID INT);CREATE VIEW DonorGender AS SELECT DonorID,DonorName,Gender FROM Donors;CREATE TABLE Causes (CauseID INT,CauseName VARCHAR(50)); | SELECT C.CauseName, SUM(D.DonationAmount) FROM Donors D JOIN DonorGender DG ON D.DonorID = DG.DonorID JOIN Causes C ON D.CauseID = C.CauseID WHERE DG.Gender = 'Female' GROUP BY C.CauseName ORDER BY SUM(D.DonationAmount) DESC; |
What is the maximum number of virtual tours engaged with in a single day for hotels in Rome, Italy? | CREATE TABLE virtual_tours (id INT,hotel_id INT,engagement_count INT,engagement_date DATE); CREATE TABLE hotels (id INT,name TEXT,city TEXT,country TEXT); | SELECT MAX(engagement_count) FROM virtual_tours vt INNER JOIN hotels h ON vt.hotel_id = h.id WHERE h.city = 'Rome' AND h.country = 'Italy' GROUP BY engagement_date; |
what is the total quantity of seafood sold in the west | CREATE TABLE sales (id INT,location VARCHAR(20),quantity INT,price DECIMAL(5,2)); INSERT INTO sales (id,location,quantity,price) VALUES (1,'Northeast',50,12.99),(2,'Midwest',75,19.99),(3,'West',120,14.49); | SELECT SUM(quantity) FROM sales WHERE location = 'West'; |
What is the total amount of water saved in liters through water conservation initiatives in the city of Chicago? | CREATE TABLE WaterConservationInitiatives (initiative_id INT,city VARCHAR(20),water_saved_liters INT); INSERT INTO WaterConservationInitiatives (initiative_id,city,water_saved_liters) VALUES (1,'Chicago',1200000),(2,'Chicago',1500000); | SELECT SUM(water_saved_liters) FROM WaterConservationInitiatives WHERE city = 'Chicago'; |
What is the number of companies founded by individuals from underrepresented backgrounds? | CREATE TABLE company (id INT,name TEXT,founding_year INT,founder_background TEXT); INSERT INTO company (id,name,founding_year,founder_background) VALUES (1,'Acme Inc',2010,'minority'); INSERT INTO company (id,name,founding_year,founder_background) VALUES (2,'Beta Corp',2015,'non-minority'); | SELECT COUNT(*) FROM company WHERE founder_background = 'minority'; |
What is the average number of virtual tour views per hotel in New York? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,city TEXT,virtual_tour_views INT); INSERT INTO hotels (hotel_id,hotel_name,city,virtual_tour_views) VALUES (1,'The Plaza Hotel','New York',700),(2,'The Mandarin Oriental','New York',600),(3,'The Bowery Hotel','New York',500); | SELECT city, AVG(virtual_tour_views) as avg_views FROM hotels WHERE city = 'New York' GROUP BY city; |
Find the vessel with the highest average speed for a specific month | CREATE TABLE VesselMovements (vessel_id INT,movement_date DATE,speed INT); | SELECT vessel_id, AVG(speed) FROM VesselMovements WHERE movement_date >= '2022-01-01' AND movement_date <= '2022-01-31' GROUP BY vessel_id ORDER BY AVG(speed) DESC LIMIT 1; |
What is the minimum cost of manufacturing the aircraft models 'Falcon 9' and 'Falcon 1'? | CREATE TABLE AircraftManufacturing(model VARCHAR(20),total_cost INT); INSERT INTO AircraftManufacturing VALUES('Falcon 1',500000),('Falcon 9',600000); | SELECT MIN(total_cost) FROM AircraftManufacturing WHERE model IN ('Falcon 9', 'Falcon 1'); |
What is the total number of defense diplomacy events held in 'canada' between 2019 and 2021? | CREATE TABLE defense_diplomacy (country VARCHAR(50),year INT,events INT); INSERT INTO defense_diplomacy (country,year,events) VALUES ('Canada',2019,15),('Canada',2020,12),('Canada',2021,18); | SELECT country, SUM(events) as total_events FROM defense_diplomacy WHERE country = 'Canada' AND year BETWEEN 2019 AND 2021 GROUP BY country; |
List all companies with onshore drilling permits in Wyoming and Montana. | CREATE TABLE permits_by_company (company VARCHAR(255),region VARCHAR(255),permit_number INT); | SELECT DISTINCT company FROM permits_by_company WHERE region IN ('Wyoming', 'Montana') INTERSECT SELECT company FROM permits_by_company WHERE region IN ('Colorado', 'New Mexico'); |
What was the average annual precipitation in rural Ethiopia between 2016 and 2020? | CREATE TABLE precipitation_ethiopia (region VARCHAR(50),year INT,avg_precipitation FLOAT); INSERT INTO precipitation_ethiopia (region,year,avg_precipitation) VALUES ('Rural Ethiopia',2016,800),('Rural Ethiopia',2017,900),('Rural Ethiopia',2018,1000),('Rural Ethiopia',2019,1100),('Rural Ethiopia',2020,1200); | SELECT AVG(avg_precipitation) FROM precipitation_ethiopia WHERE region = 'Rural Ethiopia' AND year BETWEEN 2016 AND 2020; |
What is the average CO2 emission of buildings constructed before 2000 in the city of Seattle? | CREATE TABLE Buildings (id INT,city VARCHAR(20),construction_year INT,co2_emission FLOAT); INSERT INTO Buildings (id,city,construction_year,co2_emission) VALUES (1,'Seattle',1999,350.5),(2,'Seattle',1995,400.2),(3,'Portland',2005,250.1); | SELECT AVG(co2_emission) FROM Buildings WHERE city = 'Seattle' AND construction_year < 2000; |
What is the total number of autonomous vehicles tested in Arizona? | CREATE TABLE AutonomousVehicles (Id INT,TestLocation VARCHAR(50),TestDate DATE,VehicleCount INT); INSERT INTO AutonomousVehicles (Id,TestLocation,TestDate,VehicleCount) VALUES (1,'Arizona','2018-01-01',200),(2,'Arizona','2019-01-01',400),(3,'Arizona','2020-01-01',600),(4,'Arizona','2021-01-01',800); | SELECT SUM(VehicleCount) FROM AutonomousVehicles WHERE TestLocation = 'Arizona'; |
Insert new records into 'Exploration' table for the following data: (ExplorationID, Location, StartDate, EndDate) - ('Exp01', 'Gulf of Mexico', '2020-01-01', '2020-12-31') | CREATE TABLE Exploration (ExplorationID VARCHAR(10),Location VARCHAR(20),StartDate DATE,EndDate DATE); | INSERT INTO Exploration (ExplorationID, Location, StartDate, EndDate) VALUES ('Exp01', 'Gulf of Mexico', '2020-01-01', '2020-12-31'); |
What is the percentage of visitors who identified as male or female out of total visitors? | CREATE TABLE Exhibitions (exhibition_id INT,name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO Exhibitions (exhibition_id,name,start_date,end_date) VALUES (1,'Impressionist','2020-05-01','2021-01-01'),(2,'Cubism','2019-08-15','2020-03-30'),(3,'Surrealism','2018-12-15','2019-09-15'); CREATE TABLE Visitors (vis... | SELECT (SUM(CASE WHEN gender IN ('male', 'female') THEN 1 ELSE 0 END)/COUNT(*))*100 FROM Visitors; |
Display the carbon offset programs initiated in 2015 and their respective CO2 savings, and the total CO2 savings for all programs initiated in 2015 | CREATE TABLE carbon_offset_programs (program_id INT,program_name VARCHAR(255),initiation_date DATE,co2_savings INT); INSERT INTO carbon_offset_programs (program_id,program_name,initiation_date,co2_savings) VALUES (1,'Carbon Offset Program A','2012-04-01',12000); INSERT INTO carbon_offset_programs (program_id,program_na... | SELECT program_name, co2_savings FROM carbon_offset_programs WHERE initiation_date = '2015-01-01' AND initiation_date = '2015-12-31' GROUP BY program_name; SELECT SUM(co2_savings) FROM carbon_offset_programs WHERE initiation_date BETWEEN '2015-01-01' AND '2015-12-31'; |
What is the maximum horsepower of electric vehicles in the 'GreenAutos' database? | CREATE TABLE ElectricVehicles (Id INT,Make VARCHAR(50),Model VARCHAR(50),Year INT,Horsepower INT); | SELECT MAX(Horsepower) FROM ElectricVehicles WHERE FuelType = 'Electric'; |
How many tourists visited the Eiffel Tower in 2020? | CREATE TABLE eiffel_tower_visitors (id INT,year INT,visitors INT); INSERT INTO eiffel_tower_visitors (id,year,visitors) VALUES (1,2019,7000000),(2,2020,3000000); | SELECT visitors FROM eiffel_tower_visitors WHERE year = 2020; |
What is the total revenue for games released before 2010 that have more than 100k copies sold? | CREATE TABLE Games (game_id INT,title VARCHAR(100),release_year INT,copies_sold INT,revenue INT); INSERT INTO Games (game_id,title,release_year,copies_sold,revenue) VALUES (1,'Mario Kart 64',1996,150000,500000),(2,'Tetris',1984,50000000,15000000); | SELECT SUM(revenue) FROM Games g WHERE g.release_year < 2010 AND g.copies_sold > 100000; |
What is the total number of smart city technology adoptions in the 'smart_city_technology' table? | CREATE TABLE smart_city_technology (tech_id INT,tech_name VARCHAR(100),adoption_date DATE); INSERT INTO smart_city_technology (tech_id,tech_name,adoption_date) VALUES (1,'Smart Grid','2020-03-15'),(2,'Smart Lighting','2019-08-01'),(3,'Smart Waste','2021-02-01'); | SELECT COUNT(*) FROM smart_city_technology; |
List the top 3 organizations with the highest explainability ratings. | CREATE TABLE explainability_ratings (org_id INT,explainability_score FLOAT); INSERT INTO explainability_ratings (org_id,explainability_score) VALUES (1,0.85),(2,0.92),(3,0.88),(4,0.9),(5,0.8); | SELECT org_id, explainability_score FROM explainability_ratings ORDER BY explainability_score DESC LIMIT 3; |
What is the average age of teachers who have participated in professional development programs in the last year, in the state of California? | CREATE TABLE states (state_name VARCHAR(255),state_id INT); INSERT INTO states (state_name,state_id) VALUES ('California',1); CREATE TABLE schools (school_name VARCHAR(255),state_id INT,PRIMARY KEY (school_name,state_id)); CREATE TABLE teachers (teacher_id INT,teacher_age INT,school_name VARCHAR(255),state_id INT,PRIMA... | SELECT AVG(teachers.teacher_age) FROM teachers INNER JOIN professional_development ON teachers.teacher_id = professional_development.teacher_id INNER JOIN schools ON teachers.school_name = schools.school_name WHERE schools.state_id = 1 AND professional_development.pd_date >= DATEADD(year, -1, GETDATE()); |
How many spacecraft were part of space missions to Mars? | CREATE TABLE Spacecraft (SpacecraftID INT,Name VARCHAR(50),Manufacturer VARCHAR(50));CREATE TABLE SpaceMissions (MissionID INT,SpacecraftID INT,Name VARCHAR(50),Destination VARCHAR(50)); INSERT INTO Spacecraft (SpacecraftID,Name,Manufacturer) VALUES (1,'Spirit','NASA'),(2,'Curiosity','NASA'),(3,'Perseverance','NASA'); ... | SELECT COUNT(s.SpacecraftID) FROM Spacecraft s INNER JOIN SpaceMissions sm ON s.SpacecraftID = sm.SpacecraftID WHERE sm.Destination = 'Mars'; |
What is the average well-being score for athletes from underrepresented communities? | CREATE TABLE athletes (athlete_id INT,well_being_score INT,community_representation VARCHAR(50)); | SELECT AVG(athletes.well_being_score) FROM athletes WHERE athletes.community_representation = 'Underrepresented'; |
How many rural hospitals are in the "rural_hospitals_2" table? | CREATE TABLE rural_hospitals_2 (id INT,name TEXT,location TEXT,capacity INT); INSERT INTO rural_hospitals_2 (id,name,location,capacity) VALUES (1,'Hospital C','City3',75),(2,'Hospital D','City4',60); | SELECT COUNT(*) FROM rural_hospitals_2; |
What is the percentage of hotels in India that have adopted AI voice assistants? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,ai_voice_assistant BOOLEAN); INSERT INTO hotels VALUES (6,'Hotel G','India',true); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM hotels WHERE country = 'India')) AS percentage FROM hotels WHERE country = 'India' AND ai_voice_assistant = true; |
Update the genre of the TV show 'Breaking Bad' to 'Crime' in the 'TV_Shows' table. | CREATE TABLE TV_Shows (show_id INT PRIMARY KEY,name VARCHAR(100),genre VARCHAR(50)); INSERT INTO TV_Shows (show_id,name,genre) VALUES (1,'Breaking Bad','Drama'),(2,'Stranger Things','Sci-fi'); | UPDATE TV_Shows SET genre = 'Crime' WHERE name = 'Breaking Bad'; |
What is the total production of Dysprosium in the 'North America' region for 2020? | CREATE TABLE production(year INT,region VARCHAR(20),element VARCHAR(10),quantity INT); INSERT INTO production VALUES(2020,'North America','Dysprosium',1200),(2020,'South America','Dysprosium',800),(2020,'Australia','Dysprosium',400); | SELECT SUM(quantity) FROM production WHERE element = 'Dysprosium' AND region = 'North America' AND year = 2020 |
What is the total food cost for each menu item, broken down by restaurant location? | CREATE TABLE menu_engineering_by_location(location VARCHAR(255),menu_item VARCHAR(255),food_cost DECIMAL(10,2),selling_price DECIMAL(10,2)); INSERT INTO menu_engineering_by_location(location,menu_item,food_cost,selling_price) VALUES('Location 1','Burger',1.50,7.95),('Location 1','Fries',0.35,2.50),('Location 1','Salad'... | SELECT menu_item, location, SUM(food_cost) FROM menu_engineering_by_location GROUP BY menu_item, location; |
Who are the top 5 actors with the highest number of leading roles in French movies? | CREATE TABLE actor (id INT PRIMARY KEY,name VARCHAR(255),gender VARCHAR(255)); CREATE TABLE movie (id INT PRIMARY KEY,title VARCHAR(255),year INT,country VARCHAR(255),leading_actor_id INT,leading_actress_id INT); INSERT INTO actor (id,name,gender) VALUES (1,'ActorA','Male'),(2,'ActorB','Male'),(3,'ActorC','Male'),(4,'A... | SELECT a.name, COUNT(*) AS num_leading_roles FROM actor a JOIN movie m ON a.id IN (m.leading_actor_id, m.leading_actress_id) GROUP BY a.id ORDER BY num_leading_roles DESC LIMIT 5; |
Identify the total number of subscribers for each technology type, excluding subscribers with a 'test' account type | CREATE TABLE subscriber_data (subscriber_id INT,subscriber_type VARCHAR(20),tech_type VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id,subscriber_type,tech_type) VALUES (1,'Regular','4G'),(2,'Test','3G'),(3,'Regular','5G'); | SELECT tech_type, COUNT(*) as total_subscribers FROM subscriber_data WHERE subscriber_type != 'Test' GROUP BY tech_type; |
Find the total rainfall for each crop type in the past 30 days. | CREATE TABLE crop_rainfall (crop_type VARCHAR(255),rainfall DECIMAL(5,2),record_date DATE); INSERT INTO crop_rainfall (crop_type,rainfall,record_date) VALUES ('corn',25.0,'2022-01-01'),('soybeans',30.0,'2022-01-02'),('corn',22.0,'2022-01-03'),('soybeans',28.0,'2022-01-04'); | SELECT c.crop_type, SUM(rainfall) AS total_rainfall FROM crop_rainfall c JOIN (SELECT CURDATE() - INTERVAL 30 DAY AS start_date) d ON c.record_date >= d.start_date GROUP BY c.crop_type; |
What is the correlation between energy efficiency scores and GDP per capita? | CREATE TABLE energy_efficiency_scores (id INT,country_id INT,year INT,score FLOAT); | SELECT c.name, e.score, c.gdp_per_capita, CORR(e.score, c.gdp_per_capita) as correlation FROM energy_efficiency_scores e JOIN countries c ON e.country_id = c.id; |
What is the total number of marine research projects in the Antarctic region? | CREATE TABLE marine_research_projects (project_name VARCHAR(255),region VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO marine_research_projects (project_name,region,start_date,end_date) VALUES ('Antarctic Ice Shelf Study','Antarctic','2022-01-01','2024-12-31'),('Antarctic Krill Census','Antarctic','2023-04-01... | SELECT COUNT(*) FROM marine_research_projects WHERE region = 'Antarctic'; |
How many players play each game type in North America? | CREATE TABLE Players (PlayerID INT,GameType VARCHAR(20),Location VARCHAR(20)); INSERT INTO Players (PlayerID,GameType,Location) VALUES (1,'Sports','North America'),(2,'RPG','Europe'),(3,'Strategy','Asia'),(4,'Sports','North America'),(5,'RPG','North America'); | SELECT GameType, Location, COUNT(*) as NumPlayers FROM Players GROUP BY GameType, Location |
Summarize the total hours worked per volunteer. | CREATE TABLE Volunteers (VolunteerID INT,Name TEXT); CREATE TABLE VolunteerPrograms (VolunteerID INT,Program TEXT,Hours DECIMAL); INSERT INTO Volunteers VALUES (1,'John Doe'),(2,'Jane Smith'); INSERT INTO VolunteerPrograms VALUES (1,'Program A',10.00),(1,'Program B',15.00),(2,'Program A',20.00); | SELECT Volunteers.Name, SUM(VolunteerPrograms.Hours) as TotalHours FROM Volunteers INNER JOIN VolunteerPrograms ON Volunteers.VolunteerID = VolunteerPrograms.VolunteerID GROUP BY Volunteers.Name; |
What is the average height of cricket players from Australia? | CREATE TABLE players (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),sport VARCHAR(20),height INT,country VARCHAR(50)); | SELECT AVG(height) FROM players WHERE sport = 'Cricket' AND country = 'Australia'; |
List all circular economy initiatives in 'Asia' from the 'circular_economy_initiatives' table | CREATE TABLE circular_economy_initiatives (id INT,region VARCHAR(50),initiative VARCHAR(100)); | SELECT initiative FROM circular_economy_initiatives WHERE region = 'Asia'; |
How many 5-star hotels are there in the 'Luxury' category? | CREATE TABLE Hotels (hotel_id INT,hotel_name VARCHAR(100),category VARCHAR(50),rating FLOAT); INSERT INTO Hotels (hotel_id,hotel_name,category,rating) VALUES (1,'Hotel A','Boutique',4.6),(2,'Hotel B','Boutique',4.3),(3,'Hotel C','Luxury',5.0); | SELECT COUNT(*) FROM Hotels WHERE category = 'Luxury' AND rating = 5.0; |
Show me all the chemicals produced in factories located in Florida or Georgia? | CREATE TABLE factories (factory_id INT,name TEXT,location TEXT); INSERT INTO factories (factory_id,name,location) VALUES (1,'Factory A','Florida'),(2,'Factory B','Georgia'),(3,'Factory C','California'); CREATE TABLE productions (factory_id INT,chemical TEXT); INSERT INTO productions (factory_id,chemical) VALUES (1,'Che... | SELECT p.chemical FROM factories f JOIN productions p ON f.factory_id = p.factory_id WHERE f.location IN ('Florida', 'Georgia'); |
What is the average deep-sea exploration funding for projects in the Arctic Circle? | CREATE TABLE exploration_funding (id INT,project TEXT,location TEXT,amount FLOAT); INSERT INTO exploration_funding (id,project,location,amount) VALUES (1,'Project A','Arctic Circle',5000000); INSERT INTO exploration_funding (id,project,location,amount) VALUES (2,'Project B','Antarctic Circle',7000000); | SELECT AVG(amount) FROM exploration_funding WHERE location = 'Arctic Circle'; |
What is the average amount of socially responsible loans issued by financial institutions in Africa? | CREATE TABLE financial_institutions (institution_id INT,institution_name TEXT,region TEXT);CREATE TABLE loans (loan_id INT,institution_id INT,loan_amount DECIMAL,is_socially_responsible BOOLEAN); | SELECT AVG(loan_amount) FROM loans JOIN financial_institutions ON loans.institution_id = financial_institutions.institution_id WHERE is_socially_responsible = TRUE AND region = 'Africa'; |
Which professional development courses were taken by teachers in the last 3 years? | CREATE TABLE teachers (id INT,name VARCHAR(50),professional_development_course VARCHAR(50),course_date DATE); | SELECT professional_development_course FROM teachers WHERE course_date >= DATEADD(year, -3, GETDATE()); |
Insert a new record into the 'tech_for_social_good' table with an id of 3, a 'project' name of 'Accessible coding resources', and a 'description' of 'Free coding resources for people with disabilities' | CREATE TABLE tech_for_social_good (id INT PRIMARY KEY,project VARCHAR(100),description TEXT); | INSERT INTO tech_for_social_good (id, project, description) VALUES (3, 'Accessible coding resources', 'Free coding resources for people with disabilities'); |
What is the total revenue for products that are both vegan and organic in the USA? | CREATE TABLE Products (product_id INT,product_name TEXT,vegan BOOLEAN,organic BOOLEAN,country TEXT); INSERT INTO Products (product_id,product_name,vegan,organic,country) VALUES (1,'Green Concealer',TRUE,TRUE,'USA'),(2,'Vegan Blush',TRUE,TRUE,'USA'),(3,'Organic Bronzer',FALSE,TRUE,'USA'),(4,'Pure Foundation',TRUE,FALSE,... | SELECT SUM(price * quantity_sold) AS revenue FROM Products WHERE country = 'USA' AND vegan = TRUE AND organic = TRUE; |
What is the average budget for rural infrastructure projects in Colombia? | CREATE TABLE RuralInfrastructure (id INT,project VARCHAR(255),country VARCHAR(255),budget FLOAT); INSERT INTO RuralInfrastructure (id,project,country,budget) VALUES (1,'Water Supply','Colombia',250000.00),(2,'Road Construction','Colombia',500000.00); | SELECT AVG(budget) FROM RuralInfrastructure WHERE country = 'Colombia'; |
What is the total organic revenue for each restaurant, ordered by total organic revenue in descending order? | CREATE TABLE Restaurants (RestaurantID int,RestaurantName varchar(50),City varchar(50),State varchar(50),Country varchar(50)); INSERT INTO Restaurants (RestaurantID,RestaurantName,City,State,Country) VALUES (1,'Tasty Thai','New York','NY','USA'),(2,'Pizzeria Napoli','Rome','Italy','Italy'),(3,'Sushi Bar','Tokyo','Japan... | SELECT RestaurantName, SUM(Revenue) as TotalOrganicRevenue FROM Restaurants JOIN Revenue ON Restaurants.RestaurantID = Revenue.RestaurantID WHERE IsOrganic = 1 GROUP BY RestaurantName ORDER BY TotalOrganicRevenue DESC; |
What is the total length of all vessels in the maritime safety database, grouped by their flag states? | CREATE TABLE vessels (vessel_name TEXT,length FLOAT,flag_state TEXT); | SELECT flag_state, SUM(length) AS total_length FROM vessels GROUP BY flag_state; |
What are the number of clinical trials and their outcomes for each drug that has been approved by the EMA, including the drug name and approval date? | CREATE TABLE drugs (drug_id INT,name VARCHAR(255),approval_date DATE);CREATE TABLE clinical_trials (trial_id INT,drug_id INT,outcome VARCHAR(255)); | SELECT d.name, d.approval_date, COUNT(ct.trial_id) as num_trials, STRING_AGG(ct.outcome, ',') as outcomes FROM drugs d JOIN clinical_trials ct ON d.drug_id = ct.drug_id GROUP BY d.name, d.approval_date; |
How many electric vehicle charging stations are there in Germany and Spain combined? | CREATE TABLE EVStationCounts (id INT,country VARCHAR(20),num_stations INT); INSERT INTO EVStationCounts (id,country,num_stations) VALUES (1,'Germany',3000),(2,'Spain',1500),(3,'France',2000); | SELECT COUNT(*) FROM EVStationCounts WHERE country IN ('Germany', 'Spain'); |
What are the names and prices of the menu items that are not offered at any restaurant? | CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),price DECIMAL(5,2),restaurant_id INT); INSERT INTO menu_items (menu_item_id,name,price,restaurant_id) VALUES (1,'Big Burger',12.99,1); INSERT INTO menu_items (menu_item_id,name,price,restaurant_id) VALUES (2,'Chicken Teriyaki',15.99,2); INSERT INTO menu_items ... | SELECT name, price FROM menu_items WHERE menu_item_id NOT IN (SELECT restaurant_id FROM restaurants); |
What is the average waste generation rate per capita in the 'Residential' sector? | CREATE TABLE ResidentialWaste (id INT,sector VARCHAR(20),waste_generation_rate FLOAT,population INT); INSERT INTO ResidentialWaste (id,sector,waste_generation_rate,population) VALUES (1,'Residential',1.2,500000); | SELECT AVG(waste_generation_rate) FROM ResidentialWaste WHERE sector = 'Residential'; |
What is the name and type of all satellites launched by spacecraft from Russia? | CREATE TABLE Spacecraft (id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE); INSERT INTO Spacecraft (id,name,country,launch_date) VALUES (1,'Falcon 9','USA','2010-06-04'); INSERT INTO Spacecraft (id,name,country,launch_date) VALUES (2,'Soyuz-FG','Russia','2001-11-02'); CREATE TABLE Satellites (id INT,name ... | SELECT s.name, s.type FROM Satellites s JOIN Spacecraft sp ON s.spacecraft_id = sp.id WHERE sp.country = 'Russia'; |
Identify the number of virtual tours taken in Japan and South Korea. | CREATE TABLE virtual_tours (tour_id INT,country TEXT,participants INT); INSERT INTO virtual_tours (tour_id,country,participants) VALUES (1,'Japan',200),(2,'Japan',300),(3,'South Korea',100); | SELECT SUM(participants) FROM virtual_tours WHERE country IN ('Japan', 'South Korea'); |
How many ethical AI projects have been completed in European countries? | CREATE TABLE AIProjects (ProjectID INT,ProjectName TEXT,Country TEXT,Completion BOOLEAN); INSERT INTO AIProjects (ProjectID,ProjectName,Country,Completion) VALUES (1,'Project A','Germany',TRUE); INSERT INTO AIProjects (ProjectID,ProjectName,Country,Completion) VALUES (2,'Project B','France',FALSE); INSERT INTO AIProjec... | SELECT COUNT(*) FROM AIProjects WHERE Country IN ('Germany', 'France', 'UK') AND Completion = TRUE; |
What is the total quantity of items in inventory for customers in Australia in Q3 2022? | CREATE TABLE Inventory (id INT,customer VARCHAR(255),quantity INT,country VARCHAR(255),quarter INT,year INT); | SELECT SUM(quantity) FROM Inventory WHERE country = 'Australia' AND quarter = 3 AND year = 2022; |
Update the "mission" of the company with id 1 in the "tech_companies" table to 'Promote ethical AI' | CREATE TABLE tech_companies (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),mission VARCHAR(255)); | WITH updated_data AS (UPDATE tech_companies SET mission = 'Promote ethical AI' WHERE id = 1 RETURNING *) SELECT * FROM updated_data; |
What is the most common location for Trout_Farms? | CREATE TABLE Trout_Farms (Farm_ID INT,Farm_Name TEXT,Location TEXT,Production_Volume INT); INSERT INTO Trout_Farms (Farm_ID,Farm_Name,Location,Production_Volume) VALUES (1,'Farm X','Canada',200),(2,'Farm Y','US',250),(3,'Farm Z','Canada',300); | SELECT Location, COUNT(*) AS Count FROM Trout_Farms GROUP BY Location ORDER BY Count DESC LIMIT 1; |
What is the maximum sale quantity of products in the transparency_sales table? | CREATE TABLE transparency_sales (sale_id INT,product_id INT,sale_quantity INT); INSERT INTO transparency_sales (sale_id,product_id,sale_quantity) VALUES (1,1,20),(2,2,50),(3,3,15),(4,4,100),(5,5,15); | SELECT MAX(sale_quantity) FROM transparency_sales; |
What is the average financial wellbeing score for clients in urban areas? | CREATE TABLE clients(id INT,name TEXT,location TEXT,financial_wellbeing_score INT); | SELECT AVG(c.financial_wellbeing_score) FROM clients c WHERE c.location LIKE '%urban%'; |
Insert a new record into the 'Theater Performances' table for the participant 'Zoe' who attended the 'Comedy' event. | CREATE TABLE theater_performances (performance_id INT,participant_name VARCHAR(50),event_type VARCHAR(50)); INSERT INTO theater_performances (performance_id,participant_name,event_type) VALUES (1,'Ava','Drama'),(2,'Bella','Musical'),(3,'Chloe','Tragedy'); | INSERT INTO theater_performances (performance_id, participant_name, event_type) VALUES (4, 'Zoe', 'Comedy'); |
What is the total number of employees in the 'Mining Operations' department? | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,FirstName,LastName,Department) VALUES (1,'John','Doe','Mining Operations'); | SELECT COUNT(*) FROM Employees WHERE Department = 'Mining Operations'; |
What is the total climate finance for Southeast Asian projects in 2019? | CREATE TABLE climate_finance_projects (project_id INT,year INT,region VARCHAR(255),amount FLOAT); INSERT INTO climate_finance_projects VALUES (1,2019,'Southeast Asia',3000000); | SELECT SUM(amount) FROM climate_finance_projects WHERE region = 'Southeast Asia' AND year = 2019; |
What is the total grant amount awarded to graduate students in the Engineering department for the year 2022? | CREATE TABLE graduate_students (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO graduate_students (id,name,department) VALUES (1,'Charlie','Computer Science'); INSERT INTO graduate_students (id,name,department) VALUES (2,'Dana','Electrical Engineering'); CREATE TABLE research_grants (id INT,graduate_studen... | SELECT SUM(rg.amount) FROM research_grants rg JOIN graduate_students gs ON rg.graduate_student_id = gs.id WHERE gs.department = 'Engineering' AND rg.year = 2022; |
What is the total duration of Exoplanets research for each researcher since 2017? | CREATE TABLE Astrophysics_Research (id INT,research_name VARCHAR(255),researcher_id INT,field_of_study VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO Astrophysics_Research VALUES (1,'Dark Matter Research',1001,'Dark Matter','2015-01-01','2018-12-31'),(2,'Exoplanets Research',1002,'Exoplanets','2017-01-01','20... | SELECT researcher_id, SUM(DATEDIFF(end_date, start_date)) as total_days_researched FROM Astrophysics_Research WHERE field_of_study = 'Exoplanets' GROUP BY researcher_id; |
What is the total number of investigative journalism projects in 'Europe' and 'South America'? | CREATE TABLE projects (id INT,name TEXT,type TEXT,location TEXT); INSERT INTO projects VALUES (1,'Project A','investigative','Europe'); INSERT INTO projects VALUES (2,'Project B','regular','Europe'); CREATE TABLE regions (id INT,location TEXT); INSERT INTO regions VALUES (1,'South America'); INSERT INTO regions VALUE... | SELECT COUNT(projects.id) FROM projects INNER JOIN regions ON projects.location = regions.location WHERE regions.location IN ('Europe', 'South America') AND projects.type = 'investigative'; |
How many hospital beds are available in rural hospitals of New York? | CREATE TABLE hospital_bed (bed_id INT,hospital_id INT,type TEXT,status TEXT); CREATE TABLE hospital (hospital_id INT,name TEXT,location TEXT,beds INT); | SELECT a.location, SUM(b.beds) FROM hospital a INNER JOIN hospital_bed b ON a.hospital_id = b.hospital_id WHERE a.location LIKE '%rural%' AND b.status = 'available' GROUP BY a.location; |
Update the 'vehicle_type' to 'Hybrid' for records with 'fleet_number' 5678 in the 'TransitData' table | CREATE TABLE TransitData (bus_id INT,fleet_number INT,vehicle_type VARCHAR(10),PRIMARY KEY (bus_id)); | UPDATE TransitData SET vehicle_type = 'Hybrid' WHERE fleet_number = 5678; |
List the number of primary care physicians in each state | CREATE TABLE primary_care_physicians(id INT,name TEXT,state TEXT,specialty TEXT); INSERT INTO primary_care_physicians(id,name,state,specialty) VALUES (1,'Dr. Smith','California','Primary Care'),(2,'Dr. Johnson','California','Cardiology'),(3,'Dr. Brown','New York','Primary Care'),(4,'Dr. Davis','New York','Oncology'),(5... | SELECT state, COUNT(*) FROM primary_care_physicians WHERE specialty = 'Primary Care' GROUP BY state; |
What is the total conservation budget allocated for each region in the 'habitat_preservation' table? | CREATE TABLE habitat_preservation (region VARCHAR(255),budget INT); INSERT INTO habitat_preservation (region,budget) VALUES ('Asia',100000),('Africa',150000),('South_America',75000); | SELECT region, SUM(budget) as total_budget FROM habitat_preservation GROUP BY region; |
List all the music producers and their respective countries who have worked with artists from more than one country in 2021. | CREATE TABLE MusicProducers (ProducerName TEXT,Country TEXT,Year INTEGER,ArtistCountry TEXT); INSERT INTO MusicProducers (ProducerName,Country,Year,ArtistCountry) VALUES ('David Guetta','France',2021,'USA'),('Martin Garrix','Netherlands',2021,'Canada'),('Kygo','Norway',2021,'Australia'),('Alan Walker','Norway',2021,'Sw... | SELECT ProducerName, Country FROM MusicProducers WHERE Year = 2021 GROUP BY ProducerName, Country HAVING COUNT(DISTINCT ArtistCountry) > 1; |
What is the total number of alternative sentencing programs in the justice system? | CREATE TABLE alternative_sentencing_programs (id INT,program_name VARCHAR(255),num_participants INT); INSERT INTO alternative_sentencing_programs (id,program_name,num_participants) VALUES (1,'Community Service',500),(2,'Probation',800),(3,'Restorative Justice',300); | SELECT SUM(num_participants) FROM alternative_sentencing_programs; |
Which product category had the lowest total revenue in Massachusetts in 2021? | CREATE TABLE mass_sales (product VARCHAR(20),revenue DECIMAL(10,2),state VARCHAR(20),year INT); INSERT INTO mass_sales (product,revenue,state,year) VALUES ('Flower',70000,'Massachusetts',2021),('Concentrate',60000,'Massachusetts',2021),('Edibles',50000,'Massachusetts',2021); | SELECT product, MIN(revenue) as min_revenue FROM mass_sales WHERE state = 'Massachusetts' AND year = 2021 GROUP BY product; |
What was the total energy consumption for each department in H2 of 2022? | CREATE TABLE Departments (id INT,department VARCHAR(255)); INSERT INTO Departments (id,department) VALUES (1,'Design'),(2,'Production'),(3,'Marketing'),(4,'Logistics'); CREATE TABLE Energy_Consumption (id INT,department_id INT,year INT,H1 INT,H2 INT); INSERT INTO Energy_Consumption (id,department_id,year,H1,H2) VALUES ... | SELECT d.department, SUM(e.H2) FROM Energy_Consumption e JOIN Departments d ON e.department_id = d.id WHERE e.year = 2022 GROUP BY d.department; |
What's the total value of social impact investments in India? | CREATE TABLE investment_values(investment_id INT,investment_type VARCHAR(20),value FLOAT,country VARCHAR(10)); | SELECT SUM(value) FROM investment_values WHERE investment_type = 'social_impact' AND country = 'India'; |
What is the total budget spent on accessible technology by companies in the EU? | CREATE TABLE Companies (id INT,name TEXT,country TEXT,budget_accessible_tech FLOAT); INSERT INTO Companies (id,name,country,budget_accessible_tech) VALUES (1,'TechCo','Germany',250000),(2,'GreenTech','France',350000),(3,'EthicalLabs','UK',450000),(4,'Tech4All','Spain',500000),(5,'InclusiveTech','Italy',600000); | SELECT SUM(budget_accessible_tech) FROM Companies WHERE country IN ('Germany', 'France', 'UK', 'Spain', 'Italy'); |
What is the total carbon emissions reduction achieved by clean energy projects in the US since 2015? | CREATE TABLE projects (id INT,country VARCHAR(255),name VARCHAR(255),carbon_emissions_reduction INT,start_year INT); INSERT INTO projects (id,country,name,carbon_emissions_reduction,start_year) VALUES (1,'US','Project1',1500,2015),(2,'US','Project2',2000,2017),(3,'US','Project3',1000,2016); | SELECT SUM(carbon_emissions_reduction) FROM projects WHERE country = 'US' AND start_year >= 2015; |
How many customers in India ordered a vegan dish in the last month? | CREATE TABLE Menu (MenuID INT,MenuItem VARCHAR(50),MenuType VARCHAR(50),IsVegan BOOLEAN,Price DECIMAL(5,2)); INSERT INTO Menu (MenuID,MenuItem,MenuType,IsVegan,Price) VALUES (1,'Vegan Biryani','Meal',true,15.99); CREATE TABLE Orders (OrderID INT,MenuID INT,CustomerLocation VARCHAR(50),OrderDate DATE); INSERT INTO Order... | SELECT COUNT(*) FROM Orders JOIN Menu ON Orders.MenuID = Menu.MenuID WHERE Menu.IsVegan = true AND Menu.MenuType = 'Meal' AND Orders.OrderDate >= DATEADD(MONTH, -1, GETDATE()) AND CustomerLocation = 'India' AND MenuItem LIKE '%vegan%'; |
Find the average salary of members in the 'Transport_Union' having a safety_rating above 9. | CREATE TABLE Transport_Union (union_member_id INT,member_id INT,salary FLOAT,safety_rating FLOAT); INSERT INTO Transport_Union (union_member_id,member_id,salary,safety_rating) VALUES (1,101,65000.00,9.50),(1,102,62000.00,9.25),(2,201,68000.00,8.75),(2,202,66000.00,9.75); | SELECT AVG(salary) FROM Transport_Union WHERE safety_rating > 9; |
What is the total tonnage of cargo transported by vessels in the 'Fishing' category in the last month? | CREATE TABLE vessels (id INT,name TEXT,type TEXT);CREATE TABLE cargoes (id INT,vessel_id INT,tonnage INT,cargo_type TEXT); INSERT INTO vessels (id,name,type) VALUES (1,'Fishing Vessel A','Fishing'),(2,'Fishing Vessel B','Fishing'); INSERT INTO cargoes (id,vessel_id,tonnage,cargo_type) VALUES (1,1,1000,'Fish'),(2,1,2000... | SELECT SUM(cargoes.tonnage) FROM cargoes JOIN vessels ON cargoes.vessel_id = vessels.id WHERE vessels.type = 'Fishing' AND cargoes.id >= DATEADD('month', -1, CURRENT_DATE); |
What is the average temperature in the Arctic Circle in January? | CREATE TABLE Weather (location VARCHAR(50),month VARCHAR(10),avg_temp FLOAT); INSERT INTO Weather (location,month,avg_temp) VALUES ('Arctic Circle','January',-30.1); | SELECT avg_temp FROM Weather WHERE location = 'Arctic Circle' AND month = 'January' |
List the names of players who have scored the most points in a single match, in descending order, in the basketball_matches dataset. | CREATE TABLE basketball_matches (player VARCHAR(50),points INT,match_date DATE); | SELECT player FROM basketball_matches WHERE points = (SELECT MAX(points) FROM basketball_matches) ORDER BY points DESC; |
Update the 'count' to 30 for the 'company' 'Mercedes' in the 'charging_stations' table | CREATE TABLE charging_stations (company VARCHAR(255),city VARCHAR(255),charging_level VARCHAR(255),count INT); | UPDATE charging_stations SET count = 30 WHERE company = 'Mercedes'; |
List all vessels with safety incidents in the last 30 days | CREATE TABLE Vessels (VesselID varchar(10),LastInspectionDate date); CREATE TABLE SafetyIncidents (IncidentID int,VesselID varchar(10),IncidentDate date); INSERT INTO Vessels (VesselID,LastInspectionDate) VALUES ('VesselA','2021-06-01'),('VesselB','2021-07-01'); INSERT INTO SafetyIncidents (IncidentID,VesselID,Incident... | SELECT Vessels.VesselID FROM Vessels JOIN SafetyIncidents ON Vessels.VesselID = SafetyIncidents.VesselID WHERE SafetyIncidents.IncidentDate > DATEADD(day, -30, GETDATE()); |
What is the maximum number of research grants awarded to a single faculty member in the Biology department? | CREATE TABLE grants (id INT,faculty_id INT,department VARCHAR(50),year INT,amount FLOAT); INSERT INTO grants (id,faculty_id,department,year,amount) VALUES (1,1001,'Biology',2018,10000.00),(2,1001,'Biology',2019,15000.00),(3,1002,'Biology',2018,20000.00),(4,1003,'Biology',2019,5000.00); | SELECT MAX(amount) FROM grants WHERE faculty_id IN (SELECT faculty_id FROM grants WHERE department = 'Biology' GROUP BY faculty_id HAVING COUNT(DISTINCT year) > 1); |
List the total planting area for each crop type in Canada? | CREATE TABLE if NOT EXISTS crop_planting_3 (id int,crop varchar(50),planting_area float,country varchar(50)); INSERT INTO crop_planting_3 (id,crop,planting_area,country) VALUES (1,'Canola',35000,'Canada'),(2,'Wheat',50000,'Canada'); | SELECT crop, SUM(planting_area) FROM crop_planting_3 WHERE country = 'Canada' GROUP BY crop; |
Show the total cost of non-sustainable food items from suppliers located in 'GreenValley'. | CREATE TABLE Products (product_id INT,product_name VARCHAR(50),sustainable BOOLEAN,cost INT); CREATE TABLE SupplierProducts (supplier_id INT,product_id INT); INSERT INTO Products (product_id,product_name,sustainable,cost) VALUES (1,'Quinoa',true,5),(2,'Tofu',true,8),(3,'Beef',false,20); INSERT INTO SupplierProducts (su... | SELECT SUM(Products.cost) FROM Products INNER JOIN SupplierProducts ON Products.product_id = SupplierProducts.product_id INNER JOIN Vendors ON SupplierProducts.supplier_id = Vendors.vendor_id WHERE Vendors.location = 'GreenValley' AND Products.sustainable = false |
What is the number of public libraries and the number of books available in these libraries in California, and what is the average number of books per library in California? | CREATE TABLE public_libraries (library_name VARCHAR(50),state VARCHAR(20),num_books INT); INSERT INTO public_libraries (library_name,state,num_books) VALUES ('Library 1','California',50000),('Library 2','California',80000),('Library 3','California',60000); | SELECT COUNT(*) as num_libraries, SUM(num_books) as total_books, AVG(num_books) as avg_books_per_library FROM public_libraries WHERE state = 'California'; |
What is the minimum safety stock level for each chemical category, for chemical manufacturing in the North America region? | CREATE TABLE chemicals (id INT,name VARCHAR(255),category VARCHAR(255),safety_stock_level FLOAT,region VARCHAR(255)); | SELECT category, MIN(safety_stock_level) as min_level FROM chemicals WHERE region = 'North America' GROUP BY category; |
How many professional development courses have been completed by teachers from each school? | CREATE TABLE schools (school_id INT,school_name TEXT); CREATE TABLE teachers (teacher_id INT,teacher_name TEXT,school_id INT); CREATE TABLE courses (course_id INT,course_name TEXT,completion_date DATE); CREATE TABLE teacher_courses (teacher_id INT,course_id INT); INSERT INTO schools VALUES (1,'School A'),(2,'School B')... | SELECT s.school_name, COUNT(tc.course_id) FROM schools s INNER JOIN teachers t ON s.school_id = t.school_id INNER JOIN teacher_courses tc ON t.teacher_id = tc.teacher_id INNER JOIN courses c ON tc.course_id = c.course_id GROUP BY s.school_id; |
Identify the menu items that have a higher than average revenue for all menu items. | CREATE TABLE menu_items (menu_item_id INT,restaurant_id INT,name VARCHAR(255),revenue DECIMAL(10,2)); | SELECT m.name, AVG(o.revenue) OVER (PARTITION BY m.restaurant_id) AS avg_revenue FROM menu_items m JOIN orders o ON m.menu_item_id = o.menu_item_id WHERE m.revenue > AVG(o.revenue) OVER (PARTITION BY m.restaurant_id); |
What is the total number of players who prefer FPS and RPG games, and what is the average age of these players? | CREATE TABLE Players (PlayerID int,Age int,Gender varchar(10),GamePreference varchar(20)); INSERT INTO Players (PlayerID,Age,Gender,GamePreference) VALUES (1,25,'Male','FPS'); INSERT INTO Players (PlayerID,Age,Gender,GamePreference) VALUES (2,30,'Female','RPG'); | SELECT COUNT(*) AS PlayerCount, AVG(Age) AS AvgAge FROM Players WHERE GamePreference IN ('FPS', 'RPG'); |
How many sustainable building permits were issued between July 2021 and December 2021? | CREATE TABLE building_permit (id INT,project_name VARCHAR(255),issue_date DATE,expiration_date DATE,permit_type VARCHAR(50)); INSERT INTO building_permit (id,project_name,issue_date,expiration_date,permit_type) VALUES (2,'Wind Power','2021-07-15','2022-06-30','Sustainable'); | SELECT COUNT(*) FROM building_permit WHERE permit_type = 'Sustainable' AND issue_date BETWEEN '2021-07-01' AND '2021-12-31'; |
What is the monthly sales trend for ethical fashion products? | CREATE TABLE Sales (Product VARCHAR(50),Sales FLOAT,Date DATE); INSERT INTO Sales (Product,Sales,Date) VALUES ('T-Shirt',500,'2022-01-01'),('Trousers',700,'2022-01-01'),('Jacket',300,'2022-01-01'),('T-Shirt',600,'2022-02-01'),('Trousers',800,'2022-02-01'),('Jacket',350,'2022-02-01'); | SELECT DATE_TRUNC('month', Date) AS Month, AVG(Sales) FROM Sales GROUP BY Month ORDER BY Month; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.