context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE fish_farms (farm_id INT, region VARCHAR(50), certification_status VARCHAR(50), year INT); | What is the percentage of organic certified fish farms in the Gulf of Mexico in 2020? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM fish_farms WHERE year = 2020)) as percentage FROM fish_farms WHERE region = 'Gulf of Mexico' AND certification_status = 'organic' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE bikeshare (station_id INT, city VARCHAR(20), num_bikes INT); INSERT INTO bikeshare (station_id, city, num_bikes) VALUES (1, 'Denver', 30), (2, 'Denver', 20), (3, 'Denver', 40); | Find the maximum number of bikes available at any bike-share station in the city of Denver. | SELECT MAX(num_bikes) FROM bikeshare WHERE city = 'Denver'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_name VARCHAR(255), developer_id INT, contract_status VARCHAR(10)); CREATE TABLE decentralized_exchanges (exchange_name VARCHAR(255), developer_id INT, transaction_count INT, trading_volume DECIMAL(10, 2)); | Find the total number of transactions and trading volume for each developer and smart contract status ('active', 'inactive', or 'pending') in the 'smart_contracts' and 'decentralized_exchanges' tables, and display the results in ascending order by the total trading volume. | SELECT s.contract_status, d.developer_name, SUM(de.transaction_count) as total_transactions, SUM(de.trading_volume) as total_volume FROM smart_contracts s INNER JOIN decentralized_exchanges de ON s.developer_id = de.developer_id INNER JOIN developers d ON s.developer_id = d.developer_id GROUP BY s.contract_status, d.de... | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (customer_id INT, transaction_amount DECIMAL(10,2), country VARCHAR(50)); INSERT INTO transactions (customer_id, transaction_amount, country) VALUES (1, 120.50, 'France'), (2, 75.30, 'France'), (3, 50.00, 'France'), (4, 150.00, 'France'); | List all customers and their transaction amounts who have made a transaction over 100 in France. | SELECT customer_id, transaction_amount FROM transactions WHERE country = 'France' AND transaction_amount > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(50), team VARCHAR(50), conference VARCHAR(50), followers INT); INSERT INTO athletes (id, name, team, conference, followers) VALUES (1, 'John Doe', 'TeamA', 'Eastern', 500000), (2, 'Jane Smith', 'TeamB', 'Eastern', 700000), (3, 'Mike Johnson', 'TeamC', 'Western', 800000); | Which athletes have the highest number of social media followers in the Eastern Conference? | SELECT name, followers FROM athletes WHERE conference = 'Eastern' ORDER BY followers DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(30), genre VARCHAR(20), rating INT); | What is the average rating of artworks in the 'Fauvism' genre, excluding artworks with a rating of 0, and also show the total number of artworks in this genre. | SELECT AVG(Artwork.rating) AS avg_rating, COUNT(Artwork.artwork_id) AS total_artworks FROM Artwork WHERE Artwork.genre = 'Fauvism' AND Artwork.rating > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryTechnologies (Tech VARCHAR(50), YearDiscontinued INT); INSERT INTO MilitaryTechnologies (Tech, YearDiscontinued) VALUES ('Landmines', 2015), ('Chemical Weapons', 2016), ('Biological Weapons', 2017), ('Cluster Bombs', 2018), ('Tactical Nuclear Weapons', 2005); | Find the total number of military technologies that were discontinued before 2010. | SELECT COUNT(*) FROM MilitaryTechnologies WHERE YearDiscontinued < 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials_2(trial_name TEXT, start_date DATE, end_date DATE); INSERT INTO clinical_trials_2(trial_name, start_date, end_date) VALUES('Trial1', '2019-05-01', '2020-02-15'), ('Trial2', '2020-07-15', '2021-06-30'), ('Trial3', '2021-01-01', '2022-12-31'), ('Trial4', '2018-04-05', '2019-09-30'); | List the clinical trials that have a start date on or after 2020-01-01 and their respective end dates. | SELECT trial_name, end_date FROM clinical_trials_2 WHERE start_date >= '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, country VARCHAR(50), gender VARCHAR(10), is_construction_worker BOOLEAN); INSERT INTO workers (id, country, gender, is_construction_worker) VALUES (1, 'USA', 'Male', true), (2, 'Canada', 'Female', true), (3, 'USA', 'Female', false), (4, 'Canada', 'Male', true); | What is the total number of construction workers employed in the US and Canada, and how many of them are women? | SELECT w.country, COUNT(w.id) as total_workers, SUM(CASE WHEN w.gender = 'Female' AND w.is_construction_worker = true THEN 1 ELSE 0 END) as female_construction_workers FROM workers w WHERE w.country IN ('USA', 'Canada') GROUP BY w.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT, name TEXT, date TEXT, project_type TEXT, energy_consumption FLOAT); INSERT INTO project (id, name, date, project_type, energy_consumption) VALUES (1, 'Solar Farm', '2020-01-01', 'Solar', 2.5); | What is the trend in energy consumption over time for solar projects? | SELECT date, energy_consumption, ROW_NUMBER() OVER (ORDER BY date) AS rank FROM project WHERE project_type = 'Solar' ORDER BY date; | gretelai_synthetic_text_to_sql |
CREATE TABLE pharmacies (id INT, name TEXT, city TEXT, state TEXT, num_employees INT, last_inspection_date DATE); INSERT INTO pharmacies (id, name, city, state, num_employees, last_inspection_date) VALUES (1, 'CVS Pharmacy', 'Miami', 'FL', 25, '2019-11-05'); INSERT INTO pharmacies (id, name, city, state, num_employees,... | What is the total number of employees in pharmacies in Miami, FL? | SELECT SUM(num_employees) FROM pharmacies WHERE city = 'Miami' AND state = 'FL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_personnel (id INT PRIMARY KEY, name VARCHAR(100), rank VARCHAR(50), department VARCHAR(50), num_personnel INT); INSERT INTO military_personnel (id, name, rank, department, num_personnel) VALUES (1, 'Ali Ahmed', 'Captain', 'Navy', 5000), (2, 'Zara Ali', 'Colonel', 'Air Force', 3000); | What is the total number of naval and air force personnel in the 'military_personnel' table? | SELECT SUM(num_personnel) FROM military_personnel WHERE department IN ('Navy', 'Air Force'); | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(100), crop VARCHAR(50), country VARCHAR(50)); INSERT INTO farmers (id, name, crop, country) VALUES (1, 'Ali', 'wheat', 'Pakistan'); | What is the total number of farmers in each country who grow a specific crop? | SELECT country, COUNT(*) FROM farmers WHERE crop = 'wheat' GROUP BY country | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing_centers (id INT, center_name TEXT); INSERT INTO community_policing_centers (id, center_name) VALUES (1, 'Center A'), (2, 'Center B'), (3, 'Center C'); CREATE TABLE emergency_incidents (id INT, center_id INT, incident_type TEXT, incident_count INT); INSERT INTO emergency_incidents (id, ce... | What is the total number of emergency incidents reported by each community policing center, broken down by incident type? | SELECT center_id, incident_type, SUM(incident_count) AS total_incidents FROM emergency_incidents GROUP BY center_id, incident_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_ai_asia (budget INT); INSERT INTO ethical_ai_asia (budget) VALUES (50000), (60000), (70000); | What is the maximum budget allocated to ethical AI projects in Asia? | SELECT MAX(budget) FROM ethical_ai_asia; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50), AvgRegularTicketPrice DECIMAL(5,2)); | Which teams have the highest and lowest average ticket prices for regular seats? | SELECT TeamName FROM Teams WHERE AvgRegularTicketPrice = (SELECT MAX(AvgRegularTicketPrice) FROM Teams) OR AvgRegularTicketPrice = (SELECT MIN(AvgRegularTicketPrice) FROM Teams); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name TEXT, region TEXT);INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Great White Shark', 'Pacific'), (2, 'Blue Whale', 'Atlantic'), (3, 'Giant Pacific Octopus', 'Pacific'), (4, 'Green Sea Turtle', 'Atlantic'); | List all the marine species and their corresponding regions. | SELECT species_name, region FROM marine_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (event_id INT, location VARCHAR(50), genre VARCHAR(50)); INSERT INTO esports_events (event_id, location, genre) VALUES (1, 'Seoul, Korea', 'MOBA'), (2, 'Beijing, China', 'FPS'), (3, 'Tokyo, Japan', 'RTS'), (4, 'Paris, France', 'MOBA'), (5, 'New York, USA', 'FPS'); | How many esports events have been hosted in each continent? | SELECT SUBSTRING(location, 1, INSTR(location, ',') - 1) AS continent, COUNT(*) AS num_events FROM esports_events GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, founder_race TEXT); CREATE TABLE investment (startup_id INT, investment_amount INT); INSERT INTO startup (id, name, founder_race) VALUES (1, 'Kappa Enterprises', 'African American'); INSERT INTO investment (startup_id, investment_amount) VALUES (1, 1500000); INSERT INTO startup ... | List all startups that have had an investment round of at least $1,000,000 and have a founder from an underrepresented racial or ethnic group. | SELECT s.name FROM startup s INNER JOIN investment i ON s.id = i.startup_id WHERE i.investment_amount >= 1000000 AND s.founder_race IN ('African American', 'Latinx', 'Native American', 'Pacific Islander'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Researchers (id INT, name VARCHAR(255), affiliation VARCHAR(255), publications INT); INSERT INTO Researchers (id, name, affiliation, publications) VALUES (1, 'Alice', 'University of California, Berkeley', 20), (2, 'Bob', 'MIT', 15), (3, 'Charlie', 'Stanford University', 30), (4, 'David', 'Carnegie Mellon U... | Who are the top 3 contributors to algorithmic fairness research by number of publications? | SELECT name, affiliation, publications FROM (SELECT name, affiliation, publications, RANK() OVER (ORDER BY publications DESC) as rank FROM Researchers) subquery WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (ClaimID int, PolicyID int, State varchar(50), ClaimAmount decimal(10, 2)); INSERT INTO Claims (ClaimID, PolicyID, State, ClaimAmount) VALUES (1, 1001, 'California', 4500.00), (2, 1002, 'Texas', 3200.00), (3, 1003, 'California', 5700.00), (4, 1004, 'New York', 6100.00); | List the top 3 states with the highest claim amounts? | SELECT State, SUM(ClaimAmount) AS TotalClaimAmount FROM Claims GROUP BY State ORDER BY TotalClaimAmount DESC LIMIT 3 | gretelai_synthetic_text_to_sql |
CREATE TABLE AircraftDimensions (Company VARCHAR(50), Model VARCHAR(50), Wingspan INT); INSERT INTO AircraftDimensions (Company, Model, Wingspan) VALUES ('Boeing', '747', 211), ('Boeing', '787 Dreamliner', 197), ('Airbus', 'A320', 118), ('Airbus', 'A380', 262), ('Bombardier', 'CRJ700', 91); | What is the average wingspan of aircraft manufactured by 'Bombardier'? | SELECT AVG(Wingspan) FROM AircraftDimensions WHERE Company = 'Bombardier'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, location VARCHAR(20), cost FLOAT); INSERT INTO wells (id, location, cost) VALUES (1, 'Gulf of Mexico', 1000000.0), (2, 'Alaska', 1500000.0); | Calculate the total production cost for wells in the Gulf of Mexico | SELECT SUM(cost) FROM wells w WHERE w.location = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, address TEXT); INSERT INTO donors (donor_id, donor_name, address) VALUES (1, 'John Doe', '456 Elm St'), (2, 'Jane Smith', '789 Oak Rd'); | Update the address of donor with ID 3 to '123 Main St'? | UPDATE donors SET address = '123 Main St' WHERE donor_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_id INT, product_name TEXT, customer_location TEXT, purchase_date DATE); INSERT INTO sales (product_id, product_name, customer_location, purchase_date) VALUES (1, 'Lipstick A', 'California', '2021-06-01'), (2, 'Lipstick B', 'California', '2021-07-15'), (3, 'Lipstick C', 'California', '2021-08... | What are the top 5 most purchased lipsticks by customers located in California, considering sales from the past 6 months? | SELECT product_name, COUNT(*) AS sales_count FROM sales WHERE customer_location = 'California' AND purchase_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY product_name ORDER BY sales_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, FavoriteExercise VARCHAR(20)); CREATE TABLE Wearables (DeviceID INT, MemberID INT, Type VARCHAR(20)); INSERT INTO Members (MemberID, Age, FavoriteExercise) VALUES (1, 35, 'Yoga'); INSERT INTO Members (MemberID, Age, FavoriteExercise) VALUES (2, 28, 'Running'); INSERT INTO We... | List the unique wearable device types for members doing yoga. | SELECT DISTINCT Type FROM Members JOIN Wearables ON Members.MemberID = Wearables.MemberID WHERE FavoriteExercise = 'Yoga'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budgets (budget_id INT, budget_year INT, budget_amount DECIMAL(10, 2)); | What is the average budget for disability services initiatives per year? | SELECT AVG(budget_amount) FROM budgets WHERE budget_category = 'Disability Services'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, donation_date DATE, amount_donated DECIMAL(10,2)); CREATE TABLE donors (id INT, name TEXT, donor_type TEXT); | Insert a new record for a donation of $500 made by a corporate donor named "ABC Corp" on March 15, 2022. | INSERT INTO donations (id, donor_id, donation_date, amount_donated) VALUES (1, (SELECT id FROM donors WHERE name = 'ABC Corp' AND donor_type = 'Corporate' LIMIT 1), '2022-03-15', 500); INSERT INTO donors (id, name, donor_type) VALUES (1, 'ABC Corp', 'Corporate') ON DUPLICATE KEY UPDATE id = id; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_temperature (id INT PRIMARY KEY, location VARCHAR(255), temperature FLOAT, month DATE); INSERT INTO ocean_temperature (id, location, temperature, month) VALUES (1, 'Great_Barrier_Reef', 28.5, '2022-04-01'); | Show ocean temperatures for locations with high coral bleaching risk. | SELECT location, temperature FROM ocean_temperature WHERE location IN ('Great_Barrier_Reef', 'Coral_Triangle'); | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (threat_actor VARCHAR(50), is_internal BOOLEAN, incident_year INTEGER); INSERT INTO security_incidents (threat_actor, is_internal, incident_year) VALUES ('APT28', true, 2022); INSERT INTO security_incidents (threat_actor, is_internal, incident_year) VALUES ('Lazarus Group', false, 2022); | Identify the top 5 threat actors by the number of security incidents they have been involved in, during the current year, both internal and external incidents. | SELECT threat_actor, COUNT(*) AS incident_count FROM security_incidents WHERE incident_year = EXTRACT(YEAR FROM NOW()) GROUP BY threat_actor ORDER BY incident_count DESC LIMIT 5 | gretelai_synthetic_text_to_sql |
CREATE TABLE world_countries (id INT PRIMARY KEY, country VARCHAR(20)); INSERT INTO world_countries (id, country) VALUES (1, 'France'); INSERT INTO world_countries (id, country) VALUES (2, 'Germany'); INSERT INTO open_data (id, country, year, num_initiatives) VALUES (1, 'France', 2017, 25); INSERT INTO open_data (id, c... | What was the total number of open data initiatives in the world in 2017? | SELECT SUM(num_initiatives) FROM open_data INNER JOIN world_countries ON open_data.country = world_countries.country WHERE open_data.year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, date DATE); INSERT INTO virtual_tours (tour_id, hotel_id, date) VALUES (1, 4, '2022-02-15'), (2, 4, '2022-02-17'), (3, 5, '2022-03-01'), (4, 5, '2022-03-05'); CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT); INSERT INTO hotels (hotel_id, hotel_nam... | What is the average number of virtual tours per hotel in Germany? | SELECT AVG(vt.count) FROM (SELECT hotel_id, COUNT(*) as count FROM virtual_tours GROUP BY hotel_id) as vt INNER JOIN hotels h ON vt.hotel_id = h.hotel_id WHERE h.country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, school_id INT, grade_level INT, score INT); INSERT INTO student_mental_health (student_id, school_id, grade_level, score) VALUES (1, 100, 6, 80), (2, 100, 6, 75), (3, 200, 7, 90), (4, 200, 7, 85), (5, 300, 8, 70); | What is the average mental health score for students in each school that has more than 2 grade levels? | SELECT school_id, AVG(score) as avg_score FROM student_mental_health GROUP BY school_id HAVING COUNT(DISTINCT grade_level) > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE african_conservation_programs (id INT, program_name VARCHAR(255), region VARCHAR(255)); INSERT INTO african_conservation_programs (id, program_name, region) VALUES (1, 'Samburu National Reserve', 'Kenya'), (2, 'Garamba National Park', 'DRC'); CREATE TABLE elephants (id INT, name VARCHAR(255), age INT, cons... | Find the average age of all elephants in African conservation programs | SELECT AVG(elephants.age) FROM elephants INNER JOIN african_conservation_programs ON elephants.conservation_program_id = african_conservation_programs.id WHERE african_conservation_programs.region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budgets (id INT, category TEXT, amount FLOAT, country TEXT); INSERT INTO budgets (id, category, amount, country) VALUES (1, 'education', 20000000, 'Canada'); | What is the total budget allocated for education in Canada? | SELECT SUM(budgets.amount) FROM budgets WHERE budgets.category = 'education' AND budgets.country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID int, SupplierName varchar(50), Address varchar(100), Country varchar(50)); INSERT INTO Suppliers VALUES (1, 'Supplier1', '123 Main St, California', 'USA'); INSERT INTO Suppliers VALUES (2, 'Supplier2', '456 Oak St, New York', 'USA'); CREATE TABLE Products (ProductID int, ProductName v... | What is the total revenue of all products sold by suppliers in 'California'? | SELECT SUM(Products.Revenue) FROM Products INNER JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Suppliers.Country = 'USA' AND Suppliers.State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nyc_inspections (inspection_id INT, borough VARCHAR(20), violation_date DATE, fine_amount INT); | How many food safety inspection violations occurred in each borough of New York City in 2020, and what was the total fine amount per borough? | SELECT borough, COUNT(*) as violation_count, SUM(fine_amount) as total_fine FROM nyc_inspections WHERE violation_date >= '2020-01-01' AND violation_date < '2021-01-01' GROUP BY borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_2 (drug_name TEXT, qty_sold INTEGER, sale_date DATE); INSERT INTO sales_2 (drug_name, qty_sold, sale_date) VALUES ('DrugG', 400, '2021-01-01'), ('DrugG', 450, '2021-02-01'), ('DrugG', 500, '2021-03-01'); | Decrease sales of 'DrugG' by 20% in Q1 2021. | UPDATE sales_2 SET qty_sold = FLOOR(qty_sold * 0.80) WHERE drug_name = 'DrugG' AND sale_date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Atlanta Hawks'), (2, 'Boston Celtics'); CREATE TABLE fan_demographics (fan_id INT, team_id INT, age INT); INSERT INTO fan_demographics (fan_id, team_id, age) VALUES (1, 1, 35), (2, 1, 45), (3, 2, 25), (4, 2, 30)... | What is the average age of fans for each team? | SELECT t.team_name, AVG(fd.age) as avg_age FROM teams t INNER JOIN fan_demographics fd ON t.team_id = fd.team_id GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_access (country VARCHAR(20), uninsured_percentage DECIMAL(5,2)); INSERT INTO healthcare_access (country, uninsured_percentage) VALUES ('Canada', 5.0), ('Mexico', 40.0); | What is the percentage of uninsured individuals in Canada and Mexico? | SELECT AVG(uninsured_percentage) FROM healthcare_access WHERE country IN ('Canada', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_research (id INT, author VARCHAR(50), country VARCHAR(50), concern VARCHAR(100)); INSERT INTO ai_safety_research (id, author, country, concern) VALUES (1, 'Grace Taylor', 'Australia', 'Data Privacy'), (2, 'Liam Wong', 'Singapore', 'Algorithmic Bias'); | Retrieve distinct AI safety concerns mentioned in research by Australian and Singaporean authors. | SELECT DISTINCT concern FROM ai_safety_research WHERE country IN ('Australia', 'Singapore'); | gretelai_synthetic_text_to_sql |
CREATE TABLE la_residential_water (year INT, month INT, consumption FLOAT, city VARCHAR(255), state VARCHAR(255)); INSERT INTO la_residential_water (year, month, consumption, city, state) VALUES (2017, 1, 12000, 'Los Angeles', 'CA'), (2017, 2, 11000, 'Los Angeles', 'CA'), (2017, 3, 13000, 'Los Angeles', 'CA'), (2018, 1... | What is the average monthly water consumption for residential use in Los Angeles, CA, for the years 2017 and 2018, broken down by month? | SELECT month, AVG(consumption) as avg_consumption FROM la_residential_water WHERE city = 'Los Angeles' AND state = 'CA' AND year IN (2017, 2018) GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(255), launch_country VARCHAR(50)); INSERT INTO space_missions (mission_id, mission_name, launch_country) VALUES (1, 'Apollo 11', 'USA'), (2, 'Sputnik 1', 'Russia'); | How many space missions were led by countries other than the US and Russia? | SELECT COUNT(*) FROM space_missions WHERE launch_country NOT IN ('USA', 'Russia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE product_safety (product_name VARCHAR(100), launch_year INT, safety_rating DECIMAL(3,2), country VARCHAR(100)); INSERT INTO product_safety (product_name, launch_year, safety_rating, country) VALUES ('Lush Cleanser', 2020, 4.8, 'India'), ('The Body Shop Moisturizer', 2020, 4.6, 'India'), ('Pacifica Serum', 2... | What percentage of cosmetic products from India have a safety rating above 4.5? | SELECT country, 100.0 * AVG(CASE WHEN safety_rating > 4.5 THEN 1 ELSE 0 END) AS pct_safety_rating FROM product_safety WHERE country = 'India' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonOffsetProjects (id INT, year INT, co2_offset FLOAT); INSERT INTO CarbonOffsetProjects (id, year, co2_offset) VALUES (1, 2020, 1000), (2, 2020, 2000), (3, 2021, 3000); | What is the maximum CO2 offset for carbon offset projects in a given year? | SELECT MAX(co2_offset) FROM CarbonOffsetProjects WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name VARCHAR(50), location VARCHAR(50), year INT, attendance INT); INSERT INTO heritage_sites (id, name, location, year, attendance) VALUES (1, 'Angkor Wat', 'Asia', 2017, 2500000), (2, 'Taj Mahal', 'Asia', 2018, 3000000), (3, 'Machu Picchu', 'South America', 2019, 1500000); | What is the total attendance at heritage sites in Asia in the last 5 years? | SELECT SUM(attendance) FROM heritage_sites WHERE location = 'Asia' AND year BETWEEN 2017 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE well (well_id INT, well_name TEXT, shale_play TEXT, gas_production_2020 FLOAT); INSERT INTO well (well_id, well_name, shale_play, gas_production_2020) VALUES (1, 'Well A', 'Permian Basin', 9000), (2, 'Well B', 'Permian Basin', 11000), (3, 'Well C', 'Permian Basin', 8000); | What is the average gas production for wells in the Permian Basin in 2020? | SELECT AVG(gas_production_2020) as average_gas_production FROM well WHERE shale_play = 'Permian Basin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyId INT, PolicyType VARCHAR(50), IssueDate DATE, Region VARCHAR(50)); | What is the policy type and number of policies issued per region for the last quarter? | SELECT Region, PolicyType, COUNT(PolicyId) FROM Policy WHERE IssueDate >= DATEADD(quarter, -1, GETDATE()) GROUP BY Region, PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtistExhibitions (id INT, artist_id INT, city VARCHAR(20), price DECIMAL(5,2)); INSERT INTO ArtistExhibitions (id, artist_id, city, price) VALUES (1, 1, 'Paris', 30.00), (2, 1, 'Rome', 25.00), (3, 2, 'Paris', 35.00), (4, 2, 'London', 20.00); CREATE TABLE Artists (id INT, name VARCHAR(30)); INSERT INTO Art... | What is the name of the artist with the highest ticket price for their exhibitions in Paris? | SELECT Artists.name, ArtistExhibitions.price FROM Artists JOIN ArtistExhibitions ON Artists.id = ArtistExhibitions.artist_id WHERE city = 'Paris' ORDER BY price DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams (id INT PRIMARY KEY, dam_name VARCHAR(255), year_built INT, region VARCHAR(255), current_age INT); INSERT INTO dams (id, dam_name, year_built, region, current_age) VALUES (1, 'Dam A', 1965, 'Western', 56); INSERT INTO dams (id, dam_name, year_built, region, current_age) VALUES (2, 'Dam B', 1975, 'West... | What is the average lifespan of dams in the Western region that were built between 1950 and 1970, and the number of such dams? | SELECT AVG(current_age), COUNT(*) FROM dams WHERE region = 'Western' AND year_built BETWEEN 1950 AND 1970; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (region VARCHAR(50), festival_performance INT); INSERT INTO Artists (region, festival_performance) VALUES ('Asia', 1); INSERT INTO Artists (region, festival_performance) VALUES ('Asia', 1); | How many unique artists are from Asia and performed at music festivals in 2020? | SELECT COUNT(DISTINCT region) FROM Artists WHERE region = 'Asia' AND festival_performance = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfectiousDiseases (Id INT, Disease TEXT, Region TEXT, Date DATE); INSERT INTO InfectiousDiseases (Id, Disease, Region, Date) VALUES (1, 'Measles', 'Region A', '2022-01-01'); INSERT INTO InfectiousDiseases (Id, Disease, Region, Date) VALUES (2, 'Mumps', 'Region A', '2022-01-02'); INSERT INTO InfectiousDise... | How many infectious diseases have been reported in each region? | SELECT Region, Disease FROM InfectiousDiseases GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT PRIMARY KEY, name VARCHAR(255), population INT, built_year INT); INSERT INTO cities (id, name, population, built_year) VALUES (1, 'CityA', 120000, 1950), (2, 'CityB', 250000, 1880), (3, 'CityC', 50000, 1985); | What is the average population of cities built before 1900? | SELECT AVG(population) as avg_population FROM cities WHERE built_year < 1900; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (donor_id INT, donation_amount FLOAT, donation_date DATE, cause VARCHAR(255)); INSERT INTO Donations (donor_id, donation_amount, donation_date, cause) VALUES (1, 500.00, '2021-01-01', 'Education'), (2, 300.00, '2021-02-03', 'Health'), (3, 800.00, '2021-05-05', 'Education'); | What was the total amount donated by individual donors to the 'Education' cause in '2021'? | SELECT SUM(donation_amount) FROM Donations WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' AND cause = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, year INT, region VARCHAR(255), oil_production DECIMAL(5,2), gas_production DECIMAL(5,2)); INSERT INTO production (id, year, region, oil_production, gas_production) VALUES (1, 2015, 'US', 1000.0, 500.0), (2, 2016, 'US', 1200.0, 550.0), (3, 2017, 'US', 1500.0, 600.0), (4, 2018, 'US', 1800... | What is the total production of oil and gas in the US for the years 2015 to 2018? | SELECT SUM(oil_production + gas_production) as total_production FROM production WHERE year BETWEEN 2015 AND 2018 AND region = 'US'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, name TEXT, genre TEXT, visitor_count INT, country TEXT); | Identify the top 3 countries with the highest total visitor count for 'Contemporary' art exhibitions. | SELECT country, SUM(visitor_count) as total_visitors FROM Exhibitions WHERE genre = 'Contemporary' GROUP BY country ORDER BY total_visitors DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, policy_number INT, claim_amount INT, region TEXT); INSERT INTO policies VALUES (1, 1234, 5000, 'New York'); INSERT INTO policies VALUES (2, 5678, 7000, 'New York'); INSERT INTO policies VALUES (3, 9012, 1500, 'New York'); INSERT INTO policies VALUES (4, 3456, 2500, 'New York'); | What is the percentage of policies with a claim amount less than $2000 in the 'New York' region? | SELECT (COUNT(*) FILTER (WHERE claim_amount < 2000)) * 100.0 / COUNT(*) FROM policies WHERE region = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_health_workers (state VARCHAR(2), num_workers INT); INSERT INTO state_health_workers (state, num_workers) VALUES ('NY', 100), ('CA', 150), ('TX', 200); | What is the minimum number of community health workers by state? | SELECT state, MIN(num_workers) OVER (PARTITION BY 1) as min_workers FROM state_health_workers; | gretelai_synthetic_text_to_sql |
CREATE TABLE Fish (FishID INT, FishSpecies VARCHAR(50), AvgWeight FLOAT); INSERT INTO Fish (FishID, FishSpecies, AvgWeight) VALUES (1, 'Salmon', 6.5), (2, 'Tilapia', 1.2), (3, 'Carp', 2.8), (4, 'Pangasius', 3.5), (5, 'Tuna', 15.5), (6, 'Shark', 18.2); | Which fish species have the highest average weight? | SELECT FishSpecies, AvgWeight, DENSE_RANK() OVER (ORDER BY AvgWeight DESC) as rank FROM Fish; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (id INT, name VARCHAR(50), location VARCHAR(50), yearsOfExperience INT); INSERT INTO CommunityHealthWorkers (id, name, location, yearsOfExperience) VALUES (1, 'Jamal Johnson', 'Atlanta', 7), (2, 'Aaliyah Brown', 'New York', 6); | Who are the community health workers located in Atlanta with more than 3 years of experience? | SELECT * FROM CommunityHealthWorkers WHERE location = 'Atlanta' AND yearsOfExperience > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_data (chemical_name VARCHAR(255), waste_amount INT, chemical_category VARCHAR(255)); INSERT INTO waste_data (chemical_name, waste_amount, chemical_category) VALUES ('Acetone', 150, 'Solvent'), ('Hydrochloric Acid', 200, 'Acid'), ('Sodium Hydroxide', 100, 'Base'); | List the total amount of waste produced by each chemical category in the waste_data table. | SELECT chemical_category, SUM(waste_amount) FROM waste_data GROUP BY chemical_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Game_Design (GameID INT, GameName VARCHAR(100), Genre VARCHAR(50), Platform VARCHAR(50)); INSERT INTO Game_Design (GameID, GameName, Genre, Platform) VALUES (1, 'GameA', 'Action', 'PC'), (2, 'GameB', 'Adventure', 'Console'), (3, 'GameC', 'Action', 'Console'), (4, 'GameD', 'Simulation', 'VR'); | List all unique genres of games from the 'Game Design' table, sorted alphabetically. | SELECT DISTINCT Genre FROM Game_Design ORDER BY Genre; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA socialmedia;CREATE TABLE posts (id INT, user_id INT, timestamp TIMESTAMP, region VARCHAR(255));INSERT INTO posts (id, user_id, timestamp, region) VALUES (1, 1, '2022-01-01 12:00:00', 'Africa'), (2, 2, '2022-02-15 15:00:00', 'Africa'); | What was the total number of posts made by users in Africa in each month of 2022? | SELECT EXTRACT(MONTH FROM timestamp) AS month, COUNT(DISTINCT user_id) AS total_posts FROM socialmedia.posts WHERE region = 'Africa' GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (id INT, name VARCHAR(255), avg_annual_precipitation DECIMAL(5,2)); INSERT INTO Regions (id, name, avg_annual_precipitation) VALUES (1, 'R1', 900.50), (2, 'R2', 1200.75), (3, 'R3', 750.23); CREATE TABLE Projects (id INT, region_id INT, project_name VARCHAR(255), start_date DATE); INSERT INTO Projec... | What is the average annual precipitation in regions with ongoing rural infrastructure projects? | SELECT AVG(Regions.avg_annual_precipitation) FROM Regions INNER JOIN Projects ON Regions.id = Projects.region_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO ports (id, name, country) VALUES (1, 'Los Angeles', 'USA'), (2, 'Singapore', 'Singapore'), (3, 'Rotterdam', 'Netherlands'), (4, 'Busan', 'South Korea'), (5, 'Hamburg', 'Germany'); | Show the number of unique countries where the company has operated. | SELECT COUNT(DISTINCT country) FROM ports; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability (id INT, country VARCHAR(20), capability DECIMAL(3, 2)); INSERT INTO financial_capability (id, country, capability) VALUES (1, 'Canada', 0.85), (2, 'Australia', 0.83), (3, 'Sweden', 0.82), (4, 'Norway', 0.81), (5, 'Finland', 0.80); | Find the top 3 countries with the highest financial capability. | SELECT country, capability FROM (SELECT country, capability, ROW_NUMBER() OVER (ORDER BY capability DESC) rn FROM financial_capability) t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE communitydev.initiatives (id INT, initiative_type VARCHAR(50), budget FLOAT); INSERT INTO communitydev.initiatives (id, initiative_type, budget) VALUES (1, 'Education', 10000), (2, 'Healthcare', 15000), (3, 'Agriculture', 20000), (4, 'Education', 12000), (5, 'Healthcare', 18000); | What is the total budget for community development initiatives in the 'communitydev' schema for each initiative type? | SELECT initiative_type, SUM(budget) FROM communitydev.initiatives GROUP BY initiative_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE rigs (rig_id INT, rig_name VARCHAR(100), status VARCHAR(50), region VARCHAR(50)); INSERT INTO rigs (rig_id, rig_name, status, region) VALUES (1, 'Rig X', 'Active', 'Middle East'), (2, 'Rig Y', 'Idle', 'Middle East'); | How many active drilling rigs are there currently in the Middle East? | SELECT COUNT(*) FROM rigs WHERE status = 'Active' AND region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE polar_bear_population (country VARCHAR(255), year INT, population INT); | How many polar bears are there in Canada and Russia? | SELECT SUM(population) FROM polar_bear_population WHERE country IN ('Canada', 'Russia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO workouts (id, user_id, workout_type, duration) VALUES (1, 101, 'Treadmill', 30), (2, 102, 'Treadmill', 45), (3, 103, 'Treadmill', 60), (4, 104, 'Elliptical', 30), (5, 105, 'Yoga', 60), (6, 106, 'Pilates', 45); | What are the top 5 most popular workout types? | SELECT workout_type, COUNT(*) as num_workouts FROM workouts GROUP BY workout_type ORDER BY num_workouts DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Viewership (ViewerID INT, ShowID INT, Episode INT, WatchDate DATE); INSERT INTO Viewership (ViewerID, ShowID, Episode, WatchDate) VALUES (1, 1, 1, '2022-01-01'); INSERT INTO Viewership (ViewerID, ShowID, Episode, WatchDate) VALUES (2, 2, 1, '2022-02-01'); INSERT INTO Viewership (ViewerID, ShowID, Episode, ... | How many distinct viewers watched episodes of shows with more than 2 seasons? | SELECT COUNT(DISTINCT ViewerID) as DistinctViewers FROM Viewership WHERE ShowID IN (SELECT ShowID FROM Shows WHERE Seasons > 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10, 2), project_name VARCHAR(50), donation_date DATE); INSERT INTO donations (id, donor_name, donation_amount, project_name, donation_date) VALUES (1, 'John Doe', 500, 'Habitat Restoration', '2020-01-01'); INSERT INTO donations (id, donor_n... | What is the total amount of donations received for the 'Community Education' project?; | SELECT SUM(donation_amount) FROM donations WHERE project_name = 'Community Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_improvement (patient_id INT, improvement_status VARCHAR(50), treatment_center VARCHAR(50)); INSERT INTO patient_improvement (patient_id, improvement_status, treatment_center) VALUES (9, 'No Improvement', 'clinic_i'); | How many patients were treated in 'clinic_i' without showing improvement? | SELECT COUNT(*) FROM patient_improvement WHERE improvement_status = 'No Improvement' AND treatment_center = 'clinic_i'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsWinners (EventID INT, PlayerID INT, Wins INT); INSERT INTO EsportsWinners (EventID, PlayerID, Wins) VALUES (1, 1, 3), (2, 2, 2), (3, 1, 1), (4, 3, 4); | What is the maximum number of wins by a player in esports events? | SELECT MAX(Wins) FROM EsportsWinners; | gretelai_synthetic_text_to_sql |
CREATE TABLE Distances (id INT, user_id INT, distance FLOAT, zip_code INT); INSERT INTO Distances (id, user_id, distance, zip_code) VALUES (1, 1, 5.0, 12345), (2, 2, 7.5, 67890); | What is the total distance covered by users in a specific ZIP code? | SELECT SUM(distance) FROM Distances WHERE zip_code = 12345; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_sequestration (country_code CHAR(3), year INT, sequestration FLOAT); INSERT INTO carbon_sequestration (country_code, year, sequestration) VALUES ('BRA', 2021, 3.5), ('BRA', 2020, 3.3); | Insert new record of carbon sequestration data for Brazil in 2023 | INSERT INTO carbon_sequestration (country_code, year, sequestration) VALUES ('BRA', 2023, 3.7); | gretelai_synthetic_text_to_sql |
CREATE TABLE product (id INT, name VARCHAR(50), is_cruelty_free BOOLEAN, is_vegan BOOLEAN); INSERT INTO product (id, name, is_cruelty_free, is_vegan) VALUES (1, 'Lipstick A', true, false), (2, 'Eye Shadow B', true, true); | Which cruelty-free certified products are not vegan-friendly? | SELECT name FROM product WHERE is_cruelty_free = true AND is_vegan = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfills (country VARCHAR(50), capacity INT, year INT); INSERT INTO landfills (country, capacity, year) VALUES ('Germany', 20000, 2020), ('France', 18000, 2020), ('UK', 16000, 2020), ('Italy', 14000, 2020), ('Spain', 12000, 2020); | What is the average landfill capacity in Europe in 2020?' | SELECT AVG(capacity) as avg_capacity FROM landfills WHERE year = 2020 AND country IN ('Germany', 'France', 'UK', 'Italy', 'Spain'); | gretelai_synthetic_text_to_sql |
CREATE TABLE non_organic_products AS SELECT products.product_id, products.product_name FROM products WHERE products.is_organic = false; CREATE TABLE artificial_colors (product_id INT, color_id INT, color_name TEXT); INSERT INTO artificial_colors VALUES (1, 1, 'ColorA'), (2, 2, 'ColorB'), (3, 3, 'ColorC'), (4, 4, 'Col... | List all products that are not certified organic or contain artificial colors. | SELECT products.product_id, products.product_name FROM products WHERE products.product_id NOT IN (SELECT non_organic_products.product_id FROM non_organic_products) AND products.product_id IN (SELECT artificial_colors.product_id FROM artificial_colors) | gretelai_synthetic_text_to_sql |
CREATE TABLE Genres (GenreID int, GenreName varchar(255)); INSERT INTO Genres (GenreID, GenreName) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'); CREATE TABLE Sales (SongID int, GenreID int, Revenue int); INSERT INTO Sales (SongID, GenreID, Revenue) VALUES (1, 1, 5000), (2, 2, 7000), (3, 3, 6000); | What is the total revenue for each genre of music? | SELECT Genres.GenreName, SUM(Sales.Revenue) as TotalRevenue FROM Genres INNER JOIN Sales ON Genres.GenreID = Sales.GenreID GROUP BY Genres.GenreName; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media (id INT, user_id INT, country VARCHAR(50), platform VARCHAR(50), screen_time INT); INSERT INTO social_media (id, user_id, country, platform, screen_time) VALUES (1, 1001, 'India', 'Facebook', 360); INSERT INTO social_media (id, user_id, country, platform, screen_time) VALUES (2, 1002, 'Canada'... | What is the average daily 'screen_time' for users in each country, for the 'social_media' database, partitioned by platform and ordered by average? | SELECT country, platform, AVG(screen_time) OVER (PARTITION BY country, platform ORDER BY AVG(screen_time) DESC) as avg_screen_time FROM social_media; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerSession (SessionID INT, PlayerID INT, GameID INT, StartTime TIMESTAMP, EndTime TIMESTAMP); INSERT INTO PlayerSession (SessionID, PlayerID, GameID, StartTime, EndTime) VALUES (1, 1, 1, '2022-01-01 10:00:00', '2022-01-01 11:00:00'), (2, 2, 1, '2022-01-01 10:15:00', '2022-01-01 12:00:00'), (3, 3, 2, '20... | What is the maximum number of players playing a game simultaneously? | SELECT GameID, MAX(COUNT(*)) FROM PlayerSession GROUP BY GameID HAVING COUNT(DISTINCT StartTime) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_category VARCHAR(255), sales_amount NUMERIC, sustainable BOOLEAN); INSERT INTO sales (product_category, sales_amount, sustainable) VALUES ('jeans', 600, FALSE); INSERT INTO sales (product_category, sales_amount, sustainable) VALUES ('t_shirt', 400, TRUE); INSERT INTO sales (product_category,... | What is the sum of sales for sustainable garments as a percentage of total sales in Q1 2023? | SELECT (SUM(CASE WHEN sustainable THEN sales_amount ELSE 0 END)/SUM(sales_amount))*100 FROM sales WHERE sale_date BETWEEN '2023-01-01' AND '2023-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage_facilities (id INT, state VARCHAR(255), num_facilities INT); INSERT INTO energy_storage_facilities (id, state, num_facilities) VALUES (1, 'California', 5), (2, 'Texas', 6), (3, 'New York', 4), (4, 'Florida', 3); | How many energy storage facilities are there in each state in the United States? | SELECT state, COUNT(*) FROM energy_storage_facilities GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE article_lang_category (id INT PRIMARY KEY, article_id INT, language VARCHAR(50), category VARCHAR(255), FOREIGN KEY (article_id) REFERENCES articles(id)); | What is the total number of articles published in a specific category for a specific language? | SELECT language, category, COUNT(*) as total_articles FROM article_lang_category GROUP BY language, category; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, release_year INT, country VARCHAR(50)); INSERT INTO movies (id, title, rating, release_year, country) VALUES (1, 'Movie1', 9.5, 2010, 'Germany'), (2, 'Movie2', 8.2, 2012, 'Germany'), (3, 'Movie3', 6.8, 2015, 'Germany'); | List the titles and release years of the movies produced in Germany and have a rating of 9 or higher. | SELECT title, release_year FROM movies WHERE rating >= 9 AND country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing (id INT, client_id INT, country VARCHAR(50), score FLOAT); INSERT INTO financial_wellbeing (id, client_id, country, score) VALUES (1, 601, 'Brazil', 70.0), (2, 602, 'Brazil', 80.0); | What is the average financial wellbeing score for clients in Brazil? | SELECT country, AVG(score) as avg_score FROM financial_wellbeing WHERE country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, restaurant_id INT, revenue INT, sale_date DATE); INSERT INTO sales (sale_id, restaurant_id, revenue, sale_date) VALUES (1, 1, 500, '2022-01-01'), (2, 1, 700, '2022-01-02'), (3, 1, 600, '2022-02-01'), (4, 1, 800, '2022-02-02'); CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(25... | What is the monthly revenue trend for the 'Fancy Bistro'? | SELECT DATE_FORMAT(s.sale_date, '%Y-%m') AS month, SUM(s.revenue) AS monthly_revenue FROM sales s JOIN restaurants r ON s.restaurant_id = r.restaurant_id WHERE r.name = 'Fancy Bistro' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (brand_id INT PRIMARY KEY, name VARCHAR(50), ethical_certifications INT); INSERT INTO Brands (brand_id, name, ethical_certifications) VALUES (1, 'Sustainable Fashion', 3), (2, 'Eco Friendly Wear', 2); | How many ethical certifications does the 'Sustainable Fashion' brand have? | SELECT ethical_certifications FROM Brands WHERE name = 'Sustainable Fashion'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bike_sharing (id INT, trip_id INT, start_time TIMESTAMP, end_time TIMESTAMP, start_station TEXT, end_station TEXT, trip_distance FLOAT); | What is the average trip distance for bike-sharing in Paris? | SELECT AVG(trip_distance) FROM bike_sharing WHERE start_station = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (id INT, name VARCHAR(255), network VARCHAR(255), market_cap DECIMAL(10, 2)); INSERT INTO digital_assets (id, name, network, market_cap) VALUES (1, 'Asset1', 'network1', 500), (2, 'Asset2', 'network2', 600); | What's the market capitalization of the digital asset named 'Asset1'? | SELECT market_cap FROM digital_assets WHERE name = 'Asset1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, name TEXT); INSERT INTO volunteers (volunteer_id, name) VALUES (1, 'Aarav'), (2, 'Bella'), (3, 'Charlie'); CREATE TABLE cases (case_id INT, volunteer_id INT, date TEXT, resolved_date TEXT); INSERT INTO cases (case_id, volunteer_id, date, resolved_date) VALUES (1, 1, '2022-01-0... | What is the total number of cases resolved by each volunteer? | SELECT volunteers.name, COUNT(cases.case_id) as total_cases_resolved FROM volunteers INNER JOIN cases ON volunteers.volunteer_id = cases.volunteer_id WHERE cases.date <= cases.resolved_date GROUP BY volunteers.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, Service VARCHAR(20), Amount DECIMAL(10,2)); INSERT INTO Budget (Year, Service, Amount) VALUES (2022, 'Education', 150000.00), (2022, 'Healthcare', 200000.00); | What is the total budget allocated for education and healthcare services in 2022? | SELECT SUM(Amount) FROM Budget WHERE Year = 2022 AND Service IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50)); INSERT INTO wells (well_id, well_name, region) VALUES (1, 'Well A', 'Gulf of Mexico'), (2, 'Well B', 'North Sea'); | How many wells have been drilled in the 'Gulf of Mexico'? | SELECT COUNT(*) FROM wells WHERE region = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Agricultural_Projects (Project_ID INT, Project_Name TEXT, Location TEXT, Funding_Received DECIMAL, Led_By TEXT, Year INT); INSERT INTO Agricultural_Projects (Project_ID, Project_Name, Location, Funding_Received, Led_By, Year) VALUES (1, 'Sustainable Farming Project', 'Guatemala', 40000, 'Women', 2019), (2,... | What was the total amount of funding received by agricultural projects in Guatemala in 2019, led by either women or Indigenous communities? | SELECT SUM(Funding_Received) FROM Agricultural_Projects WHERE (Led_By = 'Women' OR Led_By = 'Indigenous') AND Year = 2019 AND Location = 'Guatemala'; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(255), gender VARCHAR(255), salary DECIMAL(10,2)); INSERT INTO employees (id, name, gender, salary) VALUES (1, 'John Doe', 'Male', 40000.00), (2, 'Jane Smith', 'Female', 45000.00), (3, 'Alice Johnson', 'Female', 80000.00), (4, 'Bob Brown', 'Male', 70000.00), (5, 'Charlie Davi... | What is the distribution of employee salaries by gender? | SELECT gender, AVG(salary) as avg_salary, MIN(salary) as min_salary, MAX(salary) as max_salary FROM employees GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name VARCHAR(50), country VARCHAR(50), certification VARCHAR(50), revenue DECIMAL(5,2)); INSERT INTO factories (id, name, country, certification, revenue) VALUES (1, 'FairAF1', 'Kenya', 'Fair Trade', 5000.00), (2, 'GreenAF', 'Tanzania', 'B Corp', 7000.00), (3, 'EcoAF', 'Uganda', 'Fair Tr... | What is the total revenue of all fair trade certified factories in Africa? | SELECT SUM(revenue) as total_revenue FROM factories WHERE certification = 'Fair Trade' AND country IN ('Kenya', 'Tanzania', 'Uganda'); | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_treatment (patient_id INT, condition VARCHAR(50), treatment_date DATE); INSERT INTO patient_treatment (patient_id, condition, treatment_date) VALUES (1, 'Depression', '2020-02-14'); INSERT INTO patient_treatment (patient_id, condition, treatment_date) VALUES (2, 'Anxiety', '2019-06-21'); INSERT INT... | What is the number of patients treated for each mental health condition, and their respective percentages in the patient_treatment table? | SELECT condition, COUNT(*) AS count, ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM patient_treatment), 2) AS percentage FROM patient_treatment GROUP BY condition; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (id INT, type VARCHAR(255), description VARCHAR(255)); INSERT INTO accommodations (id, type, description) VALUES (1, 'Wheelchair Ramp', 'Ramp with handrails and non-slip surface'); INSERT INTO accommodations (id, type, description) VALUES (2, 'Elevator', 'Standard elevator for building acces... | Show all records from the accommodations table that are not elevators. | SELECT * FROM accommodations WHERE type <> 'Elevator'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clean_energy_policies (policy_id INT, state VARCHAR(20)); INSERT INTO clean_energy_policies (policy_id, state) VALUES (1, 'Texas'), (2, 'California'), (3, 'California'); | How many clean energy policies are in Texas and California | SELECT state, COUNT(*) FROM clean_energy_policies GROUP BY state HAVING state IN ('Texas', 'California'); | 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.