context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE ingredients (product_id INT, ingredient VARCHAR(255), weight FLOAT, sustainability_score INT); INSERT INTO ingredients (product_id, ingredient, weight, sustainability_score) VALUES (1, 'IngredientA', 10, 85), (1, 'IngredientB', 5, 80), (2, 'IngredientA', 8, 90), (2, 'IngredientC', 12, 75); | What is the total weight of the top 3 ingredients, by product, for products with a sustainability score greater than 80, ordered by total weight in descending order? | SELECT product_id, SUM(weight) as total_weight FROM ingredients WHERE sustainability_score > 80 GROUP BY product_id ORDER BY total_weight DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO Restaurants (id, name, type) VALUES (1, 'Green Garden', 'Vegan'); INSERT INTO Restaurants (id, name, type) VALUES (2, 'Bistro Bella', 'Italian'); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), price DECIMAL(5,2)); INSERT... | What is the maximum price of vegan dishes? | SELECT MAX(price) FROM Menu WHERE dish LIKE '%vegan%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists military_technologies (country VARCHAR(50), technology_name VARCHAR(50), year INT); | What is the total number of military technologies developed by each country since 2010? | SELECT country, COUNT(technology_name) as total_technologies FROM military_technologies WHERE year >= 2010 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE PermitsByDay (PermitID int, Date date, State varchar(25)); INSERT INTO PermitsByDay (PermitID, Date, State) VALUES (1, '2020-01-01', 'CA'), (2, '2020-02-01', 'CA'), (3, '2020-03-01', 'CA'); | How many building permits were issued per day in CA in 2020? | SELECT DATEPART(YEAR, Date) AS Year, DATEPART(MONTH, Date) AS Month, DATEPART(DAY, Date) AS Day, COUNT(*) AS PermitsIssued FROM PermitsByDay WHERE State = 'CA' AND YEAR(Date) = 2020 GROUP BY DATEPART(YEAR, Date), DATEPART(MONTH, Date), DATEPART(DAY, Date); | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums (MuseumID INT PRIMARY KEY, MuseumName VARCHAR(255), MuseumLocation VARCHAR(255), AnnualVisitors INT); INSERT INTO Museums (MuseumID, MuseumName, MuseumLocation, AnnualVisitors) VALUES (1, 'Te Papa', 'Oceania', 15000), (2, 'Australian Museum', 'Oceania', 20000), (3, 'Museum of New Zealand Te Papa To... | Count the number of museums in Oceania with more than 10000 visitors per year | SELECT COUNT(MuseumID) AS MuseumCount FROM Museums WHERE MuseumLocation = 'Oceania' AND AnnualVisitors > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tour_revenue (date TEXT, region TEXT, revenue FLOAT); INSERT INTO virtual_tour_revenue (date, region, revenue) VALUES ('2021-01-01', 'Asia', 500), ('2021-01-02', 'Asia', 700), ('2021-01-03', 'Asia', 800), ('2021-01-04', 'Asia', 600), ('2021-01-05', 'Asia', 900); | What is the average daily revenue for virtual tours in Asia? | SELECT AVG(revenue) AS avg_daily_revenue FROM virtual_tour_revenue WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (incident_id INT, incident_date DATE, user_id INT);CREATE TABLE users (user_id INT, user_name VARCHAR(255), department VARCHAR(255)); | What is the percentage of security incidents in the last year that involved a user from the finance department? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))) as percentage FROM security_incidents si JOIN users u ON si.user_id = u.user_id WHERE u.department = 'Finance' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE Clothing (id INT, brand VARCHAR(255), price DECIMAL(5,2), sustainable VARCHAR(10)); INSERT INTO Clothing (id, brand, price, sustainable) VALUES (1, 'BrandA', 25.99, 'yes'), (2, 'BrandB', 150.00, 'no'), (3, 'BrandC', 79.99, 'yes'), (4, 'BrandD', 19.99, 'yes'); | Get the minimum price of sustainable clothing items, grouped by brand, for brands that have at least one sustainable item. | SELECT brand, MIN(price) FROM Clothing WHERE sustainable = 'yes' GROUP BY brand HAVING COUNT(*) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(255), studio VARCHAR(255), rating FLOAT); INSERT INTO movies (title, genre, studio, rating) VALUES ('Movie15', 'Action', 'Brazil Studio1', 6.5), ('Movie16', 'Drama', 'Brazil Studio2', 5.0); | Find the title and genre of the bottom 2 movies with the lowest ratings from studios based in Brazil, ordered by ratings in ascending order. | SELECT title, genre FROM (SELECT title, genre, studio, rating, ROW_NUMBER() OVER (PARTITION BY studio ORDER BY rating ASC) as rank FROM movies WHERE studio LIKE '%Brazil%') subquery WHERE rank <= 2 ORDER BY rating ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_deliveries (supplier VARCHAR(50), deliveries INT, date DATE); INSERT INTO supplier_deliveries (supplier, deliveries, date) VALUES ('GreenGrowers', 15, '2022-01-01'), ('OrganicOrigins', 20, '2022-01-02'); CREATE VIEW supplier_frequencies AS SELECT supplier, COUNT(*) as delivery_frequency FROM suppl... | List the top 3 sustainable suppliers based on delivery frequency? | SELECT supplier FROM supplier_frequencies ORDER BY delivery_frequency DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_scores (student_id INT, student_name VARCHAR(255), gender VARCHAR(10), department VARCHAR(255)); INSERT INTO student_scores (student_id, student_name, gender, department) VALUES (18, 'Sarah Kim', 'Female', 'Electrical Engineering'), (19, 'David Lee', 'Male', 'Civil Engineering'), (20, 'Grace Ahn', ... | Delete all records from the student_scores table where the student_name is 'Sarah Kim' and the department is 'Electrical Engineering' | DELETE FROM student_scores WHERE student_name = 'Sarah Kim' AND department = 'Electrical Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, region TEXT); CREATE TABLE fine (id INT, company_id INT, date DATE, cost INT); INSERT INTO company (id, name, region) VALUES (1, 'ABC Shipping', 'Africa'), (2, 'XYZ Maritime', 'Europe'), (3, 'DEF Transport', 'Africa'); INSERT INTO fine (id, company_id, date, cost) VALUES (1, 1, ... | What is the total cost of all fines issued to companies from Africa in the last quarter? | SELECT SUM(f.cost) FROM fine f INNER JOIN company c ON f.company_id = c.id WHERE c.region = 'Africa' AND f.date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (id INT, name VARCHAR(255), location VARCHAR(255), followers INT); CREATE TABLE posts (id INT, account_id INT, content TEXT, timestamp TIMESTAMP); INSERT INTO accounts (id, name, location, followers) VALUES (1, 'mental_health_advocate', 'Mexico', 8000); INSERT INTO posts (id, account_id, content, ... | What is the total number of followers for accounts that have posted about mental health awareness in the past month, located in Mexico? | SELECT SUM(accounts.followers) FROM accounts JOIN posts ON accounts.id = posts.account_id WHERE posts.timestamp >= NOW() - INTERVAL '1 month' AND posts.content LIKE '%mental health%' AND accounts.location = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists blockchain; CREATE TABLE if not exists blockchain.smart_contracts ( contract_id INT AUTO_INCREMENT, contract_name VARCHAR(255), contract_address VARCHAR(255), ROW_NUM INT, PRIMARY KEY (contract_id)); INSERT INTO blockchain.smart_contracts (contract_name, contract_address) VALUES ('Uniswap', ... | Delete all records from the smart_contracts table. | DELETE FROM blockchain.smart_contracts; | gretelai_synthetic_text_to_sql |
CREATE TABLE ImportData (ImportID int, Country varchar(50), Product varchar(50), Amount decimal(10,2), Date date); | What is the total amount spent on imported organic food by each country in the past year? | SELECT Country, SUM(Amount) FROM ImportData WHERE Product LIKE '%organic food%' AND Date >= ADD_MONTHS(TRUNC(CURRENT_DATE, 'MM'), -12) GROUP BY Country ORDER BY SUM(Amount) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (company_id INT, round_type TEXT, raised_amount INT); INSERT INTO investments (company_id, round_type, raised_amount) VALUES (1, 'Series A', 5000000); INSERT INTO investments (company_id, round_type, raised_amount) VALUES (2, 'Seed', 1000000); | What is the total investment raised by companies founded in the last 5 years? | SELECT SUM(raised_amount) as total_investment FROM investments JOIN companies ON investments.company_id = companies.id WHERE companies.founding_year >= YEAR(CURRENT_DATE) - 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_scores (country VARCHAR(255), year INT, score FLOAT); INSERT INTO energy_efficiency_scores (country, year, score) VALUES ('Brazil', 2020, 60), ('Argentina', 2020, 65), ('Chile', 2020, 70); | List energy efficiency scores in 2022 and the previous year for the bottom 2 performing countries | SELECT country, year, score FROM (SELECT country, year, score, ROW_NUMBER() OVER (ORDER BY score ASC) AS rn FROM energy_efficiency_scores WHERE year IN (2020, 2022)) t WHERE rn <= 2 ORDER BY year, score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (city VARCHAR(255), year INT, capacity_m3 INT); INSERT INTO landfill_capacity (city, year, capacity_m3) VALUES ('Mumbai', 2020, 1500000); | What is the landfill capacity in Mumbai for 2020? | SELECT capacity_m3 FROM landfill_capacity WHERE city = 'Mumbai' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE viewership(id INT PRIMARY KEY, movie VARCHAR(255), viewer VARCHAR(255)); | insert new viewer 'Lia' into the viewership table | INSERT INTO viewership(id, movie, viewer) VALUES(1, 'The Witcher', 'Lia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(255)); CREATE TABLE Donations (donation_id INT, donor_id INT, donation_amount INT, donation_date DATE, program_area VARCHAR(255)); INSERT INTO Donors (donor_id, donor_name) VALUES (1, 'James Smith'); INSERT INTO Donations (donation_id, donor_id, donation_amount, don... | What is the average donation amount to 'Disaster Relief' programs in '2020'? | SELECT AVG(Donations.donation_amount) FROM Donations INNER JOIN Programs ON Donations.program_area = Programs.program_name WHERE Programs.program_name = 'Disaster Relief' AND YEAR(Donations.donation_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE min_prices (neighborhood VARCHAR(50), price DECIMAL(10, 2)); INSERT INTO min_prices (neighborhood, price) VALUES ('Westwood', 850000.00), ('Beverly Hills', 2500000.00), ('Venice', 1200000.00); | What is the minimum property price in each neighborhood? | SELECT neighborhood, MIN(price) OVER (PARTITION BY neighborhood) AS min_price FROM min_prices; | gretelai_synthetic_text_to_sql |
CREATE TABLE seoul_bikes (id INT, ride_id VARCHAR(20), start_time TIMESTAMP, end_time TIMESTAMP, bike_id INT); | What is the daily usage of bike-sharing systems in Seoul? | SELECT DATE(start_time) AS ride_date, COUNT(DISTINCT bike_id) FROM seoul_bikes GROUP BY ride_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, department VARCHAR(50), value FLOAT); INSERT INTO defense_contracts (contract_id, department, value) VALUES (1, 'Army', 500000), (2, 'Navy', 700000); | Find the total count of defense contracts awarded by the 'Army' and 'Navy' departments | SELECT SUM(value) FROM defense_contracts WHERE department IN ('Army', 'Navy'); | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_revenue (id INT, title VARCHAR(255), release_year INT, revenue INT); INSERT INTO movie_revenue (id, title, release_year, revenue) VALUES (1, 'Toy Story 3', 2010, 1103000000), (2, 'Iron Man 2', 2010, 623970000); | What's the total revenue of movies released in 2010? | SELECT SUM(revenue) FROM movie_revenue WHERE release_year = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_types_min (crop_type TEXT, acres NUMERIC, yield NUMERIC); INSERT INTO crop_types_min (crop_type, acres, yield) VALUES ('Wheat', 2.1, 12500), ('Rice', 3.5, 17500), ('Corn', 4.2, 24500), ('Soybeans', 2.9, 15500); | What is the minimum yield per acre for each crop type in urban agriculture? | SELECT crop_type, MIN(yield/acres) as min_yield_per_acre FROM crop_types_min GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments(id INT, source VARCHAR(255), destination VARCHAR(255), shipment_date DATE); INSERT INTO shipments(id, source, destination, shipment_date) VALUES (1, 'China', 'Japan', '2022-01-01'), (2, 'China', 'South Korea', '2022-01-05'), (3, 'China', 'Japan', '2022-01-10'), (4, 'China', 'India', '2022-02-01... | What is the total number of shipments sent to each country from China in the last year? | SELECT destination, COUNT(*) FROM shipments WHERE source = 'China' AND shipment_date >= CURDATE() - INTERVAL 365 DAY GROUP BY destination; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT PRIMARY KEY, customer_id INT, usage_date DATE, usage_type VARCHAR(255), amount FLOAT); CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(255), neighborhood VARCHAR(255)); | What is the total water usage by residential customers in a specific neighborhood in 2022? | SELECT SUM(wu.amount) as total_water_usage FROM water_usage wu JOIN customers c ON wu.customer_id = c.id WHERE wu.usage_type = 'Residential' AND wu.usage_date BETWEEN '2022-01-01' AND '2022-12-31' AND c.neighborhood = 'Specific Neighborhood'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (species VARCHAR(255), animal_id INT, name VARCHAR(255), age INT, health_status VARCHAR(255)); INSERT INTO animal_population (species, animal_id, name, age, health_status) VALUES ('Tiger', 1, 'Tara', 5, 'Healthy'), ('Tiger', 2, 'Tim', 3, 'Sick'), ('Elephant', 3, 'Ella', 10, 'Healthy'); | What is the average age of the animals in the 'animal_population' table per species? | SELECT species, AVG(age) as avg_age FROM animal_population GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50)); CREATE TABLE criminal_cases (case_id INT, attorney_id INT); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'Smith'), (2, 'Johnson'), (3, 'Brown'); INSERT INTO criminal_cases (case_id, attorney_id) VALUES (1, 1), (2, 3); | List all attorneys who have not handled any criminal cases. | SELECT a.name FROM attorneys a LEFT JOIN criminal_cases cc ON a.attorney_id = cc.attorney_id WHERE cc.attorney_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), chatbot VARCHAR(50), rating FLOAT); INSERT INTO hotels (hotel_id, name, chatbot, rating) VALUES (1, 'Hotel X', 'Model A', 4.5), (2, 'Hotel Y', 'Model B', 4.2), (3, 'Hotel Z', 'Model A', 4.7), (4, 'Hotel W', 'Model C', 4.3), (5, 'Hotel V', 'Model A', 4.6), (6, 'Hotel ... | List the unique AI chatbot models used by the hotels in the hotels table, the adoption count, and the number of hotels with ratings above 4.5. | SELECT chatbot, COUNT(DISTINCT hotel_id) as adoption_count, COUNT(CASE WHEN rating > 4.5 THEN 1 END) as high_rating_hotels_count FROM hotels GROUP BY chatbot; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor (labor_id INT, permit_id INT, worker_name TEXT, hours_worked INT, wage FLOAT); INSERT INTO construction_labor (labor_id, permit_id, worker_name, hours_worked, wage) VALUES (3, 3, 'Maria Garcia', 180, 28.0); | What are the total hours worked by construction laborers for permits issued in 2020, grouped by permit_id? | SELECT permit_id, SUM(hours_worked) FROM construction_labor WHERE permit_id IN (SELECT permit_id FROM building_permits WHERE EXTRACT(YEAR FROM issue_date) = 2020) GROUP BY permit_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE australia_mines (id INT, mine_name TEXT, location TEXT, mineral TEXT); INSERT INTO australia_mines (id, mine_name, location, mineral) VALUES (1, 'Opal Outback', 'Western Australia', 'Opal'), (2, 'Emerald Empire', 'Queensland, Australia', 'Emerald'); | List all mines in Australia and their respective mineral types. | SELECT id, mine_name, location, mineral FROM australia_mines; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, city, response_time) VALUES (1, 'San Francisco', 120), (2, 'New York', 150), (3, 'Los Angeles', 100); | Find the maximum response time for emergency calls in 'New York' | SELECT MAX(response_time) FROM emergency_calls WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecycledWater (id INT, state VARCHAR(20), year INT, volume FLOAT); INSERT INTO RecycledWater (id, state, year, volume) VALUES (1, 'Florida', 2020, 500000.0), (2, 'Florida', 2019, 450000.0), (3, 'Georgia', 2020, 550000.0); | What is the total volume of recycled water in Florida during 2020? | SELECT SUM(volume) FROM RecycledWater WHERE state = 'Florida' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorCities (City VARCHAR(50), Population INT); INSERT INTO DonorCities (City, Population) VALUES ('San Francisco', 884363), ('Seattle', 753359), ('Boston', 694543); CREATE TABLE Donations (DonationID INT, City VARCHAR(50), DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, City, DonationAmo... | What is the percentage of donations received by the top 3 cities? | SELECT City, SUM(DonationAmount) * 100.0 / (SELECT SUM(DonationAmount) FROM Donations) AS percentage FROM Donations GROUP BY City ORDER BY percentage DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_info(product_name TEXT, is_natural BOOLEAN, rating DECIMAL); INSERT INTO cosmetics_info(product_name, is_natural, rating) VALUES('Natural Foundation 1', true, 4.5); | Which natural foundations have the highest customer ratings? | SELECT product_name FROM cosmetics_info WHERE is_natural = true AND rating = (SELECT MAX(rating) FROM cosmetics_info WHERE is_natural = true); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerName TEXT, Country TEXT, Score INT, GamesPlayed INT); INSERT INTO Players (PlayerID, PlayerName, Country, Score, GamesPlayed) VALUES (1, 'John Doe', 'USA', 100, 50), (2, 'Jane Smith', 'Canada', 200, 75); | What is the average score and total games played by players from the United States and Canada? | SELECT AVG(Score) AS AvgScore, SUM(GamesPlayed) AS TotalGames FROM Players WHERE Country IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), menu_type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO menus (menu_id, menu_name, menu_type, price) VALUES (1, 'Quinoa Salad', 'Vegetarian', 9.99), (2, 'Margherita Pizza', 'Non-vegetarian', 12.99), (3, 'Tofu Stir Fry', 'Vegetarian', 10.99), (4, 'Vegan Burger', 'V... | What is the minimum price of vegan menu items? | SELECT MIN(price) FROM menus WHERE menu_type = 'Vegan'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.devices(id INT, name VARCHAR(255), type VARCHAR(255), output DECIMAL(10,2), country VARCHAR(255)); INSERT INTO biosensors.devices VALUES (1, 'BioSensorA', 'Type1', 5.2, 'India'); INSERT INTO biosensors.devices VALUES (2, 'BioSensorB', 'Type2',... | What is the average biosensor output for each biosensor type in India? | SELECT type, AVG(output) FROM biosensors.devices WHERE country = 'India' GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(100), Country varchar(50), DonationDate date, AmountDonated decimal(10,2)); INSERT INTO Donors (DonorID, DonorName, Country, DonationDate, AmountDonated) VALUES (1, 'Rajesh Patel', 'India', '2022-01-01', 1000.00), (2, 'Priya Gupta', 'India', '2022-02-01', 2000.00), (3... | Who are the top 5 donors from India? | SELECT DonorName, SUM(AmountDonated) as TotalDonated FROM Donors WHERE Country = 'India' GROUP BY DonorName ORDER BY TotalDonated DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Department VARCHAR(50), Publications INT, PublicationYear INT); | How many graduate students in the Business department have not published any papers in the year 2019? | SELECT COUNT(StudentID) FROM GraduateStudents WHERE Department = 'Business' AND Publications = 0 AND PublicationYear = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_quality (region VARCHAR(255), year INT, contaminant_level INT); INSERT INTO water_quality (region, year, contaminant_level) VALUES ('North', 2018, 10), ('North', 2019, 12), ('North', 2020, 15), ('South', 2018, 15), ('South', 2019, 18), ('South', 2020, 20); CREATE TABLE conservation_initiatives (regio... | Which conservation initiatives were implemented in regions with increasing contaminant levels in 2020? | SELECT c.initiative FROM conservation_initiatives c JOIN water_quality w ON c.region = w.region WHERE c.year = w.year AND w.contaminant_level > (SELECT contaminant_level FROM water_quality WHERE region = w.region AND year = w.year - 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (id INT, vessel_id INT, timestamp DATETIME, speed FLOAT); | Update records in the vessel_performance table where the vessel_id is 1001 and speed is less than 15, set the speed to 15 | UPDATE vessel_performance SET speed = 15 WHERE vessel_id = 1001 AND speed < 15; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics.sales_data (sale_id INT, category VARCHAR(50), country VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO cosmetics.sales_data (sale_id, category, country, revenue) VALUES (1, 'Skincare', 'Canada', 50.00), (2, 'Makeup', 'Canada', 75.00), (3, 'Haircare', 'Canada', 40.00), (4, 'Skincare', 'US', 100.0... | What is the total revenue for the skincare category in Canada? | SELECT SUM(revenue) as total_revenue FROM cosmetics.sales_data WHERE category = 'Skincare' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_temperatures (spacecraft_name TEXT, temperature FLOAT, mission_date DATE); | Which spacecraft had the highest temperature on its coldest mission? | SELECT spacecraft_name, MIN(temperature) as lowest_temp, MAX(temperature) as highest_temp FROM spacecraft_temperatures GROUP BY spacecraft_name HAVING MAX(temperature) = (SELECT MAX(highest_temp) FROM (SELECT spacecraft_name, MAX(temperature) as highest_temp FROM spacecraft_temperatures GROUP BY spacecraft_name) subque... | gretelai_synthetic_text_to_sql |
CREATE TABLE Boroughs (BoroughID INT, BoroughName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, PropertyValue FLOAT, BoroughID INT); INSERT INTO Boroughs VALUES (1, 'Brooklyn'); INSERT INTO Properties VALUES (1, 2000000, 1); | What is the maximum property value for townhouses in each borough? | SELECT BoroughName, MAX(PropertyValue) FROM Properties p JOIN Boroughs b ON p.BoroughID = b.BoroughID WHERE p.PropertyType = 'Townhouse' GROUP BY BoroughName; | gretelai_synthetic_text_to_sql |
CREATE TABLE whale_sightings (id INT, sighting_date DATE); | Identify the number of whale sightings in the last 30 days | SELECT COUNT(*) FROM whale_sightings WHERE sighting_date >= DATEADD(day, -30, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT, name VARCHAR(255), location VARCHAR(255), employee_count INT); INSERT INTO manufacturers (id, name, location, employee_count) VALUES (1, 'Manufacturer X', 'Tokyo', 400); CREATE TABLE suppliers (id INT, name VARCHAR(255), location VARCHAR(255), sustainability_rating INT); INSERT INTO ... | Which manufacturers in 'Tokyo' have more than 300 employees and their corresponding supplier names? | SELECT m.name, s.name AS supplier_name FROM manufacturers m INNER JOIN suppliers s ON m.location = s.location WHERE m.employee_count > 300; | gretelai_synthetic_text_to_sql |
CREATE VIEW SmartContractsTransactions AS SELECT SmartContracts.name, Transactions.volume FROM SmartContracts JOIN Transactions ON SmartContracts.hash = Transactions.smart_contract_hash; CREATE TABLE Blockchain (id INT, name VARCHAR(20), type VARCHAR(20)); INSERT INTO Blockchain (id, name, type) VALUES (1, 'Ethereum', ... | find the total transaction volume for each smart contract in the 'SmartContractsTransactions' view, limited to the 'Ethereum' blockchain. | SELECT SmartContracts.name, SUM(Transactions.volume) FROM SmartContractsTransactions JOIN SmartContracts ON SmartContractsTransactions.name = SmartContracts.name JOIN Transactions ON SmartContractsTransactions.hash = Transactions.smart_contract_hash JOIN Blockchain ON Transactions.blockchain_id = Blockchain.id WHERE Bl... | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (drug VARCHAR(255), quarter INT, year INT, sales FLOAT); INSERT INTO sales_data (drug, quarter, year, sales) VALUES ('DrugA', 1, 2023, 12000), ('DrugA', 2, 2023, 15000), ('DrugB', 1, 2023, 8000), ('DrugB', 2, 2023, 18000), ('DrugC', 1, 2023, 10000); | Update the sales figure for DrugB in Q2 2023 to 16000. | UPDATE sales_data SET sales = 16000 WHERE drug = 'DrugB' AND quarter = 2 AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (route VARCHAR(20), trip_count INT, trip_date DATE); INSERT INTO public_transportation (route, trip_count, trip_date) VALUES ('Route A', 1200, '2023-02-01'); | What is the total number of public transportation trips taken in the city of New York, including all routes, for the month of February 2023? | SELECT SUM(trip_count) FROM public_transportation WHERE trip_date BETWEEN '2023-02-01' AND '2023-02-28'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, country TEXT, ocean TEXT); INSERT INTO fish_farms (id, name, country, ocean) VALUES (1, 'Farm A', 'Country A', 'Mediterranean'), (2, 'Farm B', 'Country B', 'Mediterranean'), (3, 'Farm C', 'Country A', 'Mediterranean'), (4, 'Farm D', 'Country C', 'Mediterranean'); | What is the number of fish farms in each country in the Mediterranean? | SELECT country, COUNT(DISTINCT id) FROM fish_farms WHERE ocean = 'Mediterranean' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthProfessional (ProfessionalID INT, Age INT, Specialty VARCHAR(50), State VARCHAR(20)); INSERT INTO MentalHealthProfessional (ProfessionalID, Age, Specialty, State) VALUES (1, 50, 'Psychologist', 'Illinois'); INSERT INTO MentalHealthProfessional (ProfessionalID, Age, Specialty, State) VALUES (2, ... | What is the minimum age of a mental health professional in Illinois? | SELECT MIN(Age) FROM MentalHealthProfessional WHERE State = 'Illinois'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY, name VARCHAR(255), compliance_status VARCHAR(10), last_update_date DATETIME); INSERT INTO smart_contracts (contract_id, name, compliance_status, last_update_date) VALUES (1, 'Contract1', 'Compliant', '2022-01-10 15:00:00'), (2, 'Contract2', 'Non-compliant', '20... | Delete any smart contract that is not compliant with the regulatory framework and is older than 90 days. | DELETE FROM smart_contracts WHERE compliance_status = 'Non-compliant' AND last_update_date < DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id INT, name VARCHAR(50), type VARCHAR(50), year_built INT); | Alter the "vessels" table by adding a new column named "flag_state" of type VARCHAR(3) to record the vessel's flag state. | ALTER TABLE vessels ADD COLUMN flag_state VARCHAR(3); | gretelai_synthetic_text_to_sql |
CREATE TABLE VeganEats (location VARCHAR(20), item_type VARCHAR(15), cost DECIMAL(5,2)); INSERT INTO VeganEats (location, item_type, cost) VALUES ('GreenLeaf', 'vegan', 5.50), ('GreenLeaf', 'vegan', 4.75), ('Sprout', 'vegan', 6.25), ('EcoEats', 'vegan', 6.50); | Find the total inventory cost for 'vegan' dishes across all restaurants and cafes. | SELECT SUM(cost) FROM VeganEats WHERE item_type = 'vegan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_name VARCHAR(255), arrival_date DATE); INSERT INTO port VALUES ('Los Angeles', '2020-01-03'); CREATE TABLE vessel (vessel_name VARCHAR(255), vessel_type VARCHAR(255)); | What are the details of vessels that arrived at the port of Los Angeles in January 2020? | SELECT v.vessel_name, v.vessel_type, p.port_name, p.arrival_date FROM vessel v INNER JOIN port p ON v.port_id = p.id WHERE p.arrival_date BETWEEN '2020-01-01' AND '2020-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseContracts (id INT, contract_date DATE, company_name VARCHAR(50), contract_value FLOAT); INSERT INTO DefenseContracts (id, contract_date, company_name, contract_value) VALUES (1, '2021-01-01', 'Northrop Grumman', 15000000); INSERT INTO DefenseContracts (id, contract_date, company_name, contract_value... | Show total defense contracts value awarded per quarter | SELECT DATE_FORMAT(contract_date, '%Y-%m'), SUM(contract_value) FROM DefenseContracts GROUP BY DATE_FORMAT(contract_date, '%Y-%m') ORDER BY DATE_FORMAT(contract_date, '%Y-%m'); | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_wellbeing (athlete_id INT, program_name VARCHAR(100), start_date DATE, end_date DATE, category VARCHAR(50)); | Create a table named 'athlete_wellbeing' to store athlete wellbeing programs data | CREATE TABLE athlete_wellbeing (athlete_id INT, program_name VARCHAR(100), start_date DATE, end_date DATE, category VARCHAR(50)); | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), price INT, certification_type VARCHAR(255)); INSERT INTO properties (id, address, city, state, price, certification_type) VALUES (6, '654 Eco St', 'EcoCity', 'CO', 725000, NULL); | What is the address, city, and state of properties without green certifications in 'EcoCity' priced above 700000? | SELECT DISTINCT properties.address, properties.city, properties.state FROM properties WHERE properties.city = 'EcoCity' AND properties.price > 700000 AND properties.certification_type IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), artist_genre VARCHAR(50), artist_country VARCHAR(50)); INSERT INTO artists (artist_id, artist_name, artist_genre, artist_country) VALUES (1, 'Taylor Swift', 'Pop', 'United States'), (2, 'Drake', 'Hip-Hop', 'Canada'), (3, 'BTS', 'K-Pop', 'South Korea'); CREA... | Show the top 5 artists by total streams, including their genre and origin country. | SELECT a.artist_name, a.artist_genre, a.artist_country, SUM(s.song_id) AS total_streams FROM artists a INNER JOIN artist_streams s ON a.artist_id = s.artist_id GROUP BY a.artist_id ORDER BY total_streams DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_mobility (city VARCHAR(50), mode VARCHAR(50), PRIMARY KEY (city, mode)); | Insert a new record into the 'multimodal_mobility' table with the following values: 'Seoul', 'Transit App' | INSERT INTO multimodal_mobility (city, mode) VALUES ('Seoul', 'Transit App'); | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (id INT, date DATE, source TEXT, destination TEXT, action TEXT, actor TEXT);INSERT INTO incidents (id, date, source, destination, action, actor) VALUES (1, '2021-01-01', '10.0.0.1', '8.8.8.8', 'sent', 'user'); | Find the most common actions taken by a specific actor. | SELECT actor, action, COUNT(*) as count, RANK() OVER (PARTITION BY actor ORDER BY count DESC) as rank FROM incidents GROUP BY actor, action ORDER BY actor, rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness_papers (year INT, paper_title VARCHAR(255), author_name VARCHAR(255), num_citations INT); INSERT INTO algorithmic_fairness_papers (year, paper_title, author_name, num_citations) VALUES ('2018', 'Algorithmic Fairness: A Review', 'Alice Johnson', '50'); | What is the average number of citations for algorithmic fairness papers published in 2018 and 2019? | SELECT AVG(num_citations) as avg_citations FROM algorithmic_fairness_papers WHERE year IN (2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_management (id INT, operation_date DATE, warehouse_id INT, operation_type VARCHAR(50), units INT); INSERT INTO warehouse_management (id, operation_date, warehouse_id, operation_type, units) VALUES [(1, '2022-01-01', 1, 'receiving', 200), (2, '2022-01-02', 1, 'putaway', 150), (3, '2022-01-03', 2, ... | How many warehouse operations were performed in Q1 2022 for each warehouse? | SELECT DATE_FORMAT(operation_date, '%Y-%m') AS quarter, warehouse_id, SUM(units) AS total_units FROM warehouse_management WHERE operation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY quarter, warehouse_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (country VARCHAR(255), year INT, initiative_id INT); INSERT INTO circular_economy_initiatives (country, year, initiative_id) VALUES ('Germany', 2015, 1), ('Germany', 2016, 2), ('Germany', 2017, 3), ('France', 2016, 1), ('France', 2017, 2), ('France', 2018, 3), ('Italy', 2017, 1... | How many circular economy initiatives were launched by country from 2015 to 2020? | SELECT country, COUNT(DISTINCT initiative_id) FROM circular_economy_initiatives WHERE year BETWEEN 2015 AND 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE gas_production (id INT, location VARCHAR(20), production_date DATE, gas_production INT); | What is the maximum gas production per well in the Arctic in 2018? | SELECT MAX(gas_production) FROM gas_production WHERE location LIKE 'Arctic%' AND production_date = '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_ticket_sales (id INT, team VARCHAR(50), sale_month DATE, quantity INT); INSERT INTO monthly_ticket_sales (id, team, sale_month, quantity) VALUES (1, 'TeamA', '2022-01-01', 1000), (2, 'TeamB', '2022-01-01', 1500), (3, 'TeamA', '2022-02-01', 1200), (4, 'TeamB', '2022-02-01', 1800); | What is the total number of tickets sold by month for each team? | SELECT EXTRACT(MONTH FROM sale_month) as month, team, SUM(quantity) as total_sold FROM monthly_ticket_sales GROUP BY month, team; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(50)); CREATE TABLE immunizations (immunization_id INT, patient_id INT, immunization_date DATE, clinic_id INT); | List the monthly immunization rates for children under 5 in rural health clinic Z in 2021? | SELECT MONTH(immunization_date) as month, COUNT(DISTINCT patient_id) * 100.0 / (SELECT COUNT(DISTINCT patient_id) FROM patients WHERE age < 5) as immunization_rate FROM immunizations INNER JOIN clinics ON immunizations.clinic_id = clinics.clinic_id WHERE clinics.clinic_name = 'rural health clinic Z' AND YEAR(immunizati... | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50)); CREATE TABLE ArtTypes (ArtTypeID INT, ArtType VARCHAR(50)); CREATE TABLE ArtCountry (ArtID INT, ArtTypeID INT, CountryID INT, Popularity INT); INSERT INTO Countries VALUES (1, 'CountryA'), (2, 'CountryB'), (3, 'CountryC'); INSERT INTO ArtTypes VALUES (1, ... | Which traditional art form is the most popular in each country? | SELECT C.CountryName, A.ArtType, MAX(AC.Popularity) AS MaxPopularity FROM Countries C JOIN ArtCountry AC ON C.CountryID = AC.CountryID JOIN ArtTypes A ON AC.ArtTypeID = A.ArtTypeID GROUP BY C.CountryName, A.ArtType; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (site_id INT, name TEXT, location TEXT); INSERT INTO cultural_sites (site_id, name, location) VALUES (1, 'Meiji Shrine', 'Tokyo'); INSERT INTO cultural_sites (site_id, name, location) VALUES (2, 'Todai-ji Temple', 'Nara'); | Insert a new cultural heritage site in Kyoto, Japan named "Kiyomizu-dera" with an ID of 3 | INSERT INTO cultural_sites (site_id, name, location) VALUES (3, 'Kiyomizu-dera', 'Kyoto'); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency (state VARCHAR(50), score FLOAT); INSERT INTO energy_efficiency (state, score) VALUES ('State A', 80), ('State B', 85), ('State C', 90), ('State D', 75); | What is the energy efficiency score for each state, ranked from highest to lowest? | SELECT state, score, ROW_NUMBER() OVER (ORDER BY score DESC) as rank FROM energy_efficiency; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, avg_depth REAL); INSERT INTO marine_protected_areas (area_name, avg_depth) VALUES ('Galapagos Islands', 2000.0), ('Great Barrier Reef', 1500.0); | Add a new marine protected area to the database. | INSERT INTO marine_protected_areas (area_name, avg_depth) VALUES ('Palau', 2500.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE airline_passengers (airline VARCHAR(50), country VARCHAR(50), passengers INT, year INT); INSERT INTO airline_passengers (airline, country, passengers, year) VALUES ('IndiGo', 'India', 120000, 2019), ('SpiceJet', 'India', 150000, 2019); | What is the maximum number of passengers carried by commercial airlines in India in 2019? | SELECT MAX(passengers) FROM airline_passengers WHERE country = 'India' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(50), country VARCHAR(50), launch_date DATE); CREATE TABLE medical (id INT, spacecraft_id INT, medical_condition VARCHAR(50), medical_date DATE); INSERT INTO spacecraft (id, name, country, launch_date) VALUES (1, 'Vostok 1', 'Russia', '1961-04-12'); INSERT INTO spacecraft (i... | Which country owns the spacecraft with the most medical incidents? | SELECT country, COUNT(*) as medical_counts FROM medical JOIN spacecraft ON medical.spacecraft_id = spacecraft.id GROUP BY country ORDER BY medical_counts DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE creators (id INT, name VARCHAR(100), community VARCHAR(50)); INSERT INTO creators (id, name, community) VALUES (1, 'Alice', 'Female'), (2, 'David', 'LGBTQ+'); CREATE TABLE content (id INT, creator_id INT, type VARCHAR(50), title VARCHAR(100)); INSERT INTO content (id, creator_id, type, title) VALUES (1, 1,... | What is the total number of articles and videos produced by creators from underrepresented communities? | SELECT SUM(num_articles + num_videos) FROM (SELECT c.community, COUNT(CASE WHEN con.type = 'article' THEN 1 END) AS num_articles, COUNT(CASE WHEN con.type = 'video' THEN 1 END) AS num_videos FROM creators c JOIN content con ON c.id = con.creator_id WHERE c.community IN ('underrepresented_group_1', 'underrepresented_gro... | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, industry TEXT, founding_date DATE, founders TEXT, employees INT); INSERT INTO startups (id, name, industry, founding_date, founders, employees) VALUES (1, 'EcomPioneers', 'E-commerce', '2021-01-01', 'Immigrants', 10); | What is the minimum number of employees for startups founded by immigrants in the e-commerce sector? | SELECT MIN(employees) FROM startups WHERE founders = 'Immigrants' AND industry = 'E-commerce'; | gretelai_synthetic_text_to_sql |
CREATE TABLE boston_medical_emergencies (id INT, response_time INT); INSERT INTO boston_medical_emergencies (id, response_time) VALUES (1, 8); | Update the response time for medical emergencies in the city of Boston to 7 minutes. | UPDATE boston_medical_emergencies SET response_time = 7 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE PatientConditions (PatientID int, ConditionID int, Gender varchar(10), Age int); INSERT INTO PatientConditions (PatientID, ConditionID, Gender, Age) VALUES (1, 1, 'Male', 30), (2, 2, 'Female', 35); | What is the average age of male and female patients for each condition? | SELECT Conditions.Condition, Gender, AVG(PatientConditions.Age) FROM PatientConditions JOIN Conditions ON PatientConditions.ConditionID = Conditions.ConditionID GROUP BY Conditions.Condition, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT PRIMARY KEY, vendor VARCHAR(50), quantity INT, species VARCHAR(50), price DECIMAL(5,2)); INSERT INTO sales (id, vendor, quantity, species, price) VALUES (1, 'Seafood Haven', 20, 'Salmon', 12.99), (2, 'Sea Bounty', 30, 'Tilapia', 9.49), (3, 'Sea Bounty', 15, 'Cod', 14.50); | Calculate the average price of 'Tilapia' in the 'sales' table. | SELECT AVG(price) FROM sales WHERE species = 'Tilapia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditures (expenditure_id INT, drug_id INT, expenditure_type TEXT, expenditure_amount DECIMAL(10, 2), year INT); INSERT INTO rd_expenditures (expenditure_id, drug_id, expenditure_type, expenditure_amount, year) VALUES (1, 1, 'Research', 12000.00, 2019), (2, 1, 'Development', 15000.00, 2020), (3, 2, '... | What is the total R&D expenditure for each drug in the rd_expenditures table, grouped by drug name? | SELECT drug_id, SUM(expenditure_amount) AS total_rd_expenditure FROM rd_expenditures GROUP BY drug_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE GroceryStores (id INT, name VARCHAR(50)); CREATE TABLE FoodItems (id INT, name VARCHAR(50), caloricContent FLOAT); | What is the maximum caloric content of any food item sold by local grocery stores? | SELECT MAX(caloricContent) FROM FoodItems INNER JOIN GroceryStores ON FoodItems.name = GroceryStores.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE fda_approvals_infectious_diseases (approval_id INT, drug_name VARCHAR(255), approval_date DATE, therapeutic_area VARCHAR(255)); INSERT INTO fda_approvals_infectious_diseases (approval_id, drug_name, approval_date, therapeutic_area) VALUES (1, 'DrugS', '2022-01-01', 'Infectious Diseases'), (2, 'DrugT', '202... | Find the number of approvals received for each drug, ranked from the most approvals to the least, by the FDA for infectious diseases? | SELECT drug_name, COUNT(*) as num_of_approvals FROM fda_approvals_infectious_diseases WHERE therapeutic_area = 'Infectious Diseases' GROUP BY drug_name ORDER BY num_of_approvals DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist_songs (song_id INT, artist VARCHAR(50), streams INT); INSERT INTO artist_songs (song_id, artist, streams) VALUES (1, 'ArtistA', 20000), (1, 'ArtistB', 15000), (2, 'ArtistA', 30000), (3, 'ArtistC', 10000), (3, 'ArtistA', 25000), (4, 'ArtistB', 12000); | What is the most popular song (by number of streams) for each artist? | SELECT song_id, artist, MAX(streams) as max_streams FROM artist_songs GROUP BY artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicEvents (EventID INT, EventName TEXT, EventCity TEXT, EventState TEXT); INSERT INTO PublicEvents (EventID, EventName, EventCity, EventState) VALUES (1, 'Town Hall', 'New York', 'NY'), (2, 'Community Meeting', 'Los Angeles', 'CA'); | List the number of public events held in each city and state? | SELECT EventState, EventCity, COUNT(*) FROM PublicEvents GROUP BY EventState, EventCity; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, Name VARCHAR(50), Country VARCHAR(50), StartDate DATE, EndDate DATE, Participants INT); INSERT INTO Events (EventID, Name, Country, StartDate, EndDate, Participants) VALUES (1, 'Evo', 'USA', '2022-08-06', '2022-08-07', 1000); INSERT INTO Events (EventID, Name, Country, StartDate, EndDa... | Which esports event had the most international participants in 2022? | SELECT Name, Participants FROM Events WHERE YEAR(StartDate) = 2022 GROUP BY Name ORDER BY Participants DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, game_name TEXT, game_date DATE, winner_id INT, winner_name TEXT, winner_country TEXT); INSERT INTO games (game_id, game_name, game_date, winner_id, winner_name, winner_country) VALUES (1, 'Game1', '2022-01-01', 4, 'Han', 'South Korea'); INSERT INTO games (game_id, game_name, game_date, ... | How many games were won by players from Asia in the last week? | SELECT COUNT(*) FROM games WHERE winner_country IN ('South Korea', 'China', 'Japan') AND game_date >= DATEADD(day, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE VolunteerHours (VolunteerID INT, Hours DECIMAL(5,2), Country TEXT, Year INT); INSERT INTO VolunteerHours (VolunteerID, Hours, Country, Year) VALUES (1, 25.50, 'Mexico', 2020), (2, 30.00, 'USA', 2019); | What is the total number of hours volunteered by volunteers from Latin America in 2020? | SELECT SUM(Hours) FROM VolunteerHours WHERE Country LIKE 'Lat%' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_id INT, city_name VARCHAR(50));CREATE TABLE users (user_id INT, city_id INT, user_join_date DATE);CREATE TABLE clicks (click_id INT, user_id INT, ad_type VARCHAR(50), click_date DATE);INSERT INTO cities (city_id, city_name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houst... | What are the top 5 cities with the most users who clicked on a sports ad in the past month? | SELECT c.city_name, COUNT(DISTINCT u.user_id) as total_users FROM cities c JOIN users u ON c.city_id = u.city_id JOIN clicks cl ON u.user_id = cl.user_id WHERE cl.ad_type = 'sports' AND cl.click_date >= DATEADD(month, -1, GETDATE()) GROUP BY c.city_name ORDER BY total_users DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE IncidentResponse (region VARCHAR(50), incidentDate DATE); INSERT INTO IncidentResponse (region, incidentDate) VALUES ('EMEA', '2022-01-05'), ('APAC', '2022-01-12'), ('AMER', '2022-01-20'); | What is the earliest incident date in the IncidentResponse table? | SELECT MIN(incidentDate) FROM IncidentResponse; | gretelai_synthetic_text_to_sql |
CREATE TABLE foia_requests (request_id INT, requester_name VARCHAR(100), request_date DATE, request_type VARCHAR(50), status VARCHAR(50)); | Update the status of FOIA request with ID '98765' to 'Completed'. | UPDATE foia_requests SET status = 'Completed' WHERE request_id = 98765; | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS animal_region (animal_id INT, animal_name VARCHAR(50), region VARCHAR(10)); INSERT INTO animal_region (animal_id, animal_name, region) VALUES (1, 'Tiger', 'Asia'); INSERT INTO animal_region (animal_id, animal_name, region) VALUES (2, 'Lion', 'Africa'); INSERT INTO animal_region (animal_id, an... | Find the animals that are present in both the Asian and African regions. | SELECT animal_name FROM animal_region WHERE region = 'Asia' INTERSECT SELECT animal_name FROM animal_region WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteAnalysis (SiteName VARCHAR(50), AnalysisDate DATE); INSERT INTO SiteAnalysis (SiteName, AnalysisDate) VALUES ('Site1', '2022-01-01'), ('Site2', '2022-02-01'), ('Site3', '2021-12-01'); | Find the top 2 sites with the highest number of artifacts analyzed in the last 6 months. | SELECT SiteName FROM (SELECT SiteName, COUNT(*) AS AnalysisCount, RANK() OVER (ORDER BY COUNT(*) DESC) AS SiteRank FROM SiteAnalysis WHERE AnalysisDate >= DATEADD(month, -6, GETDATE()) GROUP BY SiteName) AS Subquery WHERE SiteRank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE dept_policy_impact (dept VARCHAR(50), impact INT); INSERT INTO dept_policy_impact (dept, impact) VALUES ('Infrastructure', 5000), ('Education', 3000), ('Health', 4500); | Which departments have a policy impact above 4000? | SELECT dept FROM dept_policy_impact WHERE impact > 4000; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (match_id INT, home_team_id INT, away_team_id INT, match_date DATE, home_team_won BOOLEAN); | How many matches were won by home teams in the last season? | SELECT COUNT(*) as num_wins FROM matches WHERE home_team_won = TRUE AND match_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (id INT, name VARCHAR(50), budget FLOAT, start_date DATE, end_date DATE); INSERT INTO carbon_offset_programs (id, name, budget, start_date, end_date) VALUES (1, 'Program 1', 12000000, '2020-01-01', '2025-12-31'); INSERT INTO carbon_offset_programs (id, name, budget, start_date, end_d... | Which carbon offset programs have a budget greater than $10 million in the carbon_offset schema? | SELECT name FROM carbon_offset.carbon_offset_programs WHERE budget > 10000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation_rural (mode VARCHAR(20), daily_ridership INT); INSERT INTO public_transportation_rural (mode, daily_ridership) VALUES ('bus', 500), ('train', 800), ('light_rail', 200); | What is the average daily ridership for public transportation in rural areas? | SELECT AVG(daily_ridership) FROM public_transportation_rural WHERE mode IN ('bus', 'train', 'light_rail'); | gretelai_synthetic_text_to_sql |
CREATE TABLE user_bookings (user_id INT, country TEXT, num_virtual_tours INT); INSERT INTO user_bookings (user_id, country, num_virtual_tours) VALUES (1, 'France', 2), (2, 'Germany', 3), (3, 'Spain', 1), (4, 'Italy', 4), (5, 'France', 3); CREATE TABLE countries (country TEXT, continent TEXT); INSERT INTO countries (cou... | Find the average number of virtual tour bookings per user in 'Europe'? | SELECT AVG(num_virtual_tours) FROM user_bookings WHERE country IN (SELECT country FROM countries WHERE continent = 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE patient (patient_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patient (patient_id, name, age, gender, condition) VALUES (1, 'John Doe', 27, 'Male', 'Anxiety'), (2, 'Jane Smith', 32, 'Female', 'Depression'), (3, 'Alice Johnson', 19, 'Female', 'Anxiety'); CREATE ... | What is the most common mental health condition among patients aged 18-35? | SELECT condition, COUNT(patient_id) AS num_patients FROM patient JOIN condition_mapping ON patient.condition = condition_mapping.condition WHERE age BETWEEN 18 AND 35 GROUP BY condition ORDER BY num_patients DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID int, ClientID int, Outcome varchar(50)); CREATE TABLE Clients (ClientID int, Community varchar(50)); CREATE TABLE Attorneys (AttorneyID int, AttorneyName varchar(50)); INSERT INTO Cases VALUES (1, 1, 'Won'), (2, 2, 'Lost'), (3, 3, 'Settled'); INSERT INTO Clients VALUES (1, 'Minority'), (2, 'L... | List all cases and their outcomes, along with the name of the attorney who handled the case, for cases with clients from underrepresented communities. | SELECT Cases.CaseID, Cases.Outcome, Attorneys.AttorneyName FROM Cases JOIN Clients ON Cases.ClientID = Clients.ClientID JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Clients.Community IN ('Minority', 'LGBTQ+', 'Veteran'); | 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.