instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the maximum budget allocated for intelligence operations in the 'Asia' region? | CREATE SCHEMA IF NOT EXISTS intelligence_operations; CREATE TABLE IF NOT EXISTS ops_budget (id INT PRIMARY KEY,region TEXT,budget DECIMAL(10,2)); INSERT INTO ops_budget (id,region,budget) VALUES (1,'Asia',20000000.00),(2,'Europe',15000000.00),(3,'Africa',10000000.00); | SELECT budget FROM intelligence_operations.ops_budget WHERE region = 'Asia' AND budget = (SELECT MAX(budget) FROM intelligence_operations.ops_budget WHERE region = 'Asia'); |
What is the percentage of donations received from each country in the last 6 months? | CREATE TABLE Donations (DonationID int,DonationDate date,Country varchar(20)); INSERT INTO Donations (DonationID,DonationDate,Country) VALUES (1,'2021-01-01','USA'),(2,'2021-02-01','Canada'),(3,'2021-03-01','Mexico'); | SELECT Country, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Donations WHERE DonationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)) as Percentage FROM Donations WHERE DonationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY Country; |
Identify the number of employees who were hired in each month, ranked by the number of new hires in descending order. | CREATE TABLE Employees (EmployeeID INT,HireDate DATE); | SELECT MONTH(HireDate) AS Month, COUNT(*) AS NewHires FROM Employees GROUP BY MONTH(HireDate) ORDER BY NewHires DESC; |
What is the average price of samarium produced in Europe? | CREATE TABLE samarium_prices (continent VARCHAR(10),price DECIMAL(5,2),year INT); INSERT INTO samarium_prices (continent,price,year) VALUES ('Europe',180.00,2020),('Europe',185.00,2019),('Europe',175.00,2018); | SELECT AVG(price) FROM samarium_prices WHERE continent = 'Europe'; |
What is the average rating of hotels in the United States that have more than 100 virtual tours? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,num_virtual_tours INT,rating FLOAT); INSERT INTO hotels (hotel_id,hotel_name,country,num_virtual_tours,rating) VALUES (1,'Hotel X','USA',120,4.2),(2,'Hotel Y','USA',50,3.9),(3,'Hotel Z','USA',150,4.6); | SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND num_virtual_tours > 100; |
Determine the total aid received by countries in Africa, excluding Egypt, from all aid agencies. | CREATE TABLE aid_agencies (country VARCHAR(50),aid_received INT); | SELECT country, SUM(aid_received) AS total_aid FROM aid_agencies WHERE country != 'Egypt' AND country LIKE '%Africa%' GROUP BY country; |
How many 'renewable' energy sources are used in the 'manufacturing' plant? | CREATE TABLE plants (id INT,name TEXT,energy_source TEXT); INSERT INTO plants (id,name,energy_source) VALUES (1,'manufacturing','renewable'),(2,'assembly','non-renewable'); | SELECT COUNT(*) FROM plants WHERE name = 'manufacturing' AND energy_source = 'renewable'; |
What is the distribution of disinformation topics in the media library? | CREATE TABLE media_library (id INT,title TEXT,genre TEXT,disinformation_topic TEXT); INSERT INTO media_library (id,title,genre,disinformation_topic) VALUES (1,'Media1','Drama','TopicA'),(2,'Media2','Comedy','TopicB'); | SELECT disinformation_topic, COUNT(*) as count FROM media_library GROUP BY disinformation_topic; |
Which marine species are affected by ocean acidification in the Arctic Ocean? | CREATE TABLE marine_species (species_id INT,species_name VARCHAR(255)); CREATE TABLE ocean_acidification (ocean_id INT,species_id INT,ocean VARCHAR(50)); INSERT INTO marine_species (species_id,species_name) VALUES (1,'Polar Bear'),(2,'Narwhal'); INSERT INTO ocean_acidification (ocean_id,species_id,ocean) VALUES (1,1,'Arctic'),(2,2,'Atlantic'); | SELECT marine_species.species_name FROM marine_species INNER JOIN ocean_acidification ON marine_species.species_id = ocean_acidification.species_id WHERE ocean_acidification.ocean = 'Arctic'; |
What is the total duration of workout sessions for each member in March 2023? | CREATE TABLE members (member_id INT,name VARCHAR(50),gender VARCHAR(10),dob DATE); INSERT INTO members (member_id,name,gender,dob) VALUES (1,'Ella Thompson','Female','2004-05-14'); INSERT INTO members (member_id,name,gender,dob) VALUES (2,'Frederick Johnson','Male','2003-12-20'); CREATE TABLE workout_sessions (session_id INT,member_id INT,session_date DATE,duration INT); INSERT INTO workout_sessions (session_id,member_id,session_date,duration) VALUES (1,1,'2023-03-02',45); INSERT INTO workout_sessions (session_id,member_id,session_date,duration) VALUES (2,1,'2023-03-05',60); INSERT INTO workout_sessions (session_id,member_id,session_date,duration) VALUES (3,2,'2023-03-07',75); INSERT INTO workout_sessions (session_id,member_id,session_date,duration) VALUES (4,1,'2023-03-13',30); | SELECT member_id, SUM(duration) AS total_duration_march_2023 FROM workout_sessions WHERE MONTH(session_date) = 3 AND YEAR(session_date) = 2023 GROUP BY member_id; |
How many unique digital assets are there on the Solana blockchain? | CREATE TABLE solana_assets (asset_address VARCHAR(44),asset_name VARCHAR(50)); | SELECT COUNT(DISTINCT asset_address) FROM solana_assets; |
Which volunteers have contributed more than 10 hours per week on average? | CREATE TABLE volunteers (id INT PRIMARY KEY,name TEXT,region_id INT,hours_per_week DECIMAL(3,1)); INSERT INTO volunteers (id,name,region_id,hours_per_week) VALUES (1,'Alice',1,15.0); INSERT INTO volunteers (id,name,region_id,hours_per_week) VALUES (2,'Bob',1,8.5); INSERT INTO volunteers (id,name,region_id,hours_per_week) VALUES (3,'Carol',2,22.5); | SELECT name FROM volunteers WHERE hours_per_week > (SELECT AVG(hours_per_week) FROM volunteers); |
Find the number of different species of fish in each aquaculture farm. | CREATE TABLE Farm (id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE Species (id INT,name VARCHAR(50),scientific_name VARCHAR(50),farm_id INT); | SELECT f.name, COUNT(DISTINCT s.id) FROM Farm f JOIN Species s ON f.id = s.farm_id GROUP BY f.name; |
Insert new record into waste_generation table for location 'Tokyo' and waste generation 300 tons | CREATE TABLE waste_generation (location VARCHAR(50),waste_type VARCHAR(50),generation INT); | INSERT INTO waste_generation (location, waste_type, generation) VALUES ('Tokyo', 'plastic', 300); |
How many players have achieved a rank of Diamond or higher in the game "Space Odyssey"? | CREATE TABLE SpaceOdysseyPlayers (PlayerID INT,PlayerName VARCHAR(50),PlaytimeMinutes INT,Rank VARCHAR(10)); INSERT INTO SpaceOdysseyPlayers VALUES (1,'JimBrown',600,'Diamond'),(2,'KarenGreen',400,'Gold'),(3,'OliverWhite',900,'Diamond'),(4,'SamBlack',500,'Platinum'); | SELECT COUNT(*) FROM SpaceOdysseyPlayers WHERE Rank IN ('Diamond', 'Master'); |
What is the maximum salary for employees who identify as male and work in the marketing department? | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),Salary DECIMAL(10,2),Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,Gender,Salary,Department) VALUES (1,'Female',85000.00,'IT'),(2,'Male',95000.00,'Marketing'),(3,'Non-binary',70000.00,'HR'),(4,'Female',80000.00,'IT'),(5,'Male',90000.00,'Marketing'),(6,'Female',87000.00,'IT'); | SELECT MAX(e.Salary) as MaxSalary FROM Employees e WHERE e.Gender = 'Male' AND e.Department = 'Marketing'; |
What is the total number of employees hired in the year 2020, grouped by their department? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,HireDate,Department) VALUES (1,'2018-01-01','HR'),(2,'2020-03-15','IT'),(3,'2019-08-25','IT'),(4,'2020-11-04','HR'); | SELECT Department, COUNT(*) FROM Employees WHERE YEAR(HireDate) = 2020 GROUP BY Department; |
Identify safety incidents involving chemical B in the past year. | CREATE TABLE safety_incidents (chemical VARCHAR(20),incident_date DATE); INSERT INTO safety_incidents VALUES ('chemical B','2021-12-15'); INSERT INTO safety_incidents VALUES ('chemical C','2022-02-01'); | SELECT * FROM safety_incidents WHERE chemical = 'chemical B' AND incident_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE(); |
What is the number of autonomous driving research papers published in the research_papers table for each year? | CREATE TABLE research_papers (id INT,title VARCHAR(100),publication_year INT,abstract TEXT); INSERT INTO research_papers (id,title,publication_year,abstract) VALUES (1,'Deep Learning for Autonomous Driving',2021,'In this paper,we propose a deep learning approach for autonomous driving...'),(2,'Motion Planning for Autonomous Vehicles',2020,'In this paper,we propose a motion planning algorithm for autonomous vehicles...'),(3,'Simulation for Autonomous Driving Testing',2022,'In this paper,we propose a simulation-based testing framework for autonomous driving...'); | SELECT publication_year, COUNT(*) FROM research_papers GROUP BY publication_year; |
What is the release year of the first movie with a budget over 70 million? | CREATE TABLE Movies (title VARCHAR(255),release_year INT,budget INT); INSERT INTO Movies (title,release_year,budget) VALUES ('Movie1',2015,50000000),('Movie2',2016,75000000),('Movie3',2017,60000000),('Movie4',2018,80000000),('Movie5',2019,90000000); | SELECT release_year FROM Movies WHERE budget > 70000000 ORDER BY release_year ASC LIMIT 1; |
What is the maximum budget for biosensor technology development projects in Q2 2021? | CREATE TABLE biosensor_tech(id INT,project_name TEXT,budget DECIMAL(10,2),quarter INT,year INT); | SELECT MAX(budget) FROM biosensor_tech WHERE quarter = 2 AND year = 2021; |
How many job applicants were there in the last 6 months, broken down by job category? | CREATE TABLE JobApplications (ApplicationID INT,ApplicationDate DATE,JobCategory VARCHAR(255)); INSERT INTO JobApplications (ApplicationID,ApplicationDate,JobCategory) VALUES (1,'2022-01-01','Software Engineer'),(2,'2022-02-15','Data Analyst'); | SELECT MONTH(ApplicationDate) AS Month, JobCategory, COUNT(*) FROM JobApplications WHERE ApplicationDate >= DATEADD(MONTH, -6, GETDATE()) GROUP BY JobCategory, MONTH(ApplicationDate); |
Add new union member records for the month of April in the Midwestern region. | CREATE TABLE union_membership (id INT,member_name VARCHAR(255),join_date DATE,is_new_member BOOLEAN); | INSERT INTO union_membership (id, member_name, join_date, is_new_member) VALUES (6, 'Member F', '2022-04-01', true), (7, 'Member G', '2022-04-15', true); |
How many hotels in the 'Urban_Hotels' table have a rating of 4 or higher? | CREATE TABLE Urban_Hotels (hotel_id INT,hotel_name TEXT,rating INT); INSERT INTO Urban_Hotels (hotel_id,hotel_name,rating) VALUES (1,'Hotel Paris',4),(2,'New York Palace',5); | SELECT COUNT(*) FROM Urban_Hotels WHERE rating >= 4; |
How many players have participated in esports events in the last 6 months from the 'Esports_Players' table? | CREATE TABLE Esports_Players (Player_ID INT,Event_Date DATE); | SELECT COUNT(*) FROM Esports_Players WHERE Event_Date >= DATE(NOW()) - INTERVAL 6 MONTH; |
Identify the total amount of water wasted in the city of Dallas for the month of July in 2019 | CREATE TABLE water_waste (waste_id INT,waste_date DATE,city VARCHAR(50),amount FLOAT); INSERT INTO water_waste (waste_id,waste_date,city,amount) VALUES (1,'2019-07-01','Dallas',100),(2,'2019-07-02','Houston',120),(3,'2019-07-03','Dallas',150); | SELECT SUM(amount) as total_wasted FROM water_waste WHERE waste_date BETWEEN '2019-07-01' AND '2019-07-31' AND city = 'Dallas'; |
What is the total number of successful satellite launches by Japanese and Brazilian space programs? | CREATE TABLE Satellite_Launches (launch_date DATE,country VARCHAR(255),success BOOLEAN); INSERT INTO Satellite_Launches (launch_date,country,success) VALUES ('2020-01-01','Japan',TRUE),('2020-02-01','Brazil',FALSE),('2020-03-01','Japan',TRUE),('2020-04-01','Brazil',TRUE),('2020-05-01','Japan',FALSE); | SELECT SUM(success) FROM (SELECT success FROM Satellite_Launches WHERE country IN ('Japan', 'Brazil')) AS subquery WHERE success = TRUE; |
What is the minimum number of wins for players who play "Rhythm Game 2023"? | CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Game VARCHAR(50),Wins INT); INSERT INTO Players (PlayerID,PlayerName,Game,Wins) VALUES (1,'Sophia Garcia','Virtual Reality Chess Extreme',35),(2,'Daniel Kim','Rhythm Game 2023',40),(3,'Lila Hernandez','Racing Simulator 2022',28),(4,'Kenji Nguyen','Rhythm Game 2023',45); | SELECT MIN(Wins) FROM Players WHERE Game = 'Rhythm Game 2023'; |
List the top 3 most streamed songs for users from South America. | CREATE TABLE artists (id INT PRIMARY KEY,name VARCHAR(255),genre VARCHAR(255),country VARCHAR(255)); CREATE TABLE songs (id INT PRIMARY KEY,title VARCHAR(255),artist_id INT,released DATE); CREATE TABLE streams (id INT PRIMARY KEY,song_id INT,user_id INT,stream_date DATE,FOREIGN KEY (song_id) REFERENCES songs(id)); CREATE TABLE users (id INT PRIMARY KEY,gender VARCHAR(50),age INT,country VARCHAR(255)); | SELECT s.title, COUNT(s.id) AS total_streams FROM streams s JOIN users u ON s.user_id = u.id WHERE u.country = 'South America' GROUP BY s.title ORDER BY total_streams DESC LIMIT 3; |
What is the total number of articles and the percentage of articles in the 'politics' category, for each country? | CREATE TABLE articles (article_id INT,title VARCHAR(50),category VARCHAR(20),country VARCHAR(20)); INSERT INTO articles (article_id,title,category,country) VALUES (1,'Politics in 2022','politics','USA'),(2,'British Politics','politics','UK'),(3,'Indian Economy','economy','India'); | SELECT country, COUNT(*) as article_count, 100.0 * COUNT(CASE WHEN category = 'politics' THEN 1 END) / COUNT(*) as politics_percentage FROM articles GROUP BY country; |
List all states that have mental health parity laws | CREATE TABLE mental_health_parity (id INT PRIMARY KEY,state VARCHAR(2),parity_law TEXT,year INT); | SELECT state FROM mental_health_parity WHERE parity_law IS NOT NULL; |
Insert a new record into the 'survey_results' table with ID '001', mine_id 'Mine_001', survey_date '2022-03-15', and result 'Satisfactory' | CREATE TABLE survey_results (id VARCHAR(10),mine_id VARCHAR(10),survey_date DATE,result VARCHAR(50)); | INSERT INTO survey_results (id, mine_id, survey_date, result) VALUES ('001', 'Mine_001', '2022-03-15', 'Satisfactory'); |
What is the total amount donated by donors with an age between 20 and 30? | CREATE TABLE donors (id INT,name TEXT,age INT,donation FLOAT); INSERT INTO donors (id,name,age,donation) VALUES (1,'John Doe',35,500.00); INSERT INTO donors (id,name,age,donation) VALUES (2,'Jane Smith',25,200.00); INSERT INTO donors (id,name,age,donation) VALUES (3,'Bob Johnson',45,1000.00); | SELECT SUM(donation) FROM donors WHERE age BETWEEN 20 AND 30; |
What is the percentage of total workplace injuries for Union D, in the year 2021? | CREATE TABLE union_table_2021 (union_name VARCHAR(255),total_injuries INT); INSERT INTO union_table_2021 (union_name,total_injuries) VALUES ('Union A',350),('Union B',450),('Union C',550),('Union D',600); | SELECT (SUM(total_injuries) / (SELECT SUM(total_injuries) FROM union_table_2021) * 100) as injury_percentage FROM union_table_2021 WHERE union_name = 'Union D' AND YEAR(incident_date) = 2021; |
What is the number of vaccinated individuals and total population in each state, ordered by the percentage of vaccinated individuals, descending? | CREATE TABLE states (id INT,name TEXT,total_population INT,vaccinated_individuals INT); INSERT INTO states (id,name,total_population,vaccinated_individuals) VALUES (1,'State A',1000000,600000),(2,'State B',700000,450000),(3,'State C',1200000,900000),(4,'State D',800000,550000); | SELECT name, total_population, vaccinated_individuals, (vaccinated_individuals * 100.0 / total_population) as vaccination_percentage FROM states ORDER BY vaccination_percentage DESC; |
Who are the top 5 donors to community development initiatives in Guatemala? | CREATE TABLE donors(id INT,name TEXT,country TEXT,donation INT); INSERT INTO donors(id,name,country,donation) VALUES (1,'USAID','USA',50000),(2,'European Union','Belgium',40000); CREATE TABLE donations(id INT,donor_id INT,initiative_id INT,amount INT); INSERT INTO donations(id,donor_id,initiative_id,amount) VALUES (1,1,1,10000),(2,2,2,15000); | SELECT d.name FROM donors d JOIN (SELECT donor_id, SUM(amount) as total_donation FROM donations GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5) dd ON d.id = dd.donor_id; |
Which cultural heritage sites in Mexico and Peru had over 15000 visitors in 2021? | CREATE TABLE sites (site_id INT,site_name VARCHAR(50),country VARCHAR(50),year INT,visitors INT); INSERT INTO sites (site_id,site_name,country,year,visitors) VALUES (1,'Chichen Itza','Mexico',2021,18000),(2,'Teotihuacan','Mexico',2021,16000),(3,'Machu Picchu','Peru',2021,19000),(4,'Nazca Lines','Peru',2021,14000); | SELECT COUNT(*) FROM sites WHERE country IN ('Mexico', 'Peru') AND year = 2021 AND visitors > 15000; |
Present the total number of cases and billing amount for each attorney. | CREATE TABLE AttorneyInfo (AttorneyID INT,Cases INT,Amount DECIMAL(10,2)); INSERT INTO AttorneyInfo (AttorneyID,Cases,Amount) VALUES (1,1000,5000),(2,1500,7000); | SELECT a.Name, SUM(a.Cases) AS TotalCases, SUM(a.Amount) AS TotalBilling FROM AttorneyInfo a GROUP BY a.Name; |
What is the average number of containers handled per day by each crane in 'Hong Kong'? | CREATE TABLE port (port_id INT,name TEXT,created_at DATETIME);CREATE TABLE crane (crane_id INT,port_id INT,name TEXT);CREATE TABLE container (container_id INT,crane_id INT,weight INT,created_at DATETIME);INSERT INTO port VALUES (4,'Hong Kong','2022-01-01'); | SELECT crane.name, AVG(COUNT(container.container_id)) FROM crane JOIN port ON crane.port_id = port.port_id JOIN container ON crane.crane_id = container.crane_id WHERE port.name = 'Hong Kong' GROUP BY crane.name, DATE(container.created_at); |
What is the total number of oil wells in the 'Onshore' and 'Offshore' regions? | CREATE TABLE if not exists oil_wells (id INT PRIMARY KEY,well_name TEXT,region TEXT,type TEXT); INSERT INTO oil_wells (id,well_name,region,type) VALUES (1,'Well A','Onshore','Oil'),(2,'Well B','Offshore','Oil'),(3,'Well C','Onshore','Gas'); | SELECT COUNT(*) FROM oil_wells WHERE region IN ('Onshore', 'Offshore') AND type = 'Oil'; |
How many labor hours have been spent on mining site A in each month of the past year? | CREATE TABLE mining_site_labor_hours (site_id INT,hours INT,labor_date DATE); INSERT INTO mining_site_labor_hours (site_id,hours,labor_date) VALUES (1,250,'2022-01-01'),(1,275,'2022-01-02'),(1,300,'2022-02-01'),(1,350,'2022-02-02'),(1,400,'2022-03-01'),(1,450,'2022-03-02'); | SELECT DATE_FORMAT(labor_date, '%Y-%m') AS month, SUM(hours) FROM mining_site_labor_hours WHERE site_id = 1 AND labor_date >= '2022-01-01' AND labor_date < '2023-01-01' GROUP BY month; |
What is the number of unique users who have streamed songs from artists who have released a new album in the last year? | CREATE TABLE user_streams (user_id INT,artist_id INT,stream_date DATE); CREATE TABLE artist_albums (artist_id INT,release_date DATE); | SELECT COUNT(DISTINCT u.user_id) FROM user_streams u JOIN artist_albums a ON u.artist_id = a.artist_id WHERE a.release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
What is the average sentiment score for African American authors' books? | CREATE TABLE authors (id INT,name VARCHAR(255),ethnicity VARCHAR(255)); INSERT INTO authors (id,name,ethnicity) VALUES (1,'Toni Morrison','African American'); CREATE TABLE books (id INT,title VARCHAR(255),sentiment FLOAT,author_id INT); INSERT INTO books (id,title,sentiment,author_id) VALUES (1,'Beloved',8.5,1); | SELECT AVG(sentiment) FROM books JOIN authors ON books.author_id = authors.id WHERE authors.ethnicity = 'African American' |
What is the total revenue for each menu category this month, with a 15% discount applied? | CREATE TABLE menu (category VARCHAR(255),price NUMERIC); INSERT INTO menu (category,price) VALUES ('Appetizers',10),('Entrees',20),('Desserts',15); | SELECT category, SUM(price * 0.85) FROM menu GROUP BY category; |
Show the vehicles that were tested in safety tests but not included in autonomous driving research. | CREATE TABLE SafetyTestingVehicle (TestID INT,Vehicle VARCHAR(20),TestResult VARCHAR(10)); CREATE TABLE AutonomousDrivingData (TestID INT,Vehicle VARCHAR(20),MaxSpeed FLOAT,MinSpeed FLOAT); | SELECT Vehicle FROM SafetyTestingVehicle WHERE Vehicle NOT IN (SELECT Vehicle FROM AutonomousDrivingData); |
Which rural infrastructure projects have a higher budget than any community development project? | CREATE TABLE rural_infrastructure (id INT,name VARCHAR(50),type VARCHAR(50),budget FLOAT); INSERT INTO rural_infrastructure (id,name,type,budget) VALUES (1,'Solar Irrigation','Agricultural Innovation',150000.00),(2,'Wind Turbines','Rural Infrastructure',200000.00); CREATE TABLE community_development (id INT,name VARCHAR(50),type VARCHAR(50),budget FLOAT); INSERT INTO community_development (id,name,type,budget) VALUES (1,'Green Spaces','Community Development',75000.00),(2,'Smart Street Lighting','Community Development',120000.00),(3,'Cultural Center','Community Development',100000.00); | SELECT name, budget FROM rural_infrastructure WHERE budget > (SELECT MAX(budget) FROM community_development); |
Find the number of vegan nail polish products sold in the USA in Q2 2021. | CREATE TABLE cosmetics_sales (product VARCHAR(255),country VARCHAR(255),sale_date DATE,revenue DECIMAL(10,2)); CREATE TABLE cosmetics (product VARCHAR(255),product_category VARCHAR(255),vegan BOOLEAN); CREATE TABLE countries (country VARCHAR(255),continent VARCHAR(255)); INSERT INTO countries (country,continent) VALUES ('USA','North America'); CREATE VIEW q2_sales AS SELECT * FROM cosmetics_sales WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30'; | SELECT COUNT(*) FROM q2_sales JOIN cosmetics ON q2_sales.product = cosmetics.product JOIN countries ON q2_sales.country = countries.country WHERE cosmetics.product_category = 'Nail Polishes' AND cosmetics.vegan = true AND countries.country = 'USA'; |
What is the total donation amount for organizations with the word "effective" in their names, in the 'Donations' and 'Organizations' tables? | CREATE TABLE Organizations (id INT,name VARCHAR(50),city VARCHAR(50),state VARCHAR(50),country VARCHAR(50)); | SELECT SUM(amount) as total_effective_donations FROM Donations JOIN Organizations ON Donations.organization_id = Organizations.id WHERE Organizations.name LIKE '%effective%'; |
What is the percentage of the population that is African American in Louisiana? | CREATE TABLE racial_composition (id INT,state VARCHAR(50),population INT,african_american INT); INSERT INTO racial_composition (id,state,population,african_american) VALUES (1,'Louisiana',4648794,1168666); | SELECT (african_american * 100.0 / population) FROM racial_composition WHERE state = 'Louisiana'; |
Which spacecraft have a mass between 5000 and 7000 tons? | CREATE TABLE SpacecraftManufacturing (id INT,company VARCHAR(255),mass FLOAT); INSERT INTO SpacecraftManufacturing (id,company,mass) VALUES (1,'Aerospace Inc.',5000.0),(2,'Galactic Corp.',7000.0),(3,'Space Tech',6500.0); | SELECT * FROM SpacecraftManufacturing WHERE mass BETWEEN 5000 AND 7000; |
Find the minimum transaction date for each investment strategy in the "InvestmentStrategies" table. | CREATE TABLE InvestmentStrategies (InvestmentStrategyID INT,CustomerID INT,TransactionDate DATE,TransactionAmount DECIMAL(10,2)); | SELECT InvestmentStrategyID, MIN(TransactionDate) as MinTransactionDate FROM InvestmentStrategies GROUP BY InvestmentStrategyID; |
What is the total time spent in space for astronauts with flight experience in military aviation? | CREATE TABLE Astronaut (Id INT,Name VARCHAR(50),SpaceMissionId INT,FlightExperience VARCHAR(50),TotalTimeInSpace INT); | SELECT SUM(TotalTimeInSpace) FROM Astronaut WHERE FlightExperience LIKE '%military%aviation%'; |
Show the total number of community health workers | CREATE TABLE healthcare.CommunityHealthWorker(worker_id INT PRIMARY KEY,name VARCHAR(100),cultural_competency_score FLOAT); INSERT INTO healthcare.CommunityHealthWorker (worker_id,name,cultural_competency_score) VALUES (1,'Jane Smith',85.5),(2,'Maria Garcia',92.3),(3,'David Kim',88.7),(4,'Fatima Patel',93.1); | SELECT COUNT(*) FROM healthcare.CommunityHealthWorker; |
What is the percentage of energy generated from fossil fuels in Mexico? | CREATE TABLE energy_generation (country VARCHAR(255),energy_source VARCHAR(255),percentage INT); INSERT INTO energy_generation (country,energy_source,percentage) VALUES ('Mexico','Fossil Fuels',80),('Mexico','Renewable',20); | SELECT percentage FROM energy_generation WHERE country = 'Mexico' AND energy_source = 'Fossil Fuels'; |
What is the total value of assets for institutional clients? | CREATE TABLE clients (id INT,client_type VARCHAR(20),asset_value DECIMAL(15,2)); INSERT INTO clients (id,client_type,asset_value) VALUES (1,'Institutional',5000000.00),(2,'Retail',100000.00),(3,'Institutional',7000000.00); | SELECT SUM(asset_value) FROM clients WHERE client_type = 'Institutional'; |
How many renewable energy projects were completed in each region in the past 3 years? | CREATE TABLE renewable_projects (id INT,region VARCHAR(50),completion_year INT); | SELECT region, COUNT(*) FROM renewable_projects WHERE completion_year >= YEAR(CURRENT_DATE) - 3 GROUP BY region; |
What is the daily transaction volume for high-risk customers in the past week? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),region VARCHAR(50),risk_level INT); CREATE TABLE transactions (transaction_id INT,customer_id INT,amount DECIMAL(10,2),transaction_date DATE); | SELECT t.transaction_date, c.customer_id, COUNT(t.transaction_id) as transaction_count FROM transactions t INNER JOIN customers c ON t.customer_id = c.customer_id WHERE c.risk_level > 7 AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) GROUP BY t.transaction_date, c.customer_id; |
What is the maximum number of public transportation trips taken in a single day in each city? | CREATE TABLE Daily_Transportation (id INT,city VARCHAR(50),trips INT,date DATE); | SELECT city, MAX(trips) FROM Daily_Transportation GROUP BY city; |
What was the total revenue for each cuisine type in June 2021? | CREATE TABLE restaurant_revenue (date DATE,cuisine VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO restaurant_revenue (date,cuisine,revenue) VALUES ('2021-06-01','Italian',5000.00),('2021-06-01','Mexican',7000.00),('2021-06-02','Italian',6000.00),('2021-06-02','Mexican',8000.00); | SELECT cuisine, SUM(revenue) as total_revenue FROM restaurant_revenue WHERE date in ('2021-06-01', '2021-06-02') GROUP BY cuisine; |
Delete all records in the "tech_companies" table where the "industry" is "cloud computing" | CREATE TABLE tech_companies (name TEXT,industry TEXT,year_founded INTEGER,location TEXT); INSERT INTO tech_companies (name,industry,year_founded,location) VALUES ('Google','Cloud Computing',1998,'Mountain View'); INSERT INTO tech_companies (name,industry,year_founded,location) VALUES ('Microsoft','Cloud Computing',1975,'Redmond'); INSERT INTO tech_companies (name,industry,year_founded,location) VALUES ('Amazon','E-commerce',1994,'Seattle'); | DELETE FROM tech_companies WHERE industry = 'Cloud Computing'; |
What is the total revenue generated from ticket sales for each sport in the 'ticket_sales' table? | CREATE TABLE ticket_sales (id INT PRIMARY KEY,event_id INT,sport VARCHAR(50),tickets_sold INT,price DECIMAL(5,2)); CREATE TABLE events (id INT PRIMARY KEY,name VARCHAR(100),date DATE,location VARCHAR(100)); | SELECT t.sport, SUM(t.price * t.tickets_sold) as total_revenue FROM ticket_sales t JOIN events e ON t.event_id = e.id GROUP BY t.sport; |
Identify the most common types of crimes in each district. | CREATE TABLE districts (district_id INT,district_name VARCHAR(255));CREATE TABLE crimes (id INT,district_id INT,crime_type VARCHAR(255),crime_date DATE,crime_count INT); | SELECT district_name, crime_type, SUM(crime_count) AS total_crimes FROM districts d JOIN crimes c ON d.district_id = c.district_id GROUP BY district_name, crime_type ORDER BY total_crimes DESC; |
What is the maximum account balance for customers in the Retail division, excluding customers with account balances below $10,000? | CREATE TABLE Retail (customer_id INT,name VARCHAR(50),division VARCHAR(20),account_balance DECIMAL(10,2)); INSERT INTO Retail (customer_id,name,division,account_balance) VALUES (1,'John Doe','Retail',5000.00),(2,'Jane Smith','Retail',12000.00),(3,'Jim Brown','Retail',7000.00); | SELECT MAX(account_balance) FROM Retail WHERE division = 'Retail' AND account_balance >= 10000; |
What is the total amount of relief aid provided by 'UNICEF' for disasters in 'Country X'? | CREATE TABLE Relief_Aid (id INT,disaster_id INT,organization VARCHAR(50),amount FLOAT,date DATE); INSERT INTO Relief_Aid (id,disaster_id,organization,amount,date) VALUES (4,5,'UNICEF',9000,'2021-09-05'); CREATE TABLE Disaster (id INT,name VARCHAR(50),location VARCHAR(50),type VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO Disaster (id,name,location,type,start_date,end_date) VALUES (5,'Typhoon','Country X','Water','2021-09-01','2021-09-10'); | SELECT SUM(Relief_Aid.amount) FROM Relief_Aid WHERE Relief_Aid.organization = 'UNICEF' AND Relief_Aid.disaster_id IN (SELECT Disaster.id FROM Disaster WHERE Disaster.location = 'Country X') |
What's the total number of players from North America and Europe? | CREATE TABLE Players (PlayerID INT,Name VARCHAR(100),Age INT,Country VARCHAR(50)); INSERT INTO Players (PlayerID,Name,Age,Country) VALUES (1,'John Doe',25,'USA'),(2,'Jane Smith',28,'Canada'),(3,'James Johnson',30,'England'),(4,'Emily Davis',24,'France'); | SELECT COUNT(*) FROM Players WHERE Country IN ('USA', 'Canada', 'England', 'France'); |
Calculate the total revenue for the museum's online store for the last year | CREATE TABLE OnlineStore (id INT,date DATE,revenue DECIMAL(10,2)); INSERT INTO OnlineStore (id,date,revenue) VALUES (1,'2022-01-01',500.00); INSERT INTO OnlineStore (id,date,revenue) VALUES (2,'2022-01-02',750.00); | SELECT SUM(revenue) FROM OnlineStore WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 365 DAY) AND CURRENT_DATE; |
What is the total funding received by art programs for unrepresented communities in New York and California? | CREATE TABLE Funding (id INT,state VARCHAR(2),program VARCHAR(20),amount FLOAT); INSERT INTO Funding (id,state,program,amount) VALUES (1,'NY','Art for All',150000.00),(2,'CA','Art Reach',200000.00),(3,'NY','Unseen Art',120000.00); | SELECT SUM(amount) FROM Funding WHERE state IN ('NY', 'CA') AND program IN ('Art for All', 'Art Reach', 'Unseen Art') AND state IN (SELECT state FROM Communities WHERE underrepresented = 'yes'); |
What is the population trend in Arctic indigenous communities since 2000? | CREATE TABLE community_population (community VARCHAR(50),year INT,population INT); INSERT INTO community_population (community,year,population) VALUES ('Inuit',2000,50000),('Inuit',2001,50500); | SELECT c.community, c.year, c.population, LAG(c.population) OVER (PARTITION BY c.community ORDER BY c.year) as prev_year_population FROM community_population c; |
Determine the number of veterans hired in the 'IT' sector in the last financial year. | CREATE TABLE veteran_employment (id INT,sector TEXT,hire_date DATE); INSERT INTO veteran_employment (id,sector,hire_date) VALUES (1,'IT','2021-10-01'),(2,'Finance','2021-04-01'); | SELECT COUNT(*) FROM veteran_employment WHERE sector = 'IT' AND hire_date >= DATEADD(year, -1, GETDATE()); |
Delete records in the menu_items table where the item_name is 'Fish Tacos' | CREATE TABLE menu_items (item_name VARCHAR(255),price DECIMAL(5,2)); | DELETE FROM menu_items WHERE item_name = 'Fish Tacos'; |
List all athletes who have won a gold medal in any sport. | CREATE TABLE athletes (athlete_id INT,name VARCHAR(50),sport VARCHAR(50),medals_won INT,medal VARCHAR(50)); INSERT INTO athletes (athlete_id,name,sport,medals_won,medal) VALUES (1,'Serena Williams','Tennis',23,'Gold'),(2,'Roger Federer','Tennis',20,'Gold'),(3,'Novak Djokovic','Tennis',18,'Gold'); | SELECT name FROM athletes WHERE medal = 'Gold'; |
What was the average cargo weight for vessels in the North sea in the past week? | CREATE TABLE cargos(id INT,vessel_id INT,cargo_weight FLOAT); CREATE TABLE vessel_locations(id INT,vessel_id INT,location VARCHAR(50),timestamp TIMESTAMP); | SELECT AVG(cargo_weight) FROM cargos JOIN vessel_locations ON cargos.vessel_id = vessel_locations.vessel_id WHERE location LIKE '%North Sea%' AND timestamp > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) |
Identify the artist with the most works displayed in galleries located in Tokyo, and show the number of works and gallery names. | CREATE TABLE Artists (id INT,name VARCHAR(30)); CREATE TABLE Works (id INT,artist_id INT,title VARCHAR(50)); CREATE TABLE Gallery_Works (id INT,gallery_id INT,work_id INT); CREATE TABLE Galleries (id INT,name VARCHAR(30),city VARCHAR(20)); INSERT INTO Galleries (id,name,city) VALUES (1,'Gallery A','Tokyo'),(2,'Gallery B','Tokyo'),(3,'Gallery C','Tokyo'); | SELECT a.name, COUNT(w.id) as num_works, GROUP_CONCAT(g.name) as gallery_names FROM Artists a JOIN Works w ON a.id = w.artist_id JOIN Gallery_Works gw ON w.id = gw.work_id JOIN Galleries g ON gw.gallery_id = g.id WHERE g.city = 'Tokyo' GROUP BY a.name ORDER BY num_works DESC LIMIT 1; |
Who is the manufacturer with the highest safety rating for vehicles produced in the UK? | CREATE TABLE Vehicle_Manufacturers (id INT,name TEXT,safety_rating FLOAT,production_country TEXT); INSERT INTO Vehicle_Manufacturers (id,name,safety_rating,production_country) VALUES (1,'Manufacturer1',4.3,'UK'); INSERT INTO Vehicle_Manufacturers (id,name,safety_rating,production_country) VALUES (2,'Manufacturer2',4.7,'UK'); | SELECT name FROM Vehicle_Manufacturers WHERE production_country = 'UK' ORDER BY safety_rating DESC LIMIT 1; |
What is the maximum number of beds available in hospitals in India? | CREATE TABLE hospitals_india (id INT,name TEXT,beds INT); INSERT INTO hospitals_india (id,name,beds) VALUES (1,'Hospital X',500); | SELECT MAX(beds) FROM hospitals_india; |
Identify the top 3 countries with the highest number of marine protected areas in the Atlantic Ocean. | CREATE TABLE marine_protected_areas (country VARCHAR(255),region VARCHAR(255),number_of_sites INT); INSERT INTO marine_protected_areas (country,region,number_of_sites) VALUES ('Norway','Atlantic Ocean',55),('Spain','Atlantic Ocean',45),('Portugal','Atlantic Ocean',35),('France','Atlantic Ocean',25),('Ireland','Atlantic Ocean',15); | SELECT country, number_of_sites, ROW_NUMBER() OVER (ORDER BY number_of_sites DESC) as rn FROM marine_protected_areas WHERE region = 'Atlantic Ocean' LIMIT 3; |
What is the number of open pedagogy courses offered in '2022' grouped by subject area? | CREATE TABLE courses (course_id INT,academic_year INT,subject_area VARCHAR(50),pedagogy_type VARCHAR(50)); INSERT INTO courses (course_id,academic_year,subject_area,pedagogy_type) VALUES (1,2022,'Math','Open'),(2,2022,'English','Traditional'),(3,2022,'Science','Open'),(4,2022,'History','Traditional'),(5,2022,'Math','Traditional'),(6,2022,'English','Open'),(7,2021,'Math','Open'),(8,2021,'English','Traditional'),(9,2021,'Science','Open'),(10,2021,'History','Traditional'); | SELECT subject_area, COUNT(*) AS number_of_courses FROM courses WHERE academic_year = 2022 AND pedagogy_type = 'Open' GROUP BY subject_area; |
How many patients have been vaccinated in Sydney with AstraZeneca this year? | CREATE TABLE vaccinations (id INT,patient_id INT,vaccine VARCHAR(50),date DATE,city VARCHAR(50)); INSERT INTO vaccinations (id,patient_id,vaccine,date,city) VALUES (5,5,'AstraZeneca','2022-02-15','Sydney'); INSERT INTO vaccinations (id,patient_id,vaccine,date,city) VALUES (6,6,'Pfizer','2022-03-15','Sydney'); | SELECT COUNT(*) FROM vaccinations WHERE city = 'Sydney' AND vaccine = 'AstraZeneca' AND date >= '2022-01-01'; |
What are the names and production quantities of all gas wells in the 'GAS_WELLS' table? | CREATE TABLE GAS_WELLS (WELL_NAME VARCHAR(255),PRODUCTION_QTY INT); | SELECT WELL_NAME, PRODUCTION_QTY FROM GAS_WELLS; |
What is the average year of creation for artworks in the 'Cubism' gallery? | CREATE TABLE Artworks (artwork_id INT,year_created INT,gallery_name VARCHAR(50)); INSERT INTO Artworks (artwork_id,year_created,gallery_name) VALUES (1,1907,'Cubism'),(2,1912,'Cubism'); | SELECT AVG(year_created) FROM Artworks WHERE gallery_name = 'Cubism'; |
Which museums in Paris and Rome have more than 5000 artworks in their collections? | CREATE TABLE museums (id INT,name VARCHAR(50),city VARCHAR(50),artworks_count INT); INSERT INTO museums (id,name,city,artworks_count) VALUES (1,'Louvre Museum','Paris',55000); INSERT INTO museums (id,name,city,artworks_count) VALUES (2,'Vatican Museums','Rome',70000); | SELECT name, city FROM museums WHERE city IN ('Paris', 'Rome') AND artworks_count > 5000; |
Which countries have greenhouse gas emissions from rare earth element production greater than 3000? | CREATE TABLE emissions (country VARCHAR(50),emissions INT); INSERT INTO emissions (country,emissions) VALUES ('China',12000),('USA',3500),('Australia',1800),('India',500),('Brazil',200); | SELECT country FROM emissions WHERE emissions > 3000; |
How many spacecraft were manufactured per year by each manufacturer? | CREATE TABLE spacecraft_manufacturing (id INT,year INT,manufacturer VARCHAR(255),quantity INT); | SELECT manufacturer, year, AVG(quantity) as avg_yearly_production FROM spacecraft_manufacturing GROUP BY manufacturer, year; |
What is the name and organization of volunteers who have provided support in the education sector? | CREATE TABLE volunteers (id INT,name TEXT,organization TEXT,sector TEXT); INSERT INTO volunteers (id,name,organization,sector) VALUES (1,'John Doe','UNICEF','Education'),(2,'Jane Smith','Save the Children','Health'); | SELECT name, organization FROM volunteers WHERE sector = 'Education'; |
What is the average rating of each hotel in the asia_hotels view? | CREATE VIEW asia_hotels AS SELECT * FROM hotels WHERE continent = 'Asia'; CREATE TABLE hotel_ratings (hotel_id INT,rating INT); | SELECT h.hotel_name, AVG(hr.rating) FROM asia_hotels h JOIN hotel_ratings hr ON h.id = hr.hotel_id GROUP BY h.hotel_name; |
What is the average speed of buses, by route? | CREATE TABLE Routes (RouteID int,RouteType varchar(10),StartingLocation varchar(20),Length float); CREATE TABLE VehicleSpeeds (VehicleID int,RouteID int,Speed float); INSERT INTO Routes VALUES (1,'Bus','City Center',20.0),(2,'Tram','City Center',15.0),(3,'Bus','Suburbs',30.0); INSERT INTO VehicleSpeeds VALUES (1,1,30),(2,1,25),(3,2,16),(4,3,28),(5,3,32); | SELECT Routes.RouteID, Routes.RouteType, AVG(VehicleSpeeds.Speed) as avg_speed FROM Routes INNER JOIN VehicleSpeeds ON Routes.RouteID = VehicleSpeeds.RouteID WHERE Routes.RouteType = 'Bus' GROUP BY Routes.RouteID; |
How many defense contracts were awarded to minority-owned businesses in 2019? | CREATE TABLE defense_contracts (contract_id INT,company_name VARCHAR(50),minority_owned BOOLEAN,award_year INT,contract_value DECIMAL(10,2)); INSERT INTO defense_contracts (contract_id,company_name,minority_owned,award_year,contract_value) VALUES (1,'Lockheed Martin',FALSE,2020,5000000.00),(2,'Raytheon',FALSE,2020,7000000.00),(3,'Minority-owned Co.',TRUE,2019,1000000.00); | SELECT COUNT(*) FROM defense_contracts WHERE minority_owned = TRUE AND award_year = 2019; |
List the total number of labor rights violations for each type in the 'LaborRightsViolations' table | CREATE TABLE LaborRightsViolations (id INT,type VARCHAR(50),violation VARCHAR(50)); INSERT INTO LaborRightsViolations (id,type,violation) VALUES (1,'TypeA','Violation1'),(2,'TypeB','Violation2'),(3,'TypeA','Violation3'); | SELECT type, COUNT(*) as total_violations FROM LaborRightsViolations GROUP BY type; |
What is the average carbon offset for each energy efficiency rating? | CREATE TABLE EnergyEfficiencyRatings (RatingID int,RatingName varchar(50)); CREATE TABLE GreenBuildings (BuildingID int,RatingID int,CarbonOffsets int); | SELECT EnergyEfficiencyRatings.RatingName, AVG(GreenBuildings.CarbonOffsets) as AvgCarbonOffsets FROM EnergyEfficiencyRatings INNER JOIN GreenBuildings ON EnergyEfficiencyRatings.RatingID = GreenBuildings.RatingID GROUP BY EnergyEfficiencyRatings.RatingName; |
Determine the average rating of beauty products that are both cruelty-free and vegan. | CREATE TABLE products (product_id INT,product_name VARCHAR(255),is_cruelty_free BOOLEAN,is_vegan BOOLEAN,rating DECIMAL(2,1)); INSERT INTO products (product_id,product_name,is_cruelty_free,is_vegan,rating) VALUES (1,'Cruelty-Free Mascara',true,true,4.5); INSERT INTO products (product_id,product_name,is_cruelty_free,is_vegan,rating) VALUES (2,'Vegan Lipstick',true,false,4.7); | SELECT AVG(rating) FROM products WHERE is_cruelty_free = true AND is_vegan = true; |
Insert a new record into the refinery_table for 'Promethium' with the given data: year = 2022, production_volume = 125 | CREATE TABLE refinery_table (rare_earth_element VARCHAR(20),year INT,production_volume INT); | INSERT INTO refinery_table (rare_earth_element, year, production_volume) VALUES ('Promethium', 2022, 125); |
What is the average environmental factor score for projects in the education sector with an investment amount greater than $700,000? | CREATE TABLE impact_investments (id INT,project VARCHAR(50),location VARCHAR(50),investment_amount DECIMAL(10,2),impact_score INT,primary_sector VARCHAR(50)); INSERT INTO impact_investments (id,project,location,investment_amount,impact_score,primary_sector) VALUES (1,'School Construction','Nigeria',750000.00,85,'Education'); | SELECT AVG(e.environmental_factor) as avg_env_factor FROM esg_factors e JOIN impact_investments i ON e.investment_id = i.id WHERE i.primary_sector = 'Education' AND i.investment_amount > 700000; |
What is the average number of employees per mining operation? | CREATE TABLE mining_operations (id INT PRIMARY KEY,operation_name VARCHAR(50),location VARCHAR(50),num_employees INT); | SELECT AVG(num_employees) FROM mining_operations; |
How many heritage sites are in Mexico? | CREATE TABLE HeritageSites (SiteID INT,Name TEXT,Country TEXT); INSERT INTO HeritageSites (SiteID,Name,Country) VALUES (1,'Palenque','Mexico'); INSERT INTO HeritageSites (SiteID,Name,Country) VALUES (2,'Teotihuacan','Mexico'); | SELECT COUNT(*) FROM HeritageSites WHERE Country = 'Mexico'; |
What is the highest number of goals scored by the 'India' women's field hockey team in a single match in the 'Asian Games'? | CREATE TABLE teams (team_id INT,team_name TEXT,league TEXT,sport TEXT); INSERT INTO teams (team_id,team_name,league,sport) VALUES (1,'India','Asian Games','Field Hockey'); CREATE TABLE games (game_id INT,team_id INT,goals INT,season_year INT); INSERT INTO games (game_id,team_id,goals,season_year) VALUES (1,1,7,2020),(2,1,6,2020),(3,1,8,2018); | SELECT MAX(goals) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'India') AND league = 'Asian Games'; |
What is the total number of accessible technology initiatives by region? | CREATE TABLE initiatives (id INT,name VARCHAR(50),region VARCHAR(50),accessibility_rating INT); | SELECT region, COUNT(*) as count FROM initiatives WHERE accessibility_rating > 6 GROUP BY region; |
What are the names of the excavation sites that have 'Tools' as an artifact type? | CREATE TABLE SiteF (site_id INT,site_name TEXT,artifact_type TEXT); INSERT INTO SiteF (site_id,site_name,artifact_type) VALUES (1,'SiteA','Pottery'),(2,'SiteB','Tools'),(3,'SiteC','Jewelry'); INSERT INTO SiteF (site_id,site_name,artifact_type) VALUES (4,'SiteD','Pottery'),(5,'SiteE','Tools'),(6,'SiteF','Jewelry'); | SELECT site_name FROM SiteF WHERE artifact_type = 'Tools'; |
Identify the top 3 industries with the highest average funding amounts | CREATE TABLE funding (id INT,company_id INT,amount INT,industry TEXT); INSERT INTO funding (id,company_id,amount,industry) VALUES (1,1,50000,'Technology'); INSERT INTO funding (id,company_id,amount,industry) VALUES (2,2,75000,'Finance'); INSERT INTO funding (id,company_id,amount,industry) VALUES (3,3,100000,'Healthcare'); | SELECT industry, AVG(amount) as avg_funding FROM funding GROUP BY industry ORDER BY avg_funding DESC LIMIT 3 |
Find the number of graduate students from African and Asian backgrounds who have not received any research grants. | CREATE TABLE students (student_id INT,student_name VARCHAR(255),student_community VARCHAR(255)); CREATE TABLE research_grants (grant_id INT,student_id INT,grant_amount DECIMAL(10,2),grant_start_date DATE,grant_end_date DATE); | SELECT COUNT(DISTINCT s.student_id) FROM students s LEFT JOIN research_grants rg ON s.student_id = rg.student_id WHERE rg.grant_id IS NULL AND s.student_community IN ('African', 'Asian'); |
Count the number of 'Bus' records in the 'PublicTransit' table where 'city' is 'New York' | CREATE TABLE PublicTransit (transit_id INT,transit_type VARCHAR(20),city VARCHAR(20)); INSERT INTO PublicTransit (transit_id,transit_type,city) VALUES (1,'Bus','New York'),(2,'Subway','New York'),(3,'Train','Los Angeles'); | SELECT COUNT(*) FROM PublicTransit WHERE transit_type = 'Bus' AND city = 'New York'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.