context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE ingredients (id INT, name VARCHAR(50), is_organic BOOLEAN, supplier_id INT, quantity INT); INSERT INTO ingredients (id, name, is_organic, supplier_id, quantity) VALUES (1, 'Tomatoes', TRUE, 101, 1200), (2, 'Cheese', FALSE, 102, 800), (3, 'Quinoa', TRUE, 103, 500); CREATE TABLE suppliers (id INT, name VARCH...
Find suppliers providing more than 1000 units of any organic ingredient
SELECT s.name, i.name, i.quantity FROM ingredients i INNER JOIN suppliers s ON i.supplier_id = s.id WHERE i.is_organic = TRUE GROUP BY s.name, i.name HAVING COUNT(*) > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT PRIMARY KEY, name VARCHAR(255), hectares DECIMAL(5,2), country VARCHAR(255)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Greenwood', 520.00, 'Canada'); CREATE TABLE Countries (code CHAR(2), name VARCHAR(255), population INT); INSERT INTO Countries (code, name, population)...
What is the name of the countries and the average hectares of forests?
SELECT Countries.name as country_name, AVG(Forests.hectares) as avg_hectares FROM Forests INNER JOIN Countries ON Forests.country = Countries.code GROUP BY Countries.name;
gretelai_synthetic_text_to_sql
CREATE TABLE network_failures (id INT PRIMARY KEY, tower_id INT, failure_type VARCHAR(255), failure_date DATE); CREATE TABLE network_investments (id INT PRIMARY KEY, tower_id INT, investment_amount FLOAT, investment_date DATE);
What is the number of network failures for each tower, grouped by month, and joined with the network investments table to show the total investment for each tower?
SELECT MONTH(f.failure_date) as month, i.tower_id, COUNT(f.id) as num_failures, SUM(i.investment_amount) as total_investment FROM network_failures f INNER JOIN network_investments i ON f.tower_id = i.tower_id GROUP BY month, i.tower_id;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, product TEXT); INSERT INTO mines (id, name, location, product) VALUES (1, 'Mammoth', 'Appalachia', 'Coal');
How many coal mines are there in the Appalachian region?
SELECT COUNT(*) FROM mines WHERE location = 'Appalachia' AND product = 'Coal';
gretelai_synthetic_text_to_sql
CREATE TABLE AnnualCropProduction (year INT, crop VARCHAR(20), quantity INT, price FLOAT);
What was the change in production of 'Potatoes' between 2015 and 2020 in 'AnnualCropProduction' table?
SELECT (SUM(CASE WHEN year = 2020 THEN quantity ELSE 0 END) - SUM(CASE WHEN year = 2015 THEN quantity ELSE 0 END)) as potato_production_change FROM AnnualCropProduction WHERE crop = 'Potatoes';
gretelai_synthetic_text_to_sql
CREATE TABLE gold_mine_production (mine_name VARCHAR(255), quantity INT); CREATE TABLE silver_mine_production (mine_name VARCHAR(255), quantity INT);
List the names of the mines that have either gold or silver production data, but not both.
SELECT mine_name FROM gold_mine_production GROUP BY mine_name HAVING COUNT(*) = 1 INTERSECT SELECT mine_name FROM silver_mine_production GROUP BY mine_name HAVING COUNT(*) = 0 UNION SELECT mine_name FROM gold_mine_production GROUP BY mine_name HAVING COUNT(*) = 0 INTERSECT SELECT mine_name FROM silver_mine_production G...
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_driving_research (id INT, make VARCHAR(50), model VARCHAR(50), autonomy_level INT);
What is the number of autonomous vehicles in the autonomous_driving_research table?
SELECT COUNT(*) FROM autonomous_driving_research WHERE autonomy_level > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(255), source_type VARCHAR(255), location VARCHAR(255), size FLOAT); INSERT INTO space_debris (id, name, source_type, location, size) VALUES (1, 'Defunct Satellite', 'Spacecraft', 'LEO', 5.0);
Find the average size of space debris in each location.
SELECT location, AVG(size) as avg_size FROM space_debris GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, section VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO ticket_sales (ticket_id, section, price, quantity) VALUES (1, 'Section A', 50.00, 25); INSERT INTO ticket_sales (ticket_id, section, price, quantity) VALUES (2, 'Section B', 40.00, 30);
What is the total revenue from ticket sales in 'Section A' in the 'ticket_sales' table?
SELECT SUM(price * quantity) FROM ticket_sales WHERE section = 'Section A';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE Donations (donation_id INT, donor_id INT, event_id INT); CREATE TABLE Events (event_id INT, name VARCHAR(255), date DATE);
How many events were attended by donors from 'CountryX'?
SELECT COUNT(*) FROM Donors D JOIN Donations DN ON D.donor_id = DN.donor_id JOIN Events E ON DN.event_id = E.event_id WHERE D.country = 'CountryX';
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), role VARCHAR(20)); INSERT INTO reporters (id, name, age, gender, role) VALUES (1, 'Sanaa Ahmed', 32, 'Female', 'Investigative Reporter'); INSERT INTO reporters (id, name, age, gender, role) VALUES (2, 'Hiroshi Tanaka', 45, 'Male', 'Senior Ed...
What are the names and roles of reporters who have worked on completed investigative projects?
SELECT r.name, r.role FROM reporters r JOIN investigative_projects ip ON r.id = ip.lead_investigator_id WHERE ip.status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, labor_productivity INT); INSERT INTO mine (id, name, location, labor_productivity) VALUES (1, 'Golden Gorge', 'CA', 120), (2, 'Silver Ridge', 'NV', 150), (3, 'Bronze Basin', 'CO', 180), (4, 'Iron Island', 'MT', 100), (5, 'Lead Land', 'SD', 90); CREATE TABLE industry_...
Identify mines with labor productivity below the industry average
SELECT name, labor_productivity FROM mine WHERE labor_productivity < (SELECT avg_labor_productivity FROM industry_average WHERE year = 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE WaterConservation (Id INT, Initiative VARCHAR(50), Savings DECIMAL(5,2), Date DATE); INSERT INTO WaterConservation (Id, Initiative, Savings, Date) VALUES (1, 'Rain Barrels', 75.2, '2021-09-01'); INSERT INTO WaterConservation (Id, Initiative, Savings, Date) VALUES (2, 'Smart Irrigation', 78.3, '2021-09-01')...
What were the water conservation initiatives with an average savings of over 70 m³ on September 1, 2021?
SELECT Initiative, AVG(Savings) FROM WaterConservation WHERE Date = '2021-09-01' GROUP BY Initiative HAVING AVG(Savings) > 70;
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (id INT, name TEXT, country TEXT, living_wage_standard BOOLEAN, water_consumption DECIMAL(5,2)); INSERT INTO Factories (id, name, country, living_wage_standard, water_consumption) VALUES (1, 'Factory A', 'USA', true, 12000.00), (2, 'Factory B', 'Mexico', false, 15000.00), (3, 'Factory C', 'India'...
What is the total water consumption of factories in each country, categorized by those meeting the living wage standard?
SELECT country, SUM(water_consumption) FROM Factories GROUP BY country, living_wage_standard;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name TEXT, location TEXT); INSERT INTO initiatives (id, name, location) VALUES (1, 'Safe Streets', 'Manhattan'), (2, 'Youth and Police Dialogues', 'Brooklyn'), (3, 'Cops and Clergy', 'Queens'), (4, 'Community Patrol', 'Bronx'), (5, 'Disaster Preparedness Workshops', 'Staten Island');
List all community policing initiatives in the 'Bronx' borough.
SELECT name FROM initiatives WHERE location = 'Bronx';
gretelai_synthetic_text_to_sql
CREATE TABLE FanEvents (FanID INT, EventType VARCHAR(10), EventDate DATE); CREATE TABLE Fans (FanID INT, FanName VARCHAR(50));
Find the number of fans who have attended both basketball and football games in the last year.
SELECT COUNT(DISTINCT FanID) FROM FanEvents WHERE EventType IN ('Basketball', 'Football') GROUP BY FanID HAVING COUNT(DISTINCT EventType) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Launches (LaunchID INT, LaunchDate DATE, SatelliteName VARCHAR(50), Company VARCHAR(50), Success VARCHAR(50)); INSERT INTO Launches (LaunchID, LaunchDate, SatelliteName, Company, Success) VALUES (1, '2022-01-01', 'SatX', 'SpaceX', 'Failure'); INSERT INTO Launches (LaunchID, LaunchDate, SatelliteName, Compa...
Count the number of unsuccessful satellite launches by private companies
SELECT Company, COUNT(*) FROM Launches WHERE Success = 'Failure' AND Company NOT LIKE '%Government%' GROUP BY Company;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE shark_populations (id INT, marine_protected_area_id INT, shark_species VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, region) VALUES (1, 'Kerguelen Islands Marine Reserve', 'Southern Ocean'), (2, 'Heard Isla...
Which marine protected areas in the Southern Ocean have shark populations?
SELECT marine_protected_areas.name FROM marine_protected_areas JOIN shark_populations ON marine_protected_areas.id = shark_populations.marine_protected_area_id WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), country VARCHAR(255), launch_year INT, mission_status VARCHAR(255)); INSERT INTO space_missions (id, mission_name, country, launch_year, mission_status) VALUES (1, 'Artemis I', 'United States', 2022, 'Planned');
List the unique mission names and their launch years for each country.
SELECT launch_year, country, mission_name FROM space_missions GROUP BY launch_year, country, mission_name;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_date, founder_gender) VALUES (1, 'DataMine', 'Technology', '2018-01-01', 'Male'); INSERT INTO companies (id, name, industry, founding_date, founder_gender) VALUES (2, '...
List the names of companies that have received funding in the last 6 months, ordered by the amount of funding received.
SELECT companies.name FROM companies JOIN funding_records ON companies.id = funding_records.company_id WHERE funding_records.funding_date >= DATEADD(month, -6, GETDATE()) ORDER BY funding_amount DESC
gretelai_synthetic_text_to_sql
CREATE TABLE TravelAdvisories (id INT, country VARCHAR(50), issue_year INT, PRIMARY KEY(id)); INSERT INTO TravelAdvisories (id, country, issue_year) VALUES (1, 'CountryA', 2020), (2, 'CountryB', 2021), (3, 'CountryA', 2022), (4, 'CountryC', 2021), (5, 'CountryB', 2022);
Find the unique number of countries with travel advisories issued in 2020, 2021 and 2022.
SELECT COUNT(DISTINCT country) FROM TravelAdvisories WHERE issue_year IN (2020, 2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (id INT, name VARCHAR(50), location VARCHAR(50), staff_count INT);
List the names of rural clinics in Africa with their staff count.
SELECT name, staff_count FROM clinics WHERE location LIKE '%Africa%' AND location LIKE '%rural%';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name TEXT, location TEXT, department TEXT); INSERT INTO factories (id, name, location, department) VALUES (1, 'Factory A', 'US', 'textiles'), (2, 'Factory B', 'Canada', 'electronics'); CREATE TABLE workers (id INT, factory_id INT, salary FLOAT); INSERT INTO workers (id, factory_id, salar...
Calculate the average salary of workers in the "textiles" department who work in factories located in the US.
SELECT AVG(salary) FROM workers INNER JOIN factories ON workers.factory_id = factories.id WHERE factories.department = 'textiles' AND factories.location = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT, name TEXT, specialty TEXT); INSERT INTO providers (id, name, specialty) VALUES (1, 'Dr. Smith', 'General Practice'), (2, 'Dr. Johnson', 'Mental Health'), (3, 'Dr. Thompson', 'Geriatrics');
What is the number of healthcare providers in each specialty?
SELECT specialty, COUNT(*) FROM providers GROUP BY specialty;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, organization_id INT, source VARCHAR(50), amount INT); CREATE TABLE organizations (organization_id INT, region VARCHAR(50));
What is the total funding received by arts organizations in the Pacific region?
SELECT SUM(f.amount) as total_funding FROM funding f JOIN organizations o ON f.organization_id = o.organization_id WHERE o.region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceLaunches (LaunchID INT, Country VARCHAR(50), SatelliteID INT, LaunchYear INT); INSERT INTO SpaceLaunches (LaunchID, Country, SatelliteID, LaunchYear) VALUES (1, 'USA', 101, 2002), (2, 'Russia', 201, 1995), (3, 'China', 301, 2000), (4, 'Germany', 401, 2005), (5, 'Canada', 501, 2010), (6, 'Japan', 601, ...
What is the earliest launch year for each country with at least one satellite launch, based on the SpaceLaunches table?
SELECT Country, MIN(LaunchYear) AS EarliestLaunchYear FROM SpaceLaunches GROUP BY Country HAVING COUNT(SatelliteID) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, dob DATE, gender TEXT, state TEXT); INSERT INTO policyholders (id, name, dob, gender, state) VALUES (1, 'John Doe', '1960-01-01', 'Male', 'NY'), (2, 'Jane Smith', '1970-05-10', 'Female', 'CA'), (3, 'Mike Johnson', '1985-08-15', 'Male', 'TX');
Calculate the average age of policyholders from each state
SELECT state, AVG(YEAR(CURRENT_DATE) - YEAR(dob)) as avg_age FROM policyholders GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO fish_farms (id, name, country, latitude, longitude) VALUES (1, 'Farm A', 'Vietnam', 10.34567, 106.45678); INSERT INTO fish_farms (id, name, country, latitude, longitude) VALUES (2, 'Farm B', 'Vietnam', ...
What is the average oxygen level in the water at the Vietnamese fish farm 'Farm E' in July?
SELECT AVG(oxygen_level) FROM water_quality wq JOIN fish_farms ff ON wq.farm_id = ff.id WHERE wq.date = '2022-07-01' AND ff.country = 'Vietnam' AND ff.name LIKE 'Farm E%';
gretelai_synthetic_text_to_sql
CREATE TABLE passenger (passenger_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), disability VARCHAR(20)); INSERT INTO passenger (passenger_id, name, age, gender, disability) VALUES (1001, 'Alex Brown', 35, 'Male', 'Visual Impairment');
How many passengers with visual impairments boarded a train at each station?
SELECT passenger_id, name, age, gender, disability, station_id, COUNT(*) OVER (PARTITION BY station_id, disability) AS passengers_by_station_disability FROM passenger;
gretelai_synthetic_text_to_sql
CREATE TABLE field_sensor_data (field_id INT, date DATE, temperature DECIMAL(5,2), humidity DECIMAL(5,2)); INSERT INTO field_sensor_data (field_id, date, temperature, humidity) VALUES (12345, '2022-01-01', 20.5, 60.0), (12345, '2022-01-02', 21.0, 62.0), (12345, '2022-01-03', 19.5, 58.0);
Find the average temperature and humidity for the crops in field ID 12345.
SELECT AVG(temperature) AS avg_temperature, AVG(humidity) AS avg_humidity FROM field_sensor_data WHERE field_id = 12345;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, state VARCHAR(50), score INT); INSERT INTO student_mental_health (student_id, state, score) VALUES (1, 'California', 75), (2, 'Texas', 80), (3, 'California', 70);
What is the distribution of mental health scores for students in each state?
SELECT state, AVG(score) as avg_score, STDDEV(score) as stddev_score FROM student_mental_health GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts(astronaut_id INT, name VARCHAR(50), country VARCHAR(50), missions INT);
total number of space missions by astronauts from the USA
SELECT COUNT(*) FROM Astronauts WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(255), employees INT, esg_rating FLOAT); INSERT INTO companies (id, sector, employees, esg_rating) VALUES (1, 'technology', 7000, 8.2), (2, 'technology', 5500, 7.9), (3, 'finance', 3000, 6.5);
What is the average ESG rating for companies in the technology sector with more than 5000 employees?
SELECT AVG(esg_rating) FROM companies WHERE sector = 'technology' AND employees > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_revenue (subscriber_id INT, revenue FLOAT, year INT, country VARCHAR(20)); INSERT INTO mobile_revenue (subscriber_id, revenue, year, country) VALUES (1, 50, 2021, 'Canada'), (2, 60, 2022, 'Canada'), (3, 45, 2021, 'Canada'); CREATE TABLE broadband_revenue (subscriber_id INT, revenue FLOAT, year INT, ...
What is the total revenue generated from mobile and broadband services in the country of Canada for the year 2021?
SELECT SUM(mobile_revenue.revenue + broadband_revenue.revenue) FROM mobile_revenue INNER JOIN broadband_revenue ON mobile_revenue.subscriber_id = broadband_revenue.subscriber_id WHERE mobile_revenue.year = 2021 AND broadband_revenue.year = 2021 AND mobile_revenue.country = 'Canada' AND broadband_revenue.country = 'Cana...
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT PRIMARY KEY, country VARCHAR(50), generation_tonnes INT, year INT); INSERT INTO waste_generation (id, country, generation_tonnes, year) VALUES (1, 'Nigeria', 100, 2014);
What was the country with the lowest waste generation tonnes in the year 2014?
SELECT country FROM waste_generation WHERE year = 2014 AND generation_tonnes = (SELECT MIN(generation_tonnes) FROM waste_generation WHERE year = 2014);
gretelai_synthetic_text_to_sql
CREATE TABLE inventors (inventor_id INT, inventor_name VARCHAR(100), gender VARCHAR(10)); INSERT INTO inventors VALUES (1, 'Grace Hopper', 'female'), (2, 'Alan Turing', 'male'); CREATE TABLE patents (patent_id INT, patent_name VARCHAR(100), inventor_id INT, filed_year INT); INSERT INTO patents VALUES (1, 'Ethical AI Al...
Identify the number of ethical AI patents filed by women inventors since 2017.
SELECT COUNT(*) FROM patents INNER JOIN inventors ON patents.inventor_id = inventors.inventor_id INNER JOIN patent_categories ON patents.patent_id = patent_categories.patent_id WHERE gender = 'female' AND filed_year >= 2017 AND category = 'ethical AI';
gretelai_synthetic_text_to_sql
CREATE TABLE fields (field_id INT, field_name VARCHAR(255), production_rate FLOAT, active BOOLEAN); INSERT INTO fields (field_id, field_name, production_rate, active) VALUES (1, 'Field A', 1000.0, true), (2, 'Field B', 2000.0, false), (3, 'Field C', 1500.0, true);
Calculate the average production rate for each field, considering only the active fields
SELECT field_name, AVG(production_rate) as avg_production_rate FROM fields WHERE active = true GROUP BY field_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyNumber INT, CoverageType VARCHAR(50)); CREATE TABLE Claim (ClaimNumber INT, PolicyNumber INT, ClaimAmount INT); INSERT INTO Policy (PolicyNumber, CoverageType) VALUES (1, 'Home'); INSERT INTO Policy (PolicyNumber, CoverageType) VALUES (2, 'Auto'); INSERT INTO Policy (PolicyNumber, CoverageTyp...
What is the total number of policies and total claim amount for policies with a coverage type of 'Auto' or 'Motorcycle'?
SELECT COUNT(Policy.PolicyNumber), SUM(Claim.ClaimAmount) FROM Policy JOIN Claim ON Policy.PolicyNumber = Claim.PolicyNumber WHERE Policy.CoverageType IN ('Auto', 'Motorcycle');
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (HourID INT, VolunteerName TEXT, Region TEXT, HoursSpent DECIMAL, HourDate DATE); INSERT INTO VolunteerHours (HourID, VolunteerName, Region, HoursSpent, HourDate) VALUES (1, 'Sophia Gonzalez', 'Los Angeles', 10.00, '2022-01-01'), (2, 'Mia Davis', 'Los Angeles', 15.00, '2022-02-01');
What is the average number of volunteer hours spent per volunteer in the Los Angeles region in the year 2022?
SELECT AVG(HoursSpent) FROM VolunteerHours WHERE Region = 'Los Angeles' AND YEAR(HourDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, habitat_name VARCHAR(50), threat_level VARCHAR(10), area_protected INT);
Update the 'habitat_preservation' table to set the area_protected of the 'Galapagos Islands' to 97500
UPDATE habitat_preservation SET area_protected = 97500 WHERE habitat_name = 'Galapagos Islands';
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (Date date, Location text, Material text, Quantity integer);CREATE TABLE RecyclingRates (Date date, Location text, Material text, Quantity real);
What is the percentage of waste generated that was recycled, for each location and material, for the year 2022?
SELECT wg.Location, wg.Material, 100.0 * AVG(rr.Quantity / wg.Quantity) as PercentageRecycled FROM WasteGeneration wg JOIN RecyclingRates rr ON wg.Location = rr.Location AND wg.Material = rr.Material WHERE wg.Date >= '2022-01-01' AND wg.Date < '2023-01-01' GROUP BY wg.Location, wg.Material;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, country TEXT, virtual_tour BOOLEAN); INSERT INTO hotels (id, name, country, virtual_tour) VALUES (1, 'Hotel A', 'Antarctica', true), (2, 'Hotel B', 'Antarctica', false);
How many hotels in Antarctica have a virtual tour?
SELECT COUNT(*) FROM hotels WHERE country = 'Antarctica' AND virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE music_platform (id INT, song_title VARCHAR(100), genre VARCHAR(50), length FLOAT);
What is the average length of songs in the pop genre on the music streaming platform?
SELECT AVG(length) as avg_length FROM music_platform WHERE genre = 'pop';
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT PRIMARY KEY, name VARCHAR(255), length FLOAT, material VARCHAR(255), built_year INT); INSERT INTO bridges (id, name, length, material, built_year) VALUES (1, 'BridgeX', 300.5, 'steel', 2000), (2, 'BridgeY', 450.7, 'concrete', 1965), (3, 'BridgeZ', 120.3, 'steel', 1990);
What is the minimum length of bridges made of steel?
SELECT MIN(length) as min_length FROM bridges WHERE material = 'steel';
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_status (id INT, species_name VARCHAR(50), status VARCHAR(20)); INSERT INTO conservation_status (id, species_name, status) VALUES (1, 'Green Sea Turtle', 'Least Concern'), (2, 'Clownfish', 'Least Concern'), (3, 'Bottlenose Dolphin', 'Data Deficient');
Update the conservation status of the 'Bottlenose Dolphin' to 'Vulnerable' in the 'conservation_status' table.
UPDATE conservation_status SET status = 'Vulnerable' WHERE species_name = 'Bottlenose Dolphin';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Game 1', 'gaming'), (2, 'Game 2', 'gaming'); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); INSERT INTO users (user_id, user_country) VALUES (1, '...
What was the total revenue from users in Nigeria and Indonesia for the 'gaming' product category in Q4 2022?
SELECT SUM(revenue) FROM orders o JOIN products p ON o.product_id = p.product_id JOIN users u ON o.user_id = u.user_id WHERE u.user_country IN ('Nigeria', 'Indonesia') AND p.category = 'gaming' AND o.order_date BETWEEN '2022-10-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_reserves (reserve_name VARCHAR(255), reserve_area FLOAT); INSERT INTO arctic_reserves (reserve_name, reserve_area) VALUES ('North Pole', 10000.0), ('Svalbard', 2000.0);
What is the total area of all marine reserves in the Arctic region?
SELECT SUM(reserve_area) FROM arctic_reserves;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT PRIMARY KEY, name TEXT, type TEXT, length REAL); CREATE TABLE delays (route_id INT, delay REAL, timestamp TIMESTAMP);
What is the average delay for the Red Line subway route?
SELECT AVG(delay) FROM delays WHERE route_id = (SELECT id FROM routes WHERE name = 'Red Line' AND type = 'Subway');
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), event VARCHAR(50), stipend DECIMAL(5,2)); INSERT INTO artists (id, name, event, stipend) VALUES (1, 'Pablo Picasso', 'Art of the Americas', 3000), (2, 'Frida Kahlo', 'Art of the Americas', 2500), (3, 'Yayoi Kusama', 'Women in Art', 4000);
Delete all artists from the 'Modern Art' event.
DELETE FROM artists WHERE event = 'Modern Art';
gretelai_synthetic_text_to_sql
CREATE SCHEMA user_activity; CREATE TABLE steps_data (user_id INT, country VARCHAR(50), steps INT, activity_date DATE); INSERT INTO steps_data VALUES (1, 'Brazil', 8000, '2023-01-01'), (2, 'Mexico', 7000, '2023-01-02'), (3, 'Brazil', 9000, '2023-01-03');
What is the total steps count for users from Brazil in the first week of January 2023?'
SELECT SUM(steps) FROM user_activity.steps_data WHERE country = 'Brazil' AND activity_date >= '2023-01-01' AND activity_date <= '2023-01-07';
gretelai_synthetic_text_to_sql
CREATE TABLE Rates (RateID INT, Age INT, Gender VARCHAR(10), City VARCHAR(20), Disease VARCHAR(20), Rate DECIMAL(5,2)); INSERT INTO Rates (RateID, Age, Gender, City, Disease, Rate) VALUES (1, 35, 'Male', 'New York', 'Cholera', 0.15);
List the top 3 diseases with the highest infection rate in New York.
SELECT Disease, Rate FROM (SELECT Disease, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Rates WHERE City = 'New York') as Rate FROM Rates WHERE City = 'New York' GROUP BY Disease) as Subquery ORDER BY Rate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(50), size FLOAT, region VARCHAR(20)); INSERT INTO marine_protected_areas (id, name, size, region) VALUES (1, 'Galapagos Marine Reserve', 133000, 'Pacific'); INSERT INTO marine_protected_areas (id, name, size, region) VALUES (2, 'Great Barrier Reef', 344400, 'Pac...
Calculate the total number of marine protected areas in the Pacific region.
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE SwimmingPools (City TEXT, NumPools INTEGER); INSERT INTO SwimmingPools (City, NumPools) VALUES ('CityA', 3), ('CityB', 5), ('CityC', 4);
How many public swimming pools are there in each city?
SELECT City, NumPools FROM SwimmingPools;
gretelai_synthetic_text_to_sql
CREATE TABLE CO2_Emissions (year INT, emissions_mt INT, region VARCHAR(50), PRIMARY KEY(year)); INSERT INTO CO2_Emissions (year, emissions_mt, region) VALUES (2015, 125678, 'Atlantic Ocean'), (2016, 136789, 'Atlantic Ocean');
What are the annual CO2 emissions from shipping activities in the Atlantic Ocean?
SELECT CO2_Emissions.emissions_mt FROM CO2_Emissions WHERE CO2_Emissions.region = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE construction_materials (bridge_id INT, material VARCHAR(255));
List all the bridges and their construction material from the 'bridges' and 'construction_materials' tables.
SELECT b.name, cm.material FROM bridges b LEFT JOIN construction_materials cm ON b.id = cm.bridge_id;
gretelai_synthetic_text_to_sql
CREATE TABLE country_data_2 (id INT, country VARCHAR(50), sector VARCHAR(50), ESG_score FLOAT); INSERT INTO country_data_2 (id, country, sector, ESG_score) VALUES (1, 'Brazil', 'Renewable Energy', 70.0), (2, 'South Africa', 'Renewable Energy', 72.5), (3, 'Mexico', 'Renewable Energy', 75.0), (4, 'Indonesia', 'Renewable ...
List the top 2 countries with the lowest average ESG scores in the renewable energy sector.
SELECT country, AVG(ESG_score) as avg_ESG_score FROM country_data_2 WHERE sector = 'Renewable Energy' GROUP BY country ORDER BY avg_ESG_score LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage_facilities (id INT, name VARCHAR(255), state VARCHAR(50), capacity FLOAT); INSERT INTO energy_storage_facilities (id, name, state, capacity) VALUES (1, 'Facility A', 'California', 1200.5), (2, 'Facility B', 'Texas', 800.3), (3, 'Facility C', 'California', 1500.2), (4, 'Facility D', 'New York...
How many energy storage facilities exist in each state of the 'energy_storage_facilities' table, along with their capacities?
SELECT e.state, COUNT(*), SUM(e.capacity) as total_capacity FROM energy_storage_facilities e GROUP BY e.state;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_id INT, hospital_name TEXT, city TEXT, state TEXT, star_rating INT); INSERT INTO hospitals (hospital_id, hospital_name, city, state, star_rating) VALUES (1, 'New York-Presbyterian', 'New York City', 'New York', 5); INSERT INTO hospitals (hospital_id, hospital_name, city, state, star_rat...
How many hospitals are there in New York City that have received a rating of 5 stars?
SELECT COUNT(*) FROM hospitals WHERE city = 'New York City' AND star_rating = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, feature_id INT, date DATE, price FLOAT); CREATE TABLE features (id INT, name TEXT); INSERT INTO bookings (id, feature_id, date, price) VALUES (1, 2, '2022-01-01', 20), (2, 2, '2022-01-02', 20), (3, 2, '2022-01-03', 20), (4, 3, '2022-01-01', 30), (5, 3, '2022-01-02', 30), (6, 1, '2022-01-0...
What is the daily revenue for the 'concierge service' feature?
SELECT SUM(price) FROM bookings INNER JOIN features ON bookings.feature_id = features.id WHERE features.name = 'Concierge service' GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE Customer_Survey (id INT, booking_id INT, rating INT, feedback VARCHAR(255)); INSERT INTO Customer_Survey (id, booking_id, rating, feedback) VALUES (1, 1, 5, 'Great experience!'); INSERT INTO Customer_Survey (id, booking_id, rating, feedback) VALUES (2, 2, 4, 'Good, but could be better'); INSERT INTO Custom...
What is the minimum rating for each booking with more than one rating?
SELECT booking_id, MIN(rating) as 'Minimum Rating' FROM Customer_Survey GROUP BY booking_id HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicSales (sale_id INT, sale_date DATE, sale_amount DECIMAL(10,2), genre VARCHAR(255)); INSERT INTO MusicSales (sale_id, sale_date, sale_amount, genre) VALUES (1, '2021-01-01', 15.99, 'Pop'), (2, '2020-12-31', 20.00, 'Rock'), (3, '2021-02-14', 10.99, 'Jazz'), (4, '2021-03-01', 12.99, 'R&B'), (5, '2021-04-...
What is the total revenue for each genre in the year 2021?
SELECT genre, SUM(sale_amount) as total_revenue FROM MusicSales WHERE YEAR(sale_date) = 2021 GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_sources (country VARCHAR(50), energy_type VARCHAR(50), generation FLOAT); INSERT INTO renewable_sources (country, energy_type, generation) VALUES ('United States', 'Solar', 123.45), ('United States', 'Wind', 678.90);
Find the total energy generated by renewable sources in the US
SELECT SUM(generation) FROM renewable_sources WHERE country = 'United States' AND energy_type IN ('Solar', 'Wind');
gretelai_synthetic_text_to_sql
CREATE TABLE TicketSales (TicketSaleID INT, ConcertID INT, UserID INT, TicketPrice DECIMAL(5, 2)); INSERT INTO TicketSales VALUES (1, 7, 20, 65.50), (2, 8, 21, 55.00), (3, 9, 22, 70.00);
What is the total revenue from concert ticket sales for artists of the 'Rock' genre?
SELECT SUM(TicketPrice) FROM TicketSales JOIN Concerts ON TicketSales.ConcertID = Concerts.ConcertID WHERE Concerts.Genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (country VARCHAR(50), year INT, budget INT); INSERT INTO military_innovation (country, year, budget) VALUES ('Brazil', 2019, 5000000), ('Argentina', 2019, 4000000), ('Colombia', 2019, 3000000);
What was the minimum budget allocated for military innovation by South American countries in 2019?
SELECT MIN(budget) FROM military_innovation WHERE country IN ('Brazil', 'Argentina', 'Colombia') AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_adoption (hotel_id INT, country VARCHAR(255), ai_adoption BOOLEAN); INSERT INTO ai_adoption (hotel_id, country, ai_adoption) VALUES (1, 'Africa', true), (2, 'Africa', false), (3, 'South America', true);
How many hotels have adopted AI in Africa?
SELECT COUNT(*) FROM ai_adoption WHERE country = 'Africa' AND ai_adoption = true;
gretelai_synthetic_text_to_sql
CREATE TABLE polkadot_transactions (transaction_id INTEGER, regulatory_framework VARCHAR(20));
Display the number of transactions for each regulatory framework in the Polkadot blockchain, sorted by the number of transactions in descending order.
SELECT regulatory_framework, COUNT(*) FROM polkadot_transactions GROUP BY regulatory_framework ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Committee (id INT, name VARCHAR(50), chairman INT, sector VARCHAR(20), FOREIGN KEY (chairman) REFERENCES Legislator(id)); INSERT INTO Committee (id, name, chairman, sector) VALUES (3, 'Finance Committee', 5, 'Finance'); INSERT INTO Committee (id, name, chairman, sector) VALUES (4, 'Budget Committee', 6, 'F...
Who are the chairpersons of all committees in the 'Finance' sector?
SELECT Committee.name, Legislator.name FROM Committee INNER JOIN Legislator ON Committee.chairman = Legislator.id WHERE Committee.sector = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(255), gender VARCHAR(10), department VARCHAR(255)); INSERT INTO faculty (id, name, gender, department) VALUES (1, 'Alice', 'Female', 'Physics'), (2, 'Bob', 'Male', 'Physics'), (3, 'Charlie', 'Non-binary', 'Mathematics'), (4, 'Dave', 'Male', 'Mathematics'), (5, 'Eve', 'Female',...
List the number of female and male professors in each department
SELECT department, gender, COUNT(*) as count FROM faculty GROUP BY department, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Interaction_Scores (visitor_id INT, community_name VARCHAR(100), year INT, score INT);
What is the average digital interaction score for visitors from the LGBTQ+ community in 2020?
SELECT AVG(score) FROM Interaction_Scores WHERE community_name = 'LGBTQ+' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 85000), (2, 'HR', 70000);
What is the maximum salary for each department in the company?
SELECT Department, MAX(Salary) as MaxSalary FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, station_name VARCHAR(50), station_type VARCHAR(20)); INSERT INTO stations (station_id, station_name, station_type) VALUES (1, 'StationA', 'Underground'), (2, 'StationB', 'Overground'), (3, 'StationC', 'Underground');
Insert a new record into the 'stations' table for a new 'Overground' station named 'StationD' with station_id '4'
INSERT INTO stations (station_id, station_name, station_type) VALUES (4, 'StationD', 'Overground');
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, type TEXT, daily_rate DECIMAL(5,2), revenue INT); INSERT INTO hotels (hotel_id, hotel_name, type, daily_rate, revenue) VALUES (1, 'Eco Hotel', 'eco', 100.00, 3000), (2, 'Urban Resort', 'standard', 150.00, 5000), (3, 'Beach Retreat', 'eco', 120.00, 4000);
What is the total revenue generated by eco-friendly hotels in the last month?
SELECT SUM(revenue) FROM hotels WHERE type = 'eco' AND revenue BETWEEN DATE_SUB(curdate(), INTERVAL 1 MONTH) AND curdate();
gretelai_synthetic_text_to_sql
CREATE TABLE investments_sector (id INT, investment_year INT, sector VARCHAR(20), investment_amount FLOAT); INSERT INTO investments_sector (id, investment_year, sector, investment_amount) VALUES (1, 2019, 'technology', 120000), (2, 2020, 'finance', 185000), (3, 2018, 'technology', 175000);
What's the total investment amount for companies in the 'technology' sector, by year?
SELECT investment_year, SUM(investment_amount) FROM investments_sector WHERE sector = 'technology' GROUP BY investment_year;
gretelai_synthetic_text_to_sql
CREATE VIEW sales_data AS SELECT id, vehicle_type, avg_speed, sales FROM vehicle_sales WHERE sales > 20000;
What is the total number of vehicles sold in 'sales_data' view that have a speed greater than 75 mph?
SELECT SUM(sales) FROM sales_data WHERE avg_speed > 75;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name TEXT, country TEXT, launch_date DATE, mass FLOAT); INSERT INTO satellites (id, name, country, launch_date, mass) VALUES (1, 'Starlink 1', 'USA', '2018-11-19', 470);
What is the average age of all satellites deployed by SpaceX?
SELECT AVG(DATEDIFF('2022-10-01', launch_date)) FROM satellites WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE food_justice_scores_na (country VARCHAR(50), score FLOAT); INSERT INTO food_justice_scores_na (country, score) VALUES ('Canada', 75.3), ('US', 72.5);
What is the average food justice score in North America?
SELECT AVG(score) FROM food_justice_scores_na WHERE country IN ('Canada', 'US');
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing_il (id INT, city VARCHAR(255), meeting_date DATE);
How many community policing meetings were held in each city in the state of Illinois in the last 6 months?
SELECT city, COUNT(*) as total_meetings FROM community_policing_il WHERE meeting_date BETWEEN '2021-07-01' AND '2021-12-31' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (id INT, name VARCHAR(100), manufacturer VARCHAR(100), mass FLOAT, launched BOOLEAN); INSERT INTO Spacecrafts (id, name, manufacturer, mass, launched) VALUES (1, 'AstroShip 1', 'AstroCorp', 1000, true), (2, 'AstroShip 2', 'AstroCorp', 2000, false);
What is the average cost of spacecrafts manufactured by AstroCorp that have been launched?
SELECT AVG(mass) FROM Spacecrafts WHERE manufacturer = 'AstroCorp' AND launched = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (program_id INT, program_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Programs (program_id, program_name, location) VALUES (1, 'Senior Fitness', 'Oakwood Community Center');
Delete all records from the 'Programs' table
DELETE FROM Programs;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investments (id INT, region VARCHAR(20), investment_year INT, investment_amount FLOAT); INSERT INTO impact_investments (id, region, investment_year, investment_amount) VALUES (1, 'Latin America', 2020, 100000), (2, 'Africa', 2019, 120000), (3, 'Latin America', 2021, 150000);
What is the minimum investment amount for the 'Latin America' region?
SELECT MIN(investment_amount) FROM impact_investments WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteName VARCHAR(50), ArtifactCount INT); INSERT INTO ExcavationSites (SiteName, ArtifactCount) VALUES ('Site1', 4), ('Site2', 2), ('Site3', 5);
Which excavation sites have more than 3 artifacts with analysis results indicating 'Presence of Organic Materials'?
SELECT SiteName FROM ExcavationSites WHERE ArtifactCount > 3 INTERSECT SELECT SiteName FROM (SELECT SiteName, COUNT(*) FROM ExcavationSites s JOIN Artifacts a ON s.SiteName = a.SiteName WHERE a.AnalysisResult = 'Presence of Organic Materials' GROUP BY SiteName) AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE time_series (id INT, month VARCHAR(7), value INT); INSERT INTO time_series VALUES (1, 'Jan-2021', 500), (2, 'Feb-2021', 600), (3, 'Mar-2021', 700); CREATE TABLE smart_contract (id INT, name VARCHAR(255), time_series_id INT); INSERT INTO smart_contract VALUES (1, 'Contract1', 1), (2, 'Contract2', 2), (3, 'C...
How many smart contracts have been created per month in 2021?
SELECT EXTRACT(MONTH FROM time_series.month) AS month, COUNT(*) FROM smart_contract JOIN time_series ON smart_contract.time_series_id = time_series.id GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_venue (venue_id INT, event_name VARCHAR(255), price DECIMAL(5,2), city VARCHAR(255)); INSERT INTO sports_venue (venue_id, event_name, price, city) VALUES (1, 'Basketball Game', 120.50, 'California'), (2, 'Baseball Game', 50.00, 'New York'), (3, 'Soccer Game', 30.00, 'California'), (4, 'Hockey Game',...
What is the minimum ticket price for any event in each city?
SELECT city, MIN(price) FROM sports_venue GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10)); INSERT INTO Employees (EmployeeID, Gender) VALUES (1, 'Male'), (2, 'Female'), (3, 'Non-binary'); CREATE TABLE Applicants (ApplicantID INT, Gender VARCHAR(10)); INSERT INTO Applicants (ApplicantID, Gender) VALUES (1, 'Male'), (2, 'Female'), (3, 'Transgender'),...
What is the total number of employees and job applicants by gender?
SELECT 'Employees' AS source, Gender, COUNT(*) as total FROM Employees GROUP BY Gender UNION ALL SELECT 'Applicants', Gender, COUNT(*) FROM Applicants GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (garment_id INT, garment_name VARCHAR(50), material VARCHAR(20), manufacturing_cost DECIMAL(10,2)); CREATE VIEW sustainable_materials AS SELECT material FROM sustainable_materials_list;
List all garments that are made of sustainable materials and their respective manufacturing costs.
SELECT garment_id, garment_name, manufacturing_cost FROM garments INNER JOIN sustainable_materials ON garments.material = sustainable_materials.material;
gretelai_synthetic_text_to_sql
CREATE TABLE offices (office_id INT, office_name VARCHAR(20)); INSERT INTO offices (office_id, office_name) VALUES (1, 'Boston'), (2, 'New York'), (3, 'Chicago'); CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(30), gender VARCHAR(10)); INSERT INTO attorneys (attorney_id, attorney_name, gender) VALUES (1...
List the number of cases lost by female attorneys from the 'Boston' office?
SELECT COUNT(*) FROM cases JOIN offices ON cases.office_id = offices.office_id JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE offices.office_name = 'Boston' AND attorneys.gender = 'Female' AND case_outcome = 'Lost';
gretelai_synthetic_text_to_sql
CREATE TABLE country_visitors (country VARCHAR(255), visitors INT, year INT); INSERT INTO country_visitors (country, visitors, year) VALUES ('Brazil', 5000000, 2021), ('India', 10000000, 2021), ('Indonesia', 7000000, 2021), ('Mexico', 8000000, 2021), ('South Korea', 9000000, 2021), ('United States', 12000000, 2021);
How many visitors were there in each country in 2021?
SELECT country, visitors FROM country_visitors WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists programs (id INT, name VARCHAR(255), type VARCHAR(255), visitors INT); INSERT INTO programs (id, name, type, visitors) VALUES (1, 'Story Time', 'Children', 300), (2, 'Art Class', 'Children', 250), (3, 'Theater Workshop', 'Youth', 150), (4, 'Jazz Night', 'Adults', 100);
What is the total number of visitors to children's programs?
SELECT SUM(visitors) FROM programs WHERE type = 'Children';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists finance;CREATE TABLE if not exists loans (id INT PRIMARY KEY, institution_name TEXT, region TEXT, amount DECIMAL(10,2), disbursal_date DATE); INSERT INTO loans (id, institution_name, region, amount, disbursal_date) VALUES (1, 'ABC Microfinance', 'Oceania', 5000.00, '2021-07-15'), (2, 'DEF Mi...
Delete all loans disbursed to microfinance institutions in Oceania in Q3 2021
DELETE FROM finance.loans WHERE region = 'Oceania' AND EXTRACT(QUARTER FROM disbursal_date) = 3 AND EXTRACT(YEAR FROM disbursal_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), num_employees INT); INSERT INTO mining_sites (id, name, location, num_employees) VALUES (1, 'Site Alpha', 'USA', 100), (2, 'Site Bravo', 'Canada', 150), (3, 'Site Charlie', 'Australia', 200);
What is the location of 'Site Charlie' in the 'mining_sites' table?
SELECT location FROM mining_sites WHERE name = 'Site Charlie';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_revenue (id INT PRIMARY KEY, farm_id INT, year INT, revenue INT); INSERT INTO farm_revenue (id, farm_id, year, revenue) VALUES (4, 3, 2019, 65000); INSERT INTO farm_revenue (id, farm_id, year, revenue) VALUES (5, 4, 2020, 70000); INSERT INTO farm_revenue (id, farm_id, year, revenue) VALUES (6, 4, 2021...
What is the minimum revenue for each farm?
SELECT farm_id, MIN(revenue) FROM farm_revenue GROUP BY farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentTypeSales (id INT PRIMARY KEY, equipment_type VARCHAR(50), country VARCHAR(50), sale_price DECIMAL(10, 2));
What is the minimum sale price for naval equipment in Japan?
SELECT MIN(sale_price) FROM EquipmentTypeSales WHERE equipment_type = 'naval' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE educators(id INT, num_courses INT); INSERT INTO educators VALUES (1, 2), (2, 5), (3, 3), (4, 10), (5, 0);
What is the maximum number of professional development courses completed by educators?
SELECT MAX(num_courses) FROM educators;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, city, response_time) VALUES (1, 'San Francisco', 120), (2, 'New York', 150), (3, 'Los Angeles', 100);
List the top 3 cities with the longest average emergency response time
SELECT city, AVG(response_time) as avg_response_time FROM emergency_calls GROUP BY city ORDER BY avg_response_time DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_apps (app_id INT PRIMARY KEY, app_name TEXT, location TEXT); INSERT INTO decentralized_apps (app_id, app_name, location) VALUES (5, 'Curve', 'Japan'), (6, 'Aave', 'United Kingdom');
Which decentralized applications are available in Japan?
SELECT app_name FROM decentralized_apps WHERE location = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Engagement_Events (id INT, country VARCHAR(255), quarter INT, number_of_events INT);
How many community engagement events were organized in Canada in Q3 2021?
SELECT SUM(number_of_events) FROM Community_Engagement_Events WHERE country = 'Canada' AND quarter = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE golf_players (player_id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO golf_players (player_id, name, age, country) VALUES (1, 'Tiger Woods', 46, 'USA'); INSERT INTO golf_players (player_id, name, age, country) VALUES (2, 'Phil Mickelson', 51, 'USA');
What is the maximum age of athletes in the golf_players table?
SELECT MAX(age) FROM golf_players;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, factory_location VARCHAR(50)); INSERT INTO factories (factory_id, factory_location) VALUES (1, 'New York'), (2, 'Chicago'), (3, 'Los Angeles'); CREATE TABLE manufacturing (manufacturing_id INT, factory_id INT, product_quantity INT, manufacture_date DATE); INSERT INTO manufacturin...
What was the total quantity of products manufactured by each factory in January 2022, grouped by factory location?
SELECT factory_location, SUM(product_quantity) as total_quantity FROM manufacturing JOIN factories ON manufacturing.factory_id = factories.factory_id WHERE manufacture_date >= '2022-01-01' AND manufacture_date < '2022-02-01' GROUP BY factory_location;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT PRIMARY KEY, year INT, location VARCHAR(50), usage FLOAT); INSERT INTO water_usage (id, year, location, usage) VALUES (1, 2020, 'Las Vegas', 3567.89), (2, 2020, 'New Orleans', 2567.89), (3, 2020, 'Philadelphia', 1890.12), (4, 2020, 'Providence', 1234.56), (5, 2020, 'Sacramento', 567.89)...
Calculate the percentage of total water usage for each location in the year 2020
SELECT location, ROUND(100.0 * usage / (SELECT SUM(usage) FROM water_usage WHERE year = 2020)::DECIMAL, 2) AS percentage FROM water_usage WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), LaunchDate DATETIME, Agency VARCHAR(50)); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, Agency) VALUES (1, 'Sat1', '2020-01-01', 'ESA'), (2, 'Sat2', '2019-05-15', 'ESA'), (3, 'Sat3', '2018-09-14', 'NASA');
What is the total number of satellites launched by the European Space Agency?
SELECT COUNT(*) FROM Satellites WHERE Agency = 'ESA';
gretelai_synthetic_text_to_sql