context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE public_schools(id INT, name TEXT, address TEXT, state TEXT); INSERT INTO public_schools VALUES (1, 'School A', 'Address A', 'California'); INSERT INTO public_schools VALUES (2, 'School B', 'Address B', 'California'); CREATE TABLE universities(id INT, name TEXT, address TEXT, state TEXT); INSERT INTO universities VALUES (1, 'University C', 'Address C', 'California'); INSERT INTO universities VALUES (2, 'University D', 'Address D', 'California');
|
What is the total number of public schools and universities in the state of California, including their names and addresses?
|
SELECT COUNT(*) as total, ps.name, ps.address FROM public_schools ps JOIN universities u ON ps.state = u.state GROUP BY ps.name, ps.address;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup (id INT, name TEXT, industry TEXT, num_employees INT); INSERT INTO startup (id, name, industry, num_employees) VALUES (1, 'CleanTechOne', 'Clean Technology', 250); INSERT INTO startup (id, name, industry, num_employees) VALUES (2, 'TechStart', 'Tech', 1000);
|
What is the average number of employees for startups with a clean technology focus?
|
SELECT AVG(num_employees) FROM startup WHERE industry = 'Clean Technology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year INT);
|
Delete a heritage site from the 'heritage_sites' table
|
DELETE FROM heritage_sites WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_providers (id INT, name TEXT, cultural_competency_score INT, community TEXT); INSERT INTO healthcare_providers (id, name, cultural_competency_score, community) VALUES (1, 'Dr. Jane Smith', 95, 'LGBTQ+'); INSERT INTO healthcare_providers (id, name, cultural_competency_score, community) VALUES (2, 'Dr. Maria Garcia', 88, 'Latinx'); INSERT INTO healthcare_providers (id, name, cultural_competency_score, community) VALUES (3, 'Dr. David Kim', 92, 'LGBTQ+');
|
What is the average cultural competency score for healthcare providers serving the LGBTQ+ community?
|
SELECT AVG(cultural_competency_score) FROM healthcare_providers WHERE community = 'LGBTQ+';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_pricing (id INT PRIMARY KEY, country VARCHAR(50), carbon_price FLOAT);
|
Delete all records in the 'carbon_pricing' table where the 'carbon_price' is less than 5
|
DELETE FROM carbon_pricing WHERE carbon_price < 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OilWells (WellID INT, Location VARCHAR(20), ProductionYear INT, OilProduction INT); INSERT INTO OilWells (WellID, Location, ProductionYear, OilProduction) VALUES (1, 'Niger Delta', 2015, 100000), (2, 'Niger Delta', 2016, 120000), (3, 'North Sea', 2014, 80000);
|
What is the total oil production, in barrels, for all wells in the Niger Delta, for the year 2015?
|
SELECT SUM(OilProduction) FROM OilWells WHERE Location = 'Niger Delta' AND ProductionYear = 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, country VARCHAR(255), vulnerability_count INT, scan_date DATE); INSERT INTO vulnerabilities (id, country, vulnerability_count, scan_date) VALUES (1, 'USA', 120, '2022-01-01'), (2, 'Canada', 80, '2022-01-01'), (3, 'Mexico', 100, '2022-01-01'), (4, 'USA', 110, '2022-01-02'), (5, 'Canada', 85, '2022-01-02'), (6, 'Mexico', 95, '2022-01-02');
|
What are the top 5 countries with the highest vulnerability count in the last month?
|
SELECT country, SUM(vulnerability_count) AS total_vulnerabilities FROM vulnerabilities WHERE scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country ORDER BY total_vulnerabilities DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data (id INT PRIMARY KEY, mine_id INT, year INT, monthly_production INT);
|
What is the annual production volume trend for the mine with the ID 'mine002'?
|
SELECT year, AVG(monthly_production) as annual_production FROM production_data WHERE mine_id = 'mine002' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE humanitarian_assistance (id INT PRIMARY KEY, disaster VARCHAR(50), year INT, country VARCHAR(50)); INSERT INTO humanitarian_assistance (id, disaster, year, country) VALUES (1, 'Earthquake', 2010, 'Haiti'); INSERT INTO humanitarian_assistance (id, disaster, year, country) VALUES (2, 'Hurricane Matthew', 2016, 'Haiti');
|
Delete all records from the 'humanitarian_assistance' table where the country is 'Haiti'
|
DELETE FROM humanitarian_assistance WHERE country = 'Haiti';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses (WarehouseID INT, City VARCHAR(20)); INSERT INTO Warehouses (WarehouseID, City) VALUES (1, 'Seattle'), (2, 'New York'); CREATE TABLE Shipments (ShipmentID INT, OriginWarehouseID INT, DestinationWarehouseID INT, CargoWeight INT); INSERT INTO Shipments (ShipmentID, OriginWarehouseID, DestinationWarehouseID, CargoWeight) VALUES (1, 1, 2, 500), (2, 1, 2, 700);
|
What are the names and total cargo weights for all shipments that originated from 'Seattle' and were delivered to 'New York'?
|
SELECT Shipments.ShipmentID, SUM(Shipments.CargoWeight) AS TotalCargoWeight FROM Shipments JOIN Warehouses ON Shipments.OriginWarehouseID = Warehouses.WarehouseID WHERE Warehouses.City = 'Seattle' JOIN Warehouses AS DestinationWarehouses ON Shipments.DestinationWarehouseID = DestinationWarehouses.WarehouseID WHERE DestinationWarehouses.City = 'New York' GROUP BY Shipments.ShipmentID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE orders (id INT PRIMARY KEY, restaurant_id INT, total_amount DECIMAL(10, 2)); INSERT INTO restaurants (id, name) VALUES (1, 'Pizzeria'), (2, 'Bistro'), (3, 'Cafe'); INSERT INTO orders (id, restaurant_id, total_amount) VALUES (1, 1, 20.00), (2, 1, 30.00), (3, 2, 50.00);
|
Show the total revenue for each restaurant
|
SELECT restaurants.name, SUM(orders.total_amount) AS revenue FROM orders JOIN restaurants ON orders.restaurant_id = restaurants.id GROUP BY orders.restaurant_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (id INT PRIMARY KEY, menu_id INT, order_date DATETIME, quantity INT); INSERT INTO orders (id, menu_id, order_date, quantity) VALUES (1, 1, '2022-01-01 18:00:00', 2), (2, 3, '2022-01-01 19:30:00', 1), (3, 2, '2022-01-02 12:15:00', 3), (4, 4, '2022-01-02 13:30:00', 2);
|
Delete the order for menu item with ID 3 on Jan 1, 2022.
|
DELETE FROM orders WHERE menu_id = 3 AND order_date = '2022-01-01 19:30:00';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmBiomass (farm_id INT, water_quality_index FLOAT, total_biomass FLOAT); INSERT INTO FarmBiomass (farm_id, water_quality_index, total_biomass) VALUES (1, 60, 2500), (2, 70, 1800), (3, 65, 2200), (4, 80, 1500);
|
Find the farms with a water quality index below 65 and a total biomass above 2000 kg?
|
SELECT farm_id FROM FarmBiomass WHERE water_quality_index < 65 AND total_biomass > 2000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT PRIMARY KEY, attorney_name VARCHAR(50), experience INT, area_of_practice VARCHAR(50)); INSERT INTO attorneys (attorney_id, attorney_name, experience, area_of_practice) VALUES (1, 'John', 10, 'Family Law'), (2, 'Jane', 8, 'Civil Law'), (3, 'Janet', 12, 'Immigration Law');
|
Update the area of practice for attorney 'John' to 'Criminal Law' in the 'attorneys' table
|
UPDATE attorneys SET area_of_practice = 'Criminal Law' WHERE attorney_name = 'John';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Genre (id INT, genre VARCHAR(255)); CREATE TABLE Song (id INT, genre_id INT, title VARCHAR(255), playtime INT);
|
What is the average playtime of all songs in the Pop genre?
|
SELECT G.genre, AVG(S.playtime) as avg_playtime FROM Genre G INNER JOIN Song S ON G.id = S.genre_id WHERE G.genre = 'Pop' GROUP BY G.genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteGeneration (ID INT PRIMARY KEY, City VARCHAR(50), WasteQuantity FLOAT, WasteType VARCHAR(50)); INSERT INTO WasteGeneration (ID, City, WasteQuantity, WasteType) VALUES (1, 'New York', 1500, 'Paper'), (2, 'New York', 2500, 'Organic');
|
What is the total waste quantity for 'Paper' and 'Organic' waste types in 'New York'?
|
SELECT City, SUM(WasteQuantity) FROM WasteGeneration WHERE WasteType IN ('Paper', 'Organic') GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members (member_id INT, gender VARCHAR(10)); CREATE TABLE workouts (workout_id INT, member_id INT, date DATE); INSERT INTO members VALUES (1,'Female'),(2,'Male'),(3,'Female'); INSERT INTO workouts VALUES (1,1,'2022-01-01'),(2,1,'2022-01-02'),(3,2,'2022-01-03'),(4,3,'2022-01-04'),(5,3,'2022-01-05');
|
Which gender has the highest average number of workouts?
|
SELECT members.gender, AVG(workouts.workout_id) AS avg_workouts FROM members JOIN workouts ON members.member_id = workouts.member_id GROUP BY members.gender ORDER BY avg_workouts DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellites (satellite_id INT, company VARCHAR(255), launch_date DATE); INSERT INTO Satellites (satellite_id, company, launch_date) VALUES (1, 'SpaceTech Corp', '2025-03-14'), (2, 'SpaceTech Corp', '2025-06-28'), (3, 'Galactic Enterprises', '2024-12-15');
|
What is the total number of satellites deployed by SpaceTech Corp in the year 2025?
|
SELECT COUNT(*) FROM Satellites WHERE company = 'SpaceTech Corp' AND YEAR(launch_date) = 2025;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT, team TEXT, location TEXT, score_team INT, score_opponent INT, half_season TEXT); INSERT INTO games (id, team, location, score_team, score_opponent, half_season) VALUES (1, 'Team F', 'Home', 100, 90, 'First'), (2, 'Team F', 'Away', 80, 95, 'First');
|
What was the total number of games played by Team F in the first half of the 2019 season?
|
SELECT SUM(score_team) FROM games WHERE team = 'Team F' AND half_season = 'First';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, category VARCHAR(20), is_organic BOOLEAN, price DECIMAL(5,2)); INSERT INTO products (product_id, category, is_organic, price) VALUES (1, 'Natural', false, 25.99), (2, 'Organic', true, 30.49), (3, 'Natural', true, 29.99), (4, 'Conventional', false, 15.99);
|
What is the average price of organic products, ranked in descending order of average price?
|
SELECT AVG(price) as avg_price, category FROM products WHERE is_organic = true GROUP BY category ORDER BY avg_price DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE skorea_renewable_projects (name TEXT, investment_usd INT, completion_date DATE); INSERT INTO skorea_renewable_projects (name, investment_usd, completion_date) VALUES ('Project A', 150000000, '2020-01-01'), ('Project B', 120000000, '2021-01-01'), ('Project C', 80000000, '2019-01-01');
|
What is the minimum investment required (in USD) for renewable energy projects in South Korea that were completed after 2019, and how many of them required an investment of over 100 million USD?
|
SELECT MIN(investment_usd) AS min_investment, COUNT(*) FILTER (WHERE investment_usd > 100000000) AS num_projects_over_100_million FROM skorea_renewable_projects WHERE completion_date > '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co_owned_properties (id INT, city VARCHAR(20), total_properties INT); INSERT INTO co_owned_properties (id, city, total_properties) VALUES (1, 'Seattle', 1000), (2, 'Portland', 1500), (3, 'Seattle', 2000), (4, 'Portland', 2500), (5, 'Los Angeles', 3000), (6, 'Los Angeles', 3500);
|
What is the rank of each city by number of co-owned properties?
|
SELECT city, ROW_NUMBER() OVER (ORDER BY total_properties DESC) as rank FROM co_owned_properties;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(255), coowners INT); INSERT INTO properties (id, city, coowners) VALUES (1, 'Portland', 2), (2, 'Portland', 1), (3, 'Seattle', 1), (4, 'Portland', 3);
|
What is the number of co-owned properties in the city of Portland?
|
SELECT COUNT(*) FROM properties WHERE city = 'Portland' AND coowners > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Affordable_Housing (Permit_ID INT, Project_Type VARCHAR(50), Issue_Date DATE, Location VARCHAR(50));
|
What was the total number of building permits issued for affordable housing projects in Chicago between 2015 and 2019?
|
SELECT COUNT(Permit_ID) FROM Affordable_Housing WHERE Project_Type = 'Affordable Housing' AND Location = 'Chicago' AND Issue_Date BETWEEN '2015-01-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE travel_advisories (id INT, country VARCHAR, region VARCHAR, level INT); INSERT INTO travel_advisories (id, country, region, level) VALUES (1, 'Maldives', 'Asia', 1);
|
Which countries in Asia have the lowest travel advisory level?
|
SELECT country FROM travel_advisories WHERE region = 'Asia' AND level = (SELECT MIN(level) FROM travel_advisories WHERE region = 'Asia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policy (id INT, name VARCHAR(50), city_id INT, start_date DATE, end_date DATE, budget DECIMAL(10,2)); INSERT INTO Policy (id, name, city_id, start_date, end_date, budget) VALUES (5, 'PolicyE', 3, '2021-01-01', '2022-12-31', 600000), (6, 'PolicyF', 3, '2021-01-01', '2022-12-31', 700000);
|
What is the total budget for all policies in city 3 in the year 2021?
|
SELECT SUM(budget) FROM Policy WHERE city_id = 3 AND YEAR(start_date) = 2021 AND YEAR(end_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, name TEXT, location TEXT); INSERT INTO ports (id, name, location) VALUES (1, 'Port of Hong Kong', 'Hong Kong'); CREATE TABLE shipments (id INT, container_weight FLOAT, departure_port_id INT, arrival_region TEXT, shipment_date DATE); INSERT INTO shipments (id, container_weight, departure_port_id, arrival_region, shipment_date) VALUES (1, 15000.0, 1, 'Oceania', '2022-02-04');
|
What is the minimum weight of containers shipped from the Port of Hong Kong to Oceania in the past 6 months?
|
SELECT MIN(container_weight) FROM shipments WHERE departure_port_id = (SELECT id FROM ports WHERE name = 'Port of Hong Kong') AND arrival_region = 'Oceania' AND shipment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO Restaurants (id, name, type) VALUES (1, 'Green Garden', 'Vegan'); INSERT INTO Restaurants (id, name, type) VALUES (2, 'Bistro Bella', 'Italian'); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), price DECIMAL(5,2), organic BOOLEAN); INSERT INTO Menu (id, restaurant_id, dish, price, organic) VALUES (1, 1, 'Quinoa Salad', 12.99, true); INSERT INTO Menu (id, restaurant_id, dish, price, organic) VALUES (2, 1, 'Tofu Stir Fry', 14.50, false);
|
What is the minimum price of organic dishes?
|
SELECT MIN(price) FROM Menu WHERE organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_emissions (industry VARCHAR(50), emissions FLOAT); INSERT INTO carbon_emissions (industry, emissions) VALUES ('Industry A', 50000, 'Industry B', 60000), ('Industry C', 40000, 'Industry D', 70000);
|
What is the total carbon emissions (in metric tons) for each industry, ranked from highest to lowest?
|
SELECT industry, emissions, ROW_NUMBER() OVER (ORDER BY emissions DESC) as rank FROM carbon_emissions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destinations_awards (destination VARCHAR(50), year INT, awards INT);
|
What is the average number of sustainable tourism awards received per destination in 2018 and 2019?
|
SELECT AVG(awards) FROM (SELECT destination, AVG(awards) AS awards FROM destinations_awards WHERE year IN (2018, 2019) GROUP BY destination, year HAVING COUNT(*) > 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ContractorPermits (contractor VARCHAR(255), permit_type VARCHAR(255), num_permits INT); INSERT INTO ContractorPermits (contractor, permit_type, num_permits) VALUES ('Johnson Construction', 'commercial', 15), ('Smith & Sons', 'residential', 0), ('GreenBuild', 'commercial', 8);
|
Who are the contractors that have no residential permits?
|
SELECT contractor FROM ContractorPermits WHERE permit_type = 'residential' AND num_permits = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_models (model_id INT, model_type VARCHAR(20), safety_score INT); INSERT INTO ai_models (model_id, model_type, safety_score) VALUES (1, 'Generative', 80), (2, 'Transformer', 85), (3, 'Reinforcement', 70), (4, 'Generative2', 82);
|
List the unique AI model types and corresponding safety scores, ordered by safety score in descending order.
|
SELECT DISTINCT model_type, safety_score FROM ai_models ORDER BY safety_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tennis_matches (id INT, player1 VARCHAR(50), player2 VARCHAR(50), score1 INT, score2 INT);
|
What is the highest score in a tennis match?
|
SELECT GREATEST(GREATEST(score1, score2), GREATEST(score2, score1)) FROM tennis_matches;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (innovation_id INT, country1 TEXT, country2 TEXT, project TEXT, start_date DATE, end_date DATE); INSERT INTO military_innovation (innovation_id, country1, country2, project, start_date, end_date) VALUES (1, 'Israel', 'USA', 'Iron Dome', '2015-01-01', '2018-12-31'), (2, 'Israel', 'Germany', 'Trophy Active Protection System', '2016-01-01', '2019-12-31');
|
Which countries have not participated in any military innovation projects with Israel since 2015?
|
SELECT military_innovation.country1 FROM military_innovation WHERE military_innovation.country2 = 'Israel' AND military_innovation.start_date >= '2015-01-01' GROUP BY military_innovation.country1 HAVING COUNT(*) = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE luxury_vehicles (vehicle_id INT, vehicle_type VARCHAR(20)); CREATE TABLE electric_vehicles (vehicle_id INT, range INT); INSERT INTO luxury_vehicles VALUES (1, 'Luxury'), (2, 'SUV'), (3, 'Luxury'), (4, 'Sedan'); INSERT INTO electric_vehicles VALUES (1, 350), (2, 280), (3, 320), (4, 420);
|
Find the number of luxury electric vehicles with a range over 300 miles
|
SELECT COUNT(*) FROM luxury_vehicles l JOIN electric_vehicles e ON l.vehicle_id = e.vehicle_id HAVING e.range > 300 AND l.vehicle_type = 'Luxury';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biotech_startups (id INT, name TEXT, budget FLOAT); INSERT INTO biotech_startups (id, name, budget) VALUES (1, 'StartupA', 5000000), (2, 'StartupB', 7000000), (3, 'StartupC', 3000000);
|
What is the average budget of biotech startups in the 'biotech_startups' table?
|
SELECT AVG(budget) FROM biotech_startups;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE covid_cases (id INT, city TEXT, state TEXT, cases INT); INSERT INTO covid_cases (id, city, state, cases) VALUES (1, 'New York', 'NY', 5000); INSERT INTO covid_cases (id, city, state, cases) VALUES (2, 'Los Angeles', 'CA', 3000); INSERT INTO covid_cases (id, city, state, cases) VALUES (3, 'Miami', 'FL', 4000);
|
Which cities have a higher number of COVID-19 cases than the average number of cases across all cities?
|
SELECT city, cases FROM covid_cases WHERE cases > (SELECT AVG(cases) FROM covid_cases);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, name TEXT, num_employees INT, dept TEXT); INSERT INTO mining_operations (id, name, num_employees, dept) VALUES (1, 'Operation A', 500, 'Mining'), (2, 'Operation B', 600, 'Mining'), (3, 'Operation C', 700, 'Environmental');
|
How many employees work in the environmental department of each mining operation?
|
SELECT name, dept, COUNT(*) FROM mining_operations WHERE dept = 'Environmental' GROUP BY name, dept;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subway_rides_moscow(ride_date DATE, num_rides INTEGER); INSERT INTO subway_rides_moscow (ride_date, num_rides) VALUES ('2022-04-01', 1500), ('2022-04-02', 1600);
|
How many subway rides were there per day in Moscow in Q2 2022?
|
SELECT ride_date, AVG(num_rides) AS avg_daily_rides FROM subway_rides_moscow WHERE ride_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY ride_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DispensarySales(id INT, dispensary VARCHAR(255), state VARCHAR(255), strain_type VARCHAR(255), retail_price DECIMAL(10,2));
|
List the top 3 states with the highest average Sativa strain retail price.
|
SELECT state, AVG(retail_price) as average_price FROM DispensarySales WHERE strain_type = 'Sativa' GROUP BY state ORDER BY average_price DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT, name VARCHAR(50), newspaper VARCHAR(50)); INSERT INTO authors (id, name, newspaper) VALUES (1, 'John Doe', 'The Times'); INSERT INTO authors (id, name, newspaper) VALUES (2, 'Jane Smith', 'The Guardian');
|
Delete all records from the 'authors' table where the 'newspaper' is 'The Times'
|
DELETE FROM authors WHERE newspaper = 'The Times';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatment (treatment_id INT, patient_id INT, condition VARCHAR(50), provider VARCHAR(50), date DATE); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (1, 1, 'Anxiety Disorder', 'Dr. Jane', '2021-01-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (2, 1, 'PTSD', 'Dr. Bob', '2021-02-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (3, 2, 'Anxiety Disorder', 'Dr. Bob', '2021-03-01');
|
Get the total number of treatments provided by 'Dr. Jane' in February 2021.
|
SELECT COUNT(*) FROM treatment WHERE provider = 'Dr. Jane' AND date BETWEEN '2021-02-01' AND '2021-02-28';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (id INT PRIMARY KEY, state VARCHAR(20), worker_count INT); CREATE TABLE cultural_competency_training (id INT PRIMARY KEY, state VARCHAR(20), worker_count INT);
|
How many community health workers have received cultural competency training by state?
|
SELECT c.state, SUM(c.worker_count) AS total_workers, SUM(t.worker_count) AS trained_workers FROM community_health_workers c FULL OUTER JOIN cultural_competency_training t ON c.state = t.state GROUP BY c.state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (startup_name VARCHAR(50), last_funded_date DATE);
|
Update the 'last_funded_date' for 'Startup XYZ' in the 'startups' table to '2022-06-01'
|
UPDATE startups SET last_funded_date = '2022-06-01' WHERE startup_name = 'Startup XYZ';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_sustainable_materials (company_id INT, material TEXT, start_date DATE, end_date DATE); INSERT INTO company_sustainable_materials (company_id, material, start_date, end_date) VALUES (1, 'organic cotton', '2020-01-01', '2022-12-31'), (1, 'recycled polyester', '2020-01-01', '2022-12-31'), (2, 'organic cotton', '2020-01-01', '2022-12-31'), (2, 'hemp', '2020-01-01', '2022-12-31'), (3, 'recycled polyester', '2020-01-01', '2022-12-31'), (3, 'linen', '2020-01-01', '2022-12-31');
|
Which companies have stopped using sustainable materials?
|
SELECT company_id FROM company_sustainable_materials WHERE end_date < CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClientPracticeArea (ClientID INT, PracticeAreaID INT, Age INT); INSERT INTO ClientPracticeArea (ClientID, PracticeAreaID, Age) VALUES (1, 1, 35), (2, 1, 41), (3, 2, 30), (4, 2, 33), (5, 3, 52), (6, 3, 50), (7, 4, 47), (8, 4, 49);
|
What is the average age of clients per practice area?
|
SELECT PA.PracticeArea, AVG(CPA.Age) AS Avg_Age FROM PracticeAreas PA INNER JOIN ClientPracticeArea CPA ON PA.PracticeAreaID = CPA.PracticeAreaID GROUP BY PA.PracticeArea;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shrimp_farms (id INT, name TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO shrimp_farms (id, name, country, latitude, longitude) VALUES (1, 'Farm C', 'Ecuador', -2.123456, -79.123456); INSERT INTO shrimp_farms (id, name, country, latitude, longitude) VALUES (2, 'Farm D', 'Ecuador', -1.123456, -78.123456); CREATE TABLE shrimp_temperature_data (id INT, farm_id INT, timestamp TIMESTAMP, temperature DECIMAL(5,2)); INSERT INTO shrimp_temperature_data (id, farm_id, timestamp, temperature) VALUES (1, 1, '2022-05-01 00:00:00', 28.5); INSERT INTO shrimp_temperature_data (id, farm_id, timestamp, temperature) VALUES (2, 1, '2022-05-02 00:00:00', 31.2); INSERT INTO shrimp_temperature_data (id, farm_id, timestamp, temperature) VALUES (3, 2, '2022-05-01 00:00:00', 29.8); INSERT INTO shrimp_temperature_data (id, farm_id, timestamp, temperature) VALUES (4, 2, '2022-05-02 00:00:00', 27.6);
|
Which shrimp farms in Ecuador have experienced water temperatures above 30°C in the last 30 days?
|
SELECT st.farm_id, sf.name FROM shrimp_temperature_data st JOIN shrimp_farms sf ON st.farm_id = sf.id WHERE sf.country = 'Ecuador' AND st.temperature > 30 AND st.timestamp >= NOW() - INTERVAL 30 DAY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE devices (device_id INT, device_cost FLOAT, user_location VARCHAR(10)); INSERT INTO devices VALUES (1, 300, 'rural'), (2, 500, 'urban'), (3, 400, 'rural');
|
What is the maximum cost of devices for users in urban areas?
|
SELECT MAX(device_cost) FROM devices WHERE user_location = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure (id INT, technology VARCHAR(10), region VARCHAR(10), state VARCHAR(10), power_consumption INT); INSERT INTO infrastructure (id, technology, region, state, power_consumption) VALUES (1, '3G', 'arctic', 'AK', 100), (2, '3G', 'arctic', 'AL', 120), (3, '4G', 'arctic', 'MT', 150);
|
How many 3G base stations are there in the "arctic" region, and what is their total power consumption?
|
SELECT technology, COUNT(*), SUM(power_consumption) FROM infrastructure WHERE technology = '3G' AND region = 'arctic' GROUP BY technology;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (event_id INT, event_name VARCHAR(50), event_type VARCHAR(50), state VARCHAR(50)); CREATE TABLE attendees (attendee_id INT, event_id INT, state VARCHAR(50));
|
Find the top 3 states with the highest number of theater performances.
|
SELECT e.state, COUNT(e.event_id) as event_count FROM events e JOIN attendees a ON e.event_id = a.event_id WHERE e.event_type = 'Theater' GROUP BY e.state ORDER BY event_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE social_media_users (user_id INT, followers_count INT); INSERT INTO social_media_users (user_id, followers_count) VALUES (1, 1200), (2, 2000), (3, 1500), (4, 1050), (5, 2500), (6, 800);
|
How many users have more than 1000 followers in the "social_media_users" table?
|
SELECT COUNT(user_id) FROM social_media_users WHERE followers_count > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (ID INT, DonorAge INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (ID, DonorAge, DonationAmount) VALUES (1, 25, 50.00), (2, 35, 100.00), (3, 45, 25.00);
|
What is the average donation by age group?
|
SELECT FLOOR(DonorAge/10)*10 AS AgeGroup, AVG(DonationAmount) as AvgDonation FROM Donations GROUP BY AgeGroup;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biosensor_technology (id INT, project_name VARCHAR(50), description TEXT, location VARCHAR(50)); INSERT INTO biosensor_technology (id, project_name, description, location) VALUES (1, 'Glucose Monitoring', 'Biosensor for continuous glucose monitoring', 'South Korea'); INSERT INTO biosensor_technology (id, project_name, description, location) VALUES (2, 'Lactate Detection', 'Biosensor for lactate detection in athletes', 'Japan'); INSERT INTO biosensor_technology (id, project_name, description, location) VALUES (3, 'pH Sensor', 'Biosensor for pH detection in water', 'South Korea');
|
What are the names and descriptions of biosensor technology projects in South Korea and Japan?
|
SELECT project_name, description FROM biosensor_technology WHERE location IN ('South Korea', 'Japan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (PolicyID INT, RiskScore INT); INSERT INTO Policyholders VALUES (1, 400); INSERT INTO Policyholders VALUES (2, 700); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimDate DATE); INSERT INTO Claims VALUES (1, 1, '2022-01-01'); INSERT INTO Claims VALUES (2, 2, '2022-02-15'); CREATE TABLE Calendar (Date DATE); INSERT INTO Calendar VALUES ('2022-01-01'); INSERT INTO Calendar VALUES ('2022-02-01'); INSERT INTO Calendar VALUES ('2022-03-01');
|
How many claims were filed by policyholders with a risk score lower than 500 in the last 6 months?
|
SELECT COUNT(c.ClaimID) as ClaimCount FROM Claims c INNER JOIN Policyholders p ON c.PolicyID = p.PolicyID INNER JOIN Calendar cal ON c.ClaimDate >= cal.Date AND cal.Date >= DATE_SUB(curdate(), INTERVAL 6 MONTH) WHERE p.RiskScore < 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255), uses_organic_cotton BOOLEAN, avg_carbon_footprint DECIMAL(5,2));
|
What is the average carbon footprint of brands that use organic cotton?
|
SELECT AVG(avg_carbon_footprint) FROM brands WHERE uses_organic_cotton = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT PRIMARY KEY, region_name VARCHAR(255), avg_temp FLOAT); INSERT INTO regions (region_id, region_name, avg_temp) VALUES (1, 'North', 5.0), (2, 'South', 20.0), (3, 'East', 15.0), (4, 'West', 10.0); CREATE TABLE mobile_towers (tower_id INT PRIMARY KEY, region_id INT, tower_location VARCHAR(255)); INSERT INTO mobile_towers (tower_id, region_id, tower_location) VALUES (1, 1, 'New York'), (2, 2, 'Miami'), (3, 3, 'Boston'), (4, 4, 'Los Angeles');
|
List all the mobile towers in the regions that have an average monthly temperature of less than 10 degrees.
|
SELECT m.tower_location FROM mobile_towers m JOIN regions r ON m.region_id = r.region_id WHERE r.avg_temp < 10.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists(artist_id INT, name VARCHAR(50)); CREATE TABLE ticket_sales(artist_id INT, region VARCHAR(50), sales INT);
|
What are the names of the top 5 artists with the highest ticket sales in 'Europe'?
|
SELECT artists.name FROM artists JOIN ticket_sales ON artists.artist_id = ticket_sales.artist_id WHERE region = 'Europe' GROUP BY artists.name ORDER BY SUM(ticket_sales.sales) DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Charlie', 'China'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Dana', 'Japan'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL, DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate) VALUES (1, 1, 300.00, '2021-12-01'); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate) VALUES (2, 2, 400.00, '2021-11-30');
|
What is the total number of donors from Asia who donated in Q4 2021?
|
SELECT COUNT(DISTINCT Donors.DonorID) AS TotalDonors FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.Country LIKE 'Asia%' AND QUARTER(Donations.DonationDate) = 4 AND YEAR(Donations.DonationDate) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MedicalProfiles(astronaut_id INT, height INT, weight INT);
|
What is the total weight of all astronauts?
|
SELECT SUM(weight) FROM MedicalProfiles;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_accommodations (student_id INT, disability_type VARCHAR(255), country VARCHAR(255), date DATE); INSERT INTO student_accommodations (student_id, disability_type, country, date) VALUES (1, 'Visual Impairment', 'USA', '2021-03-22'); INSERT INTO student_accommodations (student_id, disability_type, country, date) VALUES (2, 'Visual Impairment', 'Canada', '2021-04-01');
|
How many students with visual impairments have received accommodations in the last year, broken down by country?
|
SELECT country, COUNT(*) as num_students FROM student_accommodations WHERE disability_type = 'Visual Impairment' AND date BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW() GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(255), ocean VARCHAR(255)); INSERT INTO marine_species (species_id, species_name, ocean) VALUES (1, 'Clownfish', 'Indian Ocean'), (2, 'Dolphin', 'Indian Ocean');
|
How many marine species are found in the Indian Ocean?
|
SELECT COUNT(*) FROM marine_species WHERE ocean = 'Indian Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, state VARCHAR(50), program VARCHAR(50)); INSERT INTO programs (id, state, program) VALUES (1, 'NY', 'music'), (2, 'CA', 'theater'), (3, 'NY', 'dance'); CREATE TABLE engagement (program_id INT, engagement_score INT); INSERT INTO engagement (program_id, engagement_score) VALUES (1, 90), (1, 85), (2, 70), (3, 95), (3, 92);
|
Which art programs had the most significant impact on audience engagement in NY?
|
SELECT programs.program, MAX(engagement.engagement_score) FROM programs JOIN engagement ON programs.id = engagement.program_id WHERE programs.state = 'NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT, name TEXT, bio TEXT); CREATE VIEW article_authors AS SELECT a.id, a.name, a.bio, w.id as article_id, w.title, w.section, w.publish_date FROM website_articles w JOIN authors a ON w.author_id = a.id;
|
Which authors have written the most articles about climate change since 2020?
|
SELECT name, COUNT(*) as article_count FROM article_authors WHERE section = 'climate change' AND publish_date >= '2020-01-01' GROUP BY name ORDER BY article_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), community_id INT); INSERT INTO teachers (teacher_id, teacher_name, community_id) VALUES (1, 'Jane Smith', 1), (2, 'Ali Ahmed', 2), (3, 'Maria Garcia', 3), (4, 'Park Soo-jin', 4); CREATE TABLE communities (community_id INT, community_name VARCHAR(50)); INSERT INTO communities (community_id, community_name) VALUES (1, 'African American'), (2, 'South Asian'), (3, 'Latinx'), (4, 'Korean'); CREATE TABLE courses (course_id INT, course_name VARCHAR(50), teacher_id INT); INSERT INTO courses (course_id, course_name, teacher_id) VALUES (1, 'Teaching with Technology', 1), (2, 'Diversity in Education', 2), (3, 'Math Pedagogy', 3), (4, 'Science Pedagogy', 4);
|
How many professional development courses have been completed by teachers from underrepresented communities?
|
SELECT communities.community_name, COUNT(DISTINCT courses.course_id) as course_count FROM teachers JOIN communities ON teachers.community_id = communities.community_id JOIN courses ON teachers.teacher_id = courses.teacher_id GROUP BY communities.community_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(50));
|
List all unique suppliers that provide materials for garment manufacturing.
|
SELECT DISTINCT name FROM suppliers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_composition_data (chemical_name VARCHAR(255), is_mixture BOOLEAN); INSERT INTO chemical_composition_data (chemical_name, is_mixture) VALUES ('Hydrogen Peroxide', FALSE), ('Boric Acid', FALSE), ('Ammonium Persulfate', TRUE), ('Sodium Carbonate', FALSE);
|
Display the names of all chemicals that are part of a mixture in the chemical_composition_data table.
|
SELECT chemical_name FROM chemical_composition_data WHERE is_mixture = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (ArtworkID INT, Title TEXT); INSERT INTO Artworks (ArtworkID, Title) VALUES (1, 'The Persistence of Memory'), (2, 'The Starry Night'); CREATE TABLE Installations (InstallationID INT, Title TEXT); INSERT INTO Installations (InstallationID, Title) VALUES (1, 'The Weather Project'), (2, 'Infinity Mirrored Room');
|
What are the total number of works in the 'Artworks' and 'Installations' tables?
|
SELECT COUNT(*) FROM Artworks UNION ALL SELECT COUNT(*) FROM Installations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workplaces (id INT, name TEXT, state TEXT, safety_violation BOOLEAN); INSERT INTO workplaces (id, name, state, safety_violation) VALUES (1, 'ABC Company', 'California', true);
|
What is the total number of workplaces with safety violations in the state of California?
|
SELECT COUNT(*) FROM workplaces WHERE state = 'California' AND safety_violation = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CulturalEvents (event_name TEXT, location TEXT, date DATE, attendance INTEGER); INSERT INTO CulturalEvents (event_name, location, date, attendance) VALUES ('Event 1', 'New York', '2021-01-01', 500), ('Event 2', 'New York', '2021-02-01', 700);
|
What is the total attendance at cultural events in 'New York' in 2021?
|
SELECT SUM(attendance) FROM CulturalEvents WHERE location = 'New York' AND YEAR(date) = 2021
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeritageSites (id INT, name VARCHAR(255), location VARCHAR(255), focus_area VARCHAR(255), year_established INT, UNIQUE(id));
|
What is the percentage of heritage sites in Africa with a focus on music and dance, and the average year they were established?
|
SELECT (COUNT(HeritageSites.id) * 100.0 / (SELECT COUNT(*) FROM HeritageSites WHERE HeritageSites.location = 'Africa')) as pct, AVG(HeritageSites.year_established) as avg_year FROM HeritageSites WHERE HeritageSites.location = 'Africa' AND HeritageSites.focus_area IN ('music', 'dance');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IndigenousCommunities (name VARCHAR(255), location VARCHAR(255), population INT); INSERT INTO IndigenousCommunities (name, location, population) VALUES ('Inuit', 'Greenland', 56000); INSERT INTO IndigenousCommunities (name, location, population) VALUES ('Kalaallit', 'Greenland', 89000);
|
List the names of all indigenous communities in Greenland and their respective population counts.
|
SELECT name, population FROM IndigenousCommunities WHERE location = 'Greenland';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (incident_id INT, incident_date DATE, category VARCHAR(20)); INSERT INTO incidents (incident_id, incident_date, category) VALUES (1, '2021-01-01', 'Medical'), (2, '2021-02-15', 'Fire'), (3, '2021-03-01', 'Traffic');
|
What is the total number of incidents recorded in 'incidents' table for the year 2021?
|
SELECT COUNT(*) FROM incidents WHERE YEAR(incident_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_wellbeing (id INT, person_id INT, country VARCHAR(255), score FLOAT); INSERT INTO financial_wellbeing (id, person_id, country, score) VALUES (1, 123, 'Saudi Arabia', 72.5), (2, 456, 'UAE', 78.8), (3, 789, 'Oman', 69.2);
|
Find the minimum financial wellbeing score in the Middle East.
|
SELECT MIN(score) FROM financial_wellbeing WHERE country = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approvals (approval_id INT, drug_name VARCHAR(255), approval_date DATE, status VARCHAR(255)); INSERT INTO drug_approvals (approval_id, drug_name, approval_date, status) VALUES (1, 'DrugA', '2018-02-14', 'Approved'), (2, 'DrugB', '2019-08-21', 'Rejected'), (3, 'DrugC', '2020-10-15', 'Approved'), (4, 'DrugD', '2021-05-06', 'Pending');
|
What is the drug approval status for a specific drug?
|
SELECT drug_name, status FROM drug_approvals WHERE drug_name = 'DrugA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MuseumVisitors (visitor_id INT, museum_id INT, age INT, gender VARCHAR(50));
|
Update visitor information for a specific museum
|
UPDATE MuseumVisitors SET age = 30, gender = 'Female' WHERE visitor_id = 1 AND museum_id = 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RestaurantInspections (inspection_id INT, restaurant_id INT, food_safety_score INT); INSERT INTO RestaurantInspections (inspection_id, restaurant_id, food_safety_score) VALUES (1, 1, 90), (2, 1, 85), (3, 2, 95), (4, 2, 92);
|
Calculate the average food safety score for each restaurant
|
SELECT r.restaurant_name, AVG(ri.food_safety_score) as avg_food_safety_score FROM Restaurants r INNER JOIN RestaurantInspections ri ON r.restaurant_id = ri.restaurant_id GROUP BY r.restaurant_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ZeroBudgetPrograms (ProgramID INT, ProgramName TEXT, Volunteers INT, Budget DECIMAL(10,2)); INSERT INTO ZeroBudgetPrograms (ProgramID, ProgramName, Volunteers, Budget) VALUES (1, 'Music for All', 5, 0);
|
Identify the programs with zero budget and less than 10 volunteers?
|
SELECT ProgramID, ProgramName FROM ZeroBudgetPrograms WHERE Budget = 0 AND Volunteers < 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users(user_id INT, user_country TEXT); INSERT INTO users(user_id, user_country) VALUES (1, 'Argentina'); CREATE TABLE virtual_tours(tour_id INT, tour_date DATE); CREATE TABLE user_tour_interactions(user_id INT, tour_id INT);
|
Identify the number of virtual tours engaged by users from Argentina in 2021, grouped by the day of the week.
|
SELECT DATEPART(dw, vt.tour_date) AS day_of_week, COUNT(uti.user_id) AS num_interactions FROM users u INNER JOIN user_tour_interactions uti ON u.user_id = uti.user_id INNER JOIN virtual_tours vt ON uti.tour_id = vt.tour_id WHERE u.user_country = 'Argentina' AND YEAR(vt.tour_date) = 2021 GROUP BY day_of_week;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (cafe VARCHAR(20), item_category VARCHAR(15), cost DECIMAL(5,2)); INSERT INTO Inventory (cafe, item_category, cost) VALUES ('EcoEats', 'organic', 6.50), ('EcoEats', 'local', 7.25), ('Sprout', 'organic', 5.75), ('Sprout', 'local', 4.50);
|
Show the total inventory cost for 'organic' and 'local' items across all cafes.
|
SELECT SUM(cost) FROM Inventory WHERE item_category IN ('organic', 'local');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production(year INT, region VARCHAR(255), species VARCHAR(255), volume FLOAT); INSERT INTO timber_production(year, region, species, volume) VALUES (2015, 'USA', 'Pine', 1200.0), (2015, 'USA', 'Oak', 1500.0), (2016, 'Canada', 'Pine', 1800.0), (2016, 'Canada', 'Oak', 2000.0), (2017, 'Mexico', 'Pine', 1000.0), (2017, 'Mexico', 'Oak', 1400.0), (2018, 'Canada', 'Pine', 2100.0), (2018, 'Canada', 'Oak', 2500.0);
|
What is the total volume of timber production by species for the Mexican region?
|
SELECT species, SUM(volume) as total_volume FROM timber_production WHERE region = 'Mexico' GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_specialists (specialist_id INT, clinic_id INT); INSERT INTO mental_health_specialists (specialist_id, clinic_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3); CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (clinic_id, state) VALUES (1, 'Colorado'), (2, 'Colorado'), (3, 'Nebraska');
|
What is the total number of mental health specialists in rural clinics in Colorado?
|
SELECT COUNT(mhs.specialist_id) FROM mental_health_specialists mhs JOIN rural_clinics rc ON mhs.clinic_id = rc.clinic_id WHERE rc.state = 'Colorado';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_clinics (id INT PRIMARY KEY, region VARCHAR(20), has_cultural_competency_policy BOOLEAN); INSERT INTO mental_health_clinics (id, region, has_cultural_competency_policy) VALUES (1, 'East', true), (2, 'West', false);
|
What is the percentage of mental health clinics with cultural competency policies in the West region?
|
SELECT region, AVG(has_cultural_competency_policy::int) * 100.0 AS percentage FROM mental_health_clinics WHERE region = 'West' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menus (menu_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2), location_id INT); INSERT INTO menus (menu_id, item_name, category, price, location_id) VALUES (1, 'Quinoa Salad', 'Vegan', 9.99, 101), (2, 'Tofu Stir Fry', 'Vegan', 12.49, 102), (3, 'Chicken Caesar Salad', 'Gluten-free', 13.99, 101);
|
What is the total revenue for gluten-free menu items at location 101?
|
SELECT SUM(price) FROM menus WHERE category = 'Gluten-free' AND location_id = 101;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, city VARCHAR(50), date DATE, event_type VARCHAR(50)); INSERT INTO Events (id, city, date, event_type) VALUES (1, 'Chicago', '2020-01-01', 'Dance'), (2, 'New York', '2020-02-01', 'Dance'); CREATE TABLE Audience (id INT, event_id INT, ethnicity VARCHAR(50), is_new_attendee BOOLEAN); INSERT INTO Audience (id, event_id, ethnicity, is_new_attendee) VALUES (1, 1, 'Hispanic', FALSE), (2, 1, 'African American', TRUE), (3, 2, 'Asian', FALSE);
|
What is the number of repeat attendees at dance performances, in the past year, for each city and ethnicity?
|
SELECT e.city, a.ethnicity, COUNT(a.id) AS count FROM Events e INNER JOIN Audience a ON e.id = a.event_id AND a.is_new_attendee = FALSE WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND e.event_type = 'Dance' GROUP BY e.city, a.ethnicity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthParity (ID INT, Violation VARCHAR(255), Date DATE); INSERT INTO MentalHealthParity VALUES (1, 'Non-compliance with mental health coverage', '2022-01-15'); INSERT INTO MentalHealthParity VALUES (2, 'Lack of mental health coverage parity', '2022-02-28');
|
What is the total number of mental health parity violations in the past month?
|
SELECT COUNT(*) FROM MentalHealthParity WHERE Date >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, project_name TEXT, department TEXT, hours_spent INT); INSERT INTO projects (id, project_name, department, hours_spent) VALUES (1, 'Climate Change Experiment', 'Science', 20), (2, 'Renewable Energy Research', 'Science', 30), (3, 'Biology Lab Report', 'Science', 15);
|
What is the total number of hours spent on open pedagogy projects by students in the 'Science' department?
|
SELECT SUM(hours_spent) FROM projects WHERE department = 'Science';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscriber_data (subscriber_id INT, data_usage FLOAT, month DATE); INSERT INTO subscriber_data (subscriber_id, data_usage, month) VALUES (43, 28, '2021-01-01'), (43, 33, '2021-02-01');
|
Find the difference in data usage between consecutive months for subscriber_id 43 in the 'south' region.
|
SELECT subscriber_id, LAG(data_usage) OVER (PARTITION BY subscriber_id ORDER BY month) as prev_data_usage, data_usage, month FROM subscriber_data WHERE subscriber_id = 43 AND region = 'south' ORDER BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatments (patient_id INT, treatment VARCHAR(20)); INSERT INTO treatments (patient_id, treatment) VALUES (1, 'CBT'), (2, 'DBT'), (3, 'Medication'), (4, 'Medication');
|
How many patients have been treated with medication in total?
|
SELECT COUNT(*) FROM treatments WHERE treatment = 'Medication';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(25)); CREATE TABLE Training (TrainingID INT, EmployeeID INT, TrainingType VARCHAR(25), TrainingDate DATE); INSERT INTO Employees (EmployeeID, Department) VALUES (1, 'Engineering'), (2, 'Marketing'), (3, 'Engineering'), (4, 'HR'); INSERT INTO Training (TrainingID, EmployeeID, TrainingType, TrainingDate) VALUES (1, 1, 'Ethical Hiring Practices', '2022-06-15'), (2, 2, 'Ethical Hiring Practices', '2022-05-01'), (3, 3, 'Ethical Hiring Practices', '2022-06-05'), (4, 4, 'Diversity and Inclusion', '2022-04-10');
|
How many employees in the engineering department have been trained on ethical hiring practices in the last month?
|
SELECT COUNT(*) FROM Employees e JOIN Training t ON e.EmployeeID = t.EmployeeID WHERE e.Department = 'Engineering' AND t.TrainingType = 'Ethical Hiring Practices' AND t.TrainingDate >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE campaigns (id INT PRIMARY KEY, campaign_name VARCHAR(50), campaign_start_date DATE, campaign_end_date DATE); INSERT INTO campaigns (id, campaign_name, campaign_start_date, campaign_end_date) VALUES (1, 'Food Drive', '2022-01-01', '2022-01-15'); CREATE TABLE donations (id INT PRIMARY KEY, campaign_id INT, donation_amount INT, donation_date DATE); INSERT INTO donations (id, campaign_id, donation_amount, donation_date) VALUES (1, 1, 100, '2022-01-01');
|
List the top 3 campaigns with the highest donation amounts in 2022.
|
SELECT campaign_name, SUM(donation_amount) AS total_donation_amount FROM donations d JOIN campaigns c ON d.campaign_id = c.id GROUP BY campaign_name ORDER BY total_donation_amount DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ev_sales (ev_id INT, state VARCHAR(255), year INT, num_sold INT);
|
What is the total number of electric vehicles sold in the state of California for the year 2020?
|
SELECT SUM(num_sold) FROM ev_sales WHERE state = 'California' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (id INT, name VARCHAR(50), genre VARCHAR(50), release_date DATE, num_reviews INT); INSERT INTO Games (id, name, genre, release_date, num_reviews) VALUES (1, 'GameA', 'VR', '2016-02-03', 120), (2, 'GameB', 'VR', '2017-06-18', 50), (3, 'GameC', 'Non-VR', '2019-11-25', 200);
|
How many virtual reality (VR) games were released before 2018 and have been reviewed more than 100 times?
|
SELECT COUNT(*) FROM Games WHERE genre = 'VR' AND release_date < '2018-01-01' AND num_reviews > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat_preservation (region VARCHAR(255), budget INT); INSERT INTO habitat_preservation (region, budget) VALUES ('Asia', 100000), ('Africa', 150000), ('South_America', 75000);
|
What is the percentage of the total budget allocated for each region in the 'habitat_preservation' table?
|
SELECT region, budget, ROUND(100.0 * budget / SUM(budget) OVER(), 2) as budget_percentage FROM habitat_preservation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (investment_id INT, customer_id INT, region VARCHAR(20), account_balance DECIMAL(10,2), investment_type VARCHAR(30)); INSERT INTO investments (investment_id, customer_id, region, account_balance, investment_type) VALUES (1, 3, 'North', 10000.00, 'Green Energy'), (2, 4, 'South', 15000.00, 'Renewable Energy');
|
What is the average account balance for green energy investment customers in the North region?
|
SELECT AVG(account_balance) FROM investments WHERE region = 'North' AND investment_type = 'Green Energy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_housing (id INT, project_name VARCHAR(255), country VARCHAR(255), sector VARCHAR(255));
|
Insert new records into the 'rural_housing' table for a new housing project in Guatemala
|
INSERT INTO rural_housing (id, project_name, country, sector) VALUES (1, 'Housing Project', 'Guatemala', 'Housing');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_immigrant BOOLEAN, founding_date DATE); INSERT INTO company (id, name, industry, founder_immigrant, founding_date) VALUES (1, 'BioTechPlus', 'Biotechnology', true, '2020-08-15');
|
What is the percentage of companies founded by immigrants in the biotechnology sector?
|
SELECT (COUNT(*) FILTER (WHERE founder_immigrant = true)) * 100.0 / COUNT(*) FROM company WHERE industry = 'Biotechnology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, event_name VARCHAR(100), event_type VARCHAR(50), location VARCHAR(100), start_time TIMESTAMP, end_time TIMESTAMP, genre VARCHAR(50));
|
What is the number of events per genre, for visual arts events in Paris, in descending order?
|
SELECT genre, COUNT(*) as num_events FROM Events WHERE location LIKE '%Paris%' AND event_type = 'visual arts' GROUP BY genre ORDER BY num_events DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genome_inc (id INT, project TEXT, funding FLOAT); INSERT INTO genome_inc (id, project, funding) VALUES (1, 'Genetic Research', 12000000.0); INSERT INTO genome_inc (id, project, funding) VALUES (2, 'Bioprocess Engineering', 15000000.0);
|
What is the maximum funding for bioprocess engineering projects?
|
SELECT MAX(funding) FROM genome_inc WHERE project = 'Bioprocess Engineering';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_violations (union_id INT, violation_count INT); CREATE TABLE unions (union_id INT, union_name TEXT); INSERT INTO union_violations (union_id, violation_count) VALUES (1, 10), (2, 20), (3, 30), (4, 40); INSERT INTO unions (union_id, union_name) VALUES (1, 'Union A'), (2, 'Union B'), (3, 'Union C'), (4, 'Union D');
|
Identify the number of labor rights violations in each union.
|
SELECT unions.union_name, SUM(union_violations.violation_count) FROM unions INNER JOIN union_violations ON unions.union_id = union_violations.union_id GROUP BY unions.union_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, financial_capability_score INT, financial_wellbeing DECIMAL(10,2));
|
Display the number of customers who have both a high financial capability score and a high financial wellbeing score
|
SELECT COUNT(*) FROM customers WHERE financial_capability_score > 7 AND financial_wellbeing > 7;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.