instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the average donation amount per program, per quarter? | CREATE TABLE programs (id INT,name VARCHAR(255)); INSERT INTO programs (id,name) VALUES (1,'Education'),(2,'Health'),(3,'Environment'); CREATE TABLE donations (id INT,program_id INT,donation_date DATE,amount DECIMAL(10,2)); INSERT INTO donations (id,program_id,donation_date,amount) VALUES (1,1,'2022-01-01',500),(2,1,'2022-01-02',300),(3,2,'2022-01-03',800),(4,3,'2022-01-04',400),(5,1,'2022-04-04',900),(6,2,'2022-04-05',200),(7,3,'2022-04-06',600); | SELECT program_id, DATE_TRUNC('quarter', donation_date) AS quarter, AVG(amount) OVER (PARTITION BY program_id, quarter) AS avg_donation_amount FROM donations; |
What is the total number of lifelong learning courses offered by each institution? | CREATE TABLE institution_lifelong_learning (institution_id INT,course_count INT); | SELECT institution_id, SUM(course_count) as total_courses FROM institution_lifelong_learning GROUP BY institution_id; |
What is the average number of public comments received per public meeting in the West? | CREATE TABLE public_comments (comment_id INT,comment_text TEXT,meeting_id INT); INSERT INTO public_comments (comment_id,comment_text,meeting_id) VALUES (1,'Comment A',1),(2,'Comment B',1),(3,'Comment C',2); CREATE TABLE public_meetings (meeting_id INT,meeting_name VARCHAR(255),state VARCHAR(255),region VARCHAR(255),meeting_date DATE); INSERT INTO public_meetings (meeting_id,meeting_name,state,region,meeting_date) VALUES (1,'Meeting A','California','West','2022-01-01'),(2,'Meeting B','Oregon','West','2022-02-01'); | SELECT AVG(cnt) FROM (SELECT meeting_id, COUNT(*) AS cnt FROM public_comments GROUP BY meeting_id) AS subquery JOIN public_meetings ON subquery.meeting_id = public_meetings.meeting_id WHERE region = 'West'; |
What is the average monthly usage of mobile customers who have used international roaming, segmented by country? | CREATE TABLE international_roaming_usage (customer_id INT,data_usage FLOAT,country VARCHAR(50)); INSERT INTO international_roaming_usage (customer_id,data_usage,country) VALUES (1,2000,'USA'),(2,1500,'Mexico'),(3,3000,'Canada'); | SELECT country, AVG(data_usage) AS avg_data_usage FROM international_roaming_usage WHERE used = TRUE GROUP BY country; |
What is the average ocean acidity level in the Arctic Ocean? | CREATE TABLE ocean_acidity (ocean VARCHAR(255),level FLOAT); INSERT INTO ocean_acidity (ocean,level) VALUES ('Arctic Ocean',7.8),('Antarctic Ocean',8.1); | SELECT AVG(level) FROM ocean_acidity WHERE ocean = 'Arctic Ocean'; |
Find the number of victims served by restorative justice programs in 2020 | CREATE TABLE restorative_justice_programs (program_id INT,year INT,victims_served INT); INSERT INTO restorative_justice_programs (program_id,year,victims_served) VALUES (1,2018,300),(2,2019,400),(3,2020,550),(4,2021,600); | SELECT SUM(victims_served) FROM restorative_justice_programs WHERE year = 2020; |
What is the minimum donation amount for the 'Arts' program? | CREATE TABLE Donations (donation_id INT,amount DECIMAL(10,2),program VARCHAR(255)); | SELECT MIN(amount) FROM Donations WHERE program = 'Arts'; |
What is the maximum number of points scored by a player in a single game in the 'basketball_scores' table? | CREATE TABLE basketball_scores (player VARCHAR(50),team VARCHAR(50),date DATE,points INT); INSERT INTO basketball_scores (player,team,date,points) VALUES ('LeBron James','Los Angeles Lakers','2022-01-01',50),('Kevin Durant','Brooklyn Nets','2022-01-02',45),('Giannis Antetokounmpo','Milwaukee Bucks','2022-01-03',55); | SELECT MAX(points) FROM basketball_scores; |
Find the number of art exhibits in each city, ordered by the number of exhibits in descending order. | CREATE TABLE Exhibits (exhibit_id INT,city VARCHAR(50)); INSERT INTO Exhibits (exhibit_id,city) VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'),(4,'New York'),(5,'Los Angeles'); | SELECT city, COUNT(*) as num_exhibits FROM Exhibits GROUP BY city ORDER BY num_exhibits DESC; |
Which clients have more than one account? | CREATE TABLE accounts (account_id INT,client_id INT,account_type VARCHAR(50)); INSERT INTO accounts VALUES (1,1,'Checking'),(2,2,'Savings'),(3,3,'Checking'),(4,1,'Credit Card'),(5,4,'Savings'); | SELECT client_id, COUNT(*) as account_count FROM accounts GROUP BY client_id HAVING account_count > 1; |
How many species of seals are there in the Antarctic Ocean?" | CREATE TABLE seals (id INT,species TEXT,location TEXT,population INT); INSERT INTO seals (id,species,location,population) VALUES (1,'Crabeater Seal','Antarctic',7500); | SELECT COUNT(species) FROM seals WHERE location = 'Antarctic Ocean'; |
Find the total points scored at home by the Lakers in the games table | CREATE TABLE teams (team_id INT,name VARCHAR(50),city VARCHAR(50)); CREATE TABLE games (game_id INT,team_id INT,home_team BOOLEAN,points INT); | SELECT SUM(games.points) AS total_points FROM teams INNER JOIN games ON teams.team_id = games.team_id WHERE teams.name = 'Lakers' AND games.home_team = TRUE; |
What is the total value of investments in the 'Technology' sector? | CREATE TABLE investments (investment_id INT,sector TEXT,value DECIMAL(10,2)); INSERT INTO investments (investment_id,sector,value) VALUES (1,'Technology',100000.00),(2,'Finance',200000.00),(3,'Technology',150000.00); | SELECT SUM(value) FROM investments WHERE sector = 'Technology'; |
List all economic diversification projects in the 'rural_economy' table, excluding those with a budget over 100000. | CREATE TABLE rural_economy (id INT,project_name VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO rural_economy (id,project_name,budget) VALUES (1,'Eco-Tourism',85000.00),(2,'Handicraft Production',65000.00); | SELECT project_name FROM rural_economy WHERE budget <= 100000; |
Calculate the percentage of autonomous taxis in the fleet | CREATE TABLE Fleet (VehicleID INT,VehicleType VARCHAR(50),Autonomous BOOLEAN); INSERT INTO Fleet (VehicleID,VehicleType,Autonomous) VALUES (1,'Taxi',true),(2,'Taxi',false),(3,'Shuttle',false),(4,'Autonomous Taxi',true),(5,'Sedan',false),(6,'Autonomous Shuttle',true); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Fleet)) as Percentage FROM Fleet WHERE Autonomous = true; |
What is the average water consumption per employee across all mines? | CREATE TABLE mines (id INT,name VARCHAR(255),water_consumption INT,number_of_employees INT); INSERT INTO mines (id,name,water_consumption,number_of_employees) VALUES (1,'Mine A',50000,200),(2,'Mine B',60000,250),(3,'Mine C',40000,180),(4,'Mine D',55000,220); | SELECT AVG(m.water_consumption/m.number_of_employees) as avg_water_consumption_per_employee FROM mines m; |
Update the sustainability_score for all suppliers from 'Country A' in the suppliers table to 85. | CREATE TABLE suppliers (id INT,name VARCHAR(255),country VARCHAR(255),sustainability_score INT); | UPDATE suppliers SET sustainability_score = 85 WHERE country = 'Country A'; |
What is the distribution of attendees by age group for the "Art in the Park" event? | CREATE TABLE event_attendance (attendee_id INT,event_id INT,age_group VARCHAR(20)); INSERT INTO event_attendance (attendee_id,event_id,age_group) VALUES (1,1,'5-17'),(2,1,'18-34'),(3,1,'35-54'),(4,1,'55+'); | SELECT age_group, COUNT(*) AS attendee_count FROM event_attendance WHERE event_id = 1 GROUP BY age_group; |
What is the average CO2 emission for buildings in the 'smart_cities' schema, excluding the top 10% highest emitters? | CREATE TABLE smart_cities.buildings (id INT,city VARCHAR(255),co2_emissions INT); CREATE VIEW smart_cities.buildings_view AS SELECT id,city,co2_emissions FROM smart_cities.buildings; | SELECT AVG(co2_emissions) FROM smart_cities.buildings_view WHERE co2_emissions NOT IN ( SELECT DISTINCT co2_emissions FROM ( SELECT co2_emissions, NTILE(10) OVER (ORDER BY co2_emissions DESC) as tile FROM smart_cities.buildings_view ) as subquery WHERE tile = 1 ); |
Update the 'Head of People Ops' salary to $150,000 in the EmployeeSalary table | CREATE TABLE EmployeeSalary (EmployeeID INT,JobTitleID INT,Salary INT,FOREIGN KEY (EmployeeID) REFERENCES Employee(EmployeeID),FOREIGN KEY (JobTitleID) REFERENCES JobTitle(JobTitleID)); | UPDATE EmployeeSalary SET Salary = 150000 WHERE JobTitleID = (SELECT JobTitleID FROM JobTitle WHERE JobTitleName = 'Head of People Ops'); |
What is the total weight in kg of all shipments from Spain? | CREATE TABLE shipments (id INT,supplier_id INT,country VARCHAR(255),weight DECIMAL(5,2)); INSERT INTO shipments (id,supplier_id,country,weight) VALUES (1,1,'Spain',25),(2,1,'Spain',30),(3,2,'France',20); | SELECT SUM(weight) FROM shipments WHERE country = 'Spain'; |
Add a new textile source 'Organic Silk' to the 'sources' table | CREATE TABLE sources (id INT PRIMARY KEY,source_name VARCHAR(50)); | INSERT INTO sources (id, source_name) VALUES (2, 'Organic Silk'); |
What is the total waste generation in India over the past 5 years? | CREATE TABLE WasteGenerationByCountry (country VARCHAR(50),year INT,amount INT); INSERT INTO WasteGenerationByCountry (country,year,amount) VALUES ('India',2017,300000),('India',2018,320000),('India',2019,350000),('India',2020,370000),('India',2021,400000); | SELECT SUM(amount) FROM WasteGenerationByCountry WHERE country = 'India'; |
What is the total funding amount for companies in the renewable energy sector that have a female founder? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_date DATE,founder_gender TEXT); INSERT INTO companies (id,name,industry,founding_date,founder_gender) VALUES (1,'GreenTech','Renewable Energy','2016-01-01','Female'); INSERT INTO companies (id,name,industry,founding_date,founder_gender) VALUES (2,'EcoFirm','Renewable Energy','2017-01-01','Male'); CREATE TABLE funding_records (id INT,company_id INT,funding_amount INT,funding_date DATE); INSERT INTO funding_records (id,company_id,funding_amount,funding_date) VALUES (1,1,500000,'2018-01-01'); INSERT INTO funding_records (id,company_id,funding_amount,funding_date) VALUES (2,2,750000,'2019-01-01'); | SELECT SUM(funding_amount) FROM funding_records JOIN companies ON funding_records.company_id = companies.id WHERE companies.industry = 'Renewable Energy' AND companies.founder_gender = 'Female' |
What is the maximum and minimum credit score for customers in each country? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),country VARCHAR(50),credit_score INT); INSERT INTO customers (customer_id,name,country,credit_score) VALUES (1,'John Doe','USA',750); INSERT INTO customers (customer_id,name,country,credit_score) VALUES (2,'Jane Smith','Canada',800); INSERT INTO customers (customer_id,name,country,credit_score) VALUES (3,'Alice Johnson','USA',600); | SELECT country, MIN(credit_score) as min_credit_score, MAX(credit_score) as max_credit_score FROM customers GROUP BY country; |
Determine the number of different fish species available in the 'fish_inventory' table. | CREATE TABLE fish_inventory (id INT PRIMARY KEY,species VARCHAR(50),quantity INT,location VARCHAR(50)); INSERT INTO fish_inventory (id,species,quantity,location) VALUES (1,'Salmon',50,'Tank A'),(2,'Tilapia',75,'Tank B'),(3,'Cod',100,'Tank C'); | SELECT COUNT(DISTINCT species) FROM fish_inventory; |
What is the average trip duration for shared electric cars in London? | CREATE TABLE shared_electric_cars (car_id INT,trip_start_time TIMESTAMP,trip_end_time TIMESTAMP,trip_distance FLOAT,city VARCHAR(50)); | SELECT AVG(TIMESTAMP_DIFF(trip_end_time, trip_start_time, MINUTE)) as avg_duration FROM shared_electric_cars WHERE city = 'London'; |
What is the total budget for agricultural innovation projects in Nepal that were completed after 2018? | CREATE TABLE innovation_projects (id INT,project_name VARCHAR(100),location VARCHAR(50),budget DECIMAL(10,2),completion_date DATE); INSERT INTO innovation_projects (id,project_name,location,budget,completion_date) VALUES (1,'Precision Farming','Nepal',65000.00,'2020-01-01'); INSERT INTO innovation_projects (id,project_name,location,budget,completion_date) VALUES (2,'Agroforestry Expansion','Nepal',80000.00,'2019-06-15'); | SELECT SUM(budget) FROM innovation_projects WHERE location = 'Nepal' AND completion_date > '2018-12-31'; |
Get the top 5 most liked posts in the social_media schema's posts table, ordered by the number of likes. | CREATE TABLE post_likes (like_id INT,post_id INT,user_id INT,like_date DATE); INSERT INTO post_likes (like_id,post_id,user_id,like_date) VALUES (1,1,1,'2021-01-01'),(2,1,2,'2021-01-02'),(3,2,3,'2021-01-03'),(4,2,4,'2021-01-04'),(5,3,5,'2021-01-05'),(6,1,6,'2021-01-06'),(7,3,7,'2021-01-07'),(8,3,8,'2021-01-08'),(9,2,9,'2021-01-09'),(10,3,10,'2021-01-10'); | SELECT posts.post_id, COUNT(post_likes.like_id) as num_likes FROM posts INNER JOIN post_likes ON posts.post_id = post_likes.post_id GROUP BY posts.post_id ORDER BY num_likes DESC LIMIT 5; |
Find the number of unique volunteers and donors who are from a country not represented in the Programs table. | CREATE TABLE Volunteers (id INT,name TEXT,country TEXT); INSERT INTO Volunteers (id,name,country) VALUES (1,'Ahmed Al-Saadi','Iraq'),(2,'Minh Nguyen','Vietnam'),(3,'Clara Gomez','Colombia'),(4,'Sofia Ahmed','Pakistan'); CREATE TABLE Donors (id INT,name TEXT,country TEXT); INSERT INTO Donors (id,name,country) VALUES (1,'Jose Garcia','Spain'),(2,'Anna Kuznetsova','Russia'),(3,'Jean-Pierre Dupont','France'),(5,'Lee Seung-Hun','South Korea'); CREATE TABLE Programs (id INT,name TEXT,country TEXT); INSERT INTO Programs (id,name,country) VALUES (1,'Global Literacy','USA'),(2,'Clean Water','Mexico'),(3,'Refugee Support','Syria'); | SELECT COUNT(DISTINCT Volunteers.country) + COUNT(DISTINCT Donors.country) - COUNT(DISTINCT Programs.country) as total_unique_countries FROM Volunteers FULL OUTER JOIN Donors ON Volunteers.country = Donors.country FULL OUTER JOIN Programs ON Volunteers.country = Programs.country WHERE Programs.country IS NULL; |
What is the average cost of military equipment sold in the Middle East in Q2 2022? | CREATE TABLE military_sales (id INT,region VARCHAR(20),quarter VARCHAR(10),year INT,cost FLOAT); INSERT INTO military_sales (id,region,quarter,year,cost) VALUES (1,'Middle East','Q2',2022,2500000); | SELECT AVG(cost) FROM military_sales WHERE region = 'Middle East' AND quarter = 'Q2' AND year = 2022; |
Update the price of the membership for Jane Smith to 80.00. | CREATE TABLE Memberships (id INT,member_name TEXT,region TEXT,price DECIMAL(5,2)); INSERT INTO Memberships (id,member_name,region,price) VALUES (1,'John Doe','San Francisco',50.00); INSERT INTO Memberships (id,member_name,region,price) VALUES (2,'Jane Smith','New York',75.00); | UPDATE Memberships SET price = 80.00 WHERE member_name = 'Jane Smith'; |
What is the average capacity of schools in the 'community_development' schema? | CREATE TABLE community_development.schools (id INT,name VARCHAR(50),capacity INT,location VARCHAR(50)); | SELECT AVG(capacity) FROM community_development.schools; |
Update the is_approved status of 'Green Vendor' in the sustainable_sourcing table. | CREATE TABLE sustainable_sourcing (supplier_id INT,supplier_name VARCHAR(255),is_approved BOOLEAN); INSERT INTO sustainable_sourcing (supplier_id,supplier_name,is_approved) VALUES (4,'Green Vendor',false); | UPDATE sustainable_sourcing SET is_approved = true WHERE supplier_name = 'Green Vendor'; |
List all records of donors who have donated more than $5000 in the 'emerging_market' region. | CREATE TABLE donors (id INT,name TEXT,region TEXT,donation_amount FLOAT); INSERT INTO donors (id,name,region,donation_amount) VALUES (1,'John Doe','Emerging_Market',5000.00),(2,'Jane Smith','Emerging_Market',6000.00); | SELECT * FROM donors WHERE region = 'Emerging_Market' AND donation_amount > 5000; |
What is the total number of users who have posted a tweet in the past month and who are located in a country with a population of over 100 million? | CREATE TABLE tweets (tweet_id INT,user_id INT,tweet_date DATE);CREATE TABLE users (user_id INT,country VARCHAR(50),registration_date DATE);CREATE TABLE country_populations (country VARCHAR(50),population INT); | SELECT COUNT(DISTINCT t.user_id) as num_users FROM tweets t JOIN users u ON t.user_id = u.user_id JOIN country_populations cp ON u.country = cp.country WHERE t.tweet_date >= DATE(NOW()) - INTERVAL 1 MONTH AND cp.population > 100000000; |
What is the percentage of sustainable menu items for each restaurant? | CREATE TABLE menu_items (restaurant_id INT,is_sustainable BOOLEAN); INSERT INTO menu_items (restaurant_id,is_sustainable) VALUES (1,TRUE),(1,FALSE),(2,TRUE),(2,TRUE),(3,FALSE),(3,TRUE); | SELECT restaurant_id, (COUNT(*) FILTER (WHERE is_sustainable = TRUE) * 100.0 / COUNT(*)) AS percentage FROM menu_items GROUP BY restaurant_id; |
Delete records in the food_safety table that have an inspection score below 70 | CREATE TABLE food_safety (id INT PRIMARY KEY,restaurant_id INT,inspection_date DATE,score INT); | DELETE FROM food_safety WHERE score < 70; |
What was the total sales revenue for 'DrugC' in the 'USA' region in Q2 2020? | CREATE TABLE sales_data (drug VARCHAR(50),region VARCHAR(50),quarter INT,year INT,revenue FLOAT); INSERT INTO sales_data (drug,region,quarter,year,revenue) VALUES ('DrugC','USA',2,2020,6000000); | SELECT SUM(revenue) FROM sales_data WHERE drug = 'DrugC' AND region = 'USA' AND quarter = 2 AND year = 2020; |
Which satellite images have anomalies in the past month for soybean fields? | CREATE TABLE satellite_image (id INT,field_id INT,image_url TEXT,anomaly BOOLEAN,timestamp TIMESTAMP); CREATE TABLE field (id INT,type VARCHAR(20)); | SELECT s.image_url FROM satellite_image s INNER JOIN field f ON s.field_id = f.id WHERE f.type = 'soybean' AND s.anomaly = true AND s.timestamp >= NOW() - INTERVAL '1 month'; |
Add records to the 'artifacts' table. | CREATE TABLE artifacts (id INT,artifact_type VARCHAR(255),material VARCHAR(255),analysis_date DATE); | INSERT INTO artifacts (id, artifact_type, material, analysis_date) VALUES (1, 'Pottery Shard', 'Clay', '2005-06-01'), (2, 'Bronze Sword', 'Bronze', '1500-01-01'); |
Which manufacturers in the Asian region have a safety score above 4.5 for their chemical products? | CREATE TABLE Manufacturers (ManufacturerID INT,ManufacturerName TEXT,Region TEXT); INSERT INTO Manufacturers (ManufacturerID,ManufacturerName,Region) VALUES (1,'ABC Chemicals','Asia'),(2,'XYZ Chemicals','North America'),(3,' DEF Chemicals','Asia'); CREATE TABLE ChemicalProducts (ProductID INT,Chemical TEXT,ManufacturerID INT,SafetyScore DECIMAL(3,2)); INSERT INTO ChemicalProducts (ProductID,Chemical,ManufacturerID,SafetyScore) VALUES (1,'Acetone',1,4.2),(2,'Ethanol',1,4.8),(3,'Methanol',2,5.0),(4,'Propanol',3,4.7),(5,'Butanol',3,4.9); | SELECT M.ManufacturerName FROM ChemicalProducts CP INNER JOIN Manufacturers M ON CP.ManufacturerID = M.ManufacturerID WHERE M.Region = 'Asia' AND CP.SafetyScore > 4.5; |
What is the average number of streams per day, by genre, for the last 30 days? | CREATE TABLE genre_streams (stream_id INT,genre VARCHAR(255),streams INT,stream_date DATE); CREATE VIEW daily_genre_streams AS SELECT genre,DATE_TRUNC('day',stream_date) as date,AVG(streams) as avg_streams FROM genre_streams WHERE stream_date >= DATEADD(day,-30,CURRENT_DATE) GROUP BY genre,date; | SELECT * FROM daily_genre_streams; |
What is the average salary of employees who have been with the company for more than 5 years? | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),Department VARCHAR(20),Salary FLOAT,YearsWithCompany INT); INSERT INTO Employees (EmployeeID,Gender,Department,Salary,YearsWithCompany) VALUES (1,'Male','IT',75000,6),(2,'Female','IT',70000,3),(3,'Male','HR',60000,8),(4,'Female','HR',65000,2),(5,'Male','IT',80000,1); | SELECT AVG(Salary) FROM Employees WHERE YearsWithCompany > 5; |
How many timber harvest permits were issued in each quarter of 2019? | CREATE TABLE harvest_permits (id INT,issue_quarter INT,issued_date DATE); | SELECT EXTRACT(QUARTER FROM issued_date) as quarter, COUNT(*) as num_permits FROM harvest_permits WHERE EXTRACT(YEAR FROM issued_date) = 2019 GROUP BY quarter; |
Create a view named 'ev_adoption_stats' based on 'electric_vehicle_adoption' table | CREATE TABLE electric_vehicle_adoption (id INT PRIMARY KEY,country VARCHAR(255),adoption_percentage DECIMAL(5,2)); | CREATE VIEW ev_adoption_stats AS SELECT * FROM electric_vehicle_adoption; |
Delete all records from table cargo_handling with port as 'Seattle' | CREATE TABLE cargo_handling (id INT PRIMARY KEY,cargo_id INT,port VARCHAR(20)); INSERT INTO cargo_handling (id,cargo_id,port) VALUES (1,101,'New York'),(2,102,'Seattle'),(3,103,'Buenos Aires'); | DELETE FROM cargo_handling WHERE port = 'Seattle'; |
Update a defendant record in the 'defendants' table | CREATE TABLE defendants (defendant_id INT PRIMARY KEY,name VARCHAR(255),age INT,gender VARCHAR(50),race VARCHAR(50),ethnicity VARCHAR(50),date_of_birth DATE,charges VARCHAR(255),case_number INT,case_status VARCHAR(50)); | UPDATE defendants SET charges = 'Assault', case_status = 'In Progress' WHERE defendant_id = 2003 AND case_number = 2022001; |
What is the age of each spy agency in each country? | CREATE TABLE SpyAgencies (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),year_found INT); INSERT INTO SpyAgencies (id,name,country,year_found) VALUES (1,'CIA','USA',1947); INSERT INTO SpyAgencies (id,name,country,year_found) VALUES (2,'MI6','UK',1909); | SELECT country, MAX(year_found) - MIN(year_found) AS age FROM SpyAgencies GROUP BY country; |
Calculate the revenue generated by each category of menu item in the last 30 days. | CREATE TABLE sales (sale_id INT,menu_item_id INT,sale_amount DECIMAL(10,2),sale_date DATE); INSERT INTO sales VALUES (1,1,50.00,'2022-02-01'),(2,2,75.00,'2022-03-01'),(3,3,60.00,'2022-02-02'),(4,1,100.00,'2022-03-02'); CREATE TABLE menu_items (menu_item_id INT,category VARCHAR(255)); INSERT INTO menu_items VALUES (1,'Entrees'),(2,'Soups'),(3,'Salads'); | SELECT c1.category, SUM(s1.sale_amount) AS total_revenue FROM sales s1 INNER JOIN menu_items m1 ON s1.menu_item_id = m1.menu_item_id INNER JOIN (SELECT menu_item_id, category FROM menu_items EXCEPT SELECT menu_item_id, category FROM menu_items WHERE menu_item_id NOT IN (SELECT menu_item_id FROM sales)) c1 ON m1.menu_item_id = c1.menu_item_id WHERE s1.sale_date > DATEADD(day, -30, GETDATE()) GROUP BY c1.category; |
What are the product names and their respective hazard categories from the product_hazard table? | CREATE TABLE product_hazard (product_name VARCHAR(255),hazard_category VARCHAR(255)); INSERT INTO product_hazard (product_name,hazard_category) VALUES ('ProductA','Flammable'),('ProductB','Corrosive'),('ProductC','Toxic'); | SELECT product_name, hazard_category FROM product_hazard; |
Which local economic impact initiatives were implemented in Spain? | CREATE TABLE EconomicImpact (id INT,name TEXT,country TEXT,initiative TEXT); INSERT INTO EconomicImpact (id,name,country,initiative) VALUES (1,'Barcelona Sustainable Business Program','Spain','Local Sourcing'),(2,'Madrid Green Spaces Expansion','Spain','Community Engagement'); | SELECT DISTINCT initiative FROM EconomicImpact WHERE country = 'Spain'; |
What is the average annual budget for schools located in cities with a population over 1,500,000 in the state of New York? | CREATE TABLE cities (city_name VARCHAR(255),population INT,state_abbreviation VARCHAR(255)); INSERT INTO cities (city_name,population,state_abbreviation) VALUES ('CityG',1800000,'NY'),('CityH',1200000,'NY'),('CityI',2000000,'NY'); CREATE TABLE schools (school_name VARCHAR(255),city_name VARCHAR(255),annual_budget INT); INSERT INTO schools (school_name,city_name,annual_budget) VALUES ('School6','CityG',900000),('School7','CityG',1000000),('School8','CityH',700000),('School9','CityI',1200000); | SELECT AVG(annual_budget) FROM schools INNER JOIN cities ON schools.city_name = cities.city_name WHERE cities.population > 1500000 AND cities.state_abbreviation = 'NY'; |
Delete all records from the aircraft_manufacturing table where the manufacturing_year is greater than 2020 | CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY,model VARCHAR(100),manufacturing_year INT); | DELETE FROM aircraft_manufacturing WHERE manufacturing_year > 2020; |
How many genetic research projects have been completed in Asian countries? | CREATE TABLE GeneticResearch (project_id INT,completion_date DATE,region VARCHAR(10)); INSERT INTO GeneticResearch (project_id,completion_date,region) VALUES (1,'2020-01-01','Asia'),(2,'2019-12-31','Africa'),(3,'2021-03-15','Europe'),(4,'2018-06-20','Americas'),(5,'2020-12-27','Asia'); | SELECT COUNT(project_id) FROM GeneticResearch WHERE region = 'Asia'; |
How many security incidents occurred in each region over the last year? | CREATE TABLE security_incidents (region VARCHAR(255),incident_date DATE); INSERT INTO security_incidents (region,incident_date) VALUES ('North America','2022-01-01'),('Europe','2022-02-01'),('Asia','2022-03-01'),('Asia','2022-04-01'),('Africa','2022-05-01'); | SELECT region, COUNT(*) as incident_count FROM security_incidents WHERE incident_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY region; |
How many volunteer hours were recorded for each program in H2 2020? | CREATE TABLE VolunteerHours (VolunteerID INT,ProgramID INT,Hours DECIMAL(5,2),HourDate DATE); INSERT INTO VolunteerHours (VolunteerID,ProgramID,Hours,HourDate) VALUES (1,1,5,'2020-07-15'),(2,2,3,'2020-11-02'),(1,1,4,'2020-12-31'); | SELECT ProgramID, SUM(Hours) as TotalHours FROM VolunteerHours WHERE HourDate BETWEEN '2020-07-01' AND '2020-12-31' GROUP BY ProgramID; |
Delete records in the 'crew_members' table where the nationality is 'Russian' and the position is 'Captain' | CREATE TABLE crew_members (id INT,name VARCHAR(50),nationality VARCHAR(20),position VARCHAR(20),hire_date DATE); INSERT INTO crew_members (id,name,nationality,position,hire_date) VALUES (1,'John Doe','Canadian','Captain','2000-01-01'); INSERT INTO crew_members (id,name,nationality,position,hire_date) VALUES (2,'Jane Smith','Russian','Captain','2005-01-01'); | DELETE FROM crew_members WHERE nationality = 'Russian' AND position = 'Captain'; |
What is the minimum budget for a single public works project in the state of California? | CREATE TABLE project (id INT PRIMARY KEY,name TEXT,budget INT,status TEXT,city_id INT,FOREIGN KEY (city_id) REFERENCES city(id)); | SELECT MIN(budget) FROM project WHERE city_id IN (SELECT id FROM city WHERE state = 'CA') AND status = 'Open'; |
What is the combined monthly usage of mobile data and calls for subscribers in the New York region, in descending order? | CREATE TABLE mobile_subscribers (subscriber_id INT,name VARCHAR(50),data_usage FLOAT,call_usage FLOAT,region VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id,name,data_usage,call_usage,region) VALUES (1,'Jane Smith',500.0,120.0,'New York'); | SELECT subscriber_id, name, data_usage + call_usage AS total_usage FROM mobile_subscribers WHERE region = 'New York' ORDER BY total_usage DESC; |
What is the percentage of autonomous taxis in Singapore? | CREATE TABLE autonomous_taxis (taxi_id INT,registration_date TIMESTAMP,taxi_type VARCHAR(50),city VARCHAR(50)); | SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM autonomous_taxis) as pct_autonomous_taxis FROM autonomous_taxis WHERE taxi_type = 'autonomous' AND city = 'Singapore'; |
Calculate the average population of each animal species across all years | CREATE TABLE animal_population (id INT PRIMARY KEY,species VARCHAR(255),population INT,year INT); | SELECT species, AVG(population) FROM animal_population GROUP BY species; |
How many social enterprises are in the 'Asia-Pacific' region? | CREATE TABLE social_enterprises (id INT,region VARCHAR(20)); INSERT INTO social_enterprises (id,region) VALUES (1,'Asia-Pacific'),(2,'Europe'),(3,'Asia-Pacific'),(4,'Americas'); | SELECT COUNT(*) FROM social_enterprises WHERE region = 'Asia-Pacific'; |
List the names and total calories burned for all workouts in the 'Cardio' category. | CREATE TABLE Workouts (WorkoutID INT,WorkoutName VARCHAR(20),Category VARCHAR(10)); INSERT INTO Workouts (WorkoutID,WorkoutName,Category) VALUES (1,'Treadmill','Cardio'),(2,'Yoga','Strength'),(3,'Cycling','Cardio'); CREATE TABLE CaloriesBurned (WorkoutID INT,CaloriesBurned INT); INSERT INTO CaloriesBurned (WorkoutID,CaloriesBurned) VALUES (1,300),(2,150),(3,400); | SELECT Workouts.WorkoutName, SUM(CaloriesBurned) FROM Workouts INNER JOIN CaloriesBurned ON Workouts.WorkoutID = CaloriesBurned.WorkoutID WHERE Workouts.Category = 'Cardio' GROUP BY Workouts.WorkoutName; |
What is the average number of legal aid applications approved per month for Indigenous communities? | CREATE TABLE LegalAid (ApplicationID INT,Applicant VARCHAR(20),Community VARCHAR(20),Approval BOOLEAN,SubmissionDate DATE); INSERT INTO LegalAid (ApplicationID,Applicant,Community,Approval,SubmissionDate) VALUES (1,'John Doe','Indigenous',TRUE,'2022-01-10'),(2,'Jane Smith','African American',FALSE,'2022-02-15'),(3,'Jim Brown','Asian',TRUE,'2022-03-05'); | SELECT AVG(COUNT(CASE WHEN Approval THEN 1 END)) FROM LegalAid WHERE Community = 'Indigenous' GROUP BY EXTRACT(MONTH FROM SubmissionDate); |
Which NGOs have worked in at least 3 different countries? | CREATE TABLE ngo_projects (id INT PRIMARY KEY,ngo_name TEXT,country TEXT); INSERT INTO ngo_projects (id,ngo_name,country) VALUES (1,'Medicins Sans Frontieres','Syria'); CREATE TABLE ngo_contacts (id INT PRIMARY KEY,ngo_name TEXT,contact_name TEXT); INSERT INTO ngo_contacts (id,ngo_name,contact_name) VALUES (1,'Medicins Sans Frontieres','John Doe'); | SELECT ngo_name FROM ngo_projects GROUP BY ngo_name HAVING COUNT(DISTINCT country) >= 3; |
What is the maximum speed of a vessel in the Pacific region? | CREATE TABLE vessel_performance (id INT,vessel_name TEXT,region TEXT,speed DECIMAL(5,2)); | SELECT MAX(speed) FROM vessel_performance WHERE region = 'Pacific'; |
Show the top 3 consumers and their total spending on ethical_fashion.com. | CREATE TABLE consumer_data (id INT,consumer VARCHAR(20),total_spent DECIMAL(6,2)); INSERT INTO consumer_data (id,consumer,total_spent) VALUES (1,'Anna',450.75),(2,'Bella',321.65),(3,'Charlie',578.30),(4,'David',102.50); | SELECT consumer, SUM(total_spent) as total_spending FROM consumer_data GROUP BY consumer ORDER BY total_spending DESC LIMIT 3; |
What is the average explainable_ai_algorithms complexity score? | CREATE TABLE explainable_ai_algorithms_scores (algorithm_id INTEGER,complexity_score FLOAT); | SELECT AVG(complexity_score) FROM explainable_ai_algorithms_scores; |
What was the total value of military equipment sales by Contractor Y in Q2 of 2020? | CREATE TABLE EquipmentSales (SaleID INT,Contractor VARCHAR(255),EquipmentType VARCHAR(255),Quantity INT,SalePrice DECIMAL(5,2)); INSERT INTO EquipmentSales (SaleID,Contractor,EquipmentType,Quantity,SalePrice) VALUES (1,'Contractor Y','Helicopter',5,5000000); | SELECT Contractor, SUM(Quantity * SalePrice) FROM EquipmentSales WHERE Contractor = 'Contractor Y' AND Quarter = 'Q2' AND Year = 2020 GROUP BY Contractor; |
What is the average veteran unemployment rate for the last 12 months, rounded to the nearest integer? | CREATE TABLE veteran_unemployment (unemployment_rate FLOAT,report_date DATE); INSERT INTO veteran_unemployment (unemployment_rate,report_date) VALUES (4.1,'2021-12-01'),(4.3,'2021-11-01'),(4.5,'2021-10-01'); | SELECT ROUND(AVG(unemployment_rate)) FROM veteran_unemployment WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH); |
What is the average launch cost for SpaceX missions? | CREATE TABLE SpaceExploration (mission_id INT,launch_cost INT,spacecraft VARCHAR(50)); | SELECT AVG(launch_cost) FROM SpaceExploration WHERE spacecraft = 'SpaceX'; |
Calculate the moving average of transaction amounts for the last 3 days. | CREATE TABLE Transactions (TransactionID INT,TransactionDate DATE,Amount DECIMAL(10,2)); INSERT INTO Transactions (TransactionID,TransactionDate,Amount) VALUES (1,'2022-01-01',500.00),(2,'2022-01-02',250.00),(3,'2022-01-03',750.00),(4,'2022-01-04',1500.00),(5,'2022-01-05',200.00),(6,'2022-01-06',300.00); | SELECT TransactionDate, AVG(Amount) OVER (ORDER BY TransactionDate ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as MovingAverage FROM Transactions; |
Determine the average billing rate per region | CREATE TABLE attorneys (id INT,name VARCHAR(50),cases_handled INT,region VARCHAR(50),billable_rate DECIMAL(10,2)); INSERT INTO attorneys (id,name,cases_handled,region,billable_rate) VALUES (1,'John Lee',40,'Northeast',200.00); INSERT INTO attorneys (id,name,cases_handled,region,billable_rate) VALUES (2,'Jane Doe',50,'Southwest',250.00); | SELECT region, AVG(billable_rate) as avg_billing_rate FROM attorneys GROUP BY region; |
What is the number of users who own a smartwatch, grouped by their fitness goal? | CREATE TABLE users (id INT,smartwatch BOOLEAN,fitness_goal VARCHAR(50)); INSERT INTO users (id,smartwatch,fitness_goal) VALUES (1,TRUE,'weight loss'),(2,FALSE,'muscle gain'),(3,TRUE,'weight loss'),(4,FALSE,'flexibility'),(5,TRUE,'muscle gain'); | SELECT fitness_goal, COUNT(*) as num_users FROM users WHERE smartwatch = TRUE GROUP BY fitness_goal; |
Show the total number of goals scored by the 'hockey_teams' table in descending order. | CREATE TABLE hockey_teams (team_id INT,team_name VARCHAR(30),goals INT); | SELECT team_name, SUM(goals) as total_goals FROM hockey_teams GROUP BY team_name ORDER BY total_goals DESC; |
What is the average length (in seconds) of all classical songs released in 2020? | CREATE TABLE songs (id INT,title TEXT,length FLOAT,genre TEXT,release_year INT); INSERT INTO songs (id,title,length,genre,release_year) VALUES (1,'Song1',245.6,'Pop',2019),(2,'Song2',189.3,'Rock',2020),(3,'Song3',215.9,'Pop',2018),(4,'Song4',150.2,'Hip Hop',2020),(5,'Song5',120.0,'Hip Hop',2019),(6,'Song6',360.0,'Jazz',2018),(7,'Song7',200.0,'Country',2020),(8,'Song8',220.0,'Country',2021),(9,'Song9',400.0,'Classical',2020),(10,'Song10',300.0,'Classical',2020); | SELECT AVG(length) FROM songs WHERE genre = 'Classical' AND release_year = 2020; |
Find the number of new attendees by month for art classes in 2021 | CREATE TABLE art_classes (id INT,attendee_id INT,class_month DATE);INSERT INTO art_classes (id,attendee_id,class_month) VALUES (1,101,'2021-01-01'),(2,102,'2021-02-01'),(3,103,'2021-01-01'); | SELECT EXTRACT(MONTH FROM class_month) AS month, COUNT(DISTINCT attendee_id) AS new_attendees FROM art_classes WHERE EXTRACT(YEAR FROM class_month) = 2021 GROUP BY month ORDER BY month; |
Find the number of students who have not published any papers. | CREATE TABLE Students (StudentID INT,FirstName VARCHAR(20),LastName VARCHAR(20),NumberOfPublications INT); | SELECT COUNT(*) FROM Students WHERE NumberOfPublications = 0; |
What is the total waste generated by packaging materials per week? | CREATE TABLE inventory (ingredient_id INT,ingredient_name VARCHAR(50),packaging_type VARCHAR(50),quantity INT,order_date DATE); INSERT INTO inventory VALUES (1,'Tomatoes','Plastic',100,'2022-01-01'),(2,'Chicken','Cardboard',50,'2022-01-02'),(3,'Lettuce','Biodegradable',80,'2022-01-03'); CREATE TABLE packaging (packaging_id INT,packaging_type VARCHAR(50),is_recyclable BOOLEAN,weekly_waste INT); INSERT INTO packaging VALUES (1,'Plastic',false,5),(2,'Cardboard',true,2),(3,'Biodegradable',true,1); | SELECT SUM(packaging.weekly_waste) FROM inventory INNER JOIN packaging ON inventory.packaging_type = packaging.packaging_type WHERE inventory.order_date >= '2022-01-01' AND inventory.order_date < '2022-01-08'; |
Calculate the total salary paid to the 'engineering' department | CREATE TABLE salaries_dept (id INT,employee VARCHAR(50),department VARCHAR(50),salary DECIMAL(10,2)); INSERT INTO salaries_dept (id,employee,department,salary) VALUES (1,'John Doe','manufacturing',50000.00),(2,'Jane Smith','engineering',65000.00),(3,'Alice Johnson','engineering',60000.00); | SELECT SUM(salary) FROM salaries_dept WHERE department = 'engineering'; |
What was the daily average production of oil in 'Brazil' in 2018? | CREATE TABLE wells (well_id INT,field VARCHAR(50),region VARCHAR(50),production_oil FLOAT,production_gas FLOAT,production_date DATE); INSERT INTO wells (well_id,field,region,production_oil,production_gas,production_date) VALUES (1,'Lula','Brazil',15000.0,5000.0,'2018-01-01'),(2,'Buzios','Brazil',8000.0,6000.0,'2018-02-01'); | SELECT AVG(production_oil) FROM wells WHERE region = 'Brazil' AND YEAR(production_date) = 2018; |
What is the average age of readers who prefer 'Entertainment' news category and are from Canada? | CREATE TABLE readers (id INT,name VARCHAR(50),age INT,preferred_category VARCHAR(20)); INSERT INTO readers (id,name,age,preferred_category) VALUES (1,'John Doe',25,'Sports'); | SELECT AVG(age) FROM readers WHERE preferred_category = 'Entertainment' AND country = 'Canada' |
Show the number of public works projects in each state | CREATE TABLE Public_Works (project_id int,project_name varchar(255),state varchar(255),category varchar(255)); | SELECT state, COUNT(*) FROM Public_Works GROUP BY state; |
Show the total number of menu items in each category. | CREATE TABLE menu_items (item_id INT,name VARCHAR(255),category VARCHAR(255)); INSERT INTO menu_items (item_id,name,category) VALUES (1,'Burger','Main Course'),(2,'Salad','Side Dish'),(3,'Pizza','Main Course'); | SELECT category, COUNT(item_id) as total_items FROM menu_items GROUP BY category; |
Which menu items have a higher inventory cost than sales revenue in the past month? | CREATE TABLE Sales (sale_id INT PRIMARY KEY,menu_item VARCHAR(50),sale_quantity INT,sale_price DECIMAL(5,2),sale_date DATE); CREATE TABLE Inventory (inventory_id INT PRIMARY KEY,menu_item VARCHAR(50),inventory_quantity INT,inventory_cost DECIMAL(5,2),inventory_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY,menu_item_category VARCHAR(50)); | SELECT i.menu_item FROM Inventory i JOIN Menu m ON i.menu_item = m.menu_item JOIN Sales s ON i.menu_item = s.menu_item WHERE i.inventory_cost > s.sale_price * s.sale_quantity AND i.inventory_date >= DATEADD(month, -1, GETDATE()); |
Which sustainable materials have the least and most inventory available across all factories? | CREATE TABLE materials (material_id INT,name VARCHAR(255),is_sustainable BOOLEAN); INSERT INTO materials VALUES (1,'Hemp Fiber',true); INSERT INTO materials VALUES (2,'Bamboo Fabric',true); INSERT INTO materials VALUES (3,'Nylon',false); CREATE TABLE inventory (inventory_id INT,material_id INT,factory_id INT,quantity INT); INSERT INTO inventory VALUES (1,1,1,1200); INSERT INTO inventory VALUES (2,2,2,500); INSERT INTO inventory VALUES (3,3,1,800); | SELECT material.name, MAX(inventory.quantity) AS max_quantity, MIN(inventory.quantity) AS min_quantity FROM material JOIN inventory ON material.material_id = inventory.material_id WHERE material.is_sustainable = true GROUP BY material.name; |
Find the average age of policyholders in 'RegionA' and 'RegionB'. | CREATE TABLE Policyholders (PolicyID INT,Age INT,Region VARCHAR(10)); INSERT INTO Policyholders (PolicyID,Age,Region) VALUES (1,35,'RegionA'),(2,42,'RegionB'); | SELECT AVG(Age) FROM Policyholders WHERE Region IN ('RegionA', 'RegionB'); |
What is the number of vessels that had a safety incident in the past year, by vessel type? | CREATE TABLE safety_incidents (vessel_id INT,incident_date DATE,vessel_type VARCHAR(50)); | SELECT vessel_type, COUNT(*) FROM safety_incidents WHERE incident_date >= DATEADD(year, -1, GETDATE()) GROUP BY vessel_type; |
What is the average age of residents in 'CityData' table, grouped by city? | CREATE TABLE CityData (city VARCHAR(50),age INT); INSERT INTO CityData (city,age) VALUES ('CityA',35),('CityA',40),('CityB',28),('CityB',32); | SELECT city, AVG(age) FROM CityData GROUP BY city; |
What is the average size of green buildings in city 1? | CREATE TABLE city (id INT,name VARCHAR(255),population INT,sustainable_projects INT); INSERT INTO city (id,name,population,sustainable_projects) VALUES (1,'San Francisco',884363,450); INSERT INTO city (id,name,population,sustainable_projects) VALUES (2,'Los Angeles',4000000,650); CREATE TABLE building (id INT,name VARCHAR(255),city_id INT,size FLOAT,is_green BOOLEAN); INSERT INTO building (id,name,city_id,size,is_green) VALUES (1,'City Hall',1,12000.0,true); INSERT INTO building (id,name,city_id,size,is_green) VALUES (2,'Library',1,8000.0,false); | SELECT AVG(size) as avg_size FROM building WHERE city_id = 1 AND is_green = true; |
What are the regulatory frameworks for a specific digital asset? | CREATE TABLE regulatory_frameworks (framework_id INT,asset_id INT,country VARCHAR(255),name VARCHAR(255),description TEXT); | SELECT rf.name, rf.description FROM regulatory_frameworks rf JOIN digital_assets da ON rf.asset_id = da.asset_id WHERE da.name = 'Ethereum'; |
Delete records with no end_date in the community_development table | CREATE TABLE community_development (id INT PRIMARY KEY,name VARCHAR(255),description TEXT,start_date DATE,end_date DATE); | WITH cte AS (DELETE FROM community_development WHERE end_date IS NULL) SELECT * FROM cte; |
What is the maximum CO2 emission reduction of renewable energy projects in the RenewableEnergy schema? | CREATE TABLE RenewableEnergy (ProjectID INT,CO2EmissionReduction FLOAT); | select max(CO2EmissionReduction) as max_reduction from RenewableEnergy; |
What is the total transaction amount per country, excluding the Gaming category? | CREATE TABLE Countries (id INT PRIMARY KEY,country VARCHAR(50),region VARCHAR(50)); INSERT INTO Countries (id,country,region) VALUES (1,'USA','North America'); INSERT INTO Countries (id,country,region) VALUES (2,'Canada','North America'); | SELECT c.country, SUM(t.amount) FROM Transactions t INNER JOIN Users u ON t.user_id = u.id INNER JOIN Countries c ON u.country = c.country INNER JOIN Smart_Contracts sc ON t.smart_contract_id = sc.id WHERE sc.category != 'Gaming' GROUP BY c.country; |
How many jobs have been created in rural infrastructure projects by sector? | CREATE TABLE RuralInfrastructure (id INT,project_id INT,type VARCHAR(255),sector VARCHAR(255),jobs_created INT); CREATE TABLE AgriculturalProjects (id INT,project_name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE,budget FLOAT); INSERT INTO AgriculturalProjects (id,project_name,location,start_date,end_date,budget) VALUES (1,'Drip Irrigation','Village B','2018-01-01','2019-01-01',5000.00); INSERT INTO RuralInfrastructure (id,project_id,type,sector,jobs_created) VALUES (1,1,'Electricity','Agriculture',20); | SELECT AgriculturalProjects.location, RuralInfrastructure.sector, SUM(RuralInfrastructure.jobs_created) as total_jobs_created FROM AgriculturalProjects INNER JOIN RuralInfrastructure ON AgriculturalProjects.id = RuralInfrastructure.project_id WHERE AgriculturalProjects.location LIKE 'Village%' GROUP BY AgriculturalProjects.location, RuralInfrastructure.sector; |
What is the average network investment per quarter in the 'Asia' region? | CREATE TABLE network_investments (quarter VARCHAR(10),region VARCHAR(10),investment FLOAT); INSERT INTO network_investments (quarter,region,investment) VALUES ('Q1','Asia',500000.0),('Q2','Asia',600000.0); | SELECT quarter, AVG(investment) FROM network_investments WHERE region = 'Asia' GROUP BY quarter; |
List all space agencies with their corresponding country, including joined data from the 'space_agencies' and 'countries' tables. | CREATE TABLE countries (country VARCHAR(50),population INT); INSERT INTO countries (country,population) VALUES ('China',1439323776),('USA',331002651),('Russia',145934462),('India',1380004385),('Japan',126476461); CREATE TABLE space_agencies (country VARCHAR(50),agency VARCHAR(50)); INSERT INTO space_agencies (country,agency) VALUES ('China','China National Space Administration'),('USA','National Aeronautics and Space Administration'),('Russia','Roscosmos'),('India','Indian Space Research Organisation'),('Japan','Japan Aerospace Exploration Agency'); | SELECT sa.country, sa.agency AS space_agency FROM space_agencies sa INNER JOIN countries c ON sa.country = c.country; |
Who are the advocates and their total budgets for visual support programs? | CREATE TABLE Advocates (Advocate VARCHAR(30),Program VARCHAR(20),Budget INT); INSERT INTO Advocates (Advocate,Program,Budget) VALUES ('Carlos Gonzalez','Low Vision Services',50000); INSERT INTO Advocates (Advocate,Program,Budget) VALUES ('Fatima Patel','Braille Services',65000); | SELECT Advocate, SUM(Budget) FROM Advocates WHERE Program LIKE '%Visual%' GROUP BY Advocate; |
What is the average regulatory status duration for digital assets? | CREATE TABLE AssetRegulatoryDurations (AssetID int,AssetType varchar(50),RegulatoryStatus varchar(50),Duration int); INSERT INTO AssetRegulatoryDurations (AssetID,AssetType,RegulatoryStatus,Duration) VALUES (1,'Cryptocurrency','Regulated',36),(2,'Security Token','Partially Regulated',12),(3,'Utility Token','Unregulated',24),(4,'Stablecoin','Partially Regulated',48),(5,'Cryptocurrency','Unregulated',60); | SELECT AssetType, AVG(Duration) as AvgRegulatoryDuration FROM AssetRegulatoryDurations GROUP BY AssetType; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.