instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total production of rice in the 'agriculture' database, grouped by country? | CREATE TABLE production (id INT,crop VARCHAR(255),country VARCHAR(255),quantity INT); INSERT INTO production (id,crop,country,quantity) VALUES (1,'wheat','USA',5000000),(2,'wheat','Canada',3000000),(3,'rice','China',8000000),(4,'wheat','Australia',2500000); | SELECT country, SUM(quantity) as total_production FROM production WHERE crop = 'rice' GROUP BY country; |
How many smart contracts have been deployed on a specific blockchain platform? | CREATE TABLE blockchain_platforms (platform_id INT,name VARCHAR(255),smart_contract_count INT); | SELECT name, SUM(smart_contract_count) FROM blockchain_platforms WHERE name = 'Ethereum' GROUP BY name; |
What are the smart contracts written in Vyper by developers from the USA? | CREATE TABLE developers (developer_id INT PRIMARY KEY,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); INSERT INTO developers (developer_id,name,age,gender,country) VALUES (1,'Alice',30,'Female','USA'); INSERT INTO developers (developer_id,name,age,gender,country) VALUES (2,'Bob',35,'Male','Canada'); CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY,contract_name VARCHAR(50),developer_id INT,language VARCHAR(20),FOREIGN KEY (developer_id) REFERENCES developers(developer_id)); INSERT INTO smart_contracts (contract_id,contract_name,developer_id,language) VALUES (1,'Contract1',1,'Solidity'); INSERT INTO smart_contracts (contract_id,contract_name,developer_id,language) VALUES (2,'Contract2',2,'Vyper'); | SELECT smart_contracts.contract_name FROM smart_contracts INNER JOIN developers ON smart_contracts.developer_id = developers.developer_id WHERE developers.country = 'USA' AND smart_contracts.language = 'Vyper'; |
What is the minimum transaction amount for each digital asset in the 'crypto_transactions' table, partitioned by month? | CREATE TABLE crypto_transactions (transaction_id INT,digital_asset VARCHAR(20),transaction_amount DECIMAL(10,2),transaction_time DATETIME); | SELECT digital_asset, MIN(transaction_amount) as min_transaction_amount, DATE_TRUNC('month', transaction_time) as month FROM crypto_transactions GROUP BY digital_asset, month ORDER BY month; |
What is the regulatory status of digital asset 'CoinX'? | CREATE TABLE digital_assets (id INT,name TEXT,status TEXT); INSERT INTO digital_assets (id,name,status) VALUES (1,'CoinX','Unregulated'),(2,'CoinY','Regulated'); | SELECT status FROM digital_assets WHERE name = 'CoinX'; |
Find the total number of artworks in each category, sorted by the number of artworks in descending order. | CREATE TABLE Artworks (id INT,category VARCHAR(20)); INSERT INTO Artworks (id,category) VALUES (1,'modern'),(2,'contemporary'),(3,'classic'),(4,'modern'),(5,'classic'),(6,'impressionist'); | SELECT category, COUNT(*) FROM Artworks GROUP BY category ORDER BY COUNT(*) DESC; |
What is the average attendance at jazz concerts in New York and Los Angeles? | CREATE TABLE Concerts (city VARCHAR(20),genre VARCHAR(20),attendance INT); INSERT INTO Concerts (city,genre,attendance) VALUES ('New York','Jazz',1200),('New York','Jazz',1500),('Los Angeles','Jazz',800),('Los Angeles','Jazz',900); | SELECT AVG(attendance) FROM Concerts WHERE city IN ('New York', 'Los Angeles') AND genre = 'Jazz'; |
Find the average veteran employment rate in California for the last 3 years. | CREATE TABLE veteran_employment (employment_id INT,employment_date DATE,state VARCHAR(255),employment_rate FLOAT); INSERT INTO veteran_employment (employment_id,employment_date,state,employment_rate) VALUES (1,'2019-12-31','California',65.3),(2,'2020-04-04','Texas',70.1),(3,'2021-06-15','California',68.5); | SELECT AVG(employment_rate) FROM veteran_employment WHERE state = 'California' AND employment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR); |
What is the total number of veteran employment in 2021 for each country? | CREATE TABLE veteran_employment (country VARCHAR(255),num_veterans INT,employment_year INT); INSERT INTO veteran_employment (country,num_veterans,employment_year) VALUES ('USA',2000000,2021),('Canada',150000,2021),('UK',1200000,2021),('Australia',55000,2021),('Germany',800000,2021); | SELECT country, SUM(num_veterans) as total_num_veterans FROM veteran_employment WHERE employment_year = 2021 GROUP BY country ORDER BY total_num_veterans DESC; |
List the names of the ships that have visited ports in both the 'North America' and 'Asia' regions, considering the ports table. | CREATE TABLE fleet_management(ship_id INT,ship_name VARCHAR(50),visited_ports VARCHAR(255)); CREATE TABLE ports(port_id INT,port_name VARCHAR(50),region VARCHAR(50)); | SELECT FM.ship_name FROM fleet_management FM JOIN ports P1 ON TRIM(SPLIT_PART(FM.visited_ports, ',', n)) = P1.port_name JOIN ports P2 ON TRIM(SPLIT_PART(FM.visited_ports, ',', n2)) = P2.port_name WHERE P1.region = 'North America' AND P2.region = 'Asia' AND n <> n2 AND n >= 1 AND n2 >= 1; |
What is the maximum number of containers handled in a single day by cranes in the Port of Oakland in March 2021? | CREATE TABLE Port_Oakland_Crane_Stats (crane_name TEXT,handling_date DATE,containers_handled INTEGER); INSERT INTO Port_Oakland_Crane_Stats (crane_name,handling_date,containers_handled) VALUES ('CraneE','2021-03-01',55),('CraneF','2021-03-02',80),('CraneG','2021-03-03',70),('CraneH','2021-03-04',65); | SELECT MAX(containers_handled) FROM Port_Oakland_Crane_Stats WHERE handling_date >= '2021-03-01' AND handling_date <= '2021-03-31'; |
What is the total number of employees in the 'manufacturing' department? | CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(20)); INSERT INTO employees (id,name,department) VALUES (1,'John Doe','manufacturing'),(2,'Jane Smith','engineering'); | SELECT COUNT(*) FROM employees WHERE department = 'manufacturing'; |
What is the total number of workers in each factory? | 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)); INSERT INTO workers VALUES (1,1,'Assembly','Engineer'),(2,1,'Assembly','Technician'),(3,1,'Quality Control','Inspector'),(4,2,'Design','Architect'),(5,2,'Testing','Tester'); | SELECT f.factory_id, COUNT(w.worker_id) as total_workers FROM factories f JOIN workers w ON f.factory_id = w.factory_id GROUP BY f.factory_id; |
What are the total cybersecurity budgets for the top 3 countries with the highest cybersecurity spending? | CREATE TABLE CybersecurityBudgets (country VARCHAR(255),budget FLOAT); INSERT INTO CybersecurityBudgets (country,budget) VALUES ('United States',18000000),('China',12000000),('Japan',8000000); | SELECT country, SUM(budget) FROM CybersecurityBudgets ORDER BY budget DESC LIMIT 3; |
What is the average mental health score of students by gender? | CREATE TABLE students (student_id INT,student_name VARCHAR(50),gender VARCHAR(10),mental_health_score INT); INSERT INTO students (student_id,student_name,gender,mental_health_score) VALUES (1,'John Doe','Male',70),(2,'Jane Smith','Female',80); | SELECT gender, AVG(mental_health_score) FROM students GROUP BY gender; |
What is the minimum production quantity for wells owned by 'Big Oil'? | CREATE TABLE wells (id INT,name VARCHAR(255),owner VARCHAR(255),production_quantity INT); INSERT INTO wells (id,name,owner,production_quantity) VALUES (1,'Well A','Acme Oil',1000),(2,'Well B','Big Oil',2000),(3,'Well C','Acme Oil',1500),(4,'Well D','Big Oil',800); | SELECT MIN(production_quantity) FROM wells WHERE owner = 'Big Oil'; |
Add a new soccer match to the 'matches' table with the given details. | CREATE TABLE matches (match_id INT,home_team TEXT,away_team TEXT,home_goals INT,away_goals INT,match_date DATE); | INSERT INTO matches (match_id, home_team, away_team, home_goals, away_goals, match_date) VALUES (1, 'Barcelona', 'Real Madrid', 3, 2, '2022-10-02'); |
How many matches did Team B win? | CREATE TABLE Team_B_Matches (match_id INT,result VARCHAR(10)); INSERT INTO Team_B_Matches (match_id,result) VALUES (1,'Win'),(2,'Loss'),(3,'Win'); | SELECT COUNT(*) FROM Team_B_Matches WHERE result = 'Win'; |
Which countries have the least technology accessibility? | CREATE TABLE technology_access (id INT,person_name TEXT,has_access BOOLEAN,region TEXT); INSERT INTO technology_access (id,person_name,has_access,region) VALUES (1,'John Doe',FALSE,'Asia'),(2,'Jane Smith',TRUE,'North America'),(3,'Alice Johnson',FALSE,'Asia'); CREATE TABLE regions (id INT,region TEXT); INSERT INTO regions (id,region) VALUES (1,'Asia'),(2,'North America'),(3,'Europe'),(4,'Africa'),(5,'South America'); | SELECT r.region, COUNT(*) as access_count FROM technology_access ta JOIN regions r ON ta.region = r.region WHERE has_access = FALSE GROUP BY r.region ORDER BY access_count DESC; |
List the stations that have a departure time later than 8 PM, based on the 'route_schedule' table. | CREATE TABLE route_schedule (route_id INT,departure_time TIMESTAMP); | SELECT station FROM route_schedule JOIN route_segments ON route_schedule.route_id = route_segments.route_id WHERE EXTRACT(HOUR FROM departure_time) > 20; |
What is the distance between station 5 and station 12? | CREATE TABLE stations (station_id INT,name VARCHAR(255),latitude DECIMAL(9,6),longitude DECIMAL(9,6)); INSERT INTO stations (station_id,name,latitude,longitude) VALUES (5,'Station 5',40.712776,-74.005974),(12,'Station 12',40.718261,-74.004790); | SELECT 3959 * acos(cos(radians(stations.latitude)) * cos(radians((SELECT latitude FROM stations WHERE station_id = 12))) * cos(radians(stations.longitude) - radians((SELECT longitude FROM stations WHERE station_id = 12))) + sin(radians(stations.latitude)) * sin(radians((SELECT latitude FROM stations WHERE station_id = 12)))) as distance FROM stations WHERE station_id = 5; |
What is the maximum number of posts made by a single user in the 'social_media' table? | CREATE TABLE social_media (user_id INT,post_id INT); | SELECT MAX(COUNT(*)) FROM social_media GROUP BY user_id; |
What is the total number of users who have used the hashtag #food in the UK? | CREATE TABLE posts (id INT,user_id INT,hashtags TEXT); INSERT INTO posts (id,user_id,hashtags) VALUES (1,1,'#food'),(2,1,'#travel'),(3,2,'#food'),(4,3,'#food'),(5,4,'#travel'); CREATE TABLE users (id INT,country VARCHAR(2)); INSERT INTO users (id,country) VALUES (1,'UK'),(2,'CA'),(3,'UK'),(4,'DE'); | SELECT COUNT(DISTINCT user_id) as num_users FROM posts JOIN users ON posts.user_id = users.id WHERE hashtags LIKE '%#food%' AND users.country = 'UK'; |
Which size category has the most customers for each fashion trend? | CREATE TABLE customer_sizes (customer_id INT,size VARCHAR(10),trend VARCHAR(50)); CREATE TABLE fashion_trends (trend VARCHAR(50),category VARCHAR(50)); | SELECT f.category, s.size, COUNT(c.customer_id) as customer_count FROM customer_sizes c JOIN fashion_trends f ON c.trend = f.trend GROUP BY f.category, s.size ORDER BY f.category, COUNT(c.customer_id) DESC; |
What is the average socially responsible lending loan amount for microfinance institutions in Southeast Asia? | CREATE TABLE socially_responsible_lending(id INT,loan_number INT,institution_region VARCHAR(50),amount INT); INSERT INTO socially_responsible_lending VALUES (1,701,'Southeast Asia',5000); INSERT INTO socially_responsible_lending VALUES (2,702,'South Asia',7000); INSERT INTO socially_responsible_lending VALUES (3,703,'East Asia',9000); INSERT INTO socially_responsible_lending VALUES (4,704,'Southeast Asia',6000); | SELECT AVG(amount) FROM socially_responsible_lending WHERE institution_region = 'Southeast Asia' AND type = 'microfinance'; |
Find the number of unique programs that have received donations. | CREATE TABLE programs (program_id INT,program_name TEXT); INSERT INTO programs (program_id,program_name) VALUES (1,'Education'); INSERT INTO programs (program_id,program_name) VALUES (2,'Health'); INSERT INTO programs (program_id,program_name) VALUES (3,'Environment'); CREATE TABLE donation_programs (donation_id INT,program_id INT); INSERT INTO donation_programs (donation_id,program_id) VALUES (1,1); INSERT INTO donation_programs (donation_id,program_id) VALUES (2,1); INSERT INTO donation_programs (donation_id,program_id) VALUES (3,2); INSERT INTO donation_programs (donation_id,program_id) VALUES (4,3); INSERT INTO donation_programs (donation_id,program_id) VALUES (5,3); | SELECT COUNT(DISTINCT program_id) FROM donation_programs; |
Display all suppliers from 'Green Earth' that provide vegetables. | CREATE TABLE Suppliers (name text,product text); INSERT INTO Suppliers (name,product) VALUES ('Green Earth','Broccoli'),('Green Earth','Carrots'),('Green Earth','Apples'),('Natural Picks','Spinach'); | SELECT DISTINCT name FROM Suppliers WHERE product LIKE '%vegetable%'; |
Add a new record to the "warehouses" table for a new warehouse in "Tokyo", "Japan" | CREATE TABLE warehouses (id INT PRIMARY KEY,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50)); | INSERT INTO warehouses (name, city, country) VALUES ('New Warehouse', 'Tokyo', 'Japan'); |
How many petitions were created in 'California' and 'Texas' for the topic 'Immigration Reform'? | CREATE TABLE Petition (id INT,PetitionID INT,StateSponsor VARCHAR(50),Sponsor INT,Topic VARCHAR(50),FiscalYear VARCHAR(50)); INSERT INTO Petition (id,PetitionID,StateSponsor,Sponsor,Topic,FiscalYear) VALUES (1,1001,'California',1,'Immigration Reform','2022'); INSERT INTO Petition (id,PetitionID,StateSponsor,Sponsor,Topic,FiscalYear) VALUES (2,2001,'Texas',2,'Immigration Reform','2022'); | SELECT COUNT(DISTINCT PetitionID) FROM Petition WHERE StateSponsor IN ('California', 'Texas') AND Topic = 'Immigration Reform' AND FiscalYear = '2022'; |
What is the total number of research grants per year? | CREATE TABLE research_grants (id INT,year INT,amount DECIMAL(10,2)); INSERT INTO research_grants (id,year,amount) VALUES (1,2020,50000),(2,2020,75000),(3,2021,30000),(4,2021,100000); | SELECT year, SUM(amount) FROM research_grants GROUP BY year; |
What is the total patient count for each mental health condition, for providers in the Northeast and Southeast? | CREATE TABLE mental_health_conditions (condition_id INT,condition_name VARCHAR(50)); INSERT INTO mental_health_conditions (condition_id,condition_name) VALUES (1,'Anxiety'),(2,'Depression'),(3,'Bipolar Disorder'); CREATE TABLE providers (provider_id INT,provider_name VARCHAR(50),region_id INT); INSERT INTO providers (provider_id,provider_name,region_id) VALUES (1,'Dr. Smith',1),(2,'Dr. Johnson',2); CREATE TABLE provider_patients (provider_id INT,condition_id INT,patient_id INT); | SELECT mhc.condition_name, SUM(pp.patient_id) as total_patients FROM mental_health_conditions mhc JOIN provider_patients pp ON mhc.condition_id = pp.condition_id JOIN providers p ON pp.provider_id = p.provider_id WHERE p.region_id IN (1, 2) GROUP BY mhc.condition_name; |
Delete records in the "guests" table with the name "John Smith" | CREATE TABLE guests (id INT,name VARCHAR(50)); | WITH cte AS (DELETE FROM guests WHERE name = 'John Smith') SELECT * FROM cte; |
What is the market share of 'Online Travel Agency A' compared to 'Online Travel Agency B'? | CREATE TABLE bookings (booking_id INT,hotel_id INT,agency TEXT,revenue FLOAT); | SELECT (SUM(CASE WHEN agency = 'Online Travel Agency A' THEN revenue ELSE 0 END) / SUM(CASE WHEN agency IN ('Online Travel Agency A', 'Online Travel Agency B') THEN revenue ELSE 0 END)) * 100 as market_share_A, (SUM(CASE WHEN agency = 'Online Travel Agency B' THEN revenue ELSE 0 END) / SUM(CASE WHEN agency IN ('Online Travel Agency A', 'Online Travel Agency B') THEN revenue ELSE 0 END)) * 100 as market_share_B FROM bookings; |
Calculate the total quantity of renewable and non-renewable resources in each Arctic region. | CREATE TABLE Resources (id INT PRIMARY KEY,resource VARCHAR(255),region VARCHAR(255),quantity INT); INSERT INTO Resources (id,resource,region,quantity) VALUES (1,'oil','Arctic Ocean',10000000); INSERT INTO Resources (id,resource,region,quantity) VALUES (2,'wind','Svalbard',8000000); | SELECT region, SUM(CASE WHEN resource IN ('oil', 'wind') THEN quantity ELSE 0 END) as total_quantity FROM Resources GROUP BY region; |
What is the average age of patients with anxiety in New York? | CREATE TABLE patients (patient_id INT,age INT,gender TEXT,state TEXT,condition TEXT); INSERT INTO patients (patient_id,age,gender,state,condition) VALUES (1,35,'Female','New York','Anxiety'); INSERT INTO patients (patient_id,age,gender,state,condition) VALUES (2,40,'Male','New York','Anxiety'); INSERT INTO patients (patient_id,age,gender,state,condition) VALUES (3,50,'Non-binary','California','Depression'); | SELECT AVG(age) FROM patients WHERE state = 'New York' AND condition = 'Anxiety'; |
What is the success rate of cognitive behavioral therapy (CBT) for patients with depression in the African American community? | CREATE TABLE therapy_approaches (approach_id INT,name VARCHAR(255)); CREATE TABLE patients (patient_id INT,age INT,gender VARCHAR(10),condition VARCHAR(255),ethnicity VARCHAR(255)); CREATE TABLE therapy_sessions (session_id INT,patient_id INT,therapist_id INT,session_date DATE,success BOOLEAN,approach_id INT); | SELECT AVG(CASE WHEN therapy_sessions.success THEN 1 ELSE 0 END) AS success_rate FROM therapy_sessions JOIN patients ON therapy_sessions.patient_id = patients.patient_id JOIN therapy_approaches ON therapy_sessions.approach_id = therapy_approaches.approach_id WHERE patients.condition = 'depression' AND patients.ethnicity = 'African American' AND therapy_approaches.name = 'cognitive behavioral therapy'; |
Which mental health conditions have the highest success rates for treatment, and how many patients have been treated for each? | CREATE TABLE mental_health_conditions (id INT,name VARCHAR(50),prevalence FLOAT); CREATE TABLE treatments (id INT,condition_id INT,name VARCHAR(50),approach VARCHAR(50),success_rate FLOAT); CREATE TABLE patient_outcomes (id INT,treatment_id INT,patient_id INT); | SELECT mhc.name, t.name, COUNT(po.patient_id) as patient_count FROM mental_health_conditions mhc JOIN treatments t ON mhc.id = t.condition_id JOIN patient_outcomes po ON t.id = po.treatment_id GROUP BY mhc.name, t.name ORDER BY t.success_rate DESC; |
Identify the number of international tourists visiting African countries in the last 3 years and their average spending? | CREATE TABLE TouristData (Year INT,Country VARCHAR(255),Tourists INT,Spending DECIMAL(10,2)); INSERT INTO TouristData (Year,Country,Tourists,Spending) VALUES (2018,'South Africa',12000000,850),(2018,'Egypt',10000000,700),(2019,'South Africa',13000000,900),(2019,'Egypt',11000000,750),(2020,'South Africa',8000000,650),(2020,'Egypt',9000000,800),(2021,'South Africa',9000000,700),(2021,'Egypt',10000000,850); | SELECT Country, COUNT(*) AS NumberOfTourists, AVG(Spending) AS AverageSpending FROM TouristData WHERE Year BETWEEN 2019 AND 2021 GROUP BY Country; |
Show the names and sentences of all individuals who were sentenced to life imprisonment without parole. | CREATE TABLE Sentences (Id INT,Name VARCHAR(50),Sentence VARCHAR(50)); INSERT INTO Sentences (Id,Name,Sentence) VALUES (1,'Jane Doe','Life Imprisonment without Parole'),(2,'John Smith','10 years'),(3,'Bob Johnson','Life Imprisonment'); | SELECT Name, Sentence FROM Sentences WHERE Sentence = 'Life Imprisonment without Parole'; |
What is the average caseload per attorney in community legal clinics in California, and how does it compare to the state average? | CREATE TABLE cali_community_legal_clinics(id INT,attorney_count INT,cases_handled INT,state VARCHAR(255)); | SELECT state, AVG(cases_handled/attorney_count) AS avg_caseload FROM cali_community_legal_clinics WHERE state = 'California' GROUP BY state UNION ALL SELECT 'California', AVG(cases_handled/attorney_count) FROM cali_community_legal_clinics WHERE state = 'California'; |
Retrieve all the pollution control projects and their start and end dates from the 'PollutionProjects' table | CREATE TABLE PollutionProjects (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE); | SELECT name, start_date, end_date FROM PollutionProjects; |
What is the average weight of ingredients in vegetarian dishes in the lunch menu? | CREATE TABLE LunchMenu(menu_item VARCHAR(50),dish_type VARCHAR(20),price DECIMAL(5,2),ingredients TEXT,weight DECIMAL(5,2)); INSERT INTO LunchMenu VALUES('Vegetable Sandwich','vegetarian',9.99,'local vegetables 150g',150),('Grilled Tofu Salad','vegetarian',12.99,'tofu 200g,local lettuce 50g',250); | SELECT AVG(weight) FROM LunchMenu WHERE dish_type = 'vegetarian'; |
List the defense contractors who have had no military equipment sales in 2020. | CREATE TABLE sales_by_year (contractor VARCHAR(20),year INT,sales INT); INSERT INTO sales_by_year (contractor,year,sales) VALUES ('Boeing',2020,0),('BAE Systems',2020,500); | SELECT contractor FROM sales_by_year WHERE year = 2020 AND sales = 0; |
What is the total military equipment sales revenue for each sales representative by fiscal year? | CREATE TABLE SalesReps (SalesRepID INT,SalesRepName VARCHAR(50),FiscalYear INT,Revenue DECIMAL(10,2)); INSERT INTO SalesReps (SalesRepID,SalesRepName,FiscalYear,Revenue) VALUES (1,'John Doe',2020,150000.00),(2,'Jane Smith',2020,200000.00),(1,'John Doe',2021,180000.00),(2,'Jane Smith',2021,250000.00); | SELECT SalesRepName, FiscalYear, SUM(Revenue) OVER (PARTITION BY SalesRepName ORDER BY FiscalYear) AS TotalRevenue FROM SalesReps; |
What is the total number of military equipment sales to country X in the last 5 years? | CREATE TABLE military_sales (id INT,country VARCHAR(255),year INT,total_sales DECIMAL(10,2)); INSERT INTO military_sales (id,country,year,total_sales) VALUES (1,'Country X',2017,100000.00),(2,'Country Y',2018,150000.00); | SELECT SUM(total_sales) FROM military_sales WHERE country = 'Country X' AND year BETWEEN (SELECT YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE); |
Which projects have had risks related to 'Cybersecurity' and their associated contract amounts? | CREATE TABLE Projects (id INT,project_name VARCHAR(255),start_date DATE,end_date DATE,region VARCHAR(255)); CREATE TABLE Contracts (id INT,equipment_type VARCHAR(255),contract_amount DECIMAL(10,2),negotiation_date DATE,project_id INT); CREATE TABLE Risks (id INT,project_id INT,risk_type VARCHAR(255),description TEXT,risk_date DATE); INSERT INTO Projects (id,project_name,start_date,end_date,region) VALUES (6,'Drone Development','2022-07-01','2024-06-30','North America'); INSERT INTO Contracts (id,equipment_type,contract_amount,negotiation_date,project_id) VALUES (6,'Drone',10000000,'2022-10-05',6); INSERT INTO Risks (id,project_id,risk_type,description,risk_date) VALUES (6,6,'Cybersecurity','Potential vulnerabilities in drone software','2022-11-15'); | SELECT Contracts.equipment_type, Contracts.contract_amount FROM Contracts INNER JOIN Risks ON Contracts.project_id = Risks.project_id WHERE Risks.risk_type = 'Cybersecurity'; |
Delete records in the 'mine_production' table where the production tonnes is less than 50000 for the Democratic Republic of the Congo in the year 2018. | CREATE TABLE mine_production (id INT,mine_name VARCHAR(50),country VARCHAR(50),production_tonnes INT,year INT,PRIMARY KEY (id)); INSERT INTO mine_production (id,mine_name,country,production_tonnes,year) VALUES (1,'Tenke Fungurume','Democratic Republic of the Congo',120000,2018),(2,'Katanga','Democratic Republic of the Congo',70000,2018); | DELETE FROM mine_production WHERE production_tonnes < 50000 AND country = 'Democratic Republic of the Congo' AND year = 2018; |
What was the total amount of minerals extracted in the 'north' region for each month in 2020? | CREATE TABLE extraction(id INT,location TEXT,month INT,year INT,minerals_extracted FLOAT);INSERT INTO extraction(id,location,month,year,minerals_extracted) VALUES (1,'north',1,2020,1500),(2,'north',2,2020,1800),(3,'south',1,2020,1200); | SELECT month, SUM(minerals_extracted) FROM extraction WHERE location = 'north' AND year = 2020 GROUP BY month; |
Update the 'Mobile' service's revenue by 10% for subscribers in the 'Rural' region in Q3 of 2021. | CREATE TABLE Subscribers (subscriber_id INT,service VARCHAR(20),region VARCHAR(20),revenue FLOAT); INSERT INTO Subscribers (subscriber_id,service,region,revenue) VALUES (1,'Broadband','Metro',50.00),(2,'Mobile','Urban',35.00),(3,'Mobile','Rural',20.00); | UPDATE Subscribers SET revenue = revenue * 1.1 WHERE service = 'Mobile' AND region = 'Rural' AND QUARTER(payment_date) = 3 AND YEAR(payment_date) = 2021; |
What is the average network investment for each country in the past year? | CREATE TABLE network_investments (investment_id INT,amount_usd FLOAT,investment_date DATE,country VARCHAR(50)); INSERT INTO network_investments (investment_id,amount_usd,investment_date,country) VALUES (1,5000000,'2021-01-01','USA'),(2,7000000,'2021-02-01','USA'),(3,3000000,'2021-01-15','Canada'),(4,4000000,'2021-02-10','Canada'); | SELECT country, AVG(amount_usd) as avg_investment, EXTRACT(YEAR FROM investment_date) as investment_year FROM network_investments WHERE investment_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY country, investment_year; |
What is the total revenue generated from postpaid mobile plans in the Midwest region for the year 2022? | CREATE TABLE subscribers(id INT,plan_type VARCHAR(10),region VARCHAR(10)); INSERT INTO subscribers VALUES (1,'postpaid','Midwest'); CREATE TABLE plans(plan_type VARCHAR(10),price DECIMAL(5,2)); INSERT INTO plans VALUES ('postpaid',50.00); CREATE TABLE transactions(subscriber_id INT,transaction_date DATE,plan_id INT); INSERT INTO transactions VALUES (1,'2022-01-01',1); | SELECT SUM(plans.price) FROM subscribers INNER JOIN transactions ON subscribers.id = transactions.subscriber_id INNER JOIN plans ON subscribers.plan_type = plans.plan_type WHERE subscribers.region = 'Midwest' AND YEAR(transactions.transaction_date) = 2022 AND subscribers.plan_type = 'postpaid'; |
Identify the total revenue for all concerts in 'Tokyo' and 'Seoul'. | CREATE TABLE Concerts (ConcertID INT,VenueID INT,ArtistID INT,Revenue FLOAT); INSERT INTO Concerts (ConcertID,VenueID,ArtistID,Revenue) VALUES (1,1003,1,5000),(2,1004,2,7000),(3,1005,3,6000),(4,1003,4,8000),(5,1004,4,9000),(6,1003,5,10000),(7,1004,5,11000); CREATE TABLE Venues (VenueID INT,VenueName VARCHAR(100),Location VARCHAR(50)); INSERT INTO Venues (VenueID,VenueName,Location) VALUES (1001,'VenueA','New York'),(1002,'VenueB','Los Angeles'),(1003,'VenueC','Tokyo'),(1004,'VenueD','Paris'),(1005,'VenueE','Sydney'); | SELECT SUM(Revenue) AS TotalRevenue FROM Concerts C JOIN Venues V ON C.VenueID = V.VenueID WHERE Location IN ('Tokyo', 'Seoul'); |
What is the average number of streams for Latin music in April? | CREATE TABLE Streams (id INT,genre VARCHAR(20),date DATE,streams INT); INSERT INTO Streams (id,genre,date,streams) VALUES (1,'Latin','2022-04-01',250),(2,'Pop','2022-03-15',800),(3,'Latin','2022-04-10',450); | SELECT AVG(streams) FROM Streams WHERE genre = 'Latin' AND date BETWEEN '2022-04-01' AND '2022-04-30'; |
Find the number of articles published in 'Africa' and 'Oceania' by 'Global News'? | CREATE TABLE news_agencies (id INT,name TEXT); INSERT INTO news_agencies VALUES (1,'Acme News Agency'); INSERT INTO news_agencies VALUES (2,'Global News'); CREATE TABLE articles (id INT,agency_id INT,title TEXT,location TEXT); INSERT INTO articles VALUES (1,1,'Article 1','Africa'); INSERT INTO articles VALUES (2,1,'Article 2','Asia'); INSERT INTO articles VALUES (3,2,'Article 3','Oceania'); | SELECT COUNT(articles.id) FROM articles INNER JOIN news_agencies ON articles.agency_id = news_agencies.id WHERE news_agencies.name = 'Global News' AND articles.location IN ('Africa', 'Oceania'); |
How many deep-sea expeditions have been conducted in the Arctic Ocean since 2010? | CREATE TABLE deep_sea_expeditions (id INT,name TEXT,year INT,location TEXT); INSERT INTO deep_sea_expeditions (id,name,year,location) VALUES (1,'Arctic Ocean Expedition 2015',2015,'Arctic'),(2,'Northern Explorer Expedition 2012',2012,'Arctic'),(3,'Polar Explorer Expedition 2018',2018,'Antarctic'); | SELECT COUNT(*) FROM deep_sea_expeditions WHERE year >= 2010 AND location = 'Arctic'; |
List the number of donations per month for the donor with ID 1. | CREATE TABLE donations (id INT,donation_date DATE); INSERT INTO donations (id,donation_date) VALUES (1,'2021-01-01'),(2,'2021-01-15'),(3,'2021-02-01'),(4,'2021-02-15'),(5,'2021-03-01'); | SELECT EXTRACT(MONTH FROM donation_date) as month, COUNT(*) as donations FROM donations WHERE id = 1 GROUP BY month; |
How many unique game genres were played by players from each country? | CREATE TABLE Players (PlayerID INT,Country VARCHAR(20),GameGenre VARCHAR(20));INSERT INTO Players (PlayerID,Country,GameGenre) VALUES (1,'USA','RPG'),(2,'Canada','FPS'),(3,'Mexico','RPG'); | SELECT Country, COUNT(DISTINCT GameGenre) FROM Players GROUP BY Country; |
What is the total budget allocated to Education in urban areas compared to suburban areas? | CREATE TABLE EducationBudget (Year INT,Area VARCHAR(20),Budget FLOAT); INSERT INTO EducationBudget (Year,Area,Budget) VALUES (2018,'Urban',4000000),(2018,'Suburban',3000000),(2019,'Urban',4500000),(2019,'Suburban',3300000); | SELECT t.Area, SUM(t.Budget) as Total_Budget FROM EducationBudget t WHERE t.Year IN (2018, 2019) GROUP BY t.Area; |
What was the average citizen feedback score for public recreation centers in London in 2021? | CREATE TABLE citizen_feedback (year INT,city VARCHAR(20),service VARCHAR(20),score INT); INSERT INTO citizen_feedback VALUES (2021,'London','Public Recreation Centers',80),(2021,'London','Public Recreation Centers',85); | SELECT AVG(score) FROM citizen_feedback WHERE city = 'London' AND service = 'Public Recreation Centers' AND year = 2021; |
Find the total production of Neodymium and Dysprosium | CREATE TABLE production_data (element VARCHAR(10),year INT,quantity INT); INSERT INTO production_data VALUES ('Neodymium',2015,1200),('Neodymium',2016,1500),('Dysprosium',2015,200),('Dysprosium',2016,250); | SELECT SUM(quantity) FROM production_data WHERE element IN ('Neodymium', 'Dysprosium') GROUP BY element; |
How many Kilograms of Neodymium were produced in each country between 2012 and 2014? | CREATE TABLE neodymium_production (country VARCHAR(255),year INT,kilograms_produced INT); INSERT INTO neodymium_production (country,year,kilograms_produced) VALUES ('China',2012,60000),('China',2013,65000),('China',2014,70000),('Australia',2012,3000),('Australia',2013,3500),('Australia',2014,4000),('Brazil',2012,2000),('Brazil',2013,2500),('Brazil',2014,3000); | SELECT country, year, SUM(kilograms_produced) FROM neodymium_production WHERE year BETWEEN 2012 AND 2014 GROUP BY ROLLUP(country, year); |
How many ytterbium refineries are there in total in South America? | CREATE TABLE ytterbium_refineries (refinery_id INT,continent TEXT); INSERT INTO ytterbium_refineries (refinery_id,continent) VALUES (1,'South America'),(2,'Asia'),(3,'Africa'),(4,'Europe'),(5,'North America'); | SELECT COUNT(*) FROM ytterbium_refineries WHERE continent = 'South America'; |
What is the average price per kilogram of Dysprosium exported by Malaysia to the USA in the last 5 years? | CREATE TABLE Dysprosium_Exports (id INT PRIMARY KEY,year INT,exporting_country VARCHAR(20),importing_country VARCHAR(20),quantity INT,price PER_KG); INSERT INTO Dysprosium_Exports (id,year,exporting_country,importing_country,quantity,price) VALUES (1,2017,'Malaysia','USA',20,15),(2,2018,'Malaysia','USA',22,16),(3,2019,'Malaysia','USA',24,17),(4,2020,'Malaysia','USA',26,18),(5,2021,'Malaysia','USA',28,19),(6,2017,'Vietnam','USA',21,14),(7,2018,'Vietnam','USA',23,15),(8,2019,'Vietnam','USA',25,16),(9,2020,'Vietnam','USA',27,17),(10,2021,'Vietnam','USA',29,18); | SELECT AVG(price) FROM Dysprosium_Exports WHERE exporting_country = 'Malaysia' AND importing_country = 'USA' AND year BETWEEN 2017 AND 2021; |
Which menu items contribute to 80% of the revenue for each cuisine type? | CREATE TABLE menu_engineering(menu_item TEXT,cuisine_type TEXT,revenue FLOAT); INSERT INTO menu_engineering(menu_item,cuisine_type,revenue) VALUES ('Pizza','Italian',2500.00),('Pasta','Italian',1500.00),('Tacos','Mexican',3000.00),('Burritos','Mexican',2500.00); | SELECT menu_item, cuisine_type, SUM(revenue) as total_revenue FROM menu_engineering WHERE cuisine_type IN (SELECT cuisine_type FROM menu_engineering WHERE revenue IN (SELECT revenue FROM menu_engineering WHERE cuisine_type = menu_engineering.cuisine_type GROUP BY cuisine_type ORDER BY SUM(revenue) DESC LIMIT 1)) GROUP BY cuisine_type, menu_item HAVING SUM(revenue) / (SELECT SUM(revenue) FROM menu_engineering WHERE cuisine_type = menu_engineering.cuisine_type) >= 0.8; |
What is the minimum production emission for items in the Production_Emissions view? | CREATE VIEW Production_Emissions AS SELECT product_id,product_name,production_emissions FROM Products; INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (601,'Socks',2,4,1); INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (602,'Hat',3,5,2); INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (603,'Scarf',4,6,3); | SELECT MIN(production_emissions) FROM Production_Emissions; |
What is the total revenue generated by retail stores located in New York that sell sustainable products? | CREATE TABLE RetailStores (StoreID INT,StoreName VARCHAR(50),State VARCHAR(50)); INSERT INTO RetailStores (StoreID,StoreName,State) VALUES (1,'RetailStoreA','New York'); CREATE TABLE Sales (SaleID INT,StoreID INT,ProductID INT,Quantity INT,Price DECIMAL(5,2)); INSERT INTO Sales (SaleID,StoreID,ProductID,Quantity,Price) VALUES (1,1,1,10,15.99),(2,1,2,5,12.49); CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),IsSustainable BOOLEAN); INSERT INTO Products (ProductID,ProductName,IsSustainable) VALUES (1,'Product1',true),(2,'Product2',false); | SELECT SUM(Quantity * Price) FROM Sales JOIN RetailStores ON Sales.StoreID = RetailStores.StoreID JOIN Products ON Sales.ProductID = Products.ProductID WHERE RetailStores.State = 'New York' AND Products.IsSustainable = true; |
What is the average number of days spent in space by an astronaut? | CREATE TABLE astronauts(name TEXT,missions INTEGER,days_in_space REAL); INSERT INTO astronauts(name,missions,days_in_space) VALUES('Neil Armstrong',1,265.5),('Buzz Aldrin',1,216.4); | SELECT AVG(days_in_space) FROM astronauts; |
What is the total revenue for each sports team in the 'team_revenue' table? | CREATE TABLE team_revenue (team_name VARCHAR(255),season INT,total_revenue INT); | SELECT team_name, SUM(total_revenue) as total_revenue_per_team FROM team_revenue GROUP BY team_name; |
What is the total number of employees and unions in the 'labor_advocacy' schema? | CREATE SCHEMA labor_advocacy; CREATE TABLE employees (id INT,name VARCHAR,department VARCHAR); INSERT INTO employees VALUES (1,'John Doe','Marketing'); CREATE TABLE unions (id INT,name VARCHAR,sector VARCHAR); INSERT INTO unions VALUES (1,'Union A','Tech'); | SELECT COUNT(*), 'total' FROM (SELECT * FROM labor_advocacy.employees UNION ALL SELECT * FROM labor_advocacy.unions) AS combined_data; |
Update records in the safety_records table where the vessel_id is 401 and incident_type is 'Collision', set the resolution to 'Resolved' | CREATE TABLE safety_records (id INT,vessel_id INT,incident_type VARCHAR(20),resolution VARCHAR(20)); | UPDATE safety_records SET resolution = 'Resolved' WHERE vessel_id = 401 AND incident_type = 'Collision'; |
What is the total cargo weight transported by each vessel in the past week? | CREATE TABLE Cargo_Tracking(Vessel_ID INT,Cargo_Type VARCHAR(50),Transport_Date DATE,Total_Weight INT); INSERT INTO Cargo_Tracking VALUES (5,'Coal','2022-03-20',2000),(5,'Iron Ore','2022-03-21',3000),(5,'Grain','2022-03-23',1500),(6,'Coal','2022-03-20',3000),(6,'Grain','2022-03-21',1000); | SELECT Vessel_ID, SUM(Total_Weight) FROM Cargo_Tracking WHERE Transport_Date >= DATEADD(WEEK, -1, GETDATE()) GROUP BY Vessel_ID; |
What is the total waste generation in the past year for each district in region V? | CREATE TABLE district_waste(district TEXT,waste_gen FLOAT,waste_date DATE); INSERT INTO district_waste(district,waste_gen,waste_date) VALUES('1',100,'2022-01-01'),('1',150,'2022-02-01'),('2',200,'2022-01-01'),('2',250,'2022-02-01'); | SELECT district, SUM(waste_gen) FROM district_waste WHERE waste_date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY district; |
How many water treatment plants in the 'urban' category have exceeded their maximum capacity in the last 12 months? | CREATE TABLE water_treatment_plants (plant_id INT,plant_category VARCHAR(20),max_capacity INT,last_inspection_date DATE); INSERT INTO water_treatment_plants (plant_id,plant_category,max_capacity,last_inspection_date) VALUES (1,'urban',500,'2021-01-15'),(2,'rural',300,'2021-02-10'),(3,'urban',600,'2021-06-01'); | SELECT COUNT(plant_id) FROM water_treatment_plants WHERE plant_category = 'urban' AND last_inspection_date >= DATEADD(year, -1, GETDATE()); |
What is the percentage of wastewater treated in CityC and CityD in 2020? | CREATE TABLE wastewater_treatment (city VARCHAR(50),year INT,treated_volume INT,total_volume INT); INSERT INTO wastewater_treatment (city,year,treated_volume,total_volume) VALUES ('CityC',2019,800,1000),('CityC',2020,900,1100),('CityD',2019,700,900),('CityD',2020,800,1000); | SELECT city, ROUND((treated_volume::float / total_volume::float * 100), 2) AS treatment_percentage FROM wastewater_treatment WHERE year = 2020 AND city IN ('CityC', 'CityD'); |
What is the average age of members who do cycling workouts? | CREATE TABLE Members (MemberID INT,Age INT,FavoriteExercise VARCHAR(20)); INSERT INTO Members (MemberID,Age,FavoriteExercise) VALUES (1,35,'Cycling'); INSERT INTO Members (MemberID,Age,FavoriteExercise) VALUES (2,28,'Running'); | SELECT AVG(Age) FROM Members WHERE FavoriteExercise = 'Cycling'; |
What are the AI safety concerns raised in the past year for healthcare, in the AI Safety database? | CREATE TABLE concerns (id INT,description VARCHAR(255),published_date DATE); | SELECT description FROM concerns WHERE published_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR) AND sector = 'Healthcare'; |
What is the ratio of safe AI algorithms to unsafe AI algorithms by gender of the lead developer? | CREATE TABLE safe_ai_algorithms (algorithm_id INT,algorithm_name TEXT,is_safe BOOLEAN); INSERT INTO safe_ai_algorithms (algorithm_id,algorithm_name,is_safe) VALUES (1,'Safe AI',true),(2,'Unsafe AI',false); CREATE TABLE ai_developers (developer_id INT,developer_name TEXT,developer_gender TEXT,lead_developer BOOLEAN); INSERT INTO ai_developers (developer_id,developer_name,developer_gender,lead_developer) VALUES (1001,'Alice','Female',true),(1002,'Bob','Male',false),(1003,'Charlie','Female',true); | SELECT d.developer_gender, SUM(saa.is_safe) as num_safe, COUNT(*) as num_total, 1.0 * SUM(saa.is_safe) / COUNT(*) as ratio FROM safe_ai_algorithms saa CROSS JOIN ai_developers d WHERE d.lead_developer = true GROUP BY d.developer_gender; |
How many rural infrastructure projects were completed in each year from the 'project_completion_dates' table? | CREATE TABLE project_completion_dates (id INT,project_id INT,completion_date DATE); INSERT INTO project_completion_dates (id,project_id,completion_date) VALUES (1,1,'2018-06-25'),(2,2,'2019-12-18'),(3,3,'2018-03-04'); | SELECT EXTRACT(YEAR FROM completion_date) AS Year, COUNT(DISTINCT project_id) AS Number_Of_Projects FROM project_completion_dates GROUP BY Year; |
Insert a new rural infrastructure project 'Solar Power' in Vietnam with a budget of 600000. | CREATE TABLE RuralInfrastructure (id INT,project VARCHAR(255),country VARCHAR(255),budget FLOAT); | INSERT INTO RuralInfrastructure (project, country, budget) VALUES ('Solar Power', 'Vietnam', 600000); |
Insert new records into the 'aircraft_manufacturing' table for 'SpaceX' manufacturing the 'Starship' model in 'Boca Chica', 'USA' in 2025 | CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY,manufacturer VARCHAR(50),model VARCHAR(50),city VARCHAR(50),country VARCHAR(50),manufacturing_year INT); | INSERT INTO aircraft_manufacturing (id, manufacturer, model, city, country, manufacturing_year) VALUES (1, 'SpaceX', 'Starship', 'Boca Chica', 'USA', 2025); |
List all animals and their total population | CREATE TABLE IF NOT EXISTS region (id INT PRIMARY KEY,name VARCHAR(50));CREATE TABLE IF NOT EXISTS animal (id INT PRIMARY KEY,name VARCHAR(50));CREATE TABLE IF NOT EXISTS animal_population (id INT PRIMARY KEY,animal_id INT,region_id INT,population INT); | SELECT a.name as animal_name, SUM(ap.population) as total_population FROM animal a JOIN animal_population ap ON a.id = ap.animal_id GROUP BY a.name; |
How many construction workers were employed in Texas in Q1 and Q2 of 2021? | CREATE TABLE employment (state VARCHAR(2),quarter INT,workers INT); | SELECT state, quarter, SUM(workers) FROM employment WHERE state = 'TX' AND quarter IN (1, 2) GROUP BY state, quarter; |
What is the average permit processing time in Texas? | CREATE TABLE permit_applications (id INT,application_date DATE,permit_date DATE); INSERT INTO permit_applications (id,application_date,permit_date) VALUES (1,'2022-01-01','2022-01-05'); INSERT INTO permit_applications (id,application_date,permit_date) VALUES (2,'2022-01-02','2022-01-06'); INSERT INTO permit_applications (id,application_date,permit_date) VALUES (3,'2022-01-03','2022-01-07'); | SELECT AVG(DATEDIFF(permit_date, application_date)) as avg_processing_time FROM permit_applications WHERE state = 'Texas'; |
Insert a new precedent regarding immigration laws in France. | CREATE TABLE legal_precedents (precedent_id INT,country VARCHAR(20),law_category VARCHAR(20),description TEXT); CREATE TABLE countries (country_id INT,country VARCHAR(20)); | INSERT INTO legal_precedents (precedent_id, country, law_category, description) VALUES ((SELECT MAX(precedent_id) FROM legal_precedents) + 1, 'France', 'Immigration', 'New precedent about immigration laws in France'); |
What is the average billing amount per case? | CREATE TABLE Cases (CaseID int,BillingID int); INSERT INTO Cases VALUES (1,1),(2,2),(3,3),(4,4); CREATE TABLE Billing (BillingID int,Amount decimal(10,2)); INSERT INTO Billing VALUES (1,500.00),(2,750.00),(3,300.00),(4,600.00); | SELECT AVG(B.Amount) as AvgBillingPerCase FROM Cases C JOIN Billing B ON C.BillingID = B.BillingID; |
Delete CO2 emissions records for a specific chemical manufacturer. | CREATE TABLE emissions (emission_id INT,manufacturer_id INT,gas_type VARCHAR(255),amount INT); INSERT INTO emissions (emission_id,manufacturer_id,gas_type,amount) VALUES (1,1,'CO2',1000),(2,1,'CH4',200),(3,2,'CO2',1500),(4,3,'CO2',1200),(5,3,'CH4',300); | DELETE FROM emissions WHERE manufacturer_id = 1 AND gas_type = 'CO2'; |
Update the "equipment" table to reflect that the "equipment_id" 0102 is now "inactive". | CREATE TABLE equipment (equipment_id varchar(10),equipment_name varchar(255),equipment_model varchar(255),equipment_status varchar(50)); | UPDATE equipment SET equipment_status = 'inactive' WHERE equipment_id = '0102'; |
What is the maximum funding amount for climate mitigation projects in South Asia? | CREATE TABLE climate_finance (project_id INT,project_name TEXT,location TEXT,funded_year INT,funding_amount FLOAT); INSERT INTO climate_finance (project_id,project_name,location,funded_year,funding_amount) VALUES (1,'Mitigation 1','India',2015,6000000.0),(2,'Mitigation 2','Pakistan',2013,8000000.0),(3,'Adaptation 1','Bangladesh',2012,4000000.0); | SELECT MAX(funding_amount) FROM climate_finance WHERE funded_year >= 2010 AND project_type = 'climate mitigation' AND location LIKE 'South Asia%'; |
What is the number of primary care physicians per 100,000 population for each state in the physicians table? | CREATE TABLE physicians (state TEXT,specialty TEXT,num_physicians INT); INSERT INTO physicians (state,specialty,num_physicians) VALUES ('California','Primary Care',15000),('Texas','Primary Care',12000),('New York','Primary Care',18000),('Florida','Primary Care',14000); | SELECT state, (num_physicians * 100000) / population AS physicians_per_100k FROM physicians JOIN state_population ON physicians.state = state_population.state; |
What is the total number of primary care clinics in urban areas? | CREATE TABLE clinics (name VARCHAR(255),city_type VARCHAR(255),specialty VARCHAR(255)); INSERT INTO clinics (name,city_type,specialty) VALUES ('Family Care Clinic','Urban','Primary Care'); INSERT INTO clinics (name,city_type,specialty) VALUES ('MedPlus Clinic','Rural','Internal Medicine'); | SELECT COUNT(*) FROM clinics WHERE city_type = 'Urban' AND specialty = 'Primary Care'; |
What is the average cost of accommodations per student who utilizes assistive technology? | CREATE TABLE accommodations (accommodation_cost DECIMAL(5,2),student_id INT,utilizes_assistive_tech BOOLEAN); INSERT INTO accommodations (accommodation_cost,student_id,utilizes_assistive_tech) VALUES (100.00,1,TRUE),(200.00,2,FALSE); | SELECT AVG(accommodation_cost) FROM accommodations WHERE utilizes_assistive_tech = TRUE; |
How many timber production sites are there in each country, and what is their total area in hectares, broken down by year of establishment? | CREATE TABLE timber_production_2 (id INT,country VARCHAR(255),site_name VARCHAR(255),area FLOAT,establishment_year INT); INSERT INTO timber_production_2 (id,country,site_name,area,establishment_year) VALUES (1,'Canada','Site A',50000.0,2000),(2,'Canada','Site B',60000.0,2001),(3,'Brazil','Site C',70000.0,2002),(4,'Brazil','Site D',80000.0,2003); | SELECT country, establishment_year, COUNT(*), SUM(area) FROM timber_production_2 GROUP BY country, establishment_year; |
What is the number of products that are not cruelty-free certified and do not contain parabens? | CREATE TABLE products (product_id INT,product_name VARCHAR(255),is_cruelty_free BOOLEAN,contains_parabens BOOLEAN); | SELECT COUNT(*) FROM products WHERE is_cruelty_free = FALSE AND contains_parabens = FALSE; |
What is the average price of organic skincare products sold in the US? | CREATE TABLE products (product_id INT,product_name VARCHAR(255),price DECIMAL(5,2),is_organic BOOLEAN,country VARCHAR(255)); | SELECT AVG(price) FROM products WHERE is_organic = TRUE AND country = 'US'; |
What is the average rating of eco-friendly products for each category? | CREATE TABLE ProductRatings (ProductID INT,Rating INT,EcoFriendly VARCHAR(50)); INSERT INTO ProductRatings (ProductID,Rating,EcoFriendly) VALUES (1,4,'Yes'); INSERT INTO ProductRatings (ProductID,Rating,EcoFriendly) VALUES (2,5,'No'); | SELECT c.Category, AVG(Rating) as AvgRating FROM CosmeticsSales c INNER JOIN ProductRatings pr ON c.ProductID = pr.ProductID WHERE EcoFriendly = 'Yes' GROUP BY c.Category; |
What is the average ticket price for art exhibits in each city? | CREATE TABLE Exhibits (exhibit_id INT,city VARCHAR(50),price DECIMAL(5,2)); INSERT INTO Exhibits (exhibit_id,city,price) VALUES (1,'New York',25.99),(2,'Los Angeles',22.49),(3,'Chicago',30.00); | SELECT city, AVG(price) as avg_price FROM Exhibits GROUP BY city; |
What is the name of the artist who painted the most expensive painting? | CREATE TABLE paintings (name VARCHAR(255),artist VARCHAR(255),price DECIMAL(5,2)); INSERT INTO paintings (name,artist,price) VALUES ('Salvator Mundi','Leonardo da Vinci',450300000),('The Scream','Edvard Munch',120000000),('Guernica','Pablo Picasso',80000000); | SELECT artist FROM paintings WHERE price = (SELECT MAX(price) FROM paintings); |
What is the total number of humanitarian assistance events by each country in the last 3 years? | CREATE TABLE Humanitarian_Assistance (id INT,country VARCHAR(50),year INT,events INT); CREATE TABLE Countries (id INT,name VARCHAR(50),region VARCHAR(50)); | SELECT co.name, SUM(ha.events) FROM Humanitarian_Assistance ha INNER JOIN Countries co ON ha.country = co.name WHERE ha.year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY co.name; |
Show the top 5 customers by total transaction amount in Australia. | CREATE TABLE transactions (customer_id INT,transaction_amount DECIMAL(10,2),country VARCHAR(50)); INSERT INTO transactions (customer_id,transaction_amount,country) VALUES (1,120.50,'Australia'),(2,75.30,'Australia'),(3,150.00,'Australia'),(4,50.00,'Australia'),(5,250.00,'Australia'),(6,100.00,'Australia'),(7,300.00,'Australia'),(8,200.00,'Australia'),(9,400.00,'Australia'),(10,500.00,'Australia'); | SELECT customer_id, SUM(transaction_amount) AS total_amount FROM transactions WHERE country = 'Australia' GROUP BY customer_id ORDER BY total_amount DESC LIMIT 5; |
Delete the artifact record where artifact_id = 1001 from the artifacts table. | artifacts(artifact_id,name,description,date_found,excavation_site_id); excavations(excavation_site_id,name,location,start_date,end_date) | DELETE FROM artifacts |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.