instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total funding amount for startups founded by individuals who identify as Native American in the agriculture sector? | CREATE TABLE startup (id INT,name VARCHAR(100),industry VARCHAR(50),founder_native_american VARCHAR(3),funding FLOAT); INSERT INTO startup VALUES (1,'StartupA','Agriculture','Yes',1000000); INSERT INTO startup VALUES (2,'StartupB','Tech','No',7000000); INSERT INTO startup VALUES (3,'StartupC','Agriculture','Yes',120000... | SELECT SUM(funding) FROM startup WHERE founder_native_american = 'Yes' AND industry = 'Agriculture'; |
What is the maximum claim amount for each city? | CREATE TABLE Claims (Claim_Amount NUMERIC,City TEXT); INSERT INTO Claims (Claim_Amount,City) VALUES (2500,'New York'),(3000,'Los Angeles'),(2000,'San Francisco'),(1500,'New York'); | SELECT City, MAX(Claim_Amount) FROM Claims GROUP BY City; |
List the top 5 cities with the highest average monthly data usage for prepaid mobile customers. | CREATE TABLE mobile_subscribers (subscriber_id int,data_usage float,city varchar(20),subscription_type varchar(10)); INSERT INTO mobile_subscribers (subscriber_id,data_usage,city,subscription_type) VALUES (1,3000,'Seattle','postpaid'),(2,4000,'New York','postpaid'),(3,2500,'Seattle','prepaid'); CREATE TABLE network_tow... | SELECT city, AVG(data_usage) FROM mobile_subscribers WHERE subscription_type = 'prepaid' GROUP BY city ORDER BY AVG(data_usage) DESC LIMIT 5; |
Which online travel agencies (OTAs) have the highest number of virtual tour engagements in Asia? | CREATE TABLE ota (ota_id INT,ota_name TEXT,region TEXT,virtual_tour TEXT,engagements INT); INSERT INTO ota (ota_id,ota_name,region,virtual_tour,engagements) VALUES (1,'TravelEase','Asia','yes',10000),(2,'VoyagePlus','Europe','yes',12000),(3,'ExploreNow','Asia','no',8000); | SELECT ota_name, MAX(engagements) FROM ota WHERE region = 'Asia' AND virtual_tour = 'yes' GROUP BY ota_name |
Update the financial capability score of 'JohnDoe' to 80 in the 'financial_capability' table. | CREATE TABLE financial_capability (id INT,name VARCHAR(20),score INT); INSERT INTO financial_capability (id,name,score) VALUES (1,'JohnDoe',70),(2,'JaneDoe',85),(3,'MikeSmith',90); | UPDATE financial_capability SET score = 80 WHERE name = 'JohnDoe'; |
What is the total installed capacity of renewable energy in the world? | CREATE TABLE renewable_energy_world (plant_id INT,location VARCHAR(100),capacity FLOAT); INSERT INTO renewable_energy_world VALUES (1,'USA',500),(2,'Canada',700),(3,'Mexico',600),(4,'Brazil',800),(5,'India',900); | SELECT SUM(capacity) as total_capacity FROM renewable_energy_world; |
Insert a new travel advisory for Mexico into the travel_advisories table. | CREATE TABLE travel_advisories (id INT,country TEXT,region TEXT,advisory TEXT,date DATE); | INSERT INTO travel_advisories (country, advisory) VALUES ('Mexico', 'Exercise caution due to increased crime rates.'); |
Find the total number of employees in the "manufacturing" department | CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO employees (id,name,department) VALUES (1,'John Doe','manufacturing'),(2,'Jane Smith','engineering'),(3,'Alice Johnson','manufacturing'); | SELECT COUNT(*) FROM employees WHERE department = 'manufacturing'; |
What is the average ticket price for events in the 'music' category, sorted by city? | CREATE TABLE events (id INT,name TEXT,category TEXT,price DECIMAL(5,2),city TEXT); INSERT INTO events (id,name,category,price,city) VALUES (1,'Concert','music',50.00,'New York'),(2,'Jazz Festival','music',35.00,'Chicago'),(3,'Rock Concert','music',60.00,'Los Angeles'); | SELECT city, AVG(price) as avg_price FROM events WHERE category = 'music' GROUP BY city ORDER BY avg_price; |
What is the total number of emergency incidents reported in each city in the state of Florida by type? | CREATE TABLE emergency_incidents_fl (id INT,city VARCHAR(255),incident_type VARCHAR(255),reported_date DATE); | SELECT city, incident_type, COUNT(*) as total_incidents FROM emergency_incidents_fl GROUP BY city, incident_type; |
What is the minimum quantity of a product that is part of a circular supply chain and is produced in a developing country? | CREATE TABLE products (product_id INT,is_circular BOOLEAN,country VARCHAR(20),quantity INT); INSERT INTO products (product_id,is_circular,country,quantity) VALUES (1,true,'Developing',10),(2,false,'Developed',20),(3,true,'Developing',30); | SELECT MIN(products.quantity) FROM products WHERE products.is_circular = true AND products.country = 'Developing'; |
Delete the TV show 'Friends' from the 'TV_Shows' table if it has less than 6 seasons. | CREATE TABLE TV_Shows (show_id INT PRIMARY KEY,name VARCHAR(100),genre VARCHAR(50),release_year INT,seasons INT); INSERT INTO TV_Shows (show_id,name,genre,release_year,seasons) VALUES (1,'Friends','Comedy',1994,10),(2,'The Witcher','Fantasy',2019,1); | DELETE FROM TV_Shows WHERE name = 'Friends' AND seasons < 6; |
Get the status and count of shipments for each warehouse_id from the shipment table grouped by status and warehouse_id | CREATE TABLE shipment (shipment_id VARCHAR(10),status VARCHAR(20),warehouse_id VARCHAR(10),carrier_name VARCHAR(30),shipped_date DATE); | SELECT status, warehouse_id, COUNT(*) as count FROM shipment GROUP BY status, warehouse_id; |
What is the minimum and maximum number of tickets purchased by fans in the 'fans' table for each city? | CREATE TABLE fans (name VARCHAR(50),city VARCHAR(30),tickets_purchased INT); INSERT INTO fans (name,city,tickets_purchased) VALUES ('Alice','New York',5),('Bob','Los Angeles',3); | SELECT city, MIN(tickets_purchased) AS min_tickets, MAX(tickets_purchased) AS max_tickets FROM fans GROUP BY city; |
Number of community development initiatives, by region and gender, for the year 2021? | CREATE TABLE community_development (id INT,region VARCHAR(255),gender VARCHAR(255),initiative_count INT,year INT); INSERT INTO community_development (id,region,gender,initiative_count,year) VALUES (1,'Latin America','Female',250,2021),(2,'Latin America','Male',180,2021),(3,'Africa','Female',300,2021); | SELECT region, gender, SUM(initiative_count) as total_initiative_count FROM community_development WHERE year = 2021 GROUP BY region, gender; |
How many wind farms are there in Germany with a capacity greater than 5 MW? | CREATE TABLE WindFarms (id INT,country VARCHAR(20),capacity FLOAT); INSERT INTO WindFarms (id,country,capacity) VALUES (1,'Germany',6.2),(2,'Germany',4.8),(3,'Spain',5.5); | SELECT COUNT(*) FROM WindFarms WHERE country = 'Germany' AND capacity > 5; |
Update the renewable energy source for 'ProjectD' in the US to 'Geothermal'. | CREATE TABLE green_buildings (project_name VARCHAR(50),country VARCHAR(50),renewable_energy_source VARCHAR(50)); INSERT INTO green_buildings (project_name,country,renewable_energy_source) VALUES ('ProjectD','US','Solar'); | UPDATE green_buildings SET renewable_energy_source = 'Geothermal' WHERE project_name = 'ProjectD' AND country = 'US'; |
What is the total mass of space debris in orbit around Earth? | CREATE TABLE SpaceDebris (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),mass FLOAT,orbit_date DATE); | SELECT SUM(mass) as total_mass FROM SpaceDebris WHERE orbit_date = (SELECT MAX(orbit_date) FROM SpaceDebris); |
List all virtual reality (VR) games and their designers. | CREATE TABLE Games (GameID INT,Title VARCHAR(50),Genre VARCHAR(20),Platform VARCHAR(10)); CREATE TABLE VRGames (GameID INT,Designer VARCHAR(50)); INSERT INTO Games (GameID,Title,Genre,Platform) VALUES (1,'CyberSphere','Action','PC'); INSERT INTO VRGames (GameID,Designer) VALUES (1,'John Doe'); | SELECT Games.Title, VRGames.Designer FROM Games INNER JOIN VRGames ON Games.GameID = VRGames.GameID WHERE Games.Platform = 'VR'; |
What is the revenue by day of the week for all restaurants? | CREATE TABLE sales (id INT,restaurant_id INT,sale_date DATE,sales DECIMAL(10,2)); CREATE VIEW day_sales AS SELECT restaurant_id,EXTRACT(DOW FROM sale_date) as day_of_week,SUM(sales) as total_sales FROM sales GROUP BY restaurant_id,day_of_week; | SELECT d.day_of_week, SUM(ds.total_sales) as total_sales FROM day_sales ds JOIN day_sales d ON ds.day_of_week = d.day_of_week GROUP BY d.day_of_week; |
What is the average credit score of customers with high-risk investment portfolios? | CREATE TABLE customers (id INT,name VARCHAR(255),credit_score INT,investment_risk VARCHAR(255)); INSERT INTO customers (id,name,credit_score,investment_risk) VALUES (1,'Alice',700,'high'),(2,'Bob',650,'medium'),(3,'Charlie',800,'low'),(4,'Diana',600,'high'); | SELECT AVG(c.credit_score) FROM customers c WHERE c.investment_risk = 'high'; |
What is the total value of social impact bonds issued by organizations in the technology sector? | CREATE TABLE social_impact_bonds (id INT,organization_name VARCHAR(255),sector VARCHAR(255),issue_year INT,value FLOAT); INSERT INTO social_impact_bonds (id,organization_name,sector,issue_year,value) VALUES (1,'Acme Corp','Technology',2018,2000000),(2,'XYZ Foundation','Healthcare',2019,3000000),(3,'Global Giving','Educ... | SELECT sector, SUM(value) as total_value FROM social_impact_bonds WHERE sector = 'Technology' GROUP BY sector; |
Display the total number of satellites launched by each country in descending order from the satellite_deployment table | CREATE TABLE satellite_deployment (id INT PRIMARY KEY,country VARCHAR(100),launch_date DATE,satellite_name VARCHAR(100)); | SELECT country, COUNT(*) as total_launches FROM satellite_deployment GROUP BY country ORDER BY total_launches DESC; |
What is the percentage of satellites launched by the US out of the total number of satellites launched? | CREATE TABLE satellites (id INT,country VARCHAR(255),launch_date DATE); | SELECT (US_launches * 100.0 / total_launches) AS percentage FROM (SELECT COUNT(*) AS US_launches FROM satellites WHERE country = 'US') AS subquery1, (SELECT COUNT(*) AS total_launches FROM satellites) AS subquery2; |
Create a view for 'open_cases' | CREATE TABLE cases (id INT PRIMARY KEY,case_number VARCHAR(50),date_reported DATE,status VARCHAR(10)); | CREATE VIEW open_cases AS SELECT * FROM cases WHERE status = 'open'; |
What is the average time taken for cases to be resolved for each ethnicity of judges? | CREATE TABLE public.judges (id SERIAL PRIMARY KEY,name VARCHAR(255),age INT,ethnicity VARCHAR(255),appointment_date DATE); CREATE TABLE public.cases (id SERIAL PRIMARY KEY,judge_id INT,case_number VARCHAR(255),case_date DATE,case_type VARCHAR(255),court_location VARCHAR(255)); | SELECT j.ethnicity, AVG(c.case_date - j.appointment_date) as average_time_to_resolve FROM public.judges j JOIN public.cases c ON j.id = c.judge_id GROUP BY j.ethnicity; |
What is the percentage of customers in Canada who prefer sustainable fashion, and how many customers are there in total? | CREATE TABLE customers (customer_id INT,customer_name VARCHAR(50),country VARCHAR(50),sustainable_fashion BOOLEAN); INSERT INTO customers VALUES (1,'Customer A','Canada',true); INSERT INTO customers VALUES (2,'Customer B','Canada',false); INSERT INTO customers VALUES (3,'Customer C','Canada',true); INSERT INTO customer... | SELECT (COUNT(*) FILTER (WHERE sustainable_fashion = true)) * 100.0 / COUNT(*) as percentage, COUNT(*) as total_customers FROM customers WHERE country = 'Canada'; |
What is the total number of security incidents in the education sector? | CREATE TABLE security_incidents (id INT,sector VARCHAR(20),incident VARCHAR(50)); INSERT INTO security_incidents (id,sector,incident) VALUES (1,'Education','Phishing Attack'); | SELECT COUNT(*) FROM security_incidents WHERE sector = 'Education'; |
What are the total installed solar capacities for projects in the solar and solar_farms tables, grouped by country? | CREATE TABLE solar(id INT,project_name VARCHAR(50),capacity_mw FLOAT,country VARCHAR(50));CREATE TABLE solar_farms(id INT,project_name VARCHAR(50),capacity_mw FLOAT,country VARCHAR(50)); | SELECT s.country, SUM(s.capacity_mw + sf.capacity_mw) AS total_capacity FROM solar s INNER JOIN solar_farms sf ON s.project_name = sf.project_name GROUP BY s.country; |
Get the total quantity of recycled materials used in production | CREATE TABLE materials (material_id INT,is_recycled BOOLEAN); INSERT INTO materials (material_id,is_recycled) VALUES (1,TRUE),(2,FALSE); CREATE TABLE production (production_id INT,material_id INT,quantity INT); INSERT INTO production (production_id,material_id,quantity) VALUES (1,1,100),(2,2,50); | SELECT SUM(production.quantity) FROM production INNER JOIN materials ON production.material_id = materials.material_id WHERE materials.is_recycled = TRUE; |
What is the average donation amount per month for a specific donor? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationAmount DECIMAL,DonationDate DATE); INSERT INTO Donors (DonorID,DonorName,DonationAmount,DonationDate) VALUES (1,'John Doe',50.00,'2022-01-01'),(2,'Jane Smith',100.00,'2022-01-05'),(3,'Mike Johnson',75.00,'2022-01-10'),(4,'Sara Brown',150.00,'2022-01-15'),(5,'David... | SELECT DonorName, AVG(DonationAmount) AS AverageDonationAmount FROM Donors GROUP BY DonorName, DATE_TRUNC('month', DonationDate) ORDER BY DonorName; |
What is the minimum salary for employees? | CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50),salary FLOAT); INSERT INTO employees (id,name,department,salary) VALUES (1,'John Doe','IT',85000.00),(2,'Jane Smith','HR',68000.00),(3,'Alice Johnson','IT',90000.00); | SELECT MIN(salary) FROM employees; |
What is the average weight of containers handled by port 'Seattle'? | CREATE TABLE ports (port_id INT,port_name VARCHAR(20)); INSERT INTO ports VALUES (1,'Seattle'),(2,'New_York'); CREATE TABLE cargo (cargo_id INT,port_id INT,container_weight FLOAT); INSERT INTO cargo VALUES (1,1,2000.5),(2,1,3000.2),(3,2,1500.3); | SELECT AVG(container_weight) FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Seattle'); |
What is the sum of all Shariah-compliant finance assets in the African continent? | CREATE TABLE shariah_compliant_finance (id INT,country VARCHAR(255),asset_value DECIMAL(10,2)); | SELECT SUM(asset_value) FROM shariah_compliant_finance WHERE country IN (SELECT country FROM (SELECT DISTINCT country FROM shariah_compliant_finance WHERE region = 'Africa') t); |
What is the minimum number of lanes for highways in Florida? | CREATE TABLE Highways (id INT,name TEXT,location TEXT,state TEXT,lanes INT); INSERT INTO Highways (id,name,location,state,lanes) VALUES (1,'Highway A','Location A','Florida',4),(2,'Highway B','Location B','Georgia',6); | SELECT MIN(lanes) FROM Highways WHERE state = 'Florida'; |
What is the maximum number of unique hashtags used in a single post by users in India? | CREATE TABLE posts (id INT,user_id INT,post_date DATE,post_text VARCHAR(255)); CREATE TABLE users (id INT,country VARCHAR(50)); | SELECT MAX(hashtag_cnt) FROM (SELECT COUNT(DISTINCT hashtag) hashtag_cnt FROM (SELECT user_id, TRIM(LEADING '#' FROM SPLIT_PART(post_text, ' ', n)) hashtag FROM posts, GENERATE_SERIES(1, ARRAY_LENGTH(STRING_TO_ARRAY(post_text, ' '))) n WHERE user_id IN (SELECT id FROM users WHERE country = 'India')) t GROUP BY user_id)... |
What is the total production rate of mining operations located in the Americas region? | CREATE TABLE MiningOperations (OperationID INT,OperationName VARCHAR(50),Country VARCHAR(50),ProductionRate FLOAT); INSERT INTO MiningOperations (OperationID,OperationName,Country,ProductionRate) VALUES (1,'Operation A','Canada',5000); INSERT INTO MiningOperations (OperationID,OperationName,Country,ProductionRate) VALU... | SELECT SUM(ProductionRate) FROM MiningOperations WHERE Country IN (SELECT Country FROM Countries WHERE Region = 'Americas'); |
What is the minimum depth at which coral reefs are found in the Caribbean Sea? | CREATE TABLE coral_reefs (id INT,name VARCHAR(255),avg_depth FLOAT,region VARCHAR(255)); INSERT INTO coral_reefs (id,name,avg_depth,region) VALUES (1,'Elkhorn Reef',15,'Caribbean'); | SELECT MIN(avg_depth) FROM coral_reefs WHERE region = 'Caribbean'; |
Calculate the policy cancellation rate for policyholders from Brazil, calculated as the percentage of policyholders who cancelled their policies within the first month, for each month. | CREATE TABLE Policyholders (PolicyholderID INT,Country VARCHAR(50),Cancelled BOOLEAN,CancellationDate DATE); INSERT INTO Policyholders VALUES (1,'Brazil',TRUE,'2022-01-01'); INSERT INTO Policyholders VALUES (2,'Brazil',FALSE,'2022-01-15'); INSERT INTO Policyholders VALUES (3,'Brazil',FALSE,'2022-02-01'); | SELECT EXTRACT(MONTH FROM CancellationDate) AS Month, COUNT(*) * 100.0 / SUM(CASE WHEN EXTRACT(MONTH FROM CancellationDate) = EXTRACT(MONTH FROM CancellationDate) THEN 1 ELSE 0 END) OVER (PARTITION BY EXTRACT(MONTH FROM CancellationDate)) AS PolicyCancellationRate FROM Policyholders WHERE Country = 'Brazil' AND FirstMo... |
What is the total water consumption by each water treatment plant in the state of California in the month of July in the year 2022? | CREATE TABLE water_treatment_plant (plant_id INT,state VARCHAR(50),year INT,month INT,water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id,state,year,month,water_consumption) VALUES (13,'California',2022,7,12345.6),(14,'California',2022,7,23456.7),(15,'California',2022,7,34567.8); | SELECT plant_id, SUM(water_consumption) as total_water_consumption FROM water_treatment_plant WHERE state = 'California' AND year = 2022 AND month = 7 GROUP BY plant_id; |
Determine the number of fair trade certified suppliers in Oceania. | CREATE TABLE certified_suppliers (id INT,certification VARCHAR(20),region VARCHAR(20)); INSERT INTO certified_suppliers (id,certification,region) VALUES (1,'Fair Trade','Oceania'),(2,'GOTS','Europe'),(3,'Fair Trade','Oceania'); | SELECT COUNT(*) FROM certified_suppliers WHERE certification = 'Fair Trade' AND region = 'Oceania'; |
Which sustainable materials have a lower CO2 emissions than linen in the 'sustainable_materials' table? | CREATE TABLE sustainable_materials (material_id INT,material TEXT,co2_emissions FLOAT); | SELECT * FROM sustainable_materials WHERE co2_emissions < (SELECT co2_emissions FROM sustainable_materials WHERE material = 'linen'); |
What is the name of the spacecraft with the longest duration in space? | CREATE TABLE Spacecraft (name VARCHAR(30),duration INT); INSERT INTO Spacecraft (name,duration) VALUES ('Voyager 1',43827),('Voyager 2',42554); | SELECT name FROM Spacecraft ORDER BY duration DESC LIMIT 1; |
Calculate the total weight lost by users who have joined in the past 3 months. | CREATE TABLE Weight_Tracking (id INT,user_id INT,date DATE,weight_lost INT); INSERT INTO Weight_Tracking (id,user_id,date,weight_lost) VALUES (1,1,'2021-10-01',2),(2,2,'2021-11-01',3),(3,3,'2021-11-02',4),(4,4,'2021-11-03',5),(5,5,'2021-11-04',6),(6,1,'2021-11-05',1),(7,2,'2021-11-06',2),(8,3,'2021-11-07',3),(9,4,'2021... | SELECT SUM(weight_lost) FROM Weight_Tracking wt JOIN Memberships m ON wt.user_id = m.user_id WHERE m.start_date >= DATEADD(MONTH, -3, CURRENT_DATE); |
What was the total amount donated by organizations based in Germany to education-focused causes in 2019? | CREATE TABLE Organizations (id INT,organization_name TEXT,country TEXT); CREATE TABLE Organization_Donations (organization_id INT,cause_id INT,donation_amount DECIMAL(10,2),donation_date DATE); CREATE TABLE Causes (id INT,cause_name TEXT,cause_category TEXT); | SELECT SUM(od.donation_amount) FROM Organization_Donations od JOIN Organizations o ON od.organization_id = o.id WHERE o.country = 'Germany' AND EXTRACT(YEAR FROM od.donation_date) = 2019 AND od.cause_id IN (SELECT id FROM Causes WHERE cause_category = 'Education'); |
What is the average rating of organic cosmetics with a recycling program? | CREATE TABLE cosmetics (product_id INT,product_name VARCHAR(50),is_organic BOOLEAN,has_recycling_program BOOLEAN,rating FLOAT); | SELECT AVG(rating) FROM cosmetics WHERE is_organic = TRUE AND has_recycling_program = TRUE; |
What are the top 3 countries with the most agricultural innovation projects in the last 5 years, and how many projects are there in each country? | CREATE TABLE agricultural_innovation (country VARCHAR(50),project_name VARCHAR(50),project_start_date DATE); | SELECT country, COUNT(*) as project_count FROM agricultural_innovation WHERE project_start_date >= DATEADD(year, -5, GETDATE()) GROUP BY country ORDER BY project_count DESC LIMIT 3; |
What is the total number of military aircrafts manufactured by Lockheed Martin? | CREATE TABLE manufacturer (id INT,name VARCHAR(255)); INSERT INTO manufacturer (id,name) VALUES (1,'Lockheed Martin'); CREATE TABLE aircraft (id INT,name VARCHAR(255),manufacturer_id INT); INSERT INTO aircraft (id,name,manufacturer_id) VALUES (1,'F-35',1),(2,'F-16',1); | SELECT COUNT(*) FROM aircraft WHERE manufacturer_id = (SELECT id FROM manufacturer WHERE name = 'Lockheed Martin'); |
Delete environmental impact records for site 2 | CREATE TABLE impact (id INT PRIMARY KEY,site_id INT,impact_score INT); | DELETE FROM impact WHERE site_id = 2; |
What is the average age of athletes in the 'athlete_performance' table? | CREATE TABLE athlete_performance (athlete_id INT,name VARCHAR(50),age INT,position VARCHAR(50)); INSERT INTO athlete_performance (athlete_id,name,age,position) VALUES (1,'John Doe',25,'Goalie'); INSERT INTO athlete_performance (athlete_id,name,age,position) VALUES (2,'Jane Smith',30,'Forward'); | SELECT AVG(age) FROM athlete_performance; |
What was the total revenue generated from memberships in the first quarter of 2022?' | CREATE SCHEMA fitness; CREATE TABLE memberships (id INT,member_name VARCHAR(50),start_date DATE,end_date DATE,membership_type VARCHAR(50),price DECIMAL(5,2)); INSERT INTO memberships VALUES (1,'John Doe','2022-01-01','2022-03-31','Premium',50.00),(2,'Jane Smith','2022-01-15','2022-06-30','Basic',25.00); | SELECT SUM(price) FROM fitness.memberships WHERE start_date <= '2022-03-31' AND end_date >= '2022-01-01'; |
Insert data into the "animals" table from the previous row | CREATE TABLE animals (animal_id SERIAL PRIMARY KEY,name VARCHAR(255)); | INSERT INTO animals (name) VALUES ('Lion'), ('Tiger'), ('Bear'); |
Who are the top 5 manufacturers with the most aircraft produced? | CREATE TABLE aircraft_produced (aircraft_id INT,manufacturer VARCHAR(50)); | SELECT manufacturer, COUNT(aircraft_id) as num_aircraft FROM aircraft_produced GROUP BY manufacturer ORDER BY num_aircraft DESC LIMIT 5; |
What climate mitigation projects have been funded by the private sector? | CREATE TABLE climate_projects (id INT PRIMARY KEY,title VARCHAR(255),description TEXT,start_date DATE,end_date DATE,funding_source VARCHAR(255)); INSERT INTO climate_projects (id,title,description,start_date,end_date,funding_source) VALUES (1,'Solar Farm Construction','Construction of a 100 MW solar farm.','2022-01-01'... | SELECT * FROM climate_projects WHERE funding_source = 'Private Investment'; |
What is the waste generation in urban and rural areas in India, grouped by year? | CREATE TABLE waste_generation_by_area (id INT,country VARCHAR(255),area VARCHAR(255),year INT,amount INT); INSERT INTO waste_generation_by_area (id,country,area,year,amount) VALUES (1,'India','Urban',2015,10000),(2,'India','Rural',2015,8000),(3,'India','Urban',2016,11000),(4,'India','Rural',2016,9000); | SELECT area, year, SUM(amount) as total_waste FROM waste_generation_by_area WHERE country = 'India' GROUP BY area, year; |
What is the average number of hours of professional development completed by teachers who are also mentors? | CREATE TABLE Teachers (TeacherID INT PRIMARY KEY,Mentor BOOLEAN,Hours INT); INSERT INTO Teachers (TeacherID,Mentor,Hours) VALUES (1,1,20); | SELECT AVG(Hours) FROM Teachers WHERE Mentor = 1; |
What is the average 'recycled_content' for 'product_transparency' records from 'India'? | CREATE TABLE product_transparency (product_id INT,product_name VARCHAR(50),circular_supply_chain BOOLEAN,recycled_content DECIMAL(4,2),COUNTRY VARCHAR(50)); | SELECT AVG(recycled_content) FROM product_transparency WHERE country = 'India'; |
Who are the top 2 contributors of humanitarian assistance to African countries in the last 2 years? | CREATE TABLE humanitarian_assistance (assistance_id INT,donor TEXT,recipient TEXT,amount DECIMAL(10,2),date DATE); INSERT INTO humanitarian_assistance (assistance_id,donor,recipient,amount,date) VALUES (1,'USA','Somalia',200000,'2020-04-01'),(2,'Germany','Nigeria',300000,'2019-05-01'); | SELECT humanitarian_assistance.donor, SUM(humanitarian_assistance.amount) as total_assistance FROM humanitarian_assistance WHERE humanitarian_assistance.recipient LIKE 'Africa%' AND humanitarian_assistance.date BETWEEN DATE_SUB(CURDATE(), INTERVAL 2 YEAR) AND CURDATE() GROUP BY humanitarian_assistance.donor ORDER BY to... |
What is the average response time for emergency services, categorized by day of the week, for the current month? | CREATE TABLE ResponseTimes (ID INT,Service VARCHAR(50),Day VARCHAR(15),Time INT); INSERT INTO ResponseTimes (ID,Service,Day,Time) VALUES (5,'Fire','Monday',7),(6,'Fire','Tuesday',6),(7,'Ambulance','Wednesday',8),(8,'Ambulance','Thursday',7),(9,'Police','Friday',9),(10,'Police','Saturday',8); | SELECT Service, AVG(Time) OVER (PARTITION BY Service ORDER BY Day) AS AvgResponseTime FROM ResponseTimes WHERE Day IN (SELECT TO_CHAR(Date, 'Day') FROM generate_series(DATE_TRUNC('month', CURRENT_DATE), CURRENT_DATE, '1 day') Date); |
What is the average monthly data usage for postpaid and prepaid mobile subscribers in the region of East? | CREATE TABLE subscriber_data (subscriber_id INT,subscriber_type VARCHAR(10),data_usage FLOAT,region VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id,subscriber_type,data_usage,region) VALUES (1,'postpaid',3.5,'East'),(2,'prepaid',4.2,'West'),(3,'postpaid',200.5,'North'),(4,'prepaid',3.8,'South'),(5,'postpaid',2... | SELECT subscriber_type, AVG(data_usage) FROM subscriber_data WHERE region = 'East' GROUP BY subscriber_type; |
What is the average billable hours per case for attorneys in the New York office? | CREATE TABLE attorneys (attorney_id INT,attorney_name TEXT,office_location TEXT); INSERT INTO attorneys (attorney_id,attorney_name,office_location) VALUES (1,'John Doe','San Francisco'),(2,'Jane Smith','New York'); CREATE TABLE cases (case_id INT,attorney_id INT,billable_hours INT); INSERT INTO cases (case_id,attorney_... | SELECT AVG(c.billable_hours) as avg_billable_hours FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id WHERE a.office_location = 'New York'; |
What is the total number of transactions and their combined volume for each digital asset on the Ethereum network, grouped by month? | CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(255),network VARCHAR(255)); INSERT INTO digital_assets (asset_id,asset_name,network) VALUES (1,'ETH','Ethereum'),(2,'DAI','Ethereum'); CREATE TABLE transactions (transaction_id INT,asset_id INT,transaction_time TIMESTAMP); INSERT INTO transactions (transactio... | SELECT DATE_FORMAT(transaction_time, '%Y-%m') AS month, asset_name, COUNT(*) AS transactions, SUM(1) AS volume FROM transactions JOIN digital_assets ON transactions.asset_id = digital_assets.asset_id GROUP BY month, asset_name; |
How many unique strains were sold in the state of Colorado in Q2 2022? | CREATE TABLE sales (id INT,state VARCHAR(50),quarter VARCHAR(10),strain VARCHAR(50)); | SELECT COUNT(DISTINCT strain) FROM sales WHERE state = 'Colorado' AND quarter = 'Q2'; |
List all the distinct rare earth elements in the market trends data. | CREATE TABLE market_trends (element VARCHAR(255),price DECIMAL(10,2),quantity INT); INSERT INTO market_trends (element,price,quantity) VALUES ('Neodymium',92.50,5000),('Praseodymium',85.20,3000),('Dysprosium',120.00,2000); | SELECT DISTINCT element FROM market_trends; |
Get all articles with their corresponding media ethics information from 'articles' and 'ethics' tables | CREATE TABLE articles (article_id INT PRIMARY KEY,title VARCHAR(255),content TEXT,publish_date DATE); CREATE TABLE ethics (ethics_id INT PRIMARY KEY,article_id INT,ethical_issue VARCHAR(255),resolution TEXT); | SELECT articles.title, ethics.ethical_issue FROM articles LEFT JOIN ethics ON articles.article_id = ethics.article_id; |
What are the different mining operations in the Asia-Pacific region? | CREATE TABLE Operations (Company VARCHAR(50),Operation VARCHAR(50),Location VARCHAR(10)); INSERT INTO Operations (Company,Operation,Location) VALUES ('GHI Mines','Coal','Asia'),('JKL Mining','Gold','Australia'),('MNO Drilling','Oil','Pacific'); | SELECT DISTINCT Operation FROM Operations WHERE Location LIKE 'Asia%' OR Location LIKE 'Pacific%' |
List all donations and their corresponding donor names | CREATE TABLE donors (id INT,name VARCHAR(50)); CREATE TABLE donations (id INT,donor_id INT,amount DECIMAL(10,2)); | SELECT donors.name, donations.amount FROM donors JOIN donations ON donors.id = donations.donor_id; |
What is the maximum temperature recorded in the Southern Ocean? | CREATE TABLE deep_sea_temperature_southern (location text,temperature numeric); INSERT INTO deep_sea_temperature_southern (location,temperature) VALUES ('Southern Ocean',-2),('Atlantic Ocean',25); | SELECT MAX(temperature) FROM deep_sea_temperature_southern WHERE location = 'Southern Ocean'; |
What is the average amount donated per donor from the United States in the year 2021? | CREATE TABLE donors (id INT,name TEXT,country TEXT,amount_donated DECIMAL(10,2)); | SELECT AVG(amount_donated) FROM donors WHERE country = 'United States' AND YEAR(donation_date) = 2021 AND id NOT IN (SELECT id FROM organizations); |
What is the minimum dissolved oxygen level recorded for fish farms in Indonesia? | CREATE TABLE fish_farms (id INT,name TEXT,country TEXT,latitude DECIMAL(9,6),longitude DECIMAL(9,6)); INSERT INTO fish_farms (id,name,country,latitude,longitude) VALUES (1,'Farm X','Indonesia',-8.123456,114.78901); INSERT INTO fish_farms (id,name,country,latitude,longitude) VALUES (2,'Farm Y','Indonesia',-7.54321,113.2... | SELECT MIN(dissolved_oxygen) FROM water_quality wq JOIN fish_farms ff ON wq.farm_id = ff.id WHERE ff.country = 'Indonesia'; |
What is the total number of sustainable tour packages sold by vendors from Oceania? | CREATE TABLE Vendors (VendorID INT,VendorName VARCHAR(50),Country VARCHAR(50)); INSERT INTO Vendors (VendorID,VendorName,Country) VALUES (1,'GreenVacations','Australia'),(2,'EcoTours','New Zealand'),(3,'SustainableJourneys','Fiji'),(4,'BluePlanetTours','USA'); CREATE TABLE Packages (PackageID INT,VendorID INT,PackageTy... | SELECT V.Country, SUM(P.Sales) as TotalSales FROM Vendors V INNER JOIN Packages P ON V.VendorID = P.VendorID WHERE V.Country LIKE 'Oceania%' AND P.PackageType = 'Sustainable' GROUP BY V.Country; |
What is the total number of hospitals in the "Alabama" and "Georgia" rural regions? | CREATE TABLE Hospitals (HospitalID INT,Name VARCHAR(50),Location VARCHAR(50),Region VARCHAR(20)); INSERT INTO Hospitals (HospitalID,Name,Location,Region) VALUES (1,'Hospital A','Location A','Rural Alabama'); INSERT INTO Hospitals (HospitalID,Name,Location,Region) VALUES (2,'Hospital B','Location B','Rural Georgia'); | SELECT COUNT(*) FROM Hospitals WHERE Region IN ('Rural Alabama', 'Rural Georgia'); |
Find the top 3 cities with the highest population in the 'world_cities' database. | CREATE TABLE world_cities (city VARCHAR(50),population INT); INSERT INTO world_cities (city,population) VALUES ('New York',8500000),('Los Angeles',4000000),('Tokyo',9000000),('Sydney',5000000),('Berlin',3500000); | SELECT city, population FROM world_cities ORDER BY population DESC LIMIT 3; |
Update the 'population' field for the 'Giant Panda' species in the 'animals' table | CREATE TABLE animals (id INT PRIMARY KEY,name VARCHAR(50),species VARCHAR(50),population INT); | UPDATE animals SET population = 1864 WHERE species = 'Giant Panda'; |
Show the average energy efficiency (kWh/m^2) of buildings in Paris | CREATE TABLE buildings (building_id INT,name VARCHAR(255),city VARCHAR(255),energy_efficiency FLOAT); INSERT INTO buildings (building_id,name,city,energy_efficiency) VALUES (1,'Building 1','Tokyo',0.5),(2,'Building 2','Tokyo',0.75),(3,'Building 3','Paris',1.0),(4,'Building 4','Paris',1.25); | SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'Paris'; |
Find the number of unique materials used by each company in the circular economy. | CREATE TABLE Companies (id INT,name VARCHAR(255)); INSERT INTO Companies (id,name) VALUES (1,'CompanyA'),(2,'CompanyB'),(3,'CompanyC'); CREATE TABLE Materials (id INT,company_id INT,material VARCHAR(255)); INSERT INTO Materials (id,company_id,material) VALUES (1,1,'Organic cotton'),(2,1,'Recycled polyester'),(3,2,'Orga... | SELECT Companies.name, COUNT(DISTINCT Materials.material) AS unique_materials FROM Companies JOIN Materials ON Companies.id = Materials.company_id GROUP BY Companies.name; |
What was the total investment in agricultural innovation projects in Tanzania between 2015 and 2017, and how many were implemented? | CREATE TABLE agri_innovation_tanzania (project VARCHAR(50),country VARCHAR(50),start_year INT,end_year INT,investment FLOAT); INSERT INTO agri_innovation_tanzania (project,country,start_year,end_year,investment) VALUES ('Conservation Agriculture','Tanzania',2015,2017,1000000),('Crop Diversification','Tanzania',2015,201... | SELECT SUM(investment), COUNT(*) FROM agri_innovation_tanzania WHERE country = 'Tanzania' AND start_year BETWEEN 2015 AND 2017 AND end_year BETWEEN 2015 AND 2017; |
What is the total number of transactions for each digital asset in the 'ETH' network? | CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(50),network VARCHAR(50)); INSERT INTO digital_assets (asset_id,asset_name,network) VALUES (1,'Tether','ETH'),(2,'USD Coin','ETH'); CREATE TABLE transactions (transaction_id INT,asset_id INT,quantity DECIMAL(10,2)); INSERT INTO transactions (transaction_id,ass... | SELECT d.asset_name, SUM(t.quantity) as total_transactions FROM digital_assets d JOIN transactions t ON d.asset_id = t.asset_id WHERE d.network = 'ETH' GROUP BY d.asset_name; |
What is the total number of academic papers published by the Mathematics department in the last 5 years? | CREATE TABLE academic_papers (id INT,title VARCHAR(50),department VARCHAR(50),publication_year INT); | SELECT SUM(1) FROM academic_papers WHERE department = 'Mathematics' AND publication_year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE); |
What is the retention rate for customers who have been with the company for over 24 months? | CREATE TABLE customers (customer_id INT,service_length INT,plan_type VARCHAR(10)); INSERT INTO customers (customer_id,service_length,plan_type) VALUES (1,25,'postpaid'),(2,18,'prepaid'); CREATE TABLE plan_types (plan_type VARCHAR(10),retention_rate FLOAT); INSERT INTO plan_types (plan_type,retention_rate) VALUES ('post... | SELECT COUNT(c.customer_id) FROM customers c JOIN plan_types pt ON c.plan_type = pt.plan_type WHERE c.service_length > 24 * 12 AND pt.retention_rate = (SELECT MAX(pt.retention_rate) FROM plan_types pt); |
What is the total revenue generated by sustainable tourism businesses in Asia in Q1 2023? | CREATE TABLE Regions (id INT,name VARCHAR(255)); INSERT INTO Regions (id,name) VALUES (1,'Asia'),(2,'Europe'),(3,'Africa'),(4,'North America'),(5,'South America'); CREATE TABLE Businesses (id INT,region_id INT,type VARCHAR(255),revenue INT); INSERT INTO Businesses (id,region_id,type,revenue) VALUES (1,1,'Sustainable',1... | SELECT SUM(b.revenue) as total_revenue FROM Businesses b JOIN Regions r ON b.region_id = r.id WHERE r.name = 'Asia' AND b.type = 'Sustainable' AND b.revenue IS NOT NULL AND QUARTER(b.revenue_date) = 1 AND YEAR(b.revenue_date) = 2023; |
How many containers were unloaded at the Port of Los Angeles in January 2022? | CREATE TABLE ports (id INT,name TEXT); INSERT INTO ports (id,name) VALUES (1,'Port of Los Angeles'); CREATE TABLE container_events (id INT,port_id INT,event_date DATE,event_type TEXT,quantity INT); INSERT INTO container_events (id,port_id,event_date,event_type,quantity) VALUES (1,1,'2022-01-01','unload',500),(2,1,'2022... | SELECT SUM(quantity) FROM container_events WHERE port_id = (SELECT id FROM ports WHERE name = 'Port of Los Angeles') AND event_type = 'unload' AND event_date BETWEEN '2022-01-01' AND '2022-01-31'; |
What is the total number of construction laborers in Florida and Georgia combined? | CREATE TABLE labor_stats (state VARCHAR(20),occupation VARCHAR(20),number_of_employees INT); INSERT INTO labor_stats (state,occupation,number_of_employees) VALUES ('Florida','Construction laborer',12000); INSERT INTO labor_stats (state,occupation,number_of_employees) VALUES ('Georgia','Construction laborer',9000); | SELECT SUM(number_of_employees) FROM labor_stats WHERE (state = 'Florida' OR state = 'Georgia') AND occupation = 'Construction laborer'; |
What was the total quantity of parts produced by workers from the 'assembly' department for February 2021? | CREATE TABLE workers (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO workers (id,name,department) VALUES (1,'Rajesh Patel','Assembly'),(2,'Sophia Rodriguez','Quality Control'); CREATE TABLE parts (id INT,worker_id INT,quantity INT,date DATE); INSERT INTO parts (id,worker_id,quantity,date) VALUES (1,1,120,... | SELECT w.department, SUM(p.quantity) as total_quantity FROM workers w JOIN parts p ON w.id = p.worker_id WHERE w.department = 'Assembly' AND p.date BETWEEN '2021-02-01' AND '2021-02-28' GROUP BY w.department; |
What is the total quantity of clothing products sold by ethical brands in Germany and France? | CREATE TABLE ethical_brands (brand_id INT,brand_name TEXT,product_category TEXT); INSERT INTO ethical_brands (brand_id,brand_name,product_category) VALUES (1,'BrandA','Clothing'),(2,'BrandB','Electronics'),(3,'BrandC','Clothing'); CREATE TABLE sales (sale_id INT,brand_id INT,product_quantity INT,country TEXT); INSERT I... | SELECT SUM(product_quantity) FROM sales JOIN ethical_brands ON sales.brand_id = ethical_brands.brand_id WHERE country IN ('Germany', 'France') AND ethical_brands.product_category = 'Clothing'; |
Update the accommodation name for 'Mobility' type to 'Adaptive Equipment'. | CREATE TABLE accommodation (accommodation_id INT,accommodation_name TEXT,disability_type TEXT); INSERT INTO accommodation (accommodation_id,accommodation_name,disability_type) VALUES (1,'Wheelchair Ramp','Mobility'); INSERT INTO accommodation (accommodation_id,accommodation_name,disability_type) VALUES (2,'Sign Languag... | UPDATE accommodation SET accommodation_name = 'Adaptive Equipment' WHERE disability_type = 'Mobility'; |
What was the average cost of community development initiatives in Brazil in 2018?' | CREATE TABLE community_development_initiatives (id INT,country VARCHAR(255),year INT,cost FLOAT); INSERT INTO community_development_initiatives (id,country,year,cost) VALUES (1,'Brazil',2018,25000.00); | SELECT AVG(cost) FROM community_development_initiatives WHERE country = 'Brazil' AND year = 2018; |
Find the average calorie count for all vegetarian dishes | CREATE TABLE dishes (id INT,name TEXT,vegan BOOLEAN,calories INT); INSERT INTO dishes (id,name,vegan,calories) VALUES (1,'Quinoa Salad',TRUE,350),(2,'Pizza Margherita',FALSE,500); | SELECT AVG(calories) FROM dishes WHERE vegan = TRUE; |
How many organic products were sold in the US in 2021? | CREATE TABLE sales (id INT,product VARCHAR(50),is_organic BOOLEAN,sale_date DATE); INSERT INTO sales (id,product,is_organic,sale_date) VALUES (1,'Apples',true,'2021-01-01'),(2,'Bananas',false,'2021-01-02'); | SELECT COUNT(*) FROM sales WHERE is_organic = true AND EXTRACT(YEAR FROM sale_date) = 2021; |
What is the percentage of the population that is fully vaccinated by gender? | CREATE TABLE vaccinations (id INT,gender VARCHAR(255),fully_vaccinated BOOLEAN); INSERT INTO vaccinations VALUES (1,'Male',true),(2,'Female',false),(3,'Non-binary',true); | SELECT gender, (COUNT(*) FILTER (WHERE fully_vaccinated) * 100.0 / COUNT(*)) AS pct_fully_vaccinated FROM vaccinations GROUP BY gender; |
Find the number of hotels that have not adopted AI technology in the city of New York | CREATE TABLE hotel_ai (hotel_id INT,hotel_name TEXT,city TEXT,has_adopted_ai BOOLEAN); | SELECT COUNT(*) FROM hotel_ai WHERE city = 'New York' AND has_adopted_ai = FALSE; |
What is the count of community policing events in the neighborhoods of Compton and Watts, compared to the number of events in the neighborhood of Boyle Heights? | CREATE TABLE community_policing (id INT,neighborhood VARCHAR(20),event_type VARCHAR(20),date DATE); INSERT INTO community_policing (id,neighborhood,event_type,date) VALUES (1,'Compton','meeting','2021-01-01'); INSERT INTO community_policing (id,neighborhood,event_type,date) VALUES (2,'Watts','patrol','2021-01-02'); INS... | SELECT neighborhood, SUM(event_count) FROM (SELECT neighborhood, COUNT(*) AS event_count FROM community_policing WHERE neighborhood IN ('Compton', 'Watts') GROUP BY neighborhood UNION ALL SELECT 'Boyle Heights' AS neighborhood, COUNT(*) AS event_count FROM community_policing WHERE neighborhood = 'Boyle Heights' GROUP B... |
Identify the top 2 cities with the highest total energy consumption in the "CityEnergyData" table. | CREATE TABLE CityEnergyData (City VARCHAR(50),EnergyConsumption INT); | SELECT City, SUM(EnergyConsumption) AS TotalEnergyConsumption, RANK() OVER (ORDER BY SUM(EnergyConsumption) DESC) AS Rank FROM CityEnergyData GROUP BY City HAVING Rank <= 2; |
What is the total number of certified sustainable tourism businesses in Italy? | CREATE TABLE sustainable_tourism (id INT,name TEXT,country TEXT,is_certified BOOLEAN); INSERT INTO sustainable_tourism (id,name,country,is_certified) VALUES (1,'Eco Hotel','Italy',true),(2,'Green Tourism','Italy',true),(3,'Sustainable Travel Italy','Italy',false); | SELECT COUNT(*) FROM sustainable_tourism WHERE country = 'Italy' AND is_certified = true; |
Minimum price of lipsticks with cruelty-free certification | CREATE TABLE Cosmetics (product_id INT,name VARCHAR(50),price DECIMAL(5,2),is_cruelty_free BOOLEAN,type VARCHAR(50)); | SELECT MIN(price) FROM Cosmetics WHERE type = 'Lipstick' AND is_cruelty_free = TRUE; |
How many clinical trials were conducted for each drug in the clinical_trials table, grouped by drug name? | CREATE TABLE clinical_trials (clinical_trial_id INT,drug_id INT,trial_name TEXT,trial_status TEXT,year INT); INSERT INTO clinical_trials (clinical_trial_id,drug_id,trial_name,trial_status,year) VALUES (1,1,'TrialA','Completed',2018),(2,1,'TrialB','Ongoing',2019),(3,2,'TrialC','Completed',2018),(4,3,'TrialD','Completed'... | SELECT drug_id, COUNT(*) AS total_trials FROM clinical_trials GROUP BY drug_id; |
Find the transaction date with the highest total transaction amount. | CREATE TABLE Transactions (TransactionID INT,TransactionDate DATE,Amount DECIMAL(10,2)); INSERT INTO Transactions (TransactionID,TransactionDate,Amount) VALUES (1,'2022-01-01',500.00),(2,'2022-01-02',250.00),(3,'2022-01-03',750.00),(4,'2022-01-04',1500.00); | SELECT TransactionDate, SUM(Amount) FROM Transactions GROUP BY TransactionDate ORDER BY SUM(Amount) DESC LIMIT 1; |
Find the total number of medals won by each country in the Olympics. | CREATE TABLE countries (id INT,name VARCHAR(50),sport VARCHAR(20)); CREATE TABLE athletes (id INT,name VARCHAR(50),country VARCHAR(50),medals INT); INSERT INTO countries (id,name,sport) VALUES (1,'United States','Olympics'); INSERT INTO countries (id,name,sport) VALUES (2,'China','Olympics'); INSERT INTO athletes (id,n... | SELECT countries.name, SUM(athletes.medals) FROM countries INNER JOIN athletes ON countries.name = athletes.country GROUP BY countries.name; |
What is the average carbon offset per renewable energy project in the state of California? | CREATE TABLE ca_projects (project_id INT,project_name VARCHAR(100),state VARCHAR(50),carbon_offset INT); INSERT INTO ca_projects (project_id,project_name,state,carbon_offset) VALUES (1,'CA Project A','California',5000),(2,'CA Project B','California',7000),(3,'CA Project C','California',6000); CREATE TABLE ca_renewable_... | SELECT AVG(carbon_offset) FROM ca_projects JOIN ca_renewable_projects ON ca_projects.project_id = ca_renewable_projects.project_id WHERE state = 'California'; |
List all countries with retail sales less than 8000, based on the 'TotalSales' column in the 'RetailSales' table. | CREATE TABLE RetailSales (country VARCHAR(50),TotalSales DECIMAL(10,2)); INSERT INTO RetailSales (country,TotalSales) VALUES ('USA',12500.00),('Canada',7000.00),('Mexico',5000.00),('Brazil',9000.00); | SELECT country FROM RetailSales WHERE TotalSales < 8000; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.