context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE heritage_sites (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO heritage_sites (id, name, country) VALUES (1, 'Historic Site', 'Japan'), (2, 'Landmark', 'France'), (3, 'Monument', 'Italy'), (4, 'Archaeological Site', 'India'), (5, 'Natural Reserve', 'Germany'); | What is the total number of heritage sites in Asia and Europe? | SELECT COUNT(*) FROM heritage_sites WHERE country = 'Japan' OR country = 'France' OR country = 'Italy' OR country = 'India' OR country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (region VARCHAR(255), funding FLOAT); | Insert a new record for 'Climate Finance Australia' with '5000000' funding | INSERT INTO climate_finance (region, funding) VALUES ('Climate Finance Australia', 5000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(100), product_type VARCHAR(50), is_cruelty_free BOOLEAN, consumer_preference_score INT); INSERT INTO cosmetics (product_id, product_name, product_type, is_cruelty_free, consumer_preference_score) VALUES (1, 'Lipstick A', 'Lipstick', TRUE, 80), (2, 'Foundation B', 'Foundation', FALSE, 90), (3, 'Mascara C', 'Mascara', TRUE, 85), (4, 'Eyeshadow D', 'Eyeshadow', TRUE, 70), (5, 'Blush E', 'Blush', FALSE, 95); CREATE TABLE safety_incidents (incident_id INT, product_id INT, incident_description TEXT); INSERT INTO safety_incidents (incident_id, product_id) VALUES (1, 1), (2, 3), (3, 4), (4, 5), (5, 2); | What is the total number of safety incidents for each cosmetic product type? | SELECT product_type, COUNT(*) AS safety_incidents_count FROM cosmetics INNER JOIN safety_incidents ON cosmetics.product_id = safety_incidents.product_id GROUP BY product_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (player_id INT, name VARCHAR(255), age INT, game_genre VARCHAR(255), country VARCHAR(255)); INSERT INTO Players (player_id, name, age, game_genre, country) VALUES (1, 'John', 27, 'FPS', 'USA'), (2, 'Sarah', 30, 'RPG', 'Canada'), (3, 'Alex', 22, 'FPS', 'USA'), (4, 'Max', 25, 'FPS', 'Canada'), (5, 'Zoe', 28, 'FPS', 'Mexico'); | Which countries have players who play 'FPS' games? | SELECT DISTINCT country FROM Players WHERE game_genre = 'FPS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE plants (plant_id INT, plant_name VARCHAR(50), city VARCHAR(50), capacity INT, production_output INT); INSERT INTO plants (plant_id, plant_name, city, capacity, production_output) VALUES (1, 'PlantA', 'CityX', 1000, 500), (2, 'PlantB', 'CityY', 700, 700), (3, 'PlantC', 'CityX', 1500, 600), (4, 'PlantD', 'CityZ', 800, 800); | What is the production output of the plant with the highest capacity? | SELECT production_output FROM plants WHERE capacity = (SELECT MAX(capacity) FROM plants); | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT, name VARCHAR(255), conservation_score INT); | Find the maximum and minimum conservation scores for marine species. | SELECT MAX(conservation_score) AS max_score, MIN(conservation_score) AS min_score FROM species; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_statistics (labor_id INT, state VARCHAR(10), employees INT, salary DECIMAL(10,2)); INSERT INTO labor_statistics VALUES (1, 'Texas', 50, 45000.00), (2, 'Texas', 60, 42000.00); | Rank the construction labor statistics in Texas by the number of employees, in descending order, with a tiebreaker based on the average salary. | SELECT labor_id, state, employees, salary, RANK() OVER (PARTITION BY state ORDER BY employees DESC, salary DESC) AS labor_rank FROM labor_statistics WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ruraldev.innovation_projects (id INT, project_name VARCHAR(50), start_year INT); INSERT INTO ruraldev.innovation_projects (id, project_name, start_year) VALUES (1, 'Precision Farming', 2015), (2, 'Drip Irrigation', 2017), (3, 'Vertical Farming', 2020); | How many agricultural innovation projects were implemented in the 'ruraldev' schema in 2017 and 2019? | SELECT COUNT(*) FROM ruraldev.innovation_projects WHERE start_year IN (2017, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_fact (customer_id INT, sale_id INT, customer_age INT, customer_gender VARCHAR, customer_country VARCHAR); | List the menu categories and their total inventory quantity, from the menu_item_dim and inventory_fact tables, grouped by menu_category. | SELECT m.menu_category, SUM(i.inventory_quantity) as total_inventory_quantity FROM menu_item_dim m JOIN inventory_fact i ON m.menu_item_id = i.menu_item_id GROUP BY m.menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE produce_suppliers (supplier_id INT, supplier_name VARCHAR(255), is_organic BOOLEAN); | Display the total number of organic and non-organic produce suppliers in the produce_suppliers table. | SELECT SUM(CASE WHEN is_organic THEN 1 ELSE 0 END) as organic_count, SUM(CASE WHEN NOT is_organic THEN 1 ELSE 0 END) as non_organic_count FROM produce_suppliers; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellites (id, name, country, launch_date) VALUES (1, 'Satellite1', 'USA', '2010-01-01'); INSERT INTO satellites (id, name, country, launch_date) VALUES (2, 'Satellite2', 'Russia', '2015-05-12'); | How many satellites were launched in a given year? | SELECT COUNT(*) FROM satellites WHERE YEAR(launch_date) = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_stats (id INT, location VARCHAR(20), disease VARCHAR(20), prevalence FLOAT); INSERT INTO health_stats (id, location, disease, prevalence) VALUES (1, 'rural Oregon', 'heart disease', 0.08); | What is the prevalence of heart disease in rural Oregon compared to urban Oregon? | SELECT location, disease, prevalence FROM health_stats WHERE disease = 'heart disease' AND location IN ('rural Oregon', 'urban Oregon'); | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification (id INT, project_name VARCHAR(100), project_location VARCHAR(100), project_status VARCHAR(50), start_date DATE, end_date DATE); | How many economic diversification projects were completed before their scheduled end date in the rural region of 'Puno', Peru between 2015 and 2018? | SELECT COUNT(*) FROM economic_diversification WHERE project_location = 'Puno' AND project_status = 'completed' AND start_date <= '2018-12-31' AND end_date >= '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_sourcing (product_id INT, ingredient_id INT, is_organic BOOLEAN, source_country TEXT); INSERT INTO ingredient_sourcing VALUES (1, 1, true, 'Mexico'), (2, 2, false, 'Brazil'), (3, 3, true, 'Indonesia'), (4, 4, false, 'Peru'), (5, 1, true, 'Nigeria'), (6, 5, false, 'Mexico'); | Identify countries that source both organic and non-organic ingredients. | SELECT source_country FROM ingredient_sourcing WHERE is_organic = true INTERSECT SELECT source_country FROM ingredient_sourcing WHERE is_organic = false | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_value DECIMAL(10, 2)); INSERT INTO customer_transactions (transaction_id, customer_id, transaction_date, transaction_value) VALUES (1, 1, '2022-01-01', 100.00), (2, 1, '2022-02-01', 200.00), (3, 2, '2022-03-01', 150.00), (4, 1, '2022-04-01', 300.00); | Calculate the average daily transaction value for each customer in the last month. | SELECT customer_id, AVG(transaction_value) FROM customer_transactions WHERE transaction_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY customer_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Species ( id INT PRIMARY KEY, name VARCHAR(50), family VARCHAR(50), conservation_status VARCHAR(50)); CREATE TABLE Threats ( id INT PRIMARY KEY, species_id INT, threat_type VARCHAR(50), severity VARCHAR(50)); CREATE TABLE Protection_Programs ( id INT PRIMARY KEY, species_id INT, program_name VARCHAR(50), start_year INT, end_year INT); | List the top 5 species with the highest number of protection programs in place. | SELECT Species.name, COUNT(Protection_Programs.id) AS program_count FROM Species LEFT JOIN Protection_Programs ON Species.id = Protection_Programs.species_id GROUP BY Species.name ORDER BY program_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(50)); CREATE TABLE Attendees (attendee_id INT, event_id INT, age INT); INSERT INTO Events (event_id, event_name) VALUES (7, 'Film Festival'); INSERT INTO Attendees (attendee_id, event_id, age) VALUES (10, 7, 22), (11, 7, 32), (12, 7, 42); | How many people attended the 'Film Festival' event by age group? | SELECT e.event_name, a.age, COUNT(a.attendee_id) FROM Events e JOIN Attendees a ON e.event_id = a.event_id WHERE e.event_name = 'Film Festival' GROUP BY e.event_name, a.age; | gretelai_synthetic_text_to_sql |
CREATE TABLE MarianaTrench (id INT, name TEXT, latitude REAL, longitude REAL, depth REAL); INSERT INTO MarianaTrench (id, name, latitude, longitude, depth) VALUES (1, 'Challenger Deep', 11.2161, 142.7913, 10972); INSERT INTO MarianaTrench (id, name, latitude, longitude, depth) VALUES (2, 'Sirena Deep', 11.2121, 142.7876, 10594); | What is the maximum depth of all stations in the Mariana Trench Mapping Project? | SELECT MAX(depth) FROM MarianaTrench; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_incidents (id INT, title VARCHAR(255), description TEXT, region VARCHAR(255), countermeasure TEXT);INSERT INTO cybersecurity_incidents (id, title, description, region, countermeasure) VALUES (1, 'Incident A', 'Details about Incident A', 'Asia-Pacific', 'Countermeasure A'), (2, 'Incident B', 'Details about Incident B', 'Europe', 'Countermeasure B'); | Delete the record of the cybersecurity incident with ID 2. | DELETE FROM cybersecurity_incidents WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (state VARCHAR(2), violations INT); INSERT INTO mental_health_parity (state, violations) VALUES ('CA', 25), ('NY', 30), ('TX', 15); | What is the number of mental health parity violations in each state? | SELECT state, violations FROM mental_health_parity; | gretelai_synthetic_text_to_sql |
CREATE TABLE hours (id INT, teacher_id INT, date DATE, hours_spent DECIMAL(5,2)); INSERT INTO hours (id, teacher_id, date, hours_spent) VALUES (1, 1001, '2022-01-01', 2.5), (2, 1001, '2022-02-15', 3.0), (3, 1002, '2022-03-10', 2.0), (4, 1003, '2022-04-01', 4.0); | What is the total number of hours spent on professional development by teachers in the last quarter? | SELECT SUM(hours_spent) as total_hours FROM hours WHERE date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE company_financials (financial_year INT, rd_expenses FLOAT); INSERT INTO company_financials (financial_year, rd_expenses) VALUES (2018, 5000000), (2019, 6000000), (2020, 8000000), (2021, 9000000); | How much did the company spend on R&D in 2020? | SELECT SUM(rd_expenses) FROM company_financials WHERE financial_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_projects (project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO energy_efficiency_projects (project_name, location) VALUES ('Project A', 'Asia-Pacific'), ('Project B', 'Europe'), ('Project C', 'Asia-Pacific'), ('Project D', 'Americas'), ('Project E', 'Africa'); | Get the number of energy efficiency projects in each continent | SELECT location, COUNT(project_name) FROM energy_efficiency_projects GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE machines(id INT, name TEXT, location TEXT);CREATE TABLE cycles(id INT, machine_id INT, start_time TIMESTAMP, end_time TIMESTAMP);INSERT INTO machines(id, name, location) VALUES (1, 'Machine A', 'Location A'), (2, 'Machine B', 'Location B'); INSERT INTO cycles(id, machine_id, start_time, end_time) VALUES (1, 1, '2021-02-01 09:00:00', '2021-02-01 10:00:00'), (2, 1, '2021-02-01 11:00:00', '2021-02-01 12:00:00'), (3, 2, '2021-02-01 08:00:00', '2021-02-01 09:30:00'); | What is the average time to complete a production cycle for each machine? | SELECT machine_id, AVG(TIMESTAMPDIFF(MINUTE, start_time, end_time)) as avg_time FROM cycles GROUP BY machine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide_stats (region VARCHAR(50), issue VARCHAR(50), last_update DATETIME); | Add a new row to the 'digital_divide_stats' table with the following data: 'Rural India', 'Limited internet access', '2022-01-01' | INSERT INTO digital_divide_stats (region, issue, last_update) VALUES ('Rural India', 'Limited internet access', '2022-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccinations (person_id INT, first_dose DATE, second_dose DATE); | How many people in the vaccinations table have received their first dose, but not their second dose? | SELECT COUNT(*) FROM vaccinations WHERE first_dose IS NOT NULL AND second_dose IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, region TEXT, user_count INT); INSERT INTO virtual_tours (tour_id, tour_name, region, user_count) VALUES (1, 'Virtual Tokyo Tour', 'Asia', 1200), (2, 'Paris Cultural Tour', 'Europe', 800); | Identify the number of virtual tours in Asia with over 1000 users. | SELECT COUNT(*) FROM virtual_tours WHERE region = 'Asia' AND user_count > 1000; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA CityOfFuture; USE CityOfFuture; CREATE TABLE SmartCityProjects (id INT, project_name VARCHAR(100), cost DECIMAL(10,2)); INSERT INTO SmartCityProjects (id, project_name, cost) VALUES (1, 'Smart Lighting', 50000.00), (2, 'Smart Waste Management', 25000.00); | Get the smart city project names and costs in the CityOfFuture schema | SELECT project_name, cost FROM CityOfFuture.SmartCityProjects; | gretelai_synthetic_text_to_sql |
CREATE TABLE BuildingCO2Emissions (id INT, city VARCHAR(20), co2_emission FLOAT); INSERT INTO BuildingCO2Emissions (id, city, co2_emission) VALUES (1, 'New York', 1200.5), (2, 'New York', 1300.2), (3, 'Los Angeles', 1100.3); | What is the maximum CO2 emission of buildings in New York? | SELECT MAX(co2_emission) FROM BuildingCO2Emissions WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_type (investment_id INT, investment_type VARCHAR(50), monthly_rate DECIMAL(5,2), start_date DATE, end_date DATE); INSERT INTO investment_type (investment_id, investment_type, monthly_rate, start_date, end_date) VALUES (1, 'Network Upgrade', 10000.00, '2022-01-01', '2022-12-31'), (2, 'Marketing Campaign', 5000.00, '2022-04-01', '2022-06-30'), (3, 'Network Maintenance', 7000.00, '2022-07-01', '2022-09-30'); | What is the total revenue generated by each investment type in the last year? | SELECT investment_type, EXTRACT(YEAR FROM start_date) as year, SUM(monthly_rate * DATEDIFF('month', start_date, end_date)) as total_revenue FROM investment_type GROUP BY investment_type, EXTRACT(YEAR FROM start_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtCollection(id INT, type VARCHAR(20), artist VARCHAR(30)); INSERT INTO ArtCollection(id, type, artist) VALUES (1, 'Painting', 'Braque'), (2, 'Sculpture', 'Arp'), (3, 'Painting', 'Braque'), (4, 'Installation', 'Serra'); | What is the total number of art pieces and historical artifacts in the database, excluding any duplicate entries? | SELECT COUNT(DISTINCT type, artist) FROM ArtCollection; | gretelai_synthetic_text_to_sql |
CREATE TABLE DigitalAssets (AssetID int, AssetName varchar(50), Country varchar(50)); INSERT INTO DigitalAssets (AssetID, AssetName, Country) VALUES (1, 'Asset1', 'USA'), (2, 'Asset2', 'Canada'), (3, 'Asset3', 'USA'); | What is the total number of digital assets launched by country in descending order? | SELECT Country, COUNT(*) as TotalAssets FROM DigitalAssets GROUP BY Country ORDER BY TotalAssets DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (id INT, country VARCHAR(50), language VARCHAR(50), status VARCHAR(50)); | Insert a new language preservation record for 'Papua New Guinea', 'Tok Pisin', 'Endangered'. | INSERT INTO LanguagePreservation (id, country, language, status) VALUES (1, 'Papua New Guinea', 'Tok Pisin', 'Endangered'); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(region VARCHAR(255), year INT, recycling_rate FLOAT); | What is the average recycling rate (%) for urban areas in 2019? | SELECT AVG(recycling_rate) FROM recycling_rates WHERE region LIKE '%urban%' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_competency_training_sessions (id INT, state VARCHAR(50), year INT, worker_id INT, sessions INT); INSERT INTO cultural_competency_training_sessions (id, state, year, worker_id, sessions) VALUES (1, 'California', 2020, 1, 12), (2, 'California', 2020, 2, 15), (3, 'California', 2020, 3, 18), (4, 'Texas', 2020, 1, 10), (5, 'Texas', 2020, 2, 14), (6, 'Texas', 2020, 3, 16); | List the total number of cultural competency training sessions and the average sessions per community health worker by state in 2020. | SELECT state, SUM(sessions) as total_sessions, AVG(sessions) as avg_sessions_per_worker FROM cultural_competency_training_sessions WHERE year = 2020 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (id INT, name VARCHAR(50), state VARCHAR(50), capacity FLOAT, operational_year INT); | How many wind farms have been completed in the state of Texas since 2010? | SELECT COUNT(*) FROM wind_farms WHERE state = 'Texas' AND operational_year >= 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibits (exhibit_id INT PRIMARY KEY, name VARCHAR(100), start_date DATE, end_date DATE, venue_id INT, FOREIGN KEY (venue_id) REFERENCES venue(venue_id)); | Add a new record into the "exhibits" table for an exhibit named "Impressionist Masterpieces" with a start date of 2022-06-01 and end date of 2023-05-31 | INSERT INTO exhibits (exhibit_id, name, start_date, end_date, venue_id) VALUES ((SELECT MAX(exhibit_id) FROM exhibits) + 1, 'Impressionist Masterpieces', '2022-06-01', '2023-05-31', (SELECT venue_id FROM venue WHERE name = 'Metropolitan Museum')); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (location VARCHAR(50), rate DECIMAL(5,2)); | Update records in recycling_rates table where location is 'London' and recycling rate is 28% | UPDATE recycling_rates SET rate = 0.28 WHERE location = 'London'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_registration (player_id INT, region VARCHAR(255)); INSERT INTO player_registration (player_id, region) VALUES (1, 'North America'), (2, 'Europe'), (3, 'Asia'); | How many players are registered in each region? | SELECT region, COUNT(player_id) as num_players FROM player_registration GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, founders TEXT, founding_year INT, industry TEXT); INSERT INTO startups VALUES (1, 'StartupA', 'Alex, Bob', 2010, 'Fintech'); INSERT INTO startups VALUES (2, 'StartupB', 'Eve', 2015, 'Healthcare'); INSERT INTO startups VALUES (3, 'StartupC', 'Carlos', 2018, 'Tech'); CREATE TABLE investments(startup_id INT, round INT, funding INT); INSERT INTO investments VALUES (1, 1, 1000000); INSERT INTO investments VALUES (1, 2, 2000000); INSERT INTO investments VALUES (2, 1, 3000000); INSERT INTO investments VALUES (3, 1, 4000000); INSERT INTO investments VALUES (3, 2, 5000000); | What is the maximum funding received in a single round by startups founded by individuals who identify as LGBTQ+ in the fintech industry? | SELECT MAX(funding) FROM (SELECT startup_id, funding FROM investments JOIN startups ON investments.startup_id = startups.id WHERE startups.industry = 'Fintech' AND founders LIKE '%Alex%' GROUP BY startup_id, round) subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE compliance (id INT, state TEXT, violation TEXT, date DATE); INSERT INTO compliance (id, state, violation, date) VALUES (1, 'California', 'Pesticide Use', '2021-02-01'); | Add new compliance data for 'Oregon' | INSERT INTO compliance (id, state, violation, date) VALUES (2, 'Oregon', 'Improper Labeling', '2021-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials(trial_id INT, country VARCHAR(255), status VARCHAR(255)); INSERT INTO clinical_trials(trial_id, country, status) VALUES (1, 'USA', 'Completed'), (2, 'Canada', 'Recruiting'), (3, 'USA', 'Terminated'); | List all clinical trials with a status of 'Completed' or 'Terminated' in the USA. | SELECT * FROM clinical_trials WHERE country = 'USA' AND status IN ('Completed', 'Terminated'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteTimeline (Id INT, Name VARCHAR(50), LaunchDate DATE); INSERT INTO SatelliteTimeline (Id, Name, LaunchDate) VALUES (1, 'Sputnik 1', '1957-10-04'), (2, 'Explorer 1', '1958-01-31'); | What is the earliest launch date of any satellite? | SELECT MIN(LaunchDate) FROM SatelliteTimeline; | gretelai_synthetic_text_to_sql |
CREATE TABLE sourcing (region VARCHAR(255), material VARCHAR(255), eco_friendly BOOLEAN); | How many eco-friendly materials are sourced by region? | SELECT region, COUNT(*) as eco_friendly_materials_count FROM sourcing WHERE eco_friendly = TRUE GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_posts (id INT, post TEXT, user TEXT, like_count INT); INSERT INTO social_posts (id, post, user, like_count) VALUES (1, 'Post1', 'UserA', 10), (2, 'Post2', 'UserB', 5); | What's the average like count of posts by 'UserA'? | SELECT AVG(like_count) FROM social_posts WHERE user = 'UserA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_farms (id INT, country VARCHAR(255), name VARCHAR(255), capacity FLOAT); INSERT INTO solar_farms (id, country, name, capacity) VALUES (1, 'India', 'Solarfarm A', 100.2), (2, 'China', 'Solarfarm B', 200.5), (3, 'India', 'Solarfarm C', 150.8); | What is the total installed capacity of solar farms in India and China? | SELECT SUM(capacity) FROM solar_farms WHERE country IN ('India', 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, initiative_type VARCHAR(255), transaction_date DATE, country VARCHAR(255)); | Count the number of transactions for socially responsible lending initiatives in the United Kingdom over the past year. | SELECT COUNT(*) FROM transactions WHERE initiative_type = 'socially responsible lending' AND country = 'United Kingdom' AND transaction_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE StartupInvestments(id INT, name TEXT, industry TEXT, investment_amount INT, racial_ethnicity TEXT, founding_year INT); INSERT INTO StartupInvestments VALUES (1, 'GameChanger', 'Gaming', 7000000, 'BIPOC', 2018), (2, 'GreenTech', 'CleanTech', 8000000, 'White', 2016), (3, 'AIStudio', 'AI', 12000000, 'Asian', 2020), (4, 'RenewableEnergy', 'Renewable Energy', 9000000, 'BIPOC', 2019), (5, 'CloudServices', 'Cloud Services', 5000000, 'White', 2017), (6, 'SmartCity', 'Smart Cities', 10000000, 'White', 2016), (7, 'DataAnalytics', 'Data Analytics', 4000000, 'BIPOC', 2018); | What is the minimum investment amount in startups founded by BIPOC entrepreneurs in the gaming industry since 2017? | SELECT MIN(investment_amount) FROM StartupInvestments WHERE racial_ethnicity = 'BIPOC' AND industry = 'Gaming' AND founding_year >= 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(30)); INSERT INTO companies (id, name) VALUES (1, 'ABC Corp'), (2, 'XYZ Inc'), (3, 'DEF Investments'), (4, 'GHI Fund'); CREATE TABLE investments (id INT, company_id INT, sector_id INT, investment_amount DECIMAL, investment_date DATE); INSERT INTO investments (id, company_id, sector_id, investment_amount, investment_date) VALUES (1, 2, 2, 100000, '2021-01-01'), (2, 3, 2, 200000, '2020-12-31'), (3, 1, 2, 300000, '2019-12-31'), (4, 2, 2, 250000, '2019-01-01'), (5, 4, 2, 150000, '2020-01-01'); | Who are the top 3 investors by total investment amount in the renewable energy sector since 2019? | SELECT companies.name, SUM(investments.investment_amount) as total_investment FROM companies INNER JOIN investments ON companies.id = investments.company_id WHERE investments.sector_id IN (SELECT id FROM sectors WHERE sector = 'renewable energy') AND investments.investment_date >= '2019-01-01' GROUP BY companies.name ORDER BY total_investment DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSite (SiteID INT PRIMARY KEY, SiteName VARCHAR(100), Location VARCHAR(100), StartDate DATE, EndDate DATE);CREATE TABLE Artifact (ArtifactID INT PRIMARY KEY, SiteID INT, ArtifactName VARCHAR(100), Description TEXT, FOREIGN KEY (SiteID) REFERENCES ExcavationSite(SiteID));CREATE TABLE ArtifactType (ArtifactTypeID INT PRIMARY KEY, TypeName VARCHAR(100));CREATE TABLE ArtifactDetail (ArtifactID INT, ArtifactTypeID INT, Quantity INT, PRIMARY KEY (ArtifactID, ArtifactTypeID), FOREIGN KEY (ArtifactID) REFERENCES Artifact(ArtifactID), FOREIGN KEY (ArtifactTypeID) REFERENCES ArtifactType(ArtifactTypeID)); | Insert a new artifact 'Ancient Coin' from the 'EuropeExcavation' site, type 'Coin', quantity 1. | INSERT INTO Artifact (ArtifactID, SiteID, ArtifactName, Description) VALUES (1415, (SELECT SiteID FROM ExcavationSite WHERE SiteName = 'EuropeExcavation'), 'Ancient Coin', 'An ancient coin from the EuropeExcavation site.');INSERT INTO ArtifactDetail (ArtifactID, ArtifactTypeID, Quantity) VALUES (1415, (SELECT ArtifactTypeID FROM ArtifactType WHERE TypeName = 'Coin'), 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_workers (name VARCHAR(255), title VARCHAR(255), city VARCHAR(255), salary DECIMAL(10,2), workplace VARCHAR(255)); INSERT INTO healthcare_workers (name, title, city, salary, workplace) VALUES ('John Doe', 'Doctor', 'Miami', 200000.00, 'Hospital'); INSERT INTO healthcare_workers (name, title, city, salary, workplace) VALUES ('Jane Smith', 'Nurse', 'Miami', 80000.00, 'Hospital'); | Find the average salary of healthcare workers in hospitals, excluding doctors. | SELECT AVG(salary) FROM healthcare_workers WHERE workplace = 'Hospital' AND title != 'Doctor'; | gretelai_synthetic_text_to_sql |
CREATE TABLE JobOffers (OfferID INT, FirstName VARCHAR(50), LastName VARCHAR(50), HiringManager VARCHAR(50), DateOffered DATE, Veteran VARCHAR(10)); | How many job offers were made to candidates who identify as veterans in the past quarter, by hiring manager? | SELECT HiringManager, COUNT(*) as Num_Offers FROM JobOffers WHERE Veteran = 'Yes' AND DateOffered >= DATEADD(quarter, -1, GETDATE()) GROUP BY HiringManager; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (report_id INT, creation_date DATE); INSERT INTO threat_intelligence VALUES (1, '2022-02-01'), (2, '2022-02-02'), (3, '2022-02-05'); | Find the number of threat intelligence reports created per day in the last month, excluding weekends. | SELECT creation_date, COUNT(*) OVER (PARTITION BY creation_date) FROM threat_intelligence WHERE creation_date >= CURRENT_DATE - INTERVAL '1 month' AND EXTRACT(DOW FROM creation_date) < 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(100)); CREATE TABLE games (game_id INT, home_team INT, away_team INT); | What is the total number of games played by each team in the FIFA World Cup? | SELECT teams.team_name, COUNT(games.game_id) as total_games FROM teams INNER JOIN games ON teams.team_id IN (games.home_team, games.away_team) GROUP BY teams.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_date DATE, incident_count INT); INSERT INTO security_incidents (id, incident_date, incident_count) VALUES (1, '2022-01-01', 5), (2, '2022-01-02', 3), (3, '2022-01-03', 7); | What is the maximum number of security incidents recorded in a single day? | SELECT MAX(incident_count) FROM security_incidents; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (SiteID INT, Name VARCHAR(50), Location VARCHAR(50), ArtPieceID INT); INSERT INTO HeritageSites VALUES (1, 'Taj Mahal', 'India', 101), (2, 'Machu Picchu', 'Peru', 201), (3, 'Angkor Wat', 'Cambodia', 301); CREATE TABLE ArtPieces (ArtPieceID INT, Name VARCHAR(50), Type VARCHAR(50), Value INT); INSERT INTO ArtPieces VALUES (101, 'Painting 1', 'Traditional', 1000), (201, 'Sculpture 1', 'Traditional', 2000), (301, 'Painting 2', 'Traditional', 3000); | Calculate the number of traditional art pieces in each UNESCO World Heritage site, ranked by their total value. | SELECT hs.Name AS HeritageSite, COUNT(ap.ArtPieceID) AS ArtPieces, SUM(ap.Value) AS TotalValue FROM HeritageSites hs JOIN ArtPieces ap ON hs.ArtPieceID = ap.ArtPieceID GROUP BY hs.Name ORDER BY TotalValue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_funds(id INT, disaster_name TEXT, country TEXT, amount FLOAT, year INT); INSERT INTO disaster_funds(id, disaster_name, country, amount, year) VALUES (1, 'Typhoon', 'Philippines', 300000.00, 2019), (2, 'Volcano', 'Philippines', 500000.00, 2020), (3, 'Earthquake', 'Philippines', 400000.00, 2018); | What is the minimum amount of funds raised for disaster relief efforts in the Philippines in the year 2019? | SELECT MIN(amount) FROM disaster_funds WHERE country = 'Philippines' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycled_material_suppliers (supplier_id INT, supplier_name VARCHAR(50), material VARCHAR(50), country VARCHAR(50)); INSERT INTO recycled_material_suppliers (supplier_id, supplier_name, material, country) VALUES (1, 'Green Supplies', 'Recycled Plastic', 'USA'), (2, 'EcoTech', 'Recycled Metal', 'Canada'), (3, 'Sustainable Source', 'Recycled Paper', 'USA'), (4, 'Renewable Resources', 'Recycled Glass', 'USA'); | Who are the top 3 suppliers of recycled materials in the US? | SELECT supplier_name, material FROM recycled_material_suppliers WHERE country = 'USA' LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (country TEXT, year INT, participants INT); INSERT INTO community_development (country, year, participants) VALUES ('Mexico', 2018, 300), ('Mexico', 2018, 600), ('Mexico', 2019, 400), ('Mexico', 2019, 700), ('Mexico', 2020, 500), ('Mexico', 2020, 550), ('Mexico', 2020, 600), ('Mexico', 2021, 450), ('Mexico', 2021, 800); | How many community development initiatives were implemented in Mexico in 2020, with at least 500 participants? | SELECT COUNT(*) FROM community_development WHERE country = 'Mexico' AND year = 2020 AND participants >= 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT, name TEXT, state TEXT); INSERT INTO campaigns (id, name, state) VALUES (1, 'Campaign A', 'New York'); INSERT INTO campaigns (id, name, state) VALUES (2, 'Campaign B', 'Texas'); INSERT INTO campaigns (id, name, state) VALUES (3, 'Campaign C', 'New York'); | How many mental health campaigns were launched in New York and Texas? | SELECT COUNT(*) FROM campaigns WHERE campaigns.state IN ('New York', 'Texas'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, Program VARCHAR(50), EventDate DATE); INSERT INTO Volunteers (VolunteerID, Program, EventDate) VALUES (1, 'Arts and Culture', '2023-01-01'), (2, 'Arts and Culture', '2023-02-01'); CREATE TABLE Events (EventID INT, Program VARCHAR(50), EventDate DATE, NumberOfVolunteers INT); INSERT INTO Events (EventID, Program, EventDate, NumberOfVolunteers) VALUES (1, 'Arts and Culture', '2023-01-01', 10), (2, 'Arts and Culture', '2023-02-01', 15); | How many volunteers are needed on average per event for the Arts and Culture programs in 2023? | SELECT Program, AVG(NumberOfVolunteers) as AvgVolunteers FROM Events INNER JOIN Volunteers ON Events.Program = Volunteers.Program AND Events.EventDate = Volunteers.EventDate WHERE Program = 'Arts and Culture' AND Year(EventDate) = 2023 GROUP BY Program; | gretelai_synthetic_text_to_sql |
CREATE TABLE medical_professionals (id INT, name VARCHAR(50), clinic_id INT); CREATE TABLE clinics (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO medical_professionals (id, name, clinic_id) VALUES (1, 'Dr. Smith', 1), (2, 'Dr. Johnson', 1), (3, 'Dr. Lee', 2); INSERT INTO clinics (id, name, location) VALUES (1, 'Clinic A', 'California'), (2, 'Clinic B', 'California'); | What is the name and location of the rural clinic with the fewest medical professionals in the state of California? | SELECT clinics.name, clinics.location FROM clinics JOIN (SELECT clinic_id, COUNT(*) as num_of_professionals FROM medical_professionals GROUP BY clinic_id ORDER BY num_of_professionals LIMIT 1) AS subquery ON clinics.id = subquery.clinic_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT, region TEXT, media_literacy_score INT); INSERT INTO countries VALUES (1, 'USA', 'North America', 75), (2, 'Canada', 'North America', 85), (3, 'Mexico', 'North America', 65), (4, 'Brazil', 'South America', 55), (5, 'Argentina', 'South America', 60), (6, 'France', 'Europe', 80), (7, 'Germany', 'Europe', 85), (8, 'Italy', 'Europe', 70), (9, 'China', 'Asia', 50), (10, 'Japan', 'Asia', 75), (11, 'India', 'Asia', 60), (12, 'Australia', 'Australia', 90), (13, 'South Africa', 'Africa', 45), (14, 'Nigeria', 'Africa', 55), (15, 'Egypt', 'Africa', 65), (16, 'Russia', 'Europe', 60), (17, 'Indonesia', 'Asia', 55), (18, 'Colombia', 'South America', 70); | What is the average media literacy score for each region? | SELECT region, AVG(media_literacy_score) as avg_score FROM countries GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), production_cost DECIMAL(5,2), category VARCHAR(255), fair_trade BOOLEAN); INSERT INTO products (product_id, product_name, production_cost, category, fair_trade) VALUES (1, 'Fair Trade Dress', 19.99, 'Clothing', true); INSERT INTO products (product_id, product_name, production_cost, category, fair_trade) VALUES (2, 'Fair Trade Shirt', 12.50, 'Clothing', true); | What is the total production cost for fair trade products in the 'Clothing' category? | SELECT SUM(production_cost) FROM products WHERE fair_trade = true AND category = 'Clothing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Space_Agencies (ID INT, Agency_Name VARCHAR(255), Num_Missions INT); INSERT INTO Space_Agencies (ID, Agency_Name, Num_Missions) VALUES (1, 'NASA', 100); CREATE TABLE Space_Missions (ID INT, Mission_Name VARCHAR(255), Agency_ID INT); INSERT INTO Space_Missions (ID, Mission_Name, Agency_ID) VALUES (1, 'Apollo 11', 1); CREATE VIEW Agency_Mission_Counts AS SELECT Agency_Name, COUNT(*) as Num_Missions FROM Space_Agencies JOIN Space_Missions ON Space_Agencies.ID = Space_Missions.Agency_ID GROUP BY Agency_Name; | How many space missions were launched by each space agency, according to the Space_Agencies and Space_Missions tables? | SELECT Agency_Name, Num_Missions FROM Agency_Mission_Counts; | gretelai_synthetic_text_to_sql |
CREATE TABLE Grants (GrantID INT, AwardYear INT, Department VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO Grants (GrantID, AwardYear, Department, Amount) VALUES (1, 2020, 'Mathematics', 50000), (2, 2021, 'Physics', 60000), (3, 2020, 'Mathematics', 55000), (4, 2021, 'Computer Science', 70000), (5, 2020, 'Computer Science', 80000); | What is the total grant amount awarded to faculty members in the Computer Science department in 2020? | SELECT SUM(Amount) FROM Grants WHERE Department = 'Computer Science' AND AwardYear = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor VARCHAR(50), cause VARCHAR(50), amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor, cause, amount, donation_date) VALUES (1, 'John Doe', 'Education', 500, '2022-01-05'); INSERT INTO donations (id, donor, cause, amount, donation_date) VALUES (2, 'Jane Smith', 'Health', 300, '2021-03-15'); INSERT INTO donations (id, donor, cause, amount, donation_date) VALUES (3, 'Sophia Lee', 'Environment', 400, '2022-07-03'); | Which causes received donations in both 2021 and 2022? | SELECT cause FROM donations WHERE YEAR(donation_date) IN (2021, 2022) GROUP BY cause HAVING COUNT(DISTINCT YEAR(donation_date)) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE MenuItems (MenuItemID int, MenuItemName varchar(255), MenuItemType varchar(255), DietaryRestrictions varchar(255)); INSERT INTO MenuItems (MenuItemID, MenuItemName, MenuItemType, DietaryRestrictions) VALUES (1, 'Margherita Pizza', 'Entree', 'None'), (2, 'Spaghetti Bolognese', 'Entree', 'None'), (3, 'Caprese Salad', 'Appetizer', 'Vegan'), (4, 'Veggie Burger', 'Entree', 'Vegan'), (5, 'Garden Salad', 'Appetizer', 'Vegan'), (6, 'Chickpea Curry', 'Entree', 'Vegan'), (7, 'Falafel Wrap', 'Entree', 'Vegan'), (8, 'Tofu Stir Fry', 'Entree', 'Vegan'), (9, 'Vegan Cheese Pizza', 'Entree', 'Vegan'), (10, 'Quinoa Salad', 'Entree', 'Vegan, Gluten-free'), (11, 'Gluten-Free Pasta', 'Entree', 'Gluten-free'), (12, 'Gluten-Free Pizza', 'Entree', 'Gluten-free'), (13, 'Gluten-Free Bread', 'Appetizer', 'Gluten-free'); | What is the number of menu items that are both vegan and gluten-free? | SELECT COUNT(*) FROM MenuItems WHERE DietaryRestrictions = 'Vegan, Gluten-free'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID int, EventDate date, EventAttendance int, EventLocation varchar(50)); | What is the percentage of events with an attendance of over 200 that were held in the Americas in 2021? | SELECT (COUNT(*) / (SELECT COUNT(*) FROM Events WHERE EventDate BETWEEN '2021-01-01' AND '2021-12-31' AND EventAttendance > 200)) * 100.0 AS Percentage FROM Events WHERE EventDate BETWEEN '2021-01-01' AND '2021-12-31' AND EventLocation LIKE '%Americas%' AND EventAttendance > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE machines (id INT PRIMARY KEY, model TEXT, year INT, manufacturer TEXT, ethical_manufacturing BOOLEAN); CREATE TABLE maintenance (id INT PRIMARY KEY, machine_id INT, date DATE, FOREIGN KEY (machine_id) REFERENCES machines(id)); | Show machines produced by companies with a strong commitment to ethical manufacturing. | SELECT machines.model, machines.year, machines.manufacturer FROM machines WHERE machines.ethical_manufacturing = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE municipalities (id INT, name VARCHAR(255), population INT); INSERT INTO municipalities (id, name, population) VALUES (1, 'CityA', 50000), (2, 'CityB', 75000), (3, 'CityC', 100000); CREATE TABLE waste_generation (municipality_id INT, date DATE, generation FLOAT); INSERT INTO waste_generation (municipality_id, date, generation) VALUES (1, '2021-01-01', 150), (1, '2021-01-02', 160), (2, '2021-01-01', 200), (2, '2021-01-02', 210), (3, '2021-01-01', 250), (3, '2021-01-02', 260); | What is the average daily waste generation for each municipality? | SELECT municipality_id, AVG(generation) OVER (PARTITION BY municipality_id) as avg_daily_generation FROM waste_generation; | gretelai_synthetic_text_to_sql |
CREATE TABLE solana_transactions (transaction_id INT, tx_time TIMESTAMP, gas_price DECIMAL(10, 2)); INSERT INTO solana_transactions (transaction_id, tx_time, gas_price) VALUES (1, '2022-01-01 10:00:00', 0.01), (2, '2022-01-02 11:00:00', 0.02), (3, '2022-01-03 12:00:00', 0.03), (4, '2022-01-04 13:00:00', 0.04), (5, '2022-01-05 14:00:00', 0.05); | What is the average gas price for transactions on the Solana network, grouped by week? | SELECT DATE_FORMAT(tx_time, '%Y-%u') AS week, AVG(gas_price) AS avg_gas_price FROM solana_transactions GROUP BY week; | gretelai_synthetic_text_to_sql |
CREATE TABLE CyberThreats (id INT, country VARCHAR(50), threat_type VARCHAR(50), threat_date DATE); INSERT INTO CyberThreats (id, country, threat_type, threat_date) VALUES (1, 'Iraq', 'Phishing', '2021-01-12'), (2, 'Saudi Arabia', 'Ransomware', '2021-03-25'), (3, 'Israel', 'Malware', '2021-05-08'); | What is the total number of cyber threats detected by the military in the Middle East in the last 6 months? | SELECT SUM(frequency) FROM (SELECT COUNT(*) AS frequency FROM CyberThreats WHERE country LIKE '%Middle East%' AND threat_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY threat_type) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE factory (id INT, name TEXT, sector TEXT, country TEXT); INSERT INTO factory (id, name, sector, country) VALUES (1, 'FactoryA', 'automotive', 'France'), (2, 'FactoryB', 'aerospace', 'France'), (3, 'FactoryC', 'electronics', 'Germany'); CREATE TABLE production (factory_id INT, output REAL); INSERT INTO production (factory_id, output) VALUES (1, 1000), (1, 1200), (2, 1500), (3, 1800); | What is the total production output for all factories in France? | SELECT SUM(production.output) FROM production INNER JOIN factory ON production.factory_id = factory.id WHERE factory.country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE local_economy_extended (state TEXT, impact FLOAT, year INT); INSERT INTO local_economy_extended (state, impact, year) VALUES ('New York', 50000.0, 2021), ('California', 75000.0, 2021), ('Texas', 60000.0, 2021); | Local economic impact of sustainable tourism in each state? | SELECT state, impact FROM local_economy_extended WHERE year = 2021 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Team_E (match_id INT, playing_time INT); INSERT INTO Team_E (match_id, playing_time) VALUES (1, 180), (2, 190), (3, 200); | What was the total playing time for Team E? | SELECT SUM(playing_time) FROM Team_E; | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Development_Colombia (id INT, country VARCHAR(50), year INT, cost FLOAT); INSERT INTO Community_Development_Colombia (id, country, year, cost) VALUES (1, 'Colombia', 2017, 15000.0), (2, 'Colombia', 2018, 18000.0), (3, 'Colombia', 2019, 20000.0); | What was the average cost of rural community development initiatives in Colombia in 2017? | SELECT AVG(cost) FROM Community_Development_Colombia WHERE country = 'Colombia' AND year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, price DECIMAL(5,2), material VARCHAR(20), country VARCHAR(20)); INSERT INTO sales (id, price, material, country) VALUES (1, 75.00, 'linen', 'UK'); -- additional rows removed for brevity; | What is the maximum price of linen garments sold in the UK? | SELECT MAX(price) FROM sales WHERE material = 'linen' AND country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO warehouse (id, name, location) VALUES (1, 'Warehouse A', 'City A'), (2, 'Warehouse B', 'City B'); CREATE TABLE inventory (id INT, warehouse_id INT, product VARCHAR(50), quantity INT); INSERT INTO inventory (id, warehouse_id, product, quantity) VALUES (1, 1, 'Product X', 300), (2, 1, 'Product Y', 400), (3, 2, 'Product X', 500), (4, 2, 'Product Z', 200); CREATE TABLE product (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO product (id, name, category) VALUES (1, 'Product X', 'Category A'), (2, 'Product Y', 'Category B'), (3, 'Product Z', 'Category C'); | What is the total quantity of items stored in each warehouse for each category of products? | SELECT w.name, p.category, SUM(i.quantity) as total_quantity FROM inventory i JOIN warehouse w ON i.warehouse_id = w.id JOIN product p ON i.product = p.name GROUP BY w.name, p.category WITH ROLLUP; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_energy_projects (id INT, project_type VARCHAR(100), country VARCHAR(50), co2_emissions_reduction FLOAT, implementation_date DATE); INSERT INTO wind_energy_projects (id, project_type, country, co2_emissions_reduction, implementation_date) VALUES (1, 'Onshore Wind Project A', 'Germany', 2000, '2015-01-01'); INSERT INTO wind_energy_projects (id, project_type, country, co2_emissions_reduction, implementation_date) VALUES (2, 'Offshore Wind Project B', 'Germany', 3000, '2016-01-01'); | What is the total CO2 emissions reduction achieved by wind energy projects in Germany, grouped by project type and year of implementation? | SELECT project_type, YEAR(implementation_date) AS implementation_year, SUM(co2_emissions_reduction) AS total_reduction FROM wind_energy_projects WHERE country = 'Germany' GROUP BY project_type, YEAR(implementation_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_j_sales (quarter INTEGER, year INTEGER, revenue INTEGER); INSERT INTO drug_j_sales (quarter, year, revenue) VALUES (1, 2021, 550000), (2, 2021, 650000), (3, 2021, 750000), (4, 2021, 850000); | What was the average sales revenue for 'DrugJ' in 2021? | SELECT AVG(revenue) FROM drug_j_sales WHERE year = 2021 AND drug_name = 'DrugJ'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_for_climate_change (id INT, initiative_name VARCHAR(255), funding_quarter VARCHAR(10), budget DECIMAL(10,2)); INSERT INTO ai_for_climate_change (id, initiative_name, funding_quarter, budget) VALUES (1, 'AI for Climate Change', 'Q3 2023', 20000); | Update the budget of the AI for Climate Change initiative to $22,000 in Q3 2023. | UPDATE ai_for_climate_change SET budget = 22000 WHERE initiative_name = 'AI for Climate Change' AND funding_quarter = 'Q3 2023'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge_Inspections (inspection_id INT, bridge_name VARCHAR(50), bridge_type VARCHAR(50), inspection_date DATE); | Count the number of bridges in the Bridge_Inspections table | SELECT COUNT(*) FROM Bridge_Inspections WHERE bridge_type = 'Bridge'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name TEXT, credit_score INT, country TEXT); INSERT INTO customers (customer_id, customer_name, credit_score, country) VALUES (1, 'Budi', 700, 'Indonesia'), (2, 'Dewi', 750, 'Indonesia'); CREATE TABLE loans (loan_id INT, customer_id INT, maturity INT); INSERT INTO loans (loan_id, customer_id, maturity) VALUES (1, 1, 2), (2, 2, 3); | What is the average credit score of customers who have taken out loans with a maturity of 3 years or less, in Indonesia? | SELECT AVG(credit_score) FROM customers JOIN loans ON customers.customer_id = loans.customer_id WHERE country = 'Indonesia' AND maturity <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(10)); INSERT INTO countries (id, name) VALUES (1, 'FR'), (2, 'DE'); CREATE TABLE regulations (id INT, country VARCHAR(10), quarter DATE, description VARCHAR(50)); | Add a new regulatory record 'New Regulation C' for country 'ES' in Q1 of 2023 | INSERT INTO countries (id, name) VALUES (3, 'ES'); INSERT INTO regulations (id, country, quarter, description) VALUES (4, 'ES', '2023-01-01', 'New Regulation C'); | gretelai_synthetic_text_to_sql |
CREATE TABLE public.vehicles (id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO public.vehicles (id, type, city) VALUES (1, 'electric_car', 'Tokyo'), (2, 'conventional_car', 'Tokyo'), (3, 'autonomous_bus', 'Tokyo'); | List all types of vehicles and their respective counts in 'Tokyo' | SELECT type, COUNT(*) FROM public.vehicles WHERE city = 'Tokyo' GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE support_programs (id INT, program_name VARCHAR(50), description TEXT); INSERT INTO support_programs (id, program_name, description) VALUES (1, 'Mentorship Program', 'A program that pairs students with mentors'), (2, 'Tutoring Program', 'A program that provides tutoring for students with disabilities'); CREATE TABLE participants (id INT, program_id INT, participant_name VARCHAR(50)); INSERT INTO participants (id, program_id, participant_name) VALUES (1, 1, 'Alice Johnson'), (2, 1, 'Bob Smith'), (3, 2, 'Charlie Brown'); | List all support programs and the number of participants for each program. | SELECT support_programs.program_name, COUNT(participants.id) AS number_of_participants FROM support_programs INNER JOIN participants ON support_programs.id = participants.program_id GROUP BY support_programs.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces (id INT, country VARCHAR(50), num_employees INT, is_unionized BOOLEAN); INSERT INTO workplaces (id, country, num_employees, is_unionized) VALUES (1, 'United States', 100, true), (2, 'United States', 200, false), (3, 'United States', 150, true); | What is the average number of employees in unionized workplaces in the United States? | SELECT AVG(num_employees) FROM workplaces WHERE country = 'United States' AND is_unionized = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE droughts (state VARCHAR(50), year INT, severity INT); INSERT INTO droughts (state, year, severity) VALUES ('California', 2017, 8), ('California', 2018, 7), ('California', 2019, 6), ('California', 2020, 9), ('California', 2021, 5), ('Texas', 2017, 5), ('Texas', 2018, 6), ('Texas', 2019, 7), ('Texas', 2020, 8), ('Texas', 2021, 4), ('Nevada', 2017, 7), ('Nevada', 2018, 6), ('Nevada', 2019, 8), ('Nevada', 2020, 9), ('Nevada', 2021, 4); | What is the maximum drought severity in each state over the past 5 years? | SELECT state, MAX(severity) as max_severity FROM droughts WHERE year BETWEEN 2017 AND 2021 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE otabookings (id INT, hotel_id INT, room_type VARCHAR(255), customer_name VARCHAR(255), booking_date DATE); INSERT INTO otabookings (id, hotel_id, room_type, customer_name, booking_date) VALUES (1, 3, 'family', 'John Doe', '2022-03-15'); INSERT INTO otabookings (id, hotel_id, room_type, customer_name, booking_date) VALUES (2, 4, 'family', 'Jane Smith', '2022-03-20'); | List all OTA (Online Travel Agency) bookings made for 'Paris' hotels with a 'family' room type in the last month. | SELECT * FROM otabookings WHERE room_type = 'family' AND city = 'Paris' AND booking_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item VARCHAR(50), type VARCHAR(15), sales INT, cost DECIMAL(10,2)); INSERT INTO menu_items (item, type, sales, cost) VALUES ('Steak', 'Non-Vegan', 50, 20.00), ('Chicken Alfredo', 'Non-Vegan', 75, 18.00); CREATE VIEW profit AS SELECT item, sales - cost as profit FROM menu_items; | Identify the least profitable non-vegan menu items to potentially replace? | SELECT item FROM profit WHERE type = 'Non-Vegan' ORDER BY profit LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE depletion (mine_id INT, date DATE, resource TEXT, quantity INT); INSERT INTO mine VALUES (1, 'Mine A', 'Country A'); INSERT INTO mine VALUES (2, 'Mine B', 'Country B'); INSERT INTO depletion VALUES (1, '2021-01-01', 'Gold', 100); INSERT INTO depletion VALUES (1, '2021-02-01', 'Gold', 120); INSERT INTO depletion VALUES (1, '2021-03-01', 'Gold', 150); INSERT INTO depletion VALUES (2, '2021-01-01', 'Silver', 50); INSERT INTO depletion VALUES (2, '2021-02-01', 'Silver', 75); INSERT INTO depletion VALUES (2, '2021-03-01', 'Silver', 85); | Determine the total amount of resources depleted by each mine | SELECT mine.name, SUM(depletion.quantity) AS total_depleted FROM mine INNER JOIN depletion ON mine.id = depletion.mine_id GROUP BY mine.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), gender VARCHAR(10), state VARCHAR(50)); CREATE TABLE diagnoses (id INT, patient_id INT, diagnosis VARCHAR(50)); INSERT INTO patients (id, name, gender, state) VALUES (1, 'John Doe', 'Male', 'Montana'); INSERT INTO diagnoses (id, patient_id, diagnosis) VALUES (1, 1, 'Cancer'); INSERT INTO diagnoses (id, patient_id, diagnosis) VALUES (2, 2, 'Flu'); | What is the most common disease among male patients in rural Montana? | SELECT diagnoses.diagnosis, COUNT(*) FROM diagnoses JOIN patients ON diagnoses.patient_id = patients.id WHERE patients.gender = 'Male' AND patients.state = 'Montana' GROUP BY diagnoses.diagnosis ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_solar (project_name TEXT, country TEXT); INSERT INTO project_solar (project_name, country) VALUES ('Project A', 'Country A'), ('Project B', 'Country A'), ('Project C', 'Country B'), ('Project D', 'Country C'), ('Project E', 'Country D'), ('Project F', 'Country D'), ('Project G', 'Country A'); | Which countries have the most solar power projects? | SELECT country, COUNT(*) FROM project_solar GROUP BY country ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, name TEXT, data_usage FLOAT); INSERT INTO subscribers (id, name, data_usage) VALUES (1, 'John Doe', 15.0); INSERT INTO subscribers (id, name, data_usage) VALUES (2, 'Jane Smith', 20.0); INSERT INTO subscribers (id, name, data_usage) VALUES (3, 'Bob Johnson', 25.0); | What is the maximum data usage by a single subscriber? | SELECT MAX(data_usage) FROM subscribers; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (project_name VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO DefenseProjects (project_name, start_date, end_date, budget) VALUES ('Project Y', '2021-01-01', '2023-12-31', 1000000000); | Update the name of defense project 'Project Y' to 'Project Z' and its budget to 1,500,000,000. | UPDATE DefenseProjects SET project_name = 'Project Z', budget = 1500000000 WHERE project_name = 'Project Y'; | gretelai_synthetic_text_to_sql |
CREATE TABLE continent (id INT, name VARCHAR(50)); INSERT INTO continent (id, name) VALUES (1, 'Europe'), (2, 'Americas'), (3, 'Asia'), (4, 'Africa'), (5, 'Oceania'); CREATE TABLE country (id INT, name VARCHAR(50), continent_id INT); INSERT INTO country (id, name, continent_id) VALUES (1, 'France', 1), (2, 'USA', 2), (3, 'China', 3); CREATE TABLE museums (country_id INT, name VARCHAR(50)); INSERT INTO museums (country_id, name) VALUES (1, 'Louvre'), (1, 'Orsay'), (2, 'Metropolitan Museum of Art'), (3, 'National Museum of China'); | How many countries are represented in the 'museums' table? | SELECT COUNT(DISTINCT c.country_id) FROM museums m JOIN country c ON m.country_id = c.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_art_marketplaces (marketplace_id INT, marketplace_name VARCHAR(50), company_id INT); INSERT INTO digital_art_marketplaces (marketplace_id, marketplace_name, company_id) VALUES (1, 'OpenSea', 1); INSERT INTO digital_art_marketplaces (marketplace_id, marketplace_name, company_id) VALUES (2, 'Rarible', 2); INSERT INTO digital_art_marketplaces (marketplace_id, marketplace_name, company_id) VALUES (3, 'SuperRare', 3); CREATE TABLE blockchain_companies (company_id INT, company_name VARCHAR(50), platform VARCHAR(50)); INSERT INTO blockchain_companies (company_id, company_name, platform) VALUES (1, 'ConsenSys', 'Ethereum'); INSERT INTO blockchain_companies (company_id, company_name, platform) VALUES (2, 'Chainalysis', 'Bitcoin'); INSERT INTO blockchain_companies (company_id, company_name, platform) VALUES (3, 'MetaMask', 'Ethereum'); | What are the digital art marketplaces with their corresponding blockchain companies, ranked by marketplace ID in descending order, for the Ethereum platform? | SELECT dam.marketplace_name, bc.company_name, dam.marketplace_id, ROW_NUMBER() OVER (PARTITION BY bc.platform ORDER BY dam.marketplace_id DESC) as rank FROM digital_art_marketplaces dam JOIN blockchain_companies bc ON dam.company_id = bc.company_id WHERE bc.platform = 'Ethereum'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleSales (vehicle_id INT, model VARCHAR(100), type VARCHAR(50), country VARCHAR(50), year INT); INSERT INTO VehicleSales (vehicle_id, model, type, country, year) VALUES (1, 'Model 3', 'Electric', 'Germany', 2019), (2, 'Golf', 'Gasoline', 'Germany', 2019); | How many electric vehicles were sold in Germany in 2019? | SELECT COUNT(*) FROM VehicleSales WHERE type = 'Electric' AND country = 'Germany' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE NeodymiumExport(year INT, country VARCHAR(50), percentage DECIMAL(5,2)); INSERT INTO NeodymiumExport(year, country, percentage) VALUES (2017, 'Brazil', 18.5), (2017, 'USA', 12.0), (2017, 'China', 45.0), (2018, 'Brazil', 20.0), (2018, 'USA', 13.0), (2018, 'China', 44.0); | What is the percentage of Neodymium exported from Brazil to other countries annually? | SELECT (SUM(percentage) FILTER (WHERE country = 'Brazil'))/SUM(percentage) FROM NeodymiumExport; | 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.