instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Calculate the percentage of graduate students per department who have published at least one paper, in descending order of percentage. | CREATE TABLE students (student_id INT,dept_id INT,graduated BOOLEAN,num_publications INT);CREATE TABLE departments (dept_id INT,dept_name VARCHAR(255)); | SELECT dept_name, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM students s WHERE s.dept_id = f.dept_id) AS percentage FROM students f WHERE num_publications > 0 GROUP BY dept_name ORDER BY percentage DESC; |
Which mobile subscribers have a higher data usage than the average in their country? | CREATE TABLE mobile_subscribers (subscriber_id INT,home_location VARCHAR(50),monthly_data_usage DECIMAL(10,2)); INSERT INTO mobile_subscribers (subscriber_id,home_location,monthly_data_usage) VALUES (1,'USA',3.5),(2,'Mexico',4.2),(3,'Canada',2.8),(4,'USA',4.5),(5,'Canada',3.2); CREATE TABLE country_averages (home_locat... | SELECT ms.subscriber_id, ms.home_location, ms.monthly_data_usage FROM mobile_subscribers ms INNER JOIN country_averages ca ON ms.home_location = ca.home_location WHERE ms.monthly_data_usage > ca.average_data_usage; |
List the types of military equipment used by the US and China, and the quantity of each type. | CREATE TABLE military_equipment (id INT,country TEXT,equipment_type TEXT,quantity INT); INSERT INTO military_equipment (id,country,equipment_type,quantity) VALUES (1,'USA','Tanks',3000),(2,'China','Tanks',4000),(3,'USA','Aircraft',5000),(4,'China','Aircraft',6000); | SELECT m.country, m.equipment_type, m.quantity FROM military_equipment m WHERE m.country IN ('USA', 'China') GROUP BY m.equipment_type; |
Which threat intelligence sources reported the lowest severity threats in the last month? | CREATE TABLE threat_intelligence (id INT,source TEXT,severity TEXT,reported_date DATE); INSERT INTO threat_intelligence (id,source,severity,reported_date) VALUES (1,'FSB','low','2021-02-01'); INSERT INTO threat_intelligence (id,source,severity,reported_date) VALUES (2,'MI5','medium','2021-03-10'); INSERT INTO threat_in... | SELECT source, severity FROM threat_intelligence WHERE reported_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND severity = (SELECT MIN(severity) FROM threat_intelligence WHERE reported_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)); |
Determine the number of days between each customer's first and last transaction, partitioned by account type. | CREATE TABLE accounts (customer_id INT,account_type VARCHAR(20),transaction_date DATE); | SELECT customer_id, account_type, DATEDIFF(MAX(transaction_date), MIN(transaction_date)) OVER (PARTITION BY customer_id, account_type) AS days_between_first_last FROM accounts; |
What is the maximum treatment time for patients in 'RuralHealthFacility7'? | CREATE TABLE RuralHealthFacility7 (id INT,name TEXT,treatment_time INT); INSERT INTO RuralHealthFacility7 (id,name,treatment_time) VALUES (1,'Grace Yellow',60),(2,'Harry Blue',75); | SELECT MAX(treatment_time) FROM RuralHealthFacility7; |
What is the maximum investment in climate finance for each country in Africa, and which year did it occur? | CREATE TABLE climate_finance (country VARCHAR(50),year INT,investment FLOAT); INSERT INTO climate_finance (country,year,investment) VALUES ('Kenya',2016,1000000),('Nigeria',2017,1500000); | SELECT country, MAX(investment) as max_investment, year FROM climate_finance WHERE country IN ('Kenya', 'Nigeria') GROUP BY country, year ORDER BY max_investment DESC; |
How many clean energy policies were implemented in each year in the policies and policy_dates tables? | CREATE TABLE policies(id INT,policy_name VARCHAR(50),policy_type VARCHAR(50),policy_date DATE);CREATE TABLE policy_dates(policy_id INT,start_date DATE,end_date DATE); | SELECT YEAR(p.policy_date) AS policy_year, COUNT(*) AS num_policies FROM policies p INNER JOIN policy_dates pd ON p.id = pd.policy_id GROUP BY policy_year; |
What was the total sales amount for each product category by country in 2022, excluding online sales? | CREATE TABLE sales_2022 AS SELECT * FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-12-31'; ALTER TABLE sales_2022 ADD COLUMN sale_country VARCHAR(50); UPDATE sales_2022 SET sale_country = CASE WHEN sale_channel = 'Online' THEN 'Online' ELSE sale_city END; ALTER TABLE sales_2022 ADD COLUMN product_category VA... | SELECT sale_country, product_category, SUM(sale_amount) FROM sales_2022 WHERE sale_country != 'Online' GROUP BY sale_country, product_category; |
Display the names of all artists who had a higher number of streams than their average in 2019. | CREATE TABLE artists (id INT PRIMARY KEY,name TEXT); CREATE TABLE songs (id INT PRIMARY KEY,title TEXT,year INT,artist_id INT,genre TEXT,streams INT); INSERT INTO artists (id,name) VALUES (1,'BTS'),(2,'Blackpink'),(3,'TWICE'),(4,'Taylor Swift'),(5,'Ariana Grande'); INSERT INTO songs (id,title,year,artist_id,genre,strea... | SELECT a.name FROM artists a JOIN (SELECT artist_id, AVG(streams) as avg_streams FROM songs WHERE year = 2019 GROUP BY artist_id) b ON a.id = b.artist_id WHERE b.avg_streams < (SELECT streams FROM songs s WHERE s.artist_id = b.artist_id AND s.year = 2019 ORDER BY streams DESC LIMIT 1); |
What's the minimum ESG score for companies in the 'healthcare' or 'pharmaceutical' sectors? | CREATE TABLE companies_esg_3 (id INT,sector VARCHAR(20),ESG_score FLOAT); INSERT INTO companies_esg_3 (id,sector,ESG_score) VALUES (1,'healthcare',72.5),(2,'pharmaceutical',80.2),(3,'healthcare',76.1); | SELECT MIN(ESG_score) FROM companies_esg_3 WHERE sector IN ('healthcare', 'pharmaceutical'); |
Show animal species and their population sizes | CREATE TABLE animal_populations (id INT,species VARCHAR(50),population INT); INSERT INTO animal_populations (id,species,population) VALUES (1,'Giraffe',1500),(2,'Elephant',2000),(3,'Lion',300),(4,'Rhinoceros',800),(5,'Hippopotamus',1200); | SELECT species, population FROM animal_populations; |
What is the distribution of ethical AI research papers by publication year? | CREATE TABLE ethical_ai_research (id INT,publication_year INT,is_ethical BOOLEAN); | SELECT publication_year, COUNT(*) as num_publications FROM ethical_ai_research WHERE is_ethical = TRUE GROUP BY publication_year; |
Identify the top 2 regions with the highest average water consumption for the month of July 2020 | CREATE TABLE region_water_consumption (region VARCHAR(50),date DATE,consumption FLOAT); INSERT INTO region_water_consumption (region,date,consumption) VALUES ('Mumbai','2020-07-01',1500),('Mumbai','2020-07-02',1600),('Mumbai','2020-07-03',1400),('Delhi','2020-07-01',1800),('Delhi','2020-07-02',1900),('Delhi','2020-07-0... | SELECT region, AVG(consumption) AS avg_consumption FROM region_water_consumption WHERE date BETWEEN '2020-07-01' AND '2020-07-31' GROUP BY region ORDER BY avg_consumption DESC LIMIT 2; |
How many rural infrastructure projects were completed in Colombia each year, with at least 90% on-time completion rate? | CREATE TABLE rural_projects (country TEXT,year INT,completion_rate NUMERIC); INSERT INTO rural_projects (country,year,completion_rate) VALUES ('Colombia',2017,0.85),('Colombia',2017,0.95),('Colombia',2018,0.88),('Colombia',2018,0.92),('Colombia',2019,0.9),('Colombia',2019,0.97),('Colombia',2020,0.85),('Colombia',2020,0... | SELECT year, COUNT(*) FROM rural_projects WHERE country = 'Colombia' AND completion_rate >= 0.9 GROUP BY year; |
How many food safety violations occurred in each restaurant in the Casual Dining segment? | CREATE TABLE food_safety_inspections(restaurant_name VARCHAR(255),violation_count INT,restaurant_segment VARCHAR(255)); INSERT INTO food_safety_inspections(restaurant_name,violation_count,restaurant_segment) VALUES('Casual Diner 1',2,'Casual Dining'),('Casual Diner 2',0,'Casual Dining'),('Casual Diner 3',1,'Casual Dini... | SELECT restaurant_segment, restaurant_name, SUM(violation_count) FROM food_safety_inspections GROUP BY restaurant_segment, restaurant_name; |
Find the number of autonomous vehicles in each city, for taxis and shuttles | CREATE TABLE autonomous_vehicles_by_type (id INT PRIMARY KEY,city VARCHAR(255),type VARCHAR(255),num_vehicles INT); | CREATE VIEW autonomous_vehicles_by_type_city AS SELECT city, type, COUNT(*) as num_vehicles FROM autonomous_vehicles WHERE make = 'Wayve' GROUP BY city, type; SELECT * FROM autonomous_vehicles_by_type_city WHERE type IN ('Taxi', 'Shuttle'); |
What is the average carbon sequestration rate, in metric tons per hectare per year, for all forests in the temperate biome? | CREATE TABLE carbon_sequestration (id INT,forest_name VARCHAR(255),biome VARCHAR(255),rate_tons_per_hectare_per_year FLOAT); | SELECT AVG(rate_tons_per_hectare_per_year) FROM carbon_sequestration WHERE biome = 'temperate'; |
What is the total number of mental health parity violations and the number of patients treated for mental health issues in each region? | CREATE TABLE ParityViolations (ViolationID int,RegionID int,ViolationCount int);CREATE TABLE RegionMentalHealth (RegionID int,PatientID int); | SELECT RegionID, SUM(ViolationCount) as TotalViolations, COUNT(PatientID) as PatientCount FROM ParityViolations JOIN RegionMentalHealth ON ParityViolations.RegionID = RegionMentalHealth.RegionID GROUP BY RegionID; |
What is the total number of medical professionals in rural areas who specialize in mental health? | CREATE TABLE medical_professionals (id INT,name VARCHAR(50),specialty VARCHAR(50),location VARCHAR(20)); INSERT INTO medical_professionals (id,name,specialty,location) VALUES (1,'Dr. Smith','mental health','rural'),(2,'Dr. Johnson','cardiology','urban'),(3,'Dr. Brown','mental health','rural'); | SELECT COUNT(*) FROM medical_professionals WHERE specialty = 'mental health' AND location = 'rural'; |
Delete all cases with a case type of 'Bankruptcy'. | CREATE TABLE cases (case_id INT,case_type VARCHAR(255)); INSERT INTO cases (case_id,case_type) VALUES (1,'Civil'),(2,'Criminal'),(3,'Bankruptcy'); | DELETE FROM cases WHERE case_type = 'Bankruptcy'; |
Identify the top 5 threat actors with the highest number of attacks in the last quarter | CREATE TABLE attacks (id INT,threat_actor VARCHAR(255),date DATE); INSERT INTO attacks (id,threat_actor,date) VALUES (1,'APT28','2022-01-01'); INSERT INTO attacks (id,threat_actor,date) VALUES (2,'APT33','2022-01-02'); | SELECT threat_actor, COUNT(*) as num_attacks FROM attacks WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY threat_actor ORDER BY num_attacks DESC LIMIT 5; |
List mental health conditions treated in a given facility. | CREATE TABLE facilities (facility_id INT,condition VARCHAR(50)); | SELECT condition FROM facilities WHERE facility_id = 123; |
Who has conducted transactions with both deposit and withdrawal types? | CREATE TABLE Transaction_Types (id INT PRIMARY KEY,tx_type VARCHAR(50)); INSERT INTO Transaction_Types (id,tx_type) VALUES (1,'deposit'); INSERT INTO Transaction_Types (id,tx_type) VALUES (2,'withdrawal'); | SELECT u.name FROM Users u INNER JOIN Transactions t ON u.id = t.user_id INNER JOIN Transaction_Types tt1 ON t.tx_type = tt1.tx_type INNER JOIN Transaction_Types tt2 ON u.id = tt2.user_id WHERE tt1.id = 1 AND tt2.id = 2; |
How many advocacy projects were started in 'Africa' in each quarter of 2021? | CREATE TABLE Advocacy (id INT,location VARCHAR(50),start_date DATE,sector VARCHAR(50)); | SELECT DATEPART(YEAR, start_date) as year, DATEPART(QUARTER, start_date) as quarter, COUNT(id) as num_projects FROM Advocacy WHERE location = 'Africa' AND YEAR(start_date) = 2021 GROUP BY year, quarter; |
Display the number of socially responsible loans issued per month in 2022, with months in ascending order. | CREATE TABLE socially_responsible_loans (loan_id INT,loan_date DATE); INSERT INTO socially_responsible_loans (loan_id,loan_date) VALUES (1,'2022-01-01'),(2,'2022-02-15'),(3,'2022-03-28'),(4,'2022-04-12'); | SELECT DATE_FORMAT(loan_date, '%Y-%m') AS loan_month, COUNT(loan_id) AS loans_issued FROM socially_responsible_loans WHERE YEAR(loan_date) = 2022 GROUP BY loan_month ORDER BY loan_month; |
What is the total number of satellites for each country, based on the SpaceLaunchs and SatelliteOrbits tables? | CREATE TABLE SpaceLaunchs (LaunchID INT,Country VARCHAR(50),SatelliteID INT); INSERT INTO SpaceLaunchs (LaunchID,Country,SatelliteID) VALUES (1,'USA',101),(2,'Russia',201),(3,'China',301),(4,'India',401),(5,'Japan',501); CREATE TABLE SatelliteOrbits (SatelliteID INT,OrbitType VARCHAR(50),OrbitHeight INT); INSERT INTO S... | SELECT s.Country, COUNT(so.SatelliteID) AS TotalSatellites FROM SpaceLaunchs s JOIN SatelliteOrbits so ON s.SatelliteID = so.SatelliteID GROUP BY s.Country; |
What is the current status of all defense diplomacy initiatives between India and Pakistan? | CREATE TABLE defense_diplomacy (initiative_id INT,initiative_name TEXT,initiative_status TEXT,country1 TEXT,country2 TEXT); INSERT INTO defense_diplomacy (initiative_id,initiative_name,initiative_status,country1,country2) VALUES (1,'Joint Military Exercise','Planning','India','Pakistan'),(2,'Defense Technology Exchange... | SELECT defense_diplomacy.initiative_status FROM defense_diplomacy WHERE defense_diplomacy.country1 = 'India' AND defense_diplomacy.country2 = 'Pakistan'; |
Delete strains from CO dispensaries that have not been sold in the last 6 months | CREATE TABLE strains (id INT,name TEXT,dispensary_id INT,last_sale_date DATE); INSERT INTO strains (id,name,dispensary_id,last_sale_date) VALUES (1,'Purple Haze',1,'2022-02-15'),(2,'Sour Diesel',2,'2022-03-20'),(3,'Bubba Kush',3,NULL); CREATE TABLE dispensaries (id INT,name TEXT,state TEXT); INSERT INTO dispensaries (i... | DELETE s FROM strains s JOIN dispensaries d ON s.dispensary_id = d.id WHERE d.state = 'Colorado' AND s.last_sale_date < NOW() - INTERVAL 6 MONTH; |
What is the average property price in each neighborhood? | CREATE TABLE property (id INT,price FLOAT,neighborhood VARCHAR(20)); | SELECT neighborhood, AVG(price) FROM property GROUP BY neighborhood; |
Find users who have more posts with 'like' in the content than posts with 'dislike' in the content, and the total number of such posts. | CREATE TABLE users (id INT,name VARCHAR(50)); INSERT INTO users (id,name) VALUES (1,'Alice'),(2,'Bob'); CREATE TABLE posts (id INT,user_id INT,content TEXT,timestamp DATETIME); INSERT INTO posts (id,user_id,content,timestamp) VALUES (1,1,'I like this','2022-01-01 10:00:00'),(2,1,'I dislike that','2022-01-02 11:00:00'),... | SELECT users.name, COUNT(*) as num_posts FROM users INNER JOIN posts ON users.id = posts.user_id WHERE posts.content LIKE '%like%' AND posts.id NOT IN (SELECT posts.id FROM posts WHERE posts.content LIKE '%dislike%') GROUP BY users.name; |
Which indigenous arts and crafts from the Americas have the highest market value? | CREATE TABLE indigenous_arts (id INT,name VARCHAR(50),location VARCHAR(50),type VARCHAR(50),market_value INT,PRIMARY KEY(id)); INSERT INTO indigenous_arts (id,name,location,type,market_value) VALUES (1,'Navajo Rugs','USA','Textile',1000),(2,'Zapotec Weavings','Mexico','Textile',800),(3,'Inuit Sculptures','Canada','Scul... | SELECT i.name, i.location, i.type, MAX(i.market_value) AS highest_market_value FROM indigenous_arts i WHERE i.location LIKE '%America%' GROUP BY i.name, i.location, i.type; |
What is the total weight of goods in transit on each route, segmented by the destination country and the transportation mode? | CREATE TABLE transit (id INT,goods_id INT,weight INT,origin_region VARCHAR(50),destination_country VARCHAR(50),transportation_mode VARCHAR(50)); INSERT INTO transit (id,goods_id,weight,origin_region,destination_country,transportation_mode) VALUES (1,101,25,'East Asia','Kenya','Air'),(2,102,35,'South Asia','Ghana','Sea'... | SELECT origin_region, destination_country, transportation_mode, SUM(weight) as total_weight FROM transit GROUP BY origin_region, destination_country, transportation_mode; |
Add a new row to the 'ai_ethics_guidelines' table with the following data: 'Company A', 'Ensure data privacy and security', '2021-03-15' | CREATE TABLE ai_ethics_guidelines (company_name VARCHAR(50),guideline TEXT,last_reviewed DATETIME); | INSERT INTO ai_ethics_guidelines (company_name, guideline, last_reviewed) VALUES ('Company A', 'Ensure data privacy and security', '2021-03-15'); |
How many tourists visited New Zealand in 2020 who stayed in 5-star hotels? | CREATE TABLE tourists(tourist_id INT,name TEXT,country_visited TEXT,stay_duration INT);CREATE TABLE stays(stay_id INT,tourist_id INT,hotel_id INT,check_in DATE,check_out DATE);CREATE TABLE hotels(hotel_id INT,name TEXT,star_rating INT);INSERT INTO tourists (tourist_id,name,country_visited,stay_duration) VALUES (1,'John... | SELECT COUNT(*) FROM tourists INNER JOIN stays ON tourists.tourist_id = stays.tourist_id INNER JOIN hotels ON stays.hotel_id = hotels.hotel_id WHERE hotels.star_rating = 5 AND tourists.country_visited = 'New Zealand' AND stays.check_out <= '2020-12-31'; |
How many users are there in each gender category? | CREATE TABLE users (id INT,age INT,gender TEXT); INSERT INTO users (id,age,gender) VALUES ('1','25','Female'),('2','35','Male'),('3','45','Non-binary'); | SELECT gender, COUNT(*) as count FROM users GROUP BY gender; |
Find the number of tickets sold per game for the home_team in the ticket_sales table. | CREATE TABLE ticket_sales (ticket_id INT,game_id INT,home_team VARCHAR(20),away_team VARCHAR(20),price DECIMAL(5,2),quantity INT); | SELECT home_team, COUNT(*) as num_tickets_sold FROM ticket_sales GROUP BY home_team; |
What is the average age of patients who have been diagnosed with diabetes in the rural areas of Texas? | CREATE TABLE patients (patient_id INT,patient_name TEXT,age INT,diagnosis TEXT,state TEXT); INSERT INTO patients (patient_id,patient_name,age,diagnosis,state) VALUES (1,'John Doe',65,'Diabetes','Texas'); | SELECT AVG(age) FROM patients WHERE diagnosis = 'Diabetes' AND state = 'Texas'; |
What is the average number of hours teachers spent on professional development per week, grouped by subject area, from the "teachers_professional_development" table? | CREATE TABLE teachers_professional_development (teacher_id INT,subject_area VARCHAR(255),hours_per_week_pd INT); | SELECT subject_area, AVG(hours_per_week_pd) as avg_hours_pd FROM teachers_professional_development GROUP BY subject_area; |
Create a table for storing information about open pedagogy courses | CREATE TABLE OpenPedagogyCourses (CourseID INT PRIMARY KEY,CourseName VARCHAR(100),StartDate DATE,EndDate DATE,Enrollment INT); | CREATE TABLE OpenPedagogyCourses (CourseID INT PRIMARY KEY, CourseName VARCHAR(100), StartDate DATE, EndDate DATE, Enrollment INT); |
How many community development initiatives were implemented in the 'communitydev' schema in indigenous communities before 2010? | CREATE TABLE communitydev.initiatives (id INT,initiative_name VARCHAR(50),community_type VARCHAR(50),start_year INT); INSERT INTO communitydev.initiatives (id,initiative_name,community_type,start_year) VALUES (1,'Cultural Center','Indigenous',2005),(2,'Health Clinic','Urban',2017),(3,'Agricultural Training','Rural',201... | SELECT COUNT(*) FROM communitydev.initiatives WHERE community_type = 'Indigenous' AND start_year < 2010; |
What is the maximum heart rate recorded during yoga sessions, for users with more than 5 years of experience? | CREATE TABLE yoga_classes (id INT,user_id INT,heart_rate INT); INSERT INTO yoga_classes (id,user_id,heart_rate) VALUES (1,1,85),(2,1,80),(3,2,90),(4,2,95),(5,3,75); CREATE TABLE users (id INT,experience INT); INSERT INTO users (id,experience) VALUES (1,6),(2,7),(3,4); | SELECT MAX(heart_rate) FROM yoga_classes INNER JOIN users ON yoga_classes.user_id = users.id WHERE users.experience > 5; |
What is the average number of spectators in the last 2 home games for each team? | CREATE TABLE match_stats (id INT,team TEXT,spectators INT,home INT); INSERT INTO match_stats (id,team,spectators,home) VALUES (1,'Real Madrid',75000,1),(2,'Barcelona',65000,1),(3,'Atletico Madrid',55000,1),(4,'Real Madrid',76000,0),(5,'Barcelona',64000,0),(6,'Atletico Madrid',56000,0); | SELECT team, AVG(spectators) FROM match_stats WHERE home = 1 GROUP BY team HAVING season >= 2022; |
Which departments have more than 50 records? | CREATE TABLE all_departments (dept_name TEXT,record_count INTEGER); INSERT INTO all_departments (dept_name,record_count) VALUES ('Human Services Department',60),('Education Department',45),('Health Department',52),('Library Department',40),('Transportation Department',65); | SELECT dept_name FROM all_departments WHERE record_count > 50; |
Add an investment round for 'Ada Ventures' with 'Series A', '$10M', and '2021' | CREATE TABLE investments (id INT PRIMARY KEY,company_id INT,round_type VARCHAR(255),amount FLOAT,year INT,FOREIGN KEY (company_id) REFERENCES companies(id)); | INSERT INTO investments (id, company_id, round_type, amount, year) VALUES (1, 1, 'Series A', 10000000.0, 2021); |
What is the number of marine species with a conservation status of 'Vulnerable' or 'Endangered'? | CREATE TABLE marine_species (id INT,species_name VARCHAR(255),conservation_status VARCHAR(100)); INSERT INTO marine_species (id,species_name,conservation_status) VALUES (1,'Clownfish','Least Concern'),(2,'Green Sea Turtle','Endangered'),(3,'Whale Shark','Vulnerable'),(4,'Manta Ray','Vulnerable'),(5,'Sea Otter','Endange... | SELECT COUNT(*) FROM marine_species WHERE conservation_status IN ('Vulnerable', 'Endangered'); |
Show the total number of streams for each genre, excluding classical music, in a single query. | CREATE TABLE genre_streams (genre VARCHAR(10),stream_count BIGINT); | SELECT genre, SUM(stream_count) FROM genre_streams WHERE genre != 'classical' GROUP BY genre; |
What is the total quantity of Cerium produced in Nigeria and South Africa in 2016? | CREATE TABLE Cerium_Production (id INT,year INT,country VARCHAR(255),quantity FLOAT); | SELECT SUM(quantity) FROM Cerium_Production WHERE year = 2016 AND country IN ('Nigeria', 'South Africa'); |
What are the military equipment sales and their corresponding project timelines for the Middle East region in the year 2022, and for which countries are these sales? | CREATE TABLE EquipmentSales (id INT,region VARCHAR(50),country VARCHAR(50),sale_year INT,equipment VARCHAR(50),amount INT);CREATE TABLE ProjectTimelines (id INT,equipment VARCHAR(50),start_year INT,end_year INT); | SELECT EquipmentSales.country, EquipmentSales.equipment, EquipmentSales.sale_year, EquipmentSales.amount, ProjectTimelines.start_year, ProjectTimelines.end_year FROM EquipmentSales INNER JOIN ProjectTimelines ON EquipmentSales.equipment = ProjectTimelines.equipment WHERE EquipmentSales.region = 'Middle East' AND Equipm... |
What is the average salary of full-time employees by gender? | CREATE TABLE Employees (EmployeeID INT,EmploymentStatus VARCHAR(10),Salary INT,Gender VARCHAR(10)); INSERT INTO Employees (EmployeeID,EmploymentStatus,Salary,Gender) VALUES (1,'Full-time',50000,'Male'),(2,'Full-time',55000,'Female'),(3,'Part-time',30000,'Male'); | SELECT Gender, AVG(Salary) FROM Employees WHERE EmploymentStatus = 'Full-time' GROUP BY Gender; |
List the collective bargaining agreements in the technology sector that were signed in the last 3 years, excluding those from the United States. | CREATE TABLE cba(id INT,sector VARCHAR(50),country VARCHAR(14),signing_date DATE);INSERT INTO cba(id,sector,country,signing_date) VALUES (1,'Technology','Canada','2020-02-01'),(2,'Technology','Mexico','2019-08-15'),(3,'Technology','United States','2021-03-10'),(4,'Technology','Brazil','2018-11-28'); | SELECT * FROM cba WHERE sector = 'Technology' AND country != 'United States' AND signing_date >= (SELECT DATE_SUB(CURDATE(), INTERVAL 3 YEAR)) |
How many articles were published per day in the month of June 2022? | CREATE TABLE articles (id INT,title VARCHAR(50),publish_date DATE); INSERT INTO articles (id,title,publish_date) VALUES (1,'Article1','2022-06-01'),(2,'Article2','2022-06-15'),(3,'Article3','2022-05-30'); | SELECT DATE_FORMAT(publish_date, '%Y-%m-%d') as publish_date, COUNT(*) as articles_per_day FROM articles WHERE publish_date >= '2022-06-01' AND publish_date < '2022-07-01' GROUP BY publish_date |
What is the total number of marine species observed in the Pacific Ocean in 2018, grouped by month? | CREATE TABLE marine_species_observations (id INT,species VARCHAR(255),year INT,month INT,region VARCHAR(255)); INSERT INTO marine_species_observations (id,species,year,month,region) VALUES (1,'Sea otter',2017,1,'Pacific'); INSERT INTO marine_species_observations (id,species,year,month,region) VALUES (2,'California sea ... | SELECT month, COUNT(*) as total_observations FROM marine_species_observations WHERE region = 'Pacific' AND year = 2018 GROUP BY month; |
What was the cost of space missions that were not successful? | CREATE TABLE space_missions (id INT,mission_name VARCHAR(255),country VARCHAR(255),cost FLOAT,launch_status VARCHAR(10)); INSERT INTO space_missions (id,mission_name,country,cost,launch_status) VALUES (1,'Apollo 11','USA',25500000,'Success'),(2,'Mars Orbiter Mission','India',73000000,'Success'),(3,'Chandrayaan-1','Indi... | SELECT SUM(cost) FROM space_missions WHERE launch_status != 'Success'; |
What is the difference in age between the oldest and youngest defendant in each court case? | CREATE TABLE court_cases (case_id INT,court_date DATE); INSERT INTO court_cases (case_id,court_date) VALUES (1,'2022-01-01'),(2,'2021-12-20'),(3,'2022-02-15'); CREATE TABLE defendant_info (defendant_id INT,case_id INT,age INT,gender VARCHAR(50)); INSERT INTO defendant_info (defendant_id,case_id,age,gender) VALUES (1,1,... | SELECT case_id, MAX(age) - MIN(age) as age_diff FROM defendant_info GROUP BY case_id; |
Determine the average carbon price (€/t) in the European Union | CREATE TABLE carbon_prices (id INT,country VARCHAR(50),price FLOAT); INSERT INTO carbon_prices (id,country,price) VALUES (1,'Germany',25),(2,'France',30),(3,'Italy',28),(4,'Spain',22); | SELECT AVG(price) FROM carbon_prices WHERE country IN ('Germany', 'France', 'Italy', 'Spain'); |
List the names of economic diversification programs in the 'programs_data' table and their respective funding sources. | CREATE TABLE programs_data (program_id INT,program_name VARCHAR(50),funding_source VARCHAR(50)); INSERT INTO programs_data (program_id,program_name,funding_source) VALUES (1,'Green Jobs','Federal Government'),(2,'Renewable Energy','Provincial Government'),(3,'Sustainable Agriculture','Private Sector'); | SELECT program_name, funding_source FROM programs_data; |
List all exhibitions with the total number of artworks and the number of artists who have exhibited more than 3 works in each exhibition. | CREATE TABLE Exhibitions (exhibition_id INT,exhibition_name TEXT,artist_id INT,num_works INT); INSERT INTO Exhibitions (exhibition_id,exhibition_name,artist_id,num_works) VALUES (1,'Modern Art Museum',101,5),(2,'Modern Art Museum',102,3),(3,'Contemporary Art Gallery',101,4); | SELECT e.exhibition_name, COUNT(DISTINCT e.artist_id) AS num_artists, COUNT(e.artwork_id) AS total_artworks, SUM(CASE WHEN e.num_works > 3 THEN 1 ELSE 0 END) AS num_prolific_artists FROM Exhibitions e GROUP BY e.exhibition_name |
What is the average water consumption of factories in each country? | CREATE TABLE Factories (id INT,name TEXT,country TEXT,water_consumption DECIMAL(5,2)); INSERT INTO Factories (id,name,country,water_consumption) VALUES (1,'Factory A','USA',12000.00),(2,'Factory B','Mexico',15000.00),(3,'Factory C','India',8000.00),(4,'Factory D','Bangladesh',10000.00),(5,'Factory E','China',13000.00); | SELECT country, AVG(water_consumption) FROM Factories GROUP BY country; |
How many security incidents were reported in each department in the last 60 days, and what was the highest severity level recorded for each department? | CREATE TABLE incidents (incident_id INT,incident_date DATE,severity INT,department VARCHAR(50)); | SELECT department, COUNT(*) as incident_count, MAX(severity) as max_severity FROM incidents WHERE incident_date >= NOW() - INTERVAL 60 DAY GROUP BY department; |
What is the average CO2 emission of products that are 'recycled' and 'fair_trade' certified? | CREATE TABLE products (product_id INT,product_name VARCHAR(255),certification VARCHAR(255),CO2_emission DECIMAL(10,2));INSERT INTO products VALUES (1,'Product A','recycled',5),(2,'Product B','fair_trade',10),(3,'Product C','organic',15),(4,'Product D','recycled',20),(5,'Product E','fair_trade',25),(6,'Product F','recyc... | SELECT AVG(CO2_emission) FROM products WHERE certification IN ('recycled', 'fair_trade') GROUP BY certification HAVING COUNT(DISTINCT certification) = 2 |
How many mental health parity violations were reported in each state? | CREATE TABLE mental_health_parity_reports (id INT,state VARCHAR(20),violation_count INT); INSERT INTO mental_health_parity_reports (id,state,violation_count) VALUES (1,'California',100),(2,'New York',150),(3,'Texas',120); | SELECT state, SUM(violation_count) as total_violations FROM mental_health_parity_reports GROUP BY state; |
What is the average carbon offset for green building certifications in each country in the European Union? | CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(255),country VARCHAR(255),certification_level VARCHAR(255),carbon_offset_tons INT); CREATE TABLE eu_countries (country_code VARCHAR(255),country_name VARCHAR(255)); | SELECT e.country_name, AVG(g.carbon_offset_tons) FROM green_buildings g INNER JOIN eu_countries e ON g.country = e.country_code GROUP BY e.country_name; |
How many events in CA had more than 300 attendees in the last 3 months? | CREATE TABLE Events (EventID int,EventLocation varchar(50),Attendance int,EventDate date); INSERT INTO Events VALUES (1,'CA Museum',500,'2022-03-15'),(2,'NY Theater',300,'2022-02-01'),(3,'CA Art Gallery',200,'2022-03-01'); | SELECT COUNT(*) FROM Events WHERE EventLocation LIKE '%CA%' AND Attendance > 300 AND EventDate >= (CURRENT_DATE - INTERVAL '3 months'); |
What is the total revenue generated by eco-friendly tours? | CREATE TABLE tours(id INT,name TEXT,eco_friendly BOOLEAN,revenue FLOAT); INSERT INTO tours (id,name,eco_friendly,revenue) VALUES (1,'Amazon Rainforest Tour',TRUE,5000),(2,'City Bus Tour',FALSE,2000); | SELECT SUM(revenue) FROM tours WHERE eco_friendly = TRUE; |
Update the amount of cargo in a cargo handling operation in the "cargo_operations" table | CREATE TABLE cargo_operations (id INT PRIMARY KEY,vessel_id INT,port_id INT,operation_type VARCHAR(255),amount INT,timestamp TIMESTAMP); | UPDATE cargo_operations SET amount = 12000 WHERE id = 1; |
Which marine species are affected by ocean acidification? | CREATE TABLE marine_species (name TEXT,affected_by_ocean_acidification BOOLEAN); INSERT INTO marine_species (name,affected_by_ocean_acidification) VALUES ('Coral',TRUE),('Clownfish',FALSE),('Sea Star',TRUE),('Tuna',FALSE); | SELECT name FROM marine_species WHERE affected_by_ocean_acidification = TRUE; |
What is the average co-ownership price in Seattle? | CREATE TABLE co_ownership (price INT,city VARCHAR(20)); | SELECT AVG(price) FROM co_ownership WHERE city = 'Seattle'; |
List all countries and their total marine conservation area ('mca') size in square kilometers. | CREATE TABLE country (id INT,name VARCHAR(50)); CREATE TABLE mca (id INT,country_id INT,name VARCHAR(50),size_sqkm FLOAT); INSERT INTO country (id,name) VALUES (1,'Australia'),(2,'Canada'); INSERT INTO mca (id,country_id,name,size_sqkm) VALUES (1,1,'Great Barrier Reef',344400),(2,2,'Pacific Rim National Park',51800); | SELECT country.name, SUM(mca.size_sqkm) FROM country INNER JOIN mca ON country.id = mca.country_id GROUP BY country.name; |
Calculate the average financial wellbeing score for women in Southeast Asia. | CREATE TABLE financial_wellbeing (id INT,person_id INT,gender VARCHAR(10),country VARCHAR(255),score FLOAT); INSERT INTO financial_wellbeing (id,person_id,gender,country,score) VALUES (1,123,'Female','Indonesia',75.3),(2,456,'Male','Thailand',82.1),(3,789,'Female','Vietnam',70.9); | SELECT AVG(score) FROM financial_wellbeing WHERE country LIKE 'Southeast%' AND gender = 'Female'; |
What is the highest average weight of packages shipped to each state from the 'southeast' region? | CREATE TABLE warehouses (id INT,name TEXT,region TEXT); INSERT INTO warehouses (id,name,region) VALUES (1,'Atlanta Warehouse','southeast'),(2,'Miami Warehouse','southeast'); CREATE TABLE packages (id INT,warehouse_id INT,weight FLOAT,state TEXT); INSERT INTO packages (id,warehouse_id,weight,state) VALUES (1,1,100.5,'Ge... | SELECT state, MAX(avg_weight) FROM (SELECT state, AVG(weight) as avg_weight FROM packages p JOIN warehouses w ON p.warehouse_id = w.id WHERE w.region = 'southeast' GROUP BY state) sub GROUP BY state; |
How many new male members joined in Q1 2022 from the US? | CREATE TABLE members (member_id INT,gender VARCHAR(10),join_date DATE,country VARCHAR(50)); INSERT INTO members (member_id,gender,join_date,country) VALUES (1,'Female','2021-01-15','Canada'),(2,'Male','2022-03-28','USA'); | SELECT COUNT(*) FROM members WHERE gender = 'Male' AND join_date >= '2022-01-01' AND join_date < '2022-04-01' AND country = 'USA'; |
What is the total number of unique threat indicators in the 'ThreatIntel' table partitioned by type, ordered by the count in descending order? | CREATE TABLE ThreatIntel (indicator_id INT,indicator VARCHAR(50),type VARCHAR(20),timestamp TIMESTAMP); INSERT INTO ThreatIntel (indicator_id,indicator,type,timestamp) VALUES (1,'192.168.1.1','IP','2022-01-01 10:00:00'); | SELECT type, COUNT(DISTINCT indicator) as unique_indicator_count FROM ThreatIntel GROUP BY type ORDER BY unique_indicator_count DESC; |
Identify the number of ad impressions in France for the 'Video' ad format in the last week. | CREATE TABLE ad_impressions (id INT,country VARCHAR(255),ad_format VARCHAR(255),timestamp TIMESTAMP); INSERT INTO ad_impressions (id,country,ad_format,timestamp) VALUES (1,'France','Video','2022-06-01 12:00:00'),(2,'France','Image','2022-06-02 14:30:00'); | SELECT COUNT(*) FROM ad_impressions WHERE country = 'France' AND ad_format = 'Video' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 WEEK); |
Calculate the average calories of all organic dishes | CREATE TABLE dishes (dish_id INT,dish_name TEXT,organic BOOLEAN,calories INT); INSERT INTO dishes (dish_id,dish_name,organic,calories) VALUES (1,'Pizza',false,1200),(2,'Spaghetti',false,1000),(3,'Salad',true,500),(4,'Sushi',true,800); | SELECT AVG(calories) FROM dishes WHERE organic = true; |
What is the minimum amount donated to "disaster_relief" by a unique donor? | CREATE TABLE donations (id INT,donor_id INT,category VARCHAR(255),donation_amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (id,donor_id,category,donation_amount,donation_date) VALUES (1,1001,'disaster_relief',50.00,'2022-01-01'); INSERT INTO donations (id,donor_id,category,donation_amount,donation_date)... | SELECT MIN(donation_amount) FROM donations WHERE category = 'disaster_relief' GROUP BY donor_id HAVING COUNT(donor_id) = 1; |
What is the duration of each lifelong learning event in hours, grouped by location? | CREATE TABLE lifelong_learning_events (id INT,name VARCHAR(50),location VARCHAR(50),start_time TIMESTAMP,end_time TIMESTAMP); INSERT INTO lifelong_learning_events (id,name,location,start_time,end_time) VALUES (1,'Data Science Bootcamp','New York','2023-03-01 09:00:00','2023-03-01 17:00:00'); | SELECT location, TIMESTAMPDIFF(HOUR, start_time, end_time) as duration FROM lifelong_learning_events GROUP BY location; |
Determine the number of climate adaptation projects in the 'projects' table for each region in 2021 | CREATE TABLE projects (project_id INT,project_name VARCHAR(100),year INT,region VARCHAR(50),category VARCHAR(50)); INSERT INTO projects (project_id,project_name,year,region,category) VALUES (1,'Coastal Protection Program',2021,'Asia','Climate Adaptation'),(2,'Urban Flood Resilience Project',2021,'Africa','Climate Adapt... | SELECT region, COUNT(*) as num_projects FROM projects WHERE year = 2021 AND category = 'Climate Adaptation' GROUP BY region; |
Delete mental health parity regulations that have not been implemented by 2013. | CREATE TABLE mental_health_parity (id INT,regulation VARCHAR(100),state VARCHAR(20),implementation_date DATE); INSERT INTO mental_health_parity (id,regulation,state,implementation_date) VALUES (1,'Regulation 1','New York','2011-01-01'),(2,'Regulation 2','Florida','2012-01-01'),(3,'Regulation 3','New York',NULL); | DELETE FROM mental_health_parity WHERE implementation_date IS NULL AND implementation_date < '2013-01-01'; |
How many marine protected areas are in the Southern Ocean? | CREATE TABLE marine_protected_areas (region VARCHAR(20),name VARCHAR(50),size FLOAT); INSERT INTO marine_protected_areas (region,name,size) VALUES ('Southern Ocean','Ross Sea Marine Protected Area',1500000); INSERT INTO marine_protected_areas (region,name,size) VALUES ('Southern Ocean','Weddell Sea Marine Protected Are... | SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Southern Ocean'; |
What is the change in industrial water usage from 2020 to 2021 for each state? | CREATE TABLE industrial_water_usage (state_name TEXT,year INTEGER,usage INTEGER); INSERT INTO industrial_water_usage (state_name,year,usage) VALUES ('California',2020,5000),('California',2021,5200),('Texas',2020,4000),('Texas',2021,4100),('Florida',2020,3500),('Florida',2021,3650),('New York',2020,2500),('New York',202... | SELECT state_name, (LEAD(usage, 1) OVER (PARTITION BY state_name ORDER BY year) - usage) AS change_in_usage FROM industrial_water_usage WHERE year IN (2020, 2021); |
Update the price of a specific autonomous vehicle model in the av_models table. | CREATE TABLE av_models (model_name VARCHAR(255),price DECIMAL(5,2)); | WITH updated_price AS (UPDATE av_models SET price = 95000 WHERE model_name = 'AutoMate X') SELECT * FROM updated_price; |
Which tree species were planted in the year 2005? | CREATE TABLE Planting (id INT,year INT,tree_species_id INT); INSERT INTO Planting (id,year,tree_species_id) VALUES (1,2000,1),(2,2000,2),(3,2005,1),(4,2005,3),(5,2010,2),(6,2010,4); CREATE TABLE TreeSpecies (id INT,name VARCHAR(255)); INSERT INTO TreeSpecies (id,name) VALUES (1,'Pine'),(2,'Oak'),(3,'Maple'),(4,'Birch')... | SELECT DISTINCT ts.name AS tree_species_name FROM Planting p JOIN TreeSpecies ts ON p.tree_species_id = ts.id WHERE p.year = 2005; |
What is the average rating of hotels in the United States that have more than 100 reviews? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,rating FLOAT,num_reviews INT); INSERT INTO hotels (hotel_id,hotel_name,country,rating,num_reviews) VALUES (1,'Hotel A','USA',4.2,120),(2,'Hotel B','USA',4.5,250),(3,'Hotel C','Canada',4.7,80); | SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND num_reviews > 100; |
What is the difference in ocean health metrics between aquaculture sites with organic and non-organic certifications? | CREATE TABLE ocean_health_metrics (site_id INT,certification VARCHAR(50),metric_name VARCHAR(50),value FLOAT); INSERT INTO ocean_health_metrics VALUES (1,'Organic','pH',7.8),(2,'Non-organic','pH',8.1),(3,'Organic','Salinity',1.2),(4,'Non-organic','Salinity',3.5),(5,'Organic','Temperature',15.5),(6,'Non-organic','Temper... | SELECT certification, metric_name, AVG(value) AS avg_value FROM ocean_health_metrics GROUP BY certification, metric_name ORDER BY certification; |
What is the total area of agricultural land in the 'agricultural_land' table, grouped by location? | CREATE TABLE agricultural_land (id INT,location VARCHAR(50),size FLOAT); INSERT INTO agricultural_land (id,location,size) VALUES (1,'Springfield',500.0); INSERT INTO agricultural_land (id,location,size) VALUES (2,'Shelbyville',350.0); INSERT INTO agricultural_land (id,location,size) VALUES (3,'Springfield',750.0); | SELECT location, SUM(size) FROM agricultural_land GROUP BY location; |
List all ships that sank in the Atlantic Ocean since 2000. | CREATE TABLE ships (id INT,name TEXT,sunk_date DATE,sunk_location TEXT); INSERT INTO ships (id,name,sunk_date,sunk_location) VALUES (1,'Titanic','1912-04-15','North Atlantic Ocean'); INSERT INTO ships (id,name,sunk_date,sunk_location) VALUES (2,'Bismarck','1941-05-27','Atlantic Ocean'); | SELECT name FROM ships WHERE sunk_location = 'Atlantic Ocean' AND sunk_date >= '2000-01-01'; |
Calculate the average donation amount for each payment method | CREATE TABLE donations (id INT,donor_id INT,amount DECIMAL(10,2),payment_method VARCHAR(20)); | SELECT payment_method, AVG(amount) as avg_donation_amount FROM donations GROUP BY payment_method; |
What is the total number of medals won by US athletes in the Winter Olympics? | CREATE TABLE medals (id INT,athlete VARCHAR(50),country VARCHAR(50),medal VARCHAR(50),year INT); INSERT INTO medals (id,athlete,country,medal,year) VALUES (1,'Lindsey Vonn','USA','Gold',2010); INSERT INTO medals (id,athlete,country,medal,year) VALUES (2,'Shaun White','USA','Silver',2018); | SELECT COUNT(*) FROM medals WHERE country = 'USA' AND medal IN ('Gold', 'Silver', 'Bronze') AND year BETWEEN 1924 AND 2022 AND sport = 'Winter'; |
List all missions launched from the Vandenberg Air Force Base along with the corresponding spacecraft. | CREATE TABLE Spacecraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),missions_launched INT); INSERT INTO Spacecraft (id,name,manufacturer,missions_launched) VALUES (1,'Spacecraft 1','SpaceX',3),(2,'Spacecraft 2','ULA',2),(3,'Spacecraft 3','SpaceX',1); | SELECT m.mission_name, s.name as spacecraft_name FROM Mission m INNER JOIN Spacecraft s ON m.spacecraft_id = s.id WHERE m.launch_site = 'Vandenberg Air Force Base'; |
What is the distribution of defense contracts by category? | CREATE TABLE contracts (id INT,category VARCHAR(255),value DECIMAL(10,2));INSERT INTO contracts (id,category,value) VALUES (1,'Aircraft',5000000.00),(2,'Missiles',2000000.00),(3,'Shipbuilding',8000000.00),(4,'Cybersecurity',3000000.00),(5,'Aircraft',6000000.00),(6,'Shipbuilding',9000000.00); | SELECT category, SUM(value) as total_value FROM contracts GROUP BY category; |
What is the average number of workers employed in sustainable building projects in each state? | CREATE TABLE Workers (WorkerID INT,ProjectID INT,State CHAR(2),IsSustainable BOOLEAN); | SELECT State, AVG(COUNT(*)) FROM Workers WHERE IsSustainable=TRUE GROUP BY State; |
What are the top 3 countries with the most military equipment imports from the US? | CREATE TABLE imports (country TEXT,import_value DECIMAL(10,2),import_date DATE); INSERT INTO imports VALUES ('Canada',500000,'2021-01-01'),('Mexico',300000,'2021-02-01'),('Brazil',400000,'2021-03-01'); | SELECT country, import_value FROM (SELECT country, import_value, RANK() OVER (PARTITION BY country ORDER BY import_value DESC) AS ranking FROM imports WHERE import_country = 'US') subquery WHERE ranking <= 3; |
Determine the maximum voyage duration for each vessel type in the 'voyage_log' table | CREATE TABLE voyage_log (id INT,vessel_type VARCHAR(50),voyage_duration INT); | SELECT vessel_type, MAX(voyage_duration) FROM voyage_log GROUP BY vessel_type; |
List the number of unique volunteers and total volunteer hours for each disaster response. | CREATE TABLE volunteers (id INT,disaster_id INT,hours FLOAT); CREATE TABLE disasters (id INT,name VARCHAR(255)); | SELECT d.name, COUNT(DISTINCT volunteers.id) as volunteer_count, SUM(volunteers.hours) as total_volunteer_hours FROM disasters d LEFT JOIN volunteers ON d.id = volunteers.disaster_id GROUP BY d.id; |
What are the top 3 countries with the most ethical AI projects, and how many projects are in each? | CREATE TABLE ethical_ai_projects (country VARCHAR(2),project_count INT); INSERT INTO ethical_ai_projects (country,project_count) VALUES ('IN',15),('SG',12),('JP',10),('VN',8),('KR',7); | SELECT country, project_count FROM ethical_ai_projects ORDER BY project_count DESC LIMIT 3; |
Delete the "hotel_review_summary" view | CREATE TABLE hotel_reviews (hotel_id INT,review_date DATE,review_score INT); CREATE VIEW hotel_review_summary AS SELECT hotel_id,COUNT(*),AVG(review_score) FROM hotel_reviews GROUP BY hotel_id; | DROP VIEW hotel_review_summary; |
List the number of races each athlete has participated in the athletics_events table. | CREATE TABLE athletics_events (event_id INT,athlete_name VARCHAR(100),race_count INT); | SELECT athlete_name, SUM(race_count) as total_races FROM athletics_events GROUP BY athlete_name; |
What is the average donation amount by gender? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationAmount DECIMAL,Gender TEXT); INSERT INTO Donors (DonorID,DonorName,DonationAmount,Gender) VALUES (1,'John Doe',500.00,'Male'),(2,'Jane Smith',350.00,'Female'),(3,'Alice Johnson',700.00,'Female'); | SELECT AVG(DonationAmount) as AverageDonation, Gender FROM Donors GROUP BY Gender; |
How many dams are there in the province of Ontario? | CREATE TABLE Dams (DamID INT,Name TEXT,Province TEXT); INSERT INTO Dams (DamID,Name,Province) VALUES (1,'Dam1','Ontario'); INSERT INTO Dams (DamID,Name,Province) VALUES (2,'Dam2','Ontario'); INSERT INTO Dams (DamID,Name,Province) VALUES (3,'Dam3','Quebec'); | SELECT COUNT(*) FROM Dams WHERE Province = 'Ontario'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.