context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE staff (id INT PRIMARY KEY, name VARCHAR(255), role VARCHAR(255), email TEXT, phone TEXT); INSERT INTO staff (id, name, role, email, phone) VALUES (1, 'Alex Duong', 'Mental Health Coordinator', 'alex.duong@disabilityservices.org', '555-555-1234'); | What is the contact information of the staff member responsible for mental health services? | SELECT * FROM staff WHERE role = 'Mental Health Coordinator'; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicles (id INT, make VARCHAR(50), range INT); INSERT INTO electric_vehicles (id, make, range) VALUES (1, 'Tesla', 350), (2, 'Tesla', 400), (3, 'Nissan', 250), (4, 'Nissan', 280), (5, 'Ford', 310), (6, 'Ford', NULL), (7, 'Chevy', 240), (8, 'Lucid', 517), (9, 'Rivian', 314); | List the top 3 makes with the highest average range for electric vehicles | SELECT make, AVG(range) as avg_range FROM electric_vehicles WHERE range IS NOT NULL GROUP BY make ORDER BY avg_range DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dates (DateID INT, ExcavationDate DATE); INSERT INTO Dates (DateID, ExcavationDate) VALUES (1, '2021-05-15'), (2, '2021-06-16'), (3, '2021-07-20'); CREATE TABLE ArtifactsDates (ArtifactID INT, DateID INT); INSERT INTO ArtifactsDates (ArtifactID, DateID) VALUES (1, 1), (2, 2), (3, 1), (4, 2), (5, 3); | How many artifacts were found in the last 3 months, categorized by excavation site and artifact type? | SELECT Dates.ExcavationDate, Sites.SiteName, Artifacts.ArtifactName, COUNT(ArtifactsDates.ArtifactID) AS Quantity FROM Dates INNER JOIN ArtifactsDates ON Dates.DateID = ArtifactsDates.DateID INNER JOIN Artifacts ON ArtifactsDates.ArtifactID = Artifacts.ArtifactID INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID WHERE Dates.ExcavationDate >= DATEADD(month, -3, GETDATE()) GROUP BY Dates.ExcavationDate, Sites.SiteName, Artifacts.ArtifactName; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (salesperson_id INT, salesperson_name VARCHAR(255), revenue INT); INSERT INTO sales_data (salesperson_id, salesperson_name, revenue) VALUES (1, 'John Doe', 500000), (2, 'Jane Smith', 600000), (3, 'Bob Johnson', 400000), (4, 'Alice Williams', 700000), (5, 'Charlie Brown', 800000); | Who are the top 3 salespeople by total revenue? | SELECT salesperson_name, SUM(revenue) AS total_revenue FROM sales_data GROUP BY salesperson_name ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_tech (subscriber_id INT, subscription_start_date DATE, technology VARCHAR(50), subscription_fee DECIMAL(10, 2)); INSERT INTO subscriber_tech (subscriber_id, subscription_start_date, technology, subscription_fee) VALUES (1, '2020-01-01', 'Fiber', 50.00), (2, '2019-06-15', 'Cable', 40.00), (4, '2021-02-20', 'WiMax', 45.00); | How many broadband subscribers use 'WiMax' technology, grouped by subscription start date? | SELECT subscription_start_date, COUNT(*) as total_subscribers FROM subscriber_tech WHERE technology = 'WiMax' GROUP BY subscription_start_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_beds INT, region TEXT); INSERT INTO hospitals (id, name, location, num_beds, region) VALUES (1, 'Hospital A', 'Rural Andalusia', 200, 'Andalusia'), (2, 'Hospital B', 'Rural Madrid', 250, 'Madrid'); CREATE TABLE clinics (id INT, name TEXT, location TEXT, num_beds INT, region TEXT); INSERT INTO clinics (id, name, location, num_beds, region) VALUES (1, 'Clinic A', 'Rural Andalusia', 50, 'Andalusia'), (2, 'Clinic B', 'Rural Madrid', 75, 'Madrid'); CREATE TABLE distance (hospital_id INT, clinic_id INT, distance FLOAT); INSERT INTO distance (hospital_id, clinic_id, distance) VALUES (1, 1, 25.0), (1, 2, 30.0), (2, 1, 35.0), (2, 2, 40.0); | What is the number of rural hospitals and clinics in each region, and the number of clinics within a 30-km radius of each hospital? | SELECT h.region, COUNT(h.id) AS num_hospitals, COUNT(c.id) AS num_clinics_within_30_km FROM hospitals h INNER JOIN distance d ON h.id = d.hospital_id INNER JOIN clinics c ON d.clinic_id = c.id WHERE d.distance <= 30 GROUP BY h.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, rating INT); INSERT INTO hotels (id, name, country, rating) VALUES (1, 'Hotel Adlon Kempinski Berlin', 'Germany', 4), (2, 'Hotel Vier Jahreszeiten Kempinski Munich', 'Germany', 4), (3, 'The Ritz-Carlton, Berlin', 'Germany', 5); | How many 4-star hotels are there in Germany? | SELECT COUNT(*) FROM hotels WHERE country = 'Germany' AND rating = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE garments (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), rating INT); CREATE TABLE inventories (id INT PRIMARY KEY, garment_id INT, quantity INT); | Insert a new garment with id 3, name 'Jacket', category 'Men', rating 5 and quantity 25 into the database. | INSERT INTO garments (id, name, category, rating) VALUES (3, 'Jacket', 'Men', 5); INSERT INTO inventories (id, garment_id, quantity) VALUES (3, 3, 25); | gretelai_synthetic_text_to_sql |
CREATE TABLE shipping (country VARCHAR(20), packages INT); INSERT INTO shipping (country, packages) VALUES ('Country1', 100), ('Country2', 200), ('Country3', 150); | What is the total number of packages shipped to each country in the shipping database? | SELECT country, SUM(packages) FROM shipping GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE courses (course_id INT, course_name TEXT, year INT); INSERT INTO courses (course_id, course_name, year) VALUES (1, 'Course X', 2021), (2, 'Course Y', 2021), (3, 'Course Z', 2022), (4, 'Course W', 2022); CREATE TABLE enrollments (enrollment_id INT, course_id INT, student_id INT); INSERT INTO enrollments (enrollment_id, course_id, student_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3), (4, 2, 4), (5, 3, 5), (6, 4, 6); | Which lifelong learning courses had the lowest enrollment in the past two years? | SELECT c.course_name, MIN(c.year) as min_year, COUNT(e.student_id) as enrollment_count FROM courses c JOIN enrollments e ON c.course_id = e.course_id GROUP BY c.course_name HAVING MIN(c.year) >= 2021 ORDER BY enrollment_count ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, student_name TEXT, student_age INT); CREATE TABLE sessions (session_id INT, student_id INT, session_date DATE, support_type TEXT, hours_spent INT); INSERT INTO students VALUES (1, 'Alex', 15), (2, 'Bella', 17), (3, 'Charlie', 20), (4, 'Daniel', 22); INSERT INTO sessions VALUES (1, 1, '2022-01-01', 'mental health', 2), (2, 2, '2022-01-02', 'mental health', 3), (3, 3, '2022-01-03', 'mental health', 4), (4, 4, '2022-01-04', 'mental health', 5), (5, 1, '2022-02-01', 'mental health', 3), (6, 2, '2022-02-02', 'mental health', 4), (7, 3, '2022-02-03', 'mental health', 5), (8, 4, '2022-02-04', 'mental health', 6); | What is the average mental health support session duration for students of different age groups? | SELECT FLOOR(s.student_age / 5) * 5 AS age_group, AVG(s.hours_spent) FROM students st INNER JOIN sessions s ON st.student_id = s.student_id WHERE s.support_type = 'mental health' GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (BridgeID INT, Location VARCHAR(20), Cost FLOAT); INSERT INTO Bridges (BridgeID, Location, Cost) VALUES (1, 'California', 5000000); | What is the average cost of materials for bridges constructed in California? | SELECT AVG(Cost) FROM Bridges WHERE Location = 'California' AND BridgeID IN (SELECT BridgeID FROM Bridges WHERE Location = 'California'); | gretelai_synthetic_text_to_sql |
CREATE TABLE card_stats (id INT, player TEXT, yellow_cards INT, country TEXT); INSERT INTO card_stats (id, player, yellow_cards, country) VALUES (1, 'Klose', 5, 'Germany'), (2, 'Schweinsteiger', 4, 'Germany'), (3, 'Lahm', 3, 'Germany'); | What is the total number of yellow cards given to players from Germany? | SELECT SUM(yellow_cards) FROM card_stats WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities_by_actor (id INT, actor VARCHAR(50), vuln_count INT); INSERT INTO vulnerabilities_by_actor (id, actor, vuln_count) VALUES (1, 'APT28', 200), (2, 'APT33', 150), (3, 'Lazarus', 100); | What is the total number of vulnerabilities found for each threat actor? | SELECT actor, SUM(vuln_count) as total_vulnerabilities FROM vulnerabilities_by_actor GROUP BY actor; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (site_id INT, site_name TEXT, city TEXT, rating INT); INSERT INTO heritage_sites (site_id, site_name, city, rating) VALUES (1, 'Prado Museum', 'Madrid', 5), (2, 'Royal Palace', 'Madrid', 4), (3, 'Retiro Park', 'Madrid', 4); | What is the average rating of cultural heritage sites in Madrid? | SELECT AVG(rating) FROM heritage_sites WHERE city = 'Madrid'; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_contributions (country VARCHAR(50), region VARCHAR(50), personnel INT); INSERT INTO peacekeeping_contributions (country, region, personnel) VALUES ('Afghanistan', 'Asia', 300), ('Bangladesh', 'Asia', 1200), ('China', 'Asia', 500); | What is the average number of peacekeeping personnel contributed by each country in the 'asia' region? | SELECT region, AVG(personnel) as avg_personnel FROM peacekeeping_contributions WHERE region = 'Asia' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE disease_prevalence (county VARCHAR(50), diagnosis VARCHAR(50), prevalence DECIMAL(5,2)); INSERT INTO disease_prevalence (county, diagnosis, prevalence) VALUES ('Rural County A', 'Heart Disease', 10.00); | Update the 'Heart Disease' prevalence rate for 'Rural County A' in the "disease_prevalence" table to 12% | UPDATE disease_prevalence SET prevalence = 0.12 WHERE county = 'Rural County A' AND diagnosis = 'Heart Disease'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (warehouse_id VARCHAR(10), warehouse_location VARCHAR(20)); INSERT INTO warehouse (warehouse_id, warehouse_location) VALUES ('A', 'New York'), ('B', 'Tokyo'), ('C', 'London'); CREATE TABLE shipments (shipment_id INT, warehouse_id VARCHAR(10), quantity INT); INSERT INTO shipments (shipment_id, warehouse_id, quantity) VALUES (1, 'A', 500), (2, 'B', 300), (3, 'C', 700), (4, 'B', 200); | What was the total quantity of items shipped to a specific region (e.g. Asia)? | SELECT SUM(quantity) FROM shipments JOIN warehouse ON shipments.warehouse_id = warehouse.warehouse_id WHERE warehouse.warehouse_location LIKE 'Asia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE global_songs (id INT, title TEXT, length FLOAT, genre TEXT); INSERT INTO global_songs (id, title, length, genre) VALUES (1, 'Cancion1', 3.2, 'pop latino'), (2, 'Cancion2', 4.1, 'reggaeton'), (3, 'Cancion3', 3.8, 'salsa'), (4, 'Cancion4', 2.1, 'flamenco'), (5, 'Cancion5', 5.3, 'k-pop'), (6, 'Cancion6', 6.2, 'bhangra'); | How many unique genres are there in the global_songs table? | SELECT COUNT(DISTINCT genre) FROM global_songs; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorCountry VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorCountry, Amount) VALUES (1, 'USA', 1000), (2, 'Canada', 800), (3, 'Mexico', 600); | Which countries had the highest and lowest donation amounts? | SELECT DonorCountry, MAX(Amount) as HighestDonation, MIN(Amount) as LowestDonation FROM Donors GROUP BY DonorCountry HAVING COUNT(DonorID) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProgramAttendance (program_name VARCHAR(50), attendee_race VARCHAR(20)); INSERT INTO ProgramAttendance (program_name, attendee_race) VALUES ('Theater for All', 'African American'); INSERT INTO ProgramAttendance (program_name, attendee_race) VALUES ('Theater for All', 'Hispanic'); INSERT INTO ProgramAttendance (program_name, attendee_race) VALUES ('Theater for All', 'Asian'); INSERT INTO ProgramAttendance (program_name, attendee_race) VALUES ('Theater for All', 'White'); INSERT INTO ProgramAttendance (program_name, attendee_race) VALUES ('Theater for All', 'Native American'); | What percentage of 'Theater for All' program attendees identify as BIPOC? | SELECT (COUNT(*) FILTER (WHERE attendee_race IN ('African American', 'Hispanic', 'Asian', 'Native American')) * 100.0 / COUNT(*)) AS percentage FROM ProgramAttendance WHERE program_name = 'Theater for All'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Voyages (Id INT, VesselId INT, Year INT); INSERT INTO Voyages (Id, VesselId, Year) VALUES (1, 1, 2021), (2, 1, 2022), (3, 3, 2021), (4, 2, 2020); | What is the total number of voyages for vessels that have had zero accidents? | SELECT COUNT(*) FROM (SELECT VesselId FROM Voyages GROUP BY VesselId HAVING COUNT(*) = (SELECT COUNT(*) FROM Accidents WHERE Accidents.VesselId = Voyages.VesselId)) AS NoAccidentsVoyages; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_date DATE, salesperson VARCHAR(255), revenue FLOAT); | What is the total revenue for each salesperson in Q1 2022? | SELECT salesperson, SUM(revenue) AS total_revenue FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY salesperson; | gretelai_synthetic_text_to_sql |
CREATE TABLE VolunteerDates (Id INT, VolunteerId INT, JoinDate DATE); INSERT INTO VolunteerDates VALUES (1, 1, '2022-01-01'), (2, 2, '2022-03-01'); | What's the number of volunteers who joined each month? | SELECT EXTRACT(MONTH FROM JoinDate) as Month, COUNT(DISTINCT VolunteerId) as VolunteersJoined FROM VolunteerDates GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, city VARCHAR, joined DATE); INSERT INTO volunteers VALUES (1, 'San Francisco', '2020-01-01') | Determine the total number of unique cities where volunteers reside | SELECT COUNT(DISTINCT v.city) AS unique_cities FROM volunteers v; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibits (exhibit_id INT, city VARCHAR(50), price DECIMAL(5,2)); INSERT INTO Exhibits (exhibit_id, city, price) VALUES (1, 'London', 35.99), (2, 'Berlin', 40.00); | What is the minimum ticket price for an art exhibit in London? | SELECT MIN(price) FROM Exhibits WHERE city = 'London'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (site_id INT, site_name TEXT, region TEXT, month INT, year INT, worker_id INT, water_usage INT); INSERT INTO water_usage (site_id, site_name, region, month, year, worker_id, water_usage) VALUES (12, 'DEF Mine', 'South', 1, 2022, 12001, 200), (13, 'GHI Mine', 'South', 2, 2022, 13001, 220), (14, 'JKL Mine', 'South', 3, 2022, 14001, 240); | What is the average monthly water usage per worker at the 'South' region mines in 2022? | SELECT region, AVG(water_usage) as avg_water_usage_per_worker FROM water_usage WHERE region = 'South' AND year = 2022 GROUP BY region, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE wellness_trend (trend_name VARCHAR(50), popularity_score INT); INSERT INTO wellness_trend (trend_name, popularity_score) VALUES ('Pilates', 70); | Delete the wellness trend record for 'Pilates' | WITH deleted_trend AS (DELETE FROM wellness_trend WHERE trend_name = 'Pilates' RETURNING *) SELECT * FROM deleted_trend; | gretelai_synthetic_text_to_sql |
CREATE TABLE InvestorsESG (id INT, investor VARCHAR(255), esg_score DECIMAL(3,2)); CREATE TABLE InvestmentsCE (id INT, investor VARCHAR(255), sector VARCHAR(255)); | List the 'investor' and 'esg_score' for all 'CleanEnergy' investments. | SELECT InvestorsESG.investor, InvestorsESG.esg_score FROM InvestorsESG INNER JOIN InvestmentsCE ON InvestorsESG.id = InvestmentsCE.id WHERE InvestmentsCE.sector = 'CleanEnergy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, country VARCHAR(50)); CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(50), country VARCHAR(50)); INSERT INTO Donations (id, donor_name, donation_amount, donation_date, country) VALUES (1, 'John Doe', 50.00, '2021-01-01', 'Australia'); INSERT INTO Donations (id, donor_name, donation_amount, donation_date, country) VALUES (2, 'Jane Smith', 25.00, '2021-01-02', 'Australia'); INSERT INTO Volunteers (id, volunteer_name, country) VALUES (1, 'John Doe', 'Australia'); INSERT INTO Volunteers (id, volunteer_name, country) VALUES (2, 'Jane Smith', 'Australia'); | How many volunteers have donated more than $50 in Australia? | SELECT COUNT(DISTINCT d.donor_name) as num_volunteers FROM Donations d INNER JOIN Volunteers v ON d.donor_name = v.volunteer_name WHERE d.country = 'Australia' AND d.donation_amount > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE refugee_families (id INT, location_id INT, family_size INT); CREATE TABLE refugee_children (id INT, family_id INT, age INT); | Identify the total number of refugee families and children by joining the refugee_families and refugee_children tables. | SELECT COUNT(DISTINCT rf.id) as total_families, SUM(rc.age) as total_children_age FROM refugee_families rf INNER JOIN refugee_children rc ON rf.id = rc.family_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Sustainable BOOLEAN); INSERT INTO Suppliers (SupplierID, SupplierName, Sustainable) VALUES (1, 'Green Textiles', true), (2, 'Fashion Fabrics', false), (3, 'Eco-Friendly Materials', true); CREATE TABLE PurchaseOrders (PurchaseOrderID INT, SupplierID INT, Quantity INT, OrderDate DATE); INSERT INTO PurchaseOrders (PurchaseOrderID, SupplierID, Quantity, OrderDate) VALUES (1, 1, 500, '2021-09-01'), (2, 3, 300, '2021-10-15'), (3, 1, 700, '2022-01-10'); | Identify the textile supplier with the highest total quantity of sustainable fabric orders, for the past 12 months. | SELECT s.SupplierName, SUM(po.Quantity) as TotalQuantity FROM Suppliers s INNER JOIN PurchaseOrders po ON s.SupplierID = po.SupplierID WHERE s.Sustainable = true AND po.OrderDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY s.SupplierName ORDER BY TotalQuantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE LargeFish (id INT, species VARCHAR(255), weight FLOAT); INSERT INTO LargeFish (id, species, weight) VALUES (1, 'Shark', 350.5); INSERT INTO LargeFish (id, species, weight) VALUES (2, 'Marlin', 200.3); INSERT INTO LargeFish (id, species, weight) VALUES (3, 'Swordfish', 250.8); | Present the number of fish that weigh more than 200kg in the 'LargeFish' table | SELECT COUNT(*) FROM LargeFish WHERE weight > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_equity_metrics (state VARCHAR(255), score DECIMAL(5,2)); INSERT INTO health_equity_metrics (state, score) VALUES ('California', 85.5), ('New York', 90.0), ('Texas', 76.0), ('Florida', 82.0); | What is the average health equity metric score by state? | SELECT state, AVG(score) FROM health_equity_metrics GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE EnergyConsumption (sector VARCHAR(50), consumption FLOAT); | What is the total energy consumption in TWh for each sector (residential, commercial, industrial)? | SELECT sector, SUM(consumption) FROM EnergyConsumption GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_city_technology (technology_name TEXT, cost REAL); | List all smart city technology adoptions and their corresponding costs from the 'smart_city_technology' table. | SELECT technology_name, cost FROM smart_city_technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, industry VARCHAR(255), salary FLOAT, union_member BOOLEAN); INSERT INTO workers (id, industry, salary, union_member) VALUES (1, 'Manufacturing', 50000.0, true), (2, 'Agriculture', 60000.0, false), (3, 'Retail', 30000.0, false); | What is the average salary of workers in the 'Agriculture' industry who are not part of a union? | SELECT AVG(salary) FROM workers WHERE industry = 'Agriculture' AND union_member = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE memberships (id INT, member_state VARCHAR(50), membership_start_date DATE, membership_fee FLOAT); | Insert a new member from London with a membership fee of 60 starting on June 1st, 2022. | INSERT INTO memberships (id, member_state, membership_start_date, membership_fee) VALUES (1, 'London', '2022-06-01', 60.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE risk_models (model_id INT PRIMARY KEY, model_name VARCHAR(100), model_description TEXT, model_date DATE); | Insert sample data into 'risk_models' table | INSERT INTO risk_models (model_id, model_name, model_description, model_date) VALUES (1, 'Model A', 'Description for Model A', '2022-01-01'), (2, 'Model B', 'Description for Model B', '2022-02-15'), (3, 'Model C', 'Description for Model C', '2022-03-05'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 3, '2022-03-15', 50.00), (2, 4, '2022-01-01', 75.00); | What is the minimum donation amount made by new donors from the Asia-Pacific region in Q1 2022? | SELECT MIN(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Region = 'Asia-Pacific' AND Donations.DonationDate BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artist_Updates (update_id INT, artist_name VARCHAR(255), update_date DATE); INSERT INTO Artist_Updates (update_id, artist_name, update_date) VALUES (1, 'Artist A', '2019-01-01'), (2, 'Artist B', '2019-02-01'), (3, 'Artist A', '2019-03-01'), (4, 'Artist C', '2019-04-01'), (5, 'Artist A', '2019-05-01'); | Display the names of artists who have updated their information more than once and the respective update dates. | SELECT artist_name, COUNT(update_id) AS num_updates, MIN(update_date) AS earliest_update_date FROM Artist_Updates GROUP BY artist_name HAVING COUNT(update_id) > 1 ORDER BY earliest_update_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, gender VARCHAR(10), department VARCHAR(20)); INSERT INTO employees (id, gender, department) VALUES (1, 'Female', 'IT'), (2, 'Male', 'Marketing'), (3, 'Female', 'IT'); | What percentage of employees are female and work in IT? | SELECT (COUNT(*) FILTER (WHERE gender = 'Female' AND department = 'IT')) * 100.0 / (SELECT COUNT(*) FROM employees) AS percentage; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(255)); CREATE TABLE song (song_id INT, song_name VARCHAR(255), artist_id INT); CREATE TABLE digital_sales (sale_id INT, song_id INT, sales_revenue DECIMAL(10, 2)); | What is the total revenue for each artist, based on the 'digital_sales' table, joined with the 'artist' and 'song' tables? | SELECT a.artist_name, SUM(ds.sales_revenue) AS total_revenue FROM artist a INNER JOIN song s ON a.artist_id = s.artist_id INNER JOIN digital_sales ds ON s.song_id = ds.song_id GROUP BY a.artist_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleTesting (Id INT, Make VARCHAR(255), Model VARCHAR(255), Test VARCHAR(255), Result VARCHAR(255)); INSERT INTO VehicleTesting (Id, Make, Model, Test, Result) VALUES (3, 'Toyota', 'Corolla', 'AutoPilot', 'Pass'); | Which vehicle safety tests were passed by Toyota? | SELECT DISTINCT Test FROM VehicleTesting WHERE Make = 'Toyota' AND Result = 'Pass'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_status (species_name VARCHAR(255), region VARCHAR(255), endangerment_status VARCHAR(255)); INSERT INTO marine_species_status (species_name, region, endangerment_status) VALUES ('Krill', 'Southern Ocean', 'Least Concern'), ('Blue Whale', 'Southern Ocean', 'Endangered'); | What is the average endangerment status of marine species in the Southern ocean? | SELECT AVG(CASE WHEN endangerment_status = 'Least Concern' THEN 1 WHEN endangerment_status = 'Near Threatened' THEN 2 WHEN endangerment_status = 'Vulnerable' THEN 3 WHEN endangerment_status = 'Endangered' THEN 4 ELSE 5 END) FROM marine_species_status WHERE region = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupplierInfo (SupplierID INT, SupplierName VARCHAR(255), SustainableFabricQuantity INT); INSERT INTO SupplierInfo (SupplierID, SupplierName, SustainableFabricQuantity) VALUES (1, 'SupplierA', 30000), (2, 'SupplierB', 25000), (3, 'SupplierC', 35000); | Which textile supplier has provided the most sustainable fabric to the fashion industry? | SELECT SupplierName, MAX(SustainableFabricQuantity) FROM SupplierInfo; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (country VARCHAR(50), region VARCHAR(50), year INT, projects INT); INSERT INTO military_innovation (country, region, year, projects) VALUES ('USA', 'Americas', 2020, 150), ('USA', 'Americas', 2021, 180); | What is the total number of military innovation projects completed by 'usa' in the 'americas' region? | SELECT country, region, SUM(projects) as total_projects FROM military_innovation WHERE country = 'USA' AND region = 'Americas' GROUP BY country, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT PRIMARY KEY, name VARCHAR(100), focus VARCHAR(100), country VARCHAR(50)); | Update the "programs" table to reflect a change in the focus of a program in India | UPDATE programs SET focus = 'Indian Classical Dance' WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_branch (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO military_branch (id, name) VALUES (1, 'Army'), (2, 'Navy'), (3, 'Air Force'), (4, 'Marines'), (5, 'Coast Guard'); CREATE TABLE missions (id INT PRIMARY KEY, military_branch_id INT, type VARCHAR(255), year INT, FOREIGN KEY (military_branch_id) REFERENCES military_branch(id)); INSERT INTO missions (id, military_branch_id, type, year) VALUES (1, 1, 'Humanitarian Assistance', 2020), (2, 2, 'Humanitarian Assistance', 2020), (3, 3, 'Humanitarian Assistance', 2020), (4, 4, 'Humanitarian Assistance', 2020), (5, 5, 'Humanitarian Assistance', 2020); | What is the total number of humanitarian assistance missions conducted by each military branch in 2020? | SELECT m.name, COUNT(missions.id) as total_missions FROM missions JOIN military_branch m ON missions.military_branch_id = m.id WHERE missions.type = 'Humanitarian Assistance' AND missions.year = 2020 GROUP BY m.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE nba_games (player VARCHAR(255), games_played INTEGER, games_won INTEGER); | List the players and the number of games they have won in the "nba_games" table | SELECT player, SUM(games_won) as total_wins FROM nba_games GROUP BY player; | gretelai_synthetic_text_to_sql |
CREATE TABLE Wins ( CaseID INT, AttorneyID INT, Region VARCHAR(50), CaseOutcome VARCHAR(50) ); INSERT INTO Wins (CaseID, AttorneyID, Region, CaseOutcome) VALUES (1, 1, 'Northeast', 'Won'), (2, 1, 'Northeast', 'Lost'), (3, 2, 'Northeast', 'Won'), (4, 2, 'Northeast', 'Won'), (5, 3, 'Midwest', 'Won'), (6, 3, 'Midwest', 'Lost'), (7, 4, 'Southwest', 'Won'), (8, 4, 'Southwest', 'Won'), (9, 5, 'West', 'Lost'), (10, 5, 'West', 'Lost'); CREATE TABLE Attorneys ( AttorneyID INT, AttorneyName VARCHAR(50), Region VARCHAR(50) ); INSERT INTO Attorneys (AttorneyID, AttorneyName, Region) VALUES (1, 'John Doe', 'Northeast'), (2, 'Jane Doe', 'Northeast'), (3, 'Bob Smith', 'Midwest'), (4, 'Alice Johnson', 'Southwest'), (5, 'David Williams', 'West'); | What is the number of cases and win rate for attorneys in the Midwest? | SELECT a.AttorneyName, a.Region, COUNT(w.CaseID) AS TotalCases, COUNT(w.CaseID) * 100.0 / SUM(COUNT(w.CaseID)) OVER (PARTITION BY a.Region) AS WinRate FROM Attorneys a JOIN Wins w ON a.AttorneyID = w.AttorneyID WHERE a.Region = 'Midwest' GROUP BY a.AttorneyName, a.Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (id INT, name VARCHAR(50), linguistically_diverse_staff INT); INSERT INTO mental_health_facilities (id, name, linguistically_diverse_staff) VALUES (1, 'Facility X', 10), (2, 'Facility Y', 5), (3, 'Facility Z', 15); | Rank mental health facilities by the number of linguistically diverse staff members? | SELECT name, RANK() OVER (ORDER BY linguistically_diverse_staff DESC) as ranking FROM mental_health_facilities; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_cultural_competency (state VARCHAR(20), score INT); INSERT INTO state_cultural_competency (state, score) VALUES ('California', 85), ('Texas', 90), ('New York', 88); CREATE TABLE state_population (state VARCHAR(20), population INT); INSERT INTO state_population (state, population) VALUES ('California', 40000000), ('Texas', 30000000), ('New York', 20000000); | What is the average cultural competency score for each state? | SELECT scc.state, AVG(scc.score) FROM state_cultural_competency scc INNER JOIN state_population sp ON scc.state = sp.state GROUP BY scc.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE LaborCosts (CostID int, ProjectID int, LaborCost money, Date date); CREATE TABLE Projects (ProjectID int, ProjectName varchar(255), State varchar(255), StartDate date, EndDate date, IsSustainable bit); | What is the total labor cost for construction projects in Texas in the past month? | SELECT SUM(LaborCost) as TotalLaborCosts FROM LaborCosts JOIN Projects ON LaborCosts.ProjectID = Projects.ProjectID WHERE State = 'Texas' AND Date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, team TEXT, location TEXT, attendees INT, year INT); INSERT INTO games (id, team, location, attendees, year) VALUES (1, 'Dragons', 'Hong Kong', 12000, 2022); INSERT INTO games (id, team, location, attendees, year) VALUES (2, 'Tigers', 'Tokyo', 15000, 2022); | What is the average number of fans attending games in Asia? | SELECT location, AVG(attendees) FROM games WHERE location LIKE '%Asia%' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_costs (project_id INT, sector VARCHAR(50), labor_cost FLOAT, year INT); INSERT INTO labor_costs (project_id, sector, labor_cost, year) VALUES (1, 'Sustainable', 30000, 2021), (2, 'Sustainable', 28000, 2021), (3, 'Sustainable', 35000, 2021); | What is the minimum labor cost for sustainable building projects in 2021? | SELECT MIN(labor_cost) FROM labor_costs WHERE sector = 'Sustainable' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (id INT, program VARCHAR(50), location VARCHAR(50), date DATE); | Show the total number of educational programs in 'community_education' table | SELECT COUNT(*) FROM community_education; | gretelai_synthetic_text_to_sql |
CREATE TABLE CyberSecurity (id INT, incident VARCHAR(255), date DATE, severity INT); INSERT INTO CyberSecurity (id, incident, date, severity) VALUES (1, 'Ransomware', '2022-05-01', 8); | What is the average severity of cybersecurity incidents related to 'Ransomware' that occurred on '2022-05-01'? | SELECT AVG(severity) as avg_severity FROM CyberSecurity WHERE incident = 'Ransomware' AND date = '2022-05-01'; | 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, 'South Africa', 'Western Cape', 'Sign Language Interpreters', 120); INSERT INTO accommodations (id, country, region, accommodation_type, count) VALUES (2, 'South Africa', 'Gauteng', 'Adaptive Equipment', 180); | What is the total number of accommodations provided in South Africa by accommodation type? | SELECT accommodation_type, SUM(count) as total_count FROM accommodations WHERE country = 'South Africa' GROUP BY accommodation_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_health_policy_analysis_v3 (id INT, policy_name VARCHAR(30), impact_score INT); | Update a record with public health policy analysis data for a specific policy | UPDATE public_health_policy_analysis_v3 SET impact_score = 78 WHERE policy_name = 'Policy C'; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability (location TEXT, capable BOOLEAN); INSERT INTO financial_capability (location, capable) VALUES ('City A', TRUE), ('City B', FALSE), ('City C', TRUE), ('Town D', TRUE); | How many financially capable individuals are there in the urban areas of the country? | SELECT COUNT(*) FROM financial_capability WHERE location LIKE '%urban%' AND capable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(50), location VARCHAR(50), date_time DATETIME); | List the top 5 locations with the most incidents | SELECT location, COUNT(*) AS incidents_count FROM incidents GROUP BY location ORDER BY incidents_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE contractors (id INT, name VARCHAR(50), country VARCHAR(50), registration_date DATE); | Insert a new record in the 'contractors' table with id 6, name 'EcoTech', country 'Canada', and registration_date '2021-06-22' | INSERT INTO contractors (id, name, country, registration_date) VALUES (6, 'EcoTech', 'Canada', '2021-06-22'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fleet_inventory (id INT, vessel_name TEXT, type TEXT, quantity INT); INSERT INTO fleet_inventory (id, vessel_name, type, quantity) VALUES (1, 'Cargo Vessel 1', 'Cargo', 20), (2, 'Tanker Vessel 1', 'Tanker', 30); | What is the total number of cargo vessels in the 'fleet_inventory' table? | SELECT SUM(quantity) FROM fleet_inventory WHERE type = 'Cargo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_line VARCHAR(10), date DATE, revenue FLOAT); INSERT INTO sales (product_line, date, revenue) VALUES ('Premium', '2021-04-01', 5500), ('Basic', '2021-04-01', 3500), ('Premium', '2021-04-02', 6500), ('Basic', '2021-04-02', 4500); | What was the total revenue for the "Basic" product line in Q2 2021? | SELECT SUM(revenue) FROM sales WHERE product_line = 'Basic' AND date BETWEEN '2021-04-01' AND '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls_2022 (id INT, call_date DATE); INSERT INTO emergency_calls_2022 (id, call_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2022-01-03'), (4, '2022-02-01'), (5, '2022-02-02'), (6, '2022-03-01'), (7, '2022-03-02'), (8, '2022-03-03'); | Show the number of days in 2022 where there were no emergency calls | SELECT call_date FROM emergency_calls_2022 GROUP BY call_date HAVING COUNT(*) = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE SolarPlant (region VARCHAR(50), capacity FLOAT); | How many solar power plants are there in the 'Southwest' region with a capacity greater than 100 MW? | SELECT COUNT(*) FROM SolarPlant WHERE region = 'Southwest' AND capacity > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_temperature_sargasso (location text, temperature numeric); INSERT INTO deep_sea_temperature_sargasso (location, temperature) VALUES ('Sargasso Sea', 30), ('Atlantic Ocean', 25); | What is the maximum temperature recorded in the Sargasso Sea? | SELECT MAX(temperature) FROM deep_sea_temperature_sargasso WHERE location = 'Sargasso Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, GamePreference VARCHAR(20)); INSERT INTO Players (PlayerID, Age, GamePreference) VALUES (1, 25, 'Racing'); | What is the average age of players who play racing games? | SELECT AVG(Age) FROM Players WHERE GamePreference = 'Racing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CargoTable (CargoId INT PRIMARY KEY, VesselId INT, CargoName VARCHAR(50), Weight INT); | Update the CargoTable, setting the 'Weight' column to '0' for cargos with a CargoId of 10, 15, or 20 | UPDATE CargoTable SET Weight = 0 WHERE CargoId IN (10, 15, 20); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(255)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education Support'), (2, 'Environment Conservation'), (3, 'Health Awareness'); | What is the total number of volunteers for each program? And which program has the highest total number of volunteers? | SELECT ProgramID, ProgramName, COUNT(VolunteerID) AS TotalVolunteers, RANK() OVER (ORDER BY COUNT(VolunteerID) DESC) AS ProgramRank FROM Volunteers JOIN Programs ON Volunteers.ProgramID = Programs.ProgramID GROUP BY ProgramID, ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE libraries (library_id INT, library_name TEXT, city TEXT, rating INT); INSERT INTO libraries (library_id, library_name, city, rating) VALUES (1, 'Harold Washington Library', 'Chicago', 9), (2, 'Chicago Public Library', 'Chicago', 8), (3, 'Sulzer Regional Library', 'Chicago', 7); | How many public libraries are there in the city of "Chicago" with a rating greater than or equal to 8? | SELECT COUNT(*) FROM libraries WHERE city = 'Chicago' AND rating >= 8; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (id INT, provider VARCHAR(100), initiative VARCHAR(100), amount FLOAT, year INT); INSERT INTO climate_finance (id, provider, initiative, amount, year) VALUES (1, 'World Bank', 'Climate Communication', 10000000, 2015), (2, 'UNDP', 'Climate Adaptation', 15000000, 2016); | Find the total climate finance provided by the World Bank for climate communication initiatives since 2015. | SELECT SUM(amount) FROM climate_finance WHERE provider = 'World Bank' AND initiative = 'Climate Communication' AND year >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure_Projects (Project_ID INT, Project_Name VARCHAR(50), Project_Type VARCHAR(50), Completion_Date DATE); INSERT INTO Infrastructure_Projects (Project_ID, Project_Name, Project_Type, Completion_Date) VALUES (1, 'Seawall', 'Resilience', '2021-02-28'), (2, 'Floodgate', 'Resilience', '2020-12-31'), (3, 'Bridge_Replacement', 'Transportation', '2021-01-31'), (4, 'Water_Main_Replacement', 'Utility', '2021-05-15'), (5, 'Sewer_System_Upgrade', 'Utility', '2020-09-30'); | What are the names and completion dates of all utility projects in the infrastructure database? | SELECT Project_Name, Completion_Date FROM Infrastructure_Projects WHERE Project_Type = 'Utility'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (region VARCHAR(255), year INT, project_type VARCHAR(255), funded BOOLEAN); | What is the number of climate adaptation projects in small island developing states (SIDS) that were initiated from 2010 to 2015, and how many of those projects received funding? | SELECT project_type, COUNT(*) AS num_projects, SUM(funded) AS num_funded FROM climate_projects WHERE year BETWEEN 2010 AND 2015 AND region IN (SELECT region FROM sids_list) GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE LiteratureFestival(id INT, funding_source VARCHAR(20), amount DECIMAL(10,2)); CREATE TABLE FilmFestival(id INT, funding_source VARCHAR(20), amount DECIMAL(10,2)); | What is the distribution of funding sources for the "Literature Festival" and "Film Festival" programs? | SELECT funding_source, SUM(amount) FROM LiteratureFestival GROUP BY funding_source UNION SELECT funding_source, SUM(amount) FROM FilmFestival GROUP BY funding_source; | gretelai_synthetic_text_to_sql |
CREATE TABLE whale_sharks (id INT, name TEXT, location TEXT, population INT); INSERT INTO whale_sharks (id, name, location, population) VALUES (1, 'Whale Shark', 'Atlantic', 450); | How many whale sharks are there in the Atlantic Ocean?" | SELECT SUM(population) FROM whale_sharks WHERE location = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_data (id INT, crop_type VARCHAR(255), soil_moisture INT, timestamp TIMESTAMP); INSERT INTO crop_data (id, crop_type, soil_moisture, timestamp) VALUES (1, 'Corn', 75, '2022-01-01 10:00:00'), (2, 'Soybeans', 80, '2022-01-01 10:00:00'); | What are the average soil moisture levels for each crop type in the past month? | SELECT crop_type, AVG(soil_moisture) FROM crop_data WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name TEXT, bio TEXT); CREATE VIEW article_authors AS SELECT a.id, a.name, a.bio, w.id as article_id, w.title, w.section, w.publish_date FROM website_articles w JOIN authors a ON w.author_id = a.id; | Who are the top 5 authors with the highest number of published articles in the "sports" section in 2020? | SELECT name, COUNT(*) as article_count FROM article_authors WHERE section = 'sports' AND publish_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY name ORDER BY article_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plant (plant_id INT, state VARCHAR(50), year INT, month INT, water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id, state, year, month, water_consumption) VALUES (1, 'California', 2020, 7, 12345.6), (2, 'California', 2020, 7, 23456.7), (3, 'California', 2020, 7, 34567.8); | What is the maximum water consumption in the month of July for each water treatment plant in the state of California in 2020? | SELECT plant_id, MAX(water_consumption) as max_water_consumption FROM water_treatment_plant WHERE state = 'California' AND year = 2020 AND month = 7 GROUP BY plant_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(100)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName) VALUES (1, 'ABC Garments'), (2, 'XYZ Textiles'); CREATE TABLE Waste (WasteID INT, ManufacturerID INT, WastePerGarment DECIMAL(5,2)); INSERT INTO Waste (WasteID, ManufacturerID, WastePerGarment) VALUES (1, 1, 5.3), (2, 1, 4.8), (3, 2, 6.1), (4, 2, 5.9); | What is the average waste generated per garment for each manufacturer? | SELECT m.ManufacturerName, AVG(w.WastePerGarment) AS AvgWastePerGarment FROM Manufacturers m JOIN Waste w ON m.ManufacturerID = w.ManufacturerID GROUP BY m.ManufacturerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT, founder_minority TEXT, founder_immigrant TEXT); | List the number of unique founders for companies in the edtech sector founded between 2010 and 2015. | SELECT COUNT(DISTINCT founder_gender, founder_minority, founder_immigrant) FROM companies WHERE industry = 'Edtech' AND founding_date BETWEEN '2010-01-01' AND '2015-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (id INT PRIMARY KEY, product_name VARCHAR(100), region VARCHAR(100), sales_amount DECIMAL(10,2)); INSERT INTO sales_data (id, product_name, region, sales_amount) VALUES (1, 'Shampoo', 'North America', 1000.00); INSERT INTO sales_data (id, product_name, region, sales_amount) VALUES (2, 'Conditioner', 'Europe', 1500.00); | What are the total sales for each region and product category, sorted by the highest sales? | SELECT region, product_category, SUM(sales_amount) as total_sales FROM sales_data sd INNER JOIN (SELECT product_name, 'Hair Care' as product_category FROM sales_data WHERE product_name = 'Shampoo' OR product_name = 'Conditioner' GROUP BY product_name) pcat ON sd.product_name = pcat.product_name GROUP BY region, product_category ORDER BY total_sales DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE immunizations (immunization_type VARCHAR(50), region VARCHAR(50), year INTEGER, doses_administered INTEGER); INSERT INTO immunizations (immunization_type, region, year, doses_administered) VALUES ('MMR', 'North', 2021, 12000), ('Polio', 'North', 2021, 15000), ('MMR', 'South', 2021, 10000), ('Polio', 'South', 2021, 18000), ('MMR', 'East', 2021, 14000), ('Polio', 'East', 2021, 16000); | Calculate the total number of childhood immunization doses administered, by type, in each region, for the year 2021. | SELECT region, immunization_type, SUM(doses_administered) as total_doses FROM immunizations WHERE year = 2021 GROUP BY region, immunization_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, garment_type VARCHAR(20), color VARCHAR(20), price DECIMAL(10, 2), quantity INT); | What are the top 3 most popular garment colors in terms of quantity sold? | SELECT color, SUM(quantity) AS total_quantity_sold FROM sales GROUP BY color ORDER BY total_quantity_sold DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), is_cruelty_free BOOLEAN, sales FLOAT); INSERT INTO products VALUES (1, 'Lipstick', false, 500.50), (2, 'Mascara', false, 300.00), (3, 'Foundation', true, 700.00); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions VALUES (1, 'Canada'), (2, 'USA'), (3, 'Europe'); CREATE TABLE time (time_id INT, year INT); INSERT INTO time VALUES (1, 2022); | What are the top 2 non-cruelty-free cosmetic products by sales in the European region for 2022? | SELECT p.product_name, p.sales FROM products p INNER JOIN regions r ON p.product_id = r.region_id INNER JOIN time t ON p.product_id = t.time_id WHERE p.is_cruelty_free = false GROUP BY p.product_name, p.sales, r.region_name, t.year ORDER BY p.sales DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2), transaction_date DATE); | Identify customers who have an account balance greater than any of their previous balances for the same account type. | SELECT customer_id, account_type, balance FROM (SELECT customer_id, account_type, balance, LAG(balance) OVER (PARTITION BY customer_id, account_type ORDER BY transaction_date) AS prev_balance FROM accounts) AS lagged_accounts WHERE balance > prev_balance; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, company VARCHAR(255), value FLOAT, date DATE); INSERT INTO defense_contracts (contract_id, company, value, date) VALUES (3, 'MNO Corp', 300000, '2020-01-01'); INSERT INTO defense_contracts (contract_id, company, value, date) VALUES (4, 'DEF Inc', 450000, '2020-01-05'); | What is the total value of defense contracts signed by company 'MNO Corp' in Q1 2020? | SELECT SUM(value) FROM defense_contracts WHERE company = 'MNO Corp' AND date BETWEEN '2020-01-01' AND '2020-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name TEXT, num_heritage_sites INT); INSERT INTO regions (id, name, num_heritage_sites) VALUES (1, 'West Africa', 12), (2, 'Amazon Basin', 3); CREATE TABLE countries (id INT, region_id INT, name TEXT, num_endangered_languages INT); INSERT INTO countries (id, region_id, name, num_endangered_languages) VALUES (1, 1, 'Nigeria', 500), (2, 1, 'Ghana', 100), (3, 2, 'Brazil', 200); CREATE TABLE communities (id INT, country_id INT, num_members INT, endangered_language BOOLEAN); INSERT INTO communities (id, country_id, num_members, endangered_language) VALUES (1, 1, 10000, true), (2, 1, 5000, false), (3, 2, 2000, true), (4, 3, 1000, false); | What is the total number of community members who speak an endangered language in each region with more than 10 heritage sites? | SELECT r.id, r.name, SUM(c.num_members) FROM regions r JOIN countries c ON r.id = c.region_id JOIN communities com ON c.id = com.country_id WHERE r.num_heritage_sites > 10 AND com.endangered_language = true GROUP BY r.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE tours (id INT, name VARCHAR(50), country VARCHAR(50), price INT); | Update the "price" to 200 for all records in the "tours" table where the "country" is "France" | UPDATE tours SET price = 200 WHERE country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streams (id INT, artist VARCHAR(255), count INT); INSERT INTO Streams (id, artist, count) VALUES (1, 'Taylor Swift', 10000000), (2, 'Justin Bieber', 8000000); | How many streams does 'Justin Bieber' have in total? | SELECT SUM(count) FROM Streams WHERE artist = 'Justin Bieber'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dish (dish_id INT, dish_name TEXT, category_id INT, waste_percentage DECIMAL(5,2), co2_emissions INT); INSERT INTO dish (dish_id, dish_name, category_id, waste_percentage, co2_emissions) VALUES (1, 'Pizza Margherita', 1, 0.12, 500), (2, 'Veggie Burger', 2, 0.18, 300); CREATE TABLE category (category_id INT, category_name TEXT); INSERT INTO category (category_id, category_name) VALUES (1, 'Italian'), (2, 'Vegetarian'); | What is the total CO2 emissions for each menu category in the last year? | SELECT c.category_name, SUM(d.co2_emissions) as total_co2_emissions FROM dish d JOIN category c ON d.category_id = c.category_id WHERE d.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY c.category_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50), disability BOOLEAN); INSERT INTO students (id, name, department, disability) VALUES (1, 'Alice Johnson', 'Engineering', TRUE), (2, 'Bob Smith', 'Engineering', FALSE), (3, 'Charlie Brown', 'Business', TRUE); CREATE TABLE mentors (id INT, student_id INT, mentor_name VARCHAR(50)); INSERT INTO mentors (id, student_id, mentor_name) VALUES (1, 1, 'Mentor 1'), (2, 3, 'Mentor 2'); | Which students with disabilities have not been assigned a mentor? | SELECT students.name FROM students LEFT JOIN mentors ON students.id = mentors.student_id WHERE mentors.id IS NULL AND students.disability = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE LegalAid (case_id INT, case_type VARCHAR(10)); INSERT INTO LegalAid (case_id, case_type) VALUES (1, 'civil'), (2, 'criminal'), (3, 'family'), (4, 'criminal'), (5, 'family'); | Show the 'case_id' and 'case_type' for cases in the 'LegalAid' table where the 'case_type' is 'civil' or 'family' | SELECT case_id, case_type FROM LegalAid WHERE case_type IN ('civil', 'family'); | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthFacilities (Id INT, State VARCHAR(255), CulturalCompetencyRating INT); INSERT INTO MentalHealthFacilities (Id, State, CulturalCompetencyRating) VALUES (1, 'California', 9); INSERT INTO MentalHealthFacilities (Id, State, CulturalCompetencyRating) VALUES (2, 'Texas', 7); INSERT INTO MentalHealthFacilities (Id, State, CulturalCompetencyRating) VALUES (3, 'New York', 8); | How many mental health facilities exist in each state that have a cultural competency rating above 8? | SELECT State, COUNT(*) FROM MentalHealthFacilities WHERE CulturalCompetencyRating > 8 GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteC (id INT PRIMARY KEY, artifact_name VARCHAR(50)); | What are the artifact names from 'SiteC'? | SELECT artifact_name FROM SiteC; | gretelai_synthetic_text_to_sql |
CREATE TABLE medical_facilities (facility_id INT, facility_name TEXT, state TEXT, num_beds INT); | Delete medical facilities in New Mexico with less than 5 beds. | DELETE FROM medical_facilities WHERE facility_id IN (SELECT facility_id FROM medical_facilities WHERE state = 'New Mexico' AND num_beds < 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_name VARCHAR(50));CREATE TABLE volunteers (volunteer_id INT, volunteer_program_id INT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Education'), (2, 'Environment'), (3, 'Health'); INSERT INTO volunteers (volunteer_id, volunteer_program_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3), (7, 3); | How many unique volunteers have participated in each program in 2019? | SELECT p.program_name, COUNT(DISTINCT v.volunteer_id) as unique_volunteers FROM programs p JOIN volunteers v ON p.program_id = v.volunteer_program_id GROUP BY p.program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_species (species_name TEXT, biomass REAL, ocean TEXT); INSERT INTO fish_species (species_name, biomass, ocean) VALUES ('Tuna', 5000.0, 'Pacific'), ('Salmon', 2000.0, 'Pacific'), ('Shark', 8000.0, 'Pacific'); | What is the total biomass of fish species in the Pacific Ocean? | SELECT SUM(biomass) FROM fish_species WHERE ocean = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_uk (project_name TEXT, type TEXT, capacity NUMERIC); INSERT INTO project_uk (project_name, type, capacity) VALUES ('Solar Park A', 'Solar', 5000), ('Solar Park B', 'Solar', 6000), ('Wind Farm C', 'Wind', 8000), ('Wind Farm D', 'Wind', 9000), ('Hydro Dam E', 'Hydro', 10000); | What is the combined energy output of all renewable energy projects in the United Kingdom? | SELECT SUM(capacity) FROM project_uk WHERE type IN ('Solar', 'Wind', 'Hydro'); | 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.