context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE GreenCertified (id INT, city VARCHAR(50), building_count INT); INSERT INTO GreenCertified (id, city, building_count) VALUES (1, 'Toronto', 150), (2, 'Vancouver', 120), (3, 'Montreal', 180), (4, 'Calgary', 100);
How many green certified buildings are there in each city in Canada?
SELECT city, building_count FROM GreenCertified WHERE country = 'Canada' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE treatment_costs (cost_id INT, treatment_approach VARCHAR(255), cost DECIMAL(10, 2)); INSERT INTO treatment_costs (cost_id, treatment_approach, cost) VALUES (1, 'CBT', 150.00), (2, 'DBT', 200.00), (3, 'EMDR', 250.00), (4, 'Medication', 50.00), (5, 'Lithium', 75.00), (6, 'Antipsychotics', 100.00);
What is the average cost of treatment for each unique treatment_approach in the 'treatment_costs' schema?
SELECT treatment_approach, AVG(cost) AS avg_cost FROM treatment_costs GROUP BY treatment_approach;
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (ArtworkID INT, Title VARCHAR(100), Type VARCHAR(50), Price FLOAT); INSERT INTO Artwork VALUES (1, 'Guernica', 'Painting', 2000000); INSERT INTO Artwork VALUES (2, 'Venus de Milo', 'Sculpture', 1200000);
List all sculptures with their sale prices in descending order.
SELECT Title, Price FROM Artwork WHERE Type = 'Sculpture' ORDER BY Price DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(100), species VARCHAR(50), population INT); INSERT INTO animals (id, name, species, population) VALUES (1, 'Giraffe', 'Mammal', 30000), (2, 'Elephant', 'Mammal', 5000); CREATE VIEW mammals_view AS SELECT * FROM animals WHERE species = 'Mammal';
Count the number of records in the 'mammals_view' view
SELECT COUNT(*) FROM mammals_view;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, country VARCHAR(50), orbital_altitude INT); INSERT INTO satellites (satellite_id, country, orbital_altitude) VALUES (1, 'USA', 700), (2, 'USA', 800), (3, 'China', 600), (4, 'Russia', 900), (5, 'India', 1000), (6, 'Japan', 1100);
What is the average orbital altitude of satellites launched by each country?
SELECT country, AVG(orbital_altitude) as average_altitude FROM satellites GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Orders (order_id INT, order_date DATE, order_value FLOAT, country VARCHAR(50)); INSERT INTO Orders (order_id, order_date, order_value, country) VALUES (1, '2021-01-01', 150.00, 'USA'), (2, '2021-01-02', 200.00, 'Canada'), (3, '2021-01-03', 120.00, 'USA'), (4, '2021-01-04', 50.00, 'Mexico'), (5, '2021-01-05...
Identify the top 3 countries with the highest average order value.
SELECT country, AVG(order_value) AS avg_order_value FROM Orders GROUP BY country ORDER BY avg_order_value DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE network_latency (latency_id INT, state VARCHAR(50), latency FLOAT, measurement_date DATE); INSERT INTO network_latency (latency_id, state, latency, measurement_date) VALUES (1, 'Texas', 20, '2022-01-01'); INSERT INTO network_latency (latency_id, state, latency, measurement_date) VALUES (2, 'Texas', 25, '20...
What is the average network latency in the state of Texas for the last month?
SELECT AVG(latency) FROM network_latency WHERE state = 'Texas' AND measurement_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 35, 'Female', 'Premium'), (2, 45, 'Male', 'Basic'), (3, 28, 'Female', 'Premium'); CREATE TABLE ClassAttendance (MemberID INT, Class VARCHAR(20), Duration I...
What is the total duration of Yoga classes attended by members in their 30s?
SELECT SUM(Duration) FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE Members.Age BETWEEN 30 AND 39 AND ClassAttendance.Class = 'Yoga';
gretelai_synthetic_text_to_sql
CREATE TABLE Farming(country VARCHAR(255), year INT, species VARCHAR(255), production FLOAT);
Insert new records of farmed trout in Iceland in 2023 with production quantities of 500, 750, and 1000.
INSERT INTO Farming (country, year, species, production) VALUES ('Iceland', 2023, 'Trout', 500), ('Iceland', 2023, 'Trout', 750), ('Iceland', 2023, 'Trout', 1000);
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name VARCHAR(255));CREATE TABLE properties (property_id INT, city_id INT, has_sustainable_features BOOLEAN); INSERT INTO cities (city_id, city_name) VALUES (1, 'CityA'), (2, 'CityB'); INSERT INTO properties (property_id, city_id, has_sustainable_features) VALUES (1, 1, TRUE), (2, ...
What is the percentage of properties in each city that have sustainable features?
SELECT city_id, 100.0 * AVG(has_sustainable_features::INT) as percentage_sustainable FROM properties GROUP BY city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE budget_allocation (year INT, state VARCHAR(20), service VARCHAR(20), amount INT); INSERT INTO budget_allocation VALUES (2021, 'California', 'Public Safety', 3000000), (2021, 'California', 'Environmental Protection', 4000000);
What is the total budget allocated for public safety and environmental protection services in the state of California in 2021?
SELECT SUM(amount) FROM budget_allocation WHERE state = 'California' AND (service = 'Public Safety' OR service = 'Environmental Protection') AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_sales (sale_id INT, sale_country VARCHAR(50), tickets_sold INT); INSERT INTO concert_sales (sale_id, sale_country, tickets_sold) VALUES (1, 'Japan', 500), (2, 'China', 800), (3, 'Canada', 1500);
What percentage of concert ticket sales are from Asia?
SELECT (SUM(CASE WHEN sale_country = 'Asia' THEN tickets_sold ELSE 0 END) / SUM(tickets_sold)) * 100 AS percentage FROM concert_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE polkadot_dapps (wallet_address VARCHAR(255), interaction_count INT);
What is the total number of unique wallet addresses that have interacted with decentralized applications on the Polkadot network, and what is the average number of interactions per address?
SELECT COUNT(DISTINCT wallet_address) as total_wallets, AVG(interaction_count) as avg_interactions FROM polkadot_dapps;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, attorney_name VARCHAR(50), case_outcome VARCHAR(10)); INSERT INTO cases (case_id, attorney_name, case_outcome) VALUES (1, 'Jane Jones', 'Won'), (2, 'Robert Smith', 'Lost'), (3, 'Jane Jones', 'Won');
What are the names of attorneys who have a 100% success rate?
SELECT attorney_name FROM cases WHERE case_outcome = 'Won' GROUP BY attorney_name HAVING COUNT(*) = (SELECT COUNT(*) FROM cases WHERE attorney_name = cases.attorney_name AND case_outcome = 'Won');
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, founder_race TEXT, num_employees INT); INSERT INTO startup (id, name, founder_race, num_employees) VALUES (1, 'MinorityStart', 'Minority', 500); INSERT INTO startup (id, name, founder_race, num_employees) VALUES (2, 'TechStart', 'White', 100);
What is the maximum number of employees for startups founded by minorities?
SELECT MAX(num_employees) FROM startup WHERE founder_race = 'Minority';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item_name VARCHAR(255), category VARCHAR(255), is_fair_trade BOOLEAN, is_organic BOOLEAN); INSERT INTO inventory (id, item_name, category, is_fair_trade, is_organic) VALUES (1, 'T-Shirt', 'Tops', true, true), (2, 'Jeans', 'Bottoms', true, false), (3, 'Hoodie', 'Tops', false, true);
What is the total number of fair trade and organic certified items in the inventory?
SELECT COUNT(*) FROM inventory WHERE is_fair_trade = true OR is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id INTEGER, country TEXT); INSERT INTO clinical_trials (trial_id, country) VALUES (1, 'CountryA'), (2, 'CountryB'), (3, 'CountryC');
List all clinical trials that have been conducted in 'CountryA' or 'CountryB'.
SELECT DISTINCT trial_id FROM clinical_trials WHERE country IN ('CountryA', 'CountryB');
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id int, age int, gender varchar(10), country varchar(20)); INSERT INTO players (player_id, age, gender, country) VALUES (1, 25, 'Male', 'USA'), (2, 30, 'Female', 'Canada'), (3, 22, 'Male', 'Mexico'), (4, 35, 'Female', 'USA'); CREATE TABLE game_sessions (session_id int, player_id int, game_n...
List the names of all female players who have played strategy games.
SELECT DISTINCT players.player_id, players.gender, game_sessions.game_name FROM players INNER JOIN game_sessions ON players.player_id = game_sessions.player_id INNER JOIN game_catalog ON game_sessions.game_name = game_catalog.game_name WHERE players.gender = 'Female' AND game_catalog.game_type = 'Strategy';
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (id INT, owner VARCHAR(10), province VARCHAR(20), women_owned BOOLEAN); INSERT INTO businesses (id, owner, province, women_owned) VALUES (1, 'Owner 1', 'Province 1', true); INSERT INTO businesses (id, owner, province, women_owned) VALUES (2, 'Owner 2', 'Province 2', false);
What is the total number of women-owned businesses in each province of South Africa?
SELECT province, COUNT(*) FROM businesses WHERE women_owned = true GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE CountrySales (country VARCHAR(50), product_id INT, revenue DECIMAL(10,2), is_organic BOOLEAN);
Which countries have the highest sales revenue for organic hair care products?
SELECT country, SUM(revenue) FROM CountrySales WHERE is_organic = TRUE GROUP BY country ORDER BY SUM(revenue) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchExpeditions(expedition_id INT, organization VARCHAR(255));
What is the total number of research expeditions to the Arctic by organization?
SELECT organization, COUNT(*) FROM ResearchExpeditions GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), type VARCHAR(20), budget FLOAT); INSERT INTO projects (id, name, location, type, budget) VALUES (1, 'Carbon Capture', 'US', 'Mitigation', 7000000.0); INSERT INTO projects (id, name, location, type, budget) VALUES (2, 'Green Roofs', 'New ...
What is the total budget of all climate mitigation projects in the US?
SELECT SUM(budget) FROM projects WHERE location = 'US' AND type = 'Mitigation';
gretelai_synthetic_text_to_sql
CREATE TABLE Festivals (id INT, name VARCHAR(50), country VARCHAR(50), year INT, revenue INT); INSERT INTO Festivals (id, name, country, year, revenue) VALUES (1, 'Glastonbury', 'UK', 2022, 5000000), (2, 'Tomorrowland', 'Belgium', 2022, 7000000), (3, 'Roskilde', 'Denmark', 2021, 6000000);
What is the total revenue generated by music festivals in Europe in 2022?
SELECT SUM(revenue) FROM Festivals WHERE country IN ('UK', 'Belgium', 'Denmark') AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesigners (DesignerID INT, DesignerName VARCHAR(50), Gender VARCHAR(10), Country VARCHAR(20), GameID INT);
How many games are designed by women in Canada and Germany?
SELECT COUNT(DISTINCT GameID) FROM GameDesigners WHERE Country IN ('Canada', 'Germany') AND Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_policies (policy_name VARCHAR(255), policy_date DATE);
How many energy efficiency policies were implemented in the EU between 2015 and 2020, inclusive?
SELECT COUNT(*) FROM energy_efficiency_policies WHERE policy_date BETWEEN '2015-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE weather (city VARCHAR(255), temperature FLOAT, date DATE); INSERT INTO weather (city, temperature, date) VALUES ('Miami', 75, '2022-01-01'), ('Miami', 72, '2022-01-02'), ('Miami', 78, '2022-01-03');
What is the average temperature in 'Miami' for January?
SELECT AVG(temperature) FROM weather WHERE city = 'Miami' AND date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_database (offender_id INT, offense VARCHAR(255)); CREATE TABLE offender_demographics (offender_id INT, ethnicity VARCHAR(255));
How many unique offenders were there in the 'criminal_database' table without specifying their ethnicity in the 'offender_demographics' table?
SELECT COUNT(DISTINCT offender_id) FROM criminal_database WHERE offender_id NOT IN (SELECT offender_id FROM offender_demographics);
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (RegionID int, RegionName varchar(50)); INSERT INTO Regions VALUES (1, 'North'); INSERT INTO Regions VALUES (2, 'South'); CREATE TABLE VehicleMaintenance (MaintenanceID int, VehicleID int, MaintenanceDate date, RegionID int); INSERT INTO VehicleMaintenance VALUES (1, 1, '2022-02-10', 1); INSERT INT...
How many vehicles were serviced in each region last month?
SELECT Regions.RegionName, COUNT(VehicleMaintenance.VehicleID) as VehiclesServiced FROM Regions INNER JOIN VehicleMaintenance ON Regions.RegionID = VehicleMaintenance.RegionID WHERE VehicleMaintenance.MaintenanceDate BETWEEN DATE_SUB(LAST_DAY(CURDATE()), INTERVAL 2 MONTH) AND LAST_DAY(CURDATE()) GROUP BY Regions.Region...
gretelai_synthetic_text_to_sql
CREATE TABLE employment_initiatives (initiative_id INT, state VARCHAR(2), start_year INT, end_year INT, initiative_value DECIMAL(10, 2)); INSERT INTO employment_initiatives (initiative_id, state, start_year, end_year, initiative_value) VALUES (1, 'Texas', 2018, 2022, 1500000.00), (2, 'California', 2019, 2023, 1200000.0...
What is the total value of veteran employment initiatives in Texas since 2018?
SELECT SUM(initiative_value) FROM employment_initiatives WHERE state = 'Texas' AND start_year <= 2018 AND end_year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Wind_Farms (Farm_Name VARCHAR(30), Country VARCHAR(20), Production INT); INSERT INTO Wind_Farms VALUES ('Horns Rev', 'Denmark', 250), ('Rødsand', 'Denmark', 300), ('Nysted', 'Denmark', 350), ('Anholt', 'Denmark', 400);
What is the average energy production of wind farms in Denmark?
SELECT AVG(Production) AS Avg_Production FROM Wind_Farms WHERE Country = 'Denmark';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(50), rating DECIMAL(3,2)); INSERT INTO movies (id, title, genre, rating) VALUES (1, 'MovieA', 'Action', 7.2); INSERT INTO movies (id, title, genre, rating) VALUES (2, 'MovieB', 'Comedy', 8.5); INSERT INTO movies (id, title, genre, rating) VALUES (3, 'MovieC...
What is the average rating for movies belonging to the 'Action' genre?
SELECT AVG(rating) FROM movies WHERE genre = 'Action';
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name TEXT, habitat_type TEXT, size_km2 FLOAT); INSERT INTO habitats (id, name, habitat_type, size_km2) VALUES (1, 'Habitat1', 'Forest', 50.3), (2, 'Habitat2', 'Savannah', 32.1), (3, 'Habitat3', 'Savannah', 87.6), (4, 'Habitat4', 'Wetlands', 22.5), (5, 'Habitat5', 'Forest', 75.8);
What is the total size of protected habitats for each type of habitat?
SELECT habitat_type, SUM(size_km2) as total_size FROM habitats GROUP BY habitat_type;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, material VARCHAR(20), price DECIMAL(5,2), market VARCHAR(20)); INSERT INTO products (product_id, material, price, market) VALUES (1, 'organic cotton', 50.00, 'Europe'), (2, 'polyester', 30.00, 'Europe'), (3, 'organic cotton', 60.00, 'Asia');
What is the average price of products made from organic cotton, sold in the European market?
SELECT AVG(price) FROM products WHERE material = 'organic cotton' AND market = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Events (event_id, category, price) VALUES (1, 'Concert', 50.99), (2, 'Sports', 30.50), (3, 'Theater', 75.00); CREATE TABLE Fans (fan_id INT, age INT, event_id INT); INSERT INTO Fans (fan_id, age, event_id) VALUES (1, 25, 1), (2, ...
How many fans attended each event category?
SELECT e.category, COUNT(f.fan_id) FROM Events e LEFT JOIN Fans f ON e.event_id = f.event_id GROUP BY e.category;
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (facility_id INT, name VARCHAR(50), state VARCHAR(20), mental_health_services BOOLEAN);
List the number of rural healthcare facilities in each state that offer mental health services.
SELECT state, COUNT(*) FROM facilities WHERE mental_health_services = true GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(50), total_billing_amount DECIMAL(10,2)); CREATE TABLE cases (id INT, attorney_id INT, case_outcome VARCHAR(10));
What is the total billing amount for cases lost by the top 2 attorneys?
SELECT SUM(total_billing_amount) FROM (SELECT attorney_id, SUM(billing_amount) AS total_billing_amount FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE case_outcome = 'lost' GROUP BY attorney_id ORDER BY total_billing_amount DESC LIMIT 2);
gretelai_synthetic_text_to_sql
CREATE TABLE ytterbium_prices (year INT, country TEXT, price FLOAT); INSERT INTO ytterbium_prices (year, country, price) VALUES (2019, 'South Africa', 220.0), (2020, 'South Africa', 230.0), (2021, 'South Africa', 240.0);
What is the minimum price of Ytterbium produced in South Africa for the last 3 years?
SELECT MIN(price) FROM ytterbium_prices WHERE country = 'South Africa' AND year >= 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE advisors (id INT, student_id INT); INSERT INTO students VALUES (1, 'Aarav', 'Engineering'), (2, 'Bella', 'Engineering'), (3, 'Chris', 'Engineering'); INSERT INTO advisors VALUES (1, 1), (2, 2);
Identify the graduate students in the College of Engineering who have not been assigned any advisors.
SELECT DISTINCT students.id, students.name FROM students LEFT JOIN advisors ON students.id = advisors.student_id WHERE advisors.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, semester VARCHAR(20));
What is the average mental health score of students in the 'Spring 2022' semester?
SELECT AVG(mental_health_score) FROM student_mental_health WHERE semester = 'Spring 2022';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_sales(product_name TEXT, weight FLOAT, sale_country TEXT); INSERT INTO cosmetics_sales(product_name, weight, sale_country) VALUES ('Mascara', 12.5, 'France');
What is the total weight of plastic packaging used in cosmetics sold in France?
SELECT SUM(weight) FROM cosmetics_sales WHERE sale_country = 'France' AND packaging_material = 'plastic';
gretelai_synthetic_text_to_sql
CREATE TABLE visual_arts_funding (id INT, program_type VARCHAR(255), funding_year INT, amount DECIMAL(10, 2));
What is the change in funding for each visual arts program type from 2021 to 2022?
SELECT program_type, (fy2022.amount - fy2021.amount) AS funding_change FROM visual_arts_funding fy2021, visual_arts_funding fy2022 WHERE fy2021.program_type = fy2022.program_type AND fy2021.funding_year = 2021 AND fy2022.funding_year = 2022 AND fy2021.program_type LIKE '%visual%arts%';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (organization_id INT, name VARCHAR(50), donations_social_good FLOAT, country VARCHAR(50)); INSERT INTO organizations (organization_id, name, donations_social_good, country) VALUES (1, 'OrgA', 100000.0, 'USA'), (2, 'OrgB', 150000.0, 'Canada'), (3, 'OrgC', 75000.0, 'USA'), (4, 'OrgD', 200000.0,...
List the names and total contributions of organizations that have donated to technology for social good initiatives in the United States and Canada.
SELECT name, SUM(donations_social_good) FROM organizations WHERE country IN ('USA', 'Canada') GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, launch_country VARCHAR(50)); INSERT INTO space_missions (id, mission_name, launch_date, launch_country) VALUES (1, 'STS-31', '1990-04-24', 'USA'); INSERT INTO space_missions (id, mission_name, launch_date, launch_country) VALUES (2, 'Soyuz...
Which countries have launched the most space missions in the last 10 years?
SELECT launch_country, COUNT(*) FROM space_missions WHERE YEAR(launch_date) >= YEAR(CURRENT_DATE) - 10 GROUP BY launch_country ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_mass (spacecraft_name VARCHAR(50), type VARCHAR(50), mass FLOAT);
Get the average mass of spacecraft per type.
SELECT type, AVG(mass) as avg_mass FROM spacecraft_mass GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousDrivingResearch (StudyID INT, StudyLocation VARCHAR(20)); INSERT INTO AutonomousDrivingResearch (StudyID, StudyLocation) VALUES (1, 'North America'), (2, 'Europe');
How many autonomous driving research studies were conducted in North America?
SELECT COUNT(*) FROM AutonomousDrivingResearch WHERE StudyLocation = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE PhotographyExhibit(id INT, age INT, gender VARCHAR(10), visit_date DATE, is_repeat BOOLEAN);
What is the percentage of repeat visitors for the "Photography Exhibit" program?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM PhotographyExhibit WHERE is_repeat = FALSE) FROM PhotographyExhibit WHERE is_repeat = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE us_city_certifications (city VARCHAR(20), certifications INT); INSERT INTO us_city_certifications (city, certifications) VALUES ('New York', 500), ('Los Angeles', 300), ('Chicago', 400), ('Houston', 200);
Show the top 3 cities with the most green building certifications in the United States.
SELECT city, certifications FROM (SELECT city, certifications, RANK() OVER (ORDER BY certifications DESC) as rank FROM us_city_certifications WHERE country = 'United States') AS subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE city_customer_data (customer_id INT, city VARCHAR(50), data_usage_gb FLOAT); INSERT INTO city_customer_data (customer_id, city, data_usage_gb) VALUES (1, 'Delhi', 25.6), (2, 'Delhi', 30.9), (3, 'Mumbai', 45.2), (4, 'Mumbai', 52.1), (5, 'Bangalore', 15.6), (6, 'Bangalore', 18.9);
What is the average data usage difference between the highest and lowest data usage customers in each city?
SELECT city, AVG(MAX(data_usage_gb) - MIN(data_usage_gb)) as avg_data_usage_diff FROM city_customer_data GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, age INT, gender VARCHAR(10), racial_ethnic_minority BOOLEAN);
What is the average age of employees who identify as a racial or ethnic minority?
SELECT AVG(age) FROM employees WHERE racial_ethnic_minority = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, gender TEXT, country TEXT); CREATE TABLE diagnoses (id INT, patient_id INT, disorder_name TEXT); INSERT INTO diagnoses (id, patient_id, disorder_name) VALUES (1, 101, 'Anxiety Disorder');
What is the minimum age of patients in Australia who have been diagnosed with anxiety disorders?
SELECT MIN(patients.age) FROM patients JOIN diagnoses ON patients.id = diagnoses.patient_id WHERE diagnoses.disorder_name = 'Anxiety Disorder' AND patients.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE court_types (court_type_id INT, court_type_name VARCHAR(20), court_state VARCHAR(2)); INSERT INTO court_types VALUES (1, 'Community', 'NY'), (2, 'Juvenile', 'CA'), (3, 'Traffic', 'IL'), (4, 'Civil', 'TX'); CREATE TABLE court_cases (case_id INT, case_state VARCHAR(2), court_type_id INT, days_to_resolve INT)...
What is the total number of cases heard in each court type in each state?
SELECT ct.court_type_name, cc.case_state, COUNT(cc.case_id) FROM court_types ct INNER JOIN court_cases cc ON ct.court_type_id = cc.court_type_id GROUP BY ct.court_type_name, cc.case_state;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (state VARCHAR(255), building_type VARCHAR(255));
What is the average number of green buildings per state in the 'green_buildings' table?
SELECT state, AVG(cnt) FROM (SELECT state, COUNT(*) AS cnt FROM green_buildings GROUP BY state) AS state_building_counts;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish VARCHAR(50), created_at TIMESTAMP, is_vegetarian BOOLEAN, is_gluten_free BOOLEAN);CREATE TABLE orders (order_id INT, dish_id INT, price DECIMAL(5,2));
What is the revenue trend for dishes that are both vegetarian and gluten-free in the last month?
SELECT DATE_TRUNC('day', d.created_at) as day, SUM(o.price) as revenue FROM dishes d JOIN orders o ON d.dish_id = o.dish_id WHERE d.is_vegetarian = TRUE AND d.is_gluten_free = TRUE AND d.created_at >= NOW() - INTERVAL '1 month' GROUP BY day ORDER BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE thailand_aquaculture_sites (site_id INT, site_name TEXT, water_depth FLOAT, country TEXT); INSERT INTO thailand_aquaculture_sites (site_id, site_name, water_depth, country) VALUES (1, 'Site O', 12.5, 'Thailand'), (2, 'Site P', 8.2, 'Thailand'), (3, 'Site Q', 15.0, 'Thailand');
Count the number of aquaculture sites in Thailand with a water depth greater than 10 meters?
SELECT COUNT(*) FROM thailand_aquaculture_sites WHERE water_depth > 10.0;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(30)); INSERT INTO artists (artist_id, artist_name) VALUES (1, 'Ariana Grande'), (2, 'BTS'), (3, 'Drake'), (4, 'Ed Sheeran'), (5, 'Taylor Swift'); CREATE TABLE streams (stream_id INT, artist_id INT, revenue DECIMAL(10,2), stream_date DATE); INSERT INTO streams (st...
Who are the top 3 artists by total revenue from streaming platforms in 2020?
SELECT artists.artist_name, SUM(streams.revenue) AS total_revenue FROM artists INNER JOIN streams ON artists.artist_id = streams.artist_id WHERE streams.stream_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY artists.artist_name ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE local_business (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), seats INT); INSERT INTO local_business (id, name, type, location, seats) VALUES (1, 'Bistrot La Fontaine', 'French', 'Paris', 15);
What are the names and types of local businesses in Paris with more than 10 seats?
SELECT l.name, l.type, l.location FROM local_business l WHERE l.location = 'Paris' AND l.seats > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE team_schedule (team_id INT, played INT); INSERT INTO team_schedule (team_id, played) VALUES (1, 25), (2, 28), (3, 30), (4, 26);
What is the maximum number of games played by a team in a single season?
SELECT MAX(played) FROM team_schedule;
gretelai_synthetic_text_to_sql
CREATE TABLE tours_sp_de (id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO tours_sp_de (id, country, type) VALUES (1, 'Spain', 'Eco-friendly'), (2, 'Spain', 'Regular'), (3, 'Germany', 'Eco-friendly');
What is the total number of eco-friendly tours offered in Spain and Germany?
SELECT SUM(CASE WHEN type = 'Eco-friendly' THEN 1 ELSE 0 END) FROM tours_sp_de WHERE country IN ('Spain', 'Germany');
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(50), topic VARCHAR(50), publish_date DATE); INSERT INTO articles (id, title, topic, publish_date) VALUES (1, 'Investigation on Corruption', 'investigative journalism', '2022-02-10');
What is the total number of articles published on investigative journalism in the last year?
SELECT COUNT(*) FROM articles WHERE topic = 'investigative journalism' AND publish_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE passenger (passenger_id INT, route_id INT, boarding_time TIMESTAMP, alighting_time TIMESTAMP); INSERT INTO passenger (passenger_id, route_id, boarding_time, alighting_time) VALUES (1, 1, '2021-01-01 08:10:00', '2021-01-01 08:20:00'), (2, 1, '2021-01-01 08:30:00', '2021-01-01 08:40:00'), (3, 2, '2021-01-01 ...
How many unique passengers have traveled on each route, ordered by the number of passengers?
SELECT route_id, COUNT(DISTINCT passenger_id) AS unique_passengers FROM passenger GROUP BY route_id ORDER BY unique_passengers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE precipitation_data (region VARCHAR(255), precipitation INT, date DATE); INSERT INTO precipitation_data (region, precipitation, date) VALUES ('Africa', 50, '2022-01-01'), ('Asia', 75, '2022-01-01'), ('Australia', 100, '2022-01-01'), ('South America', 125, '2022-01-01'), ('Antarctica', 150, '2022-01-01');
What is the average precipitation in the top 5 driest regions in the past year?
SELECT region, AVG(precipitation) as avg_precipitation FROM (SELECT region, precipitation, RANK() OVER (PARTITION BY NULL ORDER BY precipitation ASC) as rain_rank FROM precipitation_data WHERE date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY region) subquery WHERE rain_rank <= 5 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE mature_forest (id INT, species VARCHAR(255), age INT); INSERT INTO mature_forest (id, species, age) VALUES (1, 'Pine', 25), (2, 'Oak', 30), (3, 'Maple', 28);
What is the minimum age of trees in the mature_forest table?
SELECT MIN(age) FROM mature_forest;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT);
Create a view to show all completed projects
CREATE VIEW completed_projects AS SELECT * FROM climate_mitigation_projects WHERE end_date < CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_id INT, name VARCHAR(50), state VARCHAR(20), num_beds INT); INSERT INTO hospitals (hospital_id, name, state, num_beds) VALUES (1, 'Hospital A', 'New York', 500), (2, 'Hospital B', 'Texas', 600), (3, 'Hospital C', 'California', 700); CREATE TABLE states (state VARCHAR(20), region VARCHAR...
Identify the top 3 states with the highest number of hospitals and the corresponding number of beds in those hospitals.
SELECT s.state, h.num_beds FROM hospitals h INNER JOIN states s ON h.state = s.state WHERE h.state IN (SELECT s.state FROM hospitals h INNER JOIN states s ON h.state = s.state GROUP BY s.state ORDER BY COUNT(h.hospital_id) DESC LIMIT 3) ORDER BY num_beds DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Training (TrainingID INT, EmployeeID INT, TrainingType VARCHAR(20), Cost DECIMAL(10,2), TrainingDate DATE); INSERT INTO Training (TrainingID, EmployeeID, TrainingType, Cost, TrainingDate) VALUES (1, 1, 'Diversity', 1500.00, '2021-01-01'), (2, 2, 'Leadership', 2000.00, '2021-02-01'), (3, 3, 'Diversity', 100...
What is the total training cost for underrepresented employees in the last year?
SELECT SUM(Cost) FROM Training JOIN Employees ON Training.EmployeeID = Employees.EmployeeID WHERE Employees.Gender IN ('Female', 'Non-binary') OR Employees.Department = 'Diversity';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), HoursDonated int, VolunteerYear int); INSERT INTO Volunteers (VolunteerID, VolunteerName, HoursDonated, VolunteerYear) VALUES (1, 'Grace Blue', 30, 2022), (2, 'Harry Yellow', 20, 2022), (3, 'Ivy Purple', 15, 2022), (4, 'Jack Orange', 25, 2022);
What is the total number of volunteers and total hours donated by them in '2022'?
SELECT COUNT(VolunteerName) as TotalVolunteers, SUM(HoursDonated) as TotalHours FROM Volunteers WHERE VolunteerYear = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Construction_Labor (worker_id INT, occupation VARCHAR(50), state VARCHAR(50), salary FLOAT); INSERT INTO Construction_Labor VALUES (7890, 'Electrician', 'California', 60000);
What is the average salary of construction workers in California, grouped by occupation?
SELECT occupation, AVG(salary) FROM Construction_Labor WHERE state = 'California' GROUP BY occupation;
gretelai_synthetic_text_to_sql
CREATE TABLE media_outlets (id INT, name TEXT, country TEXT, media_literacy_score INT); INSERT INTO media_outlets (id, name, country, media_literacy_score) VALUES (1, 'Outlet 1', 'Nigeria', 6); INSERT INTO media_outlets (id, name, country, media_literacy_score) VALUES (2, 'Outlet 2', 'Kenya', 7);
How many media outlets in Africa have a media literacy score above 7?
SELECT COUNT(*) FROM media_outlets WHERE country = 'Africa' AND media_literacy_score > 7;
gretelai_synthetic_text_to_sql
CREATE TABLE flu_shots (flu_shot_id INT, patient_id INT, date DATE, region VARCHAR(20)); INSERT INTO flu_shots (flu_shot_id, patient_id, date, region) VALUES (1, 3, '2021-01-01', 'European'); INSERT INTO flu_shots (flu_shot_id, patient_id, date, region) VALUES (2, 4, '2021-02-01', 'American');
What is the maximum number of flu shots administered in a single day in the European region?
SELECT MAX(count) FROM (SELECT date, COUNT(*) as count FROM flu_shots GROUP BY date) as subquery
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (project_id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);
How many climate communication projects are in 'Europe' and 'North America'?
SELECT COUNT(*) FROM climate_communication WHERE location IN ('Europe', 'North America');
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Women Empowerment'), (2, 'Refugee Support'), (3, 'Disaster Relief'); CREATE TABLE volunteer_hours (id INT, program_id INT, volunteer_id INT, hours INT); INSERT INTO volunteer_hours (id, program_id, volunteer_id, hours) VALUES...
How many volunteers have contributed to each program in 2022?
SELECT program_id, COUNT(DISTINCT volunteer_id) as num_volunteers FROM volunteer_hours GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(50), type VARCHAR(30)); CREATE TABLE grants (id INT, org_id INT, amount INT, date DATE, purpose VARCHAR(30)); INSERT INTO organizations (id, name, type) VALUES (1, 'ABC Nonprofit', 'capacity building'), (2, 'DEF Nonprofit', 'social impact'), (3, 'GHI Nonprofit', 'fundrai...
Which organizations have received grants for capacity building in the last year?
SELECT organizations.name FROM organizations INNER JOIN grants ON organizations.id = grants.org_id WHERE grants.date >= DATEADD(year, -1, GETDATE()) AND organizations.type = 'capacity building';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(255), gender VARCHAR(10), hire_date DATE); INSERT INTO employees (id, name, gender, hire_date) VALUES (1, 'Jane Doe', 'Female', '2022-03-15'), (2, 'Alice Smith', 'Female', '2022-02-03'), (3, 'Bob Johnson', 'Male', '2022-01-01'), (4, 'Grace Lee', 'Female', '2022-04-01');
What is the count of new employees by gender in the last 3 months?
SELECT gender, COUNT(id) as new_employees FROM employees WHERE hire_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_data (id INT, image_id VARCHAR(255), temperature INT, humidity INT, timestamp DATETIME); INSERT INTO satellite_data (id, image_id, temperature, humidity, timestamp) VALUES (1, 'IMG001', 20, 70, '2022-01-01 10:00:00');
List all the satellite images taken in the past month, along with the average temperature and humidity at the time of capture.
SELECT image_id, AVG(temperature) as avg_temp, AVG(humidity) as avg_humidity FROM satellite_data WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY image_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Gender varchar(50), AmountDonated numeric(10,2)); INSERT INTO Donors (DonorID, DonorName, Gender, AmountDonated) VALUES (1, 'John Doe', 'Male', 500.00), (2, 'Jane Smith', 'Female', 750.00);
What was the total amount donated by each gender in H1 2021?
SELECT Gender, SUM(AmountDonated) as TotalDonated FROM Donors WHERE AmountDonated >= 0 AND AmountDonated < 9999.99 GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Location) VALUES (1, 'Fresh CA Produce', 'California'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, Category VARCHAR(50), Price DECIMAL(5, 2)); INS...
List the total quantity of fruits ordered from local suppliers in California?
SELECT SUM(Quantity) FROM Orders JOIN Products ON Orders.ProductID = Products.ProductID JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Suppliers.Location = 'California' AND Products.Category = 'Fruits';
gretelai_synthetic_text_to_sql
CREATE TABLE program (id INT, name TEXT);CREATE TABLE student (id INT, program_id INT, enrollment_status TEXT);
What is the average number of graduate students enrolled per program?
SELECT AVG(s.count) FROM (SELECT program_id, COUNT(*) AS count FROM student s GROUP BY program_id) s;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50), balance DECIMAL(10,2)); INSERT INTO customers (id, name, region, balance) VALUES (1, 'John Doe', 'Southeast', 5000.00), (2, 'Jane Smith', 'Northeast', 7000.00);
What is the total balance for all customers in the Southeast region?
SELECT SUM(balance) FROM customers WHERE region = 'Southeast';
gretelai_synthetic_text_to_sql
CREATE TABLE dimensions (dimension_id INT PRIMARY KEY, work_id INT, height FLOAT, width FLOAT, depth FLOAT, FOREIGN KEY (work_id) REFERENCES works(work_id));
What are the average dimensions of sculptures in the surrealism category?
SELECT AVG(height) AS avg_height, AVG(width) AS avg_width, AVG(depth) AS avg_depth FROM dimensions d JOIN works w ON d.work_id = w.work_id WHERE w.style = 'Surrealism' AND w.category = 'Sculpture';
gretelai_synthetic_text_to_sql
CREATE TABLE workplace_safety_metrics (ws_id SERIAL PRIMARY KEY, union_id VARCHAR(5), incident_type TEXT, total_incidents INT, date DATE);
Update the total_incidents column in the workplace_safety_metrics table to 15 for all records with an incident_type of 'Electrical Hazards' and union_id of 006
UPDATE workplace_safety_metrics SET total_incidents = 15 WHERE incident_type = 'Electrical Hazards' AND union_id = '006';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_id INT, brand_id INT, quantity INT); CREATE TABLE products (id INT, name VARCHAR(255), brand_id INT, is_cruelty_free BOOLEAN);
List all cruelty-free products and their brands with more than 1000 sales
SELECT p.name, b.brand_name FROM products p INNER JOIN (SELECT brand_id, SUM(quantity) as total_sales FROM sales GROUP BY brand_id HAVING total_sales > 1000) s ON p.brand_id = s.brand_id INNER JOIN brands b ON p.brand_id = b.id WHERE p.is_cruelty_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Airline_Companies (Company_Name VARCHAR(50)); INSERT INTO Airline_Companies (Company_Name) VALUES ('AirAsia'), ('Lufthansa'), ('Delta'); CREATE TABLE Emissions (Company_Name VARCHAR(50), Flight_Number INT, Year INT, CO2_Emissions INT); INSERT INTO Emissions (Company_Name, Flight_Number, Year, CO2_Emissions...
What is the average CO2 emission per flight for each airline company?
SELECT AC.Company_Name, AVG(E.CO2_Emissions) AS Avg_CO2_Emissions FROM Emissions E JOIN Airline_Companies AC ON E.Company_Name = AC.Company_Name GROUP BY AC.Company_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, country VARCHAR(100), launch_date DATE, satellite_name VARCHAR(100));
Show the total number of satellites launched by each country in the last 10 years from the satellite_deployment table
SELECT country, COUNT(*) FROM satellite_deployment WHERE launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ProviderTrainings (ID INT PRIMARY KEY, ProviderID INT, Training VARCHAR(50), Duration INT, Location VARCHAR(50), Date DATE); INSERT INTO ProviderTrainings (ID, ProviderID, Training, Duration, Location, Date) VALUES (1, 201, 'Cultural Competency', 120, 'New York', '2022-01-01'); INSERT INTO ProviderTraining...
Find the average 'Cultural Competency' training duration for providers in 'New York' and 'Los Angeles'.
SELECT AVG(Duration) FROM ProviderTrainings WHERE Training = 'Cultural Competency' AND Location IN ('New York', 'Los Angeles');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, dispensary_id INT, strain VARCHAR(255), quantity INT);CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), state VARCHAR(255));
Find the total quantity of each strain sold in Colorado and Oregon.
SELECT strain, SUM(quantity) as total_quantity FROM sales JOIN dispensaries ON sales.dispensary_id = dispensaries.dispensary_id WHERE state IN ('Colorado', 'Oregon') GROUP BY strain;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender VARCHAR(20), condition VARCHAR(50), registration_date DATE); INSERT INTO patients (patient_id, age, gender, condition, registration_date) VALUES (1, 35, 'Female', 'Depression', '2021-05-18'); CREATE TABLE treatments (treatment_id INT, patient_id INT, therapy_type V...
How many patients have been treated with meditation in the past year?
SELECT COUNT(DISTINCT patients.patient_id) FROM patients JOIN treatments ON patients.patient_id = treatments.patient_id WHERE treatments.therapy_type = 'Meditation' AND treatments.treatment_date >= '2020-08-01';
gretelai_synthetic_text_to_sql
CREATE TABLE public.trips_by_day (id SERIAL PRIMARY KEY, vehicle_type TEXT, city TEXT, trips_on_day INTEGER); INSERT INTO public.trips_by_day (vehicle_type, city, trips_on_day) VALUES ('shared_scooter', 'Berlin', 1500), ('shared_scooter', 'Berlin', 1700), ('shared_scooter', 'London', 1200);
What is the maximum number of trips taken by shared scooters in Berlin on a single day?
SELECT MAX(trips_on_day) FROM public.trips_by_day WHERE vehicle_type = 'shared_scooter' AND city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE SchoolConstruction (Country VARCHAR(20), NumSchools INT); INSERT INTO SchoolConstruction (Country, NumSchools) VALUES ('Afghanistan', 15), ('Syria', 20), ('Iraq', 10), ('Jordan', 12), ('Lebanon', 18);
How many schools were built in each country?
SELECT Country, SUM(NumSchools) as TotalSchools FROM SchoolConstruction GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_development (project_id INT, location VARCHAR(30), start_date DATE, end_date DATE, cost INT); INSERT INTO infrastructure_development (project_id, location, start_date, end_date, cost) VALUES (3, 'South Atlantic', '2019-01-01', '2022-12-31', 600000000);
Delete records from the 'infrastructure_development' table where the 'location' is 'South Atlantic'
DELETE FROM infrastructure_development WHERE location = 'South Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableUrbanism (id INT, city VARCHAR(20), size FLOAT);
What is the average size of sustainable urbanism projects in the city of Tokyo?
SELECT AVG(size) FROM SustainableUrbanism WHERE city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE Census (id INT, state VARCHAR(50), population INT); INSERT INTO Census (id, state, population) VALUES (1, 'California', 39512223), (2, 'Texas', 29528404), (3, 'Florida', 21538187), (4, 'New York', 19453561), (5, 'Pennsylvania', 12801989);
Delete all records from the "Census" table where the state is 'California'.
DELETE FROM Census WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Recycling_Rates (material VARCHAR(20), region VARCHAR(20), recycling_rate DECIMAL(4,2)); INSERT INTO Recycling_Rates (material, region, recycling_rate) VALUES ('Glass', 'East', 0.60), ('Paper', 'East', 0.75), ('Plastic', 'West', 0.55), ('Metal', 'North', 0.80);
What is the maximum recycling rate for any material in the East region?
SELECT region, MAX(recycling_rate) FROM Recycling_Rates WHERE region = 'East' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE submersible_dives (id INT, submersible_name VARCHAR(50), region VARCHAR(20), dive_date DATE, max_depth INT);INSERT INTO submersible_dives (id, submersible_name, region, dive_date, max_depth) VALUES (1, 'Trieste', 'Atlantic', '1960-01-23', 10972);INSERT INTO submersible_dives (id, submersible_name, region, ...
What is the maximum depth ever reached by a submersible in the Atlantic Ocean?
SELECT MAX(max_depth) FROM submersible_dives WHERE region = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE injuries (id INT PRIMARY KEY, union_id INT, injury_count INT); INSERT INTO injuries (id, union_id, injury_count) VALUES (1, 1, 1500), (2, 2, 800), (3, 3, 1200);
Find the total number of workplace injuries for each union, and return only the unions with more than 1000 injuries.
SELECT union_id, SUM(injury_count) AS total_injuries FROM injuries GROUP BY union_id HAVING total_injuries > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronaut_Missions (ID INT, Astronaut_Name VARCHAR(255), Mission_Name VARCHAR(255), In_Space BOOLEAN); INSERT INTO Astronaut_Missions (ID, Astronaut_Name, Mission_Name, In_Space) VALUES (1, 'Neil Armstrong', 'Apollo 11', TRUE), (2, 'Buzz Aldrin', 'Apollo 11', TRUE);
What is the maximum number of people in space at any given time, according to the Astronaut_Missions table?
SELECT MAX(Num_In_Space) FROM (SELECT COUNT(*) as Num_In_Space FROM Astronaut_Missions WHERE In_Space = TRUE GROUP BY Mission_Name) AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, name VARCHAR(50), location VARCHAR(50), energyConsumption DECIMAL(5,2)); CREATE TABLE Averages (location VARCHAR(50), avg_consumption DECIMAL(5,2)); INSERT INTO Averages (location, avg_consumption) SELECT location, AVG(energyConsumption) FROM GreenBuildings GROUP BY location; CREATE...
What is the average energy consumption of buildings in each location that have energy consumption above the average energy consumption of all buildings in the 'GreenBuildings' table?
SELECT location, AVG(energyConsumption) as avg_above_average FROM AboveAverage GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE total_sales (state VARCHAR(20), sales_quantity INT, strain_type VARCHAR(10)); INSERT INTO total_sales (state, sales_quantity, strain_type) VALUES ('Oregon', 200, 'hybrid'); INSERT INTO total_sales (state, sales_quantity, strain_type) VALUES ('Washington', 150, 'hybrid'); INSERT INTO total_sales (state, sal...
Find the total sales quantity of hybrid strains in Oregon and Washington, and the percentage of total sales for each state.
SELECT state, sales_quantity, (sales_quantity::FLOAT / SUM(sales_quantity) OVER (PARTITION BY strain_type)) * 100 AS percentage FROM total_sales WHERE strain_type = 'hybrid';
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name TEXT, industry TEXT, union_member BOOLEAN, salary REAL); INSERT INTO workers (id, name, industry, union_member, salary) VALUES (1, 'John Doe', 'construction', true, 60000.00), (2, 'Jane Smith', 'retail', false, 35000.00);
What is the maximum salary of workers who are not union members, grouped by their industry?
SELECT industry, MAX(salary) FROM workers WHERE NOT union_member GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (Station VARCHAR(255), Date DATE, Temperature FLOAT); INSERT INTO WeatherData (Station, Date, Temperature) VALUES ('StationA', '2020-01-01', -10.5), ('StationB', '2020-01-01', -12.3);
What is the average temperature recorded in each Arctic research station in 2020?
SELECT Station, AVG(Temperature) FROM WeatherData WHERE YEAR(Date) = 2020 GROUP BY Station;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing(company VARCHAR(20), cost INT); INSERT INTO SpacecraftManufacturing(company, cost) VALUES('AeroCorp', 5000000), ('GalacticTech', 7000000), ('SpaceEagle', 6000000);
What was the total cost of spacecraft manufactured by 'AeroCorp'?
SELECT SUM(cost) FROM SpacecraftManufacturing WHERE company = 'AeroCorp';
gretelai_synthetic_text_to_sql