instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
List all mobile subscribers in the Mumbai region who have used more than 75% of their data limit and have call usage less than 50 minutes.
CREATE TABLE mobile_subscribers (subscriber_id INT,name VARCHAR(50),data_plan VARCHAR(50),data_usage FLOAT,call_usage FLOAT,region VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id,name,data_plan,data_usage,call_usage,region) VALUES (1,'Farah Khan','1GB',750.0,40.0,'Mumbai');
SELECT subscriber_id, name, data_plan FROM mobile_subscribers WHERE region = 'Mumbai' AND data_usage > (SELECT data_usage * 0.75 FROM mobile_subscribers WHERE subscriber_id = m.subscriber_id) AND call_usage < 50;
Calculate the sum of all funding allocated for each project in the 'Funding_Allocation' table and the 'Projects' table, then remove duplicates.
CREATE TABLE Funding_Allocation (id INT,project VARCHAR(30),funding FLOAT); CREATE TABLE Projects (id INT,project VARCHAR(30),funding FLOAT);
SELECT project, SUM(funding) FROM Funding_Allocation GROUP BY project UNION SELECT project, SUM(funding) FROM Projects GROUP BY project
What is the total budget for support programs in the Australian region that were implemented after 2017?
CREATE TABLE support_programs_4 (id INT,name TEXT,region TEXT,budget FLOAT,start_year INT); INSERT INTO support_programs_4 (id,name,region,budget,start_year) VALUES (1,'Accessible Tech','Australia',50000.00,2017),(2,'Mobility Training','Australia',75000.00,2018);
SELECT SUM(budget) FROM support_programs_4 WHERE region = 'Australia' AND start_year > 2017;
What is the maximum confidence score and corresponding category added after February 2022?
CREATE TABLE threat_intel (id INT,indicator VARCHAR(255),category VARCHAR(100),confidence INT,date_added DATETIME); INSERT INTO threat_intel (id,indicator,category,confidence,date_added) VALUES (1,'example.com','Malware',90,'2022-03-05 09:30:00');
SELECT category, MAX(confidence) as max_confidence FROM threat_intel WHERE date_added > '2022-02-01' GROUP BY category HAVING max_confidence = (SELECT MAX(confidence) FROM threat_intel WHERE date_added > '2022-02-01');
Identify the top 5 most common genetic mutations in patients diagnosed with cancer and their corresponding treatment types.
CREATE SCHEMA if not exists genetic; USE genetic; CREATE TABLE if not exists patients (id INT,name VARCHAR(100),diagnosis VARCHAR(100)); CREATE TABLE if not exists mutations (id INT,patient_id INT,mutation VARCHAR(100)); CREATE TABLE if not exists treatments (id INT,patient_id INT,treatment_type VARCHAR(100)); INSERT INTO patients (id,name,diagnosis) VALUES (1,'PatientA','Cancer'),(2,'PatientB','Cancer'),(3,'PatientC','Cancer'); INSERT INTO mutations (id,patient_id,mutation) VALUES (1,1,'MutationA'),(2,1,'MutationB'),(3,2,'MutationA'),(4,3,'MutationC'),(5,3,'MutationD'); INSERT INTO treatments (id,patient_id,treatment_type) VALUES (1,1,'TreatmentX'),(2,1,'TreatmentY'),(3,2,'TreatmentX'),(4,3,'TreatmentZ');
SELECT mutations.mutation, treatments.treatment_type FROM genetic.mutations INNER JOIN genetic.patients ON mutations.patient_id = patients.id INNER JOIN genetic.treatments ON patients.id = treatments.patient_id WHERE patients.diagnosis = 'Cancer' GROUP BY mutations.mutation, treatments.treatment_type ORDER BY COUNT(mutations.mutation) DESC LIMIT 5;
What is the total quantity of items in warehouse 2, 3, 4, and 5?
CREATE TABLE warehouses (id INT,location VARCHAR(10),item VARCHAR(10),quantity INT); INSERT INTO warehouses (id,location,item,quantity) VALUES (1,'NY','A101',200),(2,'NJ','A101',300),(3,'CA','B203',150),(4,'NY','C304',50);
SELECT SUM(quantity) FROM warehouses WHERE id IN (2, 3, 4);
What is the minimum clearance height for bridges in the Northeast region that were constructed after 2010?
CREATE TABLE bridges (id INT,region VARCHAR(255),construction_date DATE,clearance_height_feet FLOAT); INSERT INTO bridges (id,region,construction_date,clearance_height_feet) VALUES (1,'Northeast','2011-05-02',16.4),(2,'Southeast','2015-08-17',14.7),(3,'Northeast','2018-11-09',18.2);
SELECT MIN(clearance_height_feet) FROM bridges WHERE region = 'Northeast' AND construction_date > '2010-01-01';
What is the total revenue for each category of vegan dishes in Canada?
CREATE TABLE sales (id INT,dish_id INT,date DATE,quantity INT,price DECIMAL(5,2));CREATE VIEW dishes_view AS SELECT d.id,d.name,c.category FROM dishes d JOIN categories c ON d.category_id = c.id;
SELECT c.category, SUM(s.quantity * s.price) AS total_revenue FROM sales s JOIN dishes_view d ON s.dish_id = d.id JOIN categories c ON d.category = c.id WHERE c.country = 'Canada' AND d.is_vegan = true GROUP BY c.category;
How many urban farms are there in Mexico and Argentina?
CREATE TABLE urban_farms (id INT,name TEXT,country TEXT); INSERT INTO urban_farms (id,name,country) VALUES (1,'Farm 1','Mexico'),(2,'Farm 2','Argentina');
SELECT COUNT(*) as count FROM urban_farms WHERE country IN ('Mexico', 'Argentina');
What is the total revenue generated from ticket sales for each city?
CREATE TABLE tickets (id INT,fan_id INT,game_id INT,purchase_date DATE,price DECIMAL(10,2)); CREATE TABLE games (id INT,sport VARCHAR(50),team VARCHAR(50),date DATE,city VARCHAR(50));
SELECT city, SUM(price) FROM tickets t INNER JOIN games g ON t.game_id = g.id GROUP BY city;
What is the distribution of green building types in the 'green_buildings' table, grouped by state?
CREATE TABLE green_buildings (state VARCHAR(255),building_type VARCHAR(255));
SELECT state, building_type, COUNT(*) AS building_count FROM green_buildings GROUP BY state, building_type;
What is the average range of electric vehicles in the 'green_vehicles' table?
CREATE TABLE green_vehicles (make VARCHAR(50),model VARCHAR(50),year INT,range INT);
SELECT AVG(range) FROM green_vehicles WHERE make = 'Tesla' OR make = 'Rivian';
What is the maximum ocean acidification level for each region?
CREATE TABLE regions (id INT,name TEXT,ocean_acidification FLOAT); CREATE VIEW region_ocean_acidification AS SELECT r.id,r.name,oa.acidification_level FROM regions r INNER JOIN ocean_acidification oa ON r.id = oa.region_id; CREATE TABLE ocean_acidification (id INT,region_id INT,acidification_level FLOAT);
SELECT r.name, MAX(oa.acidification_level) as max_acidification FROM regions r INNER JOIN region_ocean_acidification oa ON r.id = oa.id GROUP BY r.name;
What is the total number of defense diplomacy events held in Europe?
CREATE TABLE defense_diplomacy (region VARCHAR(255),event_count INT);
SELECT SUM(event_count) FROM defense_diplomacy WHERE region = 'Europe';
Which open pedagogy resources have been accessed by students in the last month, and how many times have they been accessed?
CREATE TABLE student_access (student_id INT,resource_id INT,access_date DATE); CREATE TABLE open_pedagogy_resources (resource_id INT,resource_name VARCHAR(255));
SELECT r.resource_name, COUNT(s.access_date) FROM student_access s INNER JOIN open_pedagogy_resources r ON s.resource_id = r.resource_id WHERE s.access_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY r.resource_name;
What is the minimum temperature recorded in Finland's Lapland?
CREATE TABLE TemperatureData (location VARCHAR(50),year INT,temperature FLOAT); INSERT INTO TemperatureData (location,year,temperature) VALUES ('Lapland',2000,-20.5),('Lapland',2001,-25.3),('Lapland',2002,-22.9);
SELECT location, MIN(temperature) FROM TemperatureData GROUP BY location;
What's the total budget for programs in arts and environment?
CREATE TABLE Programs (ProgramID INT,ProgramName TEXT,Budget DECIMAL(10,2),Category TEXT); INSERT INTO Programs (ProgramID,ProgramName,Budget,Category) VALUES (1,'Eco Warriors',8000.00,'Environment');
SELECT SUM(Budget) FROM Programs WHERE Category IN ('Arts', 'Environment');
What is the distribution of regulatory statuses for all decentralized applications in the 'dapps' table?
CREATE TABLE dapps (dapp_id INT,dapp_name TEXT,regulatory_status TEXT); INSERT INTO dapps (dapp_id,dapp_name,regulatory_status) VALUES (1,'DappA','Compliant'),(2,'DappB','Non-compliant'),(3,'DappC','Pending'),(4,'DappD','Compliant'),(5,'DappE','Pending'),(6,'DappF','Compliant'),(7,'DappG','Non-compliant'),(8,'DappH','Pending');
SELECT regulatory_status, COUNT(*) FROM dapps GROUP BY regulatory_status;
What is the budget for humanitarian missions in the last 2 years?
CREATE TABLE humanitarian_missions (mission_id INT,mission_name VARCHAR(255),year INT,budget INT); INSERT INTO humanitarian_missions (mission_id,mission_name,year,budget) VALUES (1,'Disaster Relief in Haiti',2018,5000000),(2,'Flood Relief in Pakistan',2019,10000000),(3,'Earthquake Relief in Nepal',2020,7500000),(4,'Hurricane Relief in Bahamas',2020,8000000),(5,'Volcano Relief in Philippines',2021,9000000);
SELECT year, SUM(budget) as total_budget FROM humanitarian_missions WHERE year BETWEEN (SELECT YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE) GROUP BY year;
How many volunteers joined health-focused non-profits in Spain in 2019?
CREATE TABLE volunteers_spain (id INT,volunteer_name TEXT,country TEXT,organization_type TEXT,join_date DATE); INSERT INTO volunteers_spain (id,volunteer_name,country,organization_type,join_date) VALUES (1,'Ana Sanchez','Spain','Health','2019-02-15'); INSERT INTO volunteers_spain (id,volunteer_name,country,organization_type,join_date) VALUES (2,'Juan Garcia','Spain','Health','2019-11-07');
SELECT COUNT(*) FROM volunteers_spain WHERE country = 'Spain' AND organization_type = 'Health' AND YEAR(join_date) = 2019;
Which restaurant locations had no food safety inspections in 2021?
CREATE TABLE location_inspection(location VARCHAR(255),inspection_year INT); INSERT INTO location_inspection VALUES ('Location A',2021); INSERT INTO location_inspection VALUES ('Location B',2020);
SELECT location FROM location_inspection WHERE inspection_year IS NULL OR inspection_year != 2021;
Drop the 'policyholders_new' table
CREATE TABLE policyholders_new (policyholder_id INT PRIMARY KEY,name VARCHAR(100),age INT,gender VARCHAR(10),city VARCHAR(50),state VARCHAR(50));
DROP TABLE policyholders_new;
Find the total number of sustainable cosmetic brands and their respective regions.
CREATE TABLE sustainable_brands (brand_id INT,brand_name VARCHAR(100),region VARCHAR(50),sustainable BOOLEAN); INSERT INTO sustainable_brands (brand_id,brand_name,region,sustainable) VALUES (1,'Kjaer Weis','North America',true),(2,'Antonym Cosmetics','Europe',true),(3,'Ilia Beauty','Asia',true),(4,'RMS Beauty','South America',true),(5,'Inika Organic','Australia',true);
SELECT region, COUNT(*) FROM sustainable_brands WHERE sustainable = true GROUP BY region;
What is the total budget for all AI applications in the field of explainable AI?
CREATE TABLE ExplainableAIs (id INT,name VARCHAR(255),budget DECIMAL(10,2));
SELECT SUM(budget) FROM ExplainableAIs;
List all the crops and their yields from 'regenerative_farms' table for region '01'
CREATE TABLE regenerative_farms (id INT,region VARCHAR(10),crop VARCHAR(20),yield INT);
SELECT crop, yield FROM regenerative_farms WHERE region = '01';
Identify the top 2 states with the highest installed solar energy capacity in the United States, ranked by capacity in descending order.
CREATE TABLE US_Solar_Energy (state VARCHAR(255),capacity INT); INSERT INTO US_Solar_Energy (state,capacity) VALUES ('California',30000),('Texas',25000),('Arizona',20000),('Nevada',18000);
SELECT state, capacity FROM (SELECT state, capacity, RANK() OVER (ORDER BY capacity DESC) AS rank FROM US_Solar_Energy) AS ranked_states WHERE rank <= 2;
List all cases with a 'family' case_type, along with the attorney who handled the case, sorted by the billing amount in descending order.
CREATE TABLE attorneys (id INT,name VARCHAR(20)); INSERT INTO attorneys (id,name) VALUES (1,'Smith'),(2,'Garcia'),(3,'Kim'); CREATE TABLE cases (id INT,attorney_id INT,case_type VARCHAR(10),billing_amount INT);
SELECT cases.id, attorney_id, case_type, billing_amount, attorneys.name FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.id WHERE case_type = 'family' ORDER BY billing_amount DESC;
List all 'safety_violations' and corresponding 'violation_category' for 'coal_mines' in 'West Virginia' from the 'safety_records' table?
CREATE TABLE safety_records (mine_type VARCHAR(50),mine_location VARCHAR(50),safety_violations VARCHAR(50),violation_category VARCHAR(50)); INSERT INTO safety_records (mine_type,mine_location,safety_violations,violation_category) VALUES ('coal_mines','West Virginia','Inadequate ventilation','Air Quality'),('coal_mines','West Virginia','Unsecured roof','Workplace Safety');
SELECT safety_violations, violation_category FROM safety_records WHERE mine_type = 'coal_mines' AND mine_location = 'West Virginia';
What is the minimum amount of funding received by a company founded by a native american founder?
CREATE TABLE company (id INT,name TEXT,founding_date DATE,industry TEXT,headquarters TEXT,native_american_founder BOOLEAN); CREATE TABLE funding_rounds (id INT,company_id INT,funding_amount INT,round_type TEXT,date DATE);
SELECT MIN(funding_amount) FROM funding_rounds JOIN company ON funding_rounds.company_id = company.id WHERE native_american_founder = TRUE;
Identify the top 3 donor countries by the total amount donated in the month of July, 2019, in descending order.
CREATE TABLE donors (donor_id INT,donor_name VARCHAR(50),donor_country VARCHAR(50),donation_amount DECIMAL(10,2),donation_date DATE); INSERT INTO donors (donor_id,donor_name,donor_country,donation_amount,donation_date) VALUES (1,'John Doe','USA',50.00,'2020-01-01');
SELECT donor_country, SUM(donation_amount) AS total_donation FROM donors WHERE MONTH(donation_date) = 7 AND YEAR(donation_date) = 2019 GROUP BY donor_country ORDER BY total_donation DESC LIMIT 3;
What was the total waste generation in kg for each city in the year 2020?
CREATE TABLE waste_generation(city VARCHAR(255),year INT,amount FLOAT); INSERT INTO waste_generation(city,year,amount) VALUES('CityA',2020,123.45),('CityB',2020,678.90);
SELECT city, SUM(amount) FROM waste_generation WHERE year = 2020 GROUP BY city;
Delete all records with a 'country' value of 'China' from the 'green_buildings' table
CREATE TABLE green_buildings (id INT PRIMARY KEY,name VARCHAR(100),country VARCHAR(50));
DELETE FROM green_buildings WHERE country = 'China';
Show AI models with inconsistent performance and safety scores.
CREATE TABLE ai_models (model_name TEXT,performance_score INTEGER,safety_score INTEGER); INSERT INTO ai_models (model_name,performance_score,safety_score) VALUES ('ModelX',85,90),('ModelY',70,75),('ModelZ',95,80);
SELECT model_name FROM ai_models WHERE performance_score < 80 AND safety_score < 80;
Count the number of fish species in the "fish_species" table for each region
create table fish_species (id integer,name text,family text,region text); insert into fish_species (id,name,family,region) values (1,'Salmon','Salmonidae','North Atlantic'); insert into fish_species (id,name,family,region) values (2,'Trout','Salmonidae','North Pacific'); insert into fish_species (id,name,family,region) values (3,'Tilapia','Cichlidae','Africa');
select region, count(*) from fish_species group by region;
What is the total amount of donations received by the 'Habitats for Turtles'?
CREATE TABLE Donations (id INT,campaign VARCHAR(255),amount DECIMAL(10,2));
SELECT SUM(amount) FROM Donations WHERE campaign = 'Habitats for Turtles';
What's the number of users who played a game in the last week in the 'gaming' schema?
CREATE TABLE users (id INT,username VARCHAR(50)); CREATE TABLE games (id INT,title VARCHAR(50)); CREATE TABLE gaming.user_games (user_id INT,game_id INT,play_date TIMESTAMP);
SELECT COUNT(*) FROM gaming.user_games JOIN users ON gaming.user_games.user_id = users.id WHERE gaming.user_games.play_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
Update the viewership count for TV Show C to 5 million
CREATE TABLE tv_shows (id INT,title VARCHAR(100),viewership_count INT); CREATE VIEW tv_show_view AS SELECT * FROM tv_shows; INSERT INTO tv_shows (id,title,viewership_count) VALUES (1,'TVShowA',3000000); INSERT INTO tv_shows (id,title,viewership_count) VALUES (2,'TVShowB',4000000);
UPDATE tv_shows SET viewership_count = 5000000 WHERE title = 'TV Show C';
What is the total value of transactions in the healthcare sector in Q2 2022?
CREATE TABLE transaction (transaction_id INT,sector VARCHAR(255),transaction_value DECIMAL(10,2),transaction_date DATE); INSERT INTO transaction (transaction_id,sector,transaction_value,transaction_date) VALUES (1,'healthcare',500.00,'2022-04-01'),(2,'healthcare',700.00,'2022-05-01');
SELECT SUM(transaction_value) FROM transaction WHERE sector = 'healthcare' AND transaction_date BETWEEN '2022-04-01' AND '2022-06-30';
How many viewers watched movies produced by studios with a budget over $1B?
CREATE TABLE StudioData (id INT,studio_name VARCHAR(100),studio_budget FLOAT,movie_id INT);
SELECT COUNT(DISTINCT movie_id) FROM StudioData WHERE studio_budget > 1000000000;
List the titles and artists of all jazz albums available on the 'mobile' platform.
CREATE TABLE artists (id INT,name TEXT,genre TEXT); CREATE TABLE albums (id INT,title TEXT,artist_id INT,platform TEXT); CREATE VIEW jazz_mobile_albums AS SELECT a.id,a.title,ar.name FROM albums a JOIN artists ar ON a.artist_id = ar.id WHERE ar.genre = 'jazz' AND a.platform = 'mobile';
SELECT title, name FROM jazz_mobile_albums;
Which ocean floor mapping projects and marine life research stations are located in the same regions?
CREATE TABLE ocean_floor_mapping_projects (id INT,name VARCHAR(255),region VARCHAR(255)); CREATE TABLE marine_life_research_stations (id INT,name VARCHAR(255),region VARCHAR(255));
SELECT o.name, m.name FROM ocean_floor_mapping_projects o INNER JOIN marine_life_research_stations m ON o.region = m.region;
What was the minimum fare for each vehicle type in the first half of 2021?
CREATE TABLE fare_collection (id INT,vehicle_type VARCHAR(20),fare_date DATE,fare FLOAT); INSERT INTO fare_collection (id,vehicle_type,fare_date,fare) VALUES (1,'Bus','2021-01-01',2.0),(2,'Tram','2021-01-03',2.5),(3,'Train','2021-01-05',3.0),(4,'Bus','2021-06-07',1.8),(5,'Tram','2021-06-09',2.3),(6,'Train','2021-06-11',2.8);
SELECT vehicle_type, MIN(fare) as min_fare FROM fare_collection WHERE fare_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY vehicle_type;
What is the average salary of employees by department?
CREATE TABLE departments (id INT,name VARCHAR(255)); INSERT INTO departments (id,name) VALUES (1,'HR'),(2,'IT'),(3,'Sales'); CREATE TABLE employees (id INT,name VARCHAR(255),department_id INT,salary INT); INSERT INTO employees (id,name,department_id,salary) VALUES (1,'Jane Doe',1,60000),(2,'Alice Smith',2,70000),(3,'Bob Johnson',3,80000);
SELECT departments.name, AVG(employees.salary) as avg_salary FROM departments JOIN employees ON departments.id = employees.department_id GROUP BY departments.name;
How many explainable AI research papers have been published by each country in the past year, and what is the average number of papers published per country?
CREATE TABLE ExplainableAIPapers (id INT,paper_title VARCHAR(50),country VARCHAR(50),publication_date DATE); INSERT INTO ExplainableAIPapers (id,paper_title,country,publication_date) VALUES (1,'LIME: A Unified Approach for Explaining Classifier Decisions','USA','2023-01-01'),(2,'SHAP: A Game Theoretic Approach to Explaining the Predictions of Any Machine Learning Model','Canada','2023-02-01'),(3,'Anchors: High-Precision Model-Agnostic Explanations','Germany','2023-03-01'),(4,'TreeExplainer: An Efficient Exact Algorithm for Model Agnostic Explanations','France','2023-04-01'),(5,'DeepLIFT: A Comprehensible Framework for Model-Agnostic Explanation','UK','2023-05-01');
SELECT country, COUNT(*) as paper_count FROM ExplainableAIPapers WHERE publication_date >= '2022-01-01' GROUP BY country; SELECT AVG(paper_count) as avg_paper_count FROM (SELECT country, COUNT(*) as paper_count FROM ExplainableAIPapers WHERE publication_date >= '2022-01-01' GROUP BY country) as subquery;
What is the maximum number of public meetings held in a single year by a department?
CREATE TABLE department (id INT PRIMARY KEY,name TEXT,city_id INT,FOREIGN KEY (city_id) REFERENCES city(id)); CREATE TABLE meeting (id INT PRIMARY KEY,date DATE,department_id INT,FOREIGN KEY (department_id) REFERENCES department(id));
SELECT department_id, MAX(YEAR(date)) as max_year, COUNT(*) as max_meetings FROM meeting GROUP BY department_id HAVING MAX(YEAR(date)) = max_year;
find the total number of research stations in Greenland and Canada, and the year they were established.
CREATE TABLE ResearchStations (id INT PRIMARY KEY,station VARCHAR(255),location VARCHAR(255),year INT); INSERT INTO ResearchStations (id,station,location,year) VALUES (1,'Station A','Greenland',1990); INSERT INTO ResearchStations (id,station,location,year) VALUES (2,'Station B','Canada',2005);
SELECT location, COUNT(*) as total_stations, MIN(year) as establishment_year FROM ResearchStations WHERE location IN ('Greenland', 'Canada') GROUP BY location;
What is the total quantity of garments sold by each brand, excluding those that have never been sold?
CREATE TABLE brands (brand_id INT,brand_name VARCHAR(50)); INSERT INTO brands (brand_id,brand_name) VALUES (1,'Versace'),(2,'Gucci'),(3,'Chanel'); CREATE TABLE sales (sale_id INT,brand_id INT,quantity INT); INSERT INTO sales (sale_id,brand_id,quantity) VALUES (1,1,10),(2,1,20),(3,2,30),(4,3,40),(5,3,50);
SELECT s.brand_id, SUM(s.quantity) AS total_quantity_sold FROM sales s WHERE s.quantity IS NOT NULL GROUP BY s.brand_id;
What is the total number of hospitals and total number of beds by state?
CREATE TABLE hospitals (id INT,name TEXT,city TEXT,state TEXT,beds INT); INSERT INTO hospitals (id,name,city,state,beds) VALUES (1,'General Hospital','Miami','Florida',500); INSERT INTO hospitals (id,name,city,state,beds) VALUES (2,'Memorial Hospital','Boston','Massachusetts',600);
SELECT state, COUNT(*) as hospital_count, SUM(beds) as total_beds FROM hospitals GROUP BY state;
What is the total number of satellites launched by country?
CREATE TABLE satellites (satellite_id INT,country VARCHAR(50)); INSERT INTO satellites (satellite_id,country) VALUES (1,'USA'),(2,'Russia'),(3,'China');
SELECT country, COUNT(*) as total_launched FROM satellites GROUP BY country;
What is the total weight of ingredients sourced from sustainable suppliers?
CREATE TABLE suppliers (id INT,name TEXT,sustainable BOOLEAN); INSERT INTO suppliers (id,name,sustainable) VALUES (1,'Green Fields',true),(2,'Wholesale Inc.',false),(3,'Local Harvest',true); CREATE TABLE purchases (supplier_id INT,weight FLOAT); INSERT INTO purchases (supplier_id,weight) VALUES (1,100.5),(1,200.2),(2,50.0),(3,150.5),(3,250.0);
SELECT SUM(purchases.weight) FROM purchases JOIN suppliers ON purchases.supplier_id = suppliers.id WHERE suppliers.sustainable = true;
What is the percentage of students who passed the mental health screening?
CREATE TABLE MentalHealthScreening (StudentID INT,Age INT,Gender VARCHAR(10),PassedScreening BOOLEAN); INSERT INTO MentalHealthScreening (StudentID,Age,Gender,PassedScreening) VALUES (1,22,'Male',true); INSERT INTO MentalHealthScreening (StudentID,Age,Gender,PassedScreening) VALUES (2,20,'Female',false); INSERT INTO MentalHealthScreening (StudentID,Age,Gender,PassedScreening) VALUES (3,25,'Male',true);
SELECT (COUNT(*) FILTER (WHERE PassedScreening = true)) * 100.0 / COUNT(*) FROM MentalHealthScreening;
Which countries in Europe have the highest number of digital assets under management?
CREATE TABLE digital_assets (id INT,name VARCHAR(50),country VARCHAR(10),value INT); INSERT INTO digital_assets (id,name,country,value) VALUES (1,'Asset1','Germany',1000),(2,'Asset2','France',2000),(3,'Asset3','Italy',3000);
SELECT country, COUNT(*) as num_assets, SUM(value) as total_value, RANK() OVER (ORDER BY SUM(value) DESC) as rank FROM digital_assets WHERE country IN ('Germany', 'France', 'Italy') GROUP BY country;
What is the recycling rate in the commercial sector in the city of San Francisco in 2021?
CREATE TABLE recycling_rates (city varchar(255),sector varchar(255),year int,recycling_rate float); INSERT INTO recycling_rates (city,sector,year,recycling_rate) VALUES ('San Francisco','Commercial',2021,75);
SELECT recycling_rate FROM recycling_rates WHERE city = 'San Francisco' AND sector = 'Commercial' AND year = 2021
What is the percentage of uninsured individuals in each age group, and how does it compare to the overall percentage of uninsured individuals?
CREATE TABLE AgeGroupData (AgeGroup VARCHAR(255),Uninsured DECIMAL(3,1)); INSERT INTO AgeGroupData (AgeGroup,Uninsured) VALUES ('0-18',6.0),('19-34',12.5),('35-49',8.0),('50-64',5.0),('65+',1.0); CREATE TABLE OverallData (OverallUninsured DECIMAL(3,1)); INSERT INTO OverallData (OverallUninsured) VALUES (10.0);
SELECT AgeGroup, Uninsured, Uninsured * 100.0 / (SELECT OverallUninsured FROM OverallData) AS Percentage FROM AgeGroupData;
What is the percentage of games won by each team in the 2022 NBA playoffs?
CREATE TABLE nba_teams (team_id INT,team_name VARCHAR(255)); INSERT INTO nba_teams VALUES (1,'TeamA'),(2,'TeamB'),(3,'TeamC'); CREATE TABLE nba_games (game_id INT,home_team_id INT,away_team_id INT,home_score INT,away_score INT,playoff_round VARCHAR(255)); INSERT INTO nba_games VALUES (1,1,2,90,85,'First Round'),(2,1,3,80,85,'First Round'),(3,2,1,95,90,'First Round'),(4,2,3,88,82,'First Round');
SELECT t.team_name, (SUM(CASE WHEN g.home_team_id = t.team_id THEN 1 ELSE 0 END) + SUM(CASE WHEN g.away_team_id = t.team_id THEN 1 ELSE 0 END) - SUM(CASE WHEN (g.home_team_id = t.team_id AND g.home_score < g.away_score) OR (g.away_team_id = t.team_id AND g.home_score > g.away_score) THEN 1 ELSE 0 END)) * 100.0 / COUNT(*) AS win_percentage FROM nba_teams t JOIN nba_games g ON t.team_id IN (g.home_team_id, g.away_team_id) WHERE g.playoff_round = 'First Round' GROUP BY t.team_name;
List all autonomous truck types and their average prices
CREATE TABLE av_types (av_id INT,av_type VARCHAR(50));CREATE TABLE av_prices (price_id INT,av_id INT,price DECIMAL(5,2));INSERT INTO av_types (av_id,av_type) VALUES (1,'Wayve Truck'),(2,'NVIDIA Truck'),(3,'Zoox Truck');INSERT INTO av_prices (price_id,av_id,price) VALUES (1,1,150000),(2,2,250000),(3,3,350000);
SELECT av.av_type, AVG(ap.price) as avg_price FROM av_types av JOIN av_prices ap ON av.av_id = ap.av_id WHERE av.av_type LIKE '%Truck' GROUP BY av.av_type;
What is the average playtime for each player in the "Shooter" genre?
CREATE TABLE PlayerPlaytime (PlayerID int,PlayerName varchar(50),Game varchar(50),Playtime decimal(10,2));
SELECT PlayerName, AVG(Playtime) OVER(PARTITION BY PlayerID) as AvgPlaytime FROM PlayerPlaytime WHERE Game = 'Shooter';
What is the total number of mental health parity violations recorded in the 'violations' table, for providers serving primarily patients who identify as LGBTQ+?
CREATE TABLE providers (id INT,name VARCHAR(50),language VARCHAR(50),parity_violations INT); INSERT INTO providers (id,name,language,parity_violations) VALUES (1,'Dr. Maria Garcia','Spanish',7),(2,'Dr. John Smith','English',3); CREATE TABLE violations (id INT,provider_id INT,date DATE); INSERT INTO violations (id,provider_id,date) VALUES (1,1,'2022-01-01'),(2,1,'2022-02-01'); CREATE TABLE patients (id INT,name VARCHAR(50),gender VARCHAR(50)); INSERT INTO patients (id,name,gender) VALUES (1,'John Doe','Male'),(2,'Jane Smith','Transgender');
SELECT SUM(v.parity_violations) FROM providers p JOIN violations v ON p.id = v.provider_id JOIN patients patient ON p.id = patient.id WHERE patient.gender LIKE '%Transgender%';
What is the minimum capacity (in MW) of operational biomass power projects in the 'Europe' region?
CREATE TABLE projects (id INT,name TEXT,region TEXT,capacity_mw FLOAT,status TEXT); INSERT INTO projects (id,name,region,capacity_mw,status) VALUES (1,'Biomass Project 1','Europe',30.6,'operational'); INSERT INTO projects (id,name,region,capacity_mw,status) VALUES (2,'Biomass Project 2','Europe',40.2,'construction');
SELECT MIN(capacity_mw) FROM projects WHERE type = 'biomass' AND status = 'operational';
What is the maximum donation amount made by a donor in France?
CREATE TABLE donors (donor_id int,donation_amount decimal(10,2),country varchar(50)); INSERT INTO donors (donor_id,donation_amount,country) VALUES (1,200.00,'France'),(2,100.00,'France'),(3,300.00,'France');
SELECT MAX(donation_amount) FROM donors WHERE country = 'France';
What is the total amount of climate finance provided by public and private sector in Latin America between 2015 and 2020?
CREATE TABLE climate_finance (sector VARCHAR(255),location VARCHAR(255),year INT,amount FLOAT); INSERT INTO climate_finance (sector,location,year,amount) VALUES ('Public','Brazil',2015,12000000),('Private','Colombia',2016,15000000),('Public','Argentina',2017,18000000),('Private','Peru',2018,20000000),('Public','Chile',2019,25000000),('Private','Mexico',2020,30000000);
SELECT SUM(amount) FROM climate_finance WHERE location LIKE 'Latin America%' AND sector IN ('Public', 'Private') AND year BETWEEN 2015 AND 2020;
List all the policy proposals that have been rejected by the state of California.
CREATE TABLE Proposals (State VARCHAR(255),Status VARCHAR(255),Proposal VARCHAR(255)); INSERT INTO Proposals (State,Status,Proposal) VALUES ('CA','Approved','Expand Medicaid'),('TX','Rejected','Establish Pre-K Program'),('CA','Rejected','Implement Carbon Tax');
SELECT Proposal FROM Proposals WHERE State = 'CA' AND Status = 'Rejected';
What is the minimum length (in seconds) of any song released in the 1970s?
CREATE TABLE songs (song_id INT,title VARCHAR(255),genre VARCHAR(50),release_year INT,length FLOAT); INSERT INTO songs (song_id,title,genre,release_year,length) VALUES (1,'Song1','Classical',1975,120.5),(2,'Song2','Jazz',1978,210.3),(3,'Song3','Rock',1972,150.7),(4,'Song4','Classical',1979,200.0);
SELECT MIN(length) FROM songs WHERE release_year >= 1970 AND release_year <= 1979;
What are the names and positions of all female staff members in the 'healthcare_staff' table?
CREATE TABLE healthcare_staff (name VARCHAR(255),gender VARCHAR(255),position VARCHAR(255),hospital_id INT); INSERT INTO healthcare_staff (name,gender,position,hospital_id) VALUES ('Dr. Jane Smith','Female','Doctor',1),('Dr. Maria Garcia','Female','Doctor',2);
SELECT name, position FROM healthcare_staff WHERE gender = 'Female';
Identify the total number of articles published by each author in the Investigative Journalism section.
CREATE TABLE articles (article_id INT,author_name VARCHAR(255),section VARCHAR(255)); INSERT INTO articles (article_id,author_name,section) VALUES (1,'John Doe','Investigative Journalism'),(2,'Jane Smith','Sports'),(3,'John Doe','Investigative Journalism');
SELECT author_name, section, COUNT(*) as total_articles FROM articles WHERE section = 'Investigative Journalism' GROUP BY author_name;
find the most popular size among customers
CREATE TABLE customer_size (id INT,name VARCHAR(50),size VARCHAR(20)); INSERT INTO customer_size (id,name,size) VALUES (1,'David','L'); INSERT INTO customer_size (id,name,size) VALUES (2,'Eva','M'); INSERT INTO customer_size (id,name,size) VALUES (3,'Frank','S'); INSERT INTO customer_size (id,name,size) VALUES (4,'Grace','XL');
SELECT size, COUNT(*) FROM customer_size GROUP BY size ORDER BY COUNT(*) DESC LIMIT 1;
What is the total energy consumption by sector in 2020?
CREATE TABLE energy_consumption (year INT,sector VARCHAR(255),consumption FLOAT); INSERT INTO energy_consumption (year,sector,consumption) VALUES (2015,'Residential',1234.5),(2015,'Commercial',2345.6),(2015,'Industrial',3456.7),(2020,'Residential',1567.8),(2020,'Commercial',2890.9),(2020,'Industrial',3901.0);
SELECT SUM(consumption) AS total_consumption, sector FROM energy_consumption WHERE year = 2020 GROUP BY sector;
Show the names of unions with collective bargaining agreements in the 'northeast' region.
CREATE TABLE unions (id INT,name TEXT,region TEXT,collective_bargaining BOOLEAN); CREATE TABLE union_details (id INT,union_id INT,contract_length INT);
SELECT DISTINCT name FROM unions JOIN union_details ON unions.id = union_details.union_id WHERE unions.region = 'northeast' AND unions.collective_bargaining = true;
Delete all games where the attendance was less than 5000.
CREATE TABLE Games (GameID INT,HomeAttendance INT,AwayAttendance INT);
DELETE FROM Games WHERE HomeAttendance + AwayAttendance < 5000;
How many new broadband subscribers were added in the last month in the 'Asia' region?
CREATE TABLE broadband_subscribers (id INT,region VARCHAR(20),subscription_date DATE); INSERT INTO broadband_subscribers (id,region,subscription_date) VALUES (1,'urban','2022-01-01'),(2,'rural','2022-03-15'),(3,'urban','2022-02-01'),(4,'asia','2022-03-25'),(5,'rural','2022-04-10');
SELECT COUNT(*) FROM broadband_subscribers WHERE region = 'asia' AND subscription_date BETWEEN DATE_SUB('2022-04-01', INTERVAL 1 MONTH) AND '2022-04-01';
Insert a new record into the 'Bridges' table for a bridge named 'Chesapeake Bay Bridge-Tunnel' with an ID of 3, located in 'Virginia Beach, VA', and added on '1964-04-15'.
CREATE TABLE Bridges (ID INT,Name VARCHAR(50),Location VARCHAR(50),DateAdded DATE); INSERT INTO Bridges (ID,Name,Location,DateAdded) VALUES (1,'Golden Gate Bridge','San Francisco,CA','1937-05-27'); INSERT INTO Bridges (ID,Name,Location,DateAdded) VALUES (2,'George Washington Bridge','New York,NY','1931-10-25');
INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (3, 'Chesapeake Bay Bridge-Tunnel', 'Virginia Beach, VA', '1964-04-15');
List all marine protected areas that are in the Southern Hemisphere.
CREATE TABLE marine_protected_areas (area_name TEXT,latitude DECIMAL(10,8),longitude DECIMAL(11,8)); INSERT INTO marine_protected_areas (area_name,latitude,longitude) VALUES ('Great Barrier Reef',-18.78,147.75),('Galapagos Islands',-0.79,-90.81);
SELECT area_name FROM marine_protected_areas WHERE latitude < 0;
Which cybersecurity strategies are located in the 'Africa' region from the 'Cyber_Strategies' table?
CREATE TABLE Cyber_Strategies (id INT,name VARCHAR(50),location VARCHAR(20),type VARCHAR(20),budget INT); INSERT INTO Cyber_Strategies (id,name,location,type,budget) VALUES (1,'Cyber Shield','Africa','Defense',8000000);
SELECT * FROM Cyber_Strategies WHERE location = 'Africa';
Create a table for storing information about sustainable sourcing practices.
CREATE TABLE sustainable_sourcing (sourcing_id INT,restaurant_id INT,supplier_name VARCHAR(50),sustainable_practices VARCHAR(50));
CREATE TABLE sustainable_sourcing (sourcing_id INT, restaurant_id INT, supplier_name VARCHAR(50), sustainable_practices VARCHAR(50));
What is the maximum fairness score for each AI algorithm in the 'creative_ai' database?
CREATE TABLE creative_ai.ai_algorithms (ai_algorithm_id INT PRIMARY KEY,ai_algorithm VARCHAR(255),fairness_score FLOAT); INSERT INTO creative_ai.ai_algorithms (ai_algorithm_id,ai_algorithm,fairness_score) VALUES (1,'Generative Adversarial Networks',0.75),(2,'Transformers',0.85),(3,'Deep Reinforcement Learning',0.65);
SELECT ai_algorithm, MAX(fairness_score) as max_fairness_score FROM creative_ai.ai_algorithms GROUP BY ai_algorithm;
List all the cities with a population of over 1 million people and having at least one green building certified by LEED?
CREATE TABLE cities (city_name VARCHAR(255),population INT,num_green_buildings INT); INSERT INTO cities (city_name,population,num_green_buildings) VALUES ('New York',8500000,5000),('Los Angeles',4000000,2500),('Chicago',2700000,1500),('Houston',2300000,1000),('Phoenix',1700000,750);
SELECT city_name FROM cities WHERE population > 1000000 AND num_green_buildings > 0;
How many community policing events happened in each neighborhood in 2020?
CREATE TABLE neighborhoods (neighborhood_id INT,neighborhood_name VARCHAR(255));CREATE TABLE community_policing (event_id INT,event_date DATE,neighborhood_id INT); INSERT INTO neighborhoods VALUES (1,'West Hill'),(2,'East End'); INSERT INTO community_policing VALUES (1,'2020-01-01',1),(2,'2020-02-01',2);
SELECT neighborhood_id, COUNT(*) as num_events FROM community_policing WHERE EXTRACT(YEAR FROM event_date) = 2020 GROUP BY neighborhood_id
How many medical supplies were delivered to region 'Asia'?
CREATE TABLE deliveries (id INT,item TEXT,region TEXT); INSERT INTO deliveries (id,item,region) VALUES (1,'Medical Supplies','Africa'); INSERT INTO deliveries (id,item,region) VALUES (2,'Water Purifiers','Asia'); INSERT INTO deliveries (id,item,region) VALUES (3,'Medical Supplies','Asia');
SELECT COUNT(*) FROM deliveries WHERE item = 'Medical Supplies' AND region = 'Asia';
Rank garments by the number of times they were sold, per country, and show only the top ranked garment in each country.
CREATE TABLE GarmentSales (SaleID INT,GarmentID INT,Country VARCHAR(255)); INSERT INTO GarmentSales (SaleID,GarmentID,Country) VALUES (1,1,'USA');
SELECT GarmentID, Country, ROW_NUMBER() OVER (PARTITION BY Country ORDER BY COUNT(*) DESC) as Rank FROM GarmentSales GROUP BY GarmentID, Country HAVING Rank = 1;
Which fields have the lowest average temperature in the 'field_temperatures' view?
CREATE VIEW field_temperatures AS SELECT fields.field_name,field_sensors.temperature,field_sensors.measurement_date FROM fields JOIN field_sensors ON fields.id = field_sensors.field_id;
SELECT field_name, AVG(temperature) as avg_temp FROM field_temperatures GROUP BY field_name ORDER BY avg_temp ASC LIMIT 1;
What is the maximum and minimum response time for police departments in urban areas with a population between 250,000 and 500,000?
CREATE TABLE police_departments (id INT,department_name VARCHAR(50),location VARCHAR(50),population INT,average_response_time FLOAT);
SELECT department_name, MAX(average_response_time) FROM police_departments WHERE population BETWEEN 250000 AND 500000 AND location = 'urban' GROUP BY department_name UNION ALL SELECT department_name, MIN(average_response_time) FROM police_departments WHERE population BETWEEN 250000 AND 500000 AND location = 'urban' GROUP BY department_name;
What are the cybersecurity budgets for each country in 2020?
CREATE TABLE cybersecurity_budgets (country TEXT,year INT,amount INT); INSERT INTO cybersecurity_budgets (country,year,amount) VALUES ('USA',2020,18000000000),('UK',2020,3200000000),('China',2020,5000000000);
SELECT country, amount FROM cybersecurity_budgets WHERE year = 2020;
Which public transportation systems have the highest ridership in country X?
CREATE TABLE pt_ridership (id INT,system VARCHAR,country VARCHAR,passengers INT);
SELECT system, passengers FROM pt_ridership WHERE country = 'X' ORDER BY passengers DESC LIMIT 10;
What is the age distribution of pottery artifacts in the 'site_b' excavation?
CREATE TABLE site_b_pottery (id INT PRIMARY KEY,age INT); INSERT INTO site_b_pottery (id,age) VALUES (1,500),(2,800),(3,1200),(4,750);
SELECT AVG(age), STDDEV(age), MIN(age), MAX(age) FROM site_b_pottery;
What is the average R&D expenditure for companies located in the United States?
CREATE TABLE company (id INT,name TEXT,country TEXT,rd_expenditure FLOAT); INSERT INTO company (id,name,country,rd_expenditure) VALUES (1,'ABC Pharma','USA',15000000); INSERT INTO company (id,name,country,rd_expenditure) VALUES (2,'XYZ Labs','USA',22000000);
SELECT AVG(rd_expenditure) FROM company WHERE country = 'USA';
What is the total number of animals in the South American wildlife conservation areas, broken down by conservation area and animal status (endangered, threatened, or stable)?
CREATE TABLE south_american_conservation_areas (id INT,name VARCHAR(255),area_size FLOAT); CREATE TABLE south_american_animal_population (id INT,conservation_area_id INT,species VARCHAR(255),animal_count INT,status VARCHAR(255));
SELECT sa.name, sap.status, SUM(sap.animal_count) as total_animals FROM south_american_conservation_areas sa JOIN south_american_animal_population sap ON sa.id = sap.conservation_area_id GROUP BY sa.name, sap.status;
How many esports events have been held in Asia by game genre?
CREATE TABLE esports_events (event_id INT,location VARCHAR(50),genre VARCHAR(50)); INSERT INTO esports_events (event_id,location,genre) VALUES (1,'Seoul,Korea','MOBA'),(2,'Beijing,China','FPS'),(3,'Tokyo,Japan','RTS');
SELECT genre, COUNT(*) AS num_events FROM esports_events WHERE location LIKE '%%Asia%%' GROUP BY genre;
What is the percentage of Indigenous workers at each mine site?
CREATE TABLE workforce_diversity (site_id INT,site_name TEXT,worker_id INT,worker_role TEXT,gender TEXT,age INT,ethnicity TEXT); INSERT INTO workforce_diversity (site_id,site_name,worker_id,worker_role,gender,age,ethnicity) VALUES (7,'RST Mine',7001,'Mining Engineer','Female',35,'Indigenous'),(8,'STU Mine',8001,'Miner','Male',45,'Non-Indigenous'),(9,'VWX Mine',9001,'Safety Manager','Male',50,'Indigenous'),(7,'RST Mine',7002,'Geologist','Female',28,'Non-Indigenous'),(8,'STU Mine',8002,'Miner','Female',38,'Indigenous');
SELECT site_name, (COUNT(*) FILTER (WHERE ethnicity = 'Indigenous')) * 100.0 / COUNT(*) as percentage_indigenous FROM workforce_diversity GROUP BY site_name;
How many conservation events were held in the ocean habitat last year?
CREATE TABLE conservation_events (id INT,event_name VARCHAR(50),location VARCHAR(50),date DATE,attendees INT); INSERT INTO conservation_events (id,event_name,location,date,attendees) VALUES (5,'Marine Life Exploration','Ocean','2022-02-20',75); INSERT INTO conservation_events (id,event_name,location,date,attendees) VALUES (6,'Underwater Cleanup','Ocean','2022-09-10',50);
SELECT COUNT(*) FROM conservation_events WHERE location = 'Ocean' AND date BETWEEN '2022-01-01' AND '2022-12-31';
Find the maximum salary of employees in the company, for each position
CREATE TABLE Employees (id INT,name VARCHAR(50),position VARCHAR(50),left_company BOOLEAN,salary DECIMAL(10,2));
SELECT position, MAX(salary) FROM Employees WHERE left_company = FALSE GROUP BY position;
What is the average number of artworks per artist?
CREATE TABLE Artists (ArtistID INT,Name TEXT);CREATE TABLE Artworks (ArtworkID INT,Title TEXT,Genre TEXT,ArtistID INT); INSERT INTO Artists (ArtistID,Name) VALUES (1,'Pablo Picasso'),(2,'Jackson Pollock'); INSERT INTO Artworks (ArtworkID,Title,Genre,ArtistID) VALUES (1,'Guernica','Cubism',1),(2,'The Old Guitarist','Blue Period',1),(3,'No. 5,1948','Abstract Expressionism',2);
SELECT AVG(ArtworksPerArtist) FROM (SELECT COUNT(Artworks.ArtworkID) AS ArtworksPerArtist FROM Artworks INNER JOIN Artists ON Artworks.ArtistID = Artists.ArtistID GROUP BY Artists.ArtistID) AS Subquery;
What is the average amount of funding allocated to businesses in the Health sector?
CREATE TABLE businesses (id INT,name TEXT,industry TEXT,ownership TEXT,funding FLOAT); INSERT INTO businesses (id,name,industry,ownership,funding) VALUES (1,'HealthCo','Health','Majority',200000.00); INSERT INTO businesses (id,name,industry,ownership,funding) VALUES (2,'TechCo','Technology','Minority',500000.00);
SELECT AVG(funding) FROM businesses WHERE industry = 'Health';
What is the minimum salary in healthcare unions for employees who work 35 hours per week or less?
CREATE TABLE healthcare_unions (id INT,employee_name TEXT,hours_worked INT,salary REAL); INSERT INTO healthcare_unions (id,employee_name,hours_worked,salary) VALUES (1,'Daniel Lee',30,60000.00),(2,'Emilia Garcia',35,65000.00),(3,'Fabian Kim',40,70000.00);
SELECT MIN(salary) FROM healthcare_unions WHERE hours_worked <= 35;
List all exhibitions with more than 1000 visitors.
CREATE TABLE exhibitions (id INT,name VARCHAR(100),visitors INT); INSERT INTO exhibitions (id,name,visitors) VALUES (1,'Modern Art',1500),(2,'Ancient History',800);
SELECT name FROM exhibitions WHERE visitors > 1000;
Which economic diversification initiatives from the 'economic_diversification' table have the same funding organization as any agricultural innovation projects in the 'rural_innovations' table?
CREATE TABLE rural_innovations (id INT,project_name VARCHAR(50),funding_org VARCHAR(50)); INSERT INTO rural_innovations (id,project_name,funding_org) VALUES (1,'Precision Agriculture','InnovateAfrica'),(2,'Smart Greenhouses','GrowMoreFund'); CREATE TABLE economic_diversification (id INT,initiative_name VARCHAR(50),funding_org VARCHAR(50)); INSERT INTO economic_diversification (id,initiative_name,funding_org) VALUES (1,'Handicraft Cooperative','LocalSupport'),(2,'Sustainable Tourism','GrowMoreFund');
SELECT initiative_name FROM economic_diversification WHERE funding_org IN (SELECT funding_org FROM rural_innovations);
How many energy efficient buildings are there in the 'Northeast' region with a Platinum LEED certification?
CREATE TABLE EnergyEfficientBuildings (region VARCHAR(50),certification VARCHAR(50));
SELECT COUNT(*) FROM EnergyEfficientBuildings WHERE region = 'Northeast' AND certification = 'Platinum LEED';
What is the top 5 most data-intensive days for mobile subscribers in the past month?
CREATE TABLE mobile_data_usage (usage_id INT,subscriber_id INT,data_usage FLOAT,usage_date DATE); INSERT INTO mobile_data_usage (usage_id,subscriber_id,data_usage,usage_date) VALUES (1,1,200,'2022-03-01'),(2,2,150,'2022-03-02'),(3,3,250,'2022-03-03'),(4,4,300,'2022-03-04'),(5,5,400,'2022-03-05'),(6,1,220,'2022-03-06');
SELECT usage_date, SUM(data_usage) AS total_data_usage FROM mobile_data_usage WHERE usage_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY usage_date ORDER BY total_data_usage DESC LIMIT 5;
What is the average labor cost for construction projects in Texas?
CREATE TABLE Construction_Projects (id INT,project_name TEXT,state TEXT,labor_cost INT);
SELECT AVG(labor_cost) FROM Construction_Projects WHERE state = 'Texas';
What is the total amount donated per age group?
CREATE TABLE AgeGroups (id INT,age_range VARCHAR(20)); INSERT INTO AgeGroups (id,age_range) VALUES (1,'18-24'),(2,'25-34'),(3,'35-44'); CREATE TABLE Donors (id INT,age_group INT,donation_id INT); INSERT INTO Donors (id,age_group,donation_id) VALUES (1,1,1001),(2,2,1002),(3,3,1003); CREATE TABLE Donations (id INT,donor_id INT,amount DECIMAL(10,2)); INSERT INTO Donations (id,donor_id,amount) VALUES (1001,1,50.00),(1002,2,75.00),(1003,3,100.00);
SELECT g.age_range, SUM(d.amount) as total_amount FROM Donors g JOIN Donations d ON g.id = d.donor_id GROUP BY g.age_range;
What is the number of hospitals and their respective rurality scores in Texas?
CREATE TABLE hospitals(id INT,name TEXT,location TEXT,rurality_score FLOAT); INSERT INTO hospitals(id,name,location,rurality_score) VALUES (1,'Hospital A','Texas',0.6),(2,'Hospital B','Texas',0.3),(3,'Hospital C','California',0.8);
SELECT COUNT(*) as hospital_count, rurality_score FROM hospitals WHERE location = 'Texas' GROUP BY rurality_score;