context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE strains (id INT, name VARCHAR(10), type VARCHAR(10), retail_price DECIMAL(5,2)); INSERT INTO strains (id, name, type, retail_price) VALUES (1, 'Ak-47', 'Sativa', 12.50), (2, 'Amnesia Haze', 'Sativa', 14.25), (3, 'Blue Dream', 'Hybrid', 13.75);
What is the average retail price per gram of Sativa strains sold in California dispensaries?
SELECT AVG(retail_price) FROM strains WHERE type = 'Sativa' AND name IN ('Ak-47', 'Amnesia Haze');
gretelai_synthetic_text_to_sql
CREATE TABLE material_inventory (material_id INT, material_name VARCHAR(255), quantity INT, is_sustainable BOOLEAN);
Retrieve the names and quantities of the top 5 most ordered sustainable materials in the 'EthicalFashion' database
SELECT material_name, quantity FROM material_inventory WHERE is_sustainable = TRUE ORDER BY quantity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE site_a (artifact_id INT, artifact_type VARCHAR(255)); INSERT INTO site_a (artifact_id, artifact_type) VALUES (1, 'Pottery'), (2, 'Tools'), (3, 'Tools'), (4, 'Tools'); CREATE TABLE site_b (artifact_id INT, artifact_type VARCHAR(255)); INSERT INTO site_b (artifact_id, artifact_type) VALUES (5, 'Pottery'), (6, 'Tools'), (7, 'Tools');
Which excavation sites have more than 3 tool artifacts?
SELECT context FROM (SELECT 'site_a' AS context, COUNT(*) as count FROM site_a WHERE artifact_type = 'Tools' UNION ALL SELECT 'site_b' AS context, COUNT(*) as count FROM site_b WHERE artifact_type = 'Tools') AS subquery WHERE count > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE r_and_d_projects (id INT, project_name VARCHAR(50), project_type VARCHAR(20), sales INT); INSERT INTO r_and_d_projects (id, project_name, project_type, sales) VALUES (1, 'Autonomous Driving', 'R&D', 2000000), (2, 'Electric Engine Development', 'R&D', 1500000), (3, 'Connected Car Technology', 'R&D', 1200000), (4, 'Infotainment System Upgrade', 'R&D', 800000), (5, 'Safety Feature Enhancement', 'R&D', 1000000);
Find the total sales for autonomous driving R&D projects
SELECT SUM(sales) as total_sales FROM r_and_d_projects WHERE project_type = 'R&D' AND project_name = 'Autonomous Driving';
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (launch_year INT, launch_cost INT);
Find the total cost of satellite deployments for each year.
SELECT launch_year, SUM(launch_cost) FROM SatelliteDeployments GROUP BY launch_year;
gretelai_synthetic_text_to_sql
CREATE TABLE authors (id INT, name VARCHAR(50), newspaper VARCHAR(50)); INSERT INTO authors (id, name, newspaper) VALUES (1, 'John Doe', 'The Times'); INSERT INTO authors (id, name, newspaper) VALUES (2, 'Jane Smith', 'The Guardian');
Update the newspaper for author with id 2 to 'The Washington Post'
UPDATE authors SET newspaper = 'The Washington Post' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT);
Insert a new patient 'John' with age 50 who received 'Mindfulness' as a record.
INSERT INTO patients (name, age, treatment) VALUES ('John', 50, 'Mindfulness');
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_waste (sector VARCHAR(255), waste INT); INSERT INTO industrial_water_waste (sector, waste) VALUES ('Agriculture', 1200), ('Manufacturing', 800), ('Mining', 400), ('Construction', 600); CREATE TABLE california_waste (year INT, sector VARCHAR(255), waste INT); INSERT INTO california_waste (year, sector, waste) VALUES (2020, 'Agriculture', 500), (2020, 'Manufacturing', 400), (2020, 'Mining', 200), (2020, 'Construction', 300);
What is the total water waste generated by the industrial sector in California in the year 2020?
SELECT i.sector, SUM(i.waste) as total_water_waste FROM industrial_water_waste i INNER JOIN california_waste c ON i.sector = c.sector WHERE c.year = 2020 GROUP BY i.sector;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Age INT, Salary FLOAT);
What is the total number of employees working in the 'Mining Operations' department and the 'Environmental Department'?
SELECT Department, COUNT(*) FROM Employees WHERE Department = 'Mining Operations' OR Department = 'Environmental Department' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE atlanta_community_policing (id INT, event_type TEXT, event_date DATE); INSERT INTO atlanta_community_policing (id, event_type, event_date) VALUES (1, 'Meeting', '2022-01-01'), (2, 'Workshop', '2022-02-01'), (3, 'Meeting', '2022-03-01');CREATE TABLE atlanta_community_policing_types (id INT, event_type TEXT); INSERT INTO atlanta_community_policing_types (id, event_type) VALUES (1, 'Meeting'), (2, 'Workshop');
What is the most common type of community policing event in Atlanta?
SELECT event_type, COUNT(*) as count FROM atlanta_community_policing GROUP BY event_type ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clinician_impact_data (id INT, clinician_id INT, patients_treated INT, cultural_competency_score INT); INSERT INTO clinician_impact_data (id, clinician_id, patients_treated, cultural_competency_score) VALUES (1, 1, 55, 80), (2, 2, 45, 90);
What is the average mental health parity score for clinicians who have treated at least 50 patients?
SELECT AVG(mental_health_parity_data.mental_health_parity_score) FROM mental_health_parity_data JOIN clinician_impact_data ON mental_health_parity_data.clinician_id = clinician_impact_data.clinician_id WHERE clinician_impact_data.patients_treated >= 50;
gretelai_synthetic_text_to_sql
CREATE TABLE K_Pop_Songs (title TEXT, year INTEGER, rating FLOAT); INSERT INTO K_Pop_Songs (title, year, rating) VALUES ('Song1', 2016, 7.5), ('Song2', 2017, 8.0), ('Song3', 2018, 8.5), ('Song4', 2019, 9.0), ('Song5', 2020, 9.2), ('Song6', 2021, 9.5);
What is the average rating of K-pop songs released in 2018?
SELECT AVG(rating) FROM K_Pop_Songs WHERE year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (chw_id INT, state VARCHAR(2), name VARCHAR(50), certification_date DATE);
Add new community health worker record for Florida
INSERT INTO community_health_workers (chw_id, state, name, certification_date) VALUES (456, 'FL', 'Rosa Gomez', '2023-01-05');
gretelai_synthetic_text_to_sql
CREATE TABLE Workshops (WorkshopID INT PRIMARY KEY, WorkshopName VARCHAR(100), HeritageSiteID INT, FOREIGN KEY (HeritageSiteID) REFERENCES HeritageSites(SiteID));
Insert a new record for a traditional workshop, 'Maasai Beadwork', in the Workshops table.
INSERT INTO Workshops (WorkshopID, WorkshopName, HeritageSiteID) VALUES (nextval('workshop_id_seq'), 'Maasai Beadwork', 10);
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, volunteer_id INT);CREATE TABLE volunteer_hours (id INT, volunteer_id INT, hours DECIMAL(3,1), hour_date DATE);CREATE TABLE countries (id INT, country_code CHAR(2), country_name TEXT);
List all volunteers, their countries, and the number of hours they have volunteered, joined with the 'volunteer_hours' and 'countries' tables?
SELECT volunteers.name, countries.country_name, SUM(volunteer_hours.hours) FROM volunteers INNER JOIN volunteer_hours ON volunteers.id = volunteer_hours.volunteer_id INNER JOIN countries ON volunteers.id = countries.id GROUP BY volunteers.name, countries.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE quarterly_production (id INT, field_name VARCHAR(50), quarter INT, qty FLOAT); INSERT INTO quarterly_production (id, field_name, quarter, qty) VALUES (1, 'Galkynysh', 1, 50000); INSERT INTO quarterly_production (id, field_name, quarter, qty) VALUES (2, 'Galkynysh', 2, 55000); INSERT INTO quarterly_production (id, field_name, quarter, qty) VALUES (3, 'Samotlor', 1, 60000); INSERT INTO quarterly_production (id, field_name, quarter, qty) VALUES (4, 'Samotlor', 2, 58000);
Calculate the production change for each field between Q1 and Q2 2019
SELECT a.field_name, (b.qty - a.qty) as q1_q2_change FROM quarterly_production a JOIN quarterly_production b ON a.field_name = b.field_name WHERE a.quarter = 1 AND b.quarter = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(20), EventDate DATE); INSERT INTO EsportsEvents (EventID, EventName, EventDate) VALUES (1, 'EventA', '2022-01-01'), (2, 'EventB', '2022-02-01'), (3, 'EventC', '2022-03-01');
What is the number of esports events by month for the current year?
SELECT EXTRACT(MONTH FROM EventDate) as Month, COUNT(EventID) as Count FROM EsportsEvents WHERE EventDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE movie (id INT, title VARCHAR(50), genre VARCHAR(20), viewers INT); INSERT INTO movie (id, title, genre, viewers) VALUES (1, 'Movie1', 'Action', 100000), (2, 'Movie2', 'Action', 150000), (3, 'Movie3', 'Comedy', 200000), (4, 'Movie4', 'Action', 250000), (5, 'Movie5', 'Comedy', 220000);
What's the total number of viewers for all Action and Comedy movies?
SELECT SUM(viewers) FROM movie WHERE genre IN ('Action', 'Comedy');
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, threat_actor VARCHAR(50), severity INT, timestamp TIMESTAMP); INSERT INTO vulnerabilities (id, threat_actor, severity, timestamp) VALUES (1, 'Lazarus Group', 8, '2022-04-01 10:00:00'), (2, 'APT29', 7, '2022-05-02 12:00:00');
What are the top 3 threat actors with the highest average severity of vulnerabilities in Q2 of 2022?
SELECT threat_actor, AVG(severity) as avg_severity FROM vulnerabilities WHERE timestamp >= '2022-04-01' AND timestamp < '2022-07-01' GROUP BY threat_actor ORDER BY avg_severity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (name TEXT, funding FLOAT); INSERT INTO startups (name, funding) VALUES ('StartupA', 5000000), ('StartupB', 0), ('StartupC', 6000000);
Which biotech startups have not received any funding?
SELECT name FROM startups WHERE funding = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, country VARCHAR(50), Gadolinium_sold FLOAT, revenue FLOAT, datetime DATETIME); INSERT INTO sales (id, country, Gadolinium_sold, revenue, datetime) VALUES (1, 'Germany', 250.0, 5000.0, '2021-01-01 10:00:00'), (2, 'France', 180.0, 3600.0, '2021-02-15 14:30:00'), (3, 'UK', 300.0, 6000.0, '2021-03-05 09:15:00');
What are the top 3 European countries by total revenue from sales of Gadolinium in 2021?
SELECT country, SUM(revenue) AS total_revenue FROM sales WHERE YEAR(datetime) = 2021 AND Gadolinium_sold IS NOT NULL AND country IN ('Germany', 'France', 'UK') GROUP BY country ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Cultivator A', 'Colorado'); INSERT INTO cultivators (id, name, state) VALUES (2, 'Cultivator B', 'Colorado'); CREATE TABLE strains (cultivator_id INT, name TEXT, year INT, potency INT, sales INT); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain X', 2021, 28, 500); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain Y', 2021, 30, 700); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (2, 'Strain Z', 2021, 25, 800);
What are the total sales and average potency for each strain produced by cultivators in Colorado in 2021?
SELECT s.name as strain_name, c.state as cultivator_state, SUM(s.sales) as total_sales, AVG(s.potency) as average_potency FROM strains s INNER JOIN cultivators c ON s.cultivator_id = c.id WHERE c.state = 'Colorado' AND s.year = 2021 GROUP BY s.name, c.state;
gretelai_synthetic_text_to_sql
CREATE TABLE underrepresented_communities (community_id INT, community_name VARCHAR(100)); CREATE TABLE entertainment_programs (program_id INT, program_name VARCHAR(100), air_date DATE); CREATE TABLE mentions (mention_id INT, program_id INT, community_id INT);
Which underrepresented communities were mentioned in entertainment programs in the last six months?
SELECT community_name FROM underrepresented_communities JOIN mentions ON underrepresented_communities.community_id = mentions.community_id JOIN entertainment_programs ON mentions.program_id = entertainment_programs.program_id WHERE air_date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling(cargo_id INT, cargo_type VARCHAR(50), weight FLOAT); CREATE TABLE regulatory_compliance(cargo_id INT, cargo_type VARCHAR(50), destination VARCHAR(50));
What is the total weight of all cargos in the cargo_handling table that have a destination starting with the letter 'A' in the regulatory_compliance table?
SELECT CH.weight FROM cargo_handling CH JOIN regulatory_compliance RC ON CH.cargo_id = RC.cargo_id WHERE LEFT(RC.destination, 1) = 'A';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle (type TEXT, CO2_emission FLOAT); INSERT INTO vehicle (type, CO2_emission) VALUES ('Car', 4.6), ('Truck', 12.2), ('Motorcycle', 2.3);
What is the average CO2 emission for each vehicle type?
SELECT type, AVG(CO2_emission) FROM vehicle GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE SCHEMA public_health_data; CREATE TABLE hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO public_health_data.hospitals (id, name, location, capacity) VALUES (1, 'Hospital A', 'City A', 200), (2, 'Hospital B', 'City B', 250), (3, 'Hospital C', 'City C', 180), (4, 'Hospital D', 'City D', 150), (5, 'Hospital E', 'City E', 220);
What is the average capacity of hospitals in 'public_health_data'?
SELECT AVG(capacity) FROM public_health_data.hospitals;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, depth FLOAT); INSERT INTO marine_protected_areas (name, location, depth) VALUES ('Ross Sea Marine Protected Area', 'Southern', 5500.0), ('Kerguelen Islands Plateau', 'Southern', 3000.0), ('South Georgia and South Sandwich Islands', 'Southern', 1000.0);
What is the maximum depth of marine protected areas in the Southern Ocean?
SELECT MAX(depth) FROM marine_protected_areas WHERE location = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicles (Type VARCHAR(50), Country VARCHAR(50), Count INT); INSERT INTO ElectricVehicles (Type, Country, Count) VALUES ('Compact', 'USA', 200000), ('SUV', 'USA', 150000), ('Sedan', 'USA', 100000);
What percentage of electric vehicles in the USA are compact cars?
SELECT (Count * 100.0 / (SELECT SUM(Count) FROM ElectricVehicles WHERE Country = 'USA')) FROM ElectricVehicles WHERE Type = 'Compact' AND Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE customer_data (id INT PRIMARY KEY, customer_id INT, wellbeing_score INT); CREATE TABLE financial_capability_loans (id INT PRIMARY KEY, customer_id INT, amount DECIMAL(10,2), date DATE); CREATE VIEW last_year_loans AS SELECT * FROM financial_capability_loans WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); CREATE VIEW high_scoring_customers AS SELECT customer_id FROM customer_data, last_year_loans WHERE customer_data.wellbeing_score > 80 AND customer_data.customer_id = last_year_loans.customer_id;
How many customers who took out a financial capability loan in the last year have a financial wellbeing score higher than 80?
SELECT COUNT(DISTINCT customer_id) FROM high_scoring_customers;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.funding (id INT, name VARCHAR(50), location VARCHAR(50), industry VARCHAR(50), funding DECIMAL(10, 2), funded_date DATE); INSERT INTO biotech.funding (id, name, location, industry, funding, funded_date) VALUES (1, 'FundingA', 'China', 'Biosensor Technology', 1500000, '2021-01-10'), (2, 'FundingB', 'Argentina', 'Bioprocess Engineering', 4500000, '2020-02-23'), (3, 'FundingC', 'Australia', 'Synthetic Biology', 5000000, '2019-09-01'), (4, 'FundingD', 'Nigeria', 'Biosensor Technology', 8000000, '2020-03-12'), (5, 'FundingE', 'Japan', 'Biosensor Technology', 7000000, '2019-11-28'), (6, 'FundingF', 'Russia', 'Biosensor Technology', 9000000, '2020-05-15');
What is the total funding for biosensor technology development, per quarter, for the past 2 years?
SELECT YEAR(funded_date) as year, QUARTER(funded_date) as quarter, SUM(funding) as total_funding FROM biotech.funding WHERE industry = 'Biosensor Technology' AND funded_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY YEAR(funded_date), QUARTER(funded_date);
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title VARCHAR(100), length FLOAT, genre VARCHAR(50)); CREATE VIEW song_lengths AS SELECT genre, AVG(length) as avg_length FROM songs GROUP BY genre;
What is the average length of the songs for each genre?
SELECT * FROM song_lengths;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (debris_id INT, debris_name VARCHAR(50), country VARCHAR(50), longitude FLOAT, latitude FLOAT, altitude FLOAT, time_in_orbit INT); INSERT INTO space_debris (debris_id, debris_name, country, longitude, latitude, altitude, time_in_orbit) VALUES (1, 'DEBris-1', 'Russia', 100.123456, 20.123456, 500, 2000), (2, 'DEBris-2', 'USA', -90.123456, 30.123456, 600, 1000), (3, 'DEBris-3', 'China', 80.123456, 40.123456, 700, 1500);
Which countries have the highest space debris density, in descending order?
SELECT country, AVG(altitude) AS avg_altitude, COUNT(*) OVER (PARTITION BY country ORDER BY AVG(altitude) DESC) AS debris_density FROM space_debris GROUP BY country ORDER BY AVG(altitude) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE CitizenComplaints (City VARCHAR(100), Complaint VARCHAR(100), Year INT); INSERT INTO CitizenComplaints (City, Complaint, Year) VALUES ('New York City', 'Traffic', 2020), ('Los Angeles', 'Traffic', 2020);
How many traffic complaints were received from citizens in New York City in the year 2020?
SELECT COUNT(*) FROM CitizenComplaints WHERE City = 'New York City' AND Complaint = 'Traffic' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(20)); INSERT INTO countries (id, name) VALUES (1, 'USA'); INSERT INTO countries (id, name) VALUES (2, 'China'); CREATE TABLE esports_tournaments (id INT, country_id INT, name VARCHAR(20)); INSERT INTO esports_tournaments (id, country_id, name) VALUES (1, 1, 'Dreamhack'); INSERT INTO esports_tournaments (id, country_id, name) VALUES (2, 1, 'ESL One'); INSERT INTO esports_tournaments (id, country_id, name) VALUES (3, 2, 'World Electronic Sports Games');
Which countries have the most esports tournaments and what are their names?
SELECT countries.name, COUNT(esports_tournaments.id) AS tournament_count FROM countries INNER JOIN esports_tournaments ON countries.id = esports_tournaments.country_id GROUP BY countries.name ORDER BY tournament_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation_union (member_id INT, union_name VARCHAR(20)); INSERT INTO transportation_union (member_id, union_name) VALUES (1, 'Transportation Workers Union'), (2, 'Drivers Union'), (3, 'Mechanics Union'), (4, 'Transportation Workers Union');
What is the total number of members in the 'transportation_union' table?
SELECT COUNT(*) FROM transportation_union;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, location VARCHAR(20), initiative_name VARCHAR(50), completion_date DATE); INSERT INTO community_development (id, location, initiative_name, completion_date) VALUES (1, 'Rural', 'Road Expansion', '2020-05-15'), (2, 'Urban', 'Library Construction', '2021-08-27');
How many community development initiatives were completed in rural areas of Colombia in 2020?
SELECT COUNT(*) FROM community_development WHERE location = 'Rural' AND EXTRACT(YEAR FROM completion_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, location TEXT, funding_raised INT);
What is the average funding raised by startups in the Bay Area?
SELECT AVG(funding_raised) FROM startups WHERE location = 'Bay Area';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GameType VARCHAR(20)); INSERT INTO Players (PlayerID, Age, GameType) VALUES (1, 25, 'Racing'); INSERT INTO Players (PlayerID, Age, GameType) VALUES (2, 30, 'RPG');
Find the average age of players who play racing games
SELECT AVG(Age) FROM Players WHERE GameType = 'Racing';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, location) VALUES (1, 'John Doe', 35, 'Male', 'USA'); INSERT INTO farmers (id, name, age, gender, location) VALUES (2, 'Jane Smith', 40, 'Female', 'Canada');
Show the names and ages of farmers in the 'farmers' table
SELECT name, age FROM farmers;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT, author VARCHAR(50), title VARCHAR(100), publication_date DATE, category VARCHAR(20)); INSERT INTO news_articles (article_id, author, title, publication_date, category) VALUES (1, 'John Doe', 'Article 1', '2022-01-01', 'Politics'), (2, 'Jane Smith', 'Article 2', '2022-01-02', 'Sports');
What is the number of unique authors who have published articles in each category from the 'news_articles' table?
SELECT category, COUNT(DISTINCT author) as unique_authors FROM news_articles GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE system_status (system_id INT PRIMARY KEY, status_date DATE, is_online BOOLEAN); INSERT INTO system_status (system_id, status_date, is_online) VALUES (1, '2022-04-01', TRUE), (2, '2022-04-10', FALSE), (3, '2022-04-15', FALSE);
Which systems have been offline for more than a week?
SELECT system_id, status_date FROM system_status WHERE is_online = FALSE AND status_date < DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE detention_centers (id INT, name TEXT, state TEXT); INSERT INTO detention_centers (id, name, state) VALUES (1, 'Sacramento Juvenile Hall', 'California'); INSERT INTO detention_centers (id, name, state) VALUES (2, 'Los Angeles County Juvenile Hall', 'California'); CREATE TABLE offenders (id INT, name TEXT, detention_center_id INT, release_date DATE); INSERT INTO offenders (id, name, detention_center_id, release_date) VALUES (1, 'Jamal Davis', 1, '2021-06-01'); INSERT INTO offenders (id, name, detention_center_id, release_date) VALUES (2, 'Aaliyah Thompson', 2, '2022-01-10');
Which juvenile offenders were released early from detention centers in California?
SELECT name, detention_center_id, release_date FROM offenders WHERE detention_center_id IN (1, 2) AND release_date < DATE('now')
gretelai_synthetic_text_to_sql
CREATE TABLE CulturallyCompetentHealthcareProviders (ProviderID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Culture VARCHAR(50), Specialty VARCHAR(50)); INSERT INTO CulturallyCompetentHealthcareProviders (ProviderID, FirstName, LastName, Culture, Specialty) VALUES (1, 'Ali', 'Ahmed', 'Arabic', 'Pediatrics');
What are the total counts of CulturallyCompetentHealthcareProviders by Culture?
SELECT Culture, COUNT(*) as Total_Count FROM CulturallyCompetentHealthcareProviders GROUP BY Culture;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (user_id INT, transaction_amount DECIMAL(10, 2), transaction_date DATE, country VARCHAR(255)); INSERT INTO transactions (user_id, transaction_amount, transaction_date, country) VALUES (1, 50.00, '2022-01-01', 'Canada'), (2, 100.50, '2022-01-02', 'Canada'), (3, 200.00, '2022-01-03', 'Canada'), (4, 150.00, '2022-01-04', 'Canada');
List the top 3 users with the highest transaction amounts in Canada?
SELECT user_id, transaction_amount FROM (SELECT user_id, transaction_amount, ROW_NUMBER() OVER (ORDER BY transaction_amount DESC) as rank FROM transactions WHERE country = 'Canada') as ranked_transactions WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Project (project_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO Project (project_id, region, budget) VALUES (1, 'Southeast', 7000000.00), (2, 'Northwest', 3000000.00);
Which transportation projects in the Southeast have a budget over 5 million?
SELECT * FROM Project WHERE region = 'Southeast' AND budget > 5000000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist_id INT, city VARCHAR(50), country VARCHAR(50), revenue FLOAT); CREATE TABLE artists (id INT, name VARCHAR(50), genre VARCHAR(50)); INSERT INTO artists (id, name, genre) VALUES (1, 'The Beatles', 'Rock'), (2, 'Queen', 'Rock'), (3, 'Taylor Swift', 'Pop'), (4, 'BTS', 'K-Pop'); INSERT INTO concerts (id, artist_id, city, country, revenue) VALUES (1, 1, 'Los Angeles', 'USA', 500000), (2, 1, 'New York', 'USA', 700000), (3, 2, 'Seoul', 'South Korea', 800000), (4, 2, 'Tokyo', 'Japan', 900000), (5, 3, 'Paris', 'France', 1000000), (6, 4, 'Osaka', 'Japan', 850000), (7, 1, 'London', 'UK', 600000), (8, 4, 'Seoul', 'South Korea', 700000);
Who is the artist with the highest total revenue from concerts in 'Asia'?
SELECT a.name, SUM(c.revenue) as total_revenue FROM artists a JOIN concerts c ON a.id = c.artist_id WHERE c.country IN ('South Korea', 'Japan') GROUP BY a.name ORDER BY total_revenue DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(255), price DECIMAL(5,2));
Update the name of a menu item
UPDATE menu_items SET item_name = 'New Item Name' WHERE item_id = 123;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_projects (province VARCHAR(50), area VARCHAR(50), project_type VARCHAR(50), year INT, project_status VARCHAR(50));
Get the number of energy efficiency projects implemented in rural areas for each province in the energy_projects table.
SELECT province, COUNT(*) as num_rural_projects FROM energy_projects WHERE area = 'Rural' AND project_status = 'Implemented' GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_cases (id INT, case_id VARCHAR(50), location VARCHAR(50)); INSERT INTO infectious_disease_cases (id, case_id, location) VALUES (1, 'Case A', 'Urban Area A'); INSERT INTO infectious_disease_cases (id, case_id, location) VALUES (2, 'Case B', 'Rural Area B');
What is the number of infectious disease cases reported in urban and rural areas in the public health database?
SELECT location, COUNT(*) FROM infectious_disease_cases GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, GenderIdentity VARCHAR(20), HireYear INT); INSERT INTO Employees (EmployeeID, GenderIdentity, HireYear) VALUES (1, 'Male', 2019), (2, 'Female', 2020), (3, 'Non-binary', 2020), (4, 'Genderqueer', 2019), (5, 'Female', 2018);
What is the total number of employees who were hired in 2020 and identify as female or non-binary?
SELECT COUNT(*) FROM Employees WHERE HireYear = 2020 AND GenderIdentity IN ('Female', 'Non-binary');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitarySpending (Country VARCHAR(50), MilitarySpending DECIMAL(10,2)); INSERT INTO MilitarySpending (Country, MilitarySpending) VALUES ('United States', 700000000), ('China', 250000000), ('Russia', 65000000), ('India', 55000000), ('Germany', 45000000);
What is the average military spending by the top 5 countries in military innovation?
SELECT AVG(MilitarySpending) AS AvgSpending FROM (SELECT MilitarySpending FROM MilitarySpending ORDER BY MilitarySpending DESC LIMIT 5) AS Top5Spenders;
gretelai_synthetic_text_to_sql
CREATE TABLE Tournaments (Game VARCHAR(50), TournamentName VARCHAR(50), PrizePool INT); INSERT INTO Tournaments (Game, TournamentName, PrizePool) VALUES ('CS:GO', 'EL Major 2022', 500000); INSERT INTO Tournaments (Game, TournamentName, PrizePool) VALUES ('Dota 2', 'The International 2022', 40000000); INSERT INTO Tournaments (Game, TournamentName, PrizePool) VALUES ('Fortnite', 'World Cup 2022', 50000000);
List all tournaments with a prize pool greater than the average prize pool across all tournaments.
SELECT Tournaments.Game, Tournaments.TournamentName, Tournaments.PrizePool FROM Tournaments WHERE Tournaments.PrizePool > (SELECT AVG(Tournaments.PrizePool) FROM Tournaments);
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(255), publication_date DATE, author_id INT);
Insert a new article with the id 101, title "AI in Journalism", publication date 2022-12-01, and author id 20 into the "articles" table
INSERT INTO articles (article_id, title, publication_date, author_id) VALUES (101, 'AI in Journalism', '2022-12-01', 20);
gretelai_synthetic_text_to_sql
CREATE TABLE shark_depths (shark VARCHAR(255), min_depth FLOAT); INSERT INTO shark_depths (shark, min_depth) VALUES ('Blue Shark', 700.0), ('Thresher Shark', 300.0);
What is the minimum depth at which the Blue Shark is found?
SELECT min_depth FROM shark_depths WHERE shark = 'Blue Shark';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_projects (id INT, name VARCHAR(255), type VARCHAR(20), budget DECIMAL(10, 2)); INSERT INTO habitat_projects (id, name, type, budget) VALUES (1, 'Habitat Restoration', 'Forest', 50000), (2, 'Wildlife Corridors', 'Savannah', 75000), (3, 'Wetlands Conservation', 'Wetlands', 60000), (4, 'Forest Protection', 'Forest', 45000), (5, 'Savannah Conservation', 'Savannah', 80000), (6, 'Mangrove Preservation', 'Wetlands', 65000);
Display the total budget for each type of habitat preservation project
SELECT h.type, SUM(hp.budget) as total_budget FROM habitat_projects hp JOIN habitats h ON hp.type = h.type GROUP BY h.type;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, company_id INT, investment_value FLOAT); CREATE TABLE companies (id INT, name VARCHAR(255), ESG_rating INT, region VARCHAR(255)); INSERT INTO investments (id, company_id, investment_value) VALUES (1, 1, 500000), (2, 1, 1000000), (3, 2, 2000000); INSERT INTO companies (id, name, ESG_rating, region) VALUES (1, 'Aramco', 2, 'Middle East and North Africa'), (2, 'Oracle', 5, 'North America');
What is the total investment value in companies with a low ESG rating in the Middle East and North Africa?
SELECT SUM(investment_value) FROM investments i JOIN companies c ON i.company_id = c.id WHERE c.ESG_rating <= 4 AND c.region IN ('Middle East and North Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE Project_Timeline (id INT, region VARCHAR(20), project VARCHAR(30), phase VARCHAR(20), start_date DATE, end_date DATE, labor_cost FLOAT); INSERT INTO Project_Timeline (id, region, project, phase, start_date, end_date, labor_cost) VALUES (1, 'North', 'Green Tower', 'Planning', '2021-05-01', '2021-07-31', 50000.00), (2, 'West', 'Solar Park', 'Construction', '2021-08-01', '2022-05-31', 750000.00), (3, 'South', 'Wind Farm', 'Design', '2022-06-01', '2022-09-30', 33000.00);
What is the maximum labor cost for any project in the 'South' region?
SELECT MAX(labor_cost) FROM Project_Timeline WHERE region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (name VARCHAR(255), region VARCHAR(255)); INSERT INTO hospitals (name, region) VALUES ('Hospital A', 'Region 1'), ('Hospital B', 'Region 2');
What is the number of hospitals and their respective regions in the rural health database?
SELECT region, COUNT(name) FROM hospitals GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(id INT, startup_id INT, round_number INT, investment_amount INT); INSERT INTO investments VALUES (1, 1, 1, 1000000); INSERT INTO investments VALUES (2, 1, 2, 5000000); INSERT INTO investments VALUES (3, 2, 1, 2000000);
What is the total funding amount for startups founded by veterans in the renewable energy sector?
SELECT SUM(investment_amount) FROM investments JOIN startups ON investments.startup_id = startups.id WHERE startups.founder_identity = 'Veteran' AND startups.industry = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT, species TEXT, population INT); CREATE TABLE habitats (id INT, name TEXT, animal_id INT, size_km2 FLOAT); INSERT INTO animals (id, species, population) VALUES (1, 'Tiger', 1200), (2, 'Elephant', 1500), (3, 'Rhinoceros', 800); INSERT INTO habitats (id, name, animal_id, size_km2) VALUES (1, 'Habitat1', 1, 50.3), (2, 'Habitat2', 2, 32.1), (3, 'Habitat3', 2, 87.6), (4, 'Habitat4', 3, 22.5);
What is the average and total population of each animal species in protected habitats?
SELECT species, AVG(a.population) as avg_population, SUM(a.population) as total_population FROM animals a JOIN habitats h ON a.id = h.animal_id GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (sale_id INT, product_id INT, sale_date DATE, sale_revenue FLOAT); INSERT INTO SalesData (sale_id, product_id, sale_date, sale_revenue) VALUES (1, 1, '2022-01-02', 75), (2, 2, '2022-01-15', 30), (3, 3, '2022-01-28', 60), (4, 4, '2022-01-10', 120), (5, 5, '2022-01-22', 45);
Determine the percentage of sales revenue generated by products with a price point above $50, considering only sales from the past month.
SELECT (SUM(sale_revenue) / (SELECT SUM(sale_revenue) FROM SalesData WHERE sale_date >= DATEADD(month, -1, GETDATE()))) * 100 as revenue_percentage FROM SalesData WHERE product_id IN (SELECT product_id FROM Products WHERE price > 50) AND sale_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, ProgramID, DonationAmount) VALUES (1, 1, 1, 500.00); INSERT INTO Donations (DonationID, DonorID, ProgramID, DonationAmount) VALUES (2, 2, 2, 750.00);
List the top 5 donors who have contributed to both the Environment and Health programs?
SELECT DonorID, SUM(DonationAmount) AS TotalDonationAmount FROM Donations WHERE ProgramID IN (1, 2) GROUP BY DonorID ORDER BY TotalDonationAmount DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinic (id INT, name VARCHAR(50), specialty VARCHAR(50)); INSERT INTO rural_clinic (id, name, specialty) VALUES (1, 'John Doe', 'Cardiology'), (2, 'Jane Smith', 'Pediatrics'), (3, 'Michael Brown', 'Cardiology');
What is the total number of healthcare providers in the 'rural_clinic' table who are specialized in cardiology?
SELECT COUNT(*) FROM rural_clinic WHERE specialty = 'Cardiology';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), TrainingCompletion DATE);
Insert a new employee into the Employees table
INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, TrainingCompletion) VALUES (4, 'Jamal', 'Jackson', 'IT', '2022-03-20');
gretelai_synthetic_text_to_sql
CREATE TABLE investor (investor_id INT, name VARCHAR(255), country VARCHAR(255), impact_score FLOAT); INSERT INTO investor (investor_id, name, country, impact_score) VALUES (1, 'Acme Corp', 'Kenya', 85.5), (2, 'Beta Inc', 'Nigeria', 90.0); CREATE TABLE investment (investment_id INT, investor_id INT, strategy VARCHAR(255), impact_score FLOAT);
Which African countries do investors with the highest impact scores come from?
SELECT country, AVG(impact_score) as avg_impact_score FROM investor GROUP BY country ORDER BY avg_impact_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, donor_date DATE); INSERT INTO donors (id, donor_date) VALUES (1, '2021-01-01'), (2, '2021-01-15'), (3, '2021-03-30');
What is the total number of volunteers and donors?
SELECT (SELECT COUNT(*) FROM volunteers) + (SELECT COUNT(*) FROM donors) AS total;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_biodiversity (id INTEGER, species_name TEXT, biomass FLOAT);
What is the total biomass of each species in the 'arctic_biodiversity' table?
SELECT species_name, SUM(biomass) as total_biomass FROM arctic_biodiversity GROUP BY species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Disability_Policy_Advocacy (Department VARCHAR(20), Fiscal_Year INT, Budget DECIMAL(5,2)); INSERT INTO Disability_Policy_Advocacy VALUES ('DSS', 2021, 15000.00), ('DSS', 2022, 16000.00), ('EOP', 2021, 12000.00), ('EOP', 2022, 13000.00), ('HRS', 2021, 18000.00), ('HRS', 2022, 19000.00);
What is the total disability policy advocacy budget for each department in the last two fiscal years?
SELECT Department, Fiscal_Year, SUM(Budget) as Total_Budget FROM Disability_Policy_Advocacy WHERE Fiscal_Year IN (2021, 2022) GROUP BY Department, Fiscal_Year ORDER BY Fiscal_Year, Department;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableBites (menu_item VARCHAR(50), is_vegetarian BOOLEAN); INSERT INTO SustainableBites (menu_item, is_vegetarian) VALUES ('Lentil Soup', true), ('Grilled Cheese', true), ('Chicken Sandwich', false);
How many vegetarian options are available in the 'Sustainable Bites' menu?
SELECT COUNT(*) FROM SustainableBites WHERE is_vegetarian = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Quality_Control (id INT, chemical_name VARCHAR(255), date DATE, defects INT); INSERT INTO Quality_Control (id, chemical_name, date, defects) VALUES (1, 'Acetic Acid', '2022-01-02', 5); INSERT INTO Quality_Control (id, chemical_name, date, defects) VALUES (2, 'Nitric Acid', '2022-01-04', 3); INSERT INTO Quality_Control (id, chemical_name, date, defects) VALUES (3, 'Acetic Acid', '2022-01-05', 2);
What is the average number of defects per day for each chemical?
SELECT chemical_name, AVG(defects) as avg_defects FROM Quality_Control GROUP BY chemical_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Missions (Mission_Name VARCHAR(50), Astronaut_ID INT, Mission_Duration INT); INSERT INTO Space_Missions (Mission_Name, Astronaut_ID, Mission_Duration) VALUES ('Artemis I', 1, 25); INSERT INTO Space_Missions (Mission_Name, Astronaut_ID, Mission_Duration) VALUES ('Artemis II', 2, 300); INSERT INTO Space_Missions (Mission_Name, Astronaut_ID, Mission_Duration) VALUES ('Artemis III', 3, 365);
What are the total mission durations for each space mission?
SELECT Mission_Name, SUM(Mission_Duration) as Total_Mission_Duration FROM Space_Missions GROUP BY Mission_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255)); CREATE TABLE production (factory_id INT, quantity INT, product_type VARCHAR(255)); INSERT INTO factories (id, name) VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); INSERT INTO production (factory_id, quantity, product_type) VALUES (1, 500, 'Electronic Device'), (1, 800, 'Mechanical Component'), (2, 300, 'Electronic Device'), (3, 1000, 'Mechanical Component');
What is the total production output for each factory?
SELECT f.name, SUM(p.quantity) FROM factories f INNER JOIN production p ON f.id = p.factory_id GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (turbine_id INT, energy_production_before FLOAT, energy_production_after FLOAT); INSERT INTO wind_turbines (turbine_id, energy_production_before, energy_production_after) VALUES (1, 1.5, 2.3), (2, 2.0, 2.5), (3, 2.2, 2.8);
Determine the change in energy production for each wind turbine after installation.
SELECT turbine_id, (energy_production_after - energy_production_before) AS energy_production_change FROM wind_turbines
gretelai_synthetic_text_to_sql
CREATE TABLE flight_hours (airline VARCHAR(50), country VARCHAR(50), flight_hours INT, year INT); INSERT INTO flight_hours (airline, country, flight_hours, year) VALUES ('Korean Air', 'South Korea', 150000, 2019), ('Asiana Airlines', 'South Korea', 140000, 2019);
What is the maximum number of flight hours recorded by a commercial airline in South Korea in 2019?
SELECT MAX(flight_hours) FROM flight_hours WHERE country = 'South Korea' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (vendorID INT, vendorName VARCHAR(50), country VARCHAR(50), ethicalPractice BOOLEAN); CREATE TABLE Products (productID INT, vendorID INT, productName VARCHAR(50), price DECIMAL(10,2)); CREATE TABLE Sales (saleID INT, productID INT, saleDate DATE);
Who are the vendors in Africa with ethical labor practices and their total revenue from Q2 2022?
SELECT V.vendorName, SUM(P.price) FROM Vendors V INNER JOIN Products P ON V.vendorID = P.vendorID INNER JOIN Sales S ON P.productID = S.productID WHERE V.country = 'Africa' AND V.ethicalPractice = TRUE AND S.saleDate BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY V.vendorName;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, supporter INT, donation_date DATE); INSERT INTO donations (id, supporter, donation_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-01-02'), (3, 2, '2022-01-01'), (4, 3, '2022-01-03'), (5, 3, '2022-01-03');
What is the number of donations provided by each supporter on each day?
SELECT supporter, donation_date, COUNT(*) OVER (PARTITION BY supporter, donation_date) AS donations_per_day FROM donations;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (title VARCHAR(255), rating FLOAT, production_country VARCHAR(64));
What is the average rating of movies produced in the USA?
SELECT AVG(rating) FROM movies WHERE production_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE species_observations (species_id INT, station_id INT);
Find the number of unique species observed at each research station.
SELECT station_id, COUNT(DISTINCT species_id) AS unique_species_count FROM species_observations GROUP BY station_id;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists hydro_power_plants (plant_id integer, plant_name varchar(255), plant_location varchar(255), capacity_mw integer); INSERT INTO hydro_power_plants (plant_id, plant_name, plant_location, capacity_mw) VALUES (1, 'Plant A', 'France', 2000), (2, 'Plant B', 'Germany', 2500), (3, 'Plant C', 'Spain', 1500), (4, 'Plant D', 'Portugal', 1800);
What is the maximum capacity (in MW) of hydroelectric power plants in Europe, and which plant has the highest capacity?
SELECT plant_location, MAX(capacity_mw) as max_capacity FROM hydro_power_plants WHERE plant_location LIKE 'Europe%' GROUP BY plant_location;
gretelai_synthetic_text_to_sql
CREATE TABLE BuildingPermitsNY (id INT, city VARCHAR(20), year INT, permit_number VARCHAR(20)); INSERT INTO BuildingPermitsNY (id, city, year, permit_number) VALUES (1, 'New York', 2021, 'ABC123'), (2, 'New York', 2022, 'DEF456'), (3, 'New York', 2021, 'GHI789');
What is the total number of building permits issued in the city of New York in 2021 and 2022?
SELECT permit_number FROM BuildingPermitsNY WHERE city = 'New York' AND year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(255)); INSERT INTO Donors (donor_id, donor_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Jim Brown');
Who are the top 3 donors to 'Health' cause in '2022'?
SELECT Donor_name, SUM(donation_amount) as total_donated FROM Donations JOIN Donors ON Donations.donor_id = Donors.donor_id WHERE donation_date >= '2022-01-01' AND donation_date < '2023-01-01' AND cause = 'Health' GROUP BY Donor_name ORDER BY total_donated DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(20), material VARCHAR(20), year INT, recycled_quantity INT); INSERT INTO recycling_rates (city, material, year, recycled_quantity) VALUES ('Seattle', 'Plastic', 2020, 800), ('Seattle', 'Glass', 2020, 1200), ('Seattle', 'Paper', 2020, 1500), ('Seattle', 'Metal', 2020, 900);
Which materials were recycled the most in the city of Seattle in 2020?
SELECT MAX(recycled_quantity) AS max_recycled, material FROM recycling_rates WHERE city = 'Seattle' AND year = 2020 GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_scooters (scooter_id INT, trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, trip_distance FLOAT, city VARCHAR(50)); INSERT INTO shared_scooters (scooter_id, trip_id, trip_start_time, trip_end_time, trip_distance, city) VALUES (1, 1001, '2022-01-01 10:00:00', '2022-01-01 10:15:00', 5.3, 'Paris'), (2, 1002, '2022-01-01 11:00:00', '2022-01-01 11:45:00', 12.1, 'Paris');
What is the maximum trip distance for shared electric scooters in Paris?
SELECT MAX(trip_distance) FROM shared_scooters WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE); INSERT INTO members (member_id, name, gender, dob) VALUES (1, 'Leila Alvarez', 'Female', '2002-04-02'); INSERT INTO members (member_id, name, gender, dob) VALUES (2, 'Mohammed Ibrahim', 'Male', '2000-11-28'); CREATE TABLE workout_sessions (session_id INT, member_id INT, session_date DATE, duration INT); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (1, 1, '2023-02-02', 45); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (2, 1, '2023-02-05', 60); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (3, 2, '2023-02-07', 75); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (4, 1, '2023-02-13', 30);
What is the maximum duration of a single workout session for each member?
SELECT member_id, MAX(duration) AS max_duration FROM workout_sessions GROUP BY member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, name VARCHAR(255), continent VARCHAR(255), status VARCHAR(255)); INSERT INTO peacekeeping_operations (id, name, continent, status) VALUES (1, 'MINUSCA', 'Africa', 'inactive'), (2, 'MONUSCO', 'Africa', 'planning'), (3, 'UNMISS', 'Africa', 'active');
Update the 'status' column to 'completed' for all records in the 'peacekeeping_operations' table where 'name' is 'MONUSCO'
UPDATE peacekeeping_operations SET status = 'completed' WHERE name = 'MONUSCO';
gretelai_synthetic_text_to_sql
CREATE TABLE user_purchases (user_id INT, user_country VARCHAR(50), purchase_date DATE, purchase_amount DECIMAL(10, 2));
What is the total revenue earned from users in Japan who have made purchases on our platform between March 15 and March 31, 2022?
SELECT SUM(purchase_amount) FROM user_purchases WHERE user_country = 'Japan' AND purchase_date BETWEEN '2022-03-15' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_id INT, menu_name VARCHAR(20), is_vegetarian BOOLEAN); CREATE TABLE Menu_Orders (order_id INT, menu_id INT, order_date DATE); INSERT INTO Menu (menu_id, menu_name, is_vegetarian) VALUES (1, 'Breakfast', TRUE), (2, 'Lunch', FALSE), (3, 'Dinner', FALSE), (4, 'Vegetarian Platter', TRUE); INSERT INTO Menu_Orders (order_id, menu_id, order_date) VALUES (1, 1, '2022-03-01'), (2, 2, '2022-03-02'), (3, 4, '2022-03-03'), (4, 1, '2022-03-04'), (5, 3, '2022-03-05');
How many vegetarian menu items were sold in the month of March 2022?
SELECT COUNT(*) FROM Menu_Orders INNER JOIN Menu ON Menu_Orders.menu_id = Menu.menu_id WHERE Menu.is_vegetarian = TRUE AND MONTH(Menu_Orders.order_date) = 3 AND YEAR(Menu_Orders.order_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), type VARCHAR(50), CO2_emission_level FLOAT); CREATE TABLE handling (handling_id INT, vessel_id INT, port_id INT, handling_date DATE);
Identify vessels with a CO2 emission level above the average, for vessels that have handled cargo at the port of 'Rotterdam'.
SELECT v.vessel_name, v.CO2_emission_level FROM vessels v JOIN handling h ON v.vessel_id = h.vessel_id WHERE h.port_id = (SELECT port_id FROM ports WHERE port_name = 'Rotterdam') GROUP BY v.vessel_name, v.CO2_emission_level HAVING CO2_emission_level > (SELECT AVG(CO2_emission_level) FROM vessels);
gretelai_synthetic_text_to_sql
CREATE TABLE CONTAINER_FLEET (ID INT, Age INT, Type VARCHAR(20)); INSERT INTO CONTAINER_FLEET (ID, Age, Type) VALUES (1, 5, 'Dry'), (2, 3, 'Reefer'), (3, 7, 'Tank');
What is the average age of containers in the 'CONTAINER_FLEET' table?
SELECT AVG(Age) FROM CONTAINER_FLEET;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_safety (id INT, vessel_id INT, record_date DATE);
List all the vessels that have a safety record older than 10 years.
SELECT v.name FROM vessel_safety vs JOIN vessel v ON vs.vessel_id = v.id WHERE vs.record_date < DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS community_education (program_id INT, program_name VARCHAR(50), donation_count INT, donor_country VARCHAR(50)); INSERT INTO community_education (program_id, program_name, donation_count, donor_country) VALUES (1, 'Wildlife Conservation 101', 500, 'Canada'); INSERT INTO community_education (program_id, program_name, donation_count, donor_country) VALUES (2, 'Endangered Species Awareness', 300, 'Mexico'); INSERT INTO community_education (program_id, program_name, donation_count, donor_country) VALUES (3, 'Habitat Protection Techniques', 700, 'United States');
List the community education programs that have received donations from the 'United States'.
SELECT program_name FROM community_education WHERE donor_country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE DApps (id INT, name VARCHAR(100), network VARCHAR(50), status VARCHAR(50)); INSERT INTO DApps (id, name, network, status) VALUES (1, 'Uniswap', 'Ethereum', 'active'), (2, 'Sushiswap', 'Ethereum', 'inactive');
How many decentralized applications (dApps) are currently running on the Ethereum network?
SELECT COUNT(*) FROM DApps WHERE network = 'Ethereum' AND status = 'active';
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (id INT, city VARCHAR(50), state VARCHAR(50), account_balance DECIMAL(10,2)); CREATE TABLE customers (id INT, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(50));
Find the account with the highest balance for each city.
SELECT city, MAX(account_balance) as max_balance FROM accounts GROUP BY city; SELECT a.city, a.account_balance FROM accounts a JOIN (SELECT city, MAX(account_balance) as max_balance FROM accounts GROUP BY city) b ON a.city = b.city AND a.account_balance = b.max_balance;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (id INT, company_name VARCHAR(50), founder_name VARCHAR(50), year INT, industry VARCHAR(50));
List the top 3 industries with the highest number of female founders
SELECT industry, COUNT(*) AS num_companies FROM company_founding WHERE founder_name IN (SELECT name FROM founders WHERE gender = 'Female') GROUP BY industry ORDER BY num_companies DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, project_name VARCHAR(255), funding FLOAT, start_date DATE, county VARCHAR(50)); INSERT INTO agricultural_projects (id, project_name, funding, start_date, county) VALUES (1, 'Precision Farming', 120000.00, '2015-09-18', 'Kilifi'), (2, 'Crop Disease Detection', 180000.00, '2016-02-14', 'Kilifi'), (3, 'Sustainable Livestock', 150000.00, '2016-11-15', 'Kilifi');
What is the total funding for agricultural innovation projects in Kenya's Kilifi county that started between 2015 and 2016?
SELECT SUM(funding) FROM agricultural_projects WHERE county = 'Kilifi' AND start_date BETWEEN '2015-01-01' AND '2016-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE BlueCorpProjects(id INT, contractor VARCHAR(255), project VARCHAR(255), start_date DATE, end_date DATE);INSERT INTO BlueCorpProjects(id, contractor, project, start_date, end_date) VALUES (1, 'Blue Corp.', 'Aircraft Carrier Construction', '2018-01-01', '2020-12-31');
List the defense projects with timelines exceeding 18 months for 'Blue Corp.'.
SELECT project FROM BlueCorpProjects WHERE DATEDIFF(end_date, start_date) > 547 AND contractor = 'Blue Corp.';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(100), region VARCHAR(50), biomass FLOAT, classified BOOLEAN);
What is the total biomass of marine species in the Southern Ocean, excluding species that are not yet classified?
SELECT SUM(ms.biomass) as total_biomass FROM marine_species ms WHERE ms.region = 'Southern Ocean' AND ms.classified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Defense_Contracts (contract_id INT, company_name TEXT, state TEXT, award_amount FLOAT, quarter INT, year INT); INSERT INTO Defense_Contracts (contract_id, company_name, state, award_amount, quarter, year) VALUES (1, 'Texas Manufacturing Inc', 'Texas', 5000000, 1, 2020), (2, 'Austin Defense Systems', 'Texas', 3000000, 1, 2020);
What is the total value of defense contracts awarded to companies in Texas in Q1 2020?
SELECT SUM(award_amount) FROM Defense_Contracts WHERE state = 'Texas' AND quarter = 1 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farmers (id INT, name VARCHAR(50), location VARCHAR(50), crops VARCHAR(50)); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT); INSERT INTO urban_farmers VALUES (1, 'Jamal Johnson', 'New York', 'Tomatoes'); INSERT INTO crops VALUES (1, 'Tomatoes', 180);
Which urban farmer has the highest tomato yield in New York?
SELECT name FROM urban_farmers INNER JOIN crops ON urban_farmers.crops = crops.name WHERE crops.name = 'Tomatoes' AND crops.yield = (SELECT MAX(yield) FROM crops WHERE name = 'Tomatoes') AND urban_farmers.location = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (department VARCHAR(100), num_veterans INT, total_employees INT);
Which department has the lowest veteran employment rate?
SELECT department, (num_veterans/total_employees)*100 AS veteran_rate FROM veteran_employment ORDER BY veteran_rate LIMIT 1;
gretelai_synthetic_text_to_sql