instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the maximum container count in a single cargo transaction for port 'HOU'? | CREATE TABLE ports (port_id INT,port_name VARCHAR(20)); INSERT INTO ports (port_id,port_name) VALUES (1,'LA'),(2,'LB'),(3,'HOU'); CREATE TABLE cargo (cargo_id INT,port_id INT,container_count INT); INSERT INTO cargo (cargo_id,port_id,container_count) VALUES (1,1,5000),(2,1,3000),(3,2,4000),(4,3,6000),(5,3,7000),(6,3,800... | SELECT MAX(container_count) FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'HOU'); |
Find the number of cultural heritage sites in Brazil and their respective conservation status. | CREATE TABLE cultural_sites (site_id INT,name TEXT,country TEXT,status TEXT); INSERT INTO cultural_sites VALUES (1,'Christ the Redeemer','Brazil','Good'),(2,'Sugarloaf Mountain','Brazil','Good'),(3,'Iguazu Falls','Brazil','Excellent'); | SELECT country, COUNT(site_id), status FROM cultural_sites WHERE country = 'Brazil' GROUP BY status; |
Find the number of employees and total salary for the "mining" department in the "compensation" table | CREATE TABLE compensation (id INT,department VARCHAR(10),salary DECIMAL(10,2)); INSERT INTO compensation (id,department,salary) VALUES (1,'mining',75000.00),(2,'mining',80000.00),(3,'geology',70000.00); | SELECT COUNT(department) as num_employees, SUM(salary) as total_salary FROM compensation WHERE department = 'mining'; |
Find the top 3 countries with the highest number of users with hearing impairments in the first quarter of 2021, and display the total number of users for each. | CREATE TABLE users (user_id INT,user_disability BOOLEAN,user_country VARCHAR(50)); INSERT INTO users (user_id,user_disability,user_country) VALUES (1,true,'India'); | SELECT user_country, COUNT(*) as user_count FROM users WHERE EXTRACT(MONTH FROM user_last_login) BETWEEN 1 AND 3 AND user_disability = true GROUP BY user_country ORDER BY user_count DESC LIMIT 3; |
What is the most common mental health condition in the US? | CREATE TABLE conditions (id INT,country VARCHAR(255),condition VARCHAR(255)); INSERT INTO conditions (id,country,condition) VALUES (1,'US','Depression'),(2,'Canada','Anxiety'),(3,'US','Anxiety'); | SELECT condition, COUNT(*) FROM conditions WHERE country = 'US' GROUP BY condition ORDER BY COUNT(*) DESC LIMIT 1; |
Insert new records for the following items into the Inventory table | CREATE TABLE Inventory (item_id INT,item_name VARCHAR(50),quantity INT,warehouse_id INT); | INSERT INTO Inventory (item_id, item_name, quantity, warehouse_id) VALUES (1, 'Oranges', 50, 101), (2, 'Apples', 75, 102), (3, 'Bananas', 30, 103); |
What is the average budget for accessible technology initiatives in each continent? | CREATE TABLE accessible_tech_budget (id INT,initiative_name VARCHAR(50),continent VARCHAR(50),budget DECIMAL(5,2));INSERT INTO accessible_tech_budget (id,initiative_name,continent,budget) VALUES (1,'Screen Reader','Africa',50000.00),(2,'Voice Recognition','Europe',75000.00),(3,'Speech Synthesis','Americas',100000.00); | SELECT continent, AVG(budget) AS avg_budget FROM accessible_tech_budget GROUP BY continent; |
What is the average rating for each hotel in the 'Hotel_Ratings' table? | CREATE TABLE Hotel_Ratings (hotel_name VARCHAR(50),rating DECIMAL(2,1)); INSERT INTO Hotel_Ratings (hotel_name,rating) VALUES ('The Grand Hotel',4.5),('Executive Suites',4.2),('Harbor View',4.7); | SELECT hotel_name, AVG(rating) FROM Hotel_Ratings GROUP BY hotel_name; |
What is the name and type of all sensors from companies in the 'Biotechnology' industry? | CREATE TABLE sensor (id INT PRIMARY KEY,name TEXT,type TEXT,company_id INT,FOREIGN KEY (company_id) REFERENCES company(id)); INSERT INTO sensor (id,name,type,company_id) VALUES (1,'Biosensor 101','Biosensor',2); INSERT INTO company (id,name,industry,location) VALUES (2,'NewCo Bio','Biotechnology','New York'); | SELECT c.name, s.name, s.type FROM sensor s INNER JOIN company c ON s.company_id = c.id WHERE c.industry = 'Biotechnology'; |
Which positions have the highest average salary in the baseball_players table? | CREATE TABLE baseball_players (player_id INT,name VARCHAR(50),position VARCHAR(50),salary DECIMAL(5,2)); INSERT INTO baseball_players (player_id,name,position,salary) VALUES (1,'James Lee','Pitcher',100000.00),(2,'Jasmine White','Catcher',125000.00),(3,'Robert Johnson','Outfielder',85000.00),(4,'Grace Brown','Pitcher',... | SELECT position, AVG(salary) as avg_salary FROM baseball_players GROUP BY position ORDER BY avg_salary DESC; |
What is the maximum water depth for shrimp farms in Indonesia? | CREATE TABLE shrimp_farms (id INT,name TEXT,country TEXT,water_depth FLOAT); INSERT INTO shrimp_farms (id,name,country,water_depth) VALUES (1,'Farm E','Indonesia',8.2); INSERT INTO shrimp_farms (id,name,country,water_depth) VALUES (2,'Farm F','Indonesia',9.1); | SELECT MAX(water_depth) FROM shrimp_farms WHERE country = 'Indonesia'; |
What is the total investment made by Impact Fund 2 in the healthcare sector? | CREATE TABLE investments (id INT,fund_name VARCHAR(255),sector VARCHAR(255),investment_amount FLOAT); | SELECT SUM(investment_amount) as total_investment FROM investments WHERE fund_name = 'Impact Fund 2' AND sector = 'healthcare'; |
What was the minimum number of construction labor hours worked in Illinois in Q1 2022? | CREATE TABLE Construction_Labor_IL (id INT,hours_worked FLOAT,state VARCHAR(255),quarter VARCHAR(255)); INSERT INTO Construction_Labor_IL (id,hours_worked,state,quarter) VALUES (1,150,'Illinois','Q1 2022'); INSERT INTO Construction_Labor_IL (id,hours_worked,state,quarter) VALUES (2,180,'Illinois','Q1 2022'); INSERT INT... | SELECT MIN(hours_worked) FROM Construction_Labor_IL WHERE state = 'Illinois' AND quarter = 'Q1 2022'; |
What is the total number of companies that have implemented circular economy practices in each country? | CREATE TABLE companies (id INT,name TEXT,country TEXT,circular_economy BOOLEAN); INSERT INTO companies (id,name,country,circular_economy) VALUES (1,'Smart Manufacturing','USA',TRUE); INSERT INTO companies (id,name,country,circular_economy) VALUES (2,'Automated Assembly','Germany',FALSE); INSERT INTO companies (id,name,... | SELECT country, COUNT(*) AS company_count FROM companies WHERE circular_economy = TRUE GROUP BY country; |
What is the minimum funding received by a company founded by a person from the LGBTQ+ community in the AI sector? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founders TEXT,funding FLOAT); INSERT INTO companies (id,name,industry,founders,funding) VALUES (1,'AIforAll','AI','LGBTQ+',1000000.0); | SELECT MIN(funding) FROM companies WHERE founders = 'LGBTQ+' AND industry = 'AI'; |
What is the total number of accommodations provided by type and campus? | CREATE TABLE Accommodations (id INT,type VARCHAR(50),campus VARCHAR(50)); INSERT INTO Accommodations (id,type,campus) VALUES (1,'Sign Language Interpreting','East Campus'),(2,'Assistive Listening Devices','West Campus'); | SELECT Accommodations.type, Accommodations.campus, COUNT(*) as total FROM Accommodations GROUP BY Accommodations.type, Accommodations.campus; |
What is the total word count of articles in 'reputable_news' table and 'investigative_reports' table for each author? | CREATE TABLE reputable_news (article_id INT,author_name VARCHAR(50),author_age INT,word_count INT,publication_date DATE);CREATE TABLE investigative_reports (article_id INT,author_name VARCHAR(50),investigation_length INT,word_count INT,publication_date DATE); | SELECT author_name, SUM(word_count) FROM reputable_news GROUP BY author_name;SELECT author_name, SUM(word_count) FROM investigative_reports GROUP BY author_name; |
What is the average quantity of military equipment sold by Boeing to Asian countries in Q3 2018, excluding sales to China? | CREATE TABLE Military_Equipment_Sales(equipment_id INT,manufacturer VARCHAR(255),purchaser VARCHAR(255),sale_date DATE,quantity INT);INSERT INTO Military_Equipment_Sales(equipment_id,manufacturer,purchaser,sale_date,quantity) VALUES (1,'Boeing','Japan','2018-07-15',5),(2,'Boeing','China','2018-08-01',10),(3,'Boeing','S... | SELECT AVG(quantity) FROM Military_Equipment_Sales WHERE manufacturer = 'Boeing' AND purchaser NOT IN ('China') AND sale_date BETWEEN '2018-07-01' AND '2018-09-30'; |
What is the maximum number of electric vehicle charging stations in Tokyo, Berlin, and Sydney? | CREATE TABLE charging_stations (id INT,station_id INT,operator VARCHAR(255),city VARCHAR(255),num_chargers INT); INSERT INTO charging_stations (id,station_id,operator,city,num_chargers) VALUES (1,987,'GreenCharge','Tokyo',12); INSERT INTO charging_stations (id,station_id,operator,city,num_chargers) VALUES (2,654,'EcoPo... | SELECT MAX(num_chargers) FROM charging_stations WHERE city IN ('Tokyo', 'Berlin', 'Sydney'); |
What is the total donation amount for non-profit organizations in South Africa for the last 6 months? | CREATE TABLE donations_south_africa (id INT,donor_name TEXT,country TEXT,donation_amount DECIMAL,donation_date DATE); INSERT INTO donations_south_africa (id,donor_name,country,donation_amount,donation_date) VALUES (1,'Naledi Mthethwa','South Africa',150.00,'2021-10-15'); INSERT INTO donations_south_africa (id,donor_nam... | SELECT SUM(donation_amount) FROM donations_south_africa WHERE country = 'South Africa' AND donation_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
Which countries have implemented more than 5 climate adaptation measures in the energy sector? | CREATE TABLE country_energy(country TEXT,sector TEXT,measure_count INT); | SELECT country, measure_count FROM country_energy WHERE sector = 'energy' GROUP BY country HAVING measure_count > 5; |
What is the average policy impact score for education in the Midwest, and how many policies were evaluated? | CREATE TABLE policy_impact (service varchar(20),region varchar(20),score int); INSERT INTO policy_impact (service,region,score) VALUES ('Education','Midwest',80),('Healthcare','Midwest',70),('Education','South',75),('Healthcare','South',85); | SELECT AVG(score), COUNT(*) FROM policy_impact WHERE service = 'Education' AND region = 'Midwest'; |
List the number of volunteers who have volunteered for each program, broken down by month and year. | CREATE TABLE Programs (ProgramID int,Name varchar(50),Location varchar(50)); CREATE TABLE Volunteers (VolunteerID int,Name varchar(50),ProgramID int,VolunteerDate date); INSERT INTO Programs (ProgramID,Name,Location) VALUES (1,'Feeding America','USA'),(2,'Habitat for Humanity','Canada'); INSERT INTO Volunteers (Volunte... | SELECT P.Name, DATE_FORMAT(V.VolunteerDate, '%Y-%m') as Date, COUNT(V.VolunteerID) as Volunteers FROM Programs P JOIN Volunteers V ON P.ProgramID = V.ProgramID GROUP BY P.ProgramID, Date; |
List the number of threats detected by each system, in the last month, and the percentage of total threats each system detected. | CREATE TABLE threats(id INT,system VARCHAR(255),threat_level INT,date DATE); | SELECT system, COUNT(*) as count, ROUND(100 * COUNT(*) / (SELECT COUNT(*) FROM threats WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH)), 2) as percent FROM threats WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY system; |
Who are the top 2 cities in California with the highest average income? | CREATE TABLE cities (name TEXT,state TEXT,avg_income INTEGER); INSERT INTO cities (name,state,avg_income) VALUES ('City1','California',60000),('City2','California',70000),('City3','California',80000),('City4','California',50000),('City5','California',90000); | SELECT name, avg_income FROM (SELECT name, avg_income, ROW_NUMBER() OVER (ORDER BY avg_income DESC) as rank FROM cities WHERE state = 'California') as subquery WHERE rank <= 2; |
How many unique strains of cannabis were available in each dispensary as of March 1st, 2022? | CREATE TABLE strains (id INT,name VARCHAR(255)); INSERT INTO strains (id,name) VALUES (1,'Strain A'),(2,'Strain B'),(3,'Strain C'); CREATE TABLE inventory (dispensary_id INT,strain_id INT,quantity INT,available_date DATE); INSERT INTO inventory (dispensary_id,strain_id,quantity,available_date) VALUES (1,1,100,'2022-02-... | SELECT d.name, COUNT(DISTINCT i.strain_id) as unique_strains FROM inventory i JOIN dispensaries d ON i.dispensary_id = d.id WHERE i.available_date <= '2022-03-01' GROUP BY d.name; |
What are the names of the vessels that have not been used in any marine research expeditions? | CREATE TABLE research_expeditions (id INT PRIMARY KEY,vessel VARCHAR(255)); INSERT INTO research_expeditions (id,vessel) VALUES (1,'Ocean Explorer'),(2,'Marine Discoverer'); CREATE TABLE expedition_vessels (id INT PRIMARY KEY,expedition VARCHAR(255),vessel VARCHAR(255)); INSERT INTO expedition_vessels (id,expedition,ve... | SELECT v.vessel FROM expedition_vessels v LEFT JOIN research_expeditions re ON v.vessel = re.vessel WHERE re.vessel IS NULL; |
What is the total number of workers in the 'textile' department across all factories? | CREATE TABLE factories (factory_id INT,department VARCHAR(20));CREATE TABLE workers (worker_id INT,factory_id INT,salary DECIMAL(5,2),department VARCHAR(20)); INSERT INTO factories (factory_id,department) VALUES (1,'textile'),(2,'metal'),(3,'electronics'); INSERT INTO workers (worker_id,factory_id,salary,department) VA... | SELECT COUNT(w.worker_id) FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'textile'; |
What is the total revenue for each game in the 'gaming' database? | CREATE TABLE games (game_id INT,game_name VARCHAR(50),revenue FLOAT); INSERT INTO games (game_id,game_name,revenue) VALUES (1,'GameA',5000000),(2,'GameB',7000000),(3,'GameC',3000000); | SELECT game_name, SUM(revenue) as total_revenue FROM games GROUP BY game_name; |
What is the average healthcare access score for each country? | CREATE TABLE countries (country_id INT,country_name VARCHAR(50)); CREATE TABLE healthcare_access (access_id INT,country_id INT,score INT); | SELECT c.country_name, AVG(ha.score) AS average_score FROM countries c JOIN healthcare_access ha ON c.country_id = ha.country_id GROUP BY c.country_id; |
Add new species sighting record | species_sightings (species_id,location_id,sighted_date,sighted_time,sighted_by) | INSERT INTO species_sightings (species_id, location_id, sighted_date, sighted_time, sighted_by) |
Which countries produced more than 700 units of lutetium in 2018? | CREATE TABLE lutetium_production (country VARCHAR(20),year INT,quantity INT); INSERT INTO lutetium_production (country,year,quantity) VALUES ('China',2018,800),('USA',2018,750),('Australia',2018,650); | SELECT country FROM lutetium_production WHERE year = 2018 AND quantity > 700; |
What is the total budget for all completed projects in the 'Transportation' and 'Water Supply' categories? | CREATE TABLE projects (id INT,name VARCHAR(255),category VARCHAR(255),budget FLOAT,status VARCHAR(255)); INSERT INTO projects (id,name,category,budget,status) VALUES (9,'Storm Drainage Improvement','Public Works',750000.00,'Completed'),(10,'Sewer System Expansion','Public Works',1250000.00,'Completed'); | SELECT SUM(budget) FROM projects WHERE (category = 'Transportation' OR category = 'Water Supply') AND status = 'Completed'; |
Find forests with at least one tree species over 80 meters tall and less than 100,000 hectares in area? | CREATE TABLE forests (id INT,name VARCHAR(255),hectares FLOAT,country VARCHAR(255)); INSERT INTO forests (id,name,hectares,country) VALUES (1,'Black Forest',75000.0,'Germany'),(2,'Congo Basin',500000.0,'Congo'),(3,'Valdivian Rainforest',95000.0,'Chile'),(4,'Tongass National Forest',680000.0,'USA'); CREATE TABLE trees (... | SELECT forests.name FROM forests INNER JOIN tall_trees ON forests.id = tall_trees.forest_id WHERE forests.hectares < 100000 AND num_tall_trees > 0; |
What is the total amount of climate finance committed to each sector in North America in 2020? | CREATE TABLE north_america_finance (country VARCHAR(50),year INT,sector VARCHAR(50),amount FLOAT); INSERT INTO north_america_finance (country,year,sector,amount) VALUES ('Canada',2020,'Energy',5000000),('US',2020,'Transportation',6000000),('Canada',2020,'Agriculture',4000000),('US',2020,'Waste management',7000000); | SELECT sector, SUM(amount) as total_finance FROM north_america_finance WHERE country IN ('Canada', 'US') AND year = 2020 GROUP BY sector; |
What is the average price of non-sustainable materials for each supplier, showing only suppliers with more than 3 products using their materials? | CREATE TABLE supplier (id INT PRIMARY KEY,name VARCHAR(100),country VARCHAR(50),sustainable BOOLEAN); CREATE TABLE material (id INT PRIMARY KEY,name VARCHAR(100),supplier_id INT,price DECIMAL(5,2)); CREATE TABLE product (id INT PRIMARY KEY,name VARCHAR(100),manufacturer_id INT,price DECIMAL(5,2),sustainable BOOLEAN); C... | SELECT supplier_name, AVG(material.price) as average_price FROM material INNER JOIN product ON material.id = product.material_id INNER JOIN supplier ON material.supplier_id = supplier.id WHERE supplier.sustainable = FALSE GROUP BY supplier.name HAVING COUNT(*) > 3; |
Show the total number of military innovation projects and their corresponding budgets for each department in the 'Departments' and 'Innovation' tables | CREATE TABLE Departments (department TEXT,budget INT); CREATE TABLE Innovation (department TEXT,project TEXT); INSERT INTO Departments (department,budget) VALUES ('Research',500000),('Development',700000),('Testing',300000); INSERT INTO Innovation (department,project) VALUES ('Research','Stealth Technology'),('Developm... | SELECT Departments.department, COUNT(Innovation.project) AS total_projects, SUM(Departments.budget) AS total_budget FROM Departments INNER JOIN Innovation ON Departments.department = Innovation.department GROUP BY Departments.department; |
Which 'fair trade' certified manufacturers have the highest total quantity of sustainable materials used in their products? | CREATE TABLE manufacturers (manufacturer_id INT,name VARCHAR(50),fair_trade_certified CHAR(1)); INSERT INTO manufacturers (manufacturer_id,name,fair_trade_certified) VALUES (1,'ManufacturerA','Y'),(2,'ManufacturerB','N'),(3,'ManufacturerC','Y'); CREATE TABLE products (product_id INT,manufacturer_id INT,material VARCHAR... | SELECT manufacturer_id, SUM(quantity) AS total_quantity FROM products JOIN manufacturers ON products.manufacturer_id = manufacturers.manufacturer_id WHERE manufacturers.fair_trade_certified = 'Y' GROUP BY manufacturer_id ORDER BY total_quantity DESC; |
List all unique malware variants detected in the education sector in the last 6 months. | CREATE TABLE malware (id INT,variant VARCHAR(255),sector VARCHAR(255),date DATE); INSERT INTO malware (id,variant,sector,date) VALUES (1,'variant1','education','2022-01-01'); INSERT INTO malware (id,variant,sector,date) VALUES (2,'variant2','healthcare','2022-01-02'); | SELECT DISTINCT variant FROM malware WHERE sector = 'education' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
List the tools in the 'Accessibility' category with a price greater than 75 dollars? | CREATE TABLE HighPricedTools (id INT,name VARCHAR(255),category VARCHAR(255),price DECIMAL(10,2)); INSERT INTO HighPricedTools (id,name,category,price) VALUES (1,'AccessAdapt','Accessibility',800.00),(2,'EmpowerTech','Accessibility',700.00); | SELECT name FROM HighPricedTools WHERE category = 'Accessibility' AND price > 75; |
List all countries with deep-sea exploration vessels and the number of vessels they have.' | CREATE TABLE countries (country_name TEXT,country_code TEXT); CREATE TABLE vessels (name TEXT,country_code TEXT); CREATE TABLE deep_sea_vessels (name TEXT,type TEXT); | SELECT countries.country_name, COUNT(vessels.name) FROM countries JOIN vessels ON countries.country_code = vessels.country_code JOIN deep_sea_vessels ON vessels.name = deep_sea_vessels.name WHERE deep_sea_vessels.type = 'Deep Sea Exploration' GROUP BY countries.country_name; |
How many citizen feedback records were created by each citizen in 2022? | CREATE TABLE feedback (id INT,citizen_id INT,created_at DATETIME); INSERT INTO feedback (id,citizen_id,created_at) VALUES (1,1,'2022-01-01 12:34:56'),(2,1,'2022-01-15 10:20:34'),(3,2,'2022-02-20 16:45:01'); | SELECT citizen_id, COUNT(*) as num_records FROM feedback WHERE created_at BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY citizen_id; |
What is the total labor cost for 'Civil Engineering' projects in 'California'? | CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),StartDate DATE,EndDate DATE,Department VARCHAR(50),State VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,StartDate,EndDate,Department,State) VALUES (7,'Bridge Construction','2022-02-01','2022-08-31','Civil Engineering','California'); CREATE TABLE La... | SELECT SUM(LaborCosts.Cost) FROM Projects INNER JOIN LaborCosts ON Projects.ProjectID = LaborCosts.ProjectID WHERE Projects.Department = 'Civil Engineering' AND Projects.State = 'California'; |
What is the minimum cooking oil temperature used in preparing our vegetarian dishes? | CREATE TABLE cooking_oils (id INT,name VARCHAR(255),temperature INT); INSERT INTO cooking_oils (id,name,temperature) VALUES (1,'Olive Oil',180),(2,'Canola Oil',200); CREATE TABLE dishes (id INT,name VARCHAR(255),type VARCHAR(255),cooking_oil_id INT); INSERT INTO dishes (id,name,type,cooking_oil_id) VALUES (1,'Vegetable... | SELECT MIN(co.temperature) FROM cooking_oils co JOIN dishes d ON co.id = d.cooking_oil_id WHERE d.type = 'Vegetarian'; |
Insert a new record into the destination_marketing table with the following data: 'Australia', 'Sydney Opera House', '01-FEB-2023', '31-MAR-2023' | CREATE TABLE destination_marketing (destination VARCHAR(255),attraction VARCHAR(255),start_date DATE,end_date DATE); | INSERT INTO destination_marketing (destination, attraction, start_date, end_date) VALUES ('Australia', 'Sydney Opera House', '2023-02-01', '2023-03-31'); |
What is the average number of visitors to the dance events in the year 2020? | CREATE TABLE DanceEvents (id INT,year INT,visitors INT); INSERT INTO DanceEvents (id,year,visitors) VALUES (1,2019,300),(2,2020,400),(3,2021,500); | SELECT AVG(visitors) FROM DanceEvents WHERE year = 2020; |
How many community health workers have completed health equity training in each state? | CREATE TABLE workers (worker_id INT,worker_name VARCHAR(50),state_id INT,health_equity_training BOOLEAN); CREATE TABLE states (state_id INT,state_name VARCHAR(50)); | SELECT states.state_name, COUNT(*) as count FROM workers JOIN states ON workers.state_id = states.state_id WHERE health_equity_training = TRUE GROUP BY states.state_id; |
list all campaigns with their budgets | CREATE TABLE campaigns (campaign_id INT,campaign_name VARCHAR(50),budget INT); | SELECT campaign_name, budget FROM campaigns |
How many water quality issues were reported in New York in the year 2020? | CREATE TABLE water_quality_issues (id INT,state VARCHAR(20),year INT,issue_type VARCHAR(50)); | SELECT COUNT(*) FROM water_quality_issues WHERE state = 'New York' AND year = 2020; |
What is the total donation amount by each program? | CREATE TABLE donations (donor_id INT,program_id VARCHAR(20),amount DECIMAL(10,2)); INSERT INTO donations (donor_id,program_id,amount) VALUES (1,'Education',500.00),(2,'Health',300.00),(3,'Education',250.00); | SELECT program_id, SUM(amount) AS total_donation FROM donations GROUP BY program_id; |
Which spacecraft manufacturer has built the most spacecraft? | CREATE TABLE Spacecraft (SpacecraftID INT,Name VARCHAR(50),Manufacturer VARCHAR(50)); | SELECT Manufacturer, COUNT(*) FROM Spacecraft GROUP BY Manufacturer ORDER BY COUNT(*) DESC LIMIT 1; |
What is the average transaction value for customers in Asia in the last month, ordered by the transaction date in ascending order? | CREATE TABLE customer_transactions_2 (transaction_id INT,customer_id INT,transaction_value DECIMAL(10,2),transaction_date DATE,customer_region VARCHAR(20)); INSERT INTO customer_transactions_2 (transaction_id,customer_id,transaction_value,transaction_date,customer_region) VALUES (1,5,12000,'2021-08-05','Asia'),(2,6,350... | SELECT customer_region, AVG(transaction_value) as avg_transaction_value FROM customer_transactions_2 WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND customer_region = 'Asia' GROUP BY customer_region ORDER BY MIN(transaction_date); |
Find the average price of vegan cosmetics | CREATE TABLE cosmetics (id INT,name VARCHAR(50),price DECIMAL(5,2),vegan BOOLEAN); | SELECT AVG(price) FROM cosmetics WHERE vegan = TRUE; |
Which countries have no registered volunteers? | CREATE TABLE Volunteers (VolunteerID int,Name varchar(50),Country varchar(50)); INSERT INTO Volunteers (VolunteerID,Name,Country) VALUES (1,'Alice Johnson','USA'),(2,'Bob Brown','Canada'),(3,'Carlos Garcia','Mexico'),(4,'Daniela Green',NULL); | SELECT v.Country FROM Volunteers v WHERE v.Country NOT IN (SELECT DISTINCT Country FROM Volunteers WHERE Country IS NOT NULL); |
Find the number of members who own a wearable device and have attended a workout in LA | CREATE TABLE member_profiles (member_id INT,member_city VARCHAR(255),has_wearable BOOLEAN); CREATE TABLE gym_class_attendance (member_id INT,class_name VARCHAR(255)); | SELECT COUNT(DISTINCT m.member_id) FROM member_profiles m INNER JOIN gym_class_attendance gca ON m.member_id = gca.member_id WHERE m.member_city = 'LA' AND m.has_wearable = TRUE; |
Which menu items have had a 20% increase in sales since last month? | CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),sales_last_month INT,sales_this_month INT); INSERT INTO menu_items (menu_item_id,name,sales_last_month,sales_this_month) VALUES (1,'Pizza',50,60),(2,'Tacos',70,85),(3,'Pasta',80,70); | SELECT name, (sales_this_month - sales_last_month) / sales_last_month * 100 AS percentage_change FROM menu_items WHERE (sales_this_month - sales_last_month) / sales_last_month * 100 > 20; |
Which countries have the most organic food suppliers? | CREATE TABLE Suppliers (supplier_id INT,supplier_name VARCHAR(50),location VARCHAR(50),is_organic BOOLEAN); INSERT INTO Suppliers (supplier_id,supplier_name,location,is_organic) VALUES (1,'EcoFarms','Canada',TRUE),(2,'GreenHarvest','USA',TRUE),(3,'NatureSelect','Mexico',TRUE),(4,'BioGourmet','Germany',TRUE),(5,'FreshCa... | SELECT location, COUNT(*) as organic_supplier_count FROM Suppliers WHERE is_organic = TRUE GROUP BY location ORDER BY organic_supplier_count DESC; |
What is the total number of regulatory violations by country for digital assets classified as 'Security Tokens'? | CREATE TABLE violations (id INT,asset_id INT,country VARCHAR(50),type VARCHAR(50)); INSERT INTO violations (id,asset_id,country,type) VALUES (1,1,'USA','Security Tokens'),(2,2,'China','Security Tokens'),(3,3,'India','Utility Tokens'); CREATE TABLE assets (id INT,name VARCHAR(50),type VARCHAR(50)); INSERT INTO assets (i... | SELECT COUNT(*) FROM violations v INNER JOIN assets a ON v.asset_id = a.id WHERE a.type = 'Security Tokens'; |
What is the total price of artworks created by Indigenous Australian artists? | CREATE TABLE Artists (artist_id INT,artist_name VARCHAR(50),birth_date DATE,country VARCHAR(50)); INSERT INTO Artists (artist_id,artist_name,birth_date,country) VALUES (1,'Albert Namatjira','1902-07-28','Australia'); CREATE TABLE Artworks (artwork_id INT,title VARCHAR(50),year_made INT,artist_id INT,price FLOAT); INSER... | SELECT SUM(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id WHERE Artists.country = 'Australia' AND Artists.artist_name = 'Albert Namatjira'; |
Display creative AI applications that use image as input. | CREATE TABLE creative_ai (name VARCHAR(255),input_type VARCHAR(255)); INSERT INTO creative_ai (name,input_type) VALUES ('GANs','image'),('DeepDream','image'),('StyleTransfer','image'); | SELECT name FROM creative_ai WHERE input_type = 'image' |
What is the total weight of all satellites launched by India? | CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),LaunchDate DATETIME,CountryOfOrigin VARCHAR(50),Weight INT); INSERT INTO Satellites (SatelliteID,Name,LaunchDate,CountryOfOrigin,Weight) VALUES (1,'Sat1','2020-01-01','India',500),(2,'Sat2','2019-05-15','India',700); | SELECT SUM(Weight) FROM Satellites WHERE CountryOfOrigin = 'India'; |
Which artists have the most streams on the 'Spotify' platform? | CREATE TABLE artists (id INT,name VARCHAR(255)); CREATE TABLE streams (id INT,artist_id INT,platform VARCHAR(255),streams BIGINT); INSERT INTO artists VALUES (1,'Taylor Swift'); INSERT INTO streams VALUES (1,1,'Spotify',10000000); | SELECT a.name, SUM(s.streams) as total_streams FROM streams s JOIN artists a ON s.artist_id = a.id WHERE s.platform = 'Spotify' GROUP BY a.name ORDER BY total_streams DESC LIMIT 10; |
What is the average mental health score of students in 'Elementary' schools? | CREATE TABLE Schools (id INT,name VARCHAR(20)); INSERT INTO Schools (id,name) VALUES (1,'Elementary'),(2,'High School'),(3,'Middle School'); CREATE TABLE StudentMentalHealth (student_id INT,school_id INT,score INT); INSERT INTO StudentMentalHealth (student_id,school_id,score) VALUES (1,1,80),(2,1,90),(3,2,70),(4,3,85),... | SELECT AVG(smh.score) FROM StudentMentalHealth smh JOIN Schools s ON smh.school_id = s.id WHERE s.name = 'Elementary'; |
List all military bases, their countries, and connected intelligence operations | CREATE TABLE military_bases (id INT,base_name VARCHAR(50),country VARCHAR(50)); CREATE TABLE intelligence_operations (id INT,operation_name VARCHAR(50),base_id INT); INSERT INTO military_bases (id,base_name,country) VALUES (1,'Fort Bragg','USA'),(2,'Camp Pendleton','USA'),(3,'Canberra Deep Space Communication Complex',... | SELECT military_bases.base_name, military_bases.country, intelligence_operations.operation_name FROM military_bases INNER JOIN intelligence_operations ON military_bases.id = intelligence_operations.base_id; |
What is the percentage of climate finance allocated to the Indigenous communities? | CREATE TABLE finance_distribution (group VARCHAR(255),funding FLOAT); | SELECT (SUM(CASE WHEN group = 'Indigenous communities' THEN funding ELSE 0 END) / SUM(funding)) * 100 FROM finance_distribution; |
Delete records of timber production for the United States before 2010 | CREATE TABLE timber_production (country_code CHAR(3),year INT,volume INT); INSERT INTO timber_production (country_code,year,volume) VALUES ('CAN',2022,15000),('CAN',2011,13000),('USA',2022,20000),('USA',2011,16000),('MEX',2022,8000),('MEX',2011,7000); | DELETE FROM timber_production WHERE country_code = 'USA' AND year < 2010; |
How many marine conservation organizations were founded in the year 2000? | CREATE TABLE marine_conservation_orgs (org_name TEXT,country TEXT,year_founded INTEGER); INSERT INTO marine_conservation_orgs (org_name,country,year_founded) VALUES ('Ocean Conservancy','USA',1972),('Marine Conservation Society','UK',1983),('Coral Reef Alliance','USA',1994); | SELECT COUNT(*) FROM marine_conservation_orgs WHERE year_founded = 2000; |
What is the total installed capacity of wind farms in GW, grouped by country? | CREATE TABLE wind_farms (id INT,country VARCHAR(50),name VARCHAR(50),capacity FLOAT); INSERT INTO wind_farms (id,country,name,capacity) VALUES (1,'Germany','Windpark Nordsee',320.0),(2,'Spain','Parque Eolico Sierra Costera',300.0); | SELECT country, SUM(capacity) FROM wind_farms GROUP BY country; |
What is the highest scoring game by genre in the 'game_scores_data' schema? | CREATE TABLE game_scores_data (game_id INT,genre VARCHAR(255),score INT); INSERT INTO game_scores_data VALUES (1,'FPS',90),(2,'RPG',85),(3,'Strategy',80),(4,'FPS',82),(5,'Simulation',95),(6,'Adventure',98); | SELECT g.genre, MAX(g.score) AS highest_score_by_genre FROM game_scores_data g GROUP BY g.genre; |
Who is the manager of the fleet that contains the cargo ship with the highest capacity? | CREATE TABLE CargoShips(id INT,name VARCHAR(50),flag VARCHAR(50),capacity INT); CREATE TABLE Fleet(id INT,name VARCHAR(50),manager VARCHAR(50)); ALTER TABLE CargoShips ADD COLUMN fleet_id INT; UPDATE CargoShips SET fleet_id = 1 WHERE id = 1; INSERT INTO CargoShips VALUES (2,'Ocean Giant','Marshall Islands',200000); UPD... | SELECT Fleet.manager FROM Fleet INNER JOIN (SELECT fleet_id, MAX(capacity) as max_capacity FROM CargoShips GROUP BY fleet_id) AS max_capacities ON Fleet.id = max_capacities.fleet_id; |
What is the average monthly sales of organic skincare products in Canada? | CREATE TABLE sales (product_id INT,sale_date DATE,sales INT,product_type VARCHAR(50),region VARCHAR(50)); INSERT INTO sales (product_id,sale_date,sales,product_type,region) VALUES (1,'2021-01-01',500,'Organic Skincare','Canada'),(2,'2021-01-01',800,'Natural Makeup','Canada'); | SELECT AVG(sales) AS avg_monthly_sales FROM sales WHERE product_type = 'Organic Skincare' AND region = 'Canada' AND sale_date BETWEEN DATEADD(month, -12, CURRENT_DATE) AND CURRENT_DATE; |
Insert records into teacher professional development table | CREATE TABLE teacher_professional_development (teacher_id INT,professional_development_score INT); | INSERT INTO teacher_professional_development (teacher_id, professional_development_score) VALUES (1, 90), (2, 85), (3, 95); |
Who are the top 3 countries with the most heritage sites? | CREATE TABLE heritage_count (id INT,country VARCHAR(50),heritage_site VARCHAR(50)); INSERT INTO heritage_count (id,country,heritage_site) VALUES (1,'USA','Mesa Verde'); INSERT INTO heritage_count (id,country,heritage_site) VALUES (2,'Ecuador','Galapagos Islands'); | SELECT country, COUNT(heritage_site) FROM heritage_count GROUP BY country ORDER BY COUNT(heritage_site) DESC LIMIT 3; |
List the top 3 states with the highest average labor cost | CREATE TABLE construction_labor (state VARCHAR(2),labor_cost NUMERIC); INSERT INTO construction_labor (state,labor_cost) VALUES ('WA',45.5),('OR',38.3),('CA',52.1); | SELECT state, AVG(labor_cost) FROM construction_labor GROUP BY state ORDER BY AVG(labor_cost) DESC LIMIT 3; |
What is the total number of users from Mumbai and Delhi? | CREATE TABLE users (id INT PRIMARY KEY,name VARCHAR(50),age INT,city VARCHAR(50)); INSERT INTO users (id,name,age,city) VALUES (1,'Ravi',25,'Mumbai'); INSERT INTO users (id,name,age,city) VALUES (2,'Seetha',30,'Delhi'); INSERT INTO users (id,name,age,city) VALUES (3,'Kumar',35,'Mumbai'); | SELECT city, COUNT(*) as total FROM users WHERE city IN ('Mumbai', 'Delhi') GROUP BY city; |
What is the maximum rating given to game 2? | CREATE TABLE PlayerRatings (PlayerID INT,GameID INT,Rating FLOAT); INSERT INTO PlayerRatings (PlayerID,GameID,Rating) VALUES (1,1,8.5),(1,2,9.2),(2,1,7.8),(2,2,8.9),(3,1,8.1),(3,2,9.0); | SELECT MAX(Rating) FROM PlayerRatings WHERE GameID = 2; |
What is the average playtime of all players who achieved a rank of Platinum or higher in the game "Galactic Conquest"? | CREATE TABLE Players (PlayerID INT,GameName VARCHAR(20),Playtime FLOAT,Rank VARCHAR(10)); INSERT INTO Players (PlayerID,GameName,Playtime,Rank) VALUES (1,'Galactic Conquest',55.3,'Gold'),(2,'Galactic Conquest',76.8,'Platinum'),(3,'Galactic Conquest',34.9,'Bronze'); | SELECT AVG(Playtime) FROM Players WHERE GameName = 'Galactic Conquest' AND Rank IN ('Platinum', 'Diamond', 'Master'); |
Insert new public outreach event for site 789 | CREATE TABLE outreach_events (id INT PRIMARY KEY,site_id INT,event_type VARCHAR(50),date DATE,attendance INT); | INSERT INTO outreach_events (id, site_id, event_type, date, attendance) VALUES (1, 789, 'Public lecture', '2022-08-15', 30); |
What is the total number of resources extracted by month? | CREATE TABLE resource_extraction (id INT,site_id INT,extraction_date DATE,quantity INT); INSERT INTO resource_extraction (id,site_id,extraction_date,quantity) VALUES (1,1,'2022-01-01',100),(2,1,'2022-02-01',120),(3,1,'2022-03-01',150); | SELECT EXTRACT(MONTH FROM extraction_date) AS month, SUM(quantity) FROM resource_extraction GROUP BY month; |
What are the top 3 expensive events hosted by 'MLB' teams? | CREATE TABLE Events (event_id INT,event_name VARCHAR(255),team VARCHAR(255),price DECIMAL(5,2)); INSERT INTO Events VALUES (1,'Game 1','MLB',150.00),(2,'Game 2','MLB',200.00),(3,'Game 3','MLB',175.00); | SELECT event_name, price FROM Events WHERE team = 'MLB' ORDER BY price DESC LIMIT 3; |
Which regions have no protected species with an ID greater than 200? | CREATE TABLE ProtectedSpecies(species_id INT,species_name TEXT,region TEXT); INSERT INTO ProtectedSpecies (species_id,species_name,region) VALUES (201,'Frog','Region E'),(202,'Hawk','Region F'),(203,'Squirrel','Region F'); | SELECT region FROM ProtectedSpecies WHERE species_id > 200 GROUP BY region HAVING COUNT(*) = 0; |
List the top 3 socially responsible lenders by total loan amount in Africa, for loans issued in 2022, in descending order. | CREATE TABLE Loans (Id INT,Lender VARCHAR(20),Location VARCHAR(20),LoanType VARCHAR(20),LoanAmount DECIMAL(10,2),LoanYear INT); INSERT INTO Loans (Id,Lender,Location,LoanType,LoanAmount,LoanYear) VALUES (1,'LenderA','Africa','Socially Responsible',5000.00,2022),(2,'LenderB','Africa','Socially Responsible',7000.00,2022)... | SELECT Lender, SUM(LoanAmount) AS Total_Loan_Amount FROM Loans WHERE LoanType = 'Socially Responsible' AND LoanYear = 2022 GROUP BY Lender ORDER BY Total_Loan_Amount DESC LIMIT 3; |
Who is the most prolific artist in the 'Contemporary Art' genre? | CREATE TABLE Artworks (artwork_id INTEGER,title TEXT,artist_name TEXT,genre TEXT); INSERT INTO Artworks (artwork_id,title,artist_name,genre) VALUES (1,'Artwork 1','Alice','Contemporary Art'),(2,'Artwork 2','Bob','Contemporary Art'),(3,'Artwork 3','Charlotte','Contemporary Art'),(4,'Artwork 4','Dave','Contemporary Art')... | SELECT artist_name, COUNT(*) as count FROM Artworks WHERE genre = 'Contemporary Art' GROUP BY artist_name ORDER BY count DESC LIMIT 1 |
What are the top 5 countries with the most agricultural automation patents in the past 5 years? | CREATE TABLE patents (patent_id INTEGER,country TEXT,patent_date DATE); INSERT INTO patents VALUES (1,'USA','2022-01-01'),(2,'Germany','2021-12-31'); | SELECT country, COUNT(patent_id) as patent_count FROM patents WHERE patent_date >= CURDATE() - INTERVAL 5 YEAR GROUP BY country ORDER BY patent_count DESC LIMIT 5; |
How many students with visual impairments received accommodations in each department in 2020? | CREATE TABLE students (id INT,visual_impairment BOOLEAN,department VARCHAR(255)); INSERT INTO students (id,visual_impairment,department) VALUES (1,true,'science'),(2,false,'engineering'),(3,true,'science'),(4,true,'mathematics'),(5,false,'science'); CREATE TABLE accommodations (id INT,student_id INT,year INT); INSERT I... | SELECT s.department, COUNT(*) as accommodations FROM students s INNER JOIN accommodations a ON s.id = a.student_id WHERE s.visual_impairment = true AND a.year = 2020 GROUP BY s.department; |
What is the number of building permits issued in the United States for green building projects in the last 5 years? | CREATE TABLE Building_Permits (Permit_ID INT,Permit_Number VARCHAR(255),State VARCHAR(255),Project_Type VARCHAR(255),Issue_Date DATE); INSERT INTO Building_Permits (Permit_ID,Permit_Number,State,Project_Type,Issue_Date) VALUES (1,'12345','California','Green Building','2017-01-01'),(2,'67890','Texas','Green Building','2... | SELECT COUNT(*) FROM Building_Permits WHERE Project_Type = 'Green Building' AND Issue_Date >= DATEADD(year, -5, GETDATE()); |
What was the total amount donated by the 'young_donors' in 'support_table'? | CREATE TABLE support_table (donor VARCHAR(20),donation_amount INT,donor_category VARCHAR(20)); INSERT INTO support_table (donor,donation_amount,donor_category) VALUES ('John Doe',500,'young_donors'); | SELECT SUM(donation_amount) FROM support_table WHERE donor_category = 'young_donors'; |
Which clients in the West region have an account balance greater than 25000? | CREATE TABLE clients (client_id INT,name VARCHAR(50),region VARCHAR(50),account_balance DECIMAL(10,2)); INSERT INTO clients (client_id,name,region,account_balance) VALUES (1,'John Doe','West',30000.00),(2,'Jane Smith','East',20000.00); | SELECT client_id, name FROM clients WHERE region = 'West' AND account_balance > 25000; |
What is the total revenue generated from selling circular supply chain products in Europe? | CREATE TABLE sales (sale_id INT,product_id INT,price DECIMAL(5,2),sale_date DATE,is_circular_supply BOOLEAN,country TEXT); INSERT INTO sales (sale_id,product_id,price,sale_date,is_circular_supply,country) VALUES (1,1,39.99,'2022-02-12',true,'Germany'); | SELECT SUM(price) FROM sales WHERE is_circular_supply = true AND country = 'Europe'; |
List the total number of workers trained in workforce development programs in each country for 2021. | CREATE TABLE workforce_development (id INT,worker_id INT,country VARCHAR(50),program VARCHAR(50),date DATE); INSERT INTO workforce_development (id,worker_id,country,program,date) VALUES (1,1,'United States','SQL Training','2021-02-01'),(2,2,'Canada','AI Bootcamp','2021-03-01'),(3,3,'Mexico','Data Science Course','2021-... | SELECT country, COUNT(DISTINCT worker_id) as num_workers_trained FROM workforce_development WHERE DATE_FORMAT(date, '%Y') = '2021' GROUP BY country; |
Show the number of humanitarian assistance events per quarter in 2022. | CREATE TABLE Humanitarian_Assistance (Event_ID INT PRIMARY KEY,Quarter INT,Year INT); | SELECT Quarter, COUNT(*) FROM Humanitarian_Assistance WHERE Year = 2022 GROUP BY Quarter; |
Which sustainable materials are used by the most fashion brands, and how many fashion brands use each sustainable material? | CREATE TABLE MaterialUsage (BrandID INT,SustainableMaterial VARCHAR(50)); | SELECT TS.SustainableMaterial, COUNT(MU.BrandID) AS NumberOfBrandsUsingMaterial FROM TextileSuppliers TS INNER JOIN MaterialUsage MU ON TS.SustainableMaterial = MU.SustainableMaterial GROUP BY TS.SustainableMaterial ORDER BY NumberOfBrandsUsingMaterial DESC; |
Where are the renewable energy projects located with a capacity greater than 700 MW? | CREATE TABLE renewable_energy_projects (id INT,project_name VARCHAR(50),location VARCHAR(50),capacity_mw INT); INSERT INTO renewable_energy_projects (id,project_name,location,capacity_mw) VALUES (1,'Wind Farm XYZ','Texas',500); INSERT INTO renewable_energy_projects (id,project_name,location,capacity_mw) VALUES (2,'Sola... | SELECT location FROM renewable_energy_projects WHERE capacity_mw > 700; |
What is the number of socially responsible loans issued per month? | CREATE TABLE socially_responsible_loans (id INT,loan_date DATE,amount FLOAT); INSERT INTO socially_responsible_loans (id,loan_date,amount) VALUES (1,'2021-01-01',5000),(2,'2021-02-01',7000),(3,'2021-03-01',8000),(4,'2021-01-01',6000),(5,'2021-02-01',9000); | SELECT DATE_FORMAT(loan_date, '%Y-%m') as month, COUNT(*) as loans_issued FROM socially_responsible_loans GROUP BY month; |
Show the total budget for each program, the number of volunteers who have contributed to the program, and the total number of hours contributed. | CREATE TABLE programs (id INT,name TEXT,location TEXT,budget INT); CREATE TABLE volunteer_hours (id INT,volunteer_id INT,program_id INT,hours INT); | SELECT programs.name as program_name, SUM(volunteer_hours.hours) as total_hours, COUNT(DISTINCT volunteers.id) as num_volunteers, programs.budget as budget FROM programs LEFT JOIN volunteer_hours ON programs.id = volunteer_hours.program_id LEFT JOIN volunteers ON volunteer_hours.volunteer_id = volunteers.id GROUP BY pr... |
How many articles were published per month in 2021? | CREATE TABLE articles (id INT,publication_date DATE); INSERT INTO articles (id,publication_date) VALUES | SELECT MONTH(publication_date) AS month, COUNT(*) as num_articles FROM articles WHERE YEAR(publication_date) = 2021 GROUP BY month |
What is the maximum number of security incidents resolved by a single analyst in the last month? | CREATE TABLE SecurityIncidents(id INT,analyst_id VARCHAR(50),incidents INT,resolution_date DATE); | SELECT MAX(incidents) as max_incidents FROM SecurityIncidents WHERE resolution_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) GROUP BY analyst_id ORDER BY max_incidents DESC LIMIT 1; |
What are the locations where the area of illegal logging is greater than 400 in 2020? | CREATE TABLE illegal_logging (id INT,location VARCHAR(255),area DECIMAL(5,2),year INT); INSERT INTO illegal_logging (id,location,area,year) VALUES (1,'Congo Basin',350.0,2018),(2,'Amazon Rainforest',450.0,2020); | SELECT location FROM illegal_logging WHERE area > 400 AND year = 2020; |
List all smart contracts and their developers in the 'smart_contracts' and 'developers' tables, including contracts with no associated developers. | CREATE TABLE smart_contracts (contract_name VARCHAR(255),developer_id INT,creation_date DATE); CREATE TABLE developers (developer_id INT,developer_name VARCHAR(255)); | SELECT s.contract_name, d.developer_name FROM smart_contracts s LEFT JOIN developers d ON s.developer_id = d.developer_id; |
How many containers were handled by each port in the last month? | CREATE TABLE ports (id INT,name VARCHAR(255)); CREATE TABLE cargo (id INT,port_id INT,cargo_type VARCHAR(255),timestamp TIMESTAMP); INSERT INTO ports VALUES (1,'Port A'),(2,'Port B'),(3,'Port C'); INSERT INTO cargo VALUES (1,1,'container','2022-01-01 10:00:00'),(2,2,'container','2022-01-05 12:00:00'),(3,1,'container','... | SELECT p.name, COUNT(c.id) as container_count FROM ports p JOIN cargo c ON p.id = c.port_id WHERE c.timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND c.cargo_type = 'container' GROUP BY p.name; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.