instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the breakdown of multimodal mobility usage by city?
CREATE TABLE MultimodalMobilityUsage(City VARCHAR(50),Mode VARCHAR(50),Usage FLOAT);
SELECT City, Mode, SUM(Usage) FROM MultimodalMobilityUsage GROUP BY City, Mode;
Count the number of suppliers from the United States.
CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),sustainable BOOLEAN); INSERT INTO suppliers (id,name,location,sustainable) VALUES (1,'Eco Friendly','California',true);
SELECT COUNT(*) FROM suppliers WHERE location = 'California';
What is the average retail price of all organic cotton t-shirts?
CREATE TABLE garments (id INT,type VARCHAR(255),material VARCHAR(255),price DECIMAL(5,2)); INSERT INTO garments (id,type,material,price) VALUES
SELECT AVG(price) FROM garments WHERE type = 'T-Shirt' AND material = 'Organic Cotton';
What is the total CO2 emission for each manufacturing process in the Asia region in 2022?
CREATE TABLE emissions_asia (emission_id INT,manufacturing_process VARCHAR(50),co2_emission DECIMAL(10,2),region VARCHAR(50));
SELECT manufacturing_process, SUM(co2_emission) FROM emissions_asia WHERE region = 'Asia' AND YEAR(emission_date) = 2022 GROUP BY manufacturing_process;
Update the risk_score of policyholder with policy_holder_id 789 in the 'policy_holder' table to 350.
CREATE TABLE policy_holder (policy_holder_id INT,first_name VARCHAR(20),last_name VARCHAR(20),risk_score INT);
UPDATE policy_holder SET risk_score = 350 WHERE policy_holder_id = 789;
Show the names of unions that have more than 5000 members
CREATE TABLE union_members (id INT,union_name VARCHAR(50),member_count INT); INSERT INTO union_members (id,union_name,member_count) VALUES (1,'Union A',6000),(2,'Union B',3000),(3,'Union C',4000);
SELECT union_name FROM union_members WHERE member_count > 5000;
Update the collective bargaining agreement date for the 'Construction Workers Union' to '2022-05-01'.
CREATE TABLE CollectiveBargaining (CBAID INT,UnionID INT,AgreementDate DATE); INSERT INTO CollectiveBargaining (CBAID,UnionID,AgreementDate) VALUES (1,1,'2020-01-01'),(2,2,'2019-06-15'),(3,3,'2018-09-01');
UPDATE CollectiveBargaining SET AgreementDate = '2022-05-01' WHERE UnionID = (SELECT UnionID FROM Unions WHERE UnionName = 'Construction Workers Union');
What is the percentage of workers in unions that are in the 'Healthcare' industry and have collective bargaining agreements?
CREATE TABLE unions (id INT,industry VARCHAR(255),has_cba BOOLEAN); CREATE TABLE workers (id INT,union_id INT);
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM workers)) AS percentage FROM workers JOIN unions ON workers.union_id = unions.id WHERE unions.industry = 'Healthcare' AND unions.has_cba = TRUE;
What is the average number of autonomous vehicle research studies conducted annually in Germany?
CREATE TABLE ResearchStudies (Id INT,Title VARCHAR(100),Country VARCHAR(50),Year INT,IsAutonomous BOOLEAN); INSERT INTO ResearchStudies (Id,Title,Country,Year,IsAutonomous) VALUES (1,'Autonomous Vehicle Safety Testing','Germany',2015,true),(2,'AD Research Study','Germany',2016,true),(3,'AV Research Study','Germany',2018,true);
SELECT AVG(Year) FROM ResearchStudies WHERE Country = 'Germany' AND IsAutonomous = true;
What is the average speed of vessels that transported hazardous materials in the last 6 months?
CREATE TABLE Vessels (VesselID int,Name varchar(50),Type varchar(50),AverageSpeed float); CREATE TABLE Cargo (CargoID int,VesselID int,MaterialType varchar(50),TransportDate date); INSERT INTO Vessels VALUES (1,'Vessel1','Transport',15); INSERT INTO Cargo VALUES (1,1,'Hazardous','2022-01-01');
SELECT AVG(V.AverageSpeed) FROM Vessels V INNER JOIN Cargo C ON V.VesselID = C.VesselID WHERE C.TransportDate >= DATEADD(month, -6, GETDATE()) AND C.MaterialType = 'Hazardous';
List the top 5 water-consuming zip codes in California.
CREATE TABLE zip_water_usage (zip VARCHAR,water_consumption FLOAT); INSERT INTO zip_water_usage (zip,water_consumption) VALUES ('90001',5000),('90002',6000),('90003',4500),('90004',7000),('90005',5500),('90006',6500);
SELECT zip, water_consumption FROM zip_water_usage ORDER BY water_consumption DESC LIMIT 5;
What is the average water consumption in the residential sector in Brazil for the year 2018?
CREATE TABLE water_consumption_kl (region VARCHAR(20),sector VARCHAR(20),year INT,value FLOAT); INSERT INTO water_consumption_kl (region,sector,year,value) VALUES ('Brazil','Residential',2018,6000000);
SELECT AVG(value) FROM water_consumption_kl WHERE sector = 'Residential' AND region = 'Brazil' AND year = 2018;
Determine the number of AI safety incidents per month globally in the past 2 years.
CREATE TABLE ai_safety_incidents (id INT,incident_name VARCHAR(255),incident_date DATE);
SELECT DATEPART(YEAR, incident_date) as year, DATEPART(MONTH, incident_date) as month, COUNT(*) FROM ai_safety_incidents WHERE incident_date >= DATEADD(year, -2, GETDATE()) GROUP BY DATEPART(YEAR, incident_date), DATEPART(MONTH, incident_date);
Find the number of explainable AI projects and their total budget, partitioned by project type, ordered by budget in descending order?
CREATE TABLE explainable_ai_projects (project_id INT,project_type VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO explainable_ai_projects (project_id,project_type,budget) VALUES (1,'Healthcare',50000.00),(2,'Finance',75000.00),(3,'Education',35000.00),(4,'Manufacturing',60000.00);
SELECT project_type, COUNT(*) as num_projects, SUM(budget) as total_budget FROM explainable_ai_projects GROUP BY project_type ORDER BY total_budget DESC;
List all AI safety violations for algorithms released in 2020 and their corresponding risk levels
CREATE TABLE ai_safety_violations (id INT PRIMARY KEY,algorithm_name VARCHAR(50),violation_type VARCHAR(20),violation_date DATE,risk_level VARCHAR(10)); CREATE TABLE algorithm_details (id INT PRIMARY KEY,algorithm_name VARCHAR(50),developer VARCHAR(50),release_year INT);
SELECT algorithm_details.algorithm_name, ai_safety_violations.violation_type, ai_safety_violations.violation_date, ai_safety_violations.risk_level FROM algorithm_details JOIN ai_safety_violations ON algorithm_details.algorithm_name = ai_safety_violations.algorithm_name WHERE algorithm_details.release_year = 2020;
What is the average satisfaction score for AI safety models in Australia?
CREATE TABLE ai_safety_models (model_name TEXT,satisfaction_score INTEGER,country TEXT);
SELECT AVG(satisfaction_score) FROM ai_safety_models WHERE country = 'Australia';
What was the total agricultural innovation output for each country in Southeast Asia in 2019?
CREATE TABLE agri_innovation (project_id INT,country VARCHAR(255),innovation_output INT,year INT); INSERT INTO agri_innovation (project_id,country,innovation_output,year) VALUES (1,'Vietnam',1000,2019),(2,'Thailand',1200,2019),(3,'Indonesia',1500,2019);
SELECT country, SUM(innovation_output) FROM agri_innovation WHERE year = 2019 AND country IN ('Vietnam', 'Thailand', 'Indonesia') GROUP BY country;
Delete records for fish species that are not tilapiids.
CREATE TABLE fish_species (id INT,name VARCHAR(255),species_family VARCHAR(255)); INSERT INTO fish_species (id,name,species_family) VALUES (1,'Salmon','Salmonidae'),(2,'Tuna','Scombridae'),(3,'Tilapia','Cichlidae'); CREATE TABLE fish_data (id INT,species_id INT,weight DECIMAL(5,2),length DECIMAL(5,2)); INSERT INTO fish_data (id,species_id,weight,length) VALUES (1,1,3.5,0.6),(2,1,4.2,0.7),(3,2,22.3,1.3),(4,3,1.2,0.3);
DELETE FROM fish_data WHERE species_id NOT IN (SELECT id FROM fish_species WHERE species_family = 'Cichlidae');
List all fish species and their populations in sustainable fisheries in the Mediterranean Sea.
CREATE TABLE fisheries (fishery_name VARCHAR(50),fish_species VARCHAR(50),population INT); INSERT INTO fisheries (fishery_name,fish_species,population) VALUES ('Mediterranean Sea Sustainable 1','Sardine',150000),('Mediterranean Sea Sustainable 1','Anchovy',200000),('Mediterranean Sea Sustainable 2','Tuna',50000),('Mediterranean Sea Sustainable 2','Swordfish',30000);
SELECT fish_species, population FROM fisheries WHERE fishery_name LIKE 'Mediterranean Sea Sustainable%';
Which are the top 2 countries with the highest average dissolved oxygen levels in ocean water in the last 12 months?
CREATE TABLE monitoring_stations (id INT,name TEXT,location TEXT,country TEXT); INSERT INTO monitoring_stations (id,name,location,country) VALUES (1,'Station A','Pacific Ocean Coast','USA'),(2,'Station B','Atlantic Ocean Coast','USA'),(3,'Station C','North Sea','Germany'),(4,'Station D','Mediterranean Sea','Italy'); CREATE TABLE oxygen_readings (id INT,station_id INT,reading DATE,level DECIMAL(5,2),country TEXT); INSERT INTO oxygen_readings (id,station_id,reading,level,country) VALUES (1,1,'2022-03-01',8.2,'USA'),(2,1,'2022-03-15',8.4,'USA'),(3,2,'2022-03-05',7.8,'USA'),(4,2,'2022-03-20',8.0,'USA'),(5,3,'2022-03-02',9.2,'Germany'),(6,3,'2022-03-17',9.0,'Germany');
SELECT country, AVG(level) avg_oxygen FROM oxygen_readings WHERE reading >= DATEADD(month, -12, CURRENT_DATE) GROUP BY country ORDER BY avg_oxygen DESC FETCH FIRST 2 ROWS ONLY;
How many events have more attendees than the average number of attendees for all events?
CREATE TABLE Events (event_id INT,event_location VARCHAR(20),event_type VARCHAR(20),num_attendees INT); INSERT INTO Events (event_id,event_location,event_type,num_attendees) VALUES (1,'New York','Concert',500),(2,'Los Angeles','Theater',300),(3,'Chicago','Exhibition',400),(4,'San Francisco','Theater',200),(5,'Seattle','Exhibition',150);
SELECT COUNT(*) FROM Events WHERE num_attendees > (SELECT AVG(num_attendees) FROM Events);
How many first-time attendees were there at each event, in the past six months, broken down by funding source?
CREATE TABLE Events (id INT,date DATE,funding_source VARCHAR(50)); INSERT INTO Events (id,date,funding_source) VALUES (1,'2021-01-01','Government'),(2,'2021-02-01','Private'); CREATE TABLE Attendance (id INT,event_id INT,is_new_attendee BOOLEAN); INSERT INTO Attendance (id,event_id,is_new_attendee) VALUES (1,1,TRUE),(2,1,FALSE),(3,2,TRUE);
SELECT e.funding_source, COUNT(a.id) AS count FROM Events e INNER JOIN Attendance a ON e.id = a.event_id AND a.is_new_attendee = TRUE WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY e.funding_source;
How many viewers are there for the TV show 'The Crown'?
CREATE TABLE tv_show_viewers (show_id INT,title VARCHAR(255),viewer_count INT); INSERT INTO tv_show_viewers (show_id,title,viewer_count) VALUES (1,'The Crown',5000000),(2,'Stranger Things',7000000),(3,'Friends',6000000),(4,'Breaking Bad',8000000);
SELECT SUM(viewer_count) as total_viewers FROM tv_show_viewers WHERE title = 'The Crown';
to represent the fanbase size for each genre
INSERT INTO music_genres_ext (id,genre,popularity) VALUES (3,'Pop',25000000);
INSERT INTO music_genres_ext (id, genre, popularity) VALUES (3, 'Pop', 25000000);
What is the total amount of chemicals stored in the storage facilities, grouped by the state and the facility name?
CREATE TABLE StorageFacilities (FacilityID INT,FacilityName TEXT,State TEXT,Chemical TEXT,Quantity DECIMAL(5,2)); INSERT INTO StorageFacilities (FacilityID,FacilityName,State,Chemical,Quantity) VALUES (1,'Cool Storage','Texas','Acetone',50.5),(2,'Warm Storage','California','Acetone',75.3),(3,'Freezer','Texas','Nitrogen',150.5),(4,'Hot Storage','California','Nitrogen',250.3);
SELECT State, FacilityName, SUM(Quantity) AS TotalQuantity FROM StorageFacilities GROUP BY State, FacilityName;
How many marine protected areas are there per country?
CREATE TABLE marine_protected_areas (name VARCHAR(255),country VARCHAR(255));
SELECT country, COUNT(*) FROM marine_protected_areas GROUP BY country;
What is the total number of smart contracts by category?
CREATE TABLE smart_contracts (id INT,category VARCHAR(255),name VARCHAR(255)); INSERT INTO smart_contracts (id,category,name) VALUES (1,'DeFi','Compound'),(2,'DEX','Uniswap'),(3,'DeFi','Aave'),(4,'NFT','CryptoKitties'),(5,'DEX','SushiSwap'),(6,'DeFi','MakerDAO');
SELECT category, COUNT(*) as total FROM smart_contracts GROUP BY category;
How many timber harvest permits were issued in each region in 2019?
CREATE TABLE harvest_permits (id INT,region VARCHAR(255),issued_date DATE);
SELECT region, COUNT(*) as num_permits FROM harvest_permits WHERE EXTRACT(YEAR FROM issued_date) = 2019 GROUP BY region;
What is the number of art pieces in each collection?
CREATE TABLE ArtCollections (id INT,name VARCHAR(255),location VARCHAR(255)); CREATE TABLE ArtPieces (id INT,collection_id INT,title VARCHAR(255),artist VARCHAR(255));
SELECT c.name, COUNT(p.id) FROM ArtCollections c JOIN ArtPieces p ON c.id = p.collection_id GROUP BY c.name;
Which countries had the most artists win awards in 2021?
CREATE TABLE artists (id INT,name TEXT,country TEXT,awards_won INT); INSERT INTO artists (id,name,country,awards_won) VALUES (1,'John Doe','Nigeria',3),(2,'Jane Smith','Kenya',2),(3,'Mohamed Ahmed','Egypt',1),(4,'Aisha Mohamed','Senegal',4),(5,'Pedro Gonzales','South Africa',5);
SELECT country, SUM(awards_won) AS total_awards FROM artists WHERE YEAR(artists.awards_won) = 2021 GROUP BY country ORDER BY total_awards DESC;
Find the number of threat intelligence reports created in Q1 2022
CREATE TABLE threat_intelligence (report_id int,report_date date,report_type varchar(255));
SELECT COUNT(*) FROM threat_intelligence WHERE QUARTER(report_date) = 1 AND YEAR(report_date) = 2022;
Update the number of troops deployed in the first quarter of 2020 in peacekeeping missions to 7000 and display the updated table.
CREATE TABLE peacekeeping_missions (id INT,year INT,quarter INT,troops INT); INSERT INTO peacekeeping_missions (id,year,quarter,troops) VALUES (1,2018,1,4000),(2,2018,2,5000),(3,2019,1,5500),(4,2019,2,6000),(5,2020,1,6500),(6,2020,2,7000);
UPDATE peacekeeping_missions SET troops = 7000 WHERE year = 2020 AND quarter = 1; SELECT * FROM peacekeeping_missions;
Who are the top 3 contributors to defense diplomacy?
CREATE TABLE Contributors (id INT,country VARCHAR(50),amount INT); INSERT INTO Contributors (id,country,amount) VALUES (1,'Country1',5000000),(2,'Country2',6000000),(3,'Country3',7000000);
SELECT country, amount FROM Contributors ORDER BY amount DESC LIMIT 3;
What is the total value of trades executed by the trading desk in London?
CREATE TABLE trades (id INT,desk VARCHAR(50),value DECIMAL(10,2),currency VARCHAR(10)); INSERT INTO trades (id,desk,value,currency) VALUES (1,'New York',1000.00,'USD'),(2,'London',2000.00,'GBP'),(3,'Paris',1500.00,'EUR');
SELECT SUM(value * currency_rate) FROM trades t JOIN currency_rates cr ON t.currency = cr.currency WHERE t.desk = 'London' AND t.trade_date >= CURRENT_DATE - INTERVAL '1 month';
How many patients with diabetes are in each rural county in Texas?
CREATE TABLE patients (id INTEGER,county VARCHAR(255),state VARCHAR(255),disease VARCHAR(255));
SELECT county, disease, COUNT(*) FROM patients WHERE state = 'Texas' AND county LIKE '%rural%' AND disease = 'diabetes' GROUP BY county;
What is the average investment amount in 'Asia'?
CREATE TABLE investment_regions (region VARCHAR(20),investment_amount FLOAT); INSERT INTO investment_regions (region,investment_amount) VALUES ('Africa',450000),('Asia',650000),('South America',700000),('Europe',800000);
SELECT AVG(investment_amount) FROM investment_regions WHERE region = 'Asia';
List all countries that have a military alliance with the United States.
CREATE TABLE military_alliances (id INT,country TEXT,allied_country TEXT);INSERT INTO military_alliances (id,country,allied_country) VALUES (1,'United States','Japan');INSERT INTO military_alliances (id,country,allied_country) VALUES (2,'United States','South Korea');
SELECT allied_country FROM military_alliances WHERE country = 'United States';
What is the total number of cybersecurity incidents per country in the African region since 2018?
CREATE TABLE CybersecurityIncidents (Id INT,Country VARCHAR(50),IncidentType VARCHAR(50),Year INT,Quantity INT);INSERT INTO CybersecurityIncidents (Id,Country,IncidentType,Year,Quantity) VALUES (1,'Egypt','Malware',2018,200),(2,'Algeria','Phishing',2019,150),(3,'South Africa','Ransomware',2020,250);
SELECT Country, SUM(Quantity) AS TotalIncidents FROM CybersecurityIncidents WHERE Country IN ('Egypt', 'Algeria', 'South Africa') AND Year >= 2018 GROUP BY Country;
List all job titles that have more than 5 employees in the "employee" and "job" tables
CREATE TABLE employee (id INT,job_id INT); CREATE TABLE job (id INT,title TEXT);
SELECT j.title FROM job j JOIN employee e ON j.id = e.job_id GROUP BY j.title HAVING COUNT(*) > 5;
What is the count of job applications received from historically underrepresented communities in the last 6 months?
CREATE TABLE JobApplications (ApplicationID int,ApplicationDate date,ApplicantCommunity varchar(50)); INSERT INTO JobApplications (ApplicationID,ApplicationDate,ApplicantCommunity) VALUES (1,'2022-01-01','Underrepresented'),(2,'2022-02-15','Not Underrepresented'),(3,'2022-03-20','Underrepresented'),(4,'2022-04-01','Not Underrepresented');
SELECT COUNT(*) FROM JobApplications WHERE ApplicantCommunity = 'Underrepresented' AND ApplicationDate >= DATEADD(month, -6, GETDATE());
List the top 2 producing wells in the Arctic region, partitioned by month.
CREATE TABLE well_production_arctic (well_name VARCHAR(20),production_qty FLOAT,production_date DATE,location VARCHAR(20)); INSERT INTO well_production_arctic (well_name,production_qty,production_date,location) VALUES ('Well X',1000,'2020-01-01','Arctic'); INSERT INTO well_production_arctic (well_name,production_qty,production_date,location) VALUES ('Well X',1200,'2020-01-02','Arctic'); INSERT INTO well_production_arctic (well_name,production_qty,production_date,location) VALUES ('Well Y',1500,'2020-01-01','Arctic'); INSERT INTO well_production_arctic (well_name,production_qty,production_date,location) VALUES ('Well Y',1700,'2020-01-02','Arctic');
SELECT well_name, EXTRACT(MONTH FROM production_date) as month, RANK() OVER (PARTITION BY EXTRACT(MONTH FROM production_date) ORDER BY production_qty DESC) as rank FROM well_production_arctic WHERE well_name LIKE 'Well%' AND production_date BETWEEN '2020-01-01' AND '2021-12-31' AND location = 'Arctic' ORDER BY production_date, rank;
What is the total number of goals scored by players in the SoccerTeams and SoccerPlayerGoals tables, for teams that have a mascot starting with the letter 'C'?
CREATE TABLE SoccerTeams (TeamID INT,TeamName VARCHAR(50),Mascot VARCHAR(50)); CREATE TABLE SoccerPlayerGoals (PlayerID INT,TeamID INT,Goals INT);
SELECT SUM(Goals) FROM SoccerPlayerGoals INNER JOIN SoccerTeams ON SoccerPlayerGoals.TeamID = SoccerTeams.TeamID WHERE Mascot LIKE 'C%';
What is the total number of matches played in the CricketMatches table, for matches that were rained out?
CREATE TABLE CricketMatches (MatchID INT,HomeTeam VARCHAR(50),AwayTeam VARCHAR(50),Weather VARCHAR(50));
SELECT COUNT(*) FROM CricketMatches WHERE Weather = 'Rain';
What is the total amount of aid provided by each government, for community development projects in Southeast Asia, in the last 10 years, and the average duration of the projects?
CREATE TABLE community_development_projects (project_id INT,government_id INT,start_date DATE,end_date DATE,aid DECIMAL(10,2)); INSERT INTO community_development_projects VALUES (1,1,'2011-01-01','2013-12-31',50000); INSERT INTO community_development_projects VALUES (2,1,'2014-01-01','2016-12-31',75000); INSERT INTO community_development_projects VALUES (3,2,'2015-01-01','2017-12-31',100000); INSERT INTO community_development_projects VALUES (4,2,'2018-01-01','2020-12-31',80000);
SELECT government.name as government, SUM(aid) as total_aid, AVG(DATEDIFF(end_date, start_date) / 365) as avg_project_duration FROM community_development_projects JOIN government ON community_development_projects.government_id = government.government_id WHERE government.region = 'Southeast Asia' AND community_development_projects.start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) GROUP BY government.name;
What is the total fare collected on route 123?
CREATE TABLE Routes(id INT,name TEXT); CREATE TABLE Fares(route_id INT,fare FLOAT);
SELECT SUM(fare) FROM Fares JOIN Routes ON Fares.route_id = Routes.id WHERE Routes.name = '123';
What is the percentage of total sustainable materials used by companies located in Europe?
CREATE TABLE company_location_sustainability (company_id INT,location TEXT,sustainability_score INT); INSERT INTO company_location_sustainability (company_id,location,sustainability_score) VALUES (1,'Asia-Pacific',85),(2,'Europe',92),(3,'Asia-Pacific',78),(4,'Europe',60),(5,'Europe',88);
SELECT (SUM(CASE WHEN location = 'Europe' THEN sustainability_score ELSE 0 END) / SUM(sustainability_score)) * 100 FROM company_location_sustainability;
How many fashion brands in each country have a size diversity policy?
CREATE TABLE brands (id INT,name VARCHAR(255),country VARCHAR(255),size_diversity_policy BOOLEAN); INSERT INTO brands (id,name,country,size_diversity_policy) VALUES (1,'BrandA','USA',true),(2,'BrandB','Canada',false),(3,'BrandC','France',true),(4,'BrandD','UK',true),(5,'BrandE','Germany',false),(6,'BrandF','Italy',true),(7,'BrandG','Spain',false);
SELECT country, COUNT(*) as brand_count FROM brands WHERE size_diversity_policy = true GROUP BY country;
Find the total assets of Shariah-compliant financial institutions in the Middle East and North Africa?
CREATE TABLE financial_institutions (name TEXT,location TEXT,shariah_compliant BOOLEAN,assets NUMERIC); INSERT INTO financial_institutions (name,location,shariah_compliant,assets) VALUES ('Al Rajhi Bank','Saudi Arabia',TRUE,123456.78),('Kuwait Finance House','Kuwait',TRUE,987654.32);
SELECT SUM(assets) FROM financial_institutions WHERE shariah_compliant = TRUE AND location LIKE 'Middle East%' OR location LIKE 'North Africa%';
Insert a new record into the 'customer_data' table for 'DavidChoi' with a score of 75.
CREATE TABLE customer_data (id INT,name VARCHAR(20),state VARCHAR(2),score INT); INSERT INTO customer_data (id,name,state,score) VALUES (1,'JohnDoe','CA',75),(2,'JaneDoe','NY',80),(3,'MikeSmith','CA',65);
INSERT INTO customer_data (name, score, state) VALUES ('DavidChoi', 75, 'CA');
What is the total amount of socially responsible loans issued by each lender in Q1 2022?
CREATE TABLE lenders (lender_id INT,lender_name VARCHAR(255));CREATE TABLE loans (loan_id INT,lender_id INT,issue_date DATE,loan_amount DECIMAL(10,2));INSERT INTO lenders (lender_id,lender_name) VALUES (1,'Lender A'),(2,'Lender B');
SELECT l.lender_name, SUM(l.loan_amount) as total_loan_amount FROM loans l INNER JOIN lenders le ON l.lender_id = le.lender_id WHERE l.issue_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY l.lender_id;
Create a table for storing staff member details with columns: id, name, role, and department.
CREATE TABLE staff_members (id INT,name VARCHAR(50),role VARCHAR(50),department VARCHAR(50));
INSERT INTO staff_members (id, name, role, department) VALUES (1, 'John Doe', 'Manager', 'Finance'), (2, 'Jane Smith', 'Director', 'Marketing'), (3, 'Mike Johnson', 'Specialist', 'IT');
Calculate the total funding received by biotech startups founded in 2018.
CREATE TABLE startups (name TEXT,year INTEGER,funding FLOAT); INSERT INTO startups (name,year,funding) VALUES ('StartupA',2017,5000000),('StartupB',2018,7000000),('StartupC',2018,6000000);
SELECT SUM(funding) FROM startups WHERE year = 2018;
What is the number of public parks in each borough in the city of New York, including their names and area size?
CREATE TABLE boroughs(id INT,name TEXT); INSERT INTO boroughs VALUES (1,'Borough A'); INSERT INTO boroughs VALUES (2,'Borough B'); INSERT INTO boroughs VALUES (3,'Borough C'); CREATE TABLE parks(id INT,borough_id INT,name TEXT,area_size INT); INSERT INTO parks VALUES (1,1,'Park A',50); INSERT INTO parks VALUES (2,1,'Park B',75); INSERT INTO parks VALUES (3,2,'Park C',60); INSERT INTO parks VALUES (4,3,'Park D',80);
SELECT b.name as borough_name, p.name as park_name, COUNT(*) as park_count, SUM(p.area_size) as total_area FROM boroughs b JOIN parks p ON b.id = p.borough_id GROUP BY b.name, p.name;
How many graduate students in the Arts program have published more than one paper?
CREATE TABLE students (id INT,name VARCHAR(50),gender VARCHAR(10),program VARCHAR(50),publications INT); INSERT INTO students (id,name,gender,program,publications) VALUES (1,'Charlie','Non-binary','Arts',3),(2,'Dana','Female','Physics',1),(3,'Eli','Male','Engineering',0);
SELECT COUNT(*) FROM students WHERE program = 'Arts' AND publications > 1;
How many cultural heritage sites are in Japan and Spain?
CREATE TABLE Countries (country_id INT,name TEXT,region TEXT); CREATE TABLE Cultural_Heritage_Sites (site_id INT,country_id INT,name TEXT); INSERT INTO Countries (country_id,name,region) VALUES (1,'Japan','Asia'),(2,'Spain','Europe'); INSERT INTO Cultural_Heritage_Sites (site_id,country_id,name) VALUES (1,1,'Mount Fuji'),(2,1,'Himeji Castle'),(3,2,'Alhambra'),(4,2,'Sagrada Familia');
SELECT COUNT(DISTINCT country_id) FROM Cultural_Heritage_Sites WHERE country_id IN (1, 2);
What is the total revenue generated from sustainable tourism activities in Indonesia?
CREATE TABLE tourism_activities(activity_id INT,name TEXT,country TEXT,revenue FLOAT); INSERT INTO tourism_activities (activity_id,name,country,revenue) VALUES (1,'Eco-Trekking','Indonesia',15000),(2,'Cultural Festival','Indonesia',20000);
SELECT SUM(revenue) FROM tourism_activities WHERE country = 'Indonesia' AND sustainable = TRUE;
List all hotels with their total revenue from OTA partners.
CREATE TABLE hotel_revenue (hotel_id INT,partner_id INT,revenue FLOAT); INSERT INTO hotel_revenue (hotel_id,partner_id,revenue) VALUES (1,1,10000),(1,2,15000),(2,1,8000),(2,2,12000),(3,1,13000),(3,2,17000); CREATE TABLE hotels (id INT,name TEXT); INSERT INTO hotels (id,name) VALUES (1,'The Grand Hotel'),(2,'Park Lane Hotel'),(3,'Ocean View Hotel');
SELECT h.name, SUM(hr.revenue) AS total_revenue FROM hotels h JOIN hotel_revenue hr ON h.id = hr.hotel_id GROUP BY h.name;
What is the average number of heritage sites per region?
CREATE TABLE HeritageSites (id INT,region VARCHAR(255),site_name VARCHAR(255)); INSERT INTO HeritageSites (id,region,site_name) VALUES (1,'Africa','Giza Pyramids'),(2,'Asia','Great Wall'),(3,'Europe','Colosseum'),(4,'Africa','Victoria Falls'),(5,'Asia','Angkor Wat');
SELECT region, AVG(ROW_NUMBER() OVER(PARTITION BY region) ) as avg_heritage_sites FROM HeritageSites;
What is the maximum cost of projects in the 'infrastructure_development' table?
CREATE TABLE infrastructure_development (id INT,project_name VARCHAR(50),location VARCHAR(50),cost FLOAT); INSERT INTO infrastructure_development (id,project_name,location,cost) VALUES (1,'Highway Expansion','City K',35000000.00),(2,'Transit Hub','Region L',28000000.00);
SELECT MAX(cost) FROM infrastructure_development;
What is the percentage change in the number of international tourists in 2021 compared to 2020?
CREATE TABLE visitor_stats (country VARCHAR(50),visitors INT,year INT); INSERT INTO visitor_stats (country,visitors,year) VALUES ('Australia',42,2020),('China',39,2020),('Australia',44,2021),('China',41,2021);
SELECT year, (SUM(visitors) - LAG(SUM(visitors)) OVER (ORDER BY year)) * 100.0 / LAG(SUM(visitors)) OVER (ORDER BY year) as visitors_percentage_diff FROM visitor_stats GROUP BY year;
What is the total number of cases heard in the justice_data schema's court_hearings table where the defendant is of Hispanic or Latino origin?
CREATE TABLE justice_data.court_hearings (id INT,case_number INT,hearing_date DATE,defendant_race VARCHAR(50));
SELECT COUNT(*) FROM justice_data.court_hearings WHERE defendant_race LIKE '%Hispanic%';
How many whales were spotted in the North Atlantic during the summer months of 2021?
CREATE TABLE whale_sightings (id INT,species VARCHAR(50),location VARCHAR(50),sighting_date DATE); INSERT INTO whale_sightings (id,species,location,sighting_date) VALUES (1,'Blue Whale','North Atlantic','2021-07-15'); INSERT INTO whale_sightings (id,species,location,sighting_date) VALUES (2,'Humpback Whale','North Atlantic','2021-08-03');
SELECT COUNT(*) FROM whale_sightings WHERE species = 'Blue Whale' OR species = 'Humpback Whale' AND location = 'North Atlantic' AND sighting_date BETWEEN '2021-06-01' AND '2021-08-31';
What are the top 3 selling menu categories?
CREATE TABLE orders (order_id INT,menu_category VARCHAR(255),quantity INT); INSERT INTO orders (order_id,menu_category,quantity) VALUES (1,'Appetizers',2),(2,'Entrees',3),(3,'Desserts',1),(4,'Appetizers',1),(5,'Entrees',4);
SELECT menu_category, SUM(quantity) as total_quantity FROM orders GROUP BY menu_category ORDER BY total_quantity DESC LIMIT 3;
What is the average rating for 'Gluten-Free' items?
CREATE TABLE ratings (item_name TEXT,is_gluten_free BOOLEAN,rating INTEGER); INSERT INTO ratings (item_name,is_gluten_free,rating) VALUES ('Quinoa Salad',true,4); INSERT INTO ratings (item_name,is_gluten_free,rating) VALUES ('Chicken Stir Fry',false,5);
SELECT AVG(rating) FROM ratings WHERE is_gluten_free = true;
How many high-risk assessments exist for projects in the Asia-Pacific region?
CREATE TABLE risk_assessments (id INT PRIMARY KEY,project_id INT,region VARCHAR(255),risk_level VARCHAR(255),assessment_date DATE); INSERT INTO risk_assessments (id,project_id,region,risk_level,assessment_date) VALUES (1,1,'Asia-Pacific','High','2022-09-01');
SELECT COUNT(*) FROM risk_assessments WHERE region = 'Asia-Pacific' AND risk_level = 'High';
What were the total military sales to India in 2021?
CREATE TABLE military_sales(id INT,country VARCHAR(50),sale_value FLOAT,sale_date DATE); INSERT INTO military_sales(id,country,sale_value,sale_date) VALUES (1,'India',7000000,'2021-01-01'); INSERT INTO military_sales(id,country,sale_value,sale_date) VALUES (2,'India',6000000,'2021-02-01');
SELECT SUM(sale_value) FROM military_sales WHERE country = 'India' AND YEAR(sale_date) = 2021;
What is the maximum production volume of tin in Indonesia?
CREATE TABLE mines (id INT,name TEXT,location TEXT,product TEXT,production_volume INT); INSERT INTO mines (id,name,location,product,production_volume) VALUES (1,'Grasberg','Indonesia','Tin',10000);
SELECT MAX(production_volume) FROM mines WHERE location = 'Indonesia' AND product = 'Tin';
Which mine in Australia produces the most gold?
CREATE TABLE gold_mines (mine_name VARCHAR(30),country VARCHAR(20),production_tons INT); INSERT INTO gold_mines (mine_name,country,production_tons) VALUES ('Mine X','Australia',550),('Mine Y','Australia',650),('Mine Z','Australia',400);
SELECT mine_name, MAX(production_tons) FROM gold_mines WHERE country = 'Australia';
List the top 5 mining operations with the highest number of employees.
CREATE TABLE mining_operations (id INT,name VARCHAR(50),num_employees INT);
SELECT name, num_employees FROM (SELECT name, num_employees, ROW_NUMBER() OVER (ORDER BY num_employees DESC) as rn FROM mining_operations) tmp WHERE rn <= 5;
How many broadband customers does each regional office have?
CREATE TABLE broadband_subscribers (subscriber_id INT,regional_office VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id,regional_office) VALUES (1,'Boston'),(2,'Boston'),(3,'NYC'),(4,'NYC'),(5,'NYC');
SELECT regional_office, COUNT(*) FROM broadband_subscribers GROUP BY regional_office;
Show the average number of streams per day for artists who have held concerts in the USA and Canada.
CREATE TABLE music_streaming (artist_id INT,artist_name VARCHAR(100),genre VARCHAR(50),total_streams BIGINT,stream_date DATE); CREATE TABLE concert_ticket_sales (concert_id INT,artist_id INT,concert_date DATE,venue VARCHAR(100),country VARCHAR(50));
SELECT AVG(ms.total_streams / COUNT(DISTINCT ms.stream_date)) AS avg_daily_streams FROM music_streaming ms INNER JOIN concert_ticket_sales cts ON ms.artist_id = cts.artist_id WHERE cts.country IN ('USA', 'Canada');
Insert a new record for an article about media ethics published on March 1, 2022 into the 'articles' table
CREATE TABLE articles (article_id INT PRIMARY KEY,title VARCHAR(255),content TEXT,publication_date DATE);
INSERT INTO articles (title, content, publication_date) VALUES ('Media Ethics: A Guide for Journalists', 'An in-depth look at the ethical principles that guide journalists and the media...', '2022-03-01');
What is the average age of users who have interacted with articles about climate change?
CREATE TABLE user_interactions (user_id INT,article_id INT,interaction_date DATE); INSERT INTO user_interactions (user_id,article_id,interaction_date) VALUES (1,101,'2021-01-01'); INSERT INTO user_interactions (user_id,article_id,interaction_date) VALUES (2,102,'2021-01-02'); CREATE TABLE users (user_id INT,age INT,gender VARCHAR(10)); INSERT INTO users (user_id,age,gender) VALUES (1,30,'Female'); INSERT INTO users (user_id,age,gender) VALUES (2,45,'Male'); CREATE TABLE articles (article_id INT,title VARCHAR(100),topic VARCHAR(50)); INSERT INTO articles (article_id,title,topic) VALUES (101,'Climate Change Impact','climate_change'); INSERT INTO articles (article_id,title,topic) VALUES (102,'Political News','politics');
SELECT AVG(users.age) FROM users INNER JOIN user_interactions ON users.user_id = user_interactions.user_id WHERE user_interactions.article_id IN (SELECT article_id FROM articles WHERE articles.topic = 'climate_change');
What is the average level of satisfaction for VR games in the 'Gaming' category?
CREATE TABLE Games (id INT,name VARCHAR(100),category VARCHAR(50),satisfaction FLOAT);
SELECT AVG(satisfaction) FROM Games WHERE category = 'Gaming';
Delete all records related to the 'Battle Royale' game genre in the 'games' table.
CREATE TABLE games (id INT,name VARCHAR(30),genre VARCHAR(20)); INSERT INTO games (id,name,genre) VALUES (1,'Fortnite','Battle Royale'),(2,'PUBG','Battle Royale'),(3,'Overwatch','FPS'),(4,'CS:GO','FPS');
DELETE FROM games WHERE genre = 'Battle Royale';
How many players from Africa have designed adventure games and have more than 2,000 players?
CREATE TABLE game_designers (designer_id INT,country VARCHAR(50),genre VARCHAR(10),players INT);
SELECT COUNT(*) FROM game_designers WHERE country = 'Africa' AND genre = 'adventure' AND players > 2000;
What is the average number of sustainable urban properties in each city?
CREATE TABLE sustainable_cities (id INT,city VARCHAR(20),properties INT); INSERT INTO sustainable_cities (id,city,properties) VALUES (1,'Buenos Aires',500),(2,'Rio de Janeiro',300),(3,'Santiago',400),(4,'Bogota',600);
SELECT city, AVG(properties) FROM sustainable_cities GROUP BY city;
List all solar projects in the 'carbon_offset' schema.
CREATE SCHEMA carbon_offset; CREATE TABLE solar_projects (id INT,name VARCHAR(100),location VARCHAR(100)); INSERT INTO solar_projects (id,name,location) VALUES (1,'Solar Project C','California'),(2,'Solar Project D','Nevada');
SELECT * FROM carbon_offset.solar_projects;
Which carbon offset programs have a budget greater than $5 million and less than $15 million in the carbon_offset schema?
CREATE TABLE carbon_offset_programs (id INT,name VARCHAR(50),budget FLOAT,start_date DATE,end_date DATE); INSERT INTO carbon_offset_programs (id,name,budget,start_date,end_date) VALUES (1,'Program 1',12000000,'2020-01-01','2025-12-31'); INSERT INTO carbon_offset_programs (id,name,budget,start_date,end_date) VALUES (2,'Program 2',9000000,'2020-01-01','2024-12-31'); INSERT INTO carbon_offset_programs (id,name,budget,start_date,end_date) VALUES (3,'Program 3',7000000,'2020-01-01','2024-12-31');
SELECT name FROM carbon_offset.carbon_offset_programs WHERE budget > 5000000 AND budget < 15000000;
Insert a new food safety inspection record for 'Burrito Bar' restaurant.
CREATE TABLE food_safety_inspections (restaurant_name VARCHAR(255),inspection_date DATE,score INT); INSERT INTO food_safety_inspections (restaurant_name,inspection_date,score) VALUES ('Pizza Palace','2022-01-01',85);
INSERT INTO food_safety_inspections (restaurant_name, inspection_date, score) VALUES ('Burrito Bar', '2022-04-01', 88);
What was the total revenue for 'Bistro A' in the first quarter of 2022?
CREATE TABLE Pizzeria (Date DATE,Revenue INT); INSERT INTO Pizzeria (Date,Revenue) VALUES ('2022-01-01',500),('2022-01-02',700),('2022-01-03',800),('2022-02-01',500),('2022-02-02',700),('2022-02-03',800),('2022-03-01',500),('2022-03-02',700),('2022-03-03',800);
SELECT SUM(Revenue) FROM Pizzeria WHERE Date BETWEEN '2022-01-01' AND '2022-03-31' AND Date LIKE '2022-01%' OR Date LIKE '2022-02%' OR Date LIKE '2022-03%' AND Restaurant = 'Bistro A';
What was the total revenue for each restaurant in the month of April 2022?
CREATE TABLE restaurant_sales (restaurant_id INT,sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO restaurant_sales (restaurant_id,sale_date,revenue) VALUES (1,'2022-04-01',5000.00),(1,'2022-04-02',6000.00),(2,'2022-04-01',8000.00),(3,'2022-04-01',9000.00),(3,'2022-04-02',10000.00); CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255)); INSERT INTO restaurants (restaurant_id,name) VALUES (1,'Restaurant A'),(2,'Restaurant B'),(3,'Restaurant C');
SELECT r.name, SUM(rs.revenue) FROM restaurant_sales rs JOIN restaurants r ON rs.restaurant_id = r.restaurant_id WHERE EXTRACT(MONTH FROM rs.sale_date) = 4 AND EXTRACT(YEAR FROM rs.sale_date) = 2022 GROUP BY r.name;
Which companies have produced spacecrafts that have been piloted by astronauts from more than one country?
CREATE TABLE SpacecraftManufacturing (id INT,company VARCHAR(255),spacecraft VARCHAR(255)); CREATE TABLE SpacecraftPilots (id INT,astronaut_id INT,spacecraft VARCHAR(255),country VARCHAR(255));
SELECT DISTINCT SpacecraftManufacturing.company FROM SpacecraftManufacturing INNER JOIN SpacecraftPilots ON SpacecraftManufacturing.spacecraft = SpacecraftPilots.spacecraft GROUP BY SpacecraftManufacturing.company HAVING COUNT(DISTINCT SpacecraftPilots.country) > 1;
What are the total ticket sales by month for a specific team?
CREATE TABLE ticket_sales (sale_id INT,team_id INT,sale_date DATE,sales INT); INSERT INTO ticket_sales (sale_id,team_id,sale_date,sales) VALUES (1,1,'2022-01-01',10000),(2,1,'2022-02-01',12000),(3,1,'2022-03-01',15000);
SELECT EXTRACT(MONTH FROM sale_date) as month, SUM(sales) as total_sales FROM ticket_sales WHERE team_id = 1 GROUP BY EXTRACT(MONTH FROM sale_date);
What is the percentage of ticket sales in the first quarter for each team, ranked from highest to lowest?
CREATE TABLE Teams (TeamID INT,TeamName VARCHAR(50)); CREATE TABLE TicketSales (TicketID INT,TeamID INT,SaleDate DATE); INSERT INTO Teams (TeamID,TeamName) VALUES (1,'TeamA'),(2,'TeamB'); INSERT INTO TicketSales (TicketID,TeamID,SaleDate) VALUES (1,1,'2023-01-01'),(2,1,'2023-04-03'),(3,2,'2023-03-02'),(4,2,'2023-01-04');
SELECT TeamName, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM TicketSales WHERE SaleDate BETWEEN '2023-01-01' AND '2023-03-31') * 100.0, 2) AS Percentage FROM TicketSales JOIN Teams ON TicketSales.TeamID = Teams.TeamID WHERE SaleDate BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY TeamName ORDER BY Percentage DESC;
What is the total revenue generated from merchandise sales for the 'Milwaukee Bucks' in the 'Central' division for the year 2021? Assume the 'merchandise_sales' table has columns 'team_name', 'sale_year', 'revenue'.
CREATE TABLE TEAMS (team_name VARCHAR(50),division VARCHAR(50)); INSERT INTO TEAMS (team_name,division) VALUES ('Milwaukee Bucks','Central'); CREATE TABLE merchandise_sales (team_name VARCHAR(50),sale_year INT,revenue DECIMAL(10,2)); INSERT INTO merchandise_sales (team_name,sale_year,revenue) VALUES ('Milwaukee Bucks',2021,80000.00);
SELECT SUM(revenue) FROM merchandise_sales WHERE team_name = 'Milwaukee Bucks' AND sale_year = 2021 AND division = (SELECT division FROM TEAMS WHERE team_name = 'Milwaukee Bucks');
What are the top 5 most common security incidents in the financial sector in the last year?
CREATE TABLE incidents (incident_id INT,incident_type VARCHAR(255),sector VARCHAR(255),incident_date DATE); INSERT INTO incidents (incident_id,incident_type,sector,incident_date) VALUES (1,'Phishing','Financial','2021-06-01'),(2,'Malware','Financial','2021-06-05'),(3,'Ransomware','Healthcare','2021-06-10'),(4,'DDoS','Financial','2021-06-15'),(5,'Insider Threat','Financial','2021-06-20'),(6,'Data Breach','Retail','2021-06-25'),(7,'Phishing','Financial','2021-06-30');
SELECT incident_type, COUNT(*) as incident_count FROM incidents WHERE sector = 'Financial' GROUP BY incident_type ORDER BY incident_count DESC LIMIT 5;
What is the average claim amount for policyholders with a car model of 'Corolla'?
CREATE TABLE Auto (policyholder_id INT,car_model VARCHAR(20)); CREATE TABLE Claims (claim_id INT,policyholder_id INT,amount FLOAT);
SELECT AVG(amount) FROM Claims INNER JOIN Auto ON Claims.policyholder_id = Auto.policyholder_id WHERE car_model = 'Corolla';
What is the policy term length for the policyholder with the highest risk assessment score?
CREATE TABLE policies (id INT,policyholder_id INT,policy_term_length INT,risk_assessment_score INT); INSERT INTO policies (id,policyholder_id,policy_term_length,risk_assessment_score) VALUES (1,1,36,850),(2,2,24,600),(3,3,60,725),(4,4,12,900),(5,5,48,700);
SELECT policy_term_length FROM policies WHERE risk_assessment_score = (SELECT MAX(risk_assessment_score) FROM policies);
How many workplace safety violations were recorded in the manufacturing sector last year?
CREATE TABLE safety_violations (violation_id INT,sector VARCHAR(50),violation_date DATE); INSERT INTO safety_violations (violation_id,sector,violation_date) VALUES (1,'manufacturing','2021-01-01'),(2,'manufacturing','2021-02-01'),(3,'construction','2021-03-01');
SELECT COUNT(*) FROM safety_violations WHERE sector = 'manufacturing' AND YEAR(violation_date) = 2021;
Delete records in the cargo table where the cargo_type is 'Chemicals' and weight is less than 2000
CREATE TABLE cargo (cargo_id INT,vessel_id INT,cargo_type VARCHAR(20),weight INT);
DELETE FROM cargo WHERE cargo_type = 'Chemicals' AND weight < 2000;
List the number of users who have completed a workout of a specific type (e.g. Running) and have a membership status of 'Active'.
CREATE TABLE workouts (id INT,user_id INT,workout_type VARCHAR(20)); CREATE TABLE members (id INT,name VARCHAR(50),membership_status VARCHAR(20),state VARCHAR(20)); INSERT INTO workouts (id,user_id,workout_type) VALUES (1,1,'Running'),(2,1,'Cycling'),(3,2,'Running'),(4,3,'Cycling'),(5,3,'Swimming'),(6,4,'Running'),(7,4,'Swimming'); INSERT INTO members (id,name,membership_status,state) VALUES (1,'John Doe','Active','Texas'),(2,'Jane Doe','Inactive','California'),(3,'Bob Smith','Active','Texas'),(4,'Alice Johnson','Active','California');
SELECT COUNT(*) FROM (SELECT user_id FROM workouts WHERE workout_type = 'Running' INTERSECT SELECT id FROM members WHERE membership_status = 'Active') AS user_set;
Top 3 most expensive creative AI projects.
CREATE TABLE creative_ai_projects (id INT PRIMARY KEY,project_name VARCHAR(50),cost FLOAT); INSERT INTO creative_ai_projects (id,project_name,cost) VALUES (1,'AI-generated Art',75000.0),(2,'AI-written Poetry',32000.0),(3,'AI-composed Music',48000.0),(4,'AI-designed Fashion',51000.0),(5,'AI-generated Architecture',80000.0);
SELECT project_name, cost FROM creative_ai_projects ORDER BY cost DESC LIMIT 3;
What is the average amount of funding for women-led agricultural innovation projects in Nigeria, partitioned by the year the project was funded?
CREATE TABLE AgriculturalInnovations (ProjectID INT,ProjectName VARCHAR(255),ProjectLocation VARCHAR(255),FundingAmount DECIMAL(10,2),LeaderGender VARCHAR(10)); INSERT INTO AgriculturalInnovations (ProjectID,ProjectName,ProjectLocation,FundingAmount,LeaderGender) VALUES (1,'AgriProject1','Nigeria',50000,'Female');
SELECT AVG(FundingAmount) as AvgFunding, EXTRACT(YEAR FROM ProjectStartDate) as YearFromDate FROM AgriculturalInnovations WHERE ProjectLocation = 'Nigeria' AND LeaderGender = 'Female' GROUP BY YearFromDate;
What was the total number of rural infrastructure projects completed in Southeast Asia in 2018?
CREATE TABLE rural_infrastructure (country VARCHAR(50),year INT,project VARCHAR(50)); INSERT INTO rural_infrastructure (country,year,project) VALUES ('Indonesia',2018,'Road Construction'),('Thailand',2018,'Bridge Building'),('Philippines',2018,'Electrification'),('Vietnam',2018,'Water Supply'),('Malaysia',2018,'School Construction');
SELECT COUNT(DISTINCT project) as total_projects FROM rural_infrastructure WHERE country IN ('Indonesia', 'Thailand', 'Philippines', 'Vietnam', 'Malaysia') AND year = 2018;
What is the total cost of all space missions by mission type and launch year?
CREATE TABLE SpaceMissions (MissionID INT,MissionType VARCHAR(50),LaunchYear INT,Cost INT);
SELECT MissionType, LaunchYear, SUM(Cost) AS TotalCost FROM SpaceMissions GROUP BY MissionType, LaunchYear;
Calculate the average establishment date for feed manufacturers from Asia.
CREATE TABLE continent_map (id INT,country VARCHAR(255),continent VARCHAR(255)); INSERT INTO continent_map (id,country,continent) VALUES (1,'China','Asia'),(2,'India','Asia'),(3,'Indonesia','Asia'),(4,'Japan','Asia'),(5,'Vietnam','Asia'); CREATE TABLE feed_manufacturers_continent (manufacturer_id INT,continent VARCHAR(255)); INSERT INTO feed_manufacturers_continent (manufacturer_id,continent) SELECT id,continent FROM feed_manufacturers JOIN continent_map ON country = country;
SELECT AVG(establishment_date) FROM feed_manufacturers_continent WHERE continent = 'Asia';
Find the total revenue of movies produced by Blue Studios.
CREATE TABLE studio (studio_id INT,name VARCHAR(100)); INSERT INTO studio (studio_id,name) VALUES (1,'Blue Studios'); CREATE TABLE movie (movie_id INT,title VARCHAR(100),studio_id INT,revenue INT);
SELECT SUM(movie.revenue) FROM movie WHERE movie.studio_id = 1;
How many construction labor hours were spent on projects in the year 2018?
CREATE TABLE labor_hours (labor_hour_id INT,project_id INT,city VARCHAR(20),hours INT,year INT); INSERT INTO labor_hours (labor_hour_id,project_id,city,hours,year) VALUES (1,201,'Dallas',100,2020),(2,201,'Dallas',200,2019),(3,202,'Houston',150,2020),(6,501,'Miami',250,2018);
SELECT SUM(hours) FROM labor_hours WHERE year = 2018;
How many cases were handled by attorneys in the 'Los Angeles' office?
CREATE TABLE offices (office_id INT,office_name VARCHAR(20),city VARCHAR(20),state VARCHAR(20)); INSERT INTO offices (office_id,office_name,city,state) VALUES (1,'Boston','Boston','MA'),(2,'New York','New York','NY'),(3,'Los Angeles','Los Angeles','CA'); CREATE TABLE attorneys (attorney_id INT,office_id INT); INSERT INTO attorneys (attorney_id,office_id) VALUES (1,1),(2,2),(3,3); CREATE TABLE cases (case_id INT,attorney_id INT); INSERT INTO cases (case_id,attorney_id) VALUES (1,1),(2,2),(3,3);
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id JOIN offices ON attorneys.office_id = offices.office_id WHERE offices.city = 'Los Angeles';