context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE authors (id INT, name TEXT, gender TEXT); INSERT INTO authors (id, name, gender) VALUES (1, 'Author1', 'female'), (2, 'Author2', 'male'), (3, 'Author3', 'non-binary'); CREATE TABLE articles (id INT, author_id INT, title TEXT); INSERT INTO articles (id, author_id, title) VALUES (1, 1, 'Article1'), (2, 2, 'Article2'), (3, 1, 'Article3');
Find the number of articles written by female authors?
SELECT COUNT(*) FROM authors JOIN articles ON authors.id = articles.author_id WHERE authors.gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours_netherlands (id INT, country VARCHAR(20), revenue FLOAT); INSERT INTO virtual_tours_netherlands (id, country, revenue) VALUES (1, 'Netherlands', 500.0), (2, 'Netherlands', 600.0), (3, 'Netherlands', 700.0);
What is the minimum revenue generated by a single virtual tour in the Netherlands?
SELECT MIN(revenue) FROM virtual_tours_netherlands WHERE country = 'Netherlands';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), is_cruelty_free BOOLEAN, region VARCHAR(50), sales INT, launch_year INT, launch_quarter INT, is_organic BOOLEAN); INSERT INTO products (product_id, product_name, is_cruelty_free, region, sales, launch_year, launch_quarter, is_organic) VALUES (1, 'Lipstick', true, 'USA', 500, 2021, 2, true), (2, 'Mascara', false, 'Canada', 700, 2020, 4, false), (3, 'Foundation', true, 'USA', 800, 2021, 3, false), (4, 'Eyeshadow', true, 'USA', 600, 2020, 2, true), (5, 'Blush', false, 'Canada', 400, 2021, 1, true);
Find the percentage of organic cosmetic products that were launched in the second half of 2021, by region.
SELECT region, (COUNT(*) FILTER (WHERE is_organic = true AND launch_quarter BETWEEN 3 AND 4)) * 100.0 / COUNT(*) AS percentage FROM products WHERE region = ANY('{USA, Canada}'::VARCHAR(50)[]) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE org_beneficiaries (gender VARCHAR(6), count INT); INSERT INTO org_beneficiaries (gender, count) VALUES ('Female', 50), ('Male', 50);
What is the total number of male and female beneficiaries served by the organization?
SELECT gender, SUM(count) FROM org_beneficiaries GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE diabetes_cases (case_id INT, region_id INT, income_level_id INT, cases_count INT, case_date DATE); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); CREATE TABLE income_levels (income_level_id INT, income_level VARCHAR(50));
What is the trend of diabetes cases over time by region and income level?
SELECT r.region_name, il.income_level, EXTRACT(YEAR FROM dc.case_date) AS year, EXTRACT(MONTH FROM dc.case_date) AS month, AVG(dc.cases_count) AS avg_cases FROM diabetes_cases dc JOIN regions r ON dc.region_id = r.region_id JOIN income_levels il ON dc.income_level_id = il.income_level_id GROUP BY r.region_id, il.income_level_id, EXTRACT(YEAR FROM dc.case_date), EXTRACT(MONTH FROM dc.case_date) ORDER BY r.region_id, il.income_level_id, EXTRACT(YEAR FROM dc.case_date), EXTRACT(MONTH FROM dc.case_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Product_Info (id INT, brand VARCHAR(255), product VARCHAR(255), rating INT, vegan BOOLEAN, organic BOOLEAN); INSERT INTO Product_Info (id, brand, product, rating, vegan, organic) VALUES (1, 'Dr. Bronner’,s', 'Pure-Castile Liquid Soap - Baby Unscented', 5, true, true), (2, 'Weleda', 'Calendula Baby Cream', 4, true, true), (3, 'Estee Lauder', 'Advanced Night Repair Synchronized Recovery Complex II', 5, false, false), (4, 'Lush', 'Angels on Bare Skin Cleanser', 4, true, true), (5, 'The Body Shop', 'Tea Tree Skin Clearing Facial Wash', 3, false, true);
What is the maximum rating for vegan products from organic sources in the database?
SELECT MAX(rating) as max_rating FROM Product_Info WHERE vegan = true AND organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, visitors INT, continent VARCHAR(255)); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('France', 2019, 1000000, 'Europe'); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('Germany', 2019, 1200000, 'Europe');
Delete records of tourists who visited Europe in 2019.
DELETE FROM tourism_stats WHERE continent = 'Europe' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE volunteers (id INT, name VARCHAR(50), project_id INT, volunteer_date DATE); INSERT INTO projects (id, name, start_date, end_date) VALUES (1, 'Project A', '2022-01-01', '2022-12-31'), (2, 'Project B', '2022-07-01', '2022-12-31'); INSERT INTO volunteers (id, name, project_id, volunteer_date) VALUES (1, 'Volunteer 1', 1, '2022-02-01'), (2, 'Volunteer 2', 1, '2022-03-01'), (3, 'Volunteer 3', 2, '2022-08-01');
How many unique volunteers worked on each project in 2022?
SELECT p.name, COUNT(DISTINCT v.id) AS num_volunteers FROM projects p JOIN volunteers v ON p.id = v.project_id WHERE YEAR(v.volunteer_date) = 2022 GROUP BY p.id;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Suburbs'); CREATE TABLE students (student_id INT, student_name TEXT, district_id INT, mental_health_score INT); INSERT INTO students (student_id, student_name, district_id, mental_health_score) VALUES (1, 'John Doe', 1, 75), (2, 'Jane Smith', 2, 80), (3, 'Alice Johnson', 3, 85);
What is the average mental health score of students in each district?
SELECT d.district_name, AVG(s.mental_health_score) as avg_score FROM students s JOIN districts d ON s.district_id = d.district_id GROUP BY s.district_id;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, region TEXT, donation_amount DECIMAL(10,2)); INSERT INTO donors (id, name, region, donation_amount) VALUES (1, 'John Smith', 'Asia-Pacific', 500.00), (2, 'Jane Doe', 'North America', 1000.00);
What's the average donation amount per donor in the Asia-Pacific region?
SELECT AVG(donation_amount) FROM donors WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityEducationPrograms (id INT PRIMARY KEY, program_name VARCHAR(50), location VARCHAR(50), participants INT);
List all the community education programs, their locations, and the number of participants, sorted by the number of participants in descending order.
SELECT program_name, location, participants FROM CommunityEducationPrograms ORDER BY participants DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(20)); INSERT INTO players (id, name) VALUES (1, 'John'); INSERT INTO players (id, name) VALUES (2, 'Jane'); CREATE TABLE fps_games (id INT, player_id INT, title VARCHAR(20)); INSERT INTO fps_games (id, player_id, title) VALUES (1, 1, 'Call of Duty'); INSERT INTO fps_games (id, player_id, title) VALUES (2, 2, 'Battlefield'); CREATE TABLE rpg_games (id INT, player_id INT, title VARCHAR(20)); INSERT INTO rpg_games (id, player_id, title) VALUES (1, 1, 'World of Warcraft'); INSERT INTO rpg_games (id, player_id, title) VALUES (2, 2, 'Elder Scrolls');
List of players who have played both FPS and RPG games?
SELECT players.name FROM players INNER JOIN fps_games ON players.id = fps_games.player_id INNER JOIN rpg_games ON players.id = rpg_games.player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, age INT, team TEXT, position TEXT); INSERT INTO players (id, name, age, team, position) VALUES (1, 'Alex Garcia', 30, 'Team C', 'Goalkeeper'); INSERT INTO players (id, name, age, team, position) VALUES (2, 'Benjamin Davis', 27, 'Team D', 'Defender');
What is the average age of goalkeepers in the league?
SELECT AVG(age) FROM players WHERE position = 'Goalkeeper';
gretelai_synthetic_text_to_sql
CREATE TABLE compliance_scores (supplier_id INT, supplier_name VARCHAR(255), compliance_score INT); INSERT INTO compliance_scores (supplier_id, supplier_name, compliance_score) VALUES (1, 'Supplier A', 90), (2, 'Supplier B', 85), (3, 'Supplier C', 95), (4, 'Supplier D', 80), (5, 'Supplier E', 92), (6, 'Supplier F', 88), (7, 'Supplier G', 75);
What is the trend of ethical labor practices compliance scores for the top 5 suppliers?
SELECT supplier_name, compliance_score, ROW_NUMBER() OVER (ORDER BY compliance_score DESC) as rank FROM compliance_scores WHERE supplier_id IN (SELECT supplier_id FROM compliance_scores WHERE compliance_score IS NOT NULL ORDER BY compliance_score DESC FETCH FIRST 5 ROWS ONLY);
gretelai_synthetic_text_to_sql
CREATE TABLE public_parks (name VARCHAR(255), city VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO public_parks (name, city, budget) VALUES ('Discovery Park', 'Seattle', 2500000.00), ('Green Lake Park', 'Seattle', 1500000.00), ('Gas Works Park', 'Seattle', 1000000.00);
What is the average budget allocated to public parks in the city of Seattle?
SELECT AVG(budget) FROM public_parks WHERE city = 'Seattle' AND name = 'public parks';
gretelai_synthetic_text_to_sql
CREATE TABLE athlete (id INT, name VARCHAR(50), team VARCHAR(50));
Insert a new record in the athlete table with the following data: id=10, name='Alex Rodriguez', team='New York Yankees'.
INSERT INTO athlete (id, name, team) VALUES (10, 'Alex Rodriguez', 'New York Yankees');
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (Country VARCHAR(50), Population INT, WasteGeneration FLOAT); INSERT INTO WasteGeneration (Country, Population, WasteGeneration) VALUES ('Germany', 83166711, 41.5), ('France', 67060000, 36.1), ('Italy', 59300000, 52.3), ('Spain', 47351247, 48.3), ('Poland', 37957193, 32.4);
What is the average waste generation per capita in the European region, limited to countries with a population over 10 million?
SELECT AVG(WasteGeneration) FROM WasteGeneration WHERE Population > 10000000 AND Region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_policies (policy_name VARCHAR(255), policy_date DATE);
Which energy efficiency policies in the 'energy_efficiency_policies' table were implemented in 2018 or later?
SELECT policy_name FROM energy_efficiency_policies WHERE policy_date >= '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Safety (id INT PRIMARY KEY, flight_number VARCHAR(100), incident_date DATE, incident_type VARCHAR(100)); INSERT INTO Flight_Safety (id, flight_number, incident_date, incident_type) VALUES (1, 'UA 123', '2019-06-13', 'Emergency Landing'); INSERT INTO Flight_Safety (id, flight_number, incident_date, incident_type) VALUES (2, 'DL 456', '2020-07-22', 'Technical Failure'); INSERT INTO Flight_Safety (id, flight_number, incident_date, incident_type) VALUES (7, 'AA 789', '2021-07-25', 'Lightning Strike');
Show the flight numbers and incident types for all incidents that occurred in the second half of 2021.
SELECT flight_number, incident_type FROM Flight_Safety WHERE incident_date >= '2021-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE If Not Exists community_development (community_id INT, community_name TEXT, location TEXT, development_stage TEXT); INSERT INTO community_development (community_id, community_name, location, development_stage) VALUES (4, 'Community D', 'Somalia', 'Planning'), (5, 'Community E', 'Sudan', 'Planning');
How many communities are in the 'Planning' stage for each country?
SELECT location, COUNT(*) as num_communities FROM community_development WHERE development_stage = 'Planning' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Manufacturing(manufacturer VARCHAR(20), year INT, quantity INT); INSERT INTO Spacecraft_Manufacturing(manufacturer, year, quantity) VALUES ('SpaceCorp', 2015, 120), ('SpaceCorp', 2016, 150), ('SpaceCorp', 2017, 175), ('Galactic Inc', 2015, 110), ('Galactic Inc', 2016, 145), ('Galactic Inc', 2017, 180);
Find the number of spacecraft manufactured by 'SpaceCorp' between 2015 and 2017
SELECT SUM(quantity) FROM Spacecraft_Manufacturing WHERE manufacturer = 'SpaceCorp' AND year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO warehouse (id, name, location) VALUES (1, 'Warehouse A', 'City A'), (2, 'Warehouse B', 'City B'); CREATE TABLE inventory (id INT, warehouse_id INT, product VARCHAR(50), quantity INT); INSERT INTO inventory (id, warehouse_id, product, quantity) VALUES (1, 1, 'Product X', 300), (2, 1, 'Product Y', 400), (3, 2, 'Product X', 500), (4, 2, 'Product Z', 200); CREATE TABLE product (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO product (id, name, category) VALUES (1, 'Product X', 'Category A'), (2, 'Product Y', 'Category B'), (3, 'Product Z', 'Category C');
How many items are stored for each product across all warehouses?
SELECT p.name, SUM(i.quantity) as total_quantity FROM inventory i JOIN product p ON i.product = p.name GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE open_education_resources (resource_id INT PRIMARY KEY, title VARCHAR(100), description TEXT, license VARCHAR(50));
Delete records with a 'resource_id' of 701 from the 'open_education_resources' table
DELETE FROM open_education_resources WHERE resource_id = 701;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, dish_name VARCHAR(50), dish_type VARCHAR(50), price DECIMAL(5,2), sales INT, location VARCHAR(50));
What is the average price of 'Steak' dishes in the 'Westside' location?
SELECT AVG(price) FROM menus WHERE dish_type = 'Steak' AND location = 'Westside';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_violations (id INT, year INT, industry VARCHAR(255), violation_count INT); INSERT INTO safety_violations (id, year, industry, violation_count) VALUES (1, 2022, 'transportation', 20), (2, 2021, 'transportation', 18), (3, 2022, 'construction', 12);
What is the total number of workplace safety violations in the 'transportation' schema for the year '2022'?
SELECT SUM(violation_count) FROM safety_violations WHERE industry = 'transportation' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE sector_vulnerabilities (id INT, cve_id VARCHAR(255), sector VARCHAR(255), severity VARCHAR(255), publish_date DATE, description TEXT); INSERT INTO sector_vulnerabilities (id, cve_id, sector, severity, publish_date, description) VALUES (1, 'CVE-2021-1234', 'Financial', 'CRITICAL', '2021-01-01', 'Description of CVE-2021-1234');
What are the details of the top 5 most critical vulnerabilities in software products used in the financial sector?
SELECT * FROM sector_vulnerabilities WHERE sector = 'Financial' AND severity = 'CRITICAL' LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Fares (id INT, vehicle_type VARCHAR(10), fare DECIMAL(5,2)); INSERT INTO Fares (id, vehicle_type, fare) VALUES (1, 'Bus', 2.50), (2, 'Tram', 3.00), (3, 'Train', 5.00);
What is the total fare collected from buses and trams?
SELECT SUM(fare) FROM Fares WHERE vehicle_type IN ('Bus', 'Tram');
gretelai_synthetic_text_to_sql
CREATE TABLE feedback (id INT, service VARCHAR(20), rating INT, comment TEXT); INSERT INTO feedback (id, service, rating, comment) VALUES (1, 'Parks and Recreation', 5, 'Great job!'), (2, 'Parks and Recreation', 3, 'Could improve'), (3, 'Waste Management', 4, 'Good but room for improvement'), (4, 'Libraries', 5, 'Awesome!'), (5, 'Libraries', 4, 'Very helpful'), (6, 'Transportation', 2, 'Needs work');
How many feedback records were received for each public service?
SELECT service, COUNT(*) as total_records FROM feedback GROUP BY service;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_substances (substance_id INT, substance_name VARCHAR(255)); INSERT INTO chemical_substances (substance_id, substance_name) VALUES (1, 'SubstanceA'), (2, 'SubstanceB'), (3, 'SubstanceC'), (4, 'SubstanceD');
What are the names of all chemical substances in the chemical_substances table that have 'A' as the second letter of their substance name?
SELECT substance_name FROM chemical_substances WHERE SUBSTRING(substance_name, 2, 1) = 'A';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(20)); INSERT INTO employees (id, name, department) VALUES (1, 'Anna Smith', 'News'), (2, 'John Doe', 'News'), (3, 'Sara Connor', 'News'), (4, 'Mike Johnson', 'Sports'), (5, 'Emma White', 'Sports'), (6, 'Alex Brown', 'IT');
List all departments with more than 5 employees in the "employees" table.
SELECT department FROM employees GROUP BY department HAVING COUNT(*) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(50), specialty VARCHAR(50));
Delete the record for the provider with ID 12345 from the 'providers' table
DELETE FROM providers WHERE id = 12345;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, genre VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Concerts (id, genre, price) VALUES (1, 'Classical', 100.00), (2, 'Pop', 60.00), (3, 'Classical', 120.00);
What is the maximum ticket price for a Classical concert?
SELECT MAX(price) FROM Concerts WHERE genre = 'Classical';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicle (id INT, make VARCHAR(255), model VARCHAR(255), range FLOAT, country VARCHAR(255)); INSERT INTO ElectricVehicle (id, make, model, range, country) VALUES (1, 'BYD', 'Han', 300, 'China');
What is the average range of electric vehicles manufactured in China?
SELECT AVG(range) FROM ElectricVehicle WHERE country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_unions (id INT, union_name VARCHAR(50), members INT); CREATE TABLE safety_records (id INT, union_id INT, safety_score INT);
Show the union name and safety record for unions with a safety record over 85 from the 'labor_unions' and 'safety_records' tables
SELECT l.union_name, s.safety_score FROM labor_unions l JOIN safety_records s ON l.id = s.union_id WHERE s.safety_score > 85;
gretelai_synthetic_text_to_sql
CREATE TABLE FishRegion (region VARCHAR(10), fish_count INT, survival_rate FLOAT); INSERT INTO FishRegion (region, fish_count, survival_rate) VALUES ('Region1', 500, 92), ('Region2', 800, 88), ('Region3', 650, 95), ('Region4', 700, 85);
Count the number of fish in each region that have a survival rate above 90%?
SELECT region, COUNT(fish_count) FROM FishRegion WHERE survival_rate > 90 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_species (id, name, species, region) VALUES (1, 'Atlantic Cod', 'Gadus morhua', 'North Atlantic'), (2, 'Greenland Shark', 'Somniosus microcephalus', 'North Atlantic'); CREATE TABLE endangered_species (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), region VARCHAR(255)); INSERT INTO endangered_species (id, name, species, region) VALUES (1, 'Blue Whale', 'Balaenoptera musculus', 'North Atlantic');
What are the names of the marine species that are found in the same regions as endangered species?
SELECT m.name, e.name FROM marine_species m INNER JOIN endangered_species e ON m.region = e.region WHERE e.name = 'Blue Whale';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_materials (id INT PRIMARY KEY, brand VARCHAR(255), material_type VARCHAR(255), quantity INT); INSERT INTO sustainable_materials (id, brand, material_type, quantity) VALUES (1, 'EcoFriendlyFashions', 'Organic Cotton', 5000), (2, 'EcoFriendlyFashions', 'Recycled Polyester', 3000), (3, 'GreenThreads', 'Organic Cotton', 4000), (4, 'GreenThreads', 'Tencel', 6000); CREATE TABLE countries (id INT PRIMARY KEY, country VARCHAR(255)); INSERT INTO countries (id, country) VALUES (1, 'USA'), (2, 'UK'), (3, 'France');
What is the total quantity of sustainable materials used in production, grouped by country and material type, for the ethical fashion brand 'EcoFriendlyFashions'?
SELECT c.country, sm.material_type, SUM(sm.quantity) as total_quantity FROM sustainable_materials sm JOIN countries c ON sm.brand = c.country GROUP BY c.country, sm.material_type HAVING sm.brand = 'EcoFriendlyFashions';
gretelai_synthetic_text_to_sql
CREATE TABLE ClimateFinance (ID INT, Country VARCHAR(255), Amount DECIMAL(10,2)); INSERT INTO ClimateFinance (ID, Country, Amount) VALUES (1, 'Palau', 10000), (2, 'Fiji', 15000), (3, 'Marshall Islands', 12000), (4, 'Papua New Guinea', 18000), (5, 'Samoa', 14000);
What is the total amount of climate finance committed to Pacific Island countries?
SELECT SUM(Amount) FROM ClimateFinance WHERE Country IN ('Palau', 'Fiji', 'Marshall Islands', 'Papua New Guinea', 'Samoa');
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, country VARCHAR(255), region VARCHAR(255), accommodation_type VARCHAR(255), count INT); INSERT INTO accommodations (id, country, region, accommodation_type, count) VALUES (1, 'Brazil', 'Northeast', 'Braille Materials', 80); INSERT INTO accommodations (id, country, region, accommodation_type, count) VALUES (2, 'Brazil', 'Southeast', 'Accessible Furniture', 140);
What is the total number of accommodations provided in Brazil by region?
SELECT region, SUM(count) as total_count FROM accommodations WHERE country = 'Brazil' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgressBank (id INT, customer_age INT, financial_wellbeing_score INT); INSERT INTO ProgressBank (id, customer_age, financial_wellbeing_score) VALUES (1, 35, 70), (2, 45, 65);
What is the average financial wellbeing score for customers aged 30-40 in Progress Bank?
SELECT AVG(financial_wellbeing_score) FROM ProgressBank WHERE customer_age BETWEEN 30 AND 40;
gretelai_synthetic_text_to_sql
CREATE TABLE pga_tour (id INT, player VARCHAR(100), birdies INT, tour BOOLEAN); INSERT INTO pga_tour (id, player, birdies, tour) VALUES (1, 'Tiger Woods', 200, true), (2, 'Phil Mickelson', 150, true), (3, 'Rory McIlroy', 250, true);
Who are the top 3 players in the 2022 PGA Tour with the most birdies?
SELECT player, birdies FROM pga_tour WHERE tour = true ORDER BY birdies DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings(building_id INT, height FLOAT, location VARCHAR(255)); INSERT INTO Buildings VALUES(1,35.5,'CityA'),(2,28.0,'CityB'),(3,40.0,'CityC'),(4,32.0,'CityD'),(5,45.0,'CityE'),(6,25.0,'CityF');
What is the total number of buildings in 'Buildings' table taller than 30 meters?
SELECT COUNT(*) FROM Buildings WHERE height > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities.buildings (id INT, city VARCHAR(255), co2_emissions INT, reduction_percentage DECIMAL(5,2)); CREATE VIEW smart_cities.buildings_view AS SELECT id, city, co2_emissions, reduction_percentage FROM smart_cities.buildings;
Get the city name and the percentage of buildings that have a CO2 emissions reduction percentage higher than 10%.
SELECT city, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM smart_cities.buildings_view b2 WHERE b1.city = b2.city) as percentage FROM smart_cities.buildings_view b1 WHERE reduction_percentage > 10.0 GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE artists_data (id INT, artist_name VARCHAR(255), art_pieces INT); INSERT INTO artists_data (id, artist_name, art_pieces) VALUES (1, 'Salvador Dalí', 1500), (2, 'Frida Kahlo', 2000), (3, 'Pablo Picasso', 3000);
Calculate the average number of art pieces per artist in the 'artists_data' table.
SELECT AVG(art_pieces) FROM artists_data;
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_diseases (id INT, state VARCHAR(50), disease VARCHAR(50)); INSERT INTO infectious_diseases (id, state, disease) VALUES (1, 'State A', 'Disease A'), (2, 'State A', 'Disease B'), (3, 'State B', 'Disease A');
What is the total number of infectious diseases reported in each state?
SELECT state, COUNT(DISTINCT disease) FROM infectious_diseases GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE vendor (id INT PRIMARY KEY, name TEXT, contact_person TEXT, company_id INT, FOREIGN KEY (company_id) REFERENCES company(id)); INSERT INTO vendor (id, name, contact_person, company_id) VALUES (2, 'BioVendor', 'Alice Johnson', 3); INSERT INTO company (id, name, industry, location) VALUES (3, 'BioZone', 'Healthcare', 'San Francisco');
Who is the contact person for all vendors from companies located in 'San Francisco'?
SELECT c.name, v.name, v.contact_person FROM vendor v INNER JOIN company c ON v.company_id = c.id WHERE c.location = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE violations (id INT, city VARCHAR(255), date DATE, type VARCHAR(255), description TEXT); INSERT INTO violations (id, city, date, type, description) VALUES (1, 'Toronto', '2021-01-01', 'Speeding', 'Exceeding the speed limit'), (2, 'Toronto', '2021-02-01', 'Parking', 'Parking in a no-parking zone');
What is the total number of traffic violations in Toronto in the year 2021, and what was the most common type?
SELECT COUNT(*) FROM violations WHERE city = 'Toronto' AND YEAR(date) = 2021; SELECT type, COUNT(*) FROM violations WHERE city = 'Toronto' AND YEAR(date) = 2021 GROUP BY type ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE factories(factory_id INT, name TEXT, location TEXT, industry40 BOOLEAN);
What are the names and locations of all factories that have implemented Industry 4.0?
SELECT name, location FROM factories WHERE industry40 = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_data (id INT PRIMARY KEY, sample_id INT, gene_sequence TEXT, date DATE); INSERT INTO genetic_data (id, sample_id, gene_sequence, date) VALUES (1, 1001, 'ATGCGAT...', '2021-01-01'), (2, 1002, 'CGATCG...', '2021-01-02'), (3, 1003, 'ATCGATG...', '2021-01-16'), (4, 1004, 'GCGACTA...', '2021-02-01'), (5, 1005, 'CTAGTC...', '2021-03-15');
List the genetic data samples with gene sequences starting with 'GC' or 'CT' and sorted by the sample ID.
SELECT sample_id, gene_sequence FROM genetic_data WHERE gene_sequence LIKE 'GC%' OR gene_sequence LIKE 'CT%' ORDER BY sample_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Disasters (disaster_id INT, name VARCHAR(255), type VARCHAR(255), affected_people INT, region VARCHAR(255), date DATE); INSERT INTO Disasters (disaster_id, name, type, affected_people, region, date) VALUES (1, 'Floods', 'Hydrological', 800, 'Asia', '2018-01-01');
What are the names and types of disasters that have impacted more than 200 people in the 'Europe' region, with no limitation on the date?
SELECT name, type FROM Disasters WHERE region = 'Europe' AND affected_people > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE RealEstateCoOwnership.Properties (id INT, price FLOAT); INSERT INTO RealEstateCoOwnership.Properties (id, price) VALUES (1, 400000.0), (2, 600000.0); CREATE TABLE RealEstateCoOwnership.CoOwnership (property_id INT, coowner VARCHAR(50)); INSERT INTO RealEstateCoOwnership.CoOwnership (property_id, coowner) VALUES (1, 'John'), (1, 'Jane'), (2, 'Bob');
What is the minimum property price for properties in the RealEstateCoOwnership schema that have co-owners?
SELECT MIN(price) FROM RealEstateCoOwnership.Properties INNER JOIN RealEstateCoOwnership.CoOwnership ON Properties.id = CoOwnership.property_id;
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSourcing (id INT, country VARCHAR(255), fabric_type VARCHAR(255), quantity INT); INSERT INTO TextileSourcing (id, country, fabric_type, quantity) VALUES (1, 'France', 'Organic Cotton', 5000), (2, 'Italy', 'Recycled Polyester', 7000), (3, 'Spain', 'Tencel', 6000);
What is the total quantity of sustainable fabric used by each country?
SELECT country, SUM(quantity) as total_quantity FROM TextileSourcing WHERE fabric_type IN ('Organic Cotton', 'Recycled Polyester', 'Tencel') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Expenses (id INT, quarter DATE, expense_category VARCHAR(255), amount INT); INSERT INTO Expenses (id, quarter, expense_category, amount) VALUES (1, '2022-01-01', 'exploration', 1000), (2, '2022-01-15', 'equipment', 2000), (3, '2022-04-01', 'exploration', 1500);
What was the total amount spent on 'exploration' in the 'Expenses' table for 'Q1 2022'?
SELECT SUM(amount) FROM Expenses WHERE quarter BETWEEN '2022-01-01' AND '2022-03-31' AND expense_category = 'exploration';
gretelai_synthetic_text_to_sql
CREATE TABLE Libraries (library VARCHAR(50), state VARCHAR(20), branches INT); INSERT INTO Libraries (library, state, branches) VALUES ('LibraryA', 'California', 3), ('LibraryB', 'California', 4), ('LibraryC', 'Washington', 5);
List all the public libraries in the state of California and Washington, including their number of branches.
SELECT library, state, branches FROM Libraries WHERE state IN ('California', 'Washington');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT, country VARCHAR(255), event_name VARCHAR(255), year INT);
Get the number of defense diplomacy events that each country hosted in the last 3 years
SELECT country, COUNT(*) FROM defense_diplomacy WHERE year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_control_systems (id INT, name VARCHAR(255), last_assessment_date DATE, severity_score INT); INSERT INTO industrial_control_systems (id, name, last_assessment_date, severity_score) VALUES (1, 'ICS-A', '2021-11-15', 7), (2, 'ICS-B', '2021-12-03', 5), (3, 'ICS-C', '2021-12-10', 8);
What is the average severity score of vulnerabilities for industrial control systems in the past month?
SELECT AVG(severity_score) FROM industrial_control_systems WHERE last_assessment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (id INT, gender VARCHAR(10), race VARCHAR(30), department VARCHAR(50), total_count INT, hiring_rate DECIMAL(5,2));
Delete a diversity metric record from the "diversity_metrics" table
DELETE FROM diversity_metrics WHERE id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE Supplies (supply_id INT, supply_name VARCHAR(255), quantity INT, delivery_date DATE, service_area VARCHAR(255)); INSERT INTO Supplies (supply_id, supply_name, quantity, delivery_date, service_area) VALUES (1, 'Medical Kits', 50, '2020-01-01', 'Health Services');
What is the total number of supplies delivered to 'Health Services' in '2020'?
SELECT SUM(Supplies.quantity) FROM Supplies WHERE Supplies.service_area = 'Health Services' AND YEAR(Supplies.delivery_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE contractor (id INT, name TEXT); INSERT INTO contractor (id, name) VALUES (1, 'ACME Corp'); CREATE TABLE vehicle_manufacturing (contractor_id INT, manufacture_date DATE, quantity INT);
Find the number of military vehicles manufactured by contractor 'ACME Corp' in Q1 2022.
SELECT SUM(quantity) FROM vehicle_manufacturing WHERE contractor_id = 1 AND manufacture_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (line VARCHAR(10), station VARCHAR(20)); INSERT INTO routes (line, station) VALUES ('Blue', 'Station A'), ('Blue', 'Station B'), ('Yellow', 'Station C'), ('Yellow', 'Station D'); CREATE TABLE fares (station VARCHAR(20), revenue DECIMAL(10, 2)); INSERT INTO fares (station, revenue) VALUES ('Station A', 2000), ('Station B', 2500), ('Station C', 3000), ('Station D', 3500), ('Station A', 2200), ('Station B', 2800);
Which line has the lowest average fare collection per station?
SELECT line, AVG(revenue) AS avg_revenue FROM fares JOIN routes ON fares.station = routes.station GROUP BY line ORDER BY avg_revenue ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_data (make VARCHAR(50), model VARCHAR(50), year INT, auto_show VARCHAR(50));
List all vehicles in the 'vehicle_data' table that were showcased at the 'detroit_auto_show'.
SELECT * FROM vehicle_data WHERE auto_show = 'detroit_auto_show';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, region TEXT, occurred_at TIMESTAMP); INSERT INTO security_incidents (id, region, occurred_at) VALUES (1, 'North America', '2021-07-01 13:00:00'), (2, 'Europe', '2021-08-02 14:00:00'), (3, 'North America', '2021-10-01 15:00:00');
How many security incidents were there in the North America region in Q3 2021?
SELECT COUNT(*) FROM security_incidents WHERE region = 'North America' AND EXTRACT(QUARTER FROM occurred_at) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Content (ContentID int, ContentType varchar(50), LanguageID int); CREATE TABLE Languages (LanguageID int, LanguageName varchar(50)); INSERT INTO Languages (LanguageID, LanguageName) VALUES (1, 'English'), (2, 'Spanish'), (3, 'French'), (5, 'Chinese'); INSERT INTO Content (ContentID, ContentType, LanguageID) VALUES (1, 'Movie', 1), (2, 'Podcast', 2), (3, 'Blog', 3), (6, 'Blog', 5);
Delete all content in the 'Blog' content type and 'Chinese' language
DELETE FROM Content WHERE (ContentType, LanguageID) IN (('Blog', 3), ('Blog', 5));
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_id INT, name VARCHAR(255), description TEXT, sustainable BOOLEAN); INSERT INTO Menu (menu_id, name, description, sustainable) VALUES (1, 'Grilled Salmon', 'Wild-caught salmon with lemon butter sauce', TRUE), (2, 'Beef Burger', 'Hormone-free beef with lettuce, tomato, and mayo', FALSE), (3, 'Veggie Wrap', 'Grilled vegetables with hummus and spinach', TRUE);
Find menu items that are not sustainable.
SELECT name FROM Menu WHERE sustainable = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalAccessibilityEvents (event_id INT, event_name VARCHAR(255), event_date DATE); INSERT INTO DigitalAccessibilityEvents (event_id, event_name, event_date) VALUES (1001, 'Web Accessibility Workshop', '2022-05-15'), (1002, 'Accessible Document Training', '2022-06-30'), (1003, 'Screen Reader Basics', '2022-08-10');
How many policy advocacy events were held in the 'DigitalAccessibilityEvents' table, and what are their names?
SELECT event_name, COUNT(*) FROM DigitalAccessibilityEvents GROUP BY event_name;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (brand VARCHAR(50), items_produced INT, water_consumption FLOAT); INSERT INTO water_consumption (brand, items_produced, water_consumption) VALUES ('Brand I', 100000, 3000.00), ('Brand J', 150000, 2500.00), ('Brand K', 80000, 2000.00), ('Brand L', 120000, 1500.00), ('Brand M', 200000, 1200.00);
What is the average water consumption per item for the bottom 2 clothing brands using the most water?
SELECT AVG(water_consumption) FROM (SELECT brand, water_consumption FROM water_consumption ORDER BY water_consumption DESC LIMIT 2) as highest_water_users;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), sector VARCHAR(50), country VARCHAR(50)); INSERT INTO workers (id, name, sector, country) VALUES (1, 'John Doe', 'Industry 4.0', 'USA'), (2, 'Jane Smith', 'Industry 4.0', 'USA'), (3, 'Mike Johnson', 'Industry 4.0', 'Canada');
What is the total number of workers in the industry 4.0 sector in each country?
SELECT country, COUNT(*) FROM workers WHERE sector = 'Industry 4.0' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
Show the name and price of the least expensive menu item
SELECT name, MIN(price) FROM Menu;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), co2_emissions INT); INSERT INTO suppliers (id, name, co2_emissions) VALUES (1, 'Supplier A', 500), (2, 'Supplier B', 800), (3, 'Supplier C', 300);
What is the average CO2 emissions for each supplier in the 'suppliers' table?
SELECT name, AVG(co2_emissions) FROM suppliers GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT, Address TEXT); INSERT INTO Donors (DonorID, Name, Address) VALUES (1, 'John Doe', '123 Main St'); INSERT INTO Donors (DonorID, Name, Address) VALUES (2, 'Jane Smith', '456 Elm St'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL, DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 50.00, '2021-01-01'); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (2, 1, 75.00, '2021-03-15'); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (3, 2, 100.00, '2021-12-31');
Insert a new donation from donor with ID 1 for $100 on 2022-02-14.
INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (4, 1, 100.00, '2022-02-14');
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_training (organization VARCHAR(255), training_hours DECIMAL(10,2), training_date DATE);
What is the total amount of financial capability training conducted by each organization?
SELECT organization, SUM(training_hours) FROM financial_capability_training GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2), inventory_count INT);
Remove all records with category 'New' from the menu_items table
DELETE FROM menu_items WHERE category = 'New';
gretelai_synthetic_text_to_sql
CREATE TABLE patents (id INT, company VARCHAR(50), country VARCHAR(50), sector VARCHAR(50), year INT, renewable INT);
What is the maximum number of renewable energy patents filed by companies in Japan in the past 10 years?
SELECT MAX(renewable) FROM patents WHERE country = 'Japan' AND sector = 'Renewable Energy' AND year BETWEEN 2012 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE field (id INT, name VARCHAR(20)); CREATE TABLE rainfall (id INT, field_id INT, value INT, timestamp TIMESTAMP);
Which fields have had no rainfall in the past week?
SELECT f.name FROM field f LEFT JOIN rainfall r ON f.id = r.field_id AND r.timestamp >= NOW() - INTERVAL '1 week' WHERE r.value IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption_us (state VARCHAR, year INT, water_consumption FLOAT); INSERT INTO water_consumption_us (state, year, water_consumption) VALUES ('California', 2021, 50000000), ('Texas', 2021, 45000000), ('Florida', 2021, 40000000), ('New York', 2021, 35000000);
List the top 3 most water-consuming states in the United States in 2021.
SELECT state, water_consumption FROM water_consumption_us ORDER BY water_consumption DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE social_good_impact_africa (country VARCHAR(20), impacted INT); INSERT INTO social_good_impact_africa (country, impacted) VALUES ('Kenya', 120000), ('Nigeria', 150000), ('South Africa', 180000);
What is the average number of people impacted by social good technology initiatives in Africa?
SELECT AVG(impacted) FROM social_good_impact_africa WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_name VARCHAR(20), item_name VARCHAR(30), price DECIMAL(5,2));
Add a new menu category 'Gluten-Free' with a new menu item 'Chicken Caesar Salad' priced at 13.99
INSERT INTO Menu (menu_name, item_name, price) VALUES ('Gluten-Free', 'Chicken Caesar Salad', 13.99);
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage_gb FLOAT);
What is the average monthly data usage by mobile subscribers?
SELECT AVG(data_usage_gb) FROM mobile_subscribers;
gretelai_synthetic_text_to_sql
CREATE TABLE wastes (id INT, source VARCHAR(50), type VARCHAR(50), amount INT); INSERT INTO wastes (id, source, type, amount) VALUES (1, 'Fast Food Restaurant', 'Plastic', 50), (2, 'Fast Food Restaurant', 'Food', 30);
What is the total waste generated by fast food restaurants in the US?
SELECT SUM(amount) FROM wastes WHERE source = 'Fast Food Restaurant';
gretelai_synthetic_text_to_sql
CREATE TABLE threats (id INT, ip_address VARCHAR(255), severity VARCHAR(255)); INSERT INTO threats (id, ip_address, severity) VALUES (1, '192.168.1.1', 'High'), (2, '192.168.1.2', 'Medium'), (3, '192.168.1.3', 'Low');
List all the unique IP addresses associated with 'High' severity threats.
SELECT DISTINCT ip_address FROM threats WHERE severity = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_company_employees (company_name VARCHAR(255), num_employees INT, employee_date DATE); INSERT INTO mining_company_employees (company_name, num_employees, employee_date) VALUES ('Company A', 1000, '2021-08-01'), ('Company B', 2000, '2021-08-01'), ('Company C', 3000, '2021-08-01'), ('Company A', 1500, '2021-05-01'), ('Company B', 1800, '2021-05-01');
What is the average number of employees per mining company in the past quarter?
SELECT company_name, AVG(num_employees) as avg_num_employees FROM (SELECT company_name, num_employees, employee_date, ROW_NUMBER() OVER (PARTITION BY company_name ORDER BY employee_date DESC) as rn FROM mining_company_employees WHERE employee_date >= DATEADD(quarter, -1, CURRENT_DATE)) t WHERE rn = 1 GROUP BY company_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (Id INT, Gender VARCHAR(10)); CREATE TABLE Measurements (Id INT, MemberId INT, Weight DECIMAL(5,2), Date DATE); INSERT INTO Members (Id, Gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Female'), (4, 'Non-binary'); INSERT INTO Measurements (Id, MemberId, Weight, Date) VALUES (1, 1, 80.5, '2022-06-01'), (2, 1, 81.3, '2022-06-15'), (3, 2, 90.2, '2022-05-30'), (4, 3, 70.0, '2022-06-03'), (5, 4, 75.6, '2022-06-05');
How many male members have a recorded weight measurement in the month of June?
SELECT COUNT(DISTINCT MemberId) FROM Measurements INNER JOIN Members ON Measurements.MemberId = Members.Id WHERE DATE_FORMAT(Date, '%Y-%m') = '2022-06' AND Gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Country VARCHAR(50), LaborRating INT); INSERT INTO Brands (BrandID, BrandName, Country, LaborRating) VALUES (1, 'Brand1', 'Country1', 80), (2, 'Brand2', 'Country2', 90), (3, 'Brand3', 'Country1', 70);
Show the average labor rating of each country's brands.
SELECT Country, AVG(LaborRating) AS AvgLaborRating FROM Brands GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE mars_rovers (rover_id INT, rover_name VARCHAR(100), landing_date DATE);
List all rovers that have landed on Mars?
SELECT rover_name FROM mars_rovers WHERE landing_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (satellite_id INT, company VARCHAR(255), region VARCHAR(255));
What is the total number of satellites deployed by SpaceTech Corp in the Asia-Pacific region?
SELECT COUNT(*) FROM Satellites WHERE company = 'SpaceTech Corp' AND region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE concert_tours (concert_id INT, concert_name TEXT, artist_id INT, location TEXT, date DATE);
What is the total number of concerts for a specific artist in the 'concert_tours' table?
SELECT COUNT(*) FROM concert_tours WHERE artist_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents(id INT, incident_date DATE, location VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO incidents(id, incident_date, location, incident_type) VALUES (1, '2022-01-01', 'USA', 'Fire');
What is the number of unique countries with mining incidents in the 'incidents' table?
SELECT COUNT(DISTINCT SUBSTRING_INDEX(location, ' ', 1)) FROM incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2), start_date DATE); INSERT INTO Projects (id, name, type, budget, start_date) VALUES (1, 'Seawall', 'Resilience', 5000000.00, '2022-01-01'), (2, 'Floodgate', 'Resilience', 3000000.00, '2022-02-01'), (3, 'Bridge', 'Transportation', 8000000.00, '2021-12-01'), (4, 'Highway', 'Transportation', 12000000.00, '2022-03-15'); CREATE TABLE if not exists States (id INT, name VARCHAR(50)); INSERT INTO States (id, name) VALUES (1, 'California'), (2, 'Texas');
List all resilience projects in the state of Texas, along with their budgets and start dates.
SELECT name, budget, start_date FROM Projects INNER JOIN States ON Projects.id = 1 AND States.name = 'Texas' WHERE type = 'Resilience';
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Projects (Project_ID INT, Project_Name TEXT, Location TEXT, Cost FLOAT, Sustainable BOOLEAN); INSERT INTO Sustainable_Projects (Project_ID, Project_Name, Location, Cost, Sustainable) VALUES (1, 'Green House', 'California', 500000.00, true), (2, 'Eco Office', 'New York', 750000.00, true), (3, 'Solar Farm', 'Texas', 1000000.00, true);
What is the average cost of sustainable building projects in California?
SELECT AVG(Cost) FROM Sustainable_Projects WHERE Location = 'California' AND Sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), price DECIMAL(5,2), is_cruelty_free BOOLEAN, category VARCHAR(50));
What is the maximum price of nail polish products that are cruelty-free?
SELECT MAX(price) FROM products WHERE category = 'Nail Polish' AND is_cruelty_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT);
What is the maximum GPA of graduate students in the Computer Science department?
SELECT MAX(gs.gpa) FROM graduate_students gs WHERE gs.department = 'Computer Science';
gretelai_synthetic_text_to_sql
CREATE TABLE Viewership (ViewerID INT, ShowID INT, Episode INT, WatchDate DATE); INSERT INTO Viewership (ViewerID, ShowID, Episode, WatchDate) VALUES (1, 1, 1, '2022-01-01'); INSERT INTO Viewership (ViewerID, ShowID, Episode, WatchDate) VALUES (2, 2, 1, '2022-02-01'); INSERT INTO Viewership (ViewerID, ShowID, Episode, WatchDate) VALUES (3, 3, 1, '2022-02-15');
What is the total number of male and female viewers who watched shows in February?
SELECT COUNT(DISTINCT CASE WHEN EXTRACT(MONTH FROM WatchDate) = 2 THEN ViewerID END) as TotalViewers FROM Viewership;
gretelai_synthetic_text_to_sql
CREATE TABLE Humanitarian_Assistance (id INT, country VARCHAR(50), year INT); INSERT INTO Humanitarian_Assistance (id, country, year) VALUES (1, 'United States', 2018), (2, 'United States', 2019), (3, 'United States', 2020), (4, 'United Kingdom', 2018), (5, 'Canada', 2019), (6, 'Australia', 2020);
How many countries have been part of humanitarian assistance programs in the last 5 years?
SELECT COUNT(DISTINCT country) FROM Humanitarian_Assistance WHERE year BETWEEN YEAR(CURRENT_DATE)-5 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Production (tank VARCHAR(20), capacity INT, location VARCHAR(20)); INSERT INTO Production (tank, capacity, location) VALUES ('Tank9', 130000, 'Eastern'), ('Tank10', 140000, 'Eastern'), ('Tank11', 160000, 'Eastern');
What is the average production capacity of all tanks in the Eastern region?
SELECT AVG(capacity) FROM Production WHERE location = 'Eastern';
gretelai_synthetic_text_to_sql
CREATE TABLE Tourists (region TEXT, transport TEXT); INSERT INTO Tourists (region, transport) VALUES ('North', 'Train'), ('North', 'Plane'), ('South', 'Bus'), ('South', 'Car'), ('East', 'Train'), ('East', 'Bike'), ('West', 'Plane'), ('West', 'Car'); CREATE TABLE Tourist_Counts (region TEXT, count NUMERIC); INSERT INTO Tourist_Counts (region, count) VALUES ('North', 1000), ('South', 1500), ('East', 800), ('West', 1200);
What is the total number of tourists visiting each region and their preferred mode of transport?
SELECT T.region, T.transport, COUNT(T.region) as tourist_count FROM Tourists T JOIN Tourist_Counts TC ON T.region = TC.region GROUP BY T.region, T.transport;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, launch_date DATE, region VARCHAR(255)); INSERT INTO initiatives (id, launch_date, region) VALUES (1, '2017-01-01', 'Asia'), (2, '2018-05-15', 'Africa'), (3, '2019-09-03', 'Asia'), (4, '2020-02-20', 'Europe'), (5, '2021-07-07', 'Asia');
How many ethical AI initiatives were launched in Asia in the last 5 years?
SELECT COUNT(*) FROM initiatives WHERE region = 'Asia' AND launch_date >= '2016-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE region (id INTEGER, name TEXT);CREATE TABLE iot_sensor (id INTEGER, region_id INTEGER, installed_date DATE);
How many IoT sensors were installed in each region in the past month?
SELECT r.name, COUNT(s.id) as num_sensors FROM region r INNER JOIN iot_sensor s ON r.id = s.region_id WHERE s.installed_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Campaigns (CampaignID INT, Name VARCHAR(100), LaunchDate DATE, Budget DECIMAL(10,2));
How many public awareness campaigns were launched in the past 2 years and what was their total budget?
SELECT COUNT(*), SUM(Budget) FROM Campaigns WHERE LaunchDate >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, city VARCHAR(50), year INT, ticket_price DECIMAL(5,2));INSERT INTO Exhibitions (id, city, year, ticket_price) VALUES (1, 'Tokyo', 2021, 40.00), (2, 'Tokyo', 2021, 35.00), (3, 'Tokyo', 2020, 30.00);
What was the highest ticket price for an exhibition in Tokyo in 2021?
SELECT MAX(ticket_price) FROM Exhibitions WHERE city = 'Tokyo' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_labor_practices_transparent BOOLEAN, is_circular_supply_chain BOOLEAN, price DECIMAL); INSERT INTO products (product_id, product_name, is_labor_practices_transparent, is_circular_supply_chain, price) VALUES (1, 'Eco-Friendly Notebook', TRUE, TRUE, 5.99), (2, 'Sustainable Sneakers', FALSE, TRUE, 129.99), (3, 'Handmade Jewelry', TRUE, FALSE, 89.99);
What is the minimum price of any product that is transparent about its labor practices and produced using circular supply chains?
SELECT MIN(price) FROM products WHERE is_labor_practices_transparent = TRUE AND is_circular_supply_chain = TRUE;
gretelai_synthetic_text_to_sql