instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Who are the top 5 users with the highest number of transactions on the Binance Smart Chain? | CREATE TABLE users (user_id INT,user_name VARCHAR(255)); INSERT INTO users (user_id,user_name) VALUES (1,'Alice'),(2,'Bob'),(3,'Carol'),(4,'David'),(5,'Eve'); CREATE TABLE user_transactions (transaction_id INT,user_id INT,tx_time TIMESTAMP); INSERT INTO user_transactions (transaction_id,user_id) VALUES (1,1),(2,2),(3,3... | SELECT user_name, COUNT(*) AS transactions FROM user_transactions JOIN users ON user_transactions.user_id = users.user_id GROUP BY user_name ORDER BY transactions DESC LIMIT 5; |
How many electric vehicles are there in CityB? | CREATE TABLE CityB_Vehicles (vehicle_id INT,vehicle_type VARCHAR(20),is_electric BOOLEAN); INSERT INTO CityB_Vehicles (vehicle_id,vehicle_type,is_electric) VALUES (1,'Car',true),(2,'Bike',false),(3,'Car',true),(4,'Bus',false); | SELECT COUNT(*) FROM CityB_Vehicles WHERE is_electric = true; |
What are the names of all marine species with a population over 1200 in the 'ResearchInstitutes' and 'MarineSpecies' tables? | CREATE TABLE ResearchInstitutes (id INT,name VARCHAR(50),species VARCHAR(50),population INT); INSERT INTO ResearchInstitutes (id,name,species,population) VALUES (1,'Ocean Research Center','Dolphin',1300),(2,'Marine Life Institute','Shark',1100); CREATE TABLE MarineSpecies (id INT,name VARCHAR(50),species VARCHAR(50),po... | SELECT R.species FROM ResearchInstitutes R WHERE R.population > 1200 INTERSECT SELECT M.species FROM MarineSpecies M WHERE M.population > 1200; |
Insert a new digital asset 'BitInvest' with sector 'Investment' | CREATE TABLE digital_assets (asset_id INT,name VARCHAR(20),sector VARCHAR(20)); | INSERT INTO digital_assets (name, sector) VALUES ('BitInvest', 'Investment'); |
Update the feeding habits of the 'Blue Whale' to 'Filter Feeder' in all oceans. | CREATE TABLE marine_species (id INT,species VARCHAR(50),ocean VARCHAR(50),feeding_habits VARCHAR(50)); | UPDATE marine_species SET feeding_habits = 'Filter Feeder' WHERE species = 'Blue Whale'; |
List the top 3 most sustainable fabric suppliers in 'Asia' based on the sustainability_rating? | CREATE TABLE fabric_suppliers(name VARCHAR(50),location VARCHAR(50),sustainability_rating INT); INSERT INTO fabric_suppliers (name,location,sustainability_rating) VALUES ('GreenTextiles','India',95); INSERT INTO fabric_suppliers (name,location,sustainability_rating) VALUES ('EcoFabrics','China',88); INSERT INTO fabric_... | SELECT name, sustainability_rating FROM fabric_suppliers WHERE location = 'Asia' ORDER BY sustainability_rating DESC LIMIT 3; |
What are the names and capacities of all warehouses located in Germany? | CREATE TABLE Warehouses (id INT,name TEXT,capacity INT,country TEXT); INSERT INTO Warehouses (id,name,capacity,country) VALUES (1,'Berlin Warehouse',5000,'Germany'); INSERT INTO Warehouses (id,name,capacity,country) VALUES (2,'Munich Warehouse',7000,'Germany'); | SELECT name, capacity FROM Warehouses WHERE country = 'Germany'; |
List the unions with the highest and lowest number of members in Canada and Australia. | CREATE TABLE union_details(id INT,union_name VARCHAR(50),total_members INT,country VARCHAR(14));INSERT INTO union_details(id,union_name,total_members,country) VALUES (1,'Union A',5000,'Canada'),(2,'Union B',3000,'Canada'),(3,'Union C',8000,'Australia'),(4,'Union D',6000,'Australia'); | SELECT union_name, country, total_members FROM (SELECT union_name, country, total_members, ROW_NUMBER() OVER (PARTITION BY country ORDER BY total_members DESC, union_name ASC) AS rank FROM union_details WHERE country IN ('Canada', 'Australia')) ranked_unions WHERE rank IN (1, 2); |
What is the average number of publications by graduate students each year, overall? | CREATE TABLE Graduate_Students_2 (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO Graduate_Students_2 (id,name,department) VALUES (1,'Dana','Physics'); CREATE TABLE Publications_2 (id INT,student_id INT,year INT,title VARCHAR(100)); INSERT INTO Publications_2 (id,student_id,year,title) VALUES (1,1,2018,'Qu... | SELECT AVG(publications_per_year) FROM (SELECT COUNT(*) AS publications_per_year FROM Publications_2 JOIN Graduate_Students_2 ON Publications_2.student_id = Graduate_Students_2.id GROUP BY year) AS subquery; |
What is the sum of sustainable sourcing scores for each restaurant category in the last six months? | CREATE SCHEMA FoodService;CREATE TABLE Sustainability (sustainability_id INT,restaurant_id INT,category VARCHAR(50),score INT,sustainability_date DATE); INSERT INTO Sustainability (sustainability_id,restaurant_id,category,score,sustainability_date) VALUES (1,1,'dining',85,'2021-06-01'),(2,1,'dining',90,'2021-07-01'),(3... | SELECT category, SUM(score) as total_score FROM Sustainability WHERE sustainability_date >= '2021-06-01' GROUP BY category; |
What is the virtual tour engagement for 'Boutique' hotels in 'Rio de Janeiro'? | CREATE TABLE virtual_tours (tour_id INT,hotel_id INT,type TEXT,engagement FLOAT); CREATE TABLE hotels (hotel_id INT,name TEXT,city TEXT,rating FLOAT); CREATE TABLE boutique_hotels (hotel_id INT,name TEXT,city TEXT,rating FLOAT); | SELECT AVG(virtual_tours.engagement) FROM virtual_tours INNER JOIN (SELECT hotel_id FROM boutique_hotels WHERE city = 'Rio de Janeiro') as subquery ON virtual_tours.hotel_id = subquery.hotel_id WHERE virtual_tours.type = 'Boutique'; |
How many graduate students in the Physics department have published more than 5 papers? | CREATE TABLE graduate_students (id INT,name VARCHAR(100),department VARCHAR(50),publications INT); INSERT INTO graduate_students (id,name,department,publications) VALUES (1,'Dana','Physics',7); | SELECT COUNT(*) FROM graduate_students WHERE department = 'Physics' AND publications > 5; |
What is the minimum donation amount in the 'donors' table? | 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',45,750.00); INSERT INTO donors (id,name,age,donation) VALUES (3,'Bob Johnson',25,600.00); | SELECT MIN(donation) FROM donors; |
List the names of cities with a population over 1 million in France and Germany. | CREATE TABLE france_cities (name TEXT,population INTEGER); INSERT INTO france_cities (name,population) VALUES ('Paris',2148000),('Marseille',855000); CREATE TABLE germany_cities (name TEXT,population INTEGER); INSERT INTO germany_cities (name,population) VALUES ('Berlin',3671000),('Hamburg',1795000); | SELECT name FROM france_cities WHERE population > 1000000 INTERSECT SELECT name FROM germany_cities WHERE population > 1000000; |
Find the average R&D expenditure for the drugs approved in 2019. | CREATE TABLE drugs(drug_name TEXT,approval_year INT,rd_expenditure FLOAT); INSERT INTO drugs(drug_name,approval_year,rd_expenditure) VALUES('DrugA',2017,5000000),('DrugB',2018,7000000),('DrugC',2019,8000000),('DrugD',2019,6000000); | SELECT AVG(rd_expenditure) FROM drugs WHERE approval_year = 2019; |
Update the conservation_efforts table to reflect a successful conservation project for species with id 3 and 7 | CREATE TABLE conservation_efforts (id INT,species_id INT,project_status VARCHAR(20)); | UPDATE conservation_efforts SET project_status = 'successful' WHERE species_id IN (3, 7); |
What are the names and quantities of chemicals produced by factories located in California? | CREATE TABLE factories (id INT,name TEXT,location TEXT); INSERT INTO factories (id,name,location) VALUES (1,'Factory A','California'),(2,'Factory B','Texas'); CREATE TABLE chemical_produced (factory_id INT,chemical_name TEXT,quantity INT); INSERT INTO chemical_produced (factory_id,chemical_name,quantity) VALUES (1,'Che... | SELECT chemical_name, quantity FROM chemical_produced CP JOIN factories F ON CP.factory_id = F.id WHERE F.location = 'California'; |
Find the total revenue generated by sustainable farming in the Asia-Pacific region. | CREATE TABLE sustainable_farming (farmer_id INT,name VARCHAR(30),region VARCHAR(20),revenue REAL); INSERT INTO sustainable_farming (farmer_id,name,region,revenue) VALUES (1,'Farmer A','Asia-Pacific',12000),(2,'Farmer B','Asia-Pacific',15000),(3,'Farmer C','Europe',9000),(4,'Farmer D','Africa',18000),(5,'Farmer E','Asia... | SELECT SUM(revenue) FROM sustainable_farming WHERE region = 'Asia-Pacific'; |
What is the total production cost of sustainable materials in Africa in the last quarter? | CREATE TABLE material_production (material_id INT,material_name VARCHAR(50),production_date DATE,production_cost DECIMAL(10,2)); INSERT INTO material_production (material_id,material_name,production_date,production_cost) VALUES (1,'Organic Cotton','2021-08-05',500.00),(2,'Recycled Polyester','2021-07-10',700.00),(3,'He... | SELECT SUM(production_cost) FROM material_production WHERE material_name IN ('Organic Cotton', 'Recycled Polyester', 'Hemp') AND production_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND CURDATE(); |
What is the trend in funding received by startups founded by people from a specific region in the e-commerce sector over time? | CREATE TABLE companies (id INT,name TEXT,founding_year INT,industry TEXT,founder_region TEXT,funding FLOAT); | SELECT founding_year, AVG(funding) FROM companies WHERE industry = 'e-commerce' AND founder_region = 'region_name' GROUP BY founding_year; |
What is the average funding for music programs in 2021? | CREATE TABLE IF NOT EXISTS programs (id INT,name VARCHAR(255),type VARCHAR(255),year INT,funding DECIMAL(10,2)); INSERT INTO programs (id,name,type,year,funding) VALUES (1,'ProgramA','Music',2021,10000),(2,'ProgramB','Music',2021,20000),(3,'ProgramC','Music',2021,30000); | SELECT AVG(funding) FROM programs WHERE type = 'Music' AND year = 2021; |
Insert a new employee with ID 3 into the Employees table, with the name 'Jim Smith', department 'IT', location 'Chicago', and hire date '2022-03-20' | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Department VARCHAR(50),Location VARCHAR(50),HireDate DATE); | INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Location, HireDate) VALUES (3, 'Jim', 'Smith', 'IT', 'Chicago', '2022-03-20'); |
What is the minimum production volume for uranium mines in Australia? | CREATE TABLE mines (id INT,name TEXT,location TEXT,production_volume INT); INSERT INTO mines (id,name,location,production_volume) VALUES (1,'Australian Uranium Mine 1','Australia',500); INSERT INTO mines (id,name,location,production_volume) VALUES (2,'Australian Uranium Mine 2','Australia',600); | SELECT MIN(production_volume) FROM mines WHERE location = 'Australia' AND mineral = 'uranium'; |
Which countries does the 'peacekeeping_operations' table contain data for? | CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY,country VARCHAR(100),start_date DATE,end_date DATE); INSERT INTO peacekeeping_operations (id,country,start_date,end_date) VALUES (1,'Bosnia and Herzegovina','1995-12-14','2007-12-21'); INSERT INTO peacekeeping_operations (id,country,start_date,end_date) VALUES (2... | SELECT DISTINCT country FROM peacekeeping_operations; |
Which suppliers provide the most eco-friendly products? | CREATE TABLE Products (ProductID int,SupplierID int,IsEcoFriendly boolean); | SELECT SupplierID, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Products WHERE IsEcoFriendly = true) AS PercentEcoFriendly FROM Products WHERE IsEcoFriendly = true GROUP BY SupplierID ORDER BY PercentEcoFriendly DESC; |
Which cybersecurity policies in the 'policies' table have been reviewed in the last month, based on the 'review_date' column, and what is their average review rating? | CREATE TABLE policies (id INT,policy_name VARCHAR(100),description TEXT,review_date DATE,review_rating INT); INSERT INTO policies (id,policy_name,description,review_date,review_rating) VALUES (1,'Policy A','Policy A description','2021-09-01',4),(2,'Policy B','Policy B description','2021-08-15',5); | SELECT policy_name, AVG(review_rating) as average_rating FROM policies WHERE review_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY policy_name; |
How much was spent on R&D in Asia for a specific drug during a given year? | CREATE TABLE rd_expenditure (id INT,drug_name VARCHAR(255),region VARCHAR(255),expenditure DECIMAL(10,2),expenditure_year INT); INSERT INTO rd_expenditure (id,drug_name,region,expenditure,expenditure_year) VALUES (1,'DrugD','Asia',50000,2019); INSERT INTO rd_expenditure (id,drug_name,region,expenditure,expenditure_year... | SELECT SUM(expenditure) FROM rd_expenditure WHERE drug_name = 'DrugD' AND region = 'Asia' AND expenditure_year = 2019; |
What is the total number of military bases in South American nations with more than 200 aircrafts? | CREATE TABLE MilitaryBases (Country VARCHAR(50),NumberOfBases INT); INSERT INTO MilitaryBases (Country,NumberOfBases) VALUES ('Brazil',100),('Argentina',75),('Colombia',50),('Peru',30),('Venezuela',40); CREATE TABLE MilitaryAircrafts (Country VARCHAR(50),NumberOfAircrafts INT); INSERT INTO MilitaryAircrafts (Country,Nu... | SELECT SUM(NumberOfBases) FROM MilitaryBases INNER JOIN MilitaryAircrafts ON MilitaryBases.Country = MilitaryAircrafts.Country WHERE NumberOfAircrafts > 200; |
What was the average delivery time for shipments from South Korea to Canada in March 2021? | CREATE TABLE deliveries (id INT,shipment_id INT,delivered_at TIMESTAMP); INSERT INTO deliveries (id,shipment_id,delivered_at) VALUES (1,1,'2021-03-01 12:30:00'),(2,2,'2021-03-31 09:15:00'); CREATE TABLE shipments (id INT,origin VARCHAR(255),destination VARCHAR(255),shipped_at TIMESTAMP); INSERT INTO shipments (id,origi... | SELECT AVG(TIMESTAMPDIFF(MINUTE, shipped_at, delivered_at)) FROM deliveries D JOIN shipments S ON D.shipment_id = S.id WHERE S.origin = 'South Korea' AND S.destination = 'Canada' AND shipped_at >= '2021-03-01' AND shipped_at < '2021-04-01'; |
Insert a new record into the 'oil_fields' table with the following data: 'Alaska North Slope', 'onshore', 1968 | CREATE TABLE oil_fields (field_name VARCHAR(50) PRIMARY KEY,field_type VARCHAR(20),discovery_year INT); | INSERT INTO oil_fields (field_name, field_type, discovery_year) VALUES ('Alaska North Slope', 'onshore', 1968); |
What is the adoption rate of AI-powered chatbots in 'North America' for 'Q1 2021'? | CREATE TABLE ai_adoption (region VARCHAR(20),quarter INT,adoption_rate DECIMAL(5,2)); INSERT INTO ai_adoption (region,quarter,adoption_rate) VALUES ('North America',1,62.30),('North America',1,64.50); | SELECT AVG(adoption_rate) FROM ai_adoption WHERE region = 'North America' AND quarter = 1; |
Add a record to the recycling_rates table | CREATE TABLE recycling_rates (id INT PRIMARY KEY,location VARCHAR(50),rate FLOAT); | INSERT INTO recycling_rates (id, location, rate) VALUES (1, 'Seattle', 63.1); |
How many construction workers were employed in Colorado in 2018 and 2019? | CREATE TABLE employment (employee_id INT,state VARCHAR(2),employment_date DATE,num_employees INT); INSERT INTO employment (employee_id,state,employment_date,num_employees) VALUES (1,'CO','2018-12-31',10000),(2,'CO','2019-12-31',12000),(3,'TX','2020-12-31',16000); | SELECT employment_date, SUM(num_employees) FROM employment WHERE state = 'CO' AND employment_date IN ('2018-12-31', '2019-12-31') GROUP BY employment_date; |
What is the total number of green buildings and carbon offset projects in each state? | CREATE TABLE green_buildings (id INT,building_name VARCHAR(255),state VARCHAR(255)); CREATE TABLE carbon_offset_projects (id INT,project_name VARCHAR(255),state VARCHAR(255)); | SELECT state, COUNT(gb.building_name) + COUNT(cop.project_name) FROM green_buildings gb RIGHT JOIN carbon_offset_projects cop ON gb.state = cop.state GROUP BY state; |
List the top 5 states with the highest CO2 emissions from transportation in 2019. | CREATE TABLE co2_emissions (state VARCHAR(20),year INT,sector VARCHAR(20),co2_emissions FLOAT); | SELECT state, SUM(co2_emissions) as total_emissions FROM co2_emissions WHERE year = 2019 AND sector = 'Transportation' GROUP BY state ORDER BY total_emissions DESC LIMIT 5; |
What is the total number of collective bargaining agreements signed in the 'construction' industry? | CREATE TABLE collective_bargaining (id INT,industry VARCHAR(50),num_agreements INT); INSERT INTO collective_bargaining (id,industry,num_agreements) VALUES (1,'construction',15); INSERT INTO collective_bargaining (id,industry,num_agreements) VALUES (2,'manufacturing',10); INSERT INTO collective_bargaining (id,industry,n... | SELECT SUM(num_agreements) FROM collective_bargaining WHERE industry = 'construction'; |
What was the average temperature in Rome during excavations between 2015 and 2018? | CREATE TABLE WeatherData (site_id INT,year INT,avg_temp DECIMAL(5,2)); INSERT INTO WeatherData (site_id,year,avg_temp) VALUES (1,2015,15.6),(1,2016,15.8),(1,2017,15.3),(1,2018,15.9); | SELECT AVG(avg_temp) FROM WeatherData WHERE site_id = 1 AND year BETWEEN 2015 AND 2018; |
How many employees were hired in Q2 of 2021? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE); INSERT INTO Employees (EmployeeID,HireDate) VALUES (1,'2021-04-20'),(2,'2021-03-15'),(3,'2021-01-08'),(4,'2021-04-01'),(5,'2020-12-28'),(6,'2021-05-12'),(7,'2021-07-01'); | SELECT COUNT(*) FROM Employees WHERE HireDate BETWEEN '2021-04-01' AND '2021-06-30'; |
What is the total waste generation in Africa for the year 2019, separated by region? | CREATE TABLE WasteGenerationAfrica (region VARCHAR(50),year INT,waste_quantity INT); INSERT INTO WasteGenerationAfrica (region,year,waste_quantity) VALUES ('Africa/North',2019,200000),('Africa/West',2019,250000),('Africa/Central',2019,300000),('Africa/East',2019,220000),('Africa/South',2019,270000); | SELECT region, SUM(waste_quantity) FROM WasteGenerationAfrica WHERE year = 2019 GROUP BY region; |
How many VR games are available in the 'Adventure' category? | CREATE TABLE GameLibrary (GameID INT,GameName VARCHAR(50),GameType VARCHAR(50),Category VARCHAR(50)); INSERT INTO GameLibrary (GameID,GameName,GameType,Category) VALUES (1,'GameA','VR','Adventure'),(2,'GameB','Non-VR','Strategy'),(3,'GameC','VR','Action'),(4,'GameD','VR','Adventure'); | SELECT COUNT(GameID) FROM GameLibrary WHERE GameType = 'VR' AND Category = 'Adventure'; |
Identify the top 3 construction projects by duration in California | CREATE TABLE project_timelines (project_name VARCHAR(255),state VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO project_timelines (project_name,state,start_date,end_date) VALUES ('Project A','California','2018-01-01','2019-12-31'),('Project B','California','2018-06-01','2020-05-31'),('Project C','California','... | SELECT project_name, DATEDIFF(end_date, start_date) as duration FROM project_timelines WHERE state = 'California' ORDER BY duration DESC LIMIT 3; |
What is the average ticket price for each music festival genre? | CREATE TABLE music_festivals (festival_id INT,genre VARCHAR(255),ticket_price DECIMAL(5,2)); INSERT INTO music_festivals (festival_id,genre,ticket_price) VALUES (1,'Rock',200.00),(2,'Pop',250.00),(3,'Jazz',150.00); | SELECT genre, AVG(ticket_price) FROM music_festivals GROUP BY genre; |
What is the maximum number of ICU beds available in hospitals in Peru? | CREATE TABLE hospitals (id INT,name TEXT,country TEXT,num_of_ICU_beds INT); | SELECT MAX(num_of_ICU_beds) FROM hospitals WHERE country = 'Peru'; |
What is the average time between spacecraft launches for 'SpaceX'? | CREATE TABLE SpacecraftLaunches (id INT,name VARCHAR(50),company VARCHAR(50),launch_date DATE); | SELECT AVG(DATEDIFF(lead_launch_date, launch_date)) FROM (SELECT launch_date, LEAD(launch_date) OVER (PARTITION BY company ORDER BY launch_date) AS lead_launch_date FROM SpacecraftLaunches WHERE company = 'SpaceX') AS subquery; |
What is the average billing rate for each attorney in the 'billing' table? | CREATE TABLE billing (attorney_id INT,client_id INT,hours FLOAT,rate FLOAT); INSERT INTO billing (attorney_id,client_id,hours,rate) VALUES (1,101,10,300),(2,102,8,350),(3,103,12,250); | SELECT attorney_id, AVG(rate) FROM billing GROUP BY attorney_id; |
What were the total donations in Q3 2020 by state? | CREATE TABLE donations (id INT,donation_date DATE,state TEXT,amount DECIMAL(10,2)); INSERT INTO donations (id,donation_date,state,amount) VALUES (4,'2020-07-01','California',100.00),(5,'2020-08-15','Texas',250.50),(6,'2020-09-30','New York',150.25); | SELECT state, SUM(amount) FROM donations WHERE donation_date BETWEEN '2020-07-01' AND '2020-09-30' GROUP BY state; |
Identify astronauts who have flown more missions than their preceding colleagues within the same space agency. | CREATE TABLE Astronauts (AstronautID INT,Name VARCHAR(50),Spaceflights INT,Agency VARCHAR(50),PreviousSpaceflights INT); INSERT INTO Astronauts (AstronautID,Name,Spaceflights,Agency,PreviousSpaceflights) VALUES (1,'Neil Armstrong',2,'NASA',NULL); INSERT INTO Astronauts (AstronautID,Name,Spaceflights,Agency,PreviousSpac... | SELECT Name, Spaceflights, Agency, PreviousSpaceflights, Spaceflights - LAG(Spaceflights) OVER (PARTITION BY Agency ORDER BY Spaceflights) AS Spaceflight_Difference FROM Astronauts WHERE Spaceflights - LAG(Spaceflights) OVER (PARTITION BY Agency ORDER BY Spaceflights) > 0; |
Insert new records into the 'renewable_energy_production' table for wind and solar production in 'Florida' and 'Georgia' | CREATE TABLE renewable_energy_production (id INT PRIMARY KEY,source VARCHAR(255),state VARCHAR(255),production_gwh FLOAT); | INSERT INTO renewable_energy_production (source, state, production_gwh) VALUES ('wind', 'Florida', 30), ('solar', 'Florida', 45), ('wind', 'Georgia', 40), ('solar', 'Georgia', 55); |
What are the top 3 countries where our social media app is most popular, based on user count? | CREATE TABLE social_media_app (app_id INT,user_id INT,country VARCHAR(50)); INSERT INTO social_media_app (app_id,user_id,country) VALUES (1,12345,'USA'),(2,67890,'Canada'),(3,11121,'Mexico'),(4,22232,'Brazil'),(5,33343,'Germany'); | SELECT country, COUNT(user_id) AS user_count FROM social_media_app GROUP BY country ORDER BY user_count DESC LIMIT 3; |
Delete all records from the 'platforms' table | CREATE TABLE platforms (id INT,platform TEXT); | DELETE FROM platforms; |
Find the average speed of all vessels in the 'vessel_performance' table | CREATE TABLE vessel_performance (vessel_id INT,speed FLOAT,timestamp TIMESTAMP); | SELECT AVG(speed) FROM vessel_performance; |
What is the percentage of endangered animals in the animal_population table for each species? | CREATE TABLE animal_population (id INT,species VARCHAR(50),population INT,endangered BOOLEAN); | SELECT species, (COUNT(*) FILTER (WHERE endangered = TRUE)) * 100.0 / COUNT(*) AS percentage FROM animal_population GROUP BY species; |
What is the average age of fans who attend theater events? | CREATE TABLE Events (event_id INT,category VARCHAR(255),price DECIMAL(5,2)); INSERT INTO Events (event_id,category,price) VALUES (1,'Concert',50.99),(2,'Sports',30.50),(3,'Theater',75.00); CREATE TABLE Fans (fan_id INT,age INT,event_id INT); INSERT INTO Fans (fan_id,age,event_id) VALUES (1,25,1),(2,30,1),(3,18,2),(4,45... | SELECT AVG(age) FROM Fans WHERE event_id IN (SELECT event_id FROM Events WHERE category = 'Theater'); |
What is the total number of animals in the Australian wildlife conservation areas, broken down by animal species and conservation area? | CREATE TABLE australian_conservation_areas (id INT,name VARCHAR(255),area_size FLOAT); CREATE TABLE australian_animal_population (id INT,conservation_area_id INT,species VARCHAR(255),animal_count INT); | SELECT aca.name, aap.species, SUM(aap.animal_count) as total_animals FROM australian_conservation_areas aca JOIN australian_animal_population aap ON aca.id = aap.conservation_area_id GROUP BY aca.name, aap.species; |
What is the maximum number of satellites a private company has launched in a single year? | CREATE TABLE satellites_launches (company VARCHAR(50),year INT,num_satellites INT); INSERT INTO satellites_launches (company,year,num_satellites) VALUES ('SpaceX',2020,242),('OneWeb',2019,34),('Blue Origin',2021,12); | SELECT company, MAX(num_satellites) as max_satellites FROM satellites_launches GROUP BY company; |
What is the number of open data portals in each country as of January 1, 2022? | CREATE TABLE country (id INT,name VARCHAR(255)); INSERT INTO country (id,name) VALUES (1,'United States'); INSERT INTO country (id,name) VALUES (2,'Canada'); CREATE TABLE open_data (id INT,country_id INT,is_open INT,date DATE); INSERT INTO open_data (id,country_id,is_open,date) VALUES (1,1,1,'2021-12-31'); INSERT INTO ... | SELECT country.name, COUNT(open_data.id) as num_open_data_portals FROM country JOIN open_data ON country.id = open_data.country_id WHERE open_data.date = '2022-01-01' AND open_data.is_open = 1 GROUP BY country.name; |
Get the circular economy initiative name and start date with the highest budget for 'Africa'. | CREATE TABLE circular_initiatives (region VARCHAR(50),initiative_name VARCHAR(50),budget NUMERIC(10,2),start_date DATE); INSERT INTO circular_initiatives (region,initiative_name,budget,start_date) VALUES ('Africa','Green Cities',500000,'2020-01-01'),('Africa','Waste-to-Energy',800000,'2019-01-01'); | SELECT initiative_name, start_date FROM (SELECT initiative_name, start_date, ROW_NUMBER() OVER (PARTITION BY region ORDER BY budget DESC) AS rn FROM circular_initiatives WHERE region = 'Africa') x WHERE rn = 1; |
Which users have accessed the database in the last week, and what are their roles? | CREATE TABLE database_access (access_id INT PRIMARY KEY,user_name VARCHAR(50),access_time TIMESTAMP,role VARCHAR(50)); | SELECT user_name, role FROM database_access WHERE access_time >= NOW() - INTERVAL 1 WEEK; |
What is the total number of ambulances in rural Kenya, and how many paramedics are available per ambulance? | CREATE TABLE ambulances (ambulance_id INT,location VARCHAR(255)); INSERT INTO ambulances (ambulance_id,location) VALUES (110,'rural Kenya'); CREATE TABLE paramedics (paramedic_id INT,location VARCHAR(255)); INSERT INTO paramedics (paramedic_id,location) VALUES (111,'rural Kenya'); INSERT INTO paramedics (paramedic_id,l... | SELECT COUNT(ambulances.ambulance_id) AS ambulances_count, COUNT(paramedics.paramedic_id) / COUNT(ambulances.ambulance_id) AS paramedics_per_ambulance FROM ambulances INNER JOIN paramedics ON ambulances.location = paramedics.location WHERE ambulances.location LIKE 'rural% Kenya'; |
What is the minimum salary of athletes in the tennis_players table? | CREATE TABLE tennis_players (player_id INT,name VARCHAR(50),country VARCHAR(50),ranking INT,salary DECIMAL(10,2)); INSERT INTO tennis_players (player_id,name,country,ranking,salary) VALUES (1,'Novak Djokovic','Serbia',1,21000000.00); INSERT INTO tennis_players (player_id,name,country,ranking,salary) VALUES (2,'Rafael N... | SELECT MIN(salary) FROM tennis_players; |
What was the minimum price per ounce of indica strains sold in Oregon dispensaries in Q4 2021? | CREATE TABLE strains (type VARCHAR(10),price DECIMAL(5,2),unit VARCHAR(10)); INSERT INTO strains (type,price,unit) VALUES ('indica',225,'ounce'),('indica',250,'ounce'),('hybrid',180,'ounce'); CREATE TABLE dispensaries (state VARCHAR(20),sales INT); INSERT INTO dispensaries (state,sales) VALUES ('Oregon',2800),('Oregon'... | SELECT MIN(strains.price) FROM strains JOIN dispensaries ON TRUE WHERE strains.type = 'indica' AND strains.unit = 'ounce' AND dispensaries.state = 'Oregon' AND time_periods.quarter = 4; |
What is the total budget for rural infrastructure projects in the Western region? | CREATE TABLE projects (project_id INT,district_id INT,budget FLOAT,project_type VARCHAR(50)); INSERT INTO projects (project_id,district_id,budget,project_type) VALUES (1,10,400000,'Road Construction'),(2,10,500000,'Irrigation System'),(3,11,350000,'Electricity'),(4,12,200000,'Water Supply'); | SELECT SUM(budget) FROM projects WHERE district_id IN (SELECT district_id FROM districts WHERE region = 'Western'); |
What is the total duration of videos in the 'Education' category? | CREATE TABLE Videos (video_id INT,title VARCHAR(255),category VARCHAR(50),duration INT); INSERT INTO Videos (video_id,title,category,duration) VALUES (1,'Video1','Education',60),(2,'Video2','Entertainment',90),(3,'Video3','Education',120); | SELECT SUM(duration) FROM Videos WHERE category = 'Education'; |
What is the total billing amount for cases handled by attorney 'John Smith'? | CREATE TABLE attorneys (attorney_id INT,name VARCHAR(50)); INSERT INTO attorneys VALUES (1,'John Smith'); CREATE TABLE cases (case_id INT,attorney_id INT,billing_amount DECIMAL(10,2)); | SELECT SUM(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.name = 'John Smith'; |
What is the remaining capacity of landfill sites in Beijing and Sao Paulo as of the end of 2022? | CREATE TABLE LandfillSites (LSID INT,Location VARCHAR(50),Capacity FLOAT,OpenDate DATE,CloseDate DATE); INSERT INTO LandfillSites (LSID,Location,Capacity,OpenDate,CloseDate) VALUES (13,'Beijing',25000,'2010-01-01','2027-12-31'); INSERT INTO LandfillSites (LSID,Location,Capacity,OpenDate,CloseDate) VALUES (14,'Sao Paulo... | SELECT LS.Location, (LS.Capacity - SUM(WG.Quantity)) as RemainingCapacity FROM LandfillSites LS RIGHT JOIN WasteGeneration WG ON LS.Location = WG.Location AND WG.CollectionDate BETWEEN LS.OpenDate AND LS.CloseDate WHERE LS.Location IN ('Beijing', 'Sao Paulo') AND YEAR(WG.CollectionDate) = 2022 GROUP BY LS.Location; |
Create a table named 'StudentDiversity' that stores the number of graduate students by ethnicity and gender. | CREATE TABLE StudentDiversity (ethnicity VARCHAR(50),gender VARCHAR(10),total_students INT); | INSERT INTO StudentDiversity (ethnicity, gender, total_students) VALUES ('Asian', 'Female', 1200), ('Asian', 'Male', 1500), ('Black', 'Female', 800), ('Black', 'Male', 1000), ('Hispanic', 'Female', 900), ('Hispanic', 'Male', 1100), ('White', 'Female', 2000), ('White', 'Male', 2500); |
Determine the jurisdictions with the most regulatory frameworks in the last 6 months? | CREATE TABLE regulatory_frameworks (framework_id INT,jurisdiction VARCHAR(255),framework_name VARCHAR(255),effective_date DATE); INSERT INTO regulatory_frameworks (framework_id,jurisdiction,framework_name,effective_date) VALUES (1,'United States','Securities Act of 1933','1933-05-27'),(2,'European Union','MiCA','2022-0... | SELECT jurisdiction, COUNT(*) OVER (PARTITION BY jurisdiction) AS jurisdiction_framework_count, RANK() OVER (ORDER BY COUNT(*) DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS jurisdiction_rank FROM regulatory_frameworks WHERE effective_date >= DATEADD(month, -6, CURRENT_DATE); |
Update the 'status' column to 'completed' for all records in the 'habitat_preservation' table where the 'end_date' is less than the current date | CREATE TABLE habitat_preservation (habitat_preservation_id INT PRIMARY KEY,location_id INT,preservation_method VARCHAR(50),start_date DATE,end_date DATE,area_preserved INT,status VARCHAR(20)); | UPDATE habitat_preservation SET status = 'completed' WHERE end_date < CURDATE(); |
Which satellites were deployed by 'SpaceX'? | CREATE TABLE SatelliteDeployment(name VARCHAR(20),company VARCHAR(20)); INSERT INTO SatelliteDeployment VALUES('Satellite A','NASA'),('Satellite B','SpaceX'); | SELECT name FROM SatelliteDeployment WHERE company='SpaceX'; |
Delete the 'cybersecurity_strategy' table | CREATE TABLE cybersecurity_strategy (strategy_id INT PRIMARY KEY,strategy_name VARCHAR(30),strategy_description TEXT); | DROP TABLE cybersecurity_strategy; |
How many employees were hired in each month in the last year, broken down by job category? | CREATE TABLE HiringData (EmployeeID INT,HireDate DATE,JobCategory VARCHAR(20)); | SELECT DATEPART(MONTH, HireDate) as Month, JobCategory, COUNT(*) as NewHires FROM HiringData WHERE HireDate BETWEEN DATEADD(YEAR, -1, GETDATE()) AND GETDATE() GROUP BY DATEPART(MONTH, HireDate), JobCategory; |
What is the total number of students who received accommodations for each accommodation type? | CREATE TABLE Accommodations (student_id INT,accommodation_type VARCHAR(255)); INSERT INTO Accommodations (student_id,accommodation_type) VALUES (1,'Extended Time'),(2,'Quiet Space'),(3,'Assistive Technology'),(4,'Sign Language Interpreter'); | SELECT accommodation_type, COUNT(*) as total_students FROM Accommodations GROUP BY accommodation_type; |
What is the minimum depth of all uranium mines in the 'mine_stats' table? | CREATE TABLE mine_stats (mine_name VARCHAR(255),mine_type VARCHAR(255),depth FLOAT); INSERT INTO mine_stats (mine_name,mine_type,depth) VALUES ('Uranium Vale','uranium',3000.9),('Radium Ridge','uranium',3500.1),('Nuclear Nexus','uranium',2800.6); | SELECT MIN(depth) FROM mine_stats WHERE mine_type = 'uranium'; |
Get the count of unique residents in 'Participation' table? | CREATE TABLE Participation (participant_id INT,resident_id INT,initiative_id INT); CREATE TABLE CityData (resident_id INT,age INT,gender VARCHAR(10)); | SELECT COUNT(DISTINCT resident_id) FROM Participation; |
What is the minimum playtime for players in each region? | CREATE TABLE player_playtime (player_id INT,region VARCHAR(255),playtime FLOAT); INSERT INTO player_playtime (player_id,region,playtime) VALUES (1,'North America',50),(2,'Europe',40),(3,'Asia',60),(4,'South America',70); | SELECT region, MIN(playtime) as min_playtime FROM player_playtime GROUP BY region; |
What is the average quantity of fish caught per species in the North Atlantic region? | CREATE TABLE FishCaught (species VARCHAR(50),region VARCHAR(50),quantity INT); INSERT INTO FishCaught (species,region,quantity) VALUES ('Tuna','North Atlantic',300),('Salmon','North Atlantic',250),('Cod','North Atlantic',400); | SELECT species, AVG(quantity) as avg_quantity FROM FishCaught WHERE region = 'North Atlantic' GROUP BY species; |
Find the total count of defense contracts for each contracting agency, excluding contracts with a value of $0. | CREATE TABLE defense_contracts (contract_id INT,agency VARCHAR(255),value DECIMAL(10,2));INSERT INTO defense_contracts (contract_id,agency,value) VALUES (1,'DoD',1000000.00),(2,'DoD',0.00),(3,'VA',500000.00); | SELECT agency, COUNT(*) as total_contracts FROM defense_contracts WHERE value > 0 GROUP BY agency; |
What is the total number of esports events held in Asia and Europe? | CREATE VIEW Esports_Events (Location,Event_Name) AS SELECT 'Asia' AS Location,'E-Sports Tournament 1' AS Event_Name UNION ALL SELECT 'Europe' AS Location,'E-Sports Tournament 2' AS Event_Name; | SELECT COUNT(*) FROM Esports_Events WHERE Location IN ('Asia', 'Europe'); |
How many members have a gym membership and performed a Pilates workout in the last month? | CREATE TABLE Members (MemberID INT,GymMembership BOOLEAN); INSERT INTO Members (MemberID,GymMembership) VALUES (1,TRUE); INSERT INTO Members (MemberID,GymMembership) VALUES (2,FALSE); CREATE TABLE Workouts (WorkoutID INT,WorkoutDate DATE,WorkoutType VARCHAR(50),MemberID INT); INSERT INTO Workouts (WorkoutID,WorkoutDate... | SELECT COUNT(*) FROM Members INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE Members.GymMembership = TRUE AND Workouts.WorkoutDate >= '2022-02-01' AND Workouts.WorkoutType = 'Pilates'; |
What are the total sales for all artists in the 'Jazz' genre, excluding sales from the artist 'ArtistD'? | CREATE TABLE Sales (SaleID INT,ArtistID INT,Sales FLOAT,Genre VARCHAR(10)); INSERT INTO Sales (SaleID,ArtistID,Sales,Genre) VALUES (1,1,15000,'Hip Hop'),(2,1,12000,'Hip Hop'),(3,2,20000,'Pop'),(4,3,18000,'Jazz'),(5,3,20000,'Jazz'),(6,4,10000,'Jazz'),(7,2,10000,'Pop'); | SELECT SUM(Sales) AS TotalSales FROM Sales WHERE Genre = 'Jazz' AND ArtistID != 4; |
Delete records of visitors who are under 18 years old from the visitors table | CREATE TABLE visitors (id INT,age INT,gender TEXT,country TEXT); | DELETE FROM visitors WHERE age < 18; |
Insert a new record into the 'exhibitions' table for a digital exhibition | CREATE TABLE exhibitions (id INT PRIMARY KEY,name VARCHAR(25),type VARCHAR(15)); | INSERT INTO exhibitions (id, name, type) VALUES (1, 'Digital Art Experience', 'digital'); |
Show the number of wins for each player per game in the 'PlayerWins' and 'PlayerGames' tables | CREATE TABLE PlayerWins (PlayerID INT,GameID INT,WinID INT); CREATE TABLE PlayerGames (PlayerID INT,GameID INT); | SELECT p.PlayerID, g.GameID, COUNT(pw.WinID) as WinsPerPlayerPerGame FROM PlayerWins pw INNER JOIN PlayerGames pg ON pw.PlayerID = pg.PlayerID AND pw.GameID = pg.GameID INNER JOIN (SELECT GameID, COUNT(*) as TotalGames FROM PlayerGames GROUP BY GameID) g ON pw.GameID = g.GameID GROUP BY p.PlayerID, g.GameID; |
Delete all records of workers in the 'Textile' industry who have not received ethical manufacturing training. | CREATE TABLE Workers (ID INT,Industry VARCHAR(20),Ethical_Training BOOLEAN); INSERT INTO Workers (ID,Industry,Ethical_Training) VALUES (1,'Textile',FALSE); INSERT INTO Workers (ID,Industry,Ethical_Training) VALUES (2,'Textile',TRUE); INSERT INTO Workers (ID,Industry,Ethical_Training) VALUES (3,'Textile',FALSE); INSERT ... | DELETE FROM Workers WHERE Industry = 'Textile' AND Ethical_Training = FALSE; |
Update the production amount for 'China' in 2019 to 125000. | CREATE TABLE production (country VARCHAR(255),year INT,amount INT); INSERT INTO production (country,year,amount) VALUES ('China',2019,120000),('China',2020,140000),('USA',2020,38000),('Australia',2020,20000),('India',2020,5000); | UPDATE production SET amount = 125000 WHERE country = 'China' AND year = 2019; |
What is the total quantity of chemical products manufactured by each facility, sorted by the highest total quantity? | CREATE TABLE facility (facility_id INT,facility_name VARCHAR(255)); INSERT INTO facility (facility_id,facility_name) VALUES (1,'Facility A'),(2,'Facility B'),(3,'Facility C'); CREATE TABLE product (product_id INT,product_name VARCHAR(255),facility_id INT,quantity_manufactured INT); | SELECT facility_id, facility_name, SUM(quantity_manufactured) AS total_quantity FROM product JOIN facility ON product.facility_id = facility.facility_id GROUP BY facility_id, facility_name ORDER BY total_quantity DESC; |
What is the recycling rate for Latin America and the Caribbean in 2021?' | CREATE TABLE recycling_rates (country VARCHAR(50),region VARCHAR(50),recycling_rate FLOAT,year INT); INSERT INTO recycling_rates (country,region,recycling_rate,year) VALUES ('Brazil','Latin America and the Caribbean',0.2,2021),('Mexico','Latin America and the Caribbean',0.3,2021),('Argentina','Latin America and the Car... | SELECT AVG(recycling_rate) FROM recycling_rates WHERE region = 'Latin America and the Caribbean' AND year = 2021; |
What is the total number of cases handled by restorative justice programs in California and New York? | CREATE TABLE restorative_justice_ca (case_id INT,state VARCHAR(20)); INSERT INTO restorative_justice_ca VALUES (1,'California'),(2,'California'),(3,'California'); CREATE TABLE restorative_justice_ny (case_id INT,state VARCHAR(20)); INSERT INTO restorative_justice_ny VALUES (4,'New York'),(5,'New York'); | SELECT COUNT(*) FROM restorative_justice_ca UNION ALL SELECT COUNT(*) FROM restorative_justice_ny; |
What is the total number of streams for Pop artists from the United States? | CREATE TABLE artists (artist_id INT,artist_genre VARCHAR(50),artist_country VARCHAR(50)); INSERT INTO artists (artist_id,artist_genre,artist_country) VALUES (1,'Pop','United States'),(2,'Rock','Brazil'),(3,'Reggaeton','Mexico'); CREATE TABLE streams (stream_id INT,artist_id INT); INSERT INTO streams (stream_id,artist_i... | SELECT SUM(s.stream_id) FROM streams s INNER JOIN artists a ON s.artist_id = a.artist_id WHERE a.artist_genre = 'Pop' AND a.artist_country = 'United States'; |
What is the percentage of fair trade products in each product category? | CREATE TABLE Products (product_id INT,product_category VARCHAR(50),fair_trade_product BOOLEAN); | SELECT Products.product_category, AVG(CASE WHEN Products.fair_trade_product = TRUE THEN 100 ELSE 0 END) as fair_trade_percentage FROM Products GROUP BY Products.product_category; |
What is the average number of visitors to virtual tours in France? | CREATE TABLE tour_visitors(tour_id INT,num_visitors INT); INSERT INTO tour_visitors (tour_id,num_visitors) VALUES (1,2000),(2,3000); CREATE VIEW virtual_tours_french AS SELECT vt.tour_id,vt.name,vt.country,tv.num_visitors FROM virtual_tours vt INNER JOIN tour_visitors tv ON vt.tour_id = tv.tour_id WHERE vt.country = 'F... | SELECT AVG(num_visitors) FROM virtual_tours_french; |
Find the vessels that have transported both coal and oil. | CREATE TABLE Vessel_Cargo (Vessel_ID INT,Cargo_Type VARCHAR(255)); INSERT INTO Vessel_Cargo (Vessel_ID,Cargo_Type) VALUES (1,'Grain'),(2,'Containers'),(3,'Oil'),(4,'Coal'),(5,'Coal'),(6,'Oil'); | SELECT Vessel_ID FROM Vessel_Cargo WHERE Cargo_Type = 'Coal' INTERSECT SELECT Vessel_ID FROM Vessel_Cargo WHERE Cargo_Type = 'Oil'; |
How many patients with respiratory diseases were treated in rural healthcare facilities, broken down by gender and age group? | CREATE TABLE treatments (treatment_id INT,patient_id INT,healthcare_id INT,date DATE); CREATE TABLE patients (patient_id INT,disease TEXT,age INT,gender TEXT); CREATE TABLE healthcare_facilities (healthcare_id INT,name TEXT,type TEXT,rural BOOLEAN); INSERT INTO treatments (treatment_id,patient_id,healthcare_id,date) VA... | SELECT CASE WHEN patients.age < 60 THEN 'Under 60' ELSE '60 and Over' END as age_group, patients.gender, COUNT(treatments.treatment_id) as count FROM treatments INNER JOIN patients ON treatments.patient_id = patients.patient_id INNER JOIN healthcare_facilities ON treatments.healthcare_id = healthcare_facilities.healthc... |
What is the average number of military personnel in the Australian region in 2021? | CREATE TABLE Personnel (personnel_id INT,personnel_count INT,year INT,region_id INT); INSERT INTO Personnel (personnel_id,personnel_count,year,region_id) VALUES (1,1000,2020,6),(2,1200,2021,6); | SELECT AVG(personnel_count) FROM Personnel WHERE year = 2021 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'Australian'); |
What is the average price of each eco-friendly garment type in the North America region in Q4 2022? | CREATE TABLE sales_eco_north_america (sale_id INT,garment_type VARCHAR(50),sale_date DATE,total_sales DECIMAL(10,2),region VARCHAR(50),is_eco_friendly BOOLEAN); | SELECT garment_type, AVG(total_sales) FROM sales_eco_north_america WHERE is_eco_friendly = true AND region = 'North America' AND sale_date BETWEEN '2022-10-01' AND '2022-12-31' GROUP BY garment_type; |
What is the average number of installations visited per visitor, partitioned by country? | CREATE TABLE Countries (CountryID INT,Country VARCHAR(50)); INSERT INTO Countries (CountryID,Country) VALUES (1,'USA'),(2,'Canada'); CREATE TABLE Visits (VisitID INT,VisitorID INT,CountryID INT,InstallationID INT); INSERT INTO Visits (VisitID,VisitorID,CountryID,InstallationID) VALUES (1,1,1,1),(2,1,1,2),(3,2,2,3); | SELECT Country, AVG(InstallationID) OVER (PARTITION BY CountryID) AS AvgInstallationsPerVisitor FROM Visits V JOIN Countries C ON V.CountryID = C.CountryID; |
What is the earliest innovation date for each company? | CREATE TABLE CompanyInnovations (company_id INT,innovation_date DATE); INSERT INTO CompanyInnovations (company_id,innovation_date) VALUES (1,'2020-01-01'),(1,'2019-01-01'),(2,'2018-01-01'); | SELECT company_id, MIN(innovation_date) as earliest_innovation_date FROM CompanyInnovations GROUP BY company_id; |
Which community development programs in the 'programs' table received funding in '2022'? | CREATE TABLE programs (program_id INT,program_name VARCHAR(50),start_date DATE); INSERT INTO programs (program_id,program_name,start_date) VALUES (1,'Youth Skills','2021-01-01'),(2,'Women Empowerment','2022-01-01'),(3,'Clean Water','2020-01-01'); | SELECT program_name FROM programs WHERE YEAR(start_date) = 2022; |
Insert a new record in the fan table with the following data: id=21, name='Mia Zhang', age=32, gender='Female', city='Beijing'. | CREATE TABLE fan (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),city VARCHAR(50)); | INSERT INTO fan (id, name, age, gender, city) VALUES (21, 'Mia Zhang', 32, 'Female', 'Beijing'); |
Which teams in the 'teams' table have a name that starts with the letter 'T' and ends with the letter 'S'? | CREATE TABLE teams (team VARCHAR(50)); INSERT INTO teams (team) VALUES ('Team Alpha'),('Team Bravo'),('Team Tango'),('Team Zulu'); | SELECT team FROM teams WHERE team LIKE 'T%S'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.