instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Update the textile sourcing information for 'Supplier2'. | CREATE TABLE TEXTILE_SOURCING (supplier_id INT PRIMARY KEY,supplier_name VARCHAR(50),country VARCHAR(50),material VARCHAR(50)); INSERT INTO TEXTILE_SOURCING (supplier_id,supplier_name,country,material) VALUES (1,'Supplier1','India','Silk'),(2,'Supplier2','China','Polyester'),(3,'Supplier3','Bangladesh','Cotton'); | UPDATE TEXTILE_SOURCING SET country = 'Vietnam' WHERE supplier_name = 'Supplier2'; |
What is the total area of timber production sites and wildlife habitats in each region? | CREATE TABLE timber (id INT,name VARCHAR(255),area FLOAT,region_id INT); INSERT INTO timber (id,name,area,region_id) VALUES (1,'Timber1',123.45,1); INSERT INTO timber (id,name,area,region_id) VALUES (2,'Timber2',234.56,2); CREATE TABLE habitat (id INT,name VARCHAR(255),area FLOAT,region_id INT); INSERT INTO habitat (id... | SELECT r.name, SUM(t.area) + SUM(h.area) FROM timber t JOIN habitat h ON t.region_id = h.region_id JOIN region r ON t.region_id = r.id GROUP BY r.name; |
Delete all records of smart contracts from the 'Ethereum' network. | CREATE TABLE smart_contracts (id INT,name VARCHAR(255),network VARCHAR(50)); INSERT INTO smart_contracts (id,name,network) VALUES (1,'Contract1','Ethereum'),(2,'Contract2','Binance'),(3,'Contract3','Ethereum'); | DELETE FROM smart_contracts WHERE network = 'Ethereum'; |
Insert a new record of a Canadian tourist visiting France in 2023. | CREATE TABLE tourism_data (id INT,country VARCHAR(50),destination VARCHAR(50),arrival_date DATE,age INT); | INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (5, 'Canada', 'France', '2023-06-25', 38); |
Which cities have only one type of facility? | CREATE TABLE city_facility_types (city TEXT,facility_type TEXT); INSERT INTO city_facility_types (city,facility_type) VALUES ('CityA','hospital'),('CityB','hospital'),('CityC','hospital'),('CityA','school'),('CityB','school'),('CityC','school'),('CityA','library'),('CityB','library'),('CityC','library'); | SELECT city FROM (SELECT city, COUNT(DISTINCT facility_type) AS num_types FROM city_facility_types GROUP BY city) AS temp WHERE num_types = 1; |
What is the average rating of TV shows per production company? | CREATE TABLE tv_show (id INT,title VARCHAR(255),rating DECIMAL(3,2),company VARCHAR(255)); INSERT INTO tv_show (id,title,rating,company) VALUES (1,'TVShow1',7.5,'CompanyA'),(2,'TVShow2',8.2,'CompanyB'),(3,'TVShow3',6.9,'CompanyA'); | SELECT company, AVG(rating) FROM tv_show GROUP BY company; |
Delete the record of the investment round with id 5 in the investment_rounds table | CREATE TABLE investment_rounds (id INT,company_id INT,funding_amount INT); | DELETE FROM investment_rounds WHERE id = 5; |
Update the email address for the customer with an ID of 123 to 'alex.new_email@example.com' | CREATE TABLE customer (customer_id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50),email VARCHAR(100)); | UPDATE customer SET email = 'alex.new_email@example.com' WHERE customer_id = 123; |
What is the virtual tour engagement rate by city? | CREATE TABLE virtual_tours (tour_id INT,city TEXT,views INT,clicks INT); INSERT INTO virtual_tours (tour_id,city,views,clicks) VALUES (1,'City A',1000,200),(2,'City B',1500,300),(3,'City C',2000,400); | SELECT city, (SUM(clicks) * 100.0 / SUM(views)) as engagement_rate FROM virtual_tours GROUP BY city; |
Who are the top 3 OTA's in 'Europe' by number of bookings? | CREATE TABLE otas (ota_id INT,ota_name VARCHAR(50),region VARCHAR(50),bookings INT); INSERT INTO otas (ota_id,ota_name,region,bookings) VALUES (1,'Booking.com','Europe',5000),(2,'Expedia','North America',4000),(3,'Agoda','Asia',3000); | SELECT ota_name, bookings FROM otas WHERE region = 'Europe' ORDER BY bookings DESC LIMIT 3; |
How many companies have been founded by individuals who identify as LGBTQ+ in the Renewable Energy sector? | CREATE TABLE Companies (id INT,name TEXT,industry TEXT); INSERT INTO Companies VALUES (1,'Renewable Energy Company','Renewable Energy'); CREATE TABLE Founders (id INT,company_id INT,identity TEXT); INSERT INTO Founders VALUES (1,1,'LGBTQ+'); | SELECT COUNT(DISTINCT Companies.id) FROM Companies JOIN Founders ON Companies.id = Founders.company_id WHERE Founders.identity = 'LGBTQ+' AND Companies.industry = 'Renewable Energy'; |
How many legal aid cases were opened in each district, in the last quarter? | CREATE TABLE legal_aid_cases (case_id INT,district_id INT,open_date DATE); INSERT INTO legal_aid_cases (case_id,district_id,open_date) VALUES (1,1,'2022-01-05'),(2,2,'2022-03-10'),(3,1,'2022-04-01'); | SELECT legal_aid_cases.district_id, COUNT(*) as num_cases FROM legal_aid_cases WHERE open_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY legal_aid_cases.district_id; |
What is the average expenditure of tourists from France in New York City? | CREATE TABLE tourism_stats (visitor_country VARCHAR(20),destination VARCHAR(20),expenditure DECIMAL(10,2)); INSERT INTO tourism_stats (visitor_country,destination,expenditure) VALUES ('France','New York City',500.50),('France','New York City',450.20),('France','New York City',575.00); | SELECT AVG(expenditure) FROM tourism_stats WHERE visitor_country = 'France' AND destination = 'New York City'; |
How many IoT soil moisture sensors were installed in April? | CREATE TABLE sensor_installation (sensor_id INT,install_date DATE); INSERT INTO sensor_installation (sensor_id,install_date) VALUES (1001,'2021-04-03'),(1002,'2021-04-17'),(1003,'2021-04-01'),(1004,'2021-04-15'),(1005,'2021-03-30'); | SELECT COUNT(*) FROM sensor_installation WHERE install_date >= '2021-04-01' AND install_date < '2021-05-01'; |
What is the total number of public schools and their average budget in California? | CREATE TABLE public_schools (name TEXT,budget INTEGER,state TEXT); INSERT INTO public_schools (name,budget,state) VALUES ('School1',5000,'California'),('School2',6000,'California'),('School3',7000,'California'); | SELECT COUNT(*) as total_schools, AVG(budget) as avg_budget FROM public_schools WHERE state = 'California'; |
What is the total amount of money spent on equipment maintenance in the first half of 2021? | CREATE TABLE equipment_maintenance (equipment_id INT,maintenance_date DATE,maintenance_cost DECIMAL(10,2)); INSERT INTO equipment_maintenance (equipment_id,maintenance_date,maintenance_cost) VALUES (1,'2021-01-15',500.00),(2,'2021-01-20',800.00),(3,'2021-03-01',700.00),(4,'2021-03-14',950.00),(5,'2021-04-20',1200.00),(... | SELECT SUM(maintenance_cost) FROM equipment_maintenance WHERE maintenance_date BETWEEN '2021-01-01' AND '2021-06-30' |
What was the total funding received for 'Theater Education' programs? | CREATE TABLE Funding_Programs (program_name VARCHAR(255),funding_received INT); INSERT INTO Funding_Programs (program_name,funding_received) VALUES ('Art Education',75000),('Music Education',60000),('Theater Education',80000); | SELECT funding_received FROM Funding_Programs WHERE program_name = 'Theater Education'; |
What is the total number of sustainable urban properties? | CREATE TABLE properties (id INT,sustainability_rating FLOAT,urban BOOLEAN); INSERT INTO properties (id,sustainability_rating,urban) VALUES (1,80.5,true),(2,60.0,false); | SELECT COUNT(*) FROM properties WHERE urban = true AND sustainability_rating IS NOT NULL; |
How many students have been enrolled in lifelong learning programs each year? | CREATE TABLE lifelong_learning_enrollment (student_id INT,enrollment_year INT); INSERT INTO lifelong_learning_enrollment (student_id,enrollment_year) VALUES (1,2020),(2,2020),(3,2020),(4,2021),(5,2021),(6,2022); | SELECT enrollment_year, COUNT(DISTINCT student_id) as num_students FROM lifelong_learning_enrollment GROUP BY enrollment_year; |
What is the sum of sales for each product type in Colorado over the last quarter? | CREATE TABLE Dispensaries (id INT,name TEXT,state TEXT);CREATE TABLE Sales (id INT,dispensary_id INT,product_type TEXT,sale_amount DECIMAL,sale_date DATE); | SELECT D.product_type, SUM(S.sale_amount) FROM Dispensaries D JOIN Sales S ON D.id = S.dispensary_id WHERE D.state = 'Colorado' AND S.sale_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY D.product_type; |
How many active rigs are there in the Permian Basin? | CREATE TABLE rigs (rig_id INT,status VARCHAR(255),basin VARCHAR(255)); INSERT INTO rigs (rig_id,status,basin) VALUES (1,'active','Permian Basin'); INSERT INTO rigs (rig_id,status,basin) VALUES (2,'inactive','Permian Basin'); | SELECT COUNT(*) FROM rigs WHERE status = 'active' AND basin = 'Permian Basin'; |
List the number of safety incidents for each chemical type, ordered from most to least incidents? | CREATE TABLE safety_incidents (chemical_type VARCHAR(255),incident_date DATE); INSERT INTO safety_incidents (chemical_type,incident_date) VALUES ('Type A','2020-01-05'),('Type A','2020-03-12'),('Type B','2020-02-18'),('Type C','2020-01-02'),('Type C','2020-04-20'),('Type D','2020-03-03'); | SELECT chemical_type, COUNT(*) as incident_count FROM safety_incidents GROUP BY chemical_type ORDER BY incident_count DESC |
What is the number of properties in Atlanta with sustainable urbanism projects? | CREATE TABLE properties (id INT,city VARCHAR(50),has_sustainable_urbanism_project BOOLEAN); INSERT INTO properties (id,city,has_sustainable_urbanism_project) VALUES (1,'Atlanta',TRUE),(2,'Atlanta',FALSE),(3,'Atlanta',TRUE); | SELECT COUNT(*) FROM properties WHERE city = 'Atlanta' AND has_sustainable_urbanism_project = TRUE; |
Add a new record to the "cargo" table for cargo with ID 1, associated with vessel ID 1, destined for 'San Francisco', and with a delivery date of '2023-03-15'. | CREATE TABLE cargo (cargo_id INT,vessel_id INT,destination VARCHAR(50),delivery_date DATE); | INSERT INTO cargo (cargo_id, vessel_id, destination, delivery_date) VALUES (1, 1, 'San Francisco', '2023-03-15'); |
How many unique news categories are there in the 'news_categories' table? | CREATE TABLE news_categories (id INT,category VARCHAR(30)); INSERT INTO news_categories (id,category) VALUES (1,'Politics'); INSERT INTO news_categories (id,category) VALUES (2,'Sports'); INSERT INTO news_categories (id,category) VALUES (3,'Entertainment'); | SELECT COUNT(DISTINCT category) FROM news_categories; |
Insert a record into 'ethical_ai_research' table | CREATE TABLE ethical_ai_research (id INT PRIMARY KEY,title VARCHAR(255),abstract TEXT,author_name VARCHAR(255),author_affiliation VARCHAR(255),publication_date DATETIME); | INSERT INTO ethical_ai_research (id, title, abstract, author_name, author_affiliation, publication_date) VALUES (1, 'Bias in AI Algorithms', 'Exploring causes and potential solutions...', 'Dr. Jane Smith', 'MIT', '2023-03-15 14:30:00'); |
How many electric vehicles were sold in California during the first quarter of 2021? | CREATE TABLE sales_data (state VARCHAR(20),quarter INT,year INT,vehicle_type VARCHAR(10),quantity INT); INSERT INTO sales_data (state,quarter,year,vehicle_type,quantity) VALUES ('California',1,2021,'Electric',5000),('California',2,2021,'Electric',4500),('California',3,2021,'Electric',6000),('California',4,2021,'Electri... | SELECT state, SUM(quantity) AS total_sold FROM sales_data WHERE state = 'California' AND vehicle_type = 'Electric' AND quarter = 1 GROUP BY state; |
Delete records in the 'oil_production' table where the 'year' is less than 2010 | CREATE TABLE oil_production (year INT,well_id INT,oil_volume FLOAT); | DELETE FROM oil_production WHERE year < 2010; |
Show the number of unique founders in the retail sector | CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_year INT,founder_id INT); INSERT INTO company (id,name,industry,founding_year,founder_id) VALUES (1,'Shop Easy','Retail',2018,1001); INSERT INTO company (id,name,industry,founding_year,founder_id) VALUES (2,'BuySmart','Retail',2020,1002); INSERT INTO company... | SELECT COUNT(DISTINCT founder_id) FROM company WHERE industry = 'Retail' |
List the total number of claims and total claim amount for each product type. | CREATE TABLE Claim (ClaimID INT,PolicyholderID INT,ClaimDate DATE,Product VARCHAR(10),ClaimAmount DECIMAL(10,2)); INSERT INTO Claim (ClaimID,PolicyholderID,ClaimDate,Product,ClaimAmount) VALUES (1,1,'2020-01-01','Auto',500),(2,1,'2021-01-01','Auto',1000),(3,2,'2020-01-01','Home',2000),(4,3,'2018-01-01','Auto',1500); | SELECT Product, COUNT(*) AS TotalClaims, SUM(ClaimAmount) AS TotalClaimAmount FROM Claim GROUP BY Product; |
What is the distribution of incident severity in the 'IncidentReports' table, in a bar chart? | CREATE TABLE IncidentReports (id INT,incident_name VARCHAR(50),severity VARCHAR(10),country VARCHAR(20)); INSERT INTO IncidentReports (id,incident_name,severity,country) VALUES (1,'Incident1','High','USA'),(2,'Incident2','Medium','Canada'),(3,'Incident3','Low','Mexico'),(4,'Incident4','High','Brazil'),(5,'Incident5','L... | SELECT severity, COUNT(*) as total_incidents FROM IncidentReports GROUP BY severity; |
Determine the maximum military budget for the Southeast Asian region in 2022. | CREATE TABLE Military_Budgets (budget_id INT,year INT,region_id INT,amount DECIMAL(10,2)); INSERT INTO Military_Budgets (budget_id,year,region_id,amount) VALUES (1,2021,8,9000000.00),(2,2022,8,9500000.00); | SELECT MAX(amount) FROM Military_Budgets WHERE year = 2022 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'Southeast Asian'); |
What is the total number of AI patents filed by companies in the European Union, excluding the United Kingdom, from 2015 to 2020? | CREATE TABLE ai_patents (company VARCHAR(255),country VARCHAR(255),year INT,num_patents INT); INSERT INTO ai_patents (company,country,year,num_patents) VALUES ('Google','Germany',2015,50),('Microsoft','France',2016,75),('IBM','Italy',2017,60),('Amazon','Spain',2018,80),('Facebook','Ireland',2019,90),('Alphabet','Nether... | SELECT SUM(num_patents) as total_patents, country FROM ai_patents WHERE country NOT IN ('United Kingdom') AND year BETWEEN 2015 AND 2020 GROUP BY country; |
How many new cosmetic products were launched in Q3 2022, and how many of them are eco-friendly? | CREATE TABLE cosmetic_products (id INT,product_name VARCHAR(255),launch_date DATE,is_eco_friendly BOOLEAN); | SELECT COUNT(*), SUM(is_eco_friendly) FROM cosmetic_products WHERE launch_date BETWEEN '2022-07-01' AND '2022-09-30'; |
Calculate the total number of hours volunteered by all volunteers in the month of April 2022. | CREATE TABLE Volunteer_Hours (id INT,volunteer_id INT,hours_volunteered DECIMAL(5,2),volunteer_date DATE); INSERT INTO Volunteer_Hours (id,volunteer_id,hours_volunteered,volunteer_date) VALUES (1,1,4.00,'2022-04-01'),(2,2,5.00,'2022-04-05'),(3,1,3.00,'2022-04-10'); | SELECT SUM(hours_volunteered) as total_hours FROM Volunteer_Hours WHERE volunteer_date BETWEEN '2022-04-01' AND '2022-04-30'; |
Update the email address for clinics that provide telehealth services in Alaska. | CREATE TABLE clinic_info (clinic_id INT,state VARCHAR(2),email VARCHAR(50)); INSERT INTO clinic_info (clinic_id,state,email) VALUES (1,'Alaska','clinic1@example.com'),(2,'Alaska','clinic2@example.com'),(3,'Wyoming','clinic3@example.com'); CREATE TABLE telehealth_services (service_id INT,clinic_id INT); INSERT INTO tele... | UPDATE clinic_info SET email = 'telehealth.clinic@example.com' WHERE clinic_id IN (SELECT clinic_id FROM telehealth_services); |
What is the maximum water depth for each fish species? | CREATE TABLE fish_species (id INT,name VARCHAR(50),average_length DECIMAL(5,2)); CREATE TABLE fish_locations (id INT,fish_species_id INT,fish_farm_id INT,water_depth DECIMAL(5,2)); INSERT INTO fish_species (id,name,average_length) VALUES (1,'Salmon',70.0),(2,'Tilapia',25.0); INSERT INTO fish_locations (id,fish_species_... | SELECT fs.name, MAX(fl.water_depth) AS max_water_depth FROM fish_species fs JOIN fish_locations fl ON fs.id = fl.fish_species_id GROUP BY fs.name; |
Calculate the total water consumption in cubic meters for the region 'Greater Toronto' for the month of July 2020 | CREATE TABLE water_consumption (region VARCHAR(50),date DATE,consumption FLOAT); INSERT INTO water_consumption (region,date,consumption) VALUES ('Greater Toronto','2020-07-01',1500),('Greater Toronto','2020-07-02',1600),('Greater Toronto','2020-07-03',1400); | SELECT SUM(consumption) FROM water_consumption WHERE region = 'Greater Toronto' AND date BETWEEN '2020-07-01' AND '2020-07-31'; |
What is the average environmental impact per mine? | CREATE TABLE mines (mine_id INT,name TEXT,location TEXT,environmental_impact FLOAT); INSERT INTO mines (mine_id,name,location,environmental_impact) VALUES (1,'ABC Mine','USA',200),(2,'DEF Mine','Canada',250); | SELECT AVG(environmental_impact) FROM mines; |
Create a view 'v_high_experience_skills' that shows employees with more than 4 years of experience in any skill | CREATE TABLE employee_skills (employee_id INT,skill_name VARCHAR(50),experience_years INT); INSERT INTO employee_skills (employee_id,skill_name,experience_years) VALUES (1,'sustainable_manufacturing',3),(2,'quality_control',1),(3,'sustainable_manufacturing',5); | CREATE VIEW v_high_experience_skills AS SELECT employee_id, skill_name, experience_years FROM employee_skills WHERE experience_years > 4; |
What is the max duration of a spacewalk by an astronaut from country X? | CREATE TABLE Spacewalk (id INT,astronaut_id INT,country VARCHAR(30),duration FLOAT); | SELECT MAX(duration) FROM Spacewalk WHERE country = 'X'; |
Display policyholders with age greater than 40 | CREATE TABLE Policyholders (PolicyholderID INT,Age INT,Gender VARCHAR(10)); INSERT INTO Policyholders (PolicyholderID,Age,Gender) VALUES (1,34,'Female'),(2,45,'Male'),(3,52,'Male'); | SELECT * FROM Policyholders WHERE Age > 40; |
What is the total cost of satellite missions organized by each country? | CREATE TABLE satellite_missions (id INT,mission_name VARCHAR(255),country VARCHAR(255),cost FLOAT,duration FLOAT); INSERT INTO satellite_missions (id,mission_name,country,cost,duration) VALUES (1,'Sentinel-1A','Europe',150000000,780),(2,'Sentinel-1B','Europe',150000000,780),(3,'Landsat 8','USA',855000000,1639),(4,'Reso... | SELECT country, SUM(cost) as total_cost FROM satellite_missions GROUP BY country; |
Add new animal to 'endangered_species' table | CREATE TABLE endangered_species (id INT PRIMARY KEY,animal_name VARCHAR,population INT); | INSERT INTO endangered_species (id, animal_name, population) VALUES (5, 'Orangutan', 250); |
List destinations in South America with sustainable tourism certifications and no advisories | CREATE TABLE destinations (name VARCHAR(255),continent VARCHAR(255),certification VARCHAR(255)); CREATE TABLE advisories (destination VARCHAR(255),advisory VARCHAR(255)); INSERT INTO destinations (name,continent,certification) VALUES ('Eco-Lodge','South America','Green Key'); INSERT INTO advisories (destination,advisor... | SELECT name FROM destinations d WHERE d.continent = 'South America' AND d.certification IS NOT NULL AND NOT EXISTS (SELECT 1 FROM advisories a WHERE a.destination = d.name); |
List the top 5 broadband plans with the highest monthly charge, including plan name and monthly charge, for the 'East' region. | CREATE TABLE plans (id INT,name VARCHAR(25),type VARCHAR(10),region VARCHAR(10)); INSERT INTO plans (id,name,type,region) VALUES (1,'Plan A','broadband','East'),(2,'Plan B','broadband','East'),(3,'Plan C','mobile','East'); CREATE TABLE charges (id INT,plan_id INT,monthly_charge DECIMAL(10,2)); INSERT INTO charges (id,p... | SELECT plans.name, MAX(charges.monthly_charge) AS max_charge FROM plans INNER JOIN charges ON plans.id = charges.plan_id WHERE plans.type = 'broadband' AND plans.region = 'East' GROUP BY plans.name ORDER BY max_charge DESC LIMIT 5; |
Who are the 'junior' workers in the 'metal' department of factory 2? | CREATE TABLE factories (factory_id INT,department VARCHAR(20)); INSERT INTO factories VALUES (1,'textile'),(2,'metal'),(3,'textile'); CREATE TABLE roles (role_id INT,role_name VARCHAR(20)); INSERT INTO roles VALUES (1,'junior'),(2,'senior'),(3,'manager'); CREATE TABLE workers (worker_id INT,factory_id INT,role_id INT);... | SELECT w.worker_id, w.factory_id, r.role_name FROM workers w INNER JOIN roles r ON w.role_id = r.role_id INNER JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'metal' AND r.role_name = 'junior'; |
How many workplace safety incidents occurred in the 'Construction' industry, broken down by union membership? | CREATE TABLE SafetyIncidents (IncidentID INT,Industry VARCHAR(20),UnionMember BOOLEAN,IncidentDate DATE); INSERT INTO SafetyIncidents (IncidentID,Industry,UnionMember,IncidentDate) VALUES (1,'Construction',true,'2020-01-15'),(2,'Construction',false,'2020-02-10'),(3,'Construction',true,'2020-03-01'); | SELECT Industry, UnionMember, COUNT(*) FROM SafetyIncidents WHERE Industry = 'Construction' GROUP BY Industry, UnionMember; |
What is the minimum food safety score for restaurants in each city? | CREATE TABLE RestaurantInspections (restaurant_id INT,city VARCHAR(50),food_safety_score INT); INSERT INTO RestaurantInspections (restaurant_id,city,food_safety_score) VALUES (1,'New York',95),(2,'Los Angeles',88),(3,'New York',92); | SELECT city, MIN(food_safety_score) as min_score FROM RestaurantInspections GROUP BY city; |
Display the percentage of customers who have made a purchase from a vegan brand. | CREATE TABLE customer_demographics (customer_id INT,vegan_brand_customer BOOLEAN); INSERT INTO customer_demographics (customer_id,vegan_brand_customer) VALUES (1,true),(2,false),(3,true),(4,false),(5,true),(6,false); | SELECT (COUNT(*) FILTER (WHERE vegan_brand_customer))::float / COUNT(*) as percentage FROM customer_demographics; |
Determine the difference in flight hours between consecutive flights for each aircraft model, partitioned by manufacturer. | CREATE TABLE AircraftFlightHours (AircraftID INT,Model VARCHAR(50),Manufacturer VARCHAR(50),FlightHours INT,PreviousFlightHours INT); INSERT INTO AircraftFlightHours (AircraftID,Model,Manufacturer,FlightHours,PreviousFlightHours) VALUES (1,'747','Boeing',55000,NULL); INSERT INTO AircraftFlightHours (AircraftID,Model,Ma... | SELECT Model, Manufacturer, FlightHours, PreviousFlightHours, FlightHours - LAG(FlightHours) OVER (PARTITION BY Manufacturer ORDER BY FlightHours) AS Flight_Hour_Difference FROM AircraftFlightHours; |
Calculate the difference between the largest and smallest donations made by each donor, along with their names and IDs. | CREATE TABLE donors (id INT,name TEXT,donation_amount DECIMAL(10,2)); INSERT INTO donors (id,name,donation_amount) VALUES (1,'John Doe',500.00),(2,'Jane Smith',300.00),(3,'Alice Johnson',200.00),(3,'Alice Johnson',600.00); | SELECT donors.name, donors.id, LAG(donors.donation_amount) OVER (PARTITION BY donors.name ORDER BY donors.donation_amount DESC) AS previous_donation, donors.donation_amount - LAG(donors.donation_amount) OVER (PARTITION BY donors.name ORDER BY donors.donation_amount DESC) AS donation_difference FROM donors; |
How many wildlife sanctuaries in Greenland have experienced changes in permafrost conditions during the past 5 years? | CREATE TABLE WildlifeSanctuaries(sanctuary TEXT,permafrost TEXT,date DATE); INSERT INTO WildlifeSanctuaries(sanctuary,permafrost,date) VALUES ('Kangerlussuaq','Stable','2017-01-01'),('Kangerlussuaq','Unstable','2018-01-01'); | SELECT COUNT(*) FROM WildlifeSanctuaries WHERE permafrost != 'Stable' AND date BETWEEN '2017-01-01' AND '2022-01-01'; |
List the top 3 countries with the highest number of tourists visiting Costa Rica in 2019. | CREATE TABLE tourism_data (visitor_country VARCHAR(50),destination_country VARCHAR(50),visit_year INT); INSERT INTO tourism_data (visitor_country,destination_country,visit_year) VALUES ('USA','Costa Rica',2019),('Canada','Costa Rica',2019),('Mexico','Costa Rica',2019),('USA','Costa Rica',2019),('France','Costa Rica',20... | SELECT visitor_country, COUNT(*) as num_visitors FROM tourism_data WHERE visit_year = 2019 AND destination_country = 'Costa Rica' GROUP BY visitor_country ORDER BY num_visitors DESC LIMIT 3; |
What is the average data usage for each mobile device model? | CREATE TABLE mobile_subscribers_data_usage (subscriber_id INT,name VARCHAR(255),device_model VARCHAR(255),data_usage_gb FLOAT); INSERT INTO mobile_subscribers_data_usage (subscriber_id,name,device_model,data_usage_gb) VALUES (1,'John Doe','iPhone 12',10.5),(2,'Jane Doe','iPhone 12',11.2),(3,'Maria Garcia','Samsung Gala... | SELECT device_model, AVG(data_usage_gb) FROM mobile_subscribers_data_usage GROUP BY device_model; |
What is the average weight of packages shipped to each country in the 'warehouse_shipments' table, ordered by the highest average weight? | CREATE TABLE warehouse_shipments AS SELECT order_id,'USA' as country,AVG(weight) as avg_weight FROM orders WHERE shipping_address LIKE '123%' UNION ALL SELECT order_id,'Canada' as country,AVG(weight) as avg_weight FROM orders WHERE shipping_address LIKE '456%' UNION ALL SELECT order_id,'Mexico' as country,AVG(weight) a... | SELECT country, AVG(avg_weight) as avg_weight FROM warehouse_shipments GROUP BY country ORDER BY avg_weight DESC; |
What is the average safety rating of vehicles manufactured by Tesla since 2015? | CREATE TABLE Vehicles (id INT,make VARCHAR(255),model VARCHAR(255),safety_rating FLOAT,manufacturing_date DATE); INSERT INTO Vehicles (id,make,model,safety_rating,manufacturing_date) VALUES (1,'Tesla','Model S',5.0,'2015-01-01'); INSERT INTO Vehicles (id,make,model,safety_rating,manufacturing_date) VALUES (2,'Toyota','... | SELECT AVG(safety_rating) FROM Vehicles WHERE make = 'Tesla' AND manufacturing_date >= '2015-01-01'; |
Delete all emergency incidents and crime reports older than 2020-01-01. | CREATE TABLE emergency_incidents (id INT,incident_type VARCHAR(255),incident_date DATE); INSERT INTO emergency_incidents (id,incident_type,incident_date) VALUES (1,'Fire','2019-06-15'),(2,'Traffic Accident','2020-02-03'),(3,'Medical Emergency','2018-09-28'); CREATE TABLE crime_reports (id INT,report_type VARCHAR(255),r... | DELETE FROM emergency_incidents WHERE incident_date < '2020-01-01'; DELETE FROM crime_reports WHERE report_date < '2020-01-01'; |
How many intelligence operations were conducted per agency since 2000? | CREATE TABLE IntelOps (id INT,name VARCHAR(50),agency VARCHAR(50),location VARCHAR(50),start_date DATE); INSERT INTO IntelOps (id,name,agency,location,start_date) VALUES (1,'Operation Cyclone','CIA','Afghanistan','1979-07-03'); | SELECT agency, COUNT(*) FROM IntelOps WHERE start_date >= '2000-01-01' GROUP BY agency HAVING COUNT(*) > 0; |
What is the average monthly water usage per capita in Canada? | CREATE TABLE canada_water_usage (id INT,year INT,month TEXT,province TEXT,usage FLOAT); | SELECT AVG(usage) FROM canada_water_usage WHERE province = 'Canada' GROUP BY year, month; |
What is the average sale price of product B in the second quarter of 2022? | CREATE TABLE sales (product_id VARCHAR(255),sale_date DATE,sale_price DECIMAL(10,2)); INSERT INTO sales (product_id,sale_date,sale_price) VALUES ('B','2022-04-01',25.99),('A','2022-04-02',15.49); | SELECT AVG(sale_price) FROM sales WHERE product_id = 'B' AND QUARTER(sale_date) = 2 AND YEAR(sale_date) = 2022; |
What is the average home game attendance for the Lakers? | CREATE TABLE teams (team_id INT,team_name VARCHAR(255)); INSERT INTO teams (team_id,team_name) VALUES (1,'Lakers'); CREATE TABLE venues (venue_id INT,venue_name VARCHAR(255)); INSERT INTO venues (venue_id,venue_name) VALUES (1,'Staples Center'); CREATE TABLE games (game_id INT,team_id INT,venue_id INT,attendance INT); ... | SELECT AVG(games.attendance) FROM games INNER JOIN teams ON games.team_id = teams.team_id INNER JOIN venues ON games.venue_id = venues.venue_id WHERE teams.team_name = 'Lakers' AND venues.venue_name = 'Staples Center'; |
What is the average age of construction workers in Texas? | CREATE TABLE construction_workers (id INT,name VARCHAR(50),age INT,state VARCHAR(2)); INSERT INTO construction_workers (id,name,age,state) VALUES (1,'John Doe',35,'Texas'); INSERT INTO construction_workers (id,name,age,state) VALUES (2,'Jane Smith',40,'Texas'); | SELECT AVG(age) FROM construction_workers WHERE state = 'Texas'; |
What is the difference in population between 'animal_population' and 'endangered_species' tables for the same animal? | CREATE TABLE animal_population (id INT,animal_name VARCHAR(50),population INT); CREATE TABLE endangered_species (id INT,animal_name VARCHAR(50),population INT); | SELECT a.animal_name, a.population - e.population AS population_difference FROM animal_population a INNER JOIN endangered_species e ON a.animal_name = e.animal_name; |
How many auto shows were held in the United States in 2019? | CREATE TABLE Auto_Shows (Show_ID INT,Name VARCHAR(50),Location VARCHAR(50),Year INT); INSERT INTO Auto_Shows (Show_ID,Name,Location,Year) VALUES (1,'New York International Auto Show','New York',2018),(2,'Chicago Auto Show','Chicago',2019),(3,'Detroit Auto Show','Detroit',2019),(4,'Seattle Auto Show','Seattle',2018); | SELECT COUNT(*) FROM Auto_Shows WHERE Year = 2019 AND Location LIKE '%United States%'; |
How many impact investments were made by 'Eco Warriors' in 2021? | CREATE TABLE investments (id INT,investor VARCHAR(255),amount FLOAT,date DATE,impact BOOLEAN); INSERT INTO investments (id,investor,amount,date,impact) VALUES (5,'Eco Warriors',100000,'2021-06-01',TRUE); INSERT INTO investments (id,investor,amount,date,impact) VALUES (6,'Eco Warriors',120000,'2021-12-31',TRUE); | SELECT COUNT(*) FROM investments WHERE investor = 'Eco Warriors' AND impact = TRUE AND year(date) = 2021; |
What is the percentage of patients who identify as LGBTQ+ with a mental health disorder? | CREATE TABLE patients_demographics (patient_id INT,gender VARCHAR(50),mental_health_disorder BOOLEAN); INSERT INTO patients_demographics (patient_id,gender,mental_health_disorder) VALUES (1,'Male',true),(2,'Female',true),(3,'Non-binary',false),(4,'Transgender Male',true),(5,'Queer',false); | SELECT gender, mental_health_disorder, COUNT(*) as num_patients, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY gender) as percentage FROM patients_demographics GROUP BY gender, mental_health_disorder HAVING mental_health_disorder = true AND (gender = 'Transgender Male' OR gender = 'Queer'); |
What is the percentage of players who have completed a given achievement, broken down by platform? | CREATE TABLE GameAchievements (PlayerID INT,PlayerName TEXT,Platform TEXT,Achievement TEXT,Completed BOOLEAN); INSERT INTO GameAchievements (PlayerID,PlayerName,Platform,Achievement,Completed) VALUES (1,'Alice','PC','Achievement 1',TRUE),(2,'Bob','PC','Achievement 1',FALSE),(3,'Charlie','Console','Achievement 1',TRUE),... | SELECT Platform, (COUNT(*) FILTER (WHERE Completed = TRUE)) * 100.0 / COUNT(*) AS PercentageCompleted FROM GameAchievements GROUP BY Platform; |
Which textile suppliers prioritize sustainability? | CREATE TABLE TextileSuppliers (SupplierID INT,SupplierName TEXT,SustainabilityRating INT); INSERT INTO TextileSuppliers (SupplierID,SupplierName,SustainabilityRating) VALUES (1,'GreenFabrics',9),(2,'EcoWeave',8),(3,'StandardTextiles',5); | SELECT SupplierName FROM TextileSuppliers WHERE SustainabilityRating >= 8; |
List all reverse logistics transactions for 'ClientZ' with their corresponding statuses and dates. | CREATE TABLE Clients (ClientID VARCHAR(20),ClientName VARCHAR(20)); INSERT INTO Clients (ClientID,ClientName) VALUES ('A','ClientA'),('Z','ClientZ'); CREATE TABLE ReverseLogisticsTransactions (TransactionID INT,ClientID VARCHAR(20),TransactionStatus VARCHAR(20),TransactionDate DATE); INSERT INTO ReverseLogisticsTransac... | SELECT ReverseLogisticsTransactions.TransactionID, ReverseLogisticsTransactions.TransactionStatus, ReverseLogisticsTransactions.TransactionDate FROM Clients JOIN ReverseLogisticsTransactions ON Clients.ClientID = ReverseLogisticsTransactions.ClientID WHERE Clients.ClientName = 'ClientZ'; |
What is the budget allocated for education services in 'Colorado' and 'Utah'? | CREATE TABLE budget (state VARCHAR(20),service VARCHAR(20),amount INT); INSERT INTO budget (state,service,amount) VALUES ('Colorado','Education',40000),('Colorado','Healthcare',60000),('Colorado','Transportation',30000),('Utah','Healthcare',50000),('Utah','Education',70000),('Utah','Transportation',20000); | SELECT amount FROM budget WHERE state IN ('Colorado', 'Utah') AND service = 'Education'; |
Show the national security events with their corresponding severity levels, and calculate the average severity level. | CREATE TABLE national_security_events (id INT,event VARCHAR,severity INT); INSERT INTO national_security_events (id,event,severity) VALUES (1,'Terrorist Attack',8),(2,'Cyber Espionage',5),(3,'Nuclear Missile Test',10); | SELECT event, severity, AVG(severity) OVER () as avg_severity FROM national_security_events; |
What is the maximum mobile data usage for customers in the 'mountain' region for the year 2021? | CREATE TABLE subscribers (id INT,region VARCHAR(10)); CREATE TABLE usage (subscriber_id INT,usage_date DATE,monthly_data_usage INT); INSERT INTO subscribers (id,region) VALUES (1,'mountain'),(2,'mountain'),(3,'coastal'); INSERT INTO usage (subscriber_id,usage_date,monthly_data_usage) VALUES (1,'2021-01-01',2000),(1,'20... | SELECT MAX(monthly_data_usage) FROM usage JOIN subscribers ON usage.subscriber_id = subscribers.id WHERE subscribers.region = 'mountain' AND EXTRACT(YEAR FROM usage_date) = 2021; |
Which countries have military technologies associated with 'AI' in the 'country_tech' view? | CREATE TABLE countries (country VARCHAR(255)); INSERT INTO countries (country) VALUES ('Russia'),('China'),('France'),('Israel'); CREATE TABLE military_tech (tech VARCHAR(255)); INSERT INTO military_tech (tech) VALUES ('UAV'),('cyber_defense'),('AI'),('laser_weapon'),('stealth'); CREATE VIEW country_tech AS SELECT c.co... | SELECT DISTINCT country FROM country_tech WHERE tech = 'AI'; |
What is the average revenue of movies released in the USA? | CREATE TABLE movies (id INT,title VARCHAR(100),genre VARCHAR(50),release_year INT,revenue INT,country VARCHAR(50)); INSERT INTO movies (id,title,genre,release_year,revenue,country) VALUES (1,'Movie1','Comedy',2020,5000000,'USA'); INSERT INTO movies (id,title,genre,release_year,revenue,country) VALUES (2,'Movie2','Actio... | SELECT AVG(revenue) FROM movies WHERE country = 'USA'; |
Update the amount of investment with id 2 in the table 'impact_investments' to 2200000. | CREATE TABLE impact_investments (id INT,country VARCHAR(255),amount FLOAT,strategy_id INT); INSERT INTO impact_investments (id,country,amount,strategy_id) VALUES (1,'Brazil',1000000,2),(2,'Brazil',2000000,3); | UPDATE impact_investments SET amount = 2200000 WHERE id = 2; |
What is the average transaction amount for customers in the West region in the first quarter of 2022? | CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_date DATE,transaction_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id,customer_id,transaction_date,transaction_amount) VALUES (11,2,'2022-03-05',350.00),(12,1,'2022-03-10',500.00),(13,4,'2022-03-15',600.00),(14,4,'2022-03-30',800.... | SELECT AVG(transaction_amount) FROM transactions WHERE customer_id IN (SELECT customer_id FROM customers WHERE region = 'West') AND transaction_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the maximum number of songs in an album and album name for albums in the Jazz genre? | CREATE TABLE albums (id INT,name TEXT,genre TEXT,songs INT); INSERT INTO albums (id,name,genre,songs) VALUES (1,'Album1','Jazz',12),(2,'Album2','Pop',10),(3,'Album3','Jazz',8); | SELECT MAX(songs), name FROM albums WHERE genre = 'Jazz'; |
Calculate the total cost of accommodations for students with visual impairments in the "accommodations" table | CREATE TABLE accommodations (id INT,student_id INT,accommodation_type VARCHAR(255),cost FLOAT); INSERT INTO accommodations (id,student_id,accommodation_type,cost) VALUES (1,123,'visual_aids',250.0),(2,456,'audio_aids',100.0),(3,789,'large_print_materials',120.0),(4,890,'mobility_aids',300.0); | SELECT SUM(cost) FROM accommodations WHERE accommodation_type = 'visual_aids'; |
What is the total water consumption for the state of California in the last quarter? | CREATE TABLE MonthlyWaterUsage (Month DATE,State VARCHAR(20),Usage FLOAT); INSERT INTO MonthlyWaterUsage (Month,State,Usage) VALUES ('2022-01-01','California',2500),('2022-02-01','California',3000),('2022-03-01','California',3500); | SELECT SUM(Usage) FROM MonthlyWaterUsage WHERE State = 'California' AND Month >= DATEADD(QUARTER, -1, GETDATE()); |
Insert a new record into the "union_members" table with the following values: 4, "Sara Rodriguez", "CA", "active" | CREATE TABLE union_members (member_id INT,name VARCHAR(50),state VARCHAR(2),membership_status VARCHAR(10)); | INSERT INTO union_members (member_id, name, state, membership_status) VALUES (4, 'Sara Rodriguez', 'CA', 'active'); |
What is the average number of water purification systems installed per province in Somalia? | CREATE TABLE water_purification (id INT,province VARCHAR(255),system_count INT); INSERT INTO water_purification (id,province,system_count) VALUES (1,'Province 1',2),(2,'Province 2',3),(3,'Province 1',4); | SELECT province, AVG(system_count) FROM water_purification GROUP BY province; |
What is the average duration of yoga workouts in minutes for members who joined in 2020? | CREATE TABLE workout_data (member_id INT,workout_type VARCHAR(50),duration INT,workout_date DATE); INSERT INTO workout_data (member_id,workout_type,duration,workout_date) VALUES (1,'yoga',60,'2021-01-15'),(2,'cycling',90,'2022-03-28'); | SELECT AVG(duration) FROM workout_data JOIN members ON workout_data.member_id = members.member_id WHERE members.join_date >= '2020-01-01' AND members.join_date < '2021-01-01' AND workout_type = 'yoga'; |
What is the maximum severity of vulnerabilities for each category? | CREATE TABLE CategoryVulnerabilities (id INT,category VARCHAR(255),severity INT); INSERT INTO CategoryVulnerabilities (id,category,severity) VALUES (1,'Network',7),(2,'Application',9),(3,'Network',5); | SELECT CategoryVulnerabilities.category AS Category, MAX(CategoryVulnerabilities.severity) AS Max_Severity FROM CategoryVulnerabilities GROUP BY CategoryVulnerabilities.category; |
What are the total sales of pop and rock genres combined, for all platforms? | CREATE TABLE sales (sale_id INT,genre VARCHAR(10),platform VARCHAR(10),sales FLOAT); | SELECT SUM(sales) FROM sales WHERE genre IN ('pop', 'rock'); |
List the names and locations of Europium producers that started production after 2015. | CREATE TABLE europium_production (producer_id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),start_year INT); | SELECT name, location FROM europium_production WHERE start_year > 2015; |
Insert a new record into the 'carbon_offset_programs' table for a program initiated by 'GreenCorp' in 2022 with a budget of $100,000 | CREATE TABLE carbon_offset_programs (id INT,initiator VARCHAR(255),initiated_year INT,budget FLOAT); | INSERT INTO carbon_offset_programs (id, initiator, initiated_year, budget) VALUES (1, 'GreenCorp', 2022, 100000); |
What is the total quantity of chemical A produced per month in 2020? | CREATE TABLE chemical_production (date DATE,chemical VARCHAR(20),quantity INT); INSERT INTO chemical_production (date,chemical,quantity) VALUES ('2020-01-01','chemical A',500); INSERT INTO chemical_production (date,chemical,quantity) VALUES ('2020-02-01','chemical A',700); | SELECT date_format(date, '%Y-%m') as month, sum(quantity) as total_quantity FROM chemical_production WHERE chemical = 'chemical A' AND date >= '2020-01-01' AND date < '2021-01-01' GROUP BY month; |
What are the names and launch dates of satellites manufactured by SpaceTech Inc.? | CREATE TABLE Satellites (satellite_id INT,name VARCHAR(50),manufacturer VARCHAR(50),launch_date DATE); INSERT INTO Satellites (satellite_id,name,manufacturer,launch_date) VALUES (1,'Sat1','SpaceTech Inc.','2020-01-01'); | SELECT name, launch_date FROM Satellites WHERE manufacturer = 'SpaceTech Inc.' |
What is the total number of military equipment items that are currently in stock? | CREATE TABLE inventory (id INT,quantity INT); INSERT INTO inventory (id,quantity) VALUES (1,100),(2,50),(3,150); | SELECT SUM(quantity) as total_quantity FROM inventory WHERE id IS NOT NULL; |
What is the maximum number of charging stations in operation in Berlin, Paris, and Rome? | CREATE TABLE charging_stations (station_id INT,city VARCHAR(20),in_operation BOOLEAN); INSERT INTO charging_stations (station_id,city,in_operation) VALUES (1,'Berlin',TRUE),(2,'Berlin',TRUE),(3,'Berlin',FALSE),(4,'Paris',TRUE),(5,'Paris',TRUE),(6,'Rome',TRUE),(7,'Rome',FALSE),(8,'Rome',TRUE); | SELECT city, MAX(station_id) FROM charging_stations WHERE in_operation = TRUE GROUP BY city; |
What is the total grant amount awarded to graduate students in the 'Arts' department? | CREATE TABLE grant_amounts_total (id INT,student_id INT,amount DECIMAL(10,2)); INSERT INTO grant_amounts_total (id,student_id,amount) VALUES (1,1,50000.00),(2,2,30000.00),(3,3,40000.00); | SELECT SUM(amount) FROM grant_amounts_total WHERE student_id IN (SELECT id FROM graduate_students WHERE department = 'Arts'); |
Which manufacturers have more than 50% of their fleet be electric vehicles? | CREATE TABLE Manufacturers (Manufacturer_ID INT,Name VARCHAR(50)); INSERT INTO Manufacturers (Manufacturer_ID,Name) VALUES (1,'Tesla'),(2,'Chevrolet'),(3,'Nissan'); CREATE TABLE Vehicles (Vehicle_ID INT,Manufacturer_ID INT,Electric BOOLEAN); INSERT INTO Vehicles (Vehicle_ID,Manufacturer_ID,Electric) VALUES (1,1,TRUE),(... | SELECT Name FROM Manufacturers WHERE (SELECT COUNT(*) FROM Vehicles WHERE Manufacturer_ID = Manufacturers.Manufacturer_ID AND Electric = TRUE) > (SELECT COUNT(*) FROM Vehicles WHERE Manufacturer_ID = Manufacturers.Manufacturer_ID) * 0.5; |
What is the sum of advertising spend by users in the "technology" industry, for the last quarter? | CREATE TABLE users (id INT,industry VARCHAR(255)); CREATE TABLE ads (id INT,user_id INT,spend DECIMAL(10,2),ad_date DATE); INSERT INTO users (id,industry) VALUES (1,'technology'); INSERT INTO ads (id,user_id,spend,ad_date) VALUES (1,1,500,'2022-03-15'); | SELECT SUM(ads.spend) AS total_spend FROM ads JOIN users ON ads.user_id = users.id WHERE users.industry = 'technology' AND ads.ad_date >= DATE_TRUNC('quarter', NOW()) - INTERVAL '3 months'; |
What is the maximum number of therapy sessions attended by a patient in Oregon? | CREATE TABLE therapy_attendance (patient_id INT,sessions_attended INT,location VARCHAR(50)); INSERT INTO therapy_attendance (patient_id,sessions_attended,location) VALUES (1,12,'Oregon'),(2,10,'Washington'),(3,15,'Oregon'),(4,8,'California'),(5,20,'Oregon'); | SELECT location, MAX(sessions_attended) FROM therapy_attendance GROUP BY location; |
List all the agroecology projects in Africa that have a budget greater than the average budget for agroecology projects in Africa. | CREATE TABLE AgroecologyProject (id INT,location VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO AgroecologyProject (id,location,budget) VALUES (1,'Kenya',50000.0); INSERT INTO AgroecologyProject (id,location,budget) VALUES (2,'Nigeria',75000.0); | SELECT * FROM AgroecologyProject WHERE budget > (SELECT AVG(budget) FROM AgroecologyProject WHERE location = 'Africa'); |
What is the minimum number of hours of training per astronaut per year? | CREATE TABLE Astronaut_Training (ID INT,Astronaut VARCHAR(50),Year INT,Hours_Of_Training INT); INSERT INTO Astronaut_Training (ID,Astronaut,Year,Hours_Of_Training) VALUES (1,'Rakesh Sharma',2015,100),(2,'Wang Yaping',2015,120),(3,'Kalpana Chawla',2016,150),(4,'Yi So-yeon',2016,130),(5,'Pham Tuan',2017,110); | SELECT Astronaut, MIN(Hours_Of_Training) FROM Astronaut_Training GROUP BY Astronaut; |
What was the minimum sustainability score for factories in region "Asia" in 2020? | CREATE TABLE factory_data (factory_id INT,region VARCHAR(20),sustainability_score FLOAT,year INT); INSERT INTO factory_data (factory_id,region,sustainability_score,year) VALUES (1,'Asia',80,2020),(2,'Asia',85,2020),(3,'Asia',90,2020); | SELECT MIN(sustainability_score) FROM factory_data WHERE region = 'Asia' AND year = 2020; |
List all community education programs with their 'program_id' and related animal species. | CREATE TABLE community_education (program_id INT,program_name VARCHAR(255),animals_covered VARCHAR(255)); INSERT INTO community_education (program_id,program_name,animals_covered) VALUES (1,'Monkey Mayhem','Capuchin,Squirrel,Howler'),(2,'Rainforest Rangers','Spider,Toucan,Jaguar'); | SELECT program_id, program_name, TRIM(SPLIT_PART(animals_covered, ',', n)) as species FROM community_education CROSS JOIN generate_series(1, ARRAY_LENGTH(string_to_array(animals_covered, ','))) as n; |
Insert a new marine research station in the Arctic ocean with the name "Station C" and depth 4500 meters. | CREATE TABLE marine_life_research_stations (id INT,name TEXT,location TEXT,depth FLOAT); | INSERT INTO marine_life_research_stations (id, name, location, depth) VALUES (3, 'Station C', 'Arctic', 4500); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.