context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE safety_audit (audit_id INT, facility_id INT, audit_duration INT); CREATE TABLE facility (facility_id INT, facility_name VARCHAR(255));
What is the average time to complete a safety audit, partitioned by facility and ordered by the longest average times first?
SELECT facility_name, facility_id, AVG(audit_duration) AS avg_audit_time FROM safety_audit JOIN facility ON safety_audit.facility_id = facility.facility_id GROUP BY facility_id, facility_name ORDER BY avg_audit_time DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets_sold (concert_id INT, quantity INT); INSERT INTO tickets_sold (concert_id, quantity) VALUES (1, 1500);
Count the number of concerts where more than 1000 tickets were sold.
SELECT COUNT(*) FROM tickets_sold WHERE quantity > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE media_ethics (article_id INT, author VARCHAR(50), title VARCHAR(100), published_date DATE, category VARCHAR(30)); INSERT INTO media_ethics (article_id, author, title, published_date, category) VALUES (1, 'John Doe', 'Article 5', '2021-01-05', 'Ethics'), (2, 'Jane Smith', 'Article 6', '2021-01-06', 'Ethics');
Who are the top 3 authors with the most articles in the 'media_ethics' table?
SELECT author, COUNT(article_id) AS total_articles FROM media_ethics GROUP BY author ORDER BY total_articles DESC LIMIT 3;
gretelai_synthetic_text_to_sql
temperature_readings
List all unique locations with readings
SELECT DISTINCT location FROM temperature_readings;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, location TEXT, num_individuals INT); INSERT INTO marine_species (name, location, num_individuals) VALUES ('Clownfish', 'Indian Ocean', '10000'), ('Dolphin', 'Atlantic Ocean', '20000');
Show the total number of marine species in the Indian Ocean.
SELECT SUM(num_individuals) FROM marine_species WHERE location = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Galaxies (id INT, name VARCHAR(255), type VARCHAR(255), right_ascension VARCHAR(255), declination VARCHAR(255), diameter_ly DECIMAL(10,2), distance_Mpc DECIMAL(10,2), distance_pc DECIMAL(10,2)); INSERT INTO Galaxies (id, name, type, right_ascension, declination, diameter_ly, distance_Mpc, distance_pc) VALUES (7, 'Maffei 1', 'Elliptical', '0h 55m 55.0s', '59° 40′ 59″', 70000, 3.56, 11600); INSERT INTO Galaxies (id, name, type, right_ascension, declination, diameter_ly, distance_Mpc, distance_pc) VALUES (8, 'Maffei 2', 'Elliptical', '0h 55m 12.0s', '68° 36′ 59″', 110000, 4.42, 14400);
What is the average distance in parsecs for elliptical galaxies?
SELECT type, AVG(distance_pc) as avg_distance_pc FROM Galaxies WHERE type = 'Elliptical' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE content (content_id INT, content_type VARCHAR(20), country VARCHAR(50), hours_produced FLOAT, production_date DATE); INSERT INTO content VALUES (1, 'news', 'India', 24, '2022-01-01');
How many hours of news content are produced in Asia per day?
SELECT SUM(hours_produced) FROM content WHERE country IN ('India', 'China', 'Japan') AND content_type = 'news' AND production_date = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects_europe (id INT, project_name VARCHAR(255), region VARCHAR(255), installed_capacity FLOAT); INSERT INTO renewable_energy_projects_europe (id, project_name, region, installed_capacity) VALUES (1, 'Solar Farm A', 'Europe', 50.0), (2, 'Wind Farm B', 'Europe', 100.0);
What is the maximum installed capacity (in MW) for renewable energy projects in 'Europe' region?
SELECT MAX(installed_capacity) FROM renewable_energy_projects_europe WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, founders TEXT, industry TEXT); INSERT INTO Companies (id, name, founders, industry) VALUES (1, 'HealFast', 'Female, African American', 'Healthcare'); INSERT INTO Companies (id, name, founders, industry) VALUES (2, 'TechBoost', 'Asian, Male', 'Technology'); CREATE TABLE Investment_Rounds (company_id INT, funding_amount INT, round_number INT); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (1, 800000, 1); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (1, 1200000, 2); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (2, 3000000, 1);
What is the maximum funding amount received by a company founded by a woman of color in the healthcare industry?
SELECT MAX(r.funding_amount) FROM Companies c JOIN Investment_Rounds r ON c.id = r.company_id WHERE c.founders LIKE '%Female%' AND c.founders LIKE '%African American%' AND c.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_month (month_id INT, month_name VARCHAR(255)); INSERT INTO arctic_month (month_id, month_name) VALUES (1, 'January'), (2, 'February'), (3, 'March'); CREATE TABLE sea_ice (year INT, month_id INT, extent FLOAT); INSERT INTO sea_ice (year, month_id, extent) VALUES (2000, 1, 14.5), (2000, 2, 13.2), (2000, 3, 12.9), (2001, 1, 15.1), (2001, 2, 13.6), (2001, 3, 12.5), (2002, 1, 14.3), (2002, 2, 12.8), (2002, 3, 12.1);
What is the average sea ice extent for each month in the Arctic?
SELECT month_id, AVG(extent) as avg_extent FROM sea_ice GROUP BY month_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1, 'Blue Whale', 'Vulnerable'); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (2, 'Dolphin', 'Least Concern');
Update the "conservation_status" column to "Endangered" for all records in the "marine_species" table where the "species_name" is "Blue Whale"
UPDATE marine_species SET conservation_status = 'Endangered' WHERE species_name = 'Blue Whale';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_research_grants (grant_id INT PRIMARY KEY, grant_name VARCHAR(100), grant_value INT, domain VARCHAR(50), recipient_country VARCHAR(50)); INSERT INTO ai_research_grants (grant_id, grant_name, grant_value, domain, recipient_country) VALUES (1, 'AI Safety Research', 500000, 'AI Safety', 'Germany'), (2, 'AI Fairness Research', 600000, 'Algorithmic Fairness', 'USA');
What is the total grant value for grants in the 'AI Safety' domain, grouped by recipient country and filtered for countries with a count of 4 or more grants?
SELECT recipient_country, SUM(grant_value) as total_grant_value FROM ai_research_grants WHERE domain = 'AI Safety' GROUP BY recipient_country HAVING COUNT(*) >= 4;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, donor_name, amount) VALUES (1, 'John Doe', 50.00), (2, 'Jane Smith', 75.00), (3, 'John Doe', 100.00);
List all donations made by a specific individual.
SELECT * FROM donations WHERE donor_name = 'John Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE FishFarming (FarmID INT, Location VARCHAR(50), Date DATE, Species VARCHAR(50));
Delete fish farming records with no species information?
DELETE FROM FishFarming WHERE Species IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_calls (call_id INT, call_date DATE, response_time INT); INSERT INTO disaster_calls (call_id, call_date, response_time) VALUES (1, '2022-01-01', 30), (2, '2022-02-03', 45);
What is the maximum response time for disaster calls?
SELECT MAX(response_time) FROM disaster_calls;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmTemperature (FarmID INT, Species VARCHAR(255), WaterTemp FLOAT); INSERT INTO FarmTemperature (FarmID, Species, WaterTemp) VALUES (1, 'Salmon', 12.3), (2, 'Salmon', 13.1), (3, 'Salmon', 11.9), (4, 'Salmon', 12.8);
Identify the farms with the highest and lowest water temperatures for Salmon.
SELECT FarmID, WaterTemp FROM FarmTemperature WHERE Species = 'Salmon' AND WaterTemp IN (SELECT MAX(WaterTemp), MIN(WaterTemp) FROM FarmTemperature WHERE Species = 'Salmon');
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Department VARCHAR(50), Publications INT, PublicationYear INT);
How many graduate students in the Chemistry department have not published any papers in the year 2020?
SELECT COUNT(StudentID) FROM GraduateStudents WHERE Department = 'Chemistry' AND Publications = 0 AND PublicationYear = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists ad (ad_id int, ad_country varchar(2), start_date date, end_date date, revenue decimal(10,2));
What is the total revenue from ads in the last month, broken down by the ad's country of origin?
SELECT ad_country, SUM(revenue) as total_revenue FROM ad WHERE start_date <= DATEADD(day, -30, GETDATE()) AND end_date >= DATEADD(day, -30, GETDATE()) GROUP BY ad_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Waste_Management (Waste_ID INT, Waste_Type VARCHAR(50), Tonnage DECIMAL(10,2), Year INT, Country VARCHAR(50));
What is the total tonnage of construction waste recycled in Australia in 2017?
SELECT SUM(Tonnage) FROM Waste_Management WHERE Waste_Type = 'Construction Waste' AND Year = 2017 AND Country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE diagnoses (id INT, patient_id INT, code VARCHAR(10), ethnicity VARCHAR(50)); INSERT INTO diagnoses (id, patient_id, code, ethnicity) VALUES (1, 1, 'A01', 'Caucasian'), (2, 1, 'B01', 'Caucasian'), (3, 2, 'A01', 'African American'), (4, 3, 'C01', 'Hispanic');
What is the percentage of patients with a specific diagnosis code by ethnicity?
SELECT ethnicity, code, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM diagnoses WHERE code = 'A01') AS percentage FROM diagnoses WHERE code = 'A01' GROUP BY ethnicity;
gretelai_synthetic_text_to_sql
CREATE VIEW sales_data AS SELECT id, vehicle_type, avg_speed, sales FROM vehicle_sales WHERE sales > 20000;
What is the total number of electric and autonomous vehicles sold in 'sales_data' view?
SELECT SUM(sales) FROM sales_data WHERE vehicle_type LIKE '%electric%' OR vehicle_type LIKE '%autonomous%';
gretelai_synthetic_text_to_sql
CREATE TABLE Resilience_Metrics (Metric_ID INT, Project_ID INT, Metric_Name VARCHAR(50), Score INT, Metric_Date DATE); INSERT INTO Resilience_Metrics (Metric_ID, Project_ID, Metric_Name, Score, Metric_Date) VALUES (1, 1, 'Seismic Resistance', 8, '2021-03-01');
Update the seismic resistance score for a specific project
UPDATE Resilience_Metrics SET Score = 9 WHERE Project_ID = 1 AND Metric_Name = 'Seismic Resistance';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (mine_id INT, name TEXT, location TEXT, productivity FLOAT); INSERT INTO mines (mine_id, name, location, productivity) VALUES (1, 'ABC Mine', 'USA', 1200), (2, 'DEF Mine', 'USA', 800);
What is the minimum labor productivity for each mine located in the USA?
SELECT location, MIN(productivity) FROM mines GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50), num_papers INT); INSERT INTO graduate_students (id, name, department, num_papers) VALUES (1, 'Charlie', 'Computer Science', 4); INSERT INTO graduate_students (id, name, department, num_papers) VALUES (2, 'David', 'Physics', 6);
How many graduate students have published more than 5 papers in the Computer Science department?
SELECT COUNT(*) FROM graduate_students WHERE department = 'Computer Science' AND num_papers > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, hours INT); INSERT INTO volunteers (id, name, hours) VALUES (4, 'David', 125), (5, 'Eva', 150), (6, 'Frank', 200);
Who is the top volunteer by total hours in H1 2021?
SELECT name FROM volunteers ORDER BY hours DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE patients_treatments (patient_id INT, age INT, condition VARCHAR(20)); INSERT INTO patients_treatments (patient_id, age, condition) VALUES (1, 20, 'depression');
Find the earliest age of a patient treated for a mental health condition
SELECT MIN(age) FROM patients_treatments;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, country TEXT, number_of_farms INT); INSERT INTO organic_farms (id, country, number_of_farms) VALUES (1, 'United States', 15000), (2, 'Germany', 12000), (3, 'Australia', 8000);
Which country has the highest number of organic farms?
SELECT country, MAX(number_of_farms) FROM organic_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT); CREATE TABLE research_grants (grant_id INT, student_id INT, amount DECIMAL(10,2), date DATE, department TEXT);
What is the total number of research grants awarded to each department in the past year?
SELECT rg.department, SUM(rg.amount) FROM research_grants rg WHERE rg.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY rg.department;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistWorkshops (id INT, artist_name VARCHAR(255), region VARCHAR(255), workshops INT); INSERT INTO ArtistWorkshops (id, artist_name, region, workshops) VALUES (1, 'Artist A', 'North', 5), (2, 'Artist B', 'South', 3), (3, 'Artist C', 'North', 7), (4, 'Artist D', 'East', 2);
Which artists have conducted the most workshops by region?
SELECT region, artist_name, SUM(workshops) FROM ArtistWorkshops GROUP BY region, artist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (Id INT, Region VARCHAR(20), ReportDate DATE); INSERT INTO MentalHealthParity (Id, Region, ReportDate) VALUES (1, 'Southwest', '2020-01-01'), (2, 'Northeast', '2019-12-31'), (3, 'Southwest', '2020-06-15'), (4, 'Northeast', '2020-01-10'), (5, 'Southwest', '2020-06-15'), (6, 'Northeast', '2019-03-02'), (7, 'Southwest', '2020-02-20'), (8, 'Northwest', '2020-12-25'), (9, 'Northwest', '2020-02-28'), (10, 'Northwest', '2020-02-21');
What is the maximum number of mental health parity cases reported in the Northwest region in a single month?
SELECT DATE_FORMAT(ReportDate, '%Y-%m') as Month, COUNT(*) as CountOfCases FROM MentalHealthParity WHERE Region = 'Northwest' GROUP BY Month ORDER BY CountOfCases DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stocks (id INT, species TEXT, country TEXT, year INT, stock_weight INT); INSERT INTO fish_stocks (id, species, country, year, stock_weight) VALUES (1, 'Salmon', 'Norway', 2021, 150000), (2, 'Salmon', 'Chile', 2021, 120000), (3, 'Salmon', 'Norway', 2020, 140000), (4, 'Tuna', 'Japan', 2021, 180000), (5, 'Tuna', 'Philippines', 2021, 160000), (6, 'Tuna', 'Japan', 2020, 170000);
List the top 3 countries by fish stock in the past year, partitioned by species?
SELECT species, country, SUM(stock_weight) stock_weight FROM fish_stocks WHERE year = 2021 GROUP BY species, country ORDER BY stock_weight DESC FETCH FIRST 3 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtCollection (id INT, name VARCHAR(50), on_loan BOOLEAN); CREATE TABLE AncientArtifacts (id INT, name VARCHAR(50), on_loan BOOLEAN);
What is the total number of art pieces and artifacts in the 'ArtCollection' and 'AncientArtifacts' tables, excluding those that are on loan?
SELECT COUNT(*) FROM ArtCollection WHERE on_loan = FALSE UNION SELECT COUNT(*) FROM AncientArtifacts WHERE on_loan = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, country VARCHAR(50)); INSERT INTO Donations (donor_id, donation_amount, donation_date, country) VALUES (1, 500.00, '2021-09-01', 'USA'), (2, 300.00, '2021-07-15', 'Canada'), (3, 700.00, '2021-10-20', 'Mexico'), (4, 250.00, '2021-06-05', 'USA'), (5, 600.00, '2021-08-30', 'Canada');
Update the donation amount for donor_id 2 to $400.00
UPDATE Donations SET donation_amount = 400.00 WHERE donor_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, name VARCHAR(50), cost INT, launch_date DATE); INSERT INTO SpaceMissions (id, name, cost, launch_date) VALUES (1, 'Artemis I', 24000000000, '2022-08-29'); INSERT INTO SpaceMissions (id, name, cost, launch_date) VALUES (2, 'Artemis II', 35000000000, '2024-11-01');
Show the total cost of all space missions in the SpaceMissions table.
SELECT SUM(cost) FROM SpaceMissions;
gretelai_synthetic_text_to_sql
CREATE TABLE company_impact (id INT, name VARCHAR(255), sector VARCHAR(255), impact_measurement_score FLOAT); INSERT INTO company_impact (id, name, sector, impact_measurement_score) VALUES (1, 'Johnson & Johnson', 'Healthcare', 82.5), (2, 'Pfizer', 'Healthcare', 85.0), (3, 'Medtronic', 'Healthcare', 87.5);
What is the maximum impact measurement score for companies in the healthcare sector?
SELECT MAX(impact_measurement_score) FROM company_impact WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department_id INT, department_name VARCHAR(20)); INSERT INTO departments (department_id, department_name) VALUES (1, 'Computer Science'), (2, 'Mathematics'), (3, 'Physics'); CREATE TABLE research_grants (grant_id INT, title VARCHAR(50), amount DECIMAL(10,2), principal_investigator VARCHAR(50), department_id INT, start_date DATE, end_date DATE);
Create a view named "grant_totals_by_department" that shows the total amount of research grants awarded to each department
CREATE VIEW grant_totals_by_department AS SELECT d.department_name, SUM(r.amount) AS total_amount FROM departments d LEFT JOIN research_grants r ON d.department_id = r.department_id GROUP BY d.department_name;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_patents (patent_name VARCHAR(255), filing_country VARCHAR(255), startup BOOLEAN); INSERT INTO biosensor_patents (patent_name, filing_country, startup) VALUES ('BioPatent1', 'India', TRUE);
List all unique biosensor technology patents filed by startups from India or China.
SELECT DISTINCT patent_name FROM biosensor_patents WHERE filing_country IN ('India', 'China') AND startup = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Institutions (institution TEXT, country TEXT); INSERT INTO Institutions VALUES ('Institution-A', 'USA'), ('Institution-B', 'Canada'), ('Institution-C', 'USA'), ('Institution-D', 'Germany');
Which countries have the most AI safety research institutions?
SELECT country, COUNT(*) FROM Institutions GROUP BY country ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE PortCall (CallID INT, VesselID INT, PortID INT, CallDateTime DATETIME); INSERT INTO PortCall (CallID, VesselID, PortID, CallDateTime) VALUES (1, 1, 1, '2022-01-01 10:00:00'); INSERT INTO PortCall (CallID, VesselID, PortID, CallDateTime) VALUES (2, 1, 2, '2022-01-03 14:00:00');
Identify the previous port of call for each vessel.
SELECT VesselID, PortID, LAG(PortID) OVER (PARTITION BY VesselID ORDER BY CallDateTime) as PreviousPort FROM PortCall;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, content TEXT, category VARCHAR(50)); INSERT INTO posts (id, user_id, content, category) VALUES (1, 1, 'I love football', 'sports'), (2, 1, 'Basketball game tonight', 'sports'), (3, 2, 'Reading a book', 'literature');
What is the total number of posts related to sports?
SELECT COUNT(*) FROM posts WHERE category = 'sports';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, species VARCHAR(50), population INT);INSERT INTO animal_population (id, species, population) VALUES (1, 'Tiger', 250), (2, 'Elephant', 500);
Which species has the highest population?
SELECT species, MAX(population) FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE parks (id INT, name VARCHAR(255), establish_date DATE); INSERT INTO parks (id, name, establish_date) VALUES (1, 'Park1', '2020-01-01'), (2, 'Park2', '2019-07-15'), (3, 'Park3', '2017-03-04');
How many parks were established in the last 3 years, and what are their names?
SELECT name FROM parks WHERE establish_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR)
gretelai_synthetic_text_to_sql
CREATE TABLE Agroecological_Farming (Farm_ID INT, Crop VARCHAR(20), Production INT, Year INT, Continent VARCHAR(20)); INSERT INTO Agroecological_Farming (Farm_ID, Crop, Production, Year, Continent) VALUES (401, 'Quinoa', 1200, 2017, 'Latin America'), (402, 'Quinoa', 1500, 2018, 'Latin America'), (403, 'Quinoa', 1800, 2019, 'Latin America'), (404, 'Quinoa', 1000, 2020, 'Latin America');
What is the total production of quinoa in agroecological farming in Latin America between 2017 and 2020?
SELECT SUM(Production) FROM Agroecological_Farming WHERE Crop = 'Quinoa' AND Continent = 'Latin America' AND Year BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE modes (mode_id INT, mode_name VARCHAR(255)); CREATE TABLE fares (fare_id INT, mode_id INT, fare_amount DECIMAL(5,2)); INSERT INTO modes VALUES (1, 'Bus'); INSERT INTO modes VALUES (2, 'Train'); INSERT INTO fares VALUES (1, 1, 2.50); INSERT INTO fares VALUES (2, 1, 3.00); INSERT INTO fares VALUES (3, 2, 1.75);
What is the average fare for each mode of transportation?
SELECT mode_name, AVG(fare_amount) as avg_fare FROM modes m JOIN fares f ON m.mode_id = f.mode_id GROUP BY m.mode_name;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_ticket_prices (tier_num INT, concert_name VARCHAR(255), tier_price INT);
What is the average ticket price for each tier in the 'concert_ticket_prices' table?
SELECT tier_num, AVG(tier_price) as avg_price FROM concert_ticket_prices GROUP BY tier_num;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (item_id INT, quantity INT, order_date DATE); INSERT INTO orders (item_id, quantity, order_date) VALUES (1, 20, '2021-01-01'), (2, 30, '2021-01-02');
What is the minimum quantity of vegetarian dishes sold in the Chicago region?
SELECT MIN(quantity) FROM orders JOIN menu ON orders.item_id = menu.item_id WHERE menu.dish_type = 'vegetarian' AND menu.region = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (item_code varchar(5), warehouse_id varchar(5), quantity int); INSERT INTO inventory (item_code, warehouse_id, quantity) VALUES ('B01', 'CDG', 400), ('B02', 'CDG', 500), ('B03', 'CDG', 600);
What is the total quantity of all items in warehouse 'CDG'?
SELECT SUM(quantity) FROM inventory WHERE warehouse_id = 'CDG';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, DonationDate DATE); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationDate) VALUES (1, 'John Doe', 50.00, '2021-01-01'); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationDate) VALUES (2, 'Jane Smith', 200.00, '2021-05-15');
What is the maximum donation amount in the year 2021?
SELECT MAX(DonationAmount) FROM Donors WHERE YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(id INT, sector VARCHAR(20), esg_score INT); INSERT INTO investments VALUES(1, 'Tech', 85), (2, 'Healthcare', 75), (3, 'Tech', 82);
Find the average ESG score for each sector, only showing sectors with more than 2 investments.
SELECT sector, AVG(esg_score) as avg_esg_score FROM investments GROUP BY sector HAVING COUNT(*) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(255), followers INT, country VARCHAR(255));
Update the number of followers for a user from Brazil
UPDATE users SET followers = followers + 100 WHERE username = 'user_brazil' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_treatment_methods (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO waste_treatment_methods (id, name, state) VALUES (1, 'Landfill', 'Texas'), (2, 'Incineration', 'Texas'), (3, 'Recycling', 'Texas'), (4, 'Composting', 'Texas'); CREATE TABLE co2_emissions (treatment_method_id INT, emissions INT, state VARCHAR(255)); INSERT INTO co2_emissions (treatment_method_id, emissions, state) VALUES (1, 100, 'Texas'), (1, 120, 'Texas'), (2, 80, 'Texas'), (2, 100, 'Texas'), (3, 60, 'Texas'), (3, 70, 'Texas');
What is the total CO2 emissions for the landfill waste treatment method in the state of Texas?
SELECT wtm.name as treatment_method, SUM(ce.emissions) as total_emissions FROM waste_treatment_methods wtm JOIN co2_emissions ce ON wtm.id = ce.treatment_method_id WHERE wtm.name = 'Landfill' AND wtm.state = 'Texas' GROUP BY wtm.name;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_2 (occupation VARCHAR(255), score INT); INSERT INTO financial_capability_2 (occupation, score) VALUES ('Doctor', 1400), ('Engineer', 1300), ('Teacher', 1200), ('Lawyer', 1500);
What is the average financial capability score for each occupation?
SELECT occupation, AVG(score) FROM financial_capability_2 GROUP BY occupation;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (name VARCHAR(255), location VARCHAR(255), salary FLOAT); INSERT INTO schools (name, location, salary) VALUES ('School A', 'Urban', 50000), ('School B', 'Urban', 55000), ('School C', 'Rural', 45000), ('School D', 'Rural', 40000);
What is the average salary of teachers in urban and rural areas?
SELECT s1.location, AVG(s1.salary) as avg_salary FROM schools s1 GROUP BY s1.location;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, quantity INT, price DECIMAL(5,2), country VARCHAR(50));
Calculate the total revenue for each category from the sales table
SELECT category, SUM(quantity * price) as total_revenue FROM sales JOIN garments ON sales.product_id = garments.id GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE police_department (id INT, city VARCHAR(255), response_time INT);
What is the average response time for police departments in each city in the state of New York?
SELECT city, AVG(response_time) as avg_response_time FROM police_department GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, Membership VARCHAR(20)); CREATE TABLE Steps (StepID INT, MemberID INT, Steps INT, Date DATE); INSERT INTO Members (MemberID, Name, Age, Membership) VALUES (1, 'John Doe', 35, 'Platinum'), (2, 'Jane Smith', 28, 'Gold'); INSERT INTO Steps (StepID, MemberID, Steps, Date) VALUES (1, 1, 8000, '2022-01-01'), (2, 1, 7000, '2022-01-02'), (3, 1, 9000, '2022-01-03'), (4, 2, 6000, '2022-01-01'), (5, 2, 6500, '2022-01-02'), (6, 2, 7000, '2022-01-03');
What is the average daily step count for all members with a Platinum membership?
SELECT AVG(Steps) FROM Members JOIN Steps ON Members.MemberID = Steps.MemberID WHERE Membership = 'Platinum';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (mine_id INT, name TEXT, location TEXT, productivity FLOAT); INSERT INTO mines (mine_id, name, location, productivity) VALUES (1, 'ABC Mine', 'USA', 1200), (2, 'DEF Mine', 'Canada', 1500);
What is the sum of labor productivity for each mine located in Canada?
SELECT location, SUM(productivity) FROM mines GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id int, num_employees int, country varchar(50), donation_date date); INSERT INTO organizations (org_id, num_employees, country, donation_date) VALUES (1, 200, 'South Africa', '2019-01-01'), (2, 50, 'South Africa', '2019-02-01'), (3, 150, 'South Africa', '2019-03-01');
What is the total amount donated by organizations with more than 100 employees in South Africa, in the year 2019?
SELECT SUM(donation_amount) FROM donations INNER JOIN organizations ON donations.org_id = organizations.org_id WHERE organizations.country = 'South Africa' AND YEAR(donation_date) = 2019 GROUP BY organizations.org_id HAVING num_employees > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselTypes (id INT PRIMARY KEY, type VARCHAR(255), max_weight INT, max_length FLOAT); CREATE TABLE Vessels (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), length FLOAT, weight INT);
What is the total weight of vessels for each type, and the average length of vessels for each type?
SELECT vt.type, SUM(v.weight) as total_weight, AVG(v.length) as avg_length FROM Vessels v INNER JOIN VesselTypes vt ON v.type = vt.type GROUP BY vt.type;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (id INT, name VARCHAR(50));
Delete all records from the equipment table that have a name starting with 'Obsolete'
DELETE FROM equipment WHERE name LIKE 'Obsolete%';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trial (id INT, trial_name VARCHAR(255), therapeutic_area VARCHAR(255), expenditure DECIMAL(10,2)); INSERT INTO clinical_trial (id, trial_name, therapeutic_area, expenditure) VALUES (1, 'Trial1', 'Cardiovascular', 1000000.00), (2, 'Trial2', 'Oncology', 1200000.00), (3, 'Trial3', 'Cardiovascular', 1500000.00), (4, 'Trial4', 'Neurology', 800000.00), (5, 'Trial5', 'Cardiovascular', 2000000.00);
What are the top 3 clinical trials by expenditure in the cardiovascular therapeutic area?
SELECT * FROM clinical_trial WHERE therapeutic_area = 'Cardiovascular' ORDER BY expenditure DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Genre varchar(50), Country varchar(50)); INSERT INTO Artists (ArtistID, ArtistName, Genre, Country) VALUES (1, 'Eminem', 'Hip Hop', 'United States'), (2, 'B.B. King', 'Blues', 'United States'), (3, 'Taylor Swift', 'Pop', 'United States'); CREATE TABLE StreamingData (StreamDate date, ArtistID int, Streams int); INSERT INTO StreamingData (StreamDate, ArtistID, Streams) VALUES ('2022-01-01', 1, 10000), ('2022-01-02', 2, 8000), ('2022-01-03', 3, 9000), ('2022-01-04', 1, 11000);
What is the total number of streams for hip hop artists in the United States?
SELECT SUM(Streams) as TotalStreams FROM Artists JOIN StreamingData ON Artists.ArtistID = StreamingData.ArtistID WHERE Artists.Genre = 'Hip Hop' AND Artists.Country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600);
What is the total number of hospitals by state?
SELECT state, COUNT(*) as total_hospitals FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE salesperson (id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE tickets (id INT, salesperson_id INT, quantity INT, city VARCHAR(50), price DECIMAL(5,2)); INSERT INTO salesperson (id, name, city) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'Los Angeles'); INSERT INTO tickets (id, salesperson_id, quantity, city, price) VALUES (1, 1, 50, 'New York', 100.00), (2, 1, 75, 'New York', 100.00), (3, 2, 30, 'Los Angeles', 75.00), (4, 2, 40, 'Los Angeles', 75.00);
Update the ticket prices for all salespeople in New York by 10%.
UPDATE tickets t SET price = t.price * 1.10 WHERE t.city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_address VARCHAR(42), contract_type VARCHAR(10), country VARCHAR(2)); INSERT INTO smart_contracts (contract_address, contract_type, country) VALUES ('0x1234567890123456789012345678901234567890', 'ERC721', 'US');
Update the "contract_address" field to "0x2234567890123456789012345678901234567890" for the record with "contract_type" as "ERC721" in the "smart_contracts" table
UPDATE smart_contracts SET contract_address = '0x2234567890123456789012345678901234567890' WHERE contract_type = 'ERC721';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, site_name VARCHAR(255)); INSERT INTO mining_sites (id, site_name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'); CREATE TABLE employees (id INT, site_id INT, first_name VARCHAR(255), last_name VARCHAR(255)); INSERT INTO employees (id, site_id, first_name, last_name) VALUES (1, 1, 'John', 'Doe'), (2, 1, 'Jane', 'Smith'), (3, 2, 'Mike', 'Johnson'), (4, 3, 'Sara', 'Lee');
What's the total number of employees for each mining site?
SELECT s.site_name, COUNT(e.id) as total_employees FROM mining_sites s INNER JOIN employees e ON s.id = e.site_id GROUP BY s.site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(20), fuel_type VARCHAR(20)); INSERT INTO vessels (id, name, fuel_type) VALUES (1, 'VesselA', 'Diesel'), (2, 'VesselB', 'LNG'), (3, 'VesselC', 'Diesel'), (4, 'VesselD', 'Hybrid');
What is the count of vessels for each fuel type?
SELECT fuel_type, COUNT(*) FROM vessels GROUP BY fuel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name VARCHAR(255), state VARCHAR(255)); INSERT INTO cities (city_id, city_name, state) VALUES (1, 'Sacramento', 'California'), (2, 'San Diego', 'California'); CREATE TABLE water_usage (usage_id INT, city_id INT, water_consumption INT); INSERT INTO water_usage (usage_id, city_id, water_consumption) VALUES (1, 1, 50000), (2, 2, 70000);
What is the total water consumption by each city in the state of California?
SELECT c.city_name, SUM(w.water_consumption) FROM cities c INNER JOIN water_usage w ON c.city_id = w.city_id WHERE c.state = 'California' GROUP BY c.city_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ride_sharing (service_id INT, fare FLOAT, city VARCHAR(50));
What is the minimum fare of ride-sharing services in Rome?
SELECT MIN(fare) FROM ride_sharing WHERE city = 'Rome';
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Hours (ID INT, Year INT, Pilot VARCHAR(50), Flight_Hours INT); INSERT INTO Flight_Hours (ID, Year, Pilot, Flight_Hours) VALUES (1, 2015, 'John Doe', 1000), (2, 2015, 'Jane Smith', 1200), (3, 2016, 'John Doe', 1100), (4, 2016, 'Jane Smith', 1300), (5, 2017, 'John Doe', 1200), (6, 2017, 'Jane Smith', 1400);
What is the minimum number of flight hours per pilot per year?
SELECT Pilot, MIN(Flight_Hours) FROM Flight_Hours GROUP BY Pilot;
gretelai_synthetic_text_to_sql
CREATE TABLE Destinations (destination_id INT, destination_name TEXT, country TEXT, awards INT); INSERT INTO Destinations (destination_id, destination_name, country, awards) VALUES (1, 'City A', 'Germany', 3), (2, 'City B', 'Switzerland', 5), (3, 'City C', 'France', 2);
Which destinations have the least hotel awards in Spain?
SELECT destination_name, country, awards, RANK() OVER (PARTITION BY country ORDER BY awards ASC) AS rank FROM Destinations WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (ID INT, BaseName VARCHAR(50), Country VARCHAR(50), Personnel INT); INSERT INTO MilitaryPersonnel (ID, BaseName, Country, Personnel) VALUES (1, 'Base1', 'North America', 500); INSERT INTO MilitaryPersonnel (ID, BaseName, Country, Personnel) VALUES (2, 'Base2', 'South America', 700);
What is the total number of military personnel in 'North America' and 'South America'?
SELECT SUM(Personnel) FROM MilitaryPersonnel WHERE Country IN ('North America', 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE vessel (id INT, name VARCHAR(50));CREATE TABLE cargo (id INT, vessel_id INT, weight INT, cargo_date DATE);
Which vessels have transported the most cargo in the past 6 months?
SELECT v.name, SUM(c.weight) as total_weight FROM vessel v JOIN cargo c ON v.id = c.vessel_id WHERE c.cargo_date >= DATE(NOW(), INTERVAL -6 MONTH) GROUP BY v.name ORDER BY total_weight DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, museum VARCHAR(30), price DECIMAL(5,2)); INSERT INTO Events (id, museum, price) VALUES (1, 'Louvre Museum', 50.00), (2, 'British Museum', 40.00), (3, 'Louvre Museum', 60.00);
What is the maximum ticket price for an event at the Louvre Museum?
SELECT MAX(price) FROM Events WHERE museum = 'Louvre Museum';
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents(StudentID INT, Department VARCHAR(255)); INSERT INTO GraduateStudents VALUES (1, 'Physics'); CREATE TABLE Publications(PublicationID INT, StudentID INT, Citations INT); INSERT INTO Publications VALUES (1, 1, 50);
Show the total number of citations for all publications by graduate students in the Physics department.
SELECT SUM(Publications.Citations) FROM GraduateStudents INNER JOIN Publications ON GraduateStudents.StudentID = Publications.StudentID WHERE GraduateStudents.Department = 'Physics';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, state VARCHAR(2)); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (12345, 'Auto', 50000, 'TX'); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (67890, 'Home', 300000, 'CA'); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (111213, 'Umbrella', 1000000, 'CA');
What is the policy type and coverage amount for policies with the lowest coverage amount?
SELECT policy_type, coverage_amount FROM policies WHERE coverage_amount = (SELECT MIN(coverage_amount) FROM policies);
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy (EmployeeID INT, Company VARCHAR(50), Region VARCHAR(50), Sector VARCHAR(50)); INSERT INTO RenewableEnergy (EmployeeID, Company, Region, Sector) VALUES (1, 'Company A', 'North America', 'Renewable Energy'), (2, 'Company B', 'South America', 'Renewable Energy'), (3, 'Company C', 'Europe', 'Renewable Energy');
What is the total number of employees in the renewable energy sector by region?
SELECT Region, COUNT(*) as TotalEmployees FROM RenewableEnergy WHERE Sector = 'Renewable Energy' GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE tours (tour_id INT, tour_name VARCHAR(50), country VARCHAR(50), tour_count INT);
List the number of tours offered in each country from the 'tours' table
SELECT country, SUM(tour_count) as total_tours FROM tours GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, organization_name TEXT, organization_city TEXT);CREATE TABLE donors (id INT, name TEXT, email TEXT, donor_city TEXT);CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE);
Which organizations received donations from donors located in a specific city, based on the 'donations', 'donors', and 'organizations' tables?
SELECT organizations.organization_name FROM organizations INNER JOIN donations ON organizations.id = donations.organization_id INNER JOIN donors ON donations.donor_id = donors.id WHERE donors.donor_city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, dispensary_id INT, quantity INT, month TEXT, year INT); INSERT INTO sales (id, dispensary_id, quantity, month, year) VALUES (1, 1, 25, 'August', 2022), (2, 2, 30, 'August', 2022); CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'New York'), (2, 'Dispensary B', 'New York');
Insert new sales records for NY dispensaries in August 2022 with random quantities between 10 and 50?
INSERT INTO sales (dispensary_id, quantity, month, year) SELECT d.id, FLOOR(RAND() * 41 + 10), 'August', 2022 FROM dispensaries d WHERE d.state = 'New York' AND NOT EXISTS (SELECT 1 FROM sales s WHERE s.dispensary_id = d.id AND s.month = 'August' AND s.year = 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (State VARCHAR(20), Coverage DECIMAL(5,2)); INSERT INTO MentalHealthParity (State, Coverage) VALUES ('California', 0.75), ('Texas', 0.82), ('New York', 0.91), ('Florida', 0.68), ('Illinois', 0.77);
Identify the top three states with the highest percentage of mental health parity coverage.
SELECT State, Coverage, RANK() OVER(ORDER BY Coverage DESC) as rnk FROM MentalHealthParity WHERE rnk <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE train_routes (route_id INT, city VARCHAR(50), num_stations INT); INSERT INTO train_routes (route_id, city, num_stations) VALUES (101, 'London', 10), (102, 'London', 8), (103, 'London', 12), (104, 'London', 14);
How many stations are on each train route in London?
SELECT route_id, city, num_stations FROM train_routes WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite_Table (id INT, satellite_name VARCHAR(100), country_launched VARCHAR(50));
List all the unique satellite names from the Satellite_Table.
SELECT DISTINCT SATELLITE_NAME FROM Satellite_Table;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, job_title VARCHAR(50), salary DECIMAL(10, 2)); CREATE TABLE Departments (id INT, employee_id INT, department_name VARCHAR(50));
Identify the job titles with the lowest average salaries
SELECT job_title, AVG(salary) AS avg_salary FROM Employees JOIN Departments ON Employees.id = Departments.employee_id GROUP BY job_title ORDER BY avg_salary ASC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT); CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY, Name VARCHAR(255), StartDate DATE, EndDate DATE, ArtworkCount INT); CREATE TABLE ExhibitionArtworks (ExhibitionID INT, ArtworkID INT);
How many exhibitions featured more than 50 artworks by artists from Egypt?
SELECT COUNT(Exhibitions.ExhibitionID) AS ExhibitionCount FROM Exhibitions INNER JOIN (SELECT ExhibitionID FROM ExhibitionArtworks GROUP BY ExhibitionID HAVING COUNT(*) > 50) AS Subquery ON Exhibitions.ExhibitionID = Subquery.ExhibitionID INNER JOIN Artists ON Exhibitions.ArtistID = Artists.ArtistID WHERE Artists.Nationality = 'Egyptian';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (did INT, district_name VARCHAR(255)); CREATE TABLE emergencies (eid INT, did INT, response_time INT);
What is the average response time for emergency calls by district?
SELECT d.district_name, AVG(e.response_time) FROM districts d INNER JOIN emergencies e ON d.did = e.did GROUP BY d.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE al_jazeera (article_id INT, title TEXT, content TEXT, publisher TEXT); INSERT INTO al_jazeera (article_id, title, content, publisher) VALUES (1, 'Article 1', 'Sports content', 'Al Jazeera'), (2, 'Article 2', 'Politics content', 'Al Jazeera');
List all the articles published by 'Al Jazeera' that are not related to sports.
SELECT * FROM al_jazeera WHERE content NOT LIKE '%sports%';
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2));
Determine the number of customers who have an account balance greater than the median balance for all accounts.
SELECT COUNT(DISTINCT customer_id) FROM accounts WHERE balance > PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY balance) OVER ();
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE production (id INT, strain_id INT, year INT, quantity INT); INSERT INTO strains (id, name, type) VALUES (1, 'Strawberry Cough', 'Sativa'); INSERT INTO production (id, strain_id, year, quantity) VALUES (1, 1, 2021, 1000);
What is the minimum production quantity of Sativa strains in Nevada in 2021?
SELECT MIN(production.quantity) FROM production JOIN strains ON production.strain_id = strains.id WHERE strains.type = 'Sativa' AND production.year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Amphibians (id INT, name VARCHAR(255), population INT, status VARCHAR(255));
Add a record for the 'Houston Toad' to the Amphibians table.
INSERT INTO Amphibians (id, name, population, status) VALUES (4, 'Houston Toad', 150, 'Vulnerable');
gretelai_synthetic_text_to_sql
CREATE TABLE electric_trains (train_id INT, route_id INT, departure_time TIMESTAMP, arrival_time TIMESTAMP, distance FLOAT); INSERT INTO electric_trains (train_id, route_id, departure_time, arrival_time, distance) VALUES (1, 301, '2022-01-01 06:00:00', '2022-01-01 07:00:00', 40.0), (2, 302, '2022-01-01 06:15:00', '2022-01-01 07:15:00', 45.0);
What is the total distance traveled by electric trains in Seoul during the morning commute?
SELECT SUM(distance) AS total_distance FROM electric_trains WHERE EXTRACT(HOUR FROM departure_time) BETWEEN 6 AND 8 AND route_id IN (301, 302, 303, 304)
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (id INT, city_name VARCHAR(255)); INSERT INTO Cities (id, city_name) VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE WasteData (city_id INT, waste_type VARCHAR(50), waste_generation INT, date DATE); INSERT INTO WasteData (city_id, waste_type, waste_generation, date) VALUES (1, 'plastic', 120, '2021-01-01'), (1, 'plastic', 150, '2021-01-02'), (2, 'plastic', 80, '2021-01-01'), (2, 'plastic', 100, '2021-01-02');
What is the average daily plastic waste generation in kilograms by each city?
SELECT Cities.city_name, AVG(WasteData.waste_generation / 1000.0) FROM Cities INNER JOIN WasteData ON Cities.id = WasteData.city_id AND WasteData.waste_type = 'plastic' GROUP BY Cities.city_name;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(255), age INT, program VARCHAR(255), gender VARCHAR(255)); INSERT INTO athletes (athlete_id, name, age, program, gender) VALUES (1, 'John Doe', 25, 'Wellbeing', 'Male'), (2, 'Jane Smith', 30, 'Fitness', 'Female'), (3, 'Alice Johnson', 35, 'Wellbeing', 'Female'), (4, 'Bob Brown', 40, 'Fitness', 'Male'), (5, 'Charlie Davis', 45, 'Fitness', 'Male'), (6, 'Diana White', 50, 'Fitness', 'Female'), (7, 'Eva Green', 55, 'Wellbeing', 'Female');
List the number of athletes enrolled in each program and the average age of athletes in the 'wellbeing' program, grouped by gender.
SELECT program, gender, COUNT(*), AVG(age) FROM athletes WHERE program = 'Wellbeing' GROUP BY program, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE playtimes_genres (user_id INT, game_id INT, playtime FLOAT, genre VARCHAR(50)); INSERT INTO playtimes_genres (user_id, game_id, playtime, genre) VALUES (1, 3, 60, 'Strategy'), (2, 3, 90, 'Strategy'), (3, 3, 75, 'Strategy'), (4, 3, 80, 'Strategy'), (5, 3, 70, 'Strategy'), (1, 1, 30, 'Action'), (2, 1, 45, 'Action'), (3, 2, 60, 'Adventure'), (4, 2, 75, 'Adventure'), (5, 2, 90, 'Adventure');
What is the average playtime for each genre in the 'gaming' database?
SELECT genre, AVG(playtime) as avg_playtime FROM playtimes_genres GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE field4 (date DATE, temperature FLOAT); INSERT INTO field4 (date, temperature) VALUES ('2021-10-01', 18.2), ('2021-10-02', 20.1), ('2021-10-03', 19.3);
What is the maximum temperature recorded in 'field4' for each day in the last month?
SELECT date, MAX(temperature) FROM field4 WHERE date >= (CURRENT_DATE - INTERVAL '30 days') GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(20), CustomerID INT, Country VARCHAR(20)); INSERT INTO Policy (PolicyID, PolicyType, CustomerID, Country) VALUES (1, 'Homeowners', 101, 'USA'), (2, 'Auto', 101, 'USA'), (3, 'Renters', 102, 'USA'), (4, 'Car', 103, 'USA'), (5, 'Homeowners', 104, 'USA');
Identify customers with both 'Homeowners' and 'Car' policies in the United States.
SELECT Policy.CustomerID FROM Policy INNER JOIN Policy AS P2 ON Policy.CustomerID = P2.CustomerID WHERE Policy.PolicyType = 'Homeowners' AND P2.PolicyType = 'Car' AND Policy.Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (project_id INT, project_name TEXT, state TEXT, efficiency_kwh FLOAT); INSERT INTO solar_projects (project_id, project_name, state, efficiency_kwh) VALUES (1, 'Solar Farm 1', 'California', 0.18), (2, 'Solar Farm 2', 'Nevada', 0.20), (3, 'Solar Farm 3', 'Arizona', 0.19);
List the top 3 most energy efficient states in terms of solar power (kWh/m2/day)?
SELECT state, AVG(efficiency_kwh) as avg_efficiency FROM solar_projects GROUP BY state ORDER BY avg_efficiency DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE security_team (id INT, member VARCHAR(255), incidents_resolved INT, incident_at DATETIME); CREATE VIEW incident_view AS SELECT member, SUM(incidents_resolved) as incidents_resolved FROM security_team GROUP BY member;
What is the total number of security incidents resolved by each member of the security team in the past year?
SELECT member, incidents_resolved FROM incident_view WHERE incident_at >= DATE_SUB(NOW(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT, name TEXT, location TEXT, funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'New York', 6000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (2, 'StartupB', 'California', 7000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (3, 'StartupC', 'New York', 5000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (4, 'StartupD', 'California', 8000000.00);
What is the average funding for biotech startups in New York?
SELECT AVG(funding) FROM biotech.startups WHERE location = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE software (id INT, name VARCHAR(255)); INSERT INTO software (id, name) VALUES (1, 'Product A'), (2, 'Product B'), (3, 'Product C'); CREATE TABLE vulnerabilities (id INT, software_id INT, severity VARCHAR(255)); INSERT INTO vulnerabilities (id, software_id, severity) VALUES (1, 1, 'High'), (2, 1, 'Medium'), (3, 2, 'High'), (4, 2, 'Low'), (5, 3, 'Medium');
List the top 3 most vulnerable software products by the number of high severity vulnerabilities.
SELECT software.name, COUNT(vulnerabilities.id) as high_severity_vulnerabilities FROM software LEFT JOIN vulnerabilities ON software.id = vulnerabilities.software_id WHERE vulnerabilities.severity = 'High' GROUP BY software.name ORDER BY high_severity_vulnerabilities DESC LIMIT 3;
gretelai_synthetic_text_to_sql