context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE public.ambulances (id SERIAL PRIMARY KEY, city VARCHAR(255), num_ambulances INTEGER); INSERT INTO public.ambulances (city, num_ambulances) VALUES ('Los Angeles', 300), ('New York', 500), ('Chicago', 400); | What is the total number of ambulances in the city of Los Angeles? | SELECT num_ambulances FROM public.ambulances WHERE city = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, service VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers (id, service, region) VALUES (1, 'broadband', 'West'), (2, 'mobile', 'West'); CREATE TABLE speeds (subscriber_id INT, connection_speed INT); INSERT INTO speeds (subscriber_id, connection_speed) VALUES (1, 550), (2, 450); | What is the minimum connection speed in Mbps for broadband customers in the West region? | SELECT MIN(connection_speed) FROM speeds JOIN subscribers ON speeds.subscriber_id = subscribers.id WHERE subscribers.service = 'broadband' AND subscribers.region = 'West'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipment_details (shipment_id INT, package_id INT, weight DECIMAL(5,2), destination_state TEXT); | What is the total weight of packages shipped to California from the 'shipment_details' table? | SELECT SUM(weight) FROM shipment_details WHERE destination_state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE local_events (event_id INT, event_name TEXT, location TEXT, cause TEXT); INSERT INTO local_events (event_id, event_name, location, cause) VALUES (1, 'Festival of Diversity', 'India', 'Women''s Empowerment'), (2, 'Sustainable Fashion Show', 'Mexico', 'Sustainable Development'); | How many local events in India and Mexico support women's empowerment and sustainable development? | SELECT COUNT(*) FROM local_events WHERE location IN ('India', 'Mexico') AND cause IN ('Women''s Empowerment', 'Sustainable Development'); | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (bridge_id INT, bridge_name VARCHAR(50), location VARCHAR(50), length DECIMAL(10,2), construction_date DATE); | List all the bridges built before 2010, sorted by construction date. | SELECT * FROM bridges WHERE construction_date < '2010-01-01' ORDER BY construction_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE client_transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO client_transactions (transaction_id, client_id, amount, transaction_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 1, 100.00, '2022-01-15'), (3, 2, 75.00, '2022-02-03'), (4, 3, 120.00, '2022-03... | What is the total transaction amount per month for clients in the Southeast region? | SELECT DATE_FORMAT(transaction_date, '%Y-%m') AS month, SUM(amount) FROM client_transactions ct JOIN clients cl ON ct.client_id = cl.client_id WHERE cl.region = 'Southeast' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id int, material varchar(20)); INSERT INTO products (product_id, material) VALUES (1, 'organic cotton'), (2, 'recycled polyester'), (3, 'organic cotton'), (4, 'recycled cotton'); | How many products are made from each type of material? | SELECT material, COUNT(*) FROM products GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Warehouse I', 'EMEA'), (2, 'Warehouse J', 'APAC'); | Calculate the average weight of packages shipped from warehouses in the 'Americas' and 'APAC' regions | SELECT AVG(weight) FROM packages JOIN warehouses ON packages.warehouse_id = warehouses.id WHERE region IN ('Americas', 'APAC'); | gretelai_synthetic_text_to_sql |
CREATE TABLE physical_inactivity (age_group VARCHAR(10), pct_inactive FLOAT); INSERT INTO physical_inactivity (age_group, pct_inactive) VALUES ('0-9', 25), ('10-19', 30), ('20-29', 40), ('30-39', 45), ('40-49', 50); | What is the percentage of the population that is physically inactive, by age group? | SELECT age_group, (SUM(pct_inactive) / COUNT(age_group) * 100) as pct_inactive FROM physical_inactivity GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_rehabilitation (animal_id INT, species VARCHAR(255), admission_date DATE); INSERT INTO animal_rehabilitation (animal_id, species, admission_date) VALUES (1, 'Tiger', '2020-01-01'), (2, 'Tiger', '2019-01-01'), (3, 'Elephant', '2020-01-01'); | How many animals of each species were admitted to the 'animal_rehabilitation' table in the year 2020? | SELECT species, COUNT(animal_id) as count_2020 FROM animal_rehabilitation WHERE YEAR(admission_date) = 2020 GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE bioprocess(id INT, investment VARCHAR(50), date DATE, amount DECIMAL(10,2)); INSERT INTO bioprocess VALUES (1, 'InvestmentA', '2021-04-15', 2000000.00), (2, 'InvestmentB', '2021-06-30', 1500000.00), (3, 'InvestmentC', '2021-02-28', 2500000.00); | What is the total investment in bioprocess engineering in H1 2021? | SELECT SUM(amount) FROM bioprocess WHERE date BETWEEN '2021-01-01' AND '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtCollections (CollectionID INT PRIMARY KEY, CollectionName VARCHAR(50), ArtistID INT, FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)); INSERT INTO ArtCollections (CollectionID, CollectionName, ArtistID) VALUES (1, 'Asian Art Collection', 1); | What is the name of artists who have contributed to the 'Asian Art Collection'? | SELECT Artists.ArtistName FROM Artists INNER JOIN ArtCollections ON Artists.ArtistID = ArtCollections.ArtistID WHERE ArtCollections.CollectionName = 'Asian Art Collection'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name VARCHAR(255), state VARCHAR(255)); CREATE TABLE union_industry (id INT, union_id INT, industry VARCHAR(255), workers INT); INSERT INTO unions (id, name, state) VALUES (1, 'TEAMSTERS', 'New York'); INSERT INTO union_industry (id, union_id, industry, workers) VALUES (1, 1, 'Transportatio... | What is the average number of workers in each union by industry in New York? | SELECT ui.industry, AVG(ui.workers) as avg_workers FROM union_industry ui JOIN unions u ON ui.union_id = u.id WHERE u.state = 'New York' GROUP BY ui.industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE Donations (DonationID INT, ProgramID INT); INSERT INTO Donations (DonationID, ProgramID) VALUES (1, 1), (2, 1), (3, 2); | Which programs do not have any donations? | SELECT ProgramID, ProgramName FROM Programs WHERE ProgramID NOT IN (SELECT ProgramID FROM Donations); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, subscription_type VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id, subscription_type) VALUES (1, 'Postpaid'), (2, 'Prepaid'); | What is the total number of mobile subscribers for each mobile subscription type? | SELECT subscription_type, COUNT(*) FROM mobile_subscribers GROUP BY subscription_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE nutrition (country VARCHAR(255), calories INT, meal_time TIME); INSERT INTO nutrition (country, calories, meal_time) VALUES ('USA', 800, 'Breakfast'), ('USA', 1200, 'Lunch'), ('USA', 500, 'Dinner'); | What is the difference in calorie intake between the earliest and latest meal times in the 'nutrition' table? | SELECT MAX(meal_time_calories) - MIN(meal_time_calories) as calorie_difference FROM (SELECT meal_time, SUM(calories) as meal_time_calories FROM nutrition GROUP BY meal_time) as subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (Id INT, Name VARCHAR(50)); CREATE TABLE Cargo (VesselId INT, Weight FLOAT); INSERT INTO Vessels (Id, Name) VALUES (1, 'Vessel1'), (2, 'Vessel2'), (3, 'Vessel3'); INSERT INTO Cargo (VesselId, Weight) VALUES (1, 15000), (1, 12000), (2, 18000), (3, 20000), (3, 25000); | Find the vessel with the highest total cargo weight | SELECT Vessels.Name, SUM(Cargo.Weight) AS TotalCargoWeight FROM Vessels JOIN Cargo ON Vessels.Id = Cargo.VesselId GROUP BY Vessels.Id ORDER BY TotalCargoWeight DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryDefenseDiplomacy (id INT, country VARCHAR(50), num_operations INT); | What is the minimum number of defense diplomacy operations participated in by each country? | SELECT country, MIN(num_operations) FROM CountryDefenseDiplomacy GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (id INT PRIMARY KEY, team VARCHAR(50), event_date DATE, tickets_sold INT, total_sales DECIMAL(10,2)); | Insert ticket sales records into the "ticket_sales" table for the event held in Dallas | INSERT INTO ticket_sales (id, team, event_date, tickets_sold, total_sales) VALUES (1, 'Cowboys', '2022-08-15', 2500, 75000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding_Allocation (id INT, project VARCHAR(30), funding FLOAT); | Increase the 'funding' for a specific project by 10% in the 'Funding_Allocation' table. | UPDATE Funding_Allocation SET funding = funding * 1.10 WHERE project = 'Arctic Biodiversity Monitoring'; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_budget (state VARCHAR(20), school_district VARCHAR(20), budget INT); INSERT INTO education_budget (state, school_district, budget) VALUES ('Texas', 'Dallas ISD', 4000000); INSERT INTO education_budget (state, school_district, budget) VALUES ('Texas', 'Houston ISD', 6000000); INSERT INTO education... | What is the total budget allocated for education in the state of Texas, excluding school districts with a budget over 5 million? | SELECT SUM(budget) FROM education_budget WHERE state = 'Texas' AND school_district NOT IN (SELECT school_district FROM education_budget WHERE state = 'Texas' GROUP BY school_district HAVING SUM(budget) > 5000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (age_group VARCHAR(10), num_cases INT); INSERT INTO cases (age_group, num_cases) VALUES ('0-9', 1500), ('10-19', 2000), ('20-29', 3000), ('30-39', 2500), ('40-49', 2200); | What is the total number of infectious disease cases, by age group? | SELECT age_group, SUM(num_cases) as total_cases FROM cases GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmer_support_program (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50), support_granted INT); | What's the total number of farmers who received support in the 'farmer_support_program' table? | SELECT SUM(support_granted) FROM farmer_support_program WHERE support_granted = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(255), attendees INT); INSERT INTO Events (event_id, event_name, attendees) VALUES (1, 'Music Festival', 800), (2, 'Art Exhibition', 500); CREATE TABLE Attendee_Demographics (attendee_id INT, attendee_race VARCHAR(255), event_id INT); INSERT INTO Attendee_Demographic... | How many visitors identified as BIPOC attended the 'Music Festival' event? | SELECT COUNT(*) FROM Attendee_Demographics AD JOIN Events E ON AD.event_id = E.event_id WHERE E.event_name = 'Music Festival' AND AD.attendee_race IN ('Hispanic', 'African American', 'Asian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (id INT, route_id INT, fare FLOAT, distance FLOAT); INSERT INTO fares (id, route_id, fare, distance) VALUES (3002, 102, 4.0, 40.0), (3003, 103, 3.0, 35.0); | What is the average fare per kilometer for route 102 and 103? | SELECT route_id, AVG(fare / distance) as avg_fare_per_km FROM fares GROUP BY route_id HAVING route_id IN (102, 103); | 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, 2018, 'Jacksonville', 1234.56), (2, 2018, 'Austin', 3567.89), (3, 2018, 'Albuquerque', 1890.12), (4, 2018, 'Atlanta', 987.65), (5, 2018, 'Baltimore', 1567.89); | Find the number of times water usage exceeded 2000 cubic meters for each location in the year 2018 | SELECT location, COUNT(*) FROM water_usage WHERE year = 2018 AND usage > 2000 GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE routes (route_id INT, route_name VARCHAR(255)); INSERT INTO routes (route_id, route_name) VALUES (1, 'Green Line'), (2, 'Blue Line'), (3, 'Orange Line'); CREATE TABLE fares (route_id INT, payment_type VARCHAR(255)); INSERT INTO fares (route_id, payment_type) VALUES (1, 'credit_card'), (1, 'cash'), (2, 'c... | What are the unique payment types for each route? | SELECT r.route_name, f.payment_type FROM routes r JOIN fares f ON r.route_id = f.route_id GROUP BY r.route_name, f.payment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_ai.ai_applications (ai_application_id INT PRIMARY KEY, ai_algorithm_id INT, application_name VARCHAR(255), fairness_score FLOAT); INSERT INTO safety_ai.ai_applications (ai_application_id, ai_algorithm_id, application_name, fairness_score) VALUES (1, 1, 'AI-generated art', 0.8), (2, 1, 'AI-generated ... | What is the average fairness score for each AI application in the 'safety_ai' database, segmented by algorithm type? | SELECT f.ai_algorithm, AVG(a.fairness_score) as avg_fairness_score FROM safety_ai.ai_applications a JOIN safety_ai.ai_algorithms f ON a.ai_algorithm_id = f.ai_algorithm_id GROUP BY f.ai_algorithm; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA renewables; CREATE TABLE wind_farms (name VARCHAR(50), capacity INT); INSERT INTO wind_farms (name, capacity) VALUES ('Farm1', 100), ('Farm2', 150); | Find the total capacity (MW) of wind farms in the 'renewables' schema | SELECT SUM(capacity) FROM renewables.wind_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, SpacecraftName VARCHAR(50), Manufacturer VARCHAR(50), Mission VARCHAR(50)); | What are the names of the spacecraft that have flown to Mars but were not manufactured by NASA or SpaceX? | SELECT SpacecraftName FROM Spacecraft WHERE Manufacturer NOT IN ('NASA', 'SpaceX') AND Mission LIKE '%Mars%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pipelines (pipeline_id INT, pipeline_name TEXT, start_location TEXT, end_location TEXT); INSERT INTO pipelines (pipeline_id, pipeline_name, start_location, end_location) VALUES (1, 'Pipeline A', 'North Sea', 'Europe'), (2, 'Pipeline B', 'Atlantic', 'North America'); CREATE TABLE pipeline_segments (pipeline... | List all pipelines that intersect with platforms in the North Sea | SELECT p.pipeline_name FROM pipelines p JOIN pipeline_segments ps ON p.pipeline_id = ps.pipeline_id WHERE ps.location = 'North Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), cruelty_free BOOLEAN); INSERT INTO products (id, name, category, price, cruelty_free) VALUES (1, 'Lipstick', 'makeup', 12.99, true), (2, 'Mascara', 'makeup', 14.99, true); | Insert new cruelty-free makeup products in the 'natural' category. | INSERT INTO products (name, category, price, cruelty_free) VALUES ('Eyeshadow', 'natural', 9.99, true), ('Blush', 'natural', 7.99, true); | gretelai_synthetic_text_to_sql |
CREATE TABLE public_ferries(id INT, ferry_number INT, city VARCHAR(20), max_seating_capacity INT); | What is the maximum seating capacity of public ferries in Hong Kong? | SELECT MAX(max_seating_capacity) FROM public_ferries WHERE city = 'Hong Kong'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_city_tech (tech_id INT, tech_name VARCHAR(30), city VARCHAR(20), cost DECIMAL(10,2)); INSERT INTO smart_city_tech (tech_id, tech_name, city, cost) VALUES (1, 'Smart Grids', 'New York', 7000000.00), (2, 'Smart Lighting', 'Los Angeles', 4000000.00), (3, 'Smart Traffic Management', 'Chicago', 6000000.00... | List all smart city technology adoptions in the city of New York and their respective costs. | SELECT tech_name, cost FROM smart_city_tech WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_players (player_id INT, player_name VARCHAR(50), assists INT); INSERT INTO basketball_players (player_id, player_name, assists) VALUES (1, 'LeBron James', 325), (2, 'Stephen Curry', 287), (3, 'Nikola Jokic', 378), (4, 'James Harden', 354), (5, 'Luka Doncic', 365); | What is the total number of assists by each basketball player in the 2022 season? | SELECT player_name, SUM(assists) as total_assists FROM basketball_players GROUP BY player_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE IncidentResolution (id INT, incident_month DATE, resolution_days INT); INSERT INTO IncidentResolution (id, incident_month, resolution_days) VALUES (1, '2022-02-01', 10), (2, '2022-02-15', 15), (3, '2022-03-01', 5); | What is the average number of days to resolve security incidents in the last month? | SELECT AVG(IncidentResolution.resolution_days) AS Average_Resolution_Days FROM IncidentResolution WHERE IncidentResolution.incident_month >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT PRIMARY KEY, donation_amount DECIMAL(10, 2), donation_date DATE, first_donation_date DATE); INSERT INTO donors (donor_id, donation_amount, donation_date, first_donation_date) VALUES (1, 250, '2020-01-01', '2020-01-01'), (2, 750, '2020-01-03', '2019-01-01'), (3, 900, '2020-02-05', '2020... | What is the total amount donated by new donors (those who have donated for the first time) in the year 2020? | SELECT SUM(donation_amount) FROM donors WHERE YEAR(donation_date) = 2020 AND YEAR(first_donation_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), category VARCHAR(50)); INSERT INTO products VALUES (1, 'Sativa Flower', 'Flower'), (2, 'Indica Flower', 'Flower'), (3, 'Hybrid Flower', 'Flower'), (4, 'Cannabis Oil', 'Concentrates'), (5, 'Edibles', 'Edibles'); CREATE TABLE sales (sale_id INT, product_id ... | What was the total revenue for each product category in Q1 2022? | SELECT category, SUM(revenue) as total_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE sale_date >= '2022-01-01' AND sale_date < '2022-04-01' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Song (SongID INT, Title VARCHAR(50), GenreID INT, Revenue INT); | What is the minimum revenue for a song in the Hip-Hop genre? | SELECT MIN(Song.Revenue) as MinRevenue FROM Song WHERE Song.GenreID = (SELECT GenreID FROM Genre WHERE Name='Hip-Hop'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Esports_Events (Event_ID INT, Event_Name VARCHAR(20), Viewers INT); INSERT INTO Esports_Events (Event_ID, Event_Name, Viewers) VALUES (1, 'Event 1', 10000), (2, 'Event 2', 12000), (3, 'Event 3', 15000); | What is the name of the esports event with the highest number of viewers? | SELECT Event_Name, MAX(Viewers) FROM Esports_Events; | gretelai_synthetic_text_to_sql |
CREATE TABLE model (model_id INT, name VARCHAR(50), organization_id INT, explainability_score INT, fairness_score INT); INSERT INTO model VALUES (1, 'ModelA', 1, 8, 9), (2, 'ModelB', 2, 7, 8), (3, 'ModelC', 3, 6, 9), (4, 'ModelD', 1, 9, 8), (5, 'ModelE', 3, 5, 7); CREATE TABLE organization (organization_id INT, name VA... | List the names and fairness scores of all explainable AI models created by non-profit organizations. | SELECT model.name, model.fairness_score FROM model JOIN organization ON model.organization_id = organization.organization_id WHERE organization.type = 'non-profit' AND model.explainability_score >= 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE HospitalBeds (HospitalID int, Beds int, Rural bool); INSERT INTO HospitalBeds (HospitalID, Beds, Rural) VALUES (1, 50, true); | What is the average number of hospital beds in rural areas of China? | SELECT AVG(Beds) FROM HospitalBeds WHERE Rural = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_count INT, amount_donated DECIMAL(10,2)); | What is the average donation size for donors from India? | SELECT AVG(amount_donated / donation_count) FROM donors WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sizes (id INT, size VARCHAR(10)); INSERT INTO sizes (id, size) VALUES (1, 'XS'), (2, 'S'), (3, 'M'), (4, 'L'), (5, 'XL'); CREATE TABLE inventory (id INT, item_name VARCHAR(20), size_id INT); INSERT INTO inventory (id, item_name, size_id) VALUES (1, 't-shirt', 1), (2, 'blouse', 3), (3, 'jeans', 4); | Count the number of items in each size category | SELECT sizes.size, COUNT(inventory.id) FROM sizes JOIN inventory ON inventory.size_id = sizes.id GROUP BY sizes.size; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (drug_name VARCHAR(255), approval_year INT, country VARCHAR(255)); INSERT INTO drug_approval (drug_name, approval_year, country) VALUES ('DrugA', 2019, 'USA'), ('DrugB', 2020, 'Canada'), ('DrugC', NULL, 'Germany'), ('DrugD', NULL, NULL); | What are the names of the drugs that were not approved in any country? | SELECT drug_name FROM drug_approval WHERE approval_year IS NULL AND country IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE ancient_civilizations (artifact_id INT, weight FLOAT, culture VARCHAR(255)); | What is the average weight of artifacts from the 'ancient_civilizations'? | SELECT AVG(weight) FROM ancient_civilizations; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (vol_id INT, org_id INT, hours_contributed INT, volunteer_name TEXT);CREATE TABLE organizations (org_id INT, org_name TEXT); INSERT INTO organizations VALUES (1, 'Habitat for Humanity'); INSERT INTO organizations VALUES (2, 'Red Cross'); INSERT INTO volunteers VALUES (1, 1, 10, 'John Doe'); INSE... | What is the average number of hours contributed per volunteer, for each organization? | SELECT organizations.org_name, AVG(volunteers.hours_contributed) AS avg_hours_per_volunteer FROM organizations INNER JOIN volunteers ON organizations.org_id = volunteers.org_id GROUP BY organizations.org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name TEXT, department TEXT, age INT); INSERT INTO employees (id, name, department, age) VALUES (1, 'John Doe', 'mining_operations', 35); INSERT INTO employees (id, name, department, age) VALUES (2, 'Jane Smith', 'geology', 28); | Find the average age of employees in the 'mining_operations' department. | SELECT AVG(age) FROM employees WHERE department = 'mining_operations'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyData (PolicyID INT, PolicyholderID INT, IssueDate DATE); INSERT INTO PolicyData (PolicyID, PolicyholderID, IssueDate) VALUES (1, 1, '2021-01-01'); INSERT INTO PolicyData (PolicyID, PolicyholderID, IssueDate) VALUES (2, 2, '2021-02-15'); CREATE TABLE ClaimData (ClaimID INT, PolicyID INT, ClaimDate DAT... | What is the total number of policies and claims processed in '2021' for policyholders living in 'NY'? | SELECT COUNT(DISTINCT PolicyData.PolicyID) AS Policies, COUNT(DISTINCT ClaimData.ClaimID) AS Claims FROM PolicyData JOIN ClaimData ON PolicyData.PolicyID = ClaimData.PolicyID WHERE YEAR(PolicyData.IssueDate) = 2021 AND PolicyData.PolicyholderID IN (SELECT PolicyholderID FROM Policyholders WHERE State = 'NY'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_amount DECIMAL, sale_date DATE); CREATE TABLE products (product_id INT, product_name TEXT, category TEXT); INSERT INTO sales (sale_id, product_id, sale_amount, sale_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 1, 40.00, '2022-01-15'), (3, 2, 30.00, '2022-01-30'), (... | Determine the percentage of total sales from the 'Natural' category during the past quarter. | SELECT 100.0 * SUM(sale_amount) / (SELECT SUM(sale_amount) FROM sales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE) AS pct_natural_sales FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.category = 'Natural'; | gretelai_synthetic_text_to_sql |
CREATE TABLE paris_sustainable_hotels(id INT, name TEXT, sustainable BOOLEAN, revenue FLOAT); INSERT INTO paris_sustainable_hotels(id, name, sustainable, revenue) VALUES (1, 'EcoHotel Paris', true, 12000.0), (2, 'Paris Green Suites', true, 15000.0), (3, 'Paris Urban Hotel', false, 10000.0); | What is the average revenue per sustainable hotel in Paris? | SELECT AVG(revenue) FROM paris_sustainable_hotels WHERE sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE nfl_players (player_id INT, player_name VARCHAR(255)); INSERT INTO nfl_players VALUES (1, 'Player1'), (2, 'Player2'), (3, 'Player3'), (4, 'Player4'); CREATE TABLE nfl_stats (game_id INT, player_id INT, running_distance DECIMAL(10,2)); INSERT INTO nfl_stats VALUES (1, 1, 85.67), (1, 2, 76.34), (2, 1, 91.23)... | What is the average running distance per game for each player in the 2022 NFL season? | SELECT p.player_name, AVG(s.running_distance) AS avg_running_distance FROM nfl_players p JOIN nfl_stats s ON p.player_id = s.player_id GROUP BY p.player_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, Duration INT, MemberID INT, Location VARCHAR(50)); INSERT INTO Workouts (WorkoutID, Duration, MemberID, Location) VALUES (1, 60, 1, 'California'); INSERT INTO Workouts (WorkoutID, Duration, MemberID, Location) VALUES (2, 90, 2, 'New York'); | What is the total duration of outdoor workouts for members living in California? | SELECT SUM(Workouts.Duration) FROM Workouts WHERE Workouts.Location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT, name VARCHAR(50), population INT, conservation_status VARCHAR(20)); INSERT INTO species (id, name, population, conservation_status) VALUES (1, 'Polar Bear', 26500, 'Vulnerable'); CREATE TABLE species_research (id INT, species_id INT, year INT, location VARCHAR(50), observations INT); INSER... | What species have been studied in Canada? | SELECT s.name FROM species s JOIN species_research r ON s.id = s.species_id JOIN location l ON r.location = l.name WHERE l.name = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DisabilitySupportPrograms (ID INT, Disability VARCHAR(50), Program VARCHAR(50), Budget INT); INSERT INTO DisabilitySupportPrograms (ID, Disability, Program, Budget) VALUES (1, 'Visual Impairment', 'Braille Materials', 10000); INSERT INTO DisabilitySupportPrograms (ID, Disability, Program, Budget) VALUES (2... | What is the minimum budget allocated for disability support programs per disability type? | SELECT Disability, MIN(Budget) as MinBudget FROM DisabilitySupportPrograms GROUP BY Disability; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_id INT, ngo_identity VARCHAR(255), category VARCHAR(255), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, donor_id, ngo_identity, category, amount, donation_date) VALUES (1, 1001, 'LGBTQ+', 'Education', 5000, '2021-05-05'), (2, 1002, 'Allies', 'Environment', ... | How many donations were made to LGBTQ+ organizations in the Education sector in Q2 2021? | SELECT COUNT(*) as total_donations FROM Donations WHERE donation_date BETWEEN '2021-04-01' AND '2021-06-30' AND ngo_identity = 'LGBTQ+' AND category = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_recipients (year INT, community VARCHAR(255), amount FLOAT); INSERT INTO climate_finance_recipients VALUES (2020, 'First Nations', 600000); | Which Indigenous communities received climate finance over 500,000 in 2020? | SELECT community FROM climate_finance_recipients WHERE year = 2020 AND amount > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Salary DECIMAL(10, 2), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Name, Salary, Department) VALUES (1, 'John Doe', 50000, 'HR'), (2, 'Jane Smith', 55000, 'IT'), (3, 'Mike Johnson', 60000, 'IT'), (4, 'Sara Doe', 45000, 'LA'); | Display the names and salaries of all employees in the 'IT' department, ordered by salary. | SELECT Name, Salary FROM Employees WHERE Department = 'IT' ORDER BY Salary; | gretelai_synthetic_text_to_sql |
CREATE TABLE SkincareSales (productID INT, productName VARCHAR(50), region VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO SkincareSales (productID, productName, region, revenue) VALUES (1, 'Nourishing Cream', 'Europe', 5000.00), (2, 'Soothing Lotion', 'Europe', 7000.00), (3, 'Regenerating Serum', 'Europe', 8000.00); ... | What is the total sales revenue of organic skincare products in the European market? | SELECT SUM(revenue) FROM SkincareSales INNER JOIN ProductIngredients ON SkincareSales.productID = ProductIngredients.productID WHERE organic = true AND region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WeatherData (location VARCHAR(255), date DATE, temperature FLOAT); INSERT INTO WeatherData (location, date, temperature) VALUES ('Svalbard', '2020-01-01', -5.0); INSERT INTO WeatherData (location, date, temperature) VALUES ('Svalbard', '2020-01-02', -6.5); | What is the average temperature recorded in Svalbard during 2020? | SELECT AVG(temperature) FROM WeatherData WHERE location = 'Svalbard' AND YEAR(date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtPieces (id INT, region VARCHAR(20), year INT, type VARCHAR(20), price FLOAT); INSERT INTO ArtPieces (id, region, year, type, price) VALUES (1, 'Pacific', 2021, 'VisualArt', 5000); INSERT INTO ArtPieces (id, region, year, type, price) VALUES (2, 'Pacific', 2021, 'Sculpture', 8000); | How many visual art pieces were sold in the Pacific region in 2021? | SELECT SUM(price) FROM ArtPieces WHERE region = 'Pacific' AND year = 2021 AND type = 'VisualArt'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Journeys(journey_id INT, journey_date DATE, mode_of_transport VARCHAR(20)); INSERT INTO Journeys(journey_id, journey_date, mode_of_transport) VALUES (1, '2022-06-01', 'Light Rail'), (2, '2022-06-02', 'Light Rail'), (3, '2022-07-01', 'Light Rail'); | What is the total number of journeys for 'Light Rail' mode of transport in 'Summer' season? | SELECT COUNT(*) FROM Journeys WHERE mode_of_transport = 'Light Rail' AND EXTRACT(MONTH FROM journey_date) BETWEEN 6 AND 8; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor VARCHAR(50), cause VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donations (id, donor, cause, amount, donation_date) VALUES (1, 'John Doe', 'Education', 500, '2022-04-01'), (2, 'Jane Smith', 'Health', 300, '2022-04-15'), (3, 'Alice Johnson', 'Environment', 70... | What is the average donation amount by month in 2022? | SELECT EXTRACT(MONTH FROM donation_date) as month, AVG(amount) as avg_donation FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_events (event_id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE donors (donor_id INT, name VARCHAR(50), event_id INT, amount DECIMAL(10,2)); INSERT INTO cultural_events (event_id, name, city) VALUES (1, 'Theatre Festival', 'London'); | Insert a new record of a donor who contributed to a cultural event in London. | INSERT INTO donors (donor_id, name, event_id, amount) VALUES (1, 'Alex Johnson', 1, 500.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableEnergyProjects (id INT, name VARCHAR(100), location VARCHAR(100), type VARCHAR(50), capacity FLOAT); | List the top 3 renewable energy projects with the highest capacity in the 'RenewableEnergyProjects' table. | SELECT name, capacity FROM RenewableEnergyProjects ORDER BY capacity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(100)); | Update the email address of a volunteer in the 'Volunteers' table | UPDATE Volunteers SET Email = 'new.email@example.com' WHERE VolunteerID = 201; | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_details (tour_id INT, hotel_id INT, region VARCHAR(20), tour_date DATE); | Insert a new virtual tour record for a hotel in the 'Asia' region on 2023-03-15. | INSERT INTO tour_details (hotel_id, region, tour_date) VALUES (102, 'Asia', '2023-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), posts_count INT, followers INT); CREATE TABLE posts (id INT, user_id INT, post_text VARCHAR(255)); | How many users in the social_media schema have posted at least once and have more than 100 followers? | SELECT COUNT(DISTINCT users.id) FROM users JOIN posts ON users.id = posts.user_id WHERE posts_count > 0 AND followers > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (restaurant_id INT, revenue_date DATE, total_revenue DECIMAL(10,2)); | Insert a new record for restaurant revenue | INSERT INTO revenue (restaurant_id, revenue_date, total_revenue) VALUES (987, '2022-03-15', 6000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT); CREATE TABLE posts (id INT, user_id INT, hashtags TEXT); | What is the count of distinct users who have interacted with content related to the hashtag "#technology" in the last month? | SELECT COUNT(DISTINCT users.id) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE FIND_IN_SET('technology', posts.hashtags) > 0 AND posts.created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditures (quarter TEXT, drug_name TEXT, amount INT); CREATE TABLE drug_categories (drug_name TEXT, drug_category TEXT); INSERT INTO rd_expenditures (quarter, drug_name, amount) VALUES ('Q1', 'DrugA', 300000), ('Q2', 'DrugA', 350000), ('Q3', 'DrugA', 400000), ('Q4', 'DrugA', 450000), ('Q1', 'DrugB', ... | What are the total R&D expenditures per quarter for each drug category in the 'rd_expenditures' and 'drug_categories' tables? | SELECT c.drug_category, r.quarter, SUM(r.amount) as total_expenditure FROM rd_expenditures r JOIN drug_categories c ON r.drug_name = c.drug_name GROUP BY c.drug_category, r.quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_energy (id INT, region VARCHAR(50), year INT, production FLOAT); | Delete the hydroelectric energy production record for Ontario in 2020 | DELETE FROM hydro_energy WHERE region = 'Ontario' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification_levels (location TEXT, acidification_level REAL, measurement_date DATE); CREATE TABLE atlantic_region (region_name TEXT, region_description TEXT); | What is the maximum ocean acidification level recorded in the Atlantic region in the last decade?" | SELECT MAX(oal.acidification_level) FROM ocean_acidification_levels oal INNER JOIN atlantic_region ar ON oal.location LIKE '%Atlantic%' AND oal.measurement_date >= (CURRENT_DATE - INTERVAL '10 years'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_associates (id INT, name VARCHAR(50), is_union_member BOOLEAN); INSERT INTO sales_associates (id, name, is_union_member) VALUES (1, 'Nina', false), (2, 'Noah', false), (3, 'Nicole', true); | What is the total number of employees who are not members of a union in the 'retail_database' database? | SELECT COUNT(*) FROM sales_associates WHERE is_union_member = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_age (student_id INT, age INT, total_open_pedagogy_hours INT); INSERT INTO open_pedagogy_age (student_id, age, total_open_pedagogy_hours) VALUES (1, 18, 30), (2, 21, 45), (3, 22, 60); | What is the total number of hours spent on open pedagogy projects by students in each age group? | SELECT FLOOR(age / 10) * 10 AS age_group, SUM(total_open_pedagogy_hours) FROM open_pedagogy_age GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE lolgames (game_id INT, champion VARCHAR(50), killer_champion VARCHAR(50)); INSERT INTO lolgames (game_id, champion, killer_champion) VALUES (1, 'Ashe', 'Yasuo'); | Find the most common cause of death for each champion in LoL | SELECT champion, killer_champion, COUNT(*) as num_deaths, RANK() OVER (PARTITION BY champion ORDER BY COUNT(*) DESC) as rank FROM lolgames GROUP BY champion, killer_champion | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (id INT, name VARCHAR(50), LGBTQ BOOLEAN); CREATE TABLE Cases (id INT, attorney_id INT, precedent VARCHAR(100)); INSERT INTO Attorneys (id, name, LGBTQ) VALUES (1, 'Attorney1', FALSE), (2, 'Attorney2', TRUE), (3, 'Attorney3', FALSE); INSERT INTO Cases (id, attorney_id, precedent) VALUES (1, 1, 'P... | What are the legal precedents cited in cases handled by attorneys who identify as LGBTQ+? | SELECT Cases.precedent FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.id WHERE Attorneys.LGBTQ = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (clinic_id INT); INSERT INTO rural_clinics (clinic_id) VALUES (1), (2); CREATE TABLE urban_clinics (clinic_id INT); INSERT INTO urban_clinics (clinic_id) VALUES (1), (2); CREATE TABLE rural_hospitals (hospital_id INT); INSERT INTO rural_hospitals (hospital_id) VALUES (1), (2); CREATE TABLE ur... | Show the total number of rural clinics and hospitals, as well as the total number of urban clinics and hospitals, in a single query. | SELECT 'Rural Clinics' AS location, COUNT(*) AS total_facilities FROM rural_clinics UNION SELECT 'Urban Clinics', COUNT(*) FROM urban_clinics UNION SELECT 'Rural Hospitals', COUNT(*) FROM rural_hospitals UNION SELECT 'Urban Hospitals', COUNT(*) FROM urban_hospitals; | gretelai_synthetic_text_to_sql |
CREATE TABLE Europium_Production (Year INT, Quarter INT, Quantity INT); INSERT INTO Europium_Production (Year, Quarter, Quantity) VALUES (2018, 1, 150), (2018, 2, 175), (2018, 3, 200), (2018, 4, 225), (2019, 1, 250), (2019, 2, 275), (2019, 3, 300), (2019, 4, 325); | Determine the year with the highest Europium production. | SELECT Year, MAX(Quantity) FROM Europium_Production GROUP BY Year ORDER BY MAX(Quantity) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255), organic BOOLEAN, weight FLOAT, supplier_id INT); | Calculate the average weight of organic and non-organic products supplied by each supplier. | SELECT s.name, AVG(p.weight) as avg_weight, p.organic FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id GROUP BY s.name, p.organic; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_records (id INT, vessel_id INT, incident_date DATE, description VARCHAR(100)); | How many incidents are recorded in the 'safety_records' table? | SELECT COUNT(*) FROM safety_records; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices (practice_id INT, description TEXT, category VARCHAR(20)); | Add a new record to the "sustainable_practices" table with an ID of 7, a description of 'Reducing food waste through composting', and a category of 'Waste' | INSERT INTO sustainable_practices (practice_id, description, category) VALUES (7, 'Reducing food waste through composting', 'Waste'); | gretelai_synthetic_text_to_sql |
CREATE TABLE snapchat_stories (story_id INT, user_id INT, story_date DATE);CREATE TABLE users (user_id INT, state VARCHAR(50), registration_date DATE);CREATE TABLE state_populations (state VARCHAR(50), population INT); | What is the percentage of users who have posted a story on Snapchat in the past week and who are located in a state with a population of over 10 million, out of all users located in a state with a population of over 10 million? | SELECT 100.0 * COUNT(DISTINCT s.user_id) / (SELECT COUNT(DISTINCT u.user_id) FROM users u JOIN state_populations sp ON u.state = sp.state WHERE sp.population > 10000000) as pct_users FROM snapchat_stories s JOIN users u ON s.user_id = u.user_id JOIN state_populations sp ON u.state = sp.state WHERE s.story_date >= DATE(... | gretelai_synthetic_text_to_sql |
CREATE TABLE seasons (season_id INT, player TEXT, team TEXT, home_runs INT); | What is the average number of home runs hit by a player in a single MLB season? | SELECT AVG(home_runs) FROM seasons; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates_material(material VARCHAR(50), year INT, rate FLOAT); INSERT INTO recycling_rates_material(material, year, rate) VALUES('Plastic', 2018, 0.25), ('Plastic', 2019, 0.3), ('Plastic', 2020, 0.35), ('Paper', 2018, 0.5), ('Paper', 2019, 0.55), ('Paper', 2020, 0.6); | What is the recycling rate trend for Plastic and Paper from 2018 to 2020? | SELECT material, year, rate FROM recycling_rates_material WHERE material IN ('Plastic', 'Paper') ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE evacuations (evacuation_id INT, state VARCHAR(50), mission_status VARCHAR(10)); INSERT INTO evacuations (evacuation_id, state, mission_status) VALUES (1, 'State A', 'successful'), (2, 'State A', 'failed'), (3, 'State B', 'successful'), (4, 'State C', 'failed'), (5, 'State A', 'successful'), (6, 'State B', ... | What is the total number of successful and failed evacuation missions in each state? | SELECT s.name, SUM(CASE WHEN e.mission_status = 'successful' THEN 1 ELSE 0 END) AS num_successful, SUM(CASE WHEN e.mission_status = 'failed' THEN 1 ELSE 0 END) AS num_failed FROM evacuations e JOIN states s ON e.state = s.name GROUP BY s.name | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (id INT, language VARCHAR(255), native_speakers INT, country VARCHAR(255)); INSERT INTO languages (id, language, native_speakers, country) VALUES (1, 'Mandarin', 1100000, 'China'), (2, 'Quechua', 800000, 'Peru'); | How many languages have more than 1000 native speakers? | SELECT COUNT(*) FROM languages WHERE native_speakers > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinic_5 (patient_id INT, age INT, gender VARCHAR(10)); INSERT INTO rural_clinic_5 (patient_id, age, gender) VALUES (1, 35, 'Male'), (2, 50, 'Female'), (3, 42, 'Male'), (4, 60, 'Male'), (5, 30, 'Female'), (6, 45, 'Female'), (7, 40, 'Male'); | What is the number of male patients in the 'rural_clinic_5' table? | SELECT COUNT(*) FROM rural_clinic_5 WHERE gender = 'Male'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Weather (location VARCHAR(50), rainfall INT, timestamp TIMESTAMP); | What is the total rainfall in Oregon in the past week? | SELECT SUM(rainfall) FROM Weather WHERE location = 'Oregon' AND timestamp > NOW() - INTERVAL '1 week'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (species_id INT, species_name VARCHAR(50)); CREATE TABLE species_observations (observation_id INT, species_id INT, observation_date DATE); INSERT INTO species (species_id, species_name) VALUES (1, 'Polar Bear'), (2, 'Arctic Fox'), (3, 'Arctic Char'); INSERT INTO species_observations (observation_id... | Delete all species observation records that are older than 5 years. | DELETE FROM species_observations WHERE observation_date < (CURRENT_DATE - INTERVAL '5 years'); | gretelai_synthetic_text_to_sql |
CREATE TABLE permits (id INT PRIMARY KEY, project_id INT, issue_date DATE, expiry_date DATE); INSERT INTO permits (id, project_id, issue_date, expiry_date) VALUES (1, 1, '2020-01-10', '2021-01-10'); INSERT INTO permits (id, project_id, issue_date, expiry_date) VALUES (2, 2, '2021-02-15', '2022-02-15'); | Which projects have had more than one building permit issued? | (SELECT project_id FROM permits GROUP BY project_id HAVING COUNT(*) > 1) | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(50), state VARCHAR(2), build_date DATE, co_owners INT); INSERT INTO properties (id, city, state, build_date, co_owners) VALUES (1, 'Los Angeles', 'CA', '1999-01-01', 2), (2, 'San Diego', 'CA', '2005-01-01', 1), (3, 'Houston', 'TX', '1985-01-01', 3); | List the number of properties in each state that were built before 2000 and have more than one co-owner. | SELECT state, COUNT(*) FROM properties WHERE build_date < '2000-01-01' AND co_owners > 1 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE investigative_journalism (article_id INT, author VARCHAR(50), title VARCHAR(100), published_date DATE, category VARCHAR(30), word_count INT, author_gender VARCHAR(10)); INSERT INTO investigative_journalism (article_id, author, title, published_date, category, word_count, author_gender) VALUES (1, 'Carlos A... | What is the total number of articles in the 'investigative_journalism' table for each author's gender? | SELECT author_gender, COUNT(article_id) AS total_articles FROM investigative_journalism GROUP BY author_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (veteran_id INT, job_title VARCHAR(30), hire_date DATE, salary FLOAT); | Insert a new record into the 'veteran_employment' table for a veteran hired as a 'software engineer' on 2022-03-15 with a salary of $80,000 | INSERT INTO veteran_employment (veteran_id, job_title, hire_date, salary) VALUES (1, 'software engineer', '2022-03-15', 80000); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite (id INT, name VARCHAR(255), launch_site_id INT, country_id INT, launch_date DATE); INSERT INTO satellite (id, name, launch_site_id, country_id, launch_date) VALUES (1, 'Sentinel-3B', 1, 1, '2018-04-25'), (2, 'Telstar 18V', 2, 3, '2018-09-11'), (3, 'Galileo FOC FM-11', 3, 2, '2018-06-27'); CREATE ... | List all satellites with their launch sites and the country responsible for the launches in 2018. | SELECT s.name, ls.name as launch_site, c.name as country FROM satellite s INNER JOIN launch_site ls ON s.launch_site_id = ls.id INNER JOIN country c ON s.country_id = c.id WHERE YEAR(s.launch_date) = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE Deliveries (id INT, delivery_date DATETIME, delivery_country VARCHAR(50)); INSERT INTO Deliveries (id, delivery_date, delivery_country) VALUES (1, '2022-01-01', 'Japan'), (2, '2022-01-02', 'China'), (3, '2022-01-03', 'South Korea'); | What are the average delivery times for each country in Asia? | SELECT delivery_country, AVG(DATEDIFF('2022-01-04', delivery_date)) avg_delivery_time FROM Deliveries WHERE delivery_country IN ('Japan', 'China', 'South Korea') GROUP BY delivery_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(product_id INT, category VARCHAR(255), amount DECIMAL(10,2), sale_date DATE); INSERT INTO sales(product_id, category, amount, sale_date) VALUES (1, 'Analgesics', 1500, '2021-01-01'), (2, 'Antidepressants', 2000, '2021-01-05'), (3, 'Antibiotics', 1200, '2021-01-10'); | What are the total sales for each product category in Q1 2021? | SELECT category, SUM(amount) as total_sales FROM sales WHERE sale_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), DonationAmount DECIMAL(10,2), CauseID INT);CREATE TABLE Causes (CauseID INT, CauseName VARCHAR(50)); | What is the average donation per donor for each cause? | SELECT C.CauseName, AVG(D.DonationAmount) FROM Donors D JOIN Causes C ON D.CauseID = C.CauseID GROUP BY C.CauseName; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableUrbanismByYear (id INT PRIMARY KEY, city VARCHAR(50), state VARCHAR(50), initiative VARCHAR(100), year INT, date DATE); | Alter the SustainableUrbanismByYear table to include a date column | ALTER TABLE SustainableUrbanismByYear ADD COLUMN date DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists VehicleSafetyRating (Id int, Vehicle varchar(100), Country varchar(50), SafetyRating float); INSERT INTO VehicleSafetyRating (Id, Vehicle, Country, SafetyRating) VALUES (1, 'Tesla Model 3', 'USA', 5.3), (2, 'Tesla Model S', 'USA', 5.4), (3, 'Nissan Leaf', 'Japan', 4.8), (4, 'BMW i3', 'Germany... | Find the average safety rating of the top 2 vehicles in each country? | SELECT Country, AVG(SafetyRating) FROM (SELECT Country, SafetyRating FROM VehicleSafetyRating GROUP BY Country ORDER BY AVG(SafetyRating) DESC LIMIT 2) AS Subquery; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.