instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Update the jersey numbers of athletes who have changed their jersey numbers in the last month. | CREATE TABLE JerseyChanges (ChangeID INT,AthleteID INT,OldJerseyNumber INT,NewJerseyNumber INT,ChangeDate DATE); | UPDATE Athletes SET JerseyNumber = jc.NewJerseyNumber FROM Athletes a JOIN JerseyChanges jc ON a.AthleteID = jc.AthleteID WHERE jc.ChangeDate > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
What is the total number of marine species that have been observed in each ocean basin, based on the most recent data?" | CREATE TABLE marine_species_observations (species_name VARCHAR(255),ocean_basin VARCHAR(255),last_observed_date DATE); INSERT INTO marine_species_observations (species_name,ocean_basin,last_observed_date) VALUES ('Great White Shark','Atlantic Basin','2021-08-01'),('Blue Whale','Pacific Basin','2021-07-15'),('Green Sea ... | SELECT ocean_basin, COUNT(DISTINCT species_name) as species_count FROM marine_species_observations WHERE last_observed_date = (SELECT MAX(last_observed_date) FROM marine_species_observations) GROUP BY ocean_basin; |
List the top 3 deepest oceanic trenches in the world. | CREATE TABLE Oceanic_Trenches (trench_name TEXT,location TEXT,max_depth NUMERIC); INSERT INTO Oceanic_Trenches (trench_name,location,max_depth) VALUES ('Mariana Trench','Western Pacific Ocean',36070),('Tonga Trench','Southern Pacific Ocean',35713),('Kermadec Trench','Southern Pacific Ocean',32934),('Sunda Trench','Sout... | SELECT trench_name, location, max_depth FROM (SELECT trench_name, location, max_depth, ROW_NUMBER() OVER (ORDER BY max_depth DESC) as rn FROM Oceanic_Trenches) x WHERE rn <= 3; |
How many female and male reporters are there in the 'reporters' table? | CREATE TABLE reporters (id INT,gender VARCHAR(255),salary DECIMAL(10,2)); INSERT INTO reporters (id,gender,salary) VALUES (1,'Female',80000.00),(2,'Male',70000.00),(3,'Female',75000.00),(4,'Non-binary',85000.00) | SELECT gender, COUNT(*) FROM reporters GROUP BY gender; |
What is the total construction cost for dams in Washington state? | CREATE TABLE Dam (id INT,name VARCHAR(50),construction_cost FLOAT,state VARCHAR(50)); INSERT INTO Dam (id,name,construction_cost,state) VALUES (1,'Grand Coulee Dam',134000000,'Washington'); | SELECT SUM(construction_cost) FROM Dam WHERE state = 'Washington' AND type = 'Dam'; |
What is the total number of infectious disease cases reported in Boston in 2022? | CREATE TABLE Years (YearID INT,Age INT,Gender VARCHAR(10),City VARCHAR(20),Disease VARCHAR(20),Year INT); INSERT INTO Years (YearID,Age,Gender,City,Disease,Year) VALUES (1,30,'Male','Boston','Cholera',2022); | SELECT COUNT(*) FROM Years WHERE City = 'Boston' AND Year = 2022 AND Disease IN ('Cholera', 'Tuberculosis', 'Measles', 'Influenza'); |
What is the average temperature reading for all IoT sensors in the 'fields' table? | CREATE TABLE fields (id INT,sensor_id INT,temperature DECIMAL(5,2)); INSERT INTO fields (id,sensor_id,temperature) VALUES (1,101,23.5),(2,102,25.7),(3,103,21.8); | SELECT AVG(temperature) FROM fields; |
What is the average transaction amount for each customer-region pair in January? | CREATE TABLE Transactions (id INT,customer_id INT,region VARCHAR(10),transaction_date DATE); INSERT INTO Transactions (id,customer_id,region,transaction_date) VALUES (1,10,'Europe','2022-01-01'),(2,10,'Asia','2022-02-01'),(3,11,'Asia','2022-03-01'),(4,12,'Europe','2022-01-05'),(5,13,'Asia','2022-01-10'),(6,14,'Asia','2... | SELECT customer_id, region, AVG(amount) as avg_amount FROM Transactions JOIN Transaction_Amounts ON Transactions.id = Transaction_Amounts.transaction_id WHERE EXTRACT(MONTH FROM transaction_date) = 1 GROUP BY customer_id, region; |
Delete all hotels in the "budget" hotel category | CREATE TABLE hotels (hotel_id INT,hotel_name VARCHAR(50),city VARCHAR(50),category VARCHAR(50)); | DELETE FROM hotels WHERE category = 'budget'; |
What are the types of military aircraft owned by the Israeli government? | CREATE TABLE MilitaryAircraft (ID INT,Country VARCHAR(20),Type VARCHAR(20)); INSERT INTO MilitaryAircraft (ID,Country,Type) VALUES (1,'Israel','Helicopter'); | SELECT Type FROM MilitaryAircraft WHERE Country = 'Israel'; |
Delete records in the military_equipment table where the 'equipment_type' is 'Ground Vehicle' and 'last_maintenance_date' is older than 2018-01-01 | CREATE TABLE military_equipment (equipment_id INT,equipment_type VARCHAR(50),last_maintenance_date DATE); | DELETE FROM military_equipment WHERE equipment_type = 'Ground Vehicle' AND last_maintenance_date < '2018-01-01'; |
What is the total number of articles published in Spanish in 2020? | CREATE TABLE Articles (id INT,title VARCHAR(255),publisher VARCHAR(100),publication_year INT,language VARCHAR(50),topic VARCHAR(50)); INSERT INTO Articles (id,title,publisher,publication_year,language,topic) VALUES (1,'Article1','El País',2020,'Spanish','Politics'),(2,'Article2','The Washington Post',2019,'English','Po... | SELECT SUM(1) FROM Articles WHERE language = 'Spanish' AND publication_year = 2020; |
Insert data into workforce_training for employee 'Aaliyah Jackson' who completed 10 hours of ethics training on '2022-06-15' | CREATE TABLE workforce_training (id INT PRIMARY KEY,employee_name VARCHAR(255),training_topic VARCHAR(255),training_hours INT,training_completion_date DATE); | INSERT INTO workforce_training (id, employee_name, training_topic, training_hours, training_completion_date) VALUES (1, 'Aaliyah Jackson', 'ethics', 10, '2022-06-15'); |
What is the minimum age of male elephants in the "elephants" table? | CREATE TABLE elephants (id INT,name VARCHAR(20),species VARCHAR(20),age INT,gender VARCHAR(10)); INSERT INTO elephants (id,name,species,age,gender) VALUES (1,'Dumbo','Elephant',15,'Male'); INSERT INTO elephants (id,name,species,age,gender) VALUES (2,'Babar','Elephant',20,'Male'); | SELECT MIN(age) FROM elephants WHERE gender = 'Male' AND species = 'Elephant'; |
What is the average water consumption per manufacturing process, partitioned by month and supplier, and ordered by the average water consumption? | CREATE TABLE water_consumption (consumption_id INT,process_id INT,supplier_id INT,consumption_date DATE,water_consumption INT); INSERT INTO water_consumption (consumption_id,process_id,supplier_id,consumption_date,water_consumption) VALUES (1,1,1,'2022-02-01',500),(2,1,2,'2022-02-05',600); | SELECT process_id, supplier_id, DATE_TRUNC('month', consumption_date) AS month, AVG(water_consumption) AS avg_water_consumption, RANK() OVER (PARTITION BY process_id, supplier_id ORDER BY AVG(water_consumption) DESC) AS ranking FROM water_consumption GROUP BY process_id, supplier_id, month ORDER BY avg_water_consumptio... |
Which countries have the most artists in the 'international_artists' table? | CREATE TABLE international_artists (id INT,country VARCHAR(20)); INSERT INTO international_artists (id,country) VALUES (1,'France'),(2,'Germany'),(3,'Japan'),(4,'Italy'),(5,'France'),(6,'Germany'); | SELECT country, COUNT(*) FROM international_artists GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1; |
What is the total amount of climate finance committed to energy efficiency projects in North America? | CREATE TABLE climate_finance (project_name VARCHAR(255),region VARCHAR(255),sector VARCHAR(255),amount DECIMAL(10,2)); INSERT INTO climate_finance (project_name,region,sector,amount) VALUES ('Insulation Program','North America','Energy Efficiency',3000000.00); INSERT INTO climate_finance (project_name,region,sector,amo... | SELECT SUM(amount) FROM climate_finance WHERE region = 'North America' AND sector = 'Energy Efficiency'; |
What is the earliest date a 'funicular' station was cleaned? | CREATE TABLE public.cleaning (cleaning_id SERIAL PRIMARY KEY,cleaning_type VARCHAR(20),cleaning_date DATE,station_id INTEGER,FOREIGN KEY (station_id) REFERENCES public.station(station_id)); INSERT INTO public.cleaning (cleaning_type,cleaning_date,station_id) VALUES ('routine cleaning','2022-06-03',1),('deep cleaning','... | SELECT MIN(cleaning_date) FROM public.cleaning INNER JOIN public.station ON public.cleaning.station_id = public.station.station_id WHERE route_type = 'funicular' |
What is the maximum number of wins achieved by players from Asia who have played "Virtual Combat" and have more than 10 hours of playtime? | CREATE TABLE Players (PlayerID INT,PlayerRegion VARCHAR(10),Wins INT,GameName VARCHAR(20),Playtime INT); INSERT INTO Players (PlayerID,PlayerRegion,Wins,GameName,Playtime) VALUES (1,'Asia',25,'Virtual Combat',20),(2,'Europe',20,'Virtual Combat',30),(3,'Asia',30,'Virtual Combat',15); | SELECT MAX(Wins) FROM Players WHERE PlayerRegion = 'Asia' AND GameName = 'Virtual Combat' AND Playtime > 10; |
Who is the leading scorer for the 'hockey_teams' table? | CREATE TABLE hockey_teams (team_id INT,name VARCHAR(50)); CREATE TABLE hockey_players (player_id INT,name VARCHAR(50),team_id INT,goals INT,assists INT); INSERT INTO hockey_teams (team_id,name) VALUES (1,'Toronto Maple Leafs'),(2,'Montreal Canadiens'); INSERT INTO hockey_players (player_id,name,team_id,goals,assists) V... | SELECT name AS leading_scorer FROM ( SELECT player_id, name, (goals + assists) AS total_points, team_id FROM hockey_players ) AS subquery WHERE total_points = (SELECT MAX(total_points) FROM subquery) LIMIT 1; |
How many hotels are there in each category, grouped by the continent of the hotel location? | CREATE TABLE hotels (hotel_id INT,name TEXT,category TEXT,location TEXT); INSERT INTO hotels (hotel_id,name,category,location) VALUES (1,'Hotel A','Boutique','North America'),(2,'Hotel B','Luxury','Europe'),(3,'Hotel C','City','Asia'),(4,'Hotel D','Boutique','Africa'); | SELECT category, SUBSTRING(location, 1, INSTR(location, ' ') - 1) AS continent, COUNT(*) FROM hotels GROUP BY category, continent; |
How many military bases are there in total for each country, ordered by the number of bases in descending order? | CREATE TABLE BasesByCountry (Country varchar(50),BaseID int); INSERT INTO BasesByCountry (Country,BaseID) VALUES ('USA',1),('USA',2),('UK',3),('Iraq',4),('Iraq',5); | SELECT Country, COUNT(*) as TotalBases FROM BasesByCountry GROUP BY Country ORDER BY TotalBases DESC; |
What is the percentage of hotels in London, UK that have adopted AI technology? | CREATE TABLE hotel_tech_adoptions (id INT,hotel_id INT,tech_type TEXT,installed_date DATE); CREATE TABLE hotels (id INT,name TEXT,city TEXT,country TEXT,has_ai_tech BOOLEAN); | SELECT 100.0 * COUNT(hta.hotel_id) / (SELECT COUNT(*) FROM hotels WHERE city = 'London' AND country = 'UK') FROM hotel_tech_adoptions hta INNER JOIN hotels h ON hta.hotel_id = h.id WHERE h.city = 'London' AND h.country = 'UK' AND tech_type = 'AI'; |
What is the total number of garments produced using fair labor practices, by year? | CREATE TABLE FairLaborGarments (id INT,year INT,num_garments INT); | SELECT year, SUM(num_garments) as total_garments FROM FairLaborGarments GROUP BY year; |
Which minerals were extracted in quantities greater than 1000 tons by companies that have mining operations in South America? | CREATE TABLE company (id INT,name VARCHAR(255),country VARCHAR(255));CREATE TABLE extraction (company_id INT,mineral VARCHAR(255),amount INT); | SELECT DISTINCT e.mineral FROM extraction e JOIN company c ON e.company_id = c.id WHERE c.country LIKE '%South America%' AND e.amount > 1000; |
Identify vessels in the 'vessel_registry' table that have not had a safety inspection in the past 2 years | CREATE TABLE vessel_registry (id INT,vessel_name VARCHAR(50),last_safety_inspection DATE); | SELECT vessel_name FROM vessel_registry WHERE DATEDIFF(day, last_safety_inspection, GETDATE()) > 730; |
How many bioprocess engineers are there in India working on gene editing? | CREATE TABLE bioprocess_engineers (id INT,name TEXT,age INT,gender TEXT,country TEXT,specialization TEXT); INSERT INTO bioprocess_engineers (id,name,age,gender,country,specialization) VALUES (1,'Rajesh',32,'Male','India','Gene Editing'); | SELECT COUNT(*) FROM bioprocess_engineers WHERE country = 'India' AND specialization = 'Gene Editing'; |
Update cerium production records from 2021 to reflect a 10% decrease | CREATE TABLE production (id INT,element VARCHAR(10),year INT,quantity INT); INSERT INTO production (id,element,year,quantity) VALUES (1,'cerium',2018,500),(2,'cerium',2019,600),(3,'cerium',2020,700),(4,'cerium',2021,800); | UPDATE production SET quantity = quantity * 0.9 WHERE element = 'cerium' AND year = 2021; |
List the top 3 veteran unemployment rates by state in 2021. | CREATE TABLE VeteranEmployment (State TEXT,Year INT,UnemploymentRate DECIMAL(3,2)); INSERT INTO VeteranEmployment (State,Year,UnemploymentRate) VALUES ('California',2021,0.06),('Texas',2021,0.04),('New York',2021,0.05),('Florida',2021,0.035),('Illinois',2021,0.045); | SELECT State, UnemploymentRate FROM VeteranEmployment WHERE Year = 2021 ORDER BY UnemploymentRate DESC LIMIT 3; |
What is the total quantity of eco-friendly materials in the 'inventory' table? | CREATE TABLE inventory (id INT,material VARCHAR(20),quantity INT); INSERT INTO inventory (id,material,quantity) VALUES (1,'cotton',25),(2,'organic_silk',30),(3,'recycled_polyester',40); | SELECT SUM(quantity) FROM inventory WHERE material IN ('cotton', 'organic_silk', 'recycled_polyester'); |
Which decentralized applications are built on the Polygon network and have more than 1000 users? | CREATE TABLE dapps (dapp_id INT,name VARCHAR(100),network VARCHAR(100),users INT); INSERT INTO dapps (dapp_id,name,network,users) VALUES (1,'Dapp1','Polygon',1500),(2,'Dapp2','Polygon',800),(3,'Dapp3','Polygon',1200),(4,'Dapp4','Ethereum',200),(5,'Dapp5','Binance Smart Chain',1600); | SELECT name FROM dapps WHERE network = 'Polygon' AND users > 1000; |
What is the most recent login time for each user in the 'security_logs' table? | CREATE TABLE security_logs (user_id INT,login_time TIMESTAMP); INSERT INTO security_logs (user_id,login_time) VALUES (1,'2022-01-01 10:00:00'),(2,'2022-01-01 11:00:00'),(1,'2022-01-01 12:00:00'); | SELECT user_id, MAX(login_time) OVER (PARTITION BY user_id) AS recent_login_time FROM security_logs; |
Which allergens are present in dishes at 'The Green Kitchen'? | CREATE TABLE MenuItem (id INT,restaurant_id INT,name VARCHAR(50),category VARCHAR(50),price DECIMAL(5,2)); INSERT INTO MenuItem (id,restaurant_id,name,category,price) VALUES (1,1,'Quinoa Salad','Salads',12.99); INSERT INTO MenuItem (id,restaurant_id,name,category,price) VALUES (2,1,'Tofu Stir Fry','Entrees',15.99); INS... | SELECT Allergen.allergen FROM Allergen INNER JOIN MenuItem ON Allergen.menu_item_id = MenuItem.id WHERE MenuItem.restaurant_id = (SELECT id FROM Restaurant WHERE name = 'The Green Kitchen'); |
What is the maximum number of workplace safety violations in a single year for any company? | CREATE TABLE companies (id INT,safety_violations INT); INSERT INTO companies (id,safety_violations) VALUES (1,10),(2,5),(3,15),(4,0),(5,20); | SELECT MAX(safety_violations) FROM companies; |
How many sustainable fabric types are sourced from each country in 2022? | CREATE TABLE sourcing (year INT,country VARCHAR(20),fabric_type VARCHAR(20),quantity INT); INSERT INTO sourcing (year,country,fabric_type,quantity) VALUES (2022,'India','sustainable',3000),(2022,'India','organic_cotton',5000),(2022,'Brazil','recycled_polyester',4000),(2022,'Brazil','sustainable',6000); | SELECT country, COUNT(DISTINCT fabric_type) as num_sustainable_types FROM sourcing WHERE year = 2022 AND fabric_type LIKE 'sustainable%' GROUP BY country; |
List all train routes and their respective weekly maintenance costs in the 'nyc' schema. | CREATE TABLE nyc.train_routes (id INT,route_number INT,length DECIMAL); CREATE TABLE nyc.train_maintenance (id INT,route_number INT,weekly_cost DECIMAL); | SELECT nyc.train_routes.route_number, nyc.train_maintenance.weekly_cost FROM nyc.train_routes INNER JOIN nyc.train_maintenance ON nyc.train_routes.route_number = nyc.train_maintenance.route_number; |
How many students with visual impairments are enrolled in STEM majors in North America? | CREATE TABLE Students (Id INT,Name VARCHAR(50),DisabilityType VARCHAR(30),Major VARCHAR(50),Region VARCHAR(30)); INSERT INTO Students (Id,Name,DisabilityType,Major,Region) VALUES (1,'Jacob Brown','Visual Impairment','Computer Science','North America'),(2,'Emily Davis','Learning Disability','Physics','North America'),(3... | SELECT COUNT(*) FROM Students WHERE DisabilityType = 'Visual Impairment' AND Major LIKE 'STEM%' AND Region = 'North America'; |
What was the total number of public meetings in Canada in 2021? | CREATE TABLE canada_provinces (id INT PRIMARY KEY,province VARCHAR(20)); INSERT INTO canada_provinces (id,province) VALUES (1,'Ontario'); INSERT INTO canada_provinces (id,province) VALUES (2,'Quebec'); INSERT INTO meetings (id,province,year,num_participants) VALUES (1,'Ontario',2021,35); INSERT INTO meetings (id,provin... | SELECT SUM(num_participants) FROM meetings INNER JOIN canada_provinces ON meetings.province = canada_provinces.province WHERE canada_provinces.year = 2021; |
What is the maximum distance from the earth for each space mission? | CREATE TABLE space_missions (id INT,mission VARCHAR,max_distance FLOAT); | SELECT mission, MAX(max_distance) as max_distance FROM space_missions GROUP BY mission; |
What is the minimum runtime for any movie from India? | CREATE TABLE movies (id INT,title VARCHAR(255),runtime INT,production_country VARCHAR(64)); INSERT INTO movies (id,title,runtime,production_country) VALUES (1,'MovieA',90,'India'),(2,'MovieB',120,'Italy'),(3,'MovieC',135,'France'); | SELECT MIN(runtime) FROM movies WHERE production_country = 'India'; |
How many policies are there for each risk assessment model? | CREATE TABLE Policies (ID INT,RiskAssessmentModel VARCHAR(50)); INSERT INTO Policies (ID,RiskAssessmentModel) VALUES (1,'Standard'),(2,'Premium'),(3,'Standard'),(4,'Basic'); CREATE TABLE RiskAssessmentModels (ID INT,ModelName VARCHAR(50)); INSERT INTO RiskAssessmentModels (ID,ModelName) VALUES (1,'Standard'),(2,'Premiu... | SELECT RiskAssessmentModel, COUNT(*) FROM Policies GROUP BY RiskAssessmentModel; |
What is the maximum temperature recorded in the Arctic and Antarctic regions, and which region had the lowest maximum temperature? | CREATE TABLE ClimateChange (id INT,location VARCHAR(50),temperature FLOAT,year INT,region VARCHAR(50)); INSERT INTO ClimateChange (id,location,temperature,year,region) VALUES (1,'Arctic',-10.5,2010,'Arctic'); INSERT INTO ClimateChange (id,location,temperature,year,region) VALUES (2,'Antarctic',-5.0,2011,'Antarctic'); | SELECT region, MAX(temperature) FROM ClimateChange GROUP BY region HAVING MAX(temperature) = (SELECT MAX(temperature) FROM ClimateChange); |
What is the minimum and maximum depth of all marine protected areas in the Atlantic ocean? | CREATE TABLE marine_protected_areas (area_name TEXT,ocean TEXT,avg_depth REAL); | SELECT MIN(avg_depth), MAX(avg_depth) FROM marine_protected_areas WHERE ocean = 'Atlantic'; |
Insert a new reverse logistics record for item with ID 111 | CREATE TABLE reverse_logistics (id INT,item_id INT,quantity INT); | INSERT INTO reverse_logistics (id, item_id, quantity) VALUES (4, 111, 4); |
What is the total volume of timber produced in the last 5 years in Russia? | CREATE TABLE timber_production (id INT,volume REAL,year INT,country TEXT); | SELECT SUM(volume) FROM timber_production WHERE country = 'Russia' AND year BETWEEN 2017 AND 2021; |
List all defense diplomacy events in Africa in 2017. | CREATE TABLE defense_diplomacy (event_id INT,event_name VARCHAR(255),region VARCHAR(255),date DATE); INSERT INTO defense_diplomacy (event_id,event_name,region,date) VALUES (1,'Event A','Africa','2017-01-01'),(2,'Event B','Africa','2017-12-31'); CREATE TABLE regions (region VARCHAR(255)); | SELECT event_name FROM defense_diplomacy INNER JOIN regions ON defense_diplomacy.region = regions.region WHERE region = 'Africa' AND date >= '2017-01-01' AND date <= '2017-12-31'; |
List all safety issues for products certified as cruelty-free. | CREATE TABLE products(id INT,name TEXT,cruelty_free BOOLEAN,safety_issue TEXT); INSERT INTO products(id,name,cruelty_free,safety_issue) VALUES (1,'Cleanser X',true,'microplastic use'),(2,'Lotion Y',false,'paraben content'),(3,'Shampoo Z',true,'none'),(4,'Conditioner W',false,'formaldehyde content'),(5,'Moisturizer V',t... | SELECT name, safety_issue FROM products WHERE cruelty_free = true AND safety_issue IS NOT NULL; |
Show the number of companies that have received funding in each city | CREATE TABLE companies (company_id INT,company_name VARCHAR(255),city VARCHAR(255));CREATE TABLE funding_rounds (funding_round_id INT,company_id INT,funding_amount INT,city VARCHAR(255)); | SELECT c.city, COUNT(c.company_id) FROM companies c INNER JOIN funding_rounds fr ON c.company_id = fr.company_id GROUP BY c.city; |
Insert new records of Gadolinium production in the 'production_data' table for Q1 2023 with the following production quantities: 1200, 1500, 1800 kg. | CREATE TABLE production_data (id INT,element TEXT,production_date DATE,production_quantity INT); | INSERT INTO production_data (element, production_date, production_quantity) VALUES ('Gadolinium', '2023-01-01', 1200), ('Gadolinium', '2023-02-01', 1500), ('Gadolinium', '2023-03-01', 1800); |
List all stores and their total sales this month | CREATE TABLE store_sales (sale_date DATE,store_id INT,sale_quantity INT,sale_price DECIMAL(10,2)); | SELECT store_id, SUM(sale_quantity * sale_price) as total_sales FROM store_sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY store_id; |
What percentage of patients have been diagnosed with both depression and anxiety disorders? | CREATE TABLE diagnosis (patient_id INT,condition TEXT); INSERT INTO diagnosis (patient_id,condition) VALUES (1,'Depression'); INSERT INTO diagnosis (patient_id,condition) VALUES (1,'Anxiety Disorder'); INSERT INTO diagnosis (patient_id,condition) VALUES (2,'Anxiety Disorder'); | SELECT (COUNT(DISTINCT patient_id) * 100.0 / (SELECT COUNT(DISTINCT patient_id) FROM diagnosis)) AS percentage FROM diagnosis WHERE condition IN ('Depression', 'Anxiety Disorder') GROUP BY patient_id HAVING COUNT(DISTINCT condition) = 2; |
What was the total donation amount in Kenya in Q2 2021? | CREATE TABLE Donations (id INT,user_id INT,country VARCHAR(50),amount DECIMAL(10,2),donation_date DATE); INSERT INTO Donations (id,user_id,country,amount,donation_date) VALUES (5,105,'Kenya',30.00,'2021-04-22'); INSERT INTO Donations (id,user_id,country,amount,donation_date) VALUES (6,106,'Nigeria',15.00,'2021-06-01'); | SELECT SUM(amount) FROM Donations WHERE country = 'Kenya' AND donation_date BETWEEN '2021-04-01' AND '2021-06-30'; |
What is the total number of cases heard in community courts for each type of offense? | CREATE TABLE community_courts (id INT,offense_type VARCHAR(255),cases_heard INT); INSERT INTO community_courts (id,offense_type,cases_heard) VALUES (1,'Theft',35),(2,'Assault',47),(3,'Vandalism',29); | SELECT offense_type, SUM(cases_heard) FROM community_courts GROUP BY offense_type; |
Delete records in the consumer_awareness table where the region is 'Asia Pacific' and awareness_score is less than 5 | CREATE TABLE consumer_awareness (id INT PRIMARY KEY,consumer_id INT,region VARCHAR(255),awareness_score INT); INSERT INTO consumer_awareness (id,consumer_id,region,awareness_score) VALUES (1,1001,'Asia Pacific',6),(2,1002,'Europe',7),(3,1003,'Asia Pacific',4),(4,1004,'Americas',8); | DELETE FROM consumer_awareness WHERE region = 'Asia Pacific' AND awareness_score < 5; |
What is the total number of stops and routes in each city? | CREATE TABLE stops (id INT,name VARCHAR(255),lat DECIMAL(9,6),lon DECIMAL(9,6),city VARCHAR(255)); INSERT INTO stops (id,name,lat,lon,city) VALUES (1,'Central Station',40.7128,-74.0060,'NYC'),(2,'Times Square',40.7590,-73.9844,'NYC'),(3,'Eiffel Tower',48.8582,2.2945,'Paris'),(4,'Big Ben',51.5008,-0.1246,'London'),(5,'S... | SELECT city, COUNT(DISTINCT s.id) as Total_Stops, COUNT(DISTINCT r.id) as Total_Routes FROM stops s JOIN routes r ON s.city = r.city GROUP BY city; |
Update the country of a port | ports(port_id,port_name,country,region,location) | UPDATE ports SET country = 'China' WHERE port_id = 5002; |
Insert environmental impact data for hydrogen peroxide | CREATE TABLE environmental_impact (chemical_name VARCHAR(255),impact_description TEXT); | INSERT INTO environmental_impact (chemical_name, impact_description) VALUES ('hydrogen peroxide', 'Low environmental impact due to its rapid decomposition into water and oxygen.'); |
What is the total number of healthcare providers in urban areas? | CREATE TABLE HealthcareProviders (Id INT,Name TEXT,Location TEXT,Specialty TEXT); INSERT INTO HealthcareProviders (Id,Name,Location,Specialty) VALUES (1,'Dr. Smith','City X','Family Medicine'); INSERT INTO HealthcareProviders (Id,Name,Location,Specialty) VALUES (2,'Dr. Johnson','City X','Cardiology'); INSERT INTO Healt... | SELECT COUNT(*) FROM HealthcareProviders WHERE Location LIKE 'City%'; |
What is the maximum dissolved oxygen level in fish farms located in Europe? | CREATE TABLE fish_farms (id INT,name TEXT,location TEXT,longitude DECIMAL(9,6),latitude DECIMAL(9,6),dissolved_oxygen DECIMAL(5,2)); INSERT INTO fish_farms (id,name,location,longitude,latitude,dissolved_oxygen) VALUES (1,'Atlantic Salmon Farm','Norway',6.0,60.5,9.5),(2,'Tilapia Farm','Spain',-3.8,39.5,7.0); | SELECT MAX(dissolved_oxygen) FROM fish_farms WHERE location LIKE '%Europe%'; |
How many transportation projects were completed in '2019'? | CREATE TABLE if not exists transportation_projects (id INT,name VARCHAR(100),year INT,completed BOOLEAN); INSERT INTO transportation_projects (id,name,year,completed) VALUES (1,'Transportation Development',2019,TRUE); | SELECT COUNT(*) FROM transportation_projects WHERE year = 2019 AND completed = TRUE; |
What is the average number of daily visitors to historical sites in Germany? | CREATE TABLE visitors (site_id INT,name VARCHAR(255),country VARCHAR(255),daily_visitors INT); INSERT INTO visitors (site_id,name,country,daily_visitors) VALUES (1,'Brandenburg Gate','Germany',10000),(2,'Neuschwanstein Castle','Germany',6000),(3,'Reichstag Building','Germany',8000); | SELECT AVG(daily_visitors) FROM visitors WHERE country = 'Germany'; |
What is the maximum budget for a project in the 'housing_projects' table? | CREATE TABLE housing_projects (project VARCHAR(50),budget INT); INSERT INTO housing_projects (project,budget) VALUES ('Affordable Housing Construction',1500000); INSERT INTO housing_projects (project,budget) VALUES ('Public Housing Renovation',1200000); INSERT INTO housing_projects (project,budget) VALUES ('Rent Subsid... | SELECT MAX(budget) FROM housing_projects; |
What is the average salary of workers in the 'Assembly' department across all factories? | CREATE TABLE factories (factory_id INT,department VARCHAR(255)); INSERT INTO factories VALUES (1,'Assembly'),(1,'Quality Control'),(2,'Design'),(2,'Testing'); CREATE TABLE workers (worker_id INT,factory_id INT,department VARCHAR(255),role VARCHAR(255),salary INT); INSERT INTO workers VALUES (1,1,'Assembly','Engineer',5... | SELECT AVG(w.salary) as avg_salary FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'Assembly'; |
Delete all records for language preservation programs with a budget over 200000? | CREATE TABLE LanguagePreservation (ProgramName varchar(100),Budget decimal(10,2)); INSERT INTO LanguagePreservation (ProgramName,Budget) VALUES ('Rosetta Stone',150000.00),('Endangered Languages Project',250000.00),('Talking Dictionaries',120000.00); | DELETE FROM LanguagePreservation WHERE Budget > 200000.00; |
What was the average gas production per well in the 'Gulf of Mexico' in Q3 2019? | CREATE TABLE wells (well_id INT,field VARCHAR(50),region VARCHAR(50),production_oil FLOAT,production_gas FLOAT,production_date DATE); INSERT INTO wells (well_id,field,region,production_oil,production_gas,production_date) VALUES (1,'Thunder Horse','Gulf of Mexico',12000.0,8000.0,'2019-07-01'),(2,'Taylor','Gulf of Mexico... | SELECT AVG(production_gas) FROM wells WHERE region = 'Gulf of Mexico' AND QUARTER(production_date) = 3 AND YEAR(production_date) = 2019 GROUP BY region; |
List all RPG games that have been played by female players, along with the players' age. | CREATE TABLE Players (PlayerID INT,Name VARCHAR(100),Age INT,Gender VARCHAR(10)); INSERT INTO Players VALUES (1,'Jessica Davis',23,'Female'); INSERT INTO Players VALUES (2,'Daniel Kim',30,'Male'); CREATE TABLE GameDesign (GameID INT,GameName VARCHAR(100),Genre VARCHAR(50)); INSERT INTO GameDesign VALUES (1,'GameZ','RPG... | SELECT GD.GameName, P.Age FROM Players P JOIN (SELECT GameID, GameName FROM GameDesign WHERE Genre = 'RPG') GD ON P.PlayerID = GD.GameID WHERE P.Gender = 'Female'; |
Calculate the percentage change in mangrove coverage in Southeast Asia from 2005 to 2020, ranked by the greatest change? | CREATE TABLE mangrove_coverage (year INT,region VARCHAR(50),mangrove_coverage FLOAT); INSERT INTO mangrove_coverage (year,region,mangrove_coverage) VALUES (2005,'Southeast_Asia',0.6),(2006,'Southeast_Asia',0.63),(2005,'South_Asia',0.4),(2006,'South_Asia',0.41); | SELECT region, (LEAD(mangrove_coverage, 1, 0) OVER (ORDER BY year) - mangrove_coverage) / ABS(LEAD(mangrove_coverage, 1, 0) OVER (ORDER BY year)) * 100 AS pct_change, RANK() OVER (ORDER BY (LEAD(mangrove_coverage, 1, 0) OVER (ORDER BY year) - mangrove_coverage) DESC) AS rank FROM mangrove_coverage WHERE region = 'South... |
Show producers with the highest land degradation impact | CREATE TABLE mining_impact (id INT PRIMARY KEY,location VARCHAR(255),water_usage INT,air_pollution INT,land_degradation INT); CREATE VIEW environmental_impact AS SELECT location,SUM(water_usage) AS total_water_usage,SUM(air_pollution) AS total_air_pollution,SUM(land_degradation) AS total_land_degradation FROM mining_im... | SELECT location FROM environmental_impact WHERE total_land_degradation = (SELECT MAX(total_land_degradation) FROM environmental_impact); |
What is the percentage of completed community development initiatives in each country? | CREATE TABLE CommunityDevelopment (ProjectID INT,Country VARCHAR(100),CompletionStatus VARCHAR(20)); INSERT INTO CommunityDevelopment VALUES (1,'Canada','Completed'),(2,'Mexico','In Progress'),(3,'Brazil','Completed'),(4,'Argentina','Completed'),(5,'Colombia','In Progress'); | SELECT Country, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY NULL) AS Percentage FROM CommunityDevelopment WHERE CompletionStatus = 'Completed' GROUP BY Country; |
What is the total price of products made by sustainable manufacturers who are not based in the United States? | CREATE TABLE manufacturers (id INT PRIMARY KEY,name TEXT,location TEXT,sustainability_score INT); CREATE TABLE products (id INT PRIMARY KEY,name TEXT,category TEXT,price DECIMAL,manufacturer_id INT,FOREIGN KEY (manufacturer_id) REFERENCES manufacturers(id)); | SELECT SUM(p.price) FROM products p JOIN manufacturers m ON p.manufacturer_id = m.id WHERE m.sustainability_score >= 80 AND m.location != 'United States'; |
Update the number of employees for hotel with ID 105 to 25. | CREATE TABLE hotels (hotel_id INT,name VARCHAR(50),number_of_employees INT); INSERT INTO hotels (hotel_id,name,number_of_employees) VALUES (101,'Green Hotel',30),(102,'Eco Lodge',20),(103,'Sustainable Resort',28),(104,'Heritage Hotel',35),(105,'Cultural Inn',23); | UPDATE hotels SET number_of_employees = 25 WHERE hotel_id = 105; |
Identify the top 3 deepest marine life research data sites in the 'OceanExplorer' schema. | CREATE SCHEMA OceanExplorer; CREATE TABLE MarineLifeResearch (site_id INT,depth FLOAT); INSERT INTO MarineLifeResearch (site_id,depth) VALUES (1,5000.1),(2,6000.2),(3,7000.3),(4,4000.4),(5,3000.5); | SELECT site_id, depth FROM OceanExplorer.MarineLifeResearch ORDER BY depth DESC LIMIT 3; |
Insert a new record of the passenger 'Michael Chen' who boarded the bus with the route 103 on March 17, 2021 at 11:45 AM. | CREATE TABLE BUS_RIDERS (id INT,name VARCHAR(50),boarding_time TIMESTAMP,route_number INT); INSERT INTO BUS_ROUTES VALUES (103,'2021-03-17 11:30:00','2021-03-17 12:30:00'); | INSERT INTO BUS_RIDERS VALUES (4, 'Michael Chen', '2021-03-17 11:45:00', 103); |
Update the status of vessels with IDs 1001, 1003, and 1007 to 'under maintenance' if their last maintenance was more than 60 days ago | CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.vessels (id INT,name VARCHAR(255),status VARCHAR(255),last_maintenance DATE); | UPDATE ocean_shipping.vessels SET status = 'under maintenance' WHERE id IN (1001, 1003, 1007) AND last_maintenance < DATE_SUB(CURRENT_DATE, INTERVAL 60 DAY); |
Show the distribution of safety labels in the 'ai_safety_labels' table. | CREATE TABLE ai_safety_labels (id INT,ai_system VARCHAR(50),safety_label VARCHAR(50)); | SELECT safety_label, COUNT(*) as num_labels FROM ai_safety_labels GROUP BY safety_label; |
What is the total number of public transportation projects in the city of Toronto? | CREATE TABLE Projects (id INT,name TEXT,city TEXT,type TEXT); INSERT INTO Projects (id,name,city,type) VALUES (1,'Eglinton Crosstown LRT','Toronto','Public Transit'); INSERT INTO Projects (id,name,city,type) VALUES (2,'Sheppard East LRT','Toronto','Public Transit'); | SELECT COUNT(*) FROM Projects WHERE city = 'Toronto' AND type = 'Public Transit' |
Identify the top 3 cities with the highest renewable energy capacity? | CREATE TABLE CityEnergy (City VARCHAR(50),EnergyCapacity FLOAT,Renewable BOOLEAN); INSERT INTO CityEnergy (City,EnergyCapacity,Renewable) VALUES ('CityA',5000,TRUE),('CityB',3000,FALSE),('CityC',7000,TRUE); | SELECT City, EnergyCapacity FROM (SELECT City, EnergyCapacity, RANK() OVER (ORDER BY EnergyCapacity DESC) as CityRank FROM CityEnergy WHERE Renewable = TRUE) AS CityEnergyRanked WHERE CityRank <= 3; |
What is the total number of transactions on the Tezos network involving the FA1.2 token standard in Q3 2021? | CREATE TABLE tezos_transactions (tx_hash VARCHAR(255),block_number INT,timestamp TIMESTAMP,from_address VARCHAR(36),to_address VARCHAR(36),token_standard VARCHAR(10),value DECIMAL(20,8)); | SELECT COUNT(*) AS num_transactions FROM tezos_transactions WHERE token_standard = 'FA1.2' AND timestamp >= '2021-07-01 00:00:00' AND timestamp < '2021-10-01 00:00:00'; |
What is the average response time for emergency calls in the state of New York? | CREATE TABLE emergency_calls (id INT,state VARCHAR(255),response_time FLOAT); INSERT INTO emergency_calls (id,state,response_time) VALUES (1,'New_York',8.5),(2,'New_York',9.2),(3,'California',7.4); | SELECT AVG(response_time) FROM emergency_calls WHERE state = 'New_York'; |
What is the average environmental impact score for each chemical? | CREATE TABLE environmental_impact_2 (chemical VARCHAR(10),score INT); INSERT INTO environmental_impact_2 VALUES ('F',25),('F',30),('F',20),('G',35),('G',40); | SELECT chemical, AVG(score) FROM environmental_impact_2 GROUP BY chemical; |
List all the forest plots and their corresponding wildlife species. | CREATE TABLE ForestPlots (PlotID int,PlotName varchar(50)); INSERT INTO ForestPlots VALUES (1,'Plot1'),(2,'Plot2'); CREATE TABLE Wildlife (SpeciesID int,SpeciesName varchar(50),PlotID int); INSERT INTO Wildlife VALUES (1,'Deer',1),(2,'Bear',1),(3,'Rabbit',2); | SELECT ForestPlots.PlotName, Wildlife.SpeciesName FROM ForestPlots CROSS JOIN Wildlife; |
Delete all records in the savings table where the interest_rate is greater than 2.5 | CREATE TABLE savings (account_number INT,interest_rate DECIMAL(3,2),customer_name VARCHAR(50),created_at TIMESTAMP); | DELETE FROM savings WHERE interest_rate > 2.5; |
Calculate the average duration spent on exhibitions by age group. | CREATE TABLE exhibition_visits (id INT,visitor_id INT,exhibition_id INT,duration_mins INT,age_group TEXT); INSERT INTO exhibition_visits (id,visitor_id,exhibition_id,duration_mins,age_group) VALUES (1,1,1,60,'0-17'),(2,2,1,75,'18-25'); | SELECT exhibition_id, age_group, AVG(duration_mins) FROM exhibition_visits GROUP BY exhibition_id, age_group; |
What is the average salinity in the Red Sea? | CREATE TABLE sea_salinity (location VARCHAR(255),salinity FLOAT); INSERT INTO sea_salinity (location,salinity) VALUES ('Red Sea',41.0),('Black Sea',18.0); | SELECT AVG(salinity) FROM sea_salinity WHERE location = 'Red Sea'; |
How many players play games in each genre? | CREATE TABLE player (player_id INT,name VARCHAR(50),age INT,game_genre VARCHAR(20)); INSERT INTO player (player_id,name,age,game_genre) VALUES (1,'John Doe',25,'Racing'); INSERT INTO player (player_id,name,age,game_genre) VALUES (2,'Jane Smith',30,'RPG'); INSERT INTO player (player_id,name,age,game_genre) VALUES (3,'Al... | SELECT game_genre, COUNT(*) FROM player GROUP BY game_genre; |
Find the top 3 most energy-efficient countries in Asia based on their average energy efficiency rating? | CREATE TABLE countries (name VARCHAR(255),energy_efficiency_rating FLOAT); INSERT INTO countries (name,energy_efficiency_rating) VALUES ('Japan',5.5),('China',3.2),('India',4.1),('Singapore',5.9),('Thailand',4.7); | SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY energy_efficiency_rating DESC) as rn FROM countries WHERE name IN ('Japan', 'China', 'India', 'Singapore', 'Thailand')) t WHERE rn <= 3; |
identify the mines in the mining_sites table that have no associated labor in the mining_labor table | CREATE TABLE mining_labor (id INT,mine_id INT,name VARCHAR(50),role VARCHAR(20)); INSERT INTO mining_labor (id,mine_id,name,role) VALUES (1,1,'John Doe','Employee'),(2,1,'Jane Smith','Contractor'),(3,2,'Bob Johnson','Employee'); CREATE TABLE mining_sites (id INT,name VARCHAR(50),status VARCHAR(20)); INSERT INTO mining_... | SELECT s.* FROM mining_sites s LEFT JOIN mining_labor l ON s.id = l.mine_id WHERE l.id IS NULL; |
What is the minimum number of volunteer hours per week, for each program? | CREATE TABLE programs (id INT,name VARCHAR(255)); INSERT INTO programs (id,name) VALUES (1,'Education'),(2,'Health'),(3,'Environment'); CREATE TABLE volunteer_hours (id INT,program_id INT,volunteer_date DATE,hours INT); INSERT INTO volunteer_hours (id,program_id,volunteer_date,hours) VALUES (1,1,'2022-01-01',5),(2,1,'2... | SELECT program_id, DATE_TRUNC('week', volunteer_date) AS week, MIN(hours) OVER (PARTITION BY program_id, week) AS min_volunteer_hours FROM volunteer_hours; |
What is the total energy consumption for manufacturing garments made of silk in India? | CREATE TABLE fabric_usage (id INT PRIMARY KEY,garment_id INT,fabric_type VARCHAR(255),fabric_weight FLOAT,manufacturing_waste FLOAT,energy_consumption FLOAT); INSERT INTO fabric_usage (id,garment_id,fabric_type,fabric_weight,manufacturing_waste,energy_consumption) VALUES (1,1,'Silk',1.5,0.2,100); | SELECT SUM(fu.energy_consumption) as total_energy_consumption FROM fabric_usage fu INNER JOIN garment_manufacturing gm ON fu.garment_id = gm.garment_id WHERE fu.fabric_type = 'Silk' AND gm.manufacturing_date BETWEEN '2021-01-01' AND '2021-12-31' AND gm.country = 'India'; |
What is the total funding raised by companies founded by women in the biotechnology industry? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_year INT,founder_gender TEXT); INSERT INTO companies (id,name,industry,founding_year,founder_gender) VALUES (1,'BioTech','Biotechnology',2015,'Female'); INSERT INTO companies (id,name,industry,founding_year,founder_gender) VALUES (2,'MedicalTech','Healthca... | SELECT SUM(funding_amount) FROM funding_records INNER JOIN companies ON funding_records.company_id = companies.id WHERE companies.founder_gender = 'Female' AND companies.industry = 'Biotechnology'; |
How many car manufacturers are headquartered in South Korea? | CREATE TABLE Manufacturers (Id INT,Name VARCHAR(100),Country VARCHAR(50)); INSERT INTO Manufacturers (Id,Name,Country) VALUES (1,'Hyundai','South Korea'),(2,'Kia','South Korea'); | SELECT COUNT(*) FROM Manufacturers WHERE Country = 'South Korea'; |
Calculate the running total of donations for each donor in descending order of donation date. | CREATE TABLE Donations (DonationID int,DonorID int,DonationAmount money,DonationDate date); | SELECT DonorID, SUM(DonationAmount) OVER (PARTITION BY DonorID ORDER BY DonationDate DESC) as RunningTotal FROM Donations; |
List all destinations in Europe with a sustainability rating of 5 and their total number of visitors. | CREATE TABLE EuropeDestinations (destination_id INT,name VARCHAR(50),country VARCHAR(50),sustainability_rating INT,total_visitors INT); INSERT INTO EuropeDestinations (destination_id,name,country,sustainability_rating,total_visitors) VALUES (1,'Eco Village','France',5,1500); INSERT INTO EuropeDestinations (destination_... | SELECT name, total_visitors FROM EuropeDestinations WHERE country IN ('Europe') AND sustainability_rating = 5; |
Find the difference in ticket prices between consecutive concerts for each artist. | CREATE TABLE artists (name VARCHAR(50),genre VARCHAR(50)); INSERT INTO artists (name,genre) VALUES ('Beyoncé','Pop'),('Drake','Hip Hop'),('Taylor Swift','Country Pop'); CREATE TABLE concerts (artist_name VARCHAR(50),venue VARCHAR(50),ticket_price DECIMAL(5,2)); INSERT INTO concerts (artist_name,venue,ticket_price) VALU... | SELECT artist_name, ticket_price - LAG(ticket_price) OVER(PARTITION BY artist_name ORDER BY venue) AS ticket_price_diff FROM concerts; |
List the names and maximum depths of all marine protected areas in the Arctic region that are shallower than 500 meters. | CREATE TABLE marine_protected_areas (name VARCHAR(255),region VARCHAR(255),max_depth FLOAT); INSERT INTO marine_protected_areas (name,region,max_depth) VALUES ('Arctic National Wildlife Refuge','Arctic',499.0),('Beaufort Sea','Arctic',300.0),('Chukchi Sea','Arctic',150.0); | SELECT name, max_depth FROM marine_protected_areas WHERE region = 'Arctic' AND max_depth < 500; |
Calculate the average salary of female employees in the "HumanResources" department | CREATE TABLE Employees (EmployeeID INT,FirstName TEXT,LastName TEXT,Department TEXT,Salary INT); INSERT INTO Employees (EmployeeID,FirstName,LastName,Department,Salary) VALUES (1,'John','Doe','HumanResources',60000),(2,'Jane','Doe','HumanResources',65000); | SELECT AVG(Salary) FROM Employees WHERE Gender = 'Female' AND Department = 'HumanResources'; |
Show the top 3 sectors with the highest average ESG score. | CREATE TABLE company (id INT,name VARCHAR(50),sector VARCHAR(20),esg_score DECIMAL(3,2)); INSERT INTO company (id,name,sector,esg_score) VALUES (1,'TechCo','technology',85.67); INSERT INTO company (id,name,sector,esg_score) VALUES (2,'GreenTech Inc','renewable energy',88.54); | SELECT sector, AVG(esg_score) AS avg_esg_score, ROW_NUMBER() OVER (ORDER BY AVG(esg_score) DESC) AS sector_rank FROM company GROUP BY sector ORDER BY avg_esg_score DESC, sector_rank; |
What is the number of companies founded by individuals from underrepresented communities in the renewable energy industry? | CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_date DATE,founder_community TEXT); INSERT INTO companies (id,name,industry,founding_date,founder_community) VALUES (1,'SolarUp','Renewable Energy','2018-01-01','Indigenous'); | SELECT COUNT(*) FROM companies WHERE industry = 'Renewable Energy' AND founder_community IN ('Indigenous', 'Black', 'Latinx', 'Pacific Islander', 'Asian American', 'LGBTQ+'); |
How many unique endangered languages are spoken in each continent? | CREATE TABLE Languages (id INT,language VARCHAR(50),continent VARCHAR(50),speakers INT); INSERT INTO Languages (id,language,continent,speakers) VALUES (1,'Swahili','Africa',15000000),(2,'Mandarin','Asia',1200000000),(3,'Quechua','South America',8000000),(4,'Greenlandic','North America',56000); | SELECT continent, COUNT(DISTINCT language) FROM Languages WHERE speakers < 10000000 GROUP BY continent; |
What is the average age of players who have participated in esports events, in the last 3 months, in the United States? | CREATE TABLE players (id INT,name VARCHAR(50),age INT,country VARCHAR(50)); INSERT INTO players (id,name,age,country) VALUES (1,'John Doe',25,'USA'); INSERT INTO players (id,name,age,country) VALUES (2,'Jane Smith',30,'USA'); CREATE TABLE events (id INT,name VARCHAR(50),date DATE); INSERT INTO events (id,name,date) VAL... | SELECT AVG(players.age) FROM players INNER JOIN events ON players.country = 'USA' AND events.date >= DATEADD(month, -3, GETDATE()) AND players.id = events.id; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.