instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Update the record for 'volunteer_management' table, where 'volunteer_id' is 001, and increase the 'hours_served' by 5. | CREATE TABLE volunteer_management (volunteer_id VARCHAR(10),hours_served INT); INSERT INTO volunteer_management (volunteer_id,hours_served) VALUES ('001',25),('002',30); | UPDATE volunteer_management SET hours_served = hours_served + 5 WHERE volunteer_id = '001'; |
Find the top 3 most productive copper mines globally? | CREATE TABLE mine (id INT,name TEXT,location TEXT,mineral TEXT,productivity INT); INSERT INTO mine (id,name,location,mineral,productivity) VALUES (1,'Chuquicamata','Chile','Copper',5000),(2,'Escondida','Chile','Copper',4000),(3,'Grasberg','Indonesia','Copper',3500); | SELECT name, productivity FROM mine WHERE mineral = 'Copper' ORDER BY productivity DESC LIMIT 3; |
What is the total length of all underwater cables in the Indian ocean? | CREATE TABLE underwater_cables (cable_name VARCHAR(255),length FLOAT,ocean VARCHAR(255)); INSERT INTO underwater_cables (cable_name,length,ocean) VALUES ('South Africa-India',8700.5,'Indian Ocean'),('Perth-Dubai',4500.2,'Indian Ocean'); | SELECT SUM(length) FROM underwater_cables WHERE ocean = 'Indian Ocean'; |
Calculate the total loan amount disbursed to microfinance clients in the African continent | CREATE TABLE african_loan_disbursals (id INT PRIMARY KEY,client_name VARCHAR(100),continent VARCHAR(50),loan_amount DECIMAL(10,2)); INSERT INTO african_loan_disbursals (id,client_name,continent,loan_amount) VALUES (1,'Client A','Africa',500.00),(2,'Client B','Europe',700.00),(3,'Client C','Africa',300.00); | SELECT SUM(loan_amount) FROM african_loan_disbursals WHERE continent = 'Africa'; |
How many graduate students are enrolled in the Mathematics or Physics departments? | CREATE TABLE departments (id INT,name VARCHAR(50)); INSERT INTO departments (id,name) VALUES (1,'Mathematics'); INSERT INTO departments (id,name) VALUES (2,'Physics'); CREATE TABLE students (id INT,name VARCHAR(50),department_id INT,level VARCHAR(10)); INSERT INTO students (id,name,department_id,level) VALUES (1,'John ... | SELECT COUNT(*) FROM students WHERE department_id IN (SELECT id FROM departments WHERE name IN ('Mathematics', 'Physics')) AND level = 'Graduate'; |
How many workplace safety violations were reported in the healthcare sector in 2020? | CREATE TABLE healthcare (id INT,year INT,violations INT); INSERT INTO healthcare (id,year,violations) VALUES (1,2018,100),(2,2019,150),(3,2020,200); | SELECT SUM(violations) FROM healthcare WHERE year = 2020; |
List all aquatic species and their respective feed conversion ratios in South American aquaculture facilities. | CREATE TABLE species (species_id INT,species_name VARCHAR(30),region VARCHAR(20),feed_conversion_ratio FLOAT); INSERT INTO species (species_id,species_name,region,feed_conversion_ratio) VALUES (1,'Tilapia','South America',1.6),(2,'Catfish','South America',2.3); | SELECT species_name, feed_conversion_ratio FROM species WHERE region = 'South America'; |
Identify hotels that have adopted AI chatbots for guest services in 'Asia'. | CREATE TABLE hotel_tech (hotel_id INT,hotel_name TEXT,region TEXT,ai_chatbot BOOLEAN); INSERT INTO hotel_tech (hotel_id,hotel_name,region,ai_chatbot) VALUES (1,'Hotel Marina','Asia',TRUE),(2,'Hotel Bellagio','Europe',FALSE); | SELECT hotel_name FROM hotel_tech WHERE region = 'Asia' AND ai_chatbot = TRUE; |
Insert a new record for a song by Taylor Swift | CREATE TABLE songs (id INT PRIMARY KEY,title VARCHAR(100),artist VARCHAR(50),release_date DATE,genre VARCHAR(20)); | INSERT INTO songs (id, title, artist, release_date, genre) VALUES (123, 'Lavender Haze', 'Taylor Swift', '2022-11-10', 'pop'); |
What is the total value of artworks created by female artists from France? | CREATE TABLE Artworks (id INT,value DECIMAL(10,2),artist_id INT); CREATE TABLE Artists (id INT,name VARCHAR(255),nationality VARCHAR(255),gender VARCHAR(10)); INSERT INTO Artists (id,name,nationality,gender) VALUES (1,'Camille Claudel','France','Female'); INSERT INTO Artworks (id,value,artist_id) VALUES (1,5000,1); | SELECT SUM(Artworks.value) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.id WHERE Artists.nationality = 'France' AND Artists.gender = 'Female'; |
How many natural disasters were reported in Tokyo in 2021? | CREATE TABLE natural_disasters (id INT,disaster_date DATE,city VARCHAR(50)); INSERT INTO natural_disasters (id,disaster_date,city) VALUES (1,'2021-07-14','Tokyo'),(2,'2021-11-05','Tokyo'); | SELECT COUNT(*) FROM natural_disasters WHERE disaster_date >= '2021-01-01' AND disaster_date < '2022-01-01' AND city = 'Tokyo'; |
What is the total number of digital attendees in Delhi? | CREATE TABLE Digital_Events (id INT,location VARCHAR(20),attendees INT); INSERT INTO Digital_Events (id,location,attendees) VALUES (1,'Mumbai',25),(2,'Delhi',30); | SELECT SUM(attendees) FROM Digital_Events WHERE location = 'Delhi' |
Delete all articles that have zero pageviews from the "articles" table | CREATE TABLE articles (article_id INT,title VARCHAR(255),publication_date DATE,author_id INT,pageviews INT); | DELETE FROM articles WHERE pageviews = 0; |
What is the rank of XYZ Microfinance based on the number of loans disbursed in Europe? | CREATE SCHEMA if not exists finance;CREATE TABLE if not exists loans (id INT PRIMARY KEY,institution_name TEXT,region TEXT,number_of_loans INT); INSERT INTO loans (id,institution_name,region,number_of_loans) VALUES (1,'ABC Microfinance','Europe',300),(2,'DEF Microfinance','Europe',400),(3,'GHI Microfinance','Europe',25... | SELECT institution_name, ROW_NUMBER() OVER (ORDER BY number_of_loans DESC) as rank FROM finance.loans WHERE region = 'Europe' AND institution_name = 'XYZ Microfinance'; |
What are the details of the investments with an ESG score greater than 7.5 in the renewable energy sector? | CREATE TABLE esg_factors (id INT,company VARCHAR(255),environment FLOAT,social FLOAT,governance FLOAT); INSERT INTO esg_factors (id,company,environment,social,governance) VALUES (1,'Tesla Inc.',8.5,9.0,8.0),(2,'SolarCity',8.0,8.5,8.5); CREATE TABLE impact_investments (id INT,sector VARCHAR(255),project VARCHAR(255),loc... | SELECT i.project, i.location, i.amount, e.environment, e.social, e.governance FROM impact_investments i INNER JOIN esg_factors e ON i.sector = e.company WHERE e.environment + e.social + e.governance > 7.5 AND i.sector = 'Renewable Energy'; |
Delete records from the "military_equipment" table where the "equipment_type" is "aircraft" and "manufactured_year" is before 1990 | CREATE TABLE military_equipment (equipment_id INT PRIMARY KEY,equipment_type VARCHAR(50),manufactured_year INT); INSERT INTO military_equipment (equipment_id,equipment_type,manufactured_year) VALUES (1,'aircraft',1985),(2,'tank',2000),(3,'ship',1965); | DELETE FROM military_equipment WHERE equipment_type = 'aircraft' AND manufactured_year < 1990; |
What is the total number of articles and the average age of users who liked them, for each gender? | CREATE TABLE users (user_id INT,age INT,gender VARCHAR(10)); INSERT INTO users (user_id,age,gender) VALUES (1,25,'Female'),(2,35,'Male'); CREATE TABLE articles (article_id INT,title VARCHAR(50),category VARCHAR(20)); INSERT INTO articles (article_id,title,category) VALUES (1,'Climate Crisis 101','climate_change'),(2,'E... | SELECT gender, COUNT(*) as article_count, AVG(age) as avg_age FROM users JOIN likes ON users.user_id = likes.user_id JOIN articles ON likes.article_id = articles.article_id GROUP BY gender; |
What was the change in rural road density in India between 2015 and 2020? | CREATE TABLE road_density (country VARCHAR(50),year INT,density FLOAT); INSERT INTO road_density (country,year,density) VALUES ('India',2015,0.6),('India',2020,0.7); | SELECT (b.density - a.density) AS change_in_density FROM road_density a, road_density b WHERE a.country = 'India' AND b.country = 'India' AND a.year = 2015 AND b.year = 2020; |
List all records from the trip table for shared mobility users in New York. | CREATE TABLE trip (id INT PRIMARY KEY,user_id INT,trip_start_time TIMESTAMP,trip_end_time TIMESTAMP,trip_mode VARCHAR(255),trip_distance FLOAT); INSERT INTO trip (id,user_id,trip_start_time,trip_end_time,trip_mode,trip_distance) VALUES (1,1001,'2022-01-01 08:00:00','2022-01-01 08:30:00','Bike Share',5.0),(2,1002,'2022-... | SELECT * FROM trip WHERE trip_mode IN ('Bike Share', 'E-Scooter', 'Microtransit') AND user_id IN (SELECT DISTINCT user_id FROM trip WHERE location = 'New York'); |
Which media literacy programs have the highest and lowest average scores, and what are those scores? | CREATE TABLE programs (id INT,name VARCHAR(50),score INT); INSERT INTO programs (id,name,score) VALUES (1,'Media Matters',85),(2,'News Literacy Project',88),(3,'Common Sense Media',82); | SELECT name, score as highest_score FROM programs WHERE score = (SELECT MAX(score) FROM programs) UNION SELECT name, score as lowest_score FROM programs WHERE score = (SELECT MIN(score) FROM programs); |
Find the average donation amount for donors who identify as female in the last year. | CREATE TABLE donors (id INT,total_donations INT,last_donation_date DATE,gender VARCHAR(10)); INSERT INTO donors (id,total_donations,last_donation_date,gender) VALUES (1,2,'2021-06-01','female'),(2,1,'2022-02-15','male'),(3,3,'2021-12-31','non-binary'); | SELECT AVG(total_donations) FROM donors WHERE last_donation_date > DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND gender = 'female'; |
Delete all records from the 'water_quality_tests' table where the 'test_date' is before '2021-01-01' | CREATE TABLE water_quality_tests (id INT PRIMARY KEY,test_date DATE,region VARCHAR(20),test_result FLOAT); | DELETE FROM water_quality_tests WHERE test_date < '2021-01-01'; |
Delete all records of fish species that are not native to Europe in the past month. | CREATE TABLE fish (id INT,species VARCHAR(255),water_temp FLOAT,date DATE); CREATE TABLE species_info (id INT,species VARCHAR(255),native_continent VARCHAR(255)); | DELETE FROM fish WHERE species NOT IN (SELECT species FROM species_info WHERE native_continent = 'Europe') AND date >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '1 month'; |
Select the average price of all items made of organic cotton | CREATE TABLE products (id INT,name VARCHAR(255),material VARCHAR(255),price DECIMAL(5,2)); INSERT INTO products (id,name,material,price) VALUES (1,'T-Shirt','organic cotton',25.99),(2,'Pants','organic cotton',39.99); | SELECT AVG(price) FROM products WHERE material = 'organic cotton'; |
What is the total number of economic diversification efforts in 'economic_diversification' table, grouped by year? | CREATE TABLE economic_diversification (id INT,initiative_name VARCHAR(50),year INT); INSERT INTO economic_diversification (id,initiative_name,year) VALUES (1,'Renewable Energy',2020); INSERT INTO economic_diversification (id,initiative_name,year) VALUES (2,'Tourism',2019); | SELECT year, COUNT(*) FROM economic_diversification GROUP BY year; |
What is the total cost of all space exploration projects led by NASA in the last 10 years? | CREATE TABLE SpaceProjects (ProjectID INT,Name VARCHAR(100),Agency VARCHAR(50),Cost FLOAT,StartDate DATE,EndDate DATE); | SELECT SUM(Cost) FROM SpaceProjects WHERE Agency = 'NASA' AND StartDate >= DATEADD(year, -10, GETDATE()); |
What is the total number of green buildings in the state of Texas that have been certified since the year 2010? | CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(255),certification_date DATE); | SELECT COUNT(*) FROM green_buildings WHERE state = 'Texas' AND certification_date >= '2010-01-01'; |
List all the construction permits issued in the state of California in 2021. | CREATE TABLE Construction_Permits (id INT,permit_number VARCHAR(20),issue_date DATE,state VARCHAR(20)); INSERT INTO Construction_Permits (id,permit_number,issue_date,state) VALUES (1,'CP12345','2021-01-01','California'); | SELECT permit_number FROM Construction_Permits WHERE issue_date >= '2021-01-01' AND issue_date < '2022-01-01' AND state = 'California'; |
Which smart contracts were deployed in the last 30 days and have the highest gas consumption? | CREATE TABLE smart_contracts (id INT,name VARCHAR(50),gas_consumption INT,deployment_date DATE); INSERT INTO smart_contracts (id,name,gas_consumption,deployment_date) VALUES (1,'Contract1',100,'2022-01-01'),(2,'Contract2',200,'2022-02-01'); | SELECT name, gas_consumption FROM (SELECT name, gas_consumption, RANK() OVER (ORDER BY gas_consumption DESC) as rank, ROW_NUMBER() OVER (ORDER BY deployment_date DESC) as row_num FROM smart_contracts WHERE deployment_date >= '2022-06-01') x WHERE row_num <= 30; |
Rank ingredients based on their usage frequency, for ingredients with a frequency greater than 50, partitioned by ingredient and ordered by usage frequency in descending order. | CREATE TABLE IngredientUsage (ProductID INT,Ingredient VARCHAR(100),UsageFrequency INT); INSERT INTO IngredientUsage (ProductID,Ingredient,UsageFrequency) VALUES (1,'Water',100); INSERT INTO IngredientUsage (ProductID,Ingredient,UsageFrequency) VALUES (2,'Glycerin',75); | SELECT ProductID, Ingredient, UsageFrequency, RANK() OVER (PARTITION BY Ingredient ORDER BY UsageFrequency DESC) as 'Rank' FROM IngredientUsage WHERE UsageFrequency > 50; |
Find the average donation amount by gender? | CREATE TABLE Donations (donation_id INT,donor_id INT,amount DECIMAL(5,2),gender VARCHAR(10)); INSERT INTO Donations (donation_id,donor_id,amount,gender) VALUES (1,1,100.00,'Male'),(2,2,200.00,'Female'); | SELECT gender, AVG(amount) as avg_donation FROM Donations GROUP BY gender; |
What is the minimum capacity of any wind farm in the 'renewables' schema? | CREATE SCHEMA renewables; CREATE TABLE wind_farms (name TEXT,capacity INTEGER); INSERT INTO wind_farms (name,capacity) VALUES ('Farm A',500),('Farm B',750); | SELECT MIN(capacity) FROM renewables.wind_farms; |
What is the average salary for female reporters 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) | SELECT AVG(salary) FROM reporters WHERE gender = 'Female'; |
Update the 'IncidentType' for the record with 'IncidentID' 123 in the 'Incidents' table to 'Theft' | CREATE TABLE Incidents (IncidentID INT PRIMARY KEY,IncidentType VARCHAR(50),ResponseTime INT); | UPDATE Incidents SET IncidentType = 'Theft' WHERE IncidentID = 123; |
What is the total number of trees in the forest_inventory table, grouped by their diameter class? | CREATE TABLE forest_inventory (tree_id INT,diameter_class VARCHAR(50)); | SELECT diameter_class, COUNT(*) FROM forest_inventory GROUP BY diameter_class; |
How many safety incidents occurred for each AI model, ordered by the number of incidents in descending order? | CREATE TABLE safety_incidents (incident_id INT PRIMARY KEY,model_id INT,incident_date DATE,FOREIGN KEY (model_id) REFERENCES ai_models(model_id)); INSERT INTO safety_incidents (incident_id,model_id,incident_date) VALUES (1,1,'2021-01-01'),(2,2,'2021-02-01'),(3,1,'2021-03-01'),(4,3,'2021-04-01'),(5,2,'2021-05-01'); | SELECT model_id, COUNT(*) as num_incidents FROM safety_incidents GROUP BY model_id ORDER BY num_incidents DESC; |
How many patients have been treated in the therapy_sessions table? | CREATE TABLE therapy_sessions (session_id INT,patient_id INT,therapist_id INT,session_date DATE,session_duration TIME); | SELECT COUNT(DISTINCT patient_id) FROM therapy_sessions; |
What is the percentage change in the price of each cryptocurrency in the last 7 days? | CREATE TABLE cryptocurrencies (id INT,name VARCHAR(50),price INT,timestamp TIMESTAMP); INSERT INTO cryptocurrencies (id,name,price,timestamp) VALUES (1,'Crypto1',100,'2022-01-01 00:00:00'),(2,'Crypto2',200,'2022-02-01 00:00:00'); | SELECT name, (LAG(price) OVER (PARTITION BY name ORDER BY timestamp) - price) / ABS(LAG(price) OVER (PARTITION BY name ORDER BY timestamp)) AS percentage_change FROM cryptocurrencies WHERE timestamp >= '2022-06-01' AND timestamp < '2022-07-01'; |
Insert a new record into the "warehouses" table with the following data: "name" = "Seattle Warehouse", "capacity" = 10000, "country" = "USA" | CREATE TABLE warehouses (name VARCHAR(50),capacity INT,country VARCHAR(50)); | INSERT INTO warehouses (name, capacity, country) VALUES ('Seattle Warehouse', 10000, 'USA'); |
Which excavation site has the most total artifacts? | CREATE TABLE excavation_sites (id INT,site_name VARCHAR(255)); CREATE TABLE artifacts (id INT,excavation_site_id INT,artifact_type VARCHAR(255)); | SELECT e.site_name, COUNT(a.id) AS total_artifacts FROM excavation_sites e JOIN artifacts a ON e.id = a.excavation_site_id GROUP BY e.site_name ORDER BY total_artifacts DESC LIMIT 1; |
What is the total number of emergency calls during rush hours in 'Riverview'? | CREATE TABLE emergencies (id INT,hour INT,neighborhood VARCHAR(20),response_time FLOAT); INSERT INTO emergencies (id,hour,neighborhood,response_time) VALUES (1,8,'Northside',7.5),(2,17,'Riverview',6.3),(3,17,'Downtown',8.1),(4,17,'Riverview',6.8),(5,8,'Northside',7.9); | SELECT COUNT(*) FROM emergencies WHERE neighborhood = 'Riverview' AND hour IN (7, 8, 16, 17, 18); |
What is the total number of sea turtle sightings in all oceans in 2022? | CREATE TABLE sea_turtle_sightings_2022 (ocean VARCHAR(255),num_sightings INT); INSERT INTO sea_turtle_sightings_2022 (ocean,num_sightings) VALUES ('Atlantic',150),('Pacific',210),('Indian',180),('Arctic',120),('Southern',100); | SELECT SUM(num_sightings) FROM sea_turtle_sightings_2022; |
What is the total carbon pricing revenue in the European Union, the UK, and the US, and what is the percentage contribution of each? | CREATE TABLE carbon_pricing (country VARCHAR(20),revenue INT); INSERT INTO carbon_pricing (country,revenue) VALUES ('European Union',50000),('UK',30000),('US',60000); | SELECT c1.country, c1.revenue, (c1.revenue * 100.0 / SUM(c1.revenue)) as percentage FROM carbon_pricing c1 WHERE c1.country IN ('European Union', 'UK', 'US') GROUP BY c1.country; |
What is the average waste generation metric in India and China for the year 2016? | CREATE TABLE waste_generation (country TEXT,year INTEGER,metric FLOAT); INSERT INTO waste_generation (country,year,metric) VALUES ('India',2016,1.8),('India',2017,2.1),('China',2016,5.2),('China',2017,5.5); | SELECT AVG(metric) FROM waste_generation WHERE country IN ('India', 'China') AND year = 2016; |
What are the most common vulnerabilities in the 'vulnerabilities' table, and how many systems are affected by each? | CREATE TABLE vulnerabilities (id INT,vulnerability VARCHAR(100),systems_affected INT); INSERT INTO vulnerabilities (id,vulnerability,systems_affected) VALUES (1,'SQL Injection',20),(2,'Cross-site Scripting',30),(3,'Remote Code Execution',15),(4,'SQL Injection',10),(5,'Cross-site Scripting',25); | SELECT vulnerability, systems_affected, COUNT(*) as count FROM vulnerabilities GROUP BY vulnerability ORDER BY count DESC; |
How many members are there in the Accessibility team as of 2022-07-01? | CREATE TABLE team_membership (id INT,name VARCHAR(50),team VARCHAR(50),join_date DATE); INSERT INTO team_membership (id,name,team,join_date) VALUES (1,'Hana','Accessibility','2022-06-15'),(2,'Ibrahim','Data Science','2022-08-01'),(3,'Jasmine','Accessibility','2022-05-30'); | SELECT COUNT(*) FROM team_membership WHERE team = 'Accessibility' AND join_date <= '2022-07-01'; |
What is the total number of vessels inspected in each region for maritime law compliance, along with the inspection year? | CREATE TABLE vessel_inspection (region VARCHAR(50),inspection_year INT,inspection BOOLEAN); INSERT INTO vessel_inspection VALUES ('Region 1',2021,TRUE),('Region 1',2022,TRUE),('Region 2',2021,FALSE); | SELECT region, COUNT(*) as total_inspections, EXTRACT(YEAR FROM inspection_year) as inspection_year FROM vessel_inspection WHERE inspection = TRUE GROUP BY region, inspection_year; |
What is the total value of defense contracts awarded to foreign companies? | CREATE TABLE defense_contracts (contractor_name VARCHAR(255),contract_value FLOAT,is_foreign_company BOOLEAN); INSERT INTO defense_contracts (contractor_name,contract_value,is_foreign_company) VALUES ('BAE Systems',1000000000,true),('Airbus',800000000,true),('Leonardo',700000000,true),('Saab',600000000,true),('Thales',... | SELECT SUM(contract_value) FROM defense_contracts WHERE is_foreign_company = true; |
What is the oldest artwork ('artwork' table) for each artist in the 'artist_demographics' table? | CREATE TABLE artist_demographics (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),nationality VARCHAR(50));CREATE TABLE artwork (id INT,title VARCHAR(50),year INT,artist_id INT,medium VARCHAR(50)); | SELECT a.name, MIN(artwork.year) AS min_year FROM artist_demographics a JOIN artwork ON a.id = artwork.artist_id GROUP BY a.id; |
How many fishing vessels are registered in each sea? | CREATE TABLE fishing_vessels (id INT,name VARCHAR(255),sea VARCHAR(50)); INSERT INTO fishing_vessels (id,name,sea) VALUES (1,'Fishing Vessel 1','Mediterranean'),(2,'Fishing Vessel 2','Mediterranean'),(3,'Fishing Vessel 3','Aegean'); | SELECT sea, COUNT(*) FROM fishing_vessels GROUP BY sea; |
What is the average runtime for movies produced by studios located in the United Kingdom and Ireland? | CREATE TABLE movie_run_time (id INT,studio VARCHAR(255),run_time INT); INSERT INTO movie_run_time (id,studio,run_time) VALUES (1,'Working Title Films',120); INSERT INTO movie_run_time (id,studio,run_time) VALUES (2,'Element Pictures',90); INSERT INTO movie_run_time (id,studio,run_time) VALUES (3,'Film4',105); INSERT IN... | SELECT AVG(run_time) FROM movie_run_time WHERE studio IN (SELECT studio_name FROM movie_studios WHERE country IN ('United Kingdom', 'Ireland')); |
Identify the top 3 most active users by total workout duration, for users living in 'New York'. | CREATE TABLE Workouts (user_id INT,workout_duration INT,city VARCHAR(20)); INSERT INTO Workouts (user_id,workout_duration,city) VALUES (1,120,'New York'),(2,150,'Los Angeles'),(3,180,'New York'),(4,100,'Chicago'); | SELECT user_id, SUM(workout_duration) as total_duration FROM Workouts WHERE city = 'New York' GROUP BY user_id ORDER BY total_duration DESC LIMIT 3; |
How many mobile and broadband subscribers are there in each age group? | CREATE TABLE subscriber_demographics (subscriber_id INT,subscriber_type VARCHAR(10),age INT); INSERT INTO subscriber_demographics (subscriber_id,subscriber_type,age) VALUES (1,'Mobile',25),(2,'Broadband',35),(3,'Mobile',45); | SELECT subscriber_type, FLOOR(age/10)*10 AS age_group, COUNT(*) AS subscriber_count FROM subscriber_demographics GROUP BY subscriber_type, age_group; |
Identify the average ticket price for cultural events in Paris, France. | CREATE TABLE cultural_events (id INT,event_name VARCHAR(255),city VARCHAR(255),ticket_price DECIMAL(5,2)); INSERT INTO cultural_events (id,event_name,city,ticket_price) VALUES (1,'Theatre Play','Paris',30.50),(2,'Art Exhibition','Paris',25.00),(3,'Music Concert','Berlin',40.00); | SELECT AVG(ticket_price) FROM cultural_events WHERE city = 'Paris'; |
What is the maximum number of working hours per week for fair trade certified manufacturers in Asia? | CREATE TABLE fair_trade_manufacturers (id INT,manufacturer VARCHAR(255),asian_country VARCHAR(255),working_hours INT); INSERT INTO fair_trade_manufacturers VALUES (1,'Manufacturer D','China',48),(2,'Manufacturer E','India',45),(3,'Manufacturer F','Vietnam',50),(4,'Manufacturer G','Bangladesh',55); | SELECT MAX(working_hours) FROM fair_trade_manufacturers WHERE asian_country IN ('China', 'India', 'Vietnam', 'Bangladesh'); |
Find the number of electric vehicles (EVs) in each city | CREATE TABLE cities (city_id INT,city_name VARCHAR(50));CREATE TABLE ev_sales (sale_id INT,ev_type VARCHAR(50),sale_city INT);INSERT INTO cities (city_id,city_name) VALUES (1,'San Francisco'),(2,'New York');INSERT INTO ev_sales (sale_id,ev_type,sale_city) VALUES (1,'Tesla',1),(2,'Nissan Leaf',2),(3,'Chevy Bolt',1); | SELECT c.city_name, COUNT(es.ev_type) as num_evs FROM cities c JOIN ev_sales es ON c.city_id = es.sale_city GROUP BY c.city_name; |
Which players have made purchases worth over $100 in the 'purchases' table, and what are their names? | CREATE TABLE players (player_id INT,name VARCHAR(50)); INSERT INTO players VALUES (1,'Amina'); INSERT INTO players VALUES (2,'Brian'); INSERT INTO players VALUES (3,'Chloe'); CREATE TABLE purchases (purchase_id INT,player_id INT,amount DECIMAL(5,2)); INSERT INTO purchases VALUES (1,1,50); INSERT INTO purchases VALUES (... | SELECT p.name FROM players p JOIN purchases pc ON p.player_id = pc.player_id WHERE pc.amount > 100 GROUP BY p.player_id; |
What is the percentage of visitors aged 18-24 who engaged with digital events? | CREATE TABLE EventParticipation (id INT,visitor_age INT,event_id INT); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM EventParticipation WHERE visitor_age BETWEEN 18 AND 24)) |
List the names and titles of all papers published by graduate students who have received a research grant. | CREATE TABLE graduate_students (student_id INT,name VARCHAR(50)); CREATE TABLE grants (grant_id INT,student_id INT); CREATE TABLE publications (publication_id INT,title VARCHAR(50),student_id INT); INSERT INTO graduate_students VALUES (1,'Alice Johnson'); INSERT INTO graduate_students VALUES (2,'Bob Smith'); INSERT INT... | SELECT graduate_students.name, publications.title FROM graduate_students INNER JOIN grants ON graduate_students.student_id = grants.student_id INNER JOIN publications ON graduate_students.student_id = publications.student_id; |
What is the total revenue generated from eco-friendly tours? | CREATE TABLE tour_packages (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),revenue FLOAT); | SELECT SUM(revenue) FROM tour_packages WHERE type = 'Eco-friendly'; |
What percentage of patients in India have been treated with medication? | CREATE TABLE patients (id INT,country VARCHAR(255));CREATE TABLE treatments (id INT,patient_id INT,treatment VARCHAR(255)); INSERT INTO patients (id,country) VALUES (1,'India'),(2,'USA'),(3,'Canada'); INSERT INTO treatments (id,patient_id,treatment) VALUES (1,1,'Medication'),(2,2,'CBT'),(3,3,'DBT'); | SELECT 100.0 * COUNT(DISTINCT CASE WHEN treatments.treatment = 'Medication' THEN patients.id END) / COUNT(DISTINCT patients.id) AS percentage FROM patients LEFT JOIN treatments ON patients.id = treatments.patient_id WHERE patients.country = 'India'; |
Which public health programs in New York have a budget greater than $600,000, ranked by budget? | CREATE TABLE public_health_programs (id INT,name VARCHAR,city VARCHAR,state VARCHAR,country VARCHAR,budget DECIMAL(10,2)); INSERT INTO public_health_programs (id,name,city,state,country,budget) VALUES (1,'NYC Healthy Lives','New York','NY','USA',700000); INSERT INTO public_health_programs (id,name,city,state,country,bu... | SELECT public_health_programs.*, ROW_NUMBER() OVER(PARTITION BY public_health_programs.state ORDER BY public_health_programs.budget DESC) as rank FROM public_health_programs WHERE public_health_programs.state = 'NY' AND public_health_programs.budget > 600000; |
What is the number of employees who have completed technical and non-technical training, by department? | CREATE TABLE departments (dept_id INT,dept_name TEXT); INSERT INTO departments (dept_id,dept_name) VALUES (1,'HR'),(2,'IT'),(3,'Sales'); CREATE TABLE employees (employee_id INT,name TEXT,dept_id INT,technical_training BOOLEAN,non_technical_training BOOLEAN); INSERT INTO employees (employee_id,name,dept_id,technical_tra... | SELECT dept_name, SUM(CASE WHEN technical_training THEN 1 ELSE 0 END) AS num_technical_trained, SUM(CASE WHEN non_technical_training THEN 1 ELSE 0 END) AS num_non_technical_trained FROM employees JOIN departments ON employees.dept_id = departments.dept_id GROUP BY dept_name; |
Delete records in the 'public_transportation' table where 'route_length' is less than 10 miles | CREATE TABLE public_transportation (id INT,route_id VARCHAR(255),route_length FLOAT,type VARCHAR(255)); | DELETE FROM public_transportation WHERE route_length < 10; |
What is the minimum allocation for a climate finance project in Least Developed Countries (LDCs) in the second half of 2021? | CREATE TABLE climate_finance_projects (project_id INT,project_name VARCHAR(255),allocation DECIMAL(10,2),year INT,month INT,region VARCHAR(255)); INSERT INTO climate_finance_projects (project_id,project_name,allocation,year,month,region) VALUES (1,'LDCs Green Bond Issue',3000000,2021,7,'Least Developed Countries'),(2,'... | SELECT MIN(allocation) FROM climate_finance_projects WHERE year = 2021 AND month BETWEEN 7 AND 12 AND region = 'Least Developed Countries'; |
What is the average energy storage cost (USD/kWh) in South Korea since 2017? | CREATE TABLE energy_storage_cost (id INT,name TEXT,country TEXT,cost FLOAT,year INT); INSERT INTO energy_storage_cost (id,name,country,cost,year) VALUES (1,'Lotte ESS','South Korea',245,2017),(2,'SK ESS','South Korea',225,2018); | SELECT AVG(cost) FROM energy_storage_cost WHERE country = 'South Korea' AND year >= 2017; |
Insert a new record for a vendor named 'MNO Corp' with a contract_value of $1,000,000 in the 'defense_contracts' table | CREATE TABLE defense_contracts (contract_id INT,vendor_name VARCHAR(255),contract_value FLOAT); INSERT INTO defense_contracts (contract_id,vendor_name,contract_value) VALUES (1,'ABC Corp',2500000.00),(2,'DEF Inc',1500000.00),(3,'GHI Ltd',3000000.00),(4,'JKL Enterprises',1750000.00); | INSERT INTO defense_contracts (vendor_name, contract_value) VALUES ('MNO Corp', 1000000.00); |
What is the total number of shelters and their capacities in Kenya and South Africa? | CREATE TABLE shelters (id INT,country VARCHAR(255),name VARCHAR(255),capacity INT); INSERT INTO shelters (id,country,name,capacity) VALUES (1,'Kenya','Shelter 1',200),(2,'Kenya','Shelter 2',300),(3,'South Africa','Shelter 3',250),(4,'South Africa','Shelter 4',350); | SELECT SUM(capacity) FROM shelters WHERE country IN ('Kenya', 'South Africa'); |
Insert a new record into the 'wells' table for a well named 'Well D' located in the North Sea with a production quantity of 400 and a start date of 2022-05-01. | CREATE TABLE wells (well_id INT,well_name TEXT,location TEXT,production_qty INT,start_date DATE); | INSERT INTO wells (well_name, location, production_qty, start_date) VALUES ('Well D', 'North Sea', 400, '2022-05-01'); |
Identify the number of mental health providers in each county with a population below 50,000. | CREATE TABLE mental_health_providers (id INT,county VARCHAR(20),provider_type VARCHAR(20)); INSERT INTO mental_health_providers (id,county,provider_type) VALUES (1,'Daviess County','Psychiatrist'); CREATE TABLE counties (county VARCHAR(20),state VARCHAR(2),pop INT); INSERT INTO counties (county,state,pop) VALUES ('Davi... | SELECT h.county, COUNT(h.id) FROM mental_health_providers h JOIN counties c ON h.county = c.county WHERE c.pop < 50000 GROUP BY h.county; |
What are the names of the companies that produced devices in the 'Latin America' region? | CREATE TABLE DevicesRegion (id INT,company VARCHAR(255),region VARCHAR(255)); INSERT INTO DevicesRegion (id,company,region) VALUES (1,'TechLatina','Latin America'),(2,'InnoBrazil','Latin America'); | SELECT company FROM DevicesRegion WHERE region = 'Latin America'; |
What is the average amount of donations received by organizations located in Asia? | CREATE TABLE organizations (id INT,name TEXT,location TEXT);CREATE TABLE donations (id INT,organization_id INT,amount DECIMAL(10,2)); INSERT INTO organizations (id,name,location) VALUES (1,'Organization A','Asia'),(2,'Organization B','Europe'); INSERT INTO donations (id,organization_id,amount) VALUES (1,1,500.00),(2,1,... | SELECT AVG(d.amount) FROM donations d INNER JOIN organizations o ON d.organization_id = o.id WHERE o.location = 'Asia'; |
Find the AI models that have a higher safety score than their fairness score. | CREATE TABLE ai_models (model_name TEXT,safety_score INTEGER,fairness_score INTEGER); INSERT INTO ai_models (model_name,safety_score,fairness_score) VALUES ('ModelA',85,80),('ModelB',75,90),('ModelC',90,88); | SELECT model_name FROM ai_models WHERE safety_score > fairness_score; |
What is the total quantity of product A sold in the year 2021? | CREATE TABLE sales (product_id VARCHAR(255),sale_date DATE,quantity INT); INSERT INTO sales (product_id,sale_date,quantity) VALUES ('A','2021-01-01',5),('A','2021-01-02',3),('B','2021-01-01',7); | SELECT SUM(quantity) FROM sales WHERE product_id = 'A' AND YEAR(sale_date) = 2021; |
How many affordable housing units are there in total? | CREATE TABLE housing (id INT,affordable BOOLEAN); | SELECT COUNT(id) FROM housing WHERE affordable = TRUE; |
Add a new cruelty-free certification to the cosmetics."certifications" table | CREATE TABLE cosmetics.certifications (certification_id INT,certification_name VARCHAR(255),awarded_by VARCHAR(255)); INSERT INTO cosmetics.certifications (certification_id,certification_name,awarded_by) VALUES (1,'Leaping Bunny','CCIC'),(2,'Cruelty Free','PETA'); | INSERT INTO cosmetics.certifications (certification_id, certification_name, awarded_by) VALUES (3, 'Choose Cruelty Free', 'CCF'); |
Which cities have the most number of fans in the fan_demographics table? | CREATE TABLE fan_demographics (fan_id INT,name VARCHAR(50),age INT,city VARCHAR(50)); INSERT INTO fan_demographics (fan_id,name,age,city) VALUES (1,'John Doe',25,'New York'),(2,'Jane Smith',30,'Los Angeles'),(3,'Jim Brown',35,'New York'); | SELECT city, COUNT(*) as num_fans FROM fan_demographics GROUP BY city ORDER BY num_fans DESC; |
Show the energy efficiency (kWh/m2) of buildings in Tokyo | CREATE TABLE building_efficiency (id INT,city VARCHAR(50),efficiency FLOAT); INSERT INTO building_efficiency (id,city,efficiency) VALUES (1,'Tokyo',120),(2,'Osaka',110),(3,'Seoul',130); | SELECT efficiency FROM building_efficiency WHERE city = 'Tokyo'; |
What is the average age of community health workers by cultural competency training status? | CREATE TABLE community_health_workers (worker_id INT,age INT,cultural_competency_training VARCHAR(10)); INSERT INTO community_health_workers (worker_id,age,cultural_competency_training) VALUES (1,45,'Yes'),(2,35,'No'),(3,50,'Yes'),(4,40,'Yes'),(5,30,'No'); | SELECT AVG(age), cultural_competency_training FROM community_health_workers GROUP BY cultural_competency_training; |
Show the names of suppliers that provide materials for at least 2 products in 'Category 1'. | CREATE TABLE products (product_id INT,product_category TEXT); CREATE TABLE materials (material_id INT,material_name TEXT,product_id INT,supplier_id INT); INSERT INTO products (product_id,product_category) VALUES (1,'Category 1'),(2,'Category 2'),(3,'Category 1'),(4,'Category 3'),(5,'Category 1'); INSERT INTO materials ... | SELECT supplier_id FROM materials WHERE product_id IN (SELECT product_id FROM products WHERE product_category = 'Category 1') GROUP BY supplier_id HAVING COUNT(DISTINCT product_id) >= 2; |
What is the total number of fans who participated in athlete wellbeing programs by age group? | CREATE TABLE WellbeingPrograms (ProgramID INT,ProgramName VARCHAR(255),AgeGroup VARCHAR(255)); INSERT INTO WellbeingPrograms (ProgramID,ProgramName,AgeGroup) VALUES (1,'Yoga','18-25'),(2,'Meditation','26-35'),(3,'Strength Training','36-45'); CREATE TABLE Participants (ParticipantID INT,Age INT,ProgramID INT); INSERT IN... | SELECT w.ProgramName, p.AgeGroup, COUNT(*) as Total_Participants FROM Participants p JOIN WellbeingPrograms w ON p.ProgramID = w.ProgramID GROUP BY w.ProgramName, p.AgeGroup; |
What is the total quantity of goods shipped from all ports grouped by carrier? | CREATE TABLE ports (port_code CHAR(3),port_name VARCHAR(20)); INSERT INTO ports (port_code,port_name) VALUES ('LA','Los Angeles'),('NY','New York'),('MIA','Miami'),('HOU','Houston'),('SFO','San Francisco'); CREATE TABLE carriers (carrier_code CHAR(3),carrier_name VARCHAR(20)); INSERT INTO carriers (carrier_code,carrier... | SELECT carriers.carrier_name, SUM(shipments.quantity) as total_quantity FROM shipments JOIN carriers ON shipments.carrier_code = carriers.carrier_code GROUP BY carriers.carrier_name; |
What is the average number of research grants obtained by female faculty members in the Engineering department? | CREATE TABLE faculty (id INT,name VARCHAR(50),department VARCHAR(50),gender VARCHAR(10),race VARCHAR(30),hire_date DATE); INSERT INTO faculty (id,name,department,gender,race,hire_date) VALUES (1,'Faculty Member','Engineering','Female','Asian','2015-08-01'); CREATE TABLE grants (id INT,title VARCHAR(100),pi_name VARCHAR... | SELECT AVG(grant_count) FROM (SELECT pi_gender, pi_department, COUNT(*) as grant_count FROM grants WHERE pi_gender = 'Female' AND pi_department = 'Engineering' GROUP BY pi_gender, pi_department) AS subquery WHERE subquery.pi_gender = 'Female'; |
Delete records of athletes who haven't participated in any events | CREATE TABLE athletes (athlete_id INT,name VARCHAR(50),sport VARCHAR(50)); INSERT INTO athletes (athlete_id,name,sport) VALUES (1,'John Doe','Basketball'),(2,'Jane Smith','Soccer'); CREATE TABLE events (event_id INT,event_name VARCHAR(50),year INT); INSERT INTO events (event_id,event_name,year) VALUES (1,'FIFA World Cu... | DELETE FROM athletes WHERE athlete_id NOT IN (SELECT athlete_id FROM athlete_events WHERE athlete_id IS NOT NULL); |
What are the warehouse management statistics for warehouses located in the state of New York? | CREATE TABLE Inventory (inventory_id INT,warehouse_id INT,item_name VARCHAR(50),quantity INT); INSERT INTO Inventory (inventory_id,warehouse_id,item_name,quantity) VALUES (1,1,'Box',10),(2,2,'Palette',20),(3,3,'Package',30); | SELECT w.warehouse_id, w.warehouse_name, i.item_name, i.quantity FROM Warehouse w JOIN Inventory i ON w.warehouse_id = i.warehouse_id WHERE w.state = 'New York'; |
Insert a new record into the "smart_contracts" table with "contract_address" as "0x3334567890123456789012345678901234567890", "contract_type" as "ERC721", "country" as "FR" | CREATE TABLE smart_contracts (contract_address VARCHAR(42),contract_type VARCHAR(10),country VARCHAR(2)); | INSERT INTO smart_contracts (contract_address, contract_type, country) VALUES ('0x3334567890123456789012345678901234567890', 'ERC721', 'FR'); |
List all restorative justice programs in the Middle East and their completion rates. | CREATE TABLE programs (program_id INT,program_name VARCHAR(50),country VARCHAR(20),completion_rate DECIMAL(5,2)); INSERT INTO programs (program_id,program_name,country,completion_rate) VALUES (1,'Program 1','UAE',0.85),(2,'Program 2','Qatar',0.90); | SELECT program_name, country, completion_rate FROM programs WHERE country LIKE 'Middle East%'; |
What is the minimum donation amount in 'India' for the year 2022? | CREATE TABLE Donations (DonationID int,DonorID int,DonationDate date,DonationAmount decimal(10,2)); INSERT INTO Donations (DonationID,DonorID,DonationDate,DonationAmount) VALUES (1,1,'2022-01-01',50.00); | SELECT MIN(DonationAmount) FROM Donations WHERE Country = 'India' AND YEAR(DonationDate) = 2022; |
Update artist_id for artworks in the 'Abstract Art' exhibition | CREATE TABLE artworks (id INT,name VARCHAR(255),artist_id INT); CREATE TABLE exhibitions (id INT,name VARCHAR(255)); CREATE TABLE exhibition_artworks (exhibition_id INT,artwork_id INT); INSERT INTO artworks (id,name,artist_id) VALUES (1,'The Persistence of Memory',1); INSERT INTO exhibitions (id,name) VALUES (1,'Abstra... | WITH updated_artworks AS (UPDATE artworks SET artist_id = 2 WHERE id IN (SELECT artwork_id FROM exhibition_artworks WHERE exhibition_id = 1)) SELECT * FROM updated_artworks; |
Retrieve all records from the faculty_members table | CREATE TABLE faculty_members (id INT PRIMARY KEY,name VARCHAR(255),department VARCHAR(50)); | SELECT * FROM faculty_members; |
What is the average number of art pieces created per year by artists from different countries? | CREATE TABLE Artists (ArtistID INT,Name VARCHAR(50),Country VARCHAR(50),CreationYear INT,ArtID INT); INSERT INTO Artists VALUES (1,'Alice','USA',1990,101),(2,'Bob','Canada',1995,102),(3,'Carla','Mexico',2000,103); | SELECT AVG(NumArtPieces) FROM (SELECT Country, COUNT(ArtID) AS NumArtPieces FROM Artists GROUP BY Country, CreationYear) AS Subquery; |
Identify marine protected areas that do not have any deep-sea expeditions. | CREATE TABLE Expeditions (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),start_date DATE,end_date DATE); CREATE TABLE Protected_Areas (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),size FLOAT,protection_level VARCHAR(50)); | SELECT Protected_Areas.name FROM Protected_Areas LEFT JOIN Expeditions ON Protected_Areas.location = Expeditions.location WHERE Expeditions.id IS NULL; |
Delete the broadband subscriber record with id 2 | CREATE TABLE broadband_subscribers (id INT,region VARCHAR(20),subscription_date DATE); INSERT INTO broadband_subscribers (id,region,subscription_date) VALUES (1,'urban','2022-01-01'),(2,'rural','2022-03-15'),(3,'urban','2022-02-01'); | DELETE FROM broadband_subscribers WHERE id = 2; |
What is the number of juvenile offenders who committed each type of crime in Chicago in 2021? | CREATE TABLE juvenile_offenders (offender_id INT,crime_type VARCHAR(255),year INT); INSERT INTO juvenile_offenders (offender_id,crime_type,year) VALUES (1,'Theft',2021); | SELECT crime_type, COUNT(*) OVER (PARTITION BY crime_type) as num_offenders FROM juvenile_offenders WHERE year = 2021 |
What is the total biomass of each species in the Arctic Ocean, ordered by decreasing total biomass? | CREATE TABLE BiomassData (Species VARCHAR(100),Biomass FLOAT,Ocean VARCHAR(100)); INSERT INTO BiomassData (Species,Biomass,Ocean) VALUES ('Polar Bear',500,'Arctic Ocean'); INSERT INTO BiomassData (Species,Biomass,Ocean) VALUES ('Greenland Shark',300,'Arctic Ocean'); | SELECT Species, SUM(Biomass) OVER (PARTITION BY Species ORDER BY Species DESC) AS TotalBiomass FROM BiomassData WHERE Ocean = 'Arctic Ocean' ORDER BY TotalBiomass DESC; |
What are the top 5 countries with the highest R&D expenditures in the pharmaceuticals industry in 2020? | CREATE TABLE rd_expenditures (country VARCHAR(50),amount NUMERIC(12,2),year INT); INSERT INTO rd_expenditures (country,amount,year) VALUES ('United States',80000,2020),('Germany',45000,2020),('Japan',42000,2020),('China',38000,2020),('France',37000,2020); | SELECT country, SUM(amount) as total_expenditure FROM rd_expenditures WHERE year = 2020 GROUP BY country ORDER BY total_expenditure DESC LIMIT 5; |
Find the daily change in waste generation for the Global Mining operation. | CREATE TABLE Mining_Operation (Operation_ID INT,Mine_Name VARCHAR(50),Location VARCHAR(50),Operation_Type VARCHAR(50),Start_Date DATE,End_Date DATE); CREATE TABLE Environmental_Impact (Impact_ID INT,Operation_ID INT,Date DATE,Carbon_Emissions INT,Water_Usage INT,Waste_Generation INT); | SELECT Operation_ID, Date, Waste_Generation, LAG(Waste_Generation, 1) OVER (PARTITION BY Operation_ID ORDER BY Date) AS Previous_Day_Waste, (Waste_Generation - LAG(Waste_Generation, 1) OVER (PARTITION BY Operation_ID ORDER BY Date)) AS Daily_Change_Waste FROM Environmental_Impact WHERE Operation_ID = 4; |
What is the total number of failed login attempts for a specific user account? | CREATE TABLE login_attempts (id INT,user_account VARCHAR(255),success BOOLEAN); INSERT INTO login_attempts (id,user_account,success) VALUES (1,'user1',false),(2,'user2',true),(3,'user1',false),(4,'user3',false),(5,'user2',false),(6,'user1',false); | SELECT user_account, SUM(failed_attempts) as total_failed_attempts FROM (SELECT user_account, success, CASE WHEN success = false THEN 1 ELSE 0 END as failed_attempts FROM login_attempts) as subquery GROUP BY user_account; |
What is the average revenue of virtual tours in United States and United Kingdom? | CREATE TABLE virtual_tours (tour_id INT,tour_name TEXT,country TEXT,revenue FLOAT); INSERT INTO virtual_tours (tour_id,tour_name,country,revenue) VALUES (1,'Virtual Tour 1','United States',10000),(2,'Virtual Tour 2','United Kingdom',15000); | SELECT AVG(revenue) FROM virtual_tours WHERE country IN ('United States', 'United Kingdom'); |
Find the number of digital divide initiatives per organization in the last 2 years, ordered by the most initiatives. | CREATE TABLE digital_divide_initiatives (org_name VARCHAR(50),year INT,initiatives INT); INSERT INTO digital_divide_initiatives (org_name,year,initiatives) VALUES ('ABC Corp',2020,15),('XYZ Inc',2021,20),('DEF Org',2020,18),('GHI Ltd',2019,12),('JKL Co',2021,22); | SELECT org_name, SUM(initiatives) as total_initiatives FROM digital_divide_initiatives WHERE year >= 2020 GROUP BY org_name ORDER BY total_initiatives DESC; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.