context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE fairness_projects (id INT PRIMARY KEY, project_name VARCHAR(50), status VARCHAR(50)); INSERT INTO fairness_projects (id, project_name, status) VALUES (1, 'Bias Mitigation', 'Completed'), (2, 'Disparate Impact', 'In Progress'), (3, 'Explainability', 'Completed'), (4, 'Fairness Metrics', 'Completed'), (5, 'Transparency', 'Completed');
How many algorithmic fairness projects are completed?
SELECT COUNT(*) FROM fairness_projects WHERE status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE industries (id INT, industry VARCHAR(255), region VARCHAR(255)); INSERT INTO industries (id, industry, region) VALUES (1, 'Industry A', 'Southern'), (2, 'Industry B', 'Southern'), (3, 'Industry C', 'Northern'); CREATE TABLE violations (id INT, industry_id INT, violation_count INT, violation_date DATE); INSERT INTO violations (id, industry_id, violation_count, violation_date) VALUES (1, 1, 20, '2021-01-01'), (2, 1, 30, '2021-02-01'), (3, 2, 10, '2021-03-01'), (4, 3, 50, '2020-01-01');
How many labor rights violations were recorded for each industry in the Southern region in 2021?
SELECT i.industry, SUM(v.violation_count) as total_violations FROM industries i JOIN violations v ON i.id = v.industry_id WHERE i.region = 'Southern' AND YEAR(v.violation_date) = 2021 GROUP BY i.industry;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255), organic_certified INT); INSERT INTO suppliers (id, name, country, organic_certified) VALUES (1, 'Supplier 1', 'Germany', 1), (2, 'Supplier 2', 'France', 0), (3, 'Supplier 3', 'Italy', 1);
How many times has the organic certification been revoked for suppliers in the European Union?
SELECT COUNT(*) FROM suppliers WHERE organic_certified = 0 AND country LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (permit_id INT, permit_date DATE, permit_expiration DATE, state VARCHAR(20)); INSERT INTO Building_Permits (permit_id, permit_date, permit_expiration, state) VALUES (1, '2021-01-01', '2021-04-15', 'California'), (2, '2021-02-01', '2021-05-31', 'California'), (3, '2022-03-01', '2022-06-15', 'California');
What is the average permit duration in California for projects beginning in 2021?
SELECT AVG(DATEDIFF(permit_expiration, permit_date)) FROM Building_Permits WHERE state = 'California' AND permit_date >= '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, country VARCHAR(50), amount FLOAT);
Update the climate_finance table to reflect a new climate finance commitment of $10 million for a project in Fiji.
UPDATE climate_finance SET amount = amount + 10000000.00 WHERE country = 'Fiji';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, country_code CHAR(2)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE);
What is the percentage of transactions that were made by customers from the United States in Q1 2022?
SELECT 100.0 * SUM(CASE WHEN country_code = 'US' THEN 1 ELSE 0 END) / COUNT(*) FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicles (id INT, manufacturer VARCHAR(50), distance FLOAT, country VARCHAR(50)); INSERT INTO ElectricVehicles (id, manufacturer, distance, country) VALUES (1, 'ManufacturerA', 250.3, 'China'), (2, 'ManufacturerB', 300.5, 'China'), (3, 'ManufacturerC', 350.7, 'China'), (4, 'ManufacturerD', 400.8, 'China');
What is the maximum distance traveled by electric vehicles in China, grouped by manufacturer?
SELECT context.manufacturer, MAX(context.distance) FROM (SELECT * FROM ElectricVehicles WHERE ElectricVehicles.country = 'China') AS context GROUP BY context.manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE UrbanEfficiency (id INT, building_name TEXT, city TEXT, state TEXT, energy_efficiency_score INT);
What is the average energy efficiency score for buildings in 'UrbanEfficiency' table, by city?
SELECT city, AVG(energy_efficiency_score) FROM UrbanEfficiency GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (Id INT, Name VARCHAR(50), Age INT, Nationality VARCHAR(50)); INSERT INTO Members (Id, Name, Age, Nationality) VALUES (1, 'John Doe', 30, 'UK'), (2, 'Jane Smith', 25, 'Canada'); CREATE TABLE Workouts (Id INT, MemberId INT, WorkoutType VARCHAR(50), Duration INT, Date DATE); INSERT INTO Workouts (Id, MemberId, WorkoutType, Duration, Date) VALUES (1, 1, 'Cycling', 30, '2022-01-01'), (2, 2, 'Swimming', 60, '2022-01-02');
Find the average age of members who have done 'Cycling'?
SELECT AVG(m.Age) as AverageAge FROM Members m JOIN Workouts w ON m.Id = w.MemberId WHERE w.WorkoutType = 'Cycling';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT, safety_rating REAL); INSERT INTO vessels (id, name, type, safety_rating) VALUES (1, 'Fishing Vessel 1', 'Fishing', 8.8), (2, 'Cargo Ship 1', 'Cargo', 9.2);
What is the maximum safety rating in the 'vessels' table?
SELECT MAX(safety_rating) FROM vessels;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, assets_value FLOAT); INSERT INTO clients (client_id, name, assets_value) VALUES (1, 'John Doe', 150000.00), (2, 'Jane Smith', 220000.00);
What is the total assets value for each client as of 2022-01-01?
SELECT name, SUM(assets_value) as total_assets_value FROM clients WHERE DATE(assets_value_date) = '2022-01-01' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationProjects (ProjectID INT, Name VARCHAR(100), Budget DECIMAL(10,2), Year INT); INSERT INTO TransportationProjects (ProjectID, Name, Budget, Year) VALUES (1, 'Road Expansion', 5000000, 2020), (2, 'Bridge Construction', 8000000, 2019), (3, 'Traffic Light Installation', 200000, 2020);
What is the average budget of all transportation projects in the year 2020?
SELECT AVG(Budget) FROM TransportationProjects WHERE Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre_id INT, genre VARCHAR(255)); CREATE TABLE songs (song_id INT, song_name VARCHAR(255), genre_id INT, length FLOAT); CREATE VIEW song_length_per_genre AS SELECT genre_id, AVG(length) as avg_length FROM songs GROUP BY genre_id; CREATE VIEW genre_popularity AS SELECT genre_id, COUNT(song_id) as num_songs FROM songs GROUP BY genre_id ORDER BY num_songs DESC; CREATE VIEW final_result AS SELECT g.genre, sl.avg_length, g.num_songs, g.num_songs/SUM(g.num_songs) OVER () as popularity_ratio FROM song_length_per_genre sl JOIN genre_popularity g ON sl.genre_id = g.genre_id;
What is the average length of songs per genre, ranked by popularity?
SELECT genre, avg_length, popularity_ratio FROM final_result;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy_Limits (Policy_Type VARCHAR(20), Policy_Limit INT); INSERT INTO Policy_Limits (Policy_Type, Policy_Limit) VALUES ('Life', 25000), ('Health', 5000), ('Auto', 7500), ('Life', 30000), ('Health', 6000); CREATE TABLE Claim_Amounts (Policy_Type VARCHAR(20), Claim_Amount INT); INSERT INTO Claim_Amounts (Policy_Type, Claim_Amount) VALUES ('Life', 35000), ('Health', 7000), ('Auto', 10000), ('Life', 22000), ('Health', 5500);
Calculate the total number of policies for each insurance type where the policy limit is less than the average claim amount.
SELECT Policy_Type, COUNT(*) FROM Policy_Limits INNER JOIN Claim_Amounts ON Policy_Limits.Policy_Type = Claim_Amounts.Policy_Type WHERE Policy_Limits.Policy_Limit < AVG(Claim_Amounts.Claim_Amount) GROUP BY Policy_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE florida_rural_residents (resident_id INT, rural_area VARCHAR(255), visited_doctor BOOLEAN); INSERT INTO florida_rural_residents VALUES (1, 'Rural Area 1', true), (2, 'Rural Area 2', false);
What is the percentage of residents in rural areas of Florida who have visited a doctor in the past year?
SELECT (COUNT(*) FILTER (WHERE visited_doctor = true)) * 100.0 / COUNT(*) FROM florida_rural_residents WHERE rural_area IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName TEXT, FuelType TEXT, EngineStatus TEXT); INSERT INTO Vessels (VesselID, VesselName, FuelType, EngineStatus) VALUES (1, 'Sea Tiger', 'LNG', 'Operational'), (2, 'Ocean Wave', 'Diesel', NULL), (3, 'River Queen', 'LNG', 'Operational'), (4, 'Harbor Breeze', 'Diesel', 'Operational');
Delete records of vessels with missing engine status information.
DELETE FROM Vessels WHERE EngineStatus IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Submarines (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50), year INT); INSERT INTO Submarines (id, name, type, manufacturer, year) VALUES (1, 'Dory', 'Mini', 'Acme Inc.', 2015), (2, 'Nemo', 'Midget', 'SeaWorks', 2017), (3, 'Oceanic', 'Spy', 'OceanTech', 2018), (4, 'SeaStar', 'Mini', 'Acme Inc.', 2019);
Which manufacturer has built the most unique types of submarines?
SELECT manufacturer, COUNT(DISTINCT type) AS unique_types FROM Submarines GROUP BY manufacturer ORDER BY unique_types DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE prices (id INT, state VARCHAR(50), year INT, strain_type VARCHAR(50), price FLOAT); INSERT INTO prices (id, state, year, strain_type, price) VALUES (1, 'Washington', 2020, 'Sativa', 10.0), (2, 'Washington', 2020, 'Indica', 12.0), (3, 'Oregon', 2021, 'Hybrid', 11.5);
What was the minimum price per gram for Sativa strains in Washington in 2020?
SELECT MIN(price) FROM prices WHERE state = 'Washington' AND year = 2020 AND strain_type = 'Sativa';
gretelai_synthetic_text_to_sql
CREATE TABLE WorkHours (WorkHourID INT, SiteID INT, Year INT, Cause VARCHAR(255), Hours INT); INSERT INTO WorkHours (WorkHourID, SiteID, Year, Cause, Hours) VALUES (1, 1, 2020, 'Equipment Failure', 10), (2, 2, 2019, 'Human Error', 15), (3, 3, 2020, 'Equipment Failure', 20), (4, 1, 2020, 'Equipment Failure', 25);
What is the total number of work hours lost due to equipment failures at the mining sites in 2020?
SELECT SUM(Hours) FROM WorkHours WHERE Year = 2020 AND Cause = 'Equipment Failure';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, publication_date DATE);
How many articles were published in the articles table before and after the year 2010?
SELECT COUNT(*) FROM articles WHERE publication_date < '2010-01-01' UNION SELECT COUNT(*) FROM articles WHERE publication_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (Id INT, Name VARCHAR(50), Country VARCHAR(50)); INSERT INTO Manufacturers (Id, Name, Country) VALUES (1, 'Boeing', 'USA'), (2, 'Airbus', 'Europe'); CREATE TABLE Aircraft (Id INT, ManufacturerId INT, Model VARCHAR(50), ProductionYear INT); INSERT INTO Aircraft (Id, ManufacturerId, Model, ProductionYear) VALUES (1, 1, '737', 2020), (2, 1, '787', 2020), (3, 2, 'A320', 2020), (4, 2, 'A350', 2020);
What is the total number of aircraft manufactured by each company in 2020?
SELECT m.Name, COUNT(a.Id) as Total FROM Manufacturers m JOIN Aircraft a ON m.Id = a.ManufacturerId WHERE a.ProductionYear = 2020 GROUP BY m.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, international_calls BOOLEAN, region VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, international_calls, region) VALUES (1, TRUE, 'Southeast'), (2, FALSE, 'Northeast'), (3, FALSE, 'Southeast'), (4, TRUE, 'Northern'), (5, TRUE, 'Eastern'), (6, TRUE, 'Eastern');
What is the total number of mobile subscribers who have made international calls in the Eastern region?
SELECT COUNT(*) FROM mobile_subscribers WHERE international_calls = TRUE AND region = 'Eastern';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), category VARCHAR(255), sustainability_rating INT, monthly_revenue DECIMAL(10,2)); INSERT INTO restaurants (id, name, category, sustainability_rating, monthly_revenue) VALUES (1, 'Green Garden', 'Organic', 5, 25000), (2, 'Quick Bites', 'Fast Food', 2, 18000), (3, 'Healthy Bites', 'Organic', 4, 22000), (4, 'Farm Fresh', 'Farm to Table', 3, 19000), (5, 'Local Harvest', 'Organic', 5, 26000);
Determine the highest sustainability rating for each restaurant category.
SELECT category, MAX(sustainability_rating) FROM restaurants GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists music_schema;CREATE TABLE if not exists concerts (id INT, name VARCHAR, city VARCHAR, genre VARCHAR, revenue FLOAT);INSERT INTO concerts (id, name, city, genre, revenue) VALUES (1, 'Music Festival', 'New York', 'Pop', 50000.00), (2, 'Rock Concert', 'Chicago', 'Rock', 75000.00), (3, 'Jazz Festival', 'Los Angeles', 'Jazz', 125000.00), (4, 'Hip Hop Concert', 'Miami', 'Hip Hop', 60000.00), (5, 'Country Music Festival', 'Nashville', 'Country', 40000.00), (6, 'EDM Festival', 'Las Vegas', 'EDM', 80000.00), (7, 'Pop Concert', 'Los Angeles', 'Pop', 70000.00), (8, 'Rock Festival', 'Chicago', 'Rock', 65000.00), (9, 'Jazz Concert', 'Los Angeles', 'Jazz', 110000.00), (10, 'Hip Hop Festival', 'Miami', 'Hip Hop', 75000.00);
What is the total revenue for each genre, for genres that have more than 5 concerts, in descending order?
SELECT genre, SUM(revenue) as total_revenue FROM music_schema.concerts GROUP BY genre HAVING COUNT(*) > 5 ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), last_transaction_date DATE); INSERT INTO customers (customer_id, name, last_transaction_date) VALUES (1, 'John Doe', '2022-01-15'), (2, 'Jane Smith', NULL), (3, 'Bob Johnson', '2022-01-03');
What is the total number of customers who have made at least one transaction in the last month?
SELECT COUNT(DISTINCT customer_id) FROM customers WHERE last_transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE north_sea_oil_production (country VARCHAR(50), year INT, oil_production FLOAT, gas_production FLOAT); INSERT INTO north_sea_oil_production (country, year, oil_production, gas_production) VALUES ('UK', 2019, 70.5, 34.6), ('Norway', 2019, 124.6, 91.2), ('Denmark', 2019, 12.3, 4.8);
What are the total production figures for oil and gas in the North Sea, broken down by country?
SELECT country, SUM(oil_production) as total_oil_production, SUM(gas_production) as total_gas_production FROM north_sea_oil_production GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE LeadTimes (lead_time INT, supplier_id INT, product VARCHAR(255), lead_time_date DATE); INSERT INTO LeadTimes (lead_time, supplier_id, product, lead_time_date) VALUES (10, 1, 'Product A', '2021-01-01'); INSERT INTO LeadTimes (lead_time, supplier_id, product, lead_time_date) VALUES (15, 2, 'Product B', '2021-01-01'); INSERT INTO LeadTimes (lead_time, supplier_id, product, lead_time_date) VALUES (12, 1, 'Product A', '2021-02-01');
What is the average lead time for each product, for the past 6 months, by each supplier?
SELECT s.supplier_id, s.product, AVG(s.lead_time) as avg_lead_time FROM LeadTimes s WHERE s.lead_time_date BETWEEN DATE_SUB(NOW(), INTERVAL 6 MONTH) AND NOW() GROUP BY s.supplier_id, s.product;
gretelai_synthetic_text_to_sql
CREATE TABLE ManufacturingProcesses (ProcessID INT, ProcessName VARCHAR(50)); INSERT INTO ManufacturingProcesses (ProcessID, ProcessName) VALUES (1, 'ProcessA'), (2, 'ProcessB'), (3, 'ProcessC'); CREATE TABLE CO2Emissions (EmissionID INT, CO2Emission DECIMAL(5,2), ProcessID INT); INSERT INTO CO2Emissions (EmissionID, CO2Emission, ProcessID) VALUES (1, 50.50, 1), (2, 60.60, 1), (3, 70.70, 2), (4, 80.80, 2), (5, 90.90, 3), (6, 100.00, 3);
What is the total CO2 emission of each manufacturing process?
SELECT ProcessName, SUM(CO2Emission) as TotalCO2Emission FROM ManufacturingProcesses mp JOIN CO2Emissions ce ON mp.ProcessID = ce.ProcessID GROUP BY ProcessName;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, location TEXT); INSERT INTO organizations (id, name, location) VALUES (1, 'WFP', 'Kenya'), (2, 'UNHCR', 'Tanzania'), (3, 'Save the Children', 'Kenya');
How many unique organizations provided support in Kenya?
SELECT COUNT(DISTINCT name) FROM organizations WHERE location = 'Kenya';
gretelai_synthetic_text_to_sql
CREATE TABLE Factory (factory_id INT PRIMARY KEY, factory_country VARCHAR(50), product_id INT, FOREIGN KEY (product_id) REFERENCES Product(product_id)); CREATE TABLE Product (product_id INT PRIMARY KEY, product_name VARCHAR(50), is_ethically_sourced BOOLEAN);
List all factories that produce products that are ethically sourced in the 'Factory' table
SELECT DISTINCT Factory.factory_country FROM Factory INNER JOIN Product ON Factory.product_id = Product.product_id WHERE Product.is_ethically_sourced = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (facility_id INT, location TEXT, score INT); INSERT INTO mental_health_facilities (facility_id, location, score) VALUES (1, 'Urban', 80), (2, 'Rural', 75), (3, 'Suburban', 85);
What is the average health equity metric score for mental health facilities in suburban areas?
SELECT AVG(score) FROM mental_health_facilities WHERE location = 'Suburban';
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyIncidents (incident_id INT, incident_date DATE, region VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO SafetyIncidents (incident_id, incident_date, region, incident_type) VALUES (1, '2022-01-01', 'US', 'Algorithm Malfunction'), (2, '2022-01-10', 'Canada', 'Data Breach'), (3, '2022-01-15', 'US', 'System Failure'), (4, '2022-02-01', 'Canada', 'Algorithm Malfunction'), (5, '2022-02-15', 'US', 'Data Breach'), (6, '2022-03-01', 'Canada', 'System Failure');
Show the number of AI safety incidents that occurred before and after a specific date, partitioned by region.
SELECT region, COUNT(CASE WHEN incident_date < '2022-02-01' THEN 1 END) as incidents_before, COUNT(CASE WHEN incident_date >= '2022-02-01' THEN 1 END) as incidents_after FROM SafetyIncidents GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT);
Delete the record with id 3 from the 'animals' table
DELETE FROM animals WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE StrainRegulations (StrainName TEXT, MaximumTHCContent FLOAT); INSERT INTO StrainRegulations (StrainName, MaximumTHCContent) VALUES ('Purple Haze', 20.0), ('Blue Dream', 18.0), ('Sour Diesel', 19.0); CREATE TABLE StrainTesting (StrainName TEXT, THCContent FLOAT); INSERT INTO StrainTesting (StrainName, THCContent) VALUES ('Purple Haze', 22.0), ('Blue Dream', 17.5), ('Sour Diesel', 21.0);
Which strains are not compliant with regulatory limits for THC content?
SELECT StrainName FROM StrainTesting WHERE THCContent > (SELECT MaximumTHCContent FROM StrainRegulations WHERE StrainName = StrainTesting.StrainName);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Id INT, Name TEXT, Amount DECIMAL(10,2)); INSERT INTO Donors VALUES (1, 'Alice', 250.00), (2, 'Bob', 175.00);
What's the total amount donated by each donor, ordered by the most donated?
SELECT Name, SUM(Amount) as TotalDonated FROM Donors GROUP BY Name ORDER BY TotalDonated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE city (id INT, name VARCHAR(255), population INT, sustainable_projects INT); INSERT INTO city (id, name, population, sustainable_projects) VALUES (1, 'San Francisco', 884363, 450); INSERT INTO city (id, name, population, sustainable_projects) VALUES (2, 'Los Angeles', 4000000, 650); INSERT INTO city (id, name, population, sustainable_projects) VALUES (3, 'New York', 8500000, 1500); CREATE TABLE building (id INT, name VARCHAR(255), city_id INT, size FLOAT, is_green BOOLEAN); INSERT INTO building (id, name, city_id, size, is_green) VALUES (1, 'City Hall', 1, 12000.0, true); INSERT INTO building (id, name, city_id, size, is_green) VALUES (2, 'Library', 1, 8000.0, false); CREATE TABLE renewable_energy (id INT, building_id INT, type VARCHAR(255), capacity INT); INSERT INTO renewable_energy (id, building_id, type, capacity) VALUES (1, 1, 'Solar', 100); INSERT INTO renewable_energy (id, building_id, type, capacity) VALUES (2, 1, 'Wind', 50);
What is the maximum capacity of renewable energy sources in city 3?
SELECT MAX(capacity) as max_capacity FROM renewable_energy WHERE building_id IN (SELECT id FROM building WHERE city_id = 3);
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, Program TEXT);
Which program has the most volunteers?
SELECT Program, COUNT(*) AS Count FROM Volunteers GROUP BY Program ORDER BY Count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_programs (program_id INT, city VARCHAR(50), victims_served INT); INSERT INTO restorative_justice_programs (program_id, city, victims_served) VALUES (1, 'Los Angeles', 300), (2, 'New York', 400), (3, 'Houston', 550), (4, 'Miami', 600), (5, 'San Francisco', 700), (6, 'Chicago', 800);
Show the total number of restorative justice programs by city
SELECT city, COUNT(*) FROM restorative_justice_programs GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Property (id INT PRIMARY KEY, city_id INT, type VARCHAR(50), price INT); CREATE TABLE Sustainable_Building (id INT PRIMARY KEY, property_id INT, certification VARCHAR(50), year INT); CREATE VIEW Green_Certified_Properties AS SELECT * FROM Sustainable_Building WHERE certification IN ('LEED', 'BREEAM');
What are the green-certified properties in cities with populations over 1,000,000 and their certification years?
SELECT Property.city_id, Green_Certified_Properties.certification, Green_Certified_Properties.year FROM Property INNER JOIN Green_Certified_Properties ON Property.id = Green_Certified_Properties.property_id WHERE Property.type = 'Green Apartments' AND Property.city_id IN (SELECT id FROM City WHERE population > 1000000);
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (id INT, region VARCHAR(20), permit_number VARCHAR(20), project VARCHAR(30), quantity INT); INSERT INTO Building_Permits (id, region, permit_number, project, quantity) VALUES (1, 'North', 'GP001', 'Green Tower', 500), (2, 'West', 'GP002', 'Solar Park', 200), (3, 'East', 'GP003', 'Wind Farm', 800);
How many building permits were issued per region?
SELECT region, COUNT(permit_number) FROM Building_Permits GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, country VARCHAR(255), software_version VARCHAR(255), report_date DATE); INSERT INTO vulnerabilities (id, country, software_version, report_date) VALUES (1, 'USA', '1.0.0', '2022-01-01'); INSERT INTO vulnerabilities (id, country, software_version, report_date) VALUES (2, 'Canada', '2.0.0', '2022-01-05'); INSERT INTO vulnerabilities (id, country, software_version, report_date) VALUES (3, 'Mexico', '1.0.0', '2022-01-09');
Show the top 3 countries with the highest number of reported vulnerabilities in the last month, excluding any vulnerabilities related to software version 1.0.0.
SELECT country, COUNT(*) as total_vulnerabilities FROM vulnerabilities WHERE report_date >= DATEADD(month, -1, GETDATE()) AND software_version != '1.0.0' GROUP BY country ORDER BY total_vulnerabilities DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_taxis (taxi_id INT, in_operation BOOLEAN, city VARCHAR(50));
How many electric taxis are currently in operation in Berlin, Germany?
SELECT COUNT(*) FROM electric_taxis WHERE in_operation = TRUE AND city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE DispensarySales (dispensary_id INT, sale_revenue DECIMAL(10,2), sale_date DATE);
Find the dispensary with the highest total sales revenue in the third quarter of 2021.
SELECT dispensary_id, SUM(sale_revenue) as total_revenue FROM DispensarySales WHERE sale_date >= '2021-07-01' AND sale_date <= '2021-09-30' GROUP BY dispensary_id ORDER BY total_revenue DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_per_capita (region VARCHAR(50), year INT, per_capita_kg FLOAT); INSERT INTO waste_per_capita (region, year, per_capita_kg) VALUES ('Jakarta', 2021, 567.89);
What is the average waste generation per capita in kg for the region 'Jakarta' in 2021?
SELECT AVG(per_capita_kg) FROM waste_per_capita WHERE region = 'Jakarta' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(id INT, sector VARCHAR(20), esg_score INT); INSERT INTO investments VALUES(1, 'Agriculture', 90), (2, 'Healthcare', 75), (3, 'Agriculture', 87);
What is the maximum ESG score for the Agriculture sector?
SELECT MAX(esg_score) as max_esg_score FROM investments WHERE sector = 'Agriculture';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_type VARCHAR(10)); INSERT INTO cases (case_id, case_type) VALUES (1, 'civil'), (2, 'criminal');
Delete all records from the "cases" table where the case type is 'civil'
DELETE FROM cases WHERE case_type = 'civil';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (restaurant VARCHAR(255), state VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO Revenue (restaurant, state, revenue) VALUES ('Bistro Veggie', 'California', 35000), ('Pizza House', 'New York', 50000), ('Vegan Delight', 'California', 40000);
Show revenue for restaurants located in 'California' and 'Texas' from the 'Revenue' table, excluding records with a revenue greater than 40000.
SELECT revenue FROM Revenue WHERE state IN ('California', 'Texas') AND revenue <= 40000;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_by_basin (id INT, species VARCHAR(255), basin VARCHAR(255)); INSERT INTO marine_species_by_basin (id, species, basin) VALUES (1, 'Species1', 'Atlantic'), (2, 'Species2', 'Pacific');
How many marine species are there in each ocean basin, in descending order?
SELECT basin, COUNT(*) as species_count FROM marine_species_by_basin GROUP BY basin ORDER BY species_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE epl_goals (player_name VARCHAR(50), goals INT, assists INT); INSERT INTO epl_goals (player_name, goals, assists) VALUES ('Alan Shearer', 260, 64), ('Wayne Rooney', 208, 103);
Who is the leading goal scorer in the history of the English Premier League?
SELECT player_name, SUM(goals) as total_goals FROM epl_goals GROUP BY player_name ORDER BY total_goals DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (PersonnelID INT, PersonnelName TEXT, Position TEXT, Salary INT); INSERT INTO MilitaryPersonnel (PersonnelID, PersonnelName, Position, Salary) VALUES (1, 'John Smith', 'General', 200000); INSERT INTO MilitaryPersonnel (PersonnelID, PersonnelName, Position, Salary) VALUES (2, 'Jane Doe', 'Colonel', 150000); INSERT INTO MilitaryPersonnel (PersonnelID, PersonnelName, Position, Salary) VALUES (3, 'Mike Johnson', 'Sergeant', 80000);
What is the name and position of the top 2 military personnel with the highest salaries?
SELECT PersonnelName, Position FROM MilitaryPersonnel ORDER BY Salary DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE movie_info (title VARCHAR(255), release_year INT, country VARCHAR(255)); INSERT INTO movie_info (title, release_year, country) VALUES ('The Matrix', 1999, 'USA'), ('Pulp Fiction', 1994, 'USA');
How many movies were released per year in the USA?
SELECT release_year, COUNT(*) FROM movie_info WHERE country = 'USA' GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learning (student_id INT, learning_score INT, date DATE); INSERT INTO lifelong_learning (student_id, learning_score, date) VALUES (1, 90, '2022-06-01'), (2, 95, '2022-06-02'), (3, 80, '2022-06-03');
What is the average lifelong learning score of students in 'Summer 2022'?
SELECT AVG(learning_score) FROM lifelong_learning WHERE date = '2022-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_price (year INT, price FLOAT); INSERT INTO carbon_price (year, price) VALUES (2015, 10.0), (2016, 12.5), (2017, 15.0), (2018, 17.5), (2019, 20.0), (2020, 22.5), (2021, 25.0), (2022, 27.5), (2023, 30.0), (2024, 32.5), (2025, 35.0);
Yearly change in carbon price from 2015 to 2025?
SELECT cp1.year + INTERVAL '1 year' AS year, (cp2.price - cp1.price) / cp1.price * 100.0 AS percentage_change FROM carbon_price cp1 JOIN carbon_price cp2 ON cp1.year + 1 = cp2.year;
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, state VARCHAR(2), safety_issues INT); INSERT INTO workplaces (id, state, safety_issues) VALUES (1, 'NY', 10), (2, 'CA', 5), (3, 'TX', 15), (4, 'FL', 8);
What is the maximum number of safety issues in a workplace for each state?
SELECT state, MAX(safety_issues) OVER (PARTITION BY state) AS max_safety_issues FROM workplaces;
gretelai_synthetic_text_to_sql
CREATE TABLE CopperMined (MineID INT, MineType VARCHAR(15), MinedDate DATE, CopperAmount INT);
What is the total amount of copper mined in the last quarter from the mines in the Andes?
SELECT SUM(CopperAmount) FROM CopperMined WHERE MineType = 'Copper' AND MinedDate >= DATEADD(quarter, DATEDIFF(quarter, 0, GETDATE()), 0);
gretelai_synthetic_text_to_sql
CREATE TABLE TropicalRainforest (id INT, species VARCHAR(255), diameter FLOAT, height FLOAT, volume FLOAT); INSERT INTO TropicalRainforest (id, species, diameter, height, volume) VALUES (1, 'RubberTree', 3.2, 45, 15.6); INSERT INTO TropicalRainforest (id, species, diameter, height, volume) VALUES (2, 'Mahogany', 4.5, 60, 30.8);
What is the total volume of trees in the 'TropicalRainforest' table?
SELECT SUM(volume) FROM TropicalRainforest;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(100), max_depth FLOAT, order_name VARCHAR(50), family VARCHAR(50));
What is the average depth for marine species in the Actinopterygii order, grouped by their family?
SELECT family, AVG(max_depth) FROM marine_species WHERE order_name = 'Actinopterygii' GROUP BY family;
gretelai_synthetic_text_to_sql
CREATE TABLE supplies (id INT, name TEXT, quantity INT, category TEXT, expiration_date DATE); INSERT INTO supplies (id, name, quantity, category, expiration_date) VALUES (1, 'Water', 500, 'Essential', '2023-05-01'); INSERT INTO supplies (id, name, quantity, category, expiration_date) VALUES (2, 'Tents', 100, 'Shelter', '2022-12-31');
What is the tier of each supply based on quantity, with 5 tiers?
SELECT *, NTILE(5) OVER (ORDER BY quantity DESC) as tier FROM supplies;
gretelai_synthetic_text_to_sql
CREATE TABLE Plants (id INT, name VARCHAR(255), circular_economy_rating DECIMAL(3, 2)); INSERT INTO Plants (id, name, circular_economy_rating) VALUES (4, 'Innovative Technologies', 4.2);
What is the circular economy rating of the 'Innovative Technologies' plant?
SELECT circular_economy_rating FROM Plants WHERE name = 'Innovative Technologies';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings ( id INT PRIMARY KEY, building_name VARCHAR(255), certification VARCHAR(255), certification_authority VARCHAR(255) ); INSERT INTO green_buildings (id, building_name, certification, certification_authority) VALUES (1, 'EcoCampus', 'LEED', 'USGBC'); INSERT INTO green_buildings (id, building_name, certification, certification_authority) VALUES (2, 'GreenApartments', 'BREEAM', 'BRE'); INSERT INTO green_buildings (id, building_name, certification, certification_authority) VALUES (3, 'EcoOffice', 'Green Star', 'GBCA');
Identify the Green building certification with the lowest certification authority count, along with the certification authority
SELECT certification, certification_authority FROM green_buildings GROUP BY certification, certification_authority HAVING COUNT(*) = (SELECT MIN(cert_count) FROM (SELECT certification_authority, COUNT(*) as cert_count FROM green_buildings GROUP BY certification_authority) t);
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cities (city_id INT, city VARCHAR(255)); INSERT INTO cities (city_id, city) VALUES (1, 'Rio de Janeiro'), (2, 'Sydney'), (3, 'Tokyo'); CREATE TABLE if not exists athletes (athlete_id INT, city_id INT, speed FLOAT); INSERT INTO athletes (athlete_id, city_id, speed) VALUES (1, 1, 1.2), (2, 2, 1.5), (3, 3, 1.3), (4, 1, 1.8), (5, 1, 2.0);
What is the maximum swimming speed achieved in a race by athletes in Rio de Janeiro?
SELECT MAX(speed) FROM athletes WHERE city_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle (vehicle_id INT, vehicle_type VARCHAR(20), last_maintenance_date DATE);
Show the number of maintenance requests for each public transportation vehicle type
SELECT vehicle_type, COUNT(*) AS maintenance_requests FROM vehicle WHERE last_maintenance_date < DATE(NOW()) - INTERVAL 30 DAY GROUP BY vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (HourID INT, VolunteerID INT, Hours DECIMAL(10,2), HourDate DATE);
How many hours did each volunteer contribute in the first quarter of 2024, including any partial hours?
SELECT V.Name, SUM(VH.Hours) as TotalHours FROM VolunteerHours VH JOIN Volunteers V ON VH.VolunteerID = Volunteers.VolunteerID WHERE VH.HourDate BETWEEN '2024-01-01' AND '2024-03-31' GROUP BY V.VolunteerID, V.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Purchases (PlayerID INT, PlayerName VARCHAR(50), Game VARCHAR(50), Purchase_amount DECIMAL(10,2)); CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Game VARCHAR(50), Country VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, Game, Country) VALUES (1, 'John Doe', 'Galactic Guardians', 'Egypt'); INSERT INTO Players (PlayerID, PlayerName, Game, Country) VALUES (2, 'Jane Smith', 'Galactic Guardians', 'South Africa'); INSERT INTO Purchases (PlayerID, PlayerName, Game, Purchase_amount) VALUES (1, 'John Doe', 'Galactic Guardians', 50.00); INSERT INTO Purchases (PlayerID, PlayerName, Game, Purchase_amount) VALUES (2, 'Jane Smith', 'Galactic Guardians', 75.00);
What is the average amount spent by players who have made a purchase in the game "Galactic Guardians" and are from Africa?
SELECT AVG(Purchase_amount) FROM Players INNER JOIN Purchases ON Players.PlayerID = Purchases.PlayerID WHERE Players.Game = 'Galactic Guardians' AND Players.Country LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE quarterly_arrivals (continent VARCHAR(255), year INT, quarter INT, arrivals INT); INSERT INTO quarterly_arrivals (continent, year, quarter, arrivals) VALUES ('Asia', 2021, 1, 4000000); INSERT INTO quarterly_arrivals (continent, year, quarter, arrivals) VALUES ('Asia', 2021, 2, 4500000); INSERT INTO quarterly_arrivals (continent, year, quarter, arrivals) VALUES ('Asia', 2020, 1, 3500000); INSERT INTO quarterly_arrivals (continent, year, quarter, arrivals) VALUES ('Asia', 2020, 2, 4000000);
What is the percentage change in international arrivals to each continent compared to the same quarter last year?
SELECT continent, year, quarter, arrivals, NTILE(4) OVER (ORDER BY arrivals) as quartile, (arrivals - LAG(arrivals) OVER (PARTITION BY continent ORDER BY year, quarter))*100.0 / LAG(arrivals) OVER (PARTITION BY continent ORDER BY year, quarter) as pct_change FROM quarterly_arrivals;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_inspections (id INT, restaurant_id INT, inspection_date DATE, score INT); INSERT INTO restaurant_inspections (id, restaurant_id, inspection_date, score) VALUES (1, 1, '2022-01-01', 95), (2, 1, '2022-03-15', 92), (3, 2, '2022-01-10', 88), (4, 2, '2022-02-20', 90), (5, 3, '2022-01-05', 98), (6, 3, '2022-03-22', 97); CREATE TABLE restaurants (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO restaurants (id, name, location) VALUES (1, 'Green Garden', 'NY'), (2, 'Quick Bites', 'CA'), (3, 'Healthy Bites', 'NY');
Calculate the average food safety score for restaurants located in NY.
SELECT AVG(score) FROM restaurant_inspections JOIN restaurants ON restaurant_inspections.restaurant_id = restaurants.id WHERE restaurants.location = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (initiative_id INT, state VARCHAR(20), initiative_year INT); INSERT INTO conservation_initiatives (initiative_id, state, initiative_year) VALUES (1, 'New York', 2015); INSERT INTO conservation_initiatives (initiative_id, state, initiative_year) VALUES (2, 'New York', 2016);
What is the number of water conservation initiatives implemented in the state of New York for each year since 2015?
SELECT initiative_year, COUNT(*) FROM conservation_initiatives WHERE state = 'New York' GROUP BY initiative_year;
gretelai_synthetic_text_to_sql
CREATE TABLE SouthAfrica (Age VARCHAR(50), TuberculosisCases INT); INSERT INTO SouthAfrica (Age, TuberculosisCases) VALUES ('0-4', 123), ('5-9', 234), ('10-14', 345), ('15-19', 456), ('20-24', 567), ('25-29', 678), ('30-34', 789), ('35-39', 890), ('40-44', 901), ('45-49', 1012), ('50-54', 1123), ('55-59', 1234), ('60-64', 1345), ('65-69', 1456), ('70-74', 1567), ('75-79', 1678), ('80-84', 1789), ('85-89', 1890), ('90-94', 1901), ('95-99', 2012), ('100-104', 2123);
What is the most common age group for tuberculosis cases in South Africa?
SELECT Age, TuberculosisCases FROM SouthAfrica ORDER BY TuberculosisCases DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (county VARCHAR(255), year INTEGER, num_permits INTEGER); INSERT INTO building_permits (county, year, num_permits) VALUES ('Los Angeles County', 2020, 12000), ('Los Angeles County', 2019, 11000), ('Orange County', 2020, 9000);
Find the number of building permits issued in Los Angeles County for 2020
SELECT SUM(num_permits) FROM building_permits WHERE county = 'Los Angeles County' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR(50), price INT); CREATE TABLE co_owners (property_id INT, owner_name VARCHAR(50)); INSERT INTO properties (id, city, price) VALUES (1, 'Vancouver', 800000), (2, 'Seattle', 400000); INSERT INTO co_owners (property_id, owner_name) VALUES (1, 'Greg'), (1, 'Harmony'), (2, 'Ivy');
List all the co-owned properties in Vancouver, BC and their owners.
SELECT properties.city, co_owners.owner_name FROM properties INNER JOIN co_owners ON properties.id = co_owners.property_id WHERE properties.city = 'Vancouver';
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (TransactionID INT, VisitorID INT, Amount DECIMAL(10,2));
What's the total revenue generated per visitor who attended the 'Ancient Civilization' exhibition?
SELECT AVG(t.Amount) FROM Transactions t JOIN Visitors v ON t.VisitorID = v.VisitorID JOIN Artworks a ON v.VisitorID = a.VisitorID JOIN Exhibitions e ON a.ExhibitionID = e.ExhibitionID WHERE e.ExhibitionName = 'Ancient Civilization';
gretelai_synthetic_text_to_sql
CREATE TABLE Support_Services (Student_ID INT, Student_Name TEXT, Service_Type TEXT); INSERT INTO Support_Services (Student_ID, Student_Name, Service_Type) VALUES (1, 'John Doe', 'Tutoring'), (2, 'Jane Smith', 'Sign Language Interpreting'), (3, 'Michael Brown', 'Tutoring');
What is the number of students who received each type of disability support service?
SELECT Service_Type, COUNT(*) FROM Support_Services GROUP BY Service_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE school_enrollment (school_id INT, student_count INT, school_type VARCHAR(10));
How many students are enrolled in each school type (public, private, or charter) in the 'school_enrollment' table?
SELECT school_type, SUM(student_count) FROM school_enrollment GROUP BY school_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Household_Water_Usage (ID INT, City VARCHAR(20), Consumption FLOAT); INSERT INTO Household_Water_Usage (ID, City, Consumption) VALUES (1, 'Seattle', 12.3), (2, 'Los Angeles', 15.6), (3, 'Seattle', 13.4);
What is the maximum water consumption recorded for any household in the city of Los Angeles?
SELECT MAX(Consumption) FROM Household_Water_Usage WHERE City = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists product (id INT PRIMARY KEY, name TEXT, brand_id INT, price DECIMAL(5,2)); INSERT INTO product (id, name, brand_id, price) VALUES (3, 'Luxury Moisturizing Cream', 1, 250.00);
What are the top 5 most expensive products?
SELECT name, price FROM product ORDER BY price DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (id INT, region VARCHAR(20), permit_number VARCHAR(20), project VARCHAR(30), is_sustainable BOOLEAN); INSERT INTO Building_Permits (id, region, permit_number, project, is_sustainable) VALUES (1, 'North', 'GP001', 'Green Tower', true), (2, 'West', 'GP002', 'Solar Park', false), (3, 'East', 'GP003', 'Wind Farm', true);
How many sustainable projects are there in each region?
SELECT region, COUNT(*) FROM Building_Permits WHERE is_sustainable = true GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(50), state VARCHAR(50), is_national_park BOOLEAN); INSERT INTO forests (id, name, state, is_national_park) VALUES (1, 'Yosemite National Park', 'California', true); CREATE TABLE carbon_sequestration (id INT, forest_id INT, year INT, sequestration FLOAT); INSERT INTO carbon_sequestration (id, forest_id, year, sequestration) VALUES (1, 1, 2019, 35000);
Find the total carbon sequestered in the year 2019 in California forests, excluding national parks.
SELECT SUM(cs.sequestration) FROM carbon_sequestration cs JOIN forests f ON cs.forest_id = f.id WHERE f.state = 'California' AND NOT f.is_national_park AND cs.year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics_sourced (id INT PRIMARY KEY, fabric_type VARCHAR(255), country VARCHAR(255), sustainability_rating INT);
Show average sustainability rating for each fabric type
SELECT fabric_type, AVG(sustainability_rating) FROM fabrics_sourced GROUP BY fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE RefugeeSupport (support_id INT, support_location VARCHAR(50), support_year INT, support_organization VARCHAR(50)); INSERT INTO RefugeeSupport (support_id, support_location, support_year, support_organization) VALUES (1, 'Germany', 2020, 'Non-Profit A'), (2, 'Canada', 2019, 'Non-Profit B'), (3, 'France', 2020, 'Government Agency C');
Which refugee support organizations provided assistance in Europe in 2020?
SELECT DISTINCT support_organization FROM RefugeeSupport WHERE support_location LIKE 'Europe%' AND support_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing(id INT, country VARCHAR(50), cost FLOAT); INSERT INTO SpacecraftManufacturing(id, country, cost) VALUES (1, 'France', 30000000), (2, 'Germany', 35000000), (3, 'France', 28000000), (4, 'UK', 40000000);
What is the second highest cost of a spacecraft manufactured in Europe?
SELECT cost FROM (SELECT cost FROM SpacecraftManufacturing WHERE country = 'France' ORDER BY cost DESC LIMIT 2) AS subquery ORDER BY cost LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (PermitID INT, IssueDate DATE, State CHAR(2)); INSERT INTO Permits (PermitID, IssueDate, State) VALUES (1, '2010-03-05', 'CA'), (2, '2011-06-18', 'NY'), (3, '2012-09-21', 'CA'); CREATE TABLE LaborHours (LaborHourID INT, PermitID INT, Hours DECIMAL(10,2)); INSERT INTO LaborHours (LaborHourID, PermitID, Hours) VALUES (1, 1, 250.00), (2, 1, 300.00), (3, 2, 150.00), (4, 3, 400.00);
What is the total number of construction labor hours spent on permits issued in California since 2010?
SELECT SUM(LaborHours.Hours) FROM LaborHours INNER JOIN Permits ON LaborHours.PermitID = Permits.PermitID WHERE Permits.State = 'CA' AND Permits.IssueDate >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE farm (farm_id INT, farm_name TEXT, region TEXT); INSERT INTO farm (farm_id, farm_name, region) VALUES (1, 'FarmA', 'region1'), (2, 'FarmB', 'region2'), (3, 'FarmC', 'region2'); CREATE TABLE crop_production (production_id INT, farm_id INT, crop_name TEXT, quantity INT); INSERT INTO crop_production (production_id, farm_id, crop_name, quantity) VALUES (1, 1, 'Corn', 500), (2, 1, 'Potatoes', 200), (3, 2, 'Corn', 700), (4, 2, 'Beans', 300), (5, 3, 'Carrots', 400); CREATE TABLE animal_rearing (rearing_id INT, farm_id INT, animal_type TEXT, quantity INT); INSERT INTO animal_rearing (rearing_id, farm_id, animal_type, quantity) VALUES (1, 1, 'Cattle', 10), (2, 1, 'Chickens', 50), (3, 2, 'Pigs', 20), (4, 3, 'Goats', 30);
What is the total quantity of crops and animals raised by each farmer in 'region2'?
SELECT f.farm_name, SUM(cp.quantity) as total_crops, SUM(ar.quantity) as total_animals FROM farm f LEFT JOIN crop_production cp ON f.farm_id = cp.farm_id LEFT JOIN animal_rearing ar ON f.farm_id = ar.farm_id WHERE f.region = 'region2' GROUP BY f.farm_name;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO manufacturers (id, name, country) VALUES (1, 'Manufacturer A', 'India'), (2, 'Manufacturer B', 'India'), (3, 'Manufacturer C', 'USA'); CREATE TABLE material_sourcing (id INT, manufacturer_id INT, sustainable_sourcing BOOLEAN); INSERT INTO material_sourcing (id, manufacturer_id, sustainable_sourcing) VALUES (1, 1, true), (2, 2, true), (3, 3, false); CREATE TABLE sales_volume (id INT, manufacturer_id INT, volume INT); INSERT INTO sales_volume (id, manufacturer_id, volume) VALUES (1, 1, 500), (2, 2, 250), (3, 3, 750);
What is the total sales volume for manufacturers in India who use sustainable materials?
SELECT m.name, SUM(SV.volume) as total_sales_volume FROM sales_volume SV JOIN manufacturers m ON SV.manufacturer_id = m.id JOIN material_sourcing MS ON m.id = MS.manufacturer_id WHERE m.country = 'India' AND MS.sustainable_sourcing = true GROUP BY m.name;
gretelai_synthetic_text_to_sql
CREATE TABLE user_demographics (user_id INT, age INT, gender VARCHAR(10), occupation VARCHAR(255)); INSERT INTO user_demographics (user_id, age, gender, occupation) VALUES (1, 35, 'male', 'software engineer');
Create a view to display the number of users by gender in the 'user_demographics' table
CREATE VIEW user_gender_counts AS SELECT gender, COUNT(*) as user_count FROM user_demographics GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE crypto_exchanges (exchange_name VARCHAR(50), exchange_location VARCHAR(50), year_founded INT, regulatory_status VARCHAR(20));
Insert a new record into the 'crypto_exchanges' table with 'exchange_name' 'Kraken', 'exchange_location' 'USA', and 'year_founded' 2011
INSERT INTO crypto_exchanges (exchange_name, exchange_location, year_founded, regulatory_status) VALUES ('Kraken', 'USA', 2011, 'Registered');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Site A', 'Country X'), (2, 'Site B', 'Country Y'), (3, 'Site C', 'Country Z');
Insert a new mining site named 'Site D' located in 'Country W' with no environmental impact score yet.
INSERT INTO mining_sites (site_id, site_name, location) VALUES (4, 'Site D', 'Country W');
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety_data (id INT, make VARCHAR(20), model VARCHAR(20), safety_rating DECIMAL(3,1)); INSERT INTO vehicle_safety_data (id, make, model, safety_rating) VALUES (1, 'Tesla', 'Model 3', 5.3), (2, 'Ford', 'Mustang Mach-E', 4.8), (3, 'Chevrolet', 'Bolt', 5.1);
What is the average safety rating for electric vehicles in the vehicle_safety_data table?
SELECT AVG(safety_rating) FROM vehicle_safety_data WHERE make IN ('Tesla', 'Ford', 'Chevrolet') AND model IN (SELECT DISTINCT model FROM vehicle_safety_data WHERE make IN ('Tesla', 'Ford', 'Chevrolet') AND is_electric = TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE Site (SiteID INT PRIMARY KEY, SiteName VARCHAR(50), Country VARCHAR(50), City VARCHAR(50)); INSERT INTO Site (SiteID, SiteName, Country, City) VALUES (7, 'Machu Picchu', 'Peru', 'Cuzco'); CREATE TABLE Artifact (ArtifactID INT PRIMARY KEY, SiteID INT, ArtifactName VARCHAR(50), Material VARCHAR(50), Era VARCHAR(50)); INSERT INTO Artifact (ArtifactID, SiteID, ArtifactName, Material, Era) VALUES (6, 2, 'Golden Mask', 'Gold', 'Inca'), (7, 7, 'Golden Idol', 'Gold', 'Inca');
How many artifacts are made of gold in Peru?
SELECT COUNT(*) FROM Artifact WHERE Material = 'Gold' AND SiteID = (SELECT SiteID FROM Site WHERE SiteName = 'Machu Picchu');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (id INT, actor_name VARCHAR(255), incident_time TIMESTAMP);
Who are the top 3 threat actors by the number of incidents in the last month?
SELECT actor_name, COUNT(*) as incident_count FROM threat_actors WHERE incident_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) GROUP BY actor_name ORDER BY incident_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditures (drug_name TEXT, half INT, year INT, expenditure FLOAT); INSERT INTO rd_expenditures (drug_name, half, year, expenditure) VALUES ('DrugC', 1, 2019, 6000000.0), ('DrugD', 2, 2019, 4000000.0);
List drugs with R&D expenditures over $5 million in H1 2019?
SELECT drug_name FROM rd_expenditures WHERE expenditure > 5000000 AND half = 1 AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (element VARCHAR(20), year INT, quantity FLOAT); INSERT INTO production_data (element, year, quantity) VALUES ('cerium', 2015, 3000), ('cerium', 2016, 3500), ('cerium', 2017, 4000), ('cerium', 2018, 4500), ('cerium', 2019, 5000), ('cerium', 2020, 5500), ('lanthanum', 2015, 2000), ('lanthanum', 2016, 2200), ('lanthanum', 2017, 2500), ('lanthanum', 2018, 2800), ('lanthanum', 2019, 3100), ('lanthanum', 2020, 3400), ('samarium', 2015, 1000), ('samarium', 2016, 1100), ('samarium', 2017, 1200), ('samarium', 2018, 1300), ('samarium', 2019, 1400), ('samarium', 2020, 1500);
What is the total production quantity (in metric tons) of cerium, lanthanum, and samarium in 2017 and 2018?
SELECT SUM(quantity) FROM production_data WHERE element IN ('cerium', 'lanthanum', 'samarium') AND year BETWEEN 2017 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, region VARCHAR(255), completed_on_time BOOLEAN); INSERT INTO projects (id, region, completed_on_time) VALUES (1, 'Africa', true), (2, 'Europe', false), (3, 'Africa', true);
What is the minimum number of defense projects in the African region that were completed on time?
SELECT MIN(id) as min_project_id FROM projects WHERE region = 'Africa' AND completed_on_time = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtWorks (ArtworkID int, Title varchar(100), YearCreated int, Country varchar(100));
How many artworks were created each year in France?
SELECT YearCreated, COUNT(ArtworkID) FROM ArtWorks
gretelai_synthetic_text_to_sql
CREATE TABLE Fabrics (fabric_id INT, fabric_type VARCHAR(25), is_sustainable BOOLEAN); INSERT INTO Fabrics (fabric_id, fabric_type, is_sustainable) VALUES (1, 'Cotton', true), (2, 'Polyester', false), (3, 'Hemp', true), (4, 'Silk', false), (5, 'Recycled Polyester', true);
count the total number of unique fabric types used in garment manufacturing for sustainable fabrics
SELECT COUNT(DISTINCT fabric_type) FROM Fabrics WHERE is_sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (ShipmentID int, CarrierID int, ShippedWeight int, ShippedDate datetime, ShippingMethod varchar(255));CREATE TABLE Carriers (CarrierID int, CarrierName varchar(255), Region varchar(255)); INSERT INTO Carriers (CarrierID, CarrierName, Region) VALUES (1, 'Carrier A', 'Europe'); INSERT INTO Shipments (ShipmentID, CarrierID, ShippedWeight, ShippedDate, ShippingMethod) VALUES (1, 1, 100, '2022-01-01', 'Air Freight');
Determine the total weight of shipments sent via air freight to each country in the Europe region in the past quarter.
SELECT s.ShippingMethod, w.Country, SUM(s.ShippedWeight) as TotalWeight FROM Shipments s INNER JOIN Carriers c ON s.CarrierID = c.CarrierID INNER JOIN Warehouses w ON s.WarehouseID = w.WarehouseID WHERE s.ShippingMethod = 'Air Freight' AND c.Region = 'Europe' AND s.ShippedDate >= DATEADD(quarter, -1, GETDATE()) GROUP BY s.ShippingMethod, w.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_animal_sightings (id INT, observer VARCHAR(255), animal VARCHAR(255)); INSERT INTO arctic_animal_sightings (id, observer, animal) VALUES (1, 'John', 'Polar Bear'), (2, 'Sarah', 'Walrus'), (3, 'John', 'Fox');
How many different animals were observed in the 'arctic_animal_sightings' table for each observer?
SELECT observer, COUNT(DISTINCT animal) AS animal_count FROM arctic_animal_sightings GROUP BY observer;
gretelai_synthetic_text_to_sql
CREATE TABLE city_feedback (city VARCHAR(255), feedback_id INT, feedback TEXT, response_time INT); INSERT INTO city_feedback
What is the average response time for citizen feedback in 'City F'?
SELECT AVG(response_time) FROM city_feedback WHERE city = 'City F'
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (HotelID INT, HotelName VARCHAR(50), SustainableCertifications INT, Continent VARCHAR(20)); INSERT INTO Hotels (HotelID, HotelName, SustainableCertifications, Continent) VALUES (1, 'GreenPalace', 3, 'South America'), (2, 'EcoLodge', 7, 'South America');
What is the minimum and maximum number of sustainable tourism certifications held by hotels in South America?
SELECT MIN(SustainableCertifications) as MinCertifications, MAX(SustainableCertifications) as MaxCertifications FROM Hotels WHERE Continent = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (id INT, region VARCHAR(255), year INT, co2_emission INT); INSERT INTO co2_emissions (id, region, year, co2_emission) VALUES (1, 'Africa', 2000, 400);
What is the maximum CO2 emission increase in Africa in any year since 2000, and what is the year in which it occurred?
SELECT region, MAX(co2_emission) AS max_co2, year FROM co2_emissions WHERE region = 'Africa' GROUP BY region, year HAVING max_co2 = (SELECT MAX(co2_emission) FROM co2_emissions WHERE region = 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition_Daily_Attendance (exhibition_id INT, visit_date DATE, visitor_count INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(50)); INSERT INTO Exhibitions (id, name) VALUES (1, 'Contemporary Art'); ALTER TABLE Exhibition_Daily_Attendance ADD FOREIGN KEY (exhibition_id) REFERENCES Exhibitions(id);
What is the average number of visitors per day for the 'Contemporary Art' exhibition in 2021?
SELECT AVG(visitor_count) FROM Exhibition_Daily_Attendance WHERE exhibition_id = 1 AND visit_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql