context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE hotel_ratings (hotel_id INT, hotel_name TEXT, country TEXT, region TEXT, stars FLOAT); INSERT INTO hotel_ratings (hotel_id, hotel_name, country, region, stars) VALUES (1, 'Hotel A', 'Australia', 'Asia Pacific', 4.5), (2, 'Hotel B', 'Japan', 'Asia Pacific', 5.0), (3, 'Hotel C', 'New Zealand', 'Asia Pacific'... | Find the top 3 countries with the highest average hotel star rating in the Asia Pacific region. | SELECT country, AVG(stars) as avg_stars FROM hotel_ratings WHERE region = 'Asia Pacific' GROUP BY country ORDER BY avg_stars DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Research (id INT PRIMARY KEY, title VARCHAR(50), category VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE Publication (id INT PRIMARY KEY, research_id INT, title VARCHAR(50), publication_date DATE, FOREIGN KEY (research_id) REFERENCES Research(id)); | List all research in the astrophysics category with associated publications. | SELECT Research.title, Publication.title, Publication.publication_date FROM Research INNER JOIN Publication ON Research.id = Publication.research_id WHERE Research.category = 'Astrophysics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE specialists (id INT, name TEXT, specialty TEXT, facility_id INT); INSERT INTO specialists (id, name, specialty, facility_id) VALUES (1, 'Dr. Smith', 'Cardiology', 101); CREATE TABLE facilities (id INT, name TEXT, location TEXT, capacity INT); | How many specialists are available in rural healthcare facilities in California, excluding facilities with a capacity below 50? | SELECT COUNT(*) as num_specialists FROM specialists JOIN facilities ON specialists.facility_id = facilities.id WHERE facilities.location LIKE '%California%' AND facilities.capacity >= 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, employee_id INT, salary INT, salary_date DATE, department VARCHAR(255)); INSERT INTO salaries (id, employee_id, salary, salary_date, department) VALUES (1, 201, 50000, '2020-01-01', 'Sales'); INSERT INTO salaries (id, employee_id, salary, salary_date, department) VALUES (2, 202, 60000, '2... | What is the total salary paid to the 'Sales' department in 2020 | SELECT SUM(salary) FROM salaries JOIN hiring ON salaries.employee_id = hiring.employee_id WHERE department = 'Sales' AND YEAR(salary_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, province VARCHAR(50), revenue FLOAT); | List all concerts in Canada that had a higher revenue than the maximum revenue in Quebec. | SELECT * FROM Concerts WHERE revenue > (SELECT MAX(revenue) FROM Concerts WHERE province = 'Quebec') AND province = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_productivity (operation_id INT, region VARCHAR(20), productivity FLOAT); INSERT INTO mining_productivity (operation_id, region, productivity) VALUES (1001, 'South America', 2.5), (1002, 'South America', 3.0), (1003, 'South America', 2.8), (1004, 'South America', 3.2), (1005, 'South America', 2.2), (... | Identify mining operations with below-average labor productivity in the South American region. | SELECT * FROM mining_productivity WHERE region = 'South America' AND productivity < (SELECT AVG(productivity) FROM mining_productivity WHERE region = 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE genres (genre_id INT, genre VARCHAR(255)); CREATE TABLE songs (song_id INT, title VARCHAR(255), genre_id INT, release_date DATE); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, stream_date DATE, revenue DECIMAL(10,2)); | Calculate the average number of streams per user for each genre. | SELECT g.genre, AVG(st.stream_count) as avg_streams_per_user FROM genres g JOIN (SELECT song_id, user_id, COUNT(*) as stream_count FROM streams GROUP BY song_id, user_id) st ON g.genre_id = st.song_id GROUP BY g.genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_outlets (id INT, name VARCHAR(255), location VARCHAR(64), is_local BOOLEAN); CREATE TABLE articles (id INT, title VARCHAR(255), publication_language VARCHAR(64), publication_date DATE, outlet_id INT, PRIMARY KEY (id), FOREIGN KEY (outlet_id) REFERENCES news_outlets(id)); INSERT INTO news_outlets (id, ... | How many articles were published in Spanish by local news outlets in Spain in 2021? | SELECT COUNT(*) FROM articles INNER JOIN news_outlets ON articles.outlet_id = news_outlets.id WHERE news_outlets.location = 'Spain' AND news_outlets.is_local = true AND articles.publication_language = 'Spanish' AND EXTRACT(YEAR FROM articles.publication_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (satellite_id INT, satellite_name VARCHAR(100), country VARCHAR(50), launch_date DATE); INSERT INTO satellites (satellite_id, satellite_name, country, launch_date) VALUES (1, 'Sentinel-1A', 'France', '2012-04-03'); INSERT INTO satellites (satellite_id, satellite_name, country, launch_date) VALUE... | How many satellites were launched by each country in the 21st century? | SELECT country, COUNT(*) as launch_count FROM satellites WHERE YEAR(launch_date) >= 2000 GROUP BY country; UPDATE countries SET launch_count = (SELECT COUNT(*) FROM satellites WHERE YEAR(launch_date) >= 2000 AND satellites.country = countries.country_name) WHERE TRUE; SELECT country_name, launch_count FROM countries; | gretelai_synthetic_text_to_sql |
CREATE TABLE CaseOutcomes (CaseID INT, OutcomeDate DATE, Outcome VARCHAR(20)); INSERT INTO CaseOutcomes (CaseID, OutcomeDate, Outcome) VALUES (1, '2022-01-15', 'Conviction'), (2, '2022-02-20', 'Dismissal'), (3, '2022-03-05', 'Conviction'), (4, '2022-04-12', 'Dismissal'); | What is the percentage of cases that resulted in a conviction, by month? | SELECT DATEPART(month, OutcomeDate) AS Month, COUNT(*) FILTER (WHERE Outcome = 'Conviction') * 100.0 / COUNT(*) AS Percentage FROM CaseOutcomes WHERE OutcomeDate IS NOT NULL GROUP BY DATEPART(month, OutcomeDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE region (id INT, name VARCHAR(255)); CREATE TABLE volunteer (id INT, region_id INT, program_id INT, name VARCHAR(255), last_volunteered DATE); INSERT INTO region (id, name) VALUES (1, 'Asia-Pacific'), (2, 'Americas'), (3, 'Europe'); INSERT INTO volunteer (id, region_id, program_id, name, last_volunteered) V... | What is the total number of volunteers from the 'Asia-Pacific' region who volunteered in the last month for any program? | SELECT COUNT(*) as total_volunteers FROM volunteer WHERE region_id = (SELECT id FROM region WHERE name = 'Asia-Pacific') AND last_volunteered >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(20), IdentifiesAsLGBTQ BOOLEAN, Salary DECIMAL(10,2), YearsWithCompany INT); INSERT INTO Employees (EmployeeID, Department, Gender, IdentifiesAsLGBTQ, Salary, YearsWithCompany) VALUES (1, 'Finance', 'Male', true, 95000.00, 4), (2, 'IT', 'Fem... | What is the minimum salary for employees in the Finance department who identify as LGBTQ+ and have been with the company for more than 3 years? | SELECT MIN(Salary) FROM Employees WHERE Department = 'Finance' AND IdentifiesAsLGBTQ = true AND YearsWithCompany > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE comments (id INT, post_id INT, user_id INT, text TEXT, created_date DATE); INSERT INTO comments (id, post_id, user_id, text, created_date) VALUES (1, 1, 3, 'Excellent post!', '2022-10-01'); | What is the name and text of the most recent comment made by a user from India? | SELECT c.text, c.user_id FROM comments c WHERE c.country = 'India' AND c.created_date = (SELECT MAX(created_date) FROM comments WHERE country = 'India') | gretelai_synthetic_text_to_sql |
CREATE TABLE Animal_Sightings (id INT, animal VARCHAR(10), sighting_date DATE, location VARCHAR(20)); | Insert new records of arctic fox sightings in the 'Animal_Sightings' table, ensuring there are no duplicates based on date and location. | INSERT INTO Animal_Sightings (id, animal, sighting_date, location) SELECT 6, 'Arctic Fox', '2023-03-01', 'Tundra' FROM dual WHERE NOT EXISTS (SELECT 1 FROM Animal_Sightings WHERE animal = 'Arctic Fox' AND sighting_date = '2023-03-01' AND location = 'Tundra'); | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePrograms(ProgramID INT, ProgramName VARCHAR(100), Region VARCHAR(50), Budget DECIMAL(10,2)); CREATE TABLE Allocations(ProgramID INT, AllocationID INT, AllocationAmount DECIMAL(10,2)); | What is the total budget allocated for language preservation programs in Africa, and which programs have received more than 75% of the allocated budget? | SELECT ProgramName, SUM(AllocationAmount) as AllocatedBudget FROM Allocations INNER JOIN LanguagePrograms ON Allocations.ProgramID = LanguagePrograms.ProgramID WHERE Region = 'Africa' GROUP BY ProgramName HAVING SUM(AllocationAmount) > (SELECT Budget FROM LanguagePrograms WHERE ProgramName = Programs.ProgramName) * 0.7... | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditure(trial_id TEXT, country TEXT, year INT, amount FLOAT); INSERT INTO rd_expenditure (trial_id, country, year, amount) VALUES ('Trial1', 'CountryX', 2021, 2500000), ('Trial2', 'CountryY', 2020, 3000000); | Find the average R&D expenditure for trials in 'CountryX' in 2021? | SELECT AVG(amount) FROM rd_expenditure WHERE country = 'CountryX' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE housing_affordability (id INT, city VARCHAR(20), score FLOAT); INSERT INTO housing_affordability (id, city, score) VALUES (1, 'SF', 45.2), (2, 'NYC', 38.6), (3, 'LA', 51.1), (4, 'SF', 47.9), (5, 'NYC', 39.8); | What is the maximum housing affordability score for each city? | SELECT city, MAX(score) as max_score FROM housing_affordability GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_metrics (id INT, metric TEXT); INSERT INTO diversity_metrics (id, metric) VALUES (1, 'Gender'); INSERT INTO diversity_metrics (id, metric) VALUES (2, 'Race'); | Delete the diversity metric 'Age' from the database. | DELETE FROM diversity_metrics WHERE metric = 'Age'; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_water_consumption (user_category VARCHAR(20), consumption FLOAT, consumption_date DATE); INSERT INTO daily_water_consumption (user_category, consumption, consumption_date) VALUES ('residential', 15000, '2022-04-01'), ('commercial', 25000, '2022-04-01'), ('residential', 16000, '2022-04-02'), ('commerc... | What is the average water consumption per day for the 'commercial' category in the last 30 days? | SELECT AVG(consumption) FROM daily_water_consumption WHERE user_category = 'commercial' AND consumption_date >= DATEADD(day, -30, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (id INT, name VARCHAR(50), country VARCHAR(50), is_inscribed BOOLEAN); CREATE TABLE UNESCO_Committee (id INT, country VARCHAR(50)); | What is the total number of heritage sites for each UNESCO World Heritage Committee member, excluding those that are not yet inscribed? | SELECT C.country, COUNT(H.id) as total_sites FROM HeritageSites H INNER JOIN UNESCO_Committee C ON H.country = C.country WHERE H.is_inscribed GROUP BY C.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_projects (id INT, beneficiary_id INT, country VARCHAR(50), project VARCHAR(50), expenditure DECIMAL(10,2), start_date DATE, end_date DATE); INSERT INTO rural_projects (id, beneficiary_id, country, project, expenditure, start_date, end_date) VALUES (1, 3001, 'India', 'Irrigation System', 15000.00, '20... | Who are the top 3 beneficiaries of rural infrastructure projects in India by total expenditure? | SELECT beneficiary_id, SUM(expenditure) FROM rural_projects WHERE country = 'India' GROUP BY beneficiary_id ORDER BY SUM(expenditure) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS transportation; CREATE TABLE transportation.projects (id INT, name VARCHAR(100), start_date DATE); INSERT INTO transportation.projects (id, name, start_date) VALUES (1, 'Highway Repaving', '2020-04-01'), (2, 'Traffic Signal Installation', '2019-10-15'), (3, 'Pedestrian Bridge Construction', ... | List the names and start dates of all projects in the 'transportation' schema, ordered by start date | SELECT name, start_date FROM transportation.projects ORDER BY start_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE smoking_rates (country VARCHAR(20), percentage_smokers DECIMAL(5,2)); INSERT INTO smoking_rates (country, percentage_smokers) VALUES ('China', 30.0), ('Indonesia', 25.0); | What is the percentage of smokers in China and Indonesia? | SELECT AVG(percentage_smokers) FROM smoking_rates WHERE country IN ('China', 'Indonesia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_unemployment (state VARCHAR(2), unemployment_date DATE, unemployment_rate FLOAT); INSERT INTO veteran_unemployment (state, unemployment_date, unemployment_rate) VALUES ('CA', '2022-01-01', 0.05), ('NY', '2022-01-01', 0.06); | Calculate the veteran unemployment rate by state for the last quarter | SELECT state, AVG(unemployment_rate) AS avg_unemployment_rate FROM veteran_unemployment WHERE unemployment_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_schools (id INT, name TEXT, location TEXT, num_students INT, avg_teacher_age FLOAT); INSERT INTO public_schools (id, name, location, num_students, avg_teacher_age) VALUES (1, 'School 1', 'TX', 500, 48.3), (2, 'School 2', 'TX', 600, 42.2), (3, 'School 3', 'TX', 700, 46.1), (4, 'School 4', 'TX', 800, ... | How many public schools are there in Texas with an average teacher age above 45? | SELECT COUNT(*) FROM public_schools WHERE location = 'TX' AND avg_teacher_age > 45; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, client_name VARCHAR(50), country VARCHAR(50), organization VARCHAR(50), amount DECIMAL(10,2), date DATE); INSERT INTO donations (id, client_name, country, organization, amount, date) VALUES (1, 'Zainab', 'Nigeria', 'charity1', 800, '2022-01-01'); INSERT INTO donations (id, client_name, c... | Which clients have made donations of over 700 in Nigeria and Kenya? | SELECT client_name, country, amount FROM donations WHERE country IN ('Nigeria', 'Kenya') AND amount > 700; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_streaming (user_id INT, song_id INT, duration FLOAT, date DATE); | Identify users who streamed the same song on consecutive days in 'music_streaming' table? | SELECT a.user_id, a.song_id, a.date as first_date, b.date as second_date FROM music_streaming a INNER JOIN music_streaming b ON a.user_id = b.user_id AND a.song_id = b.song_id AND b.date = DATE_ADD(a.date, INTERVAL 1 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_domains (id INT, domain VARCHAR(255), dataset VARCHAR(255), model VARCHAR(255)); INSERT INTO ai_domains (id, domain, dataset, model) VALUES (1, 'AI in Healthcare', 'Medical Images', 'Deep Learning Model'), (2, 'AI in Healthcare', 'Genomic Data', 'Random Forest Model'), (3, 'AI in Finance', 'Stock Prices... | Identify the number of models and datasets in each AI domain (AI in Healthcare, AI in Finance, and AI in Agriculture). | SELECT domain, COUNT(DISTINCT dataset) as num_datasets, COUNT(DISTINCT model) as num_models FROM ai_domains GROUP BY domain; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (strain_id INT, name VARCHAR(255), price FLOAT); INSERT INTO strains (strain_id, name, price) VALUES (1, 'Blue Dream', 10); CREATE TABLE inventory (inventory_id INT, strain_id INT, dispensary_id INT, quantity INT); INSERT INTO inventory (inventory_id, strain_id, dispensary_id) VALUES (1, 1, 2); CRE... | Update the price of 'Blue Dream' strain to $12 per gram in 'Green Earth' dispensary. | UPDATE inventory SET price = 12 WHERE strain_id = (SELECT strain_id FROM strains WHERE name = 'Blue Dream') AND dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Green Earth'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AccommodationFacilities (id INT, country VARCHAR(50), facility_type VARCHAR(50), capacity INT); INSERT INTO AccommodationFacilities (id, country, facility_type, capacity) VALUES (1, 'India', 'Hotel', 300), (2, 'India', 'Hostel', 50), (3, 'Indonesia', 'Resort', 200), (4, 'Indonesia', 'Villa', 100); | What is the maximum and minimum capacity of accommodation facilities in India and Indonesia? | SELECT MAX(capacity) max_capacity, MIN(capacity) min_capacity FROM AccommodationFacilities WHERE country IN ('India', 'Indonesia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, sector VARCHAR(50), esg_score INT, risk_score INT, investment_amount INT); | Insert a new investment in the employment sector with an ESG score of 5, a risk score of 4, and an investment amount of 800,000. | INSERT INTO investments (investment_id, sector, esg_score, risk_score, investment_amount) VALUES (6, 'Employment', 5, 4, 800000); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), restocked_date DATE); | Delete products that have not been restocked in the past 6 months | DELETE FROM products WHERE restocked_date < (CURRENT_DATE - INTERVAL '6 months'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableTourism (InitiativeID INT, InitiativeName VARCHAR(255), Country VARCHAR(255)); INSERT INTO SustainableTourism (InitiativeID, InitiativeName, Country) VALUES (1, 'Initiative1', 'United States'), (2, 'Initiative2', 'United States'); CREATE TABLE VisitorCounts (InitiativeID INT, Year INT, VisitorCo... | List all sustainable tourism initiatives and their number of annual visitors from the United States. | SELECT SustainableTourism.InitiativeName, SUM(VisitorCounts.VisitorCount) FROM SustainableTourism INNER JOIN VisitorCounts ON SustainableTourism.InitiativeID = VisitorCounts.InitiativeID WHERE SustainableTourism.Country = 'United States' GROUP BY SustainableTourism.InitiativeName; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT, name VARCHAR(255), type VARCHAR(255), country VARCHAR(255)); INSERT INTO campaigns (id, name, type, country) VALUES (1, 'Climate Adaptation Seminar', 'Seminar', 'Brazil'), (2, 'Climate Adaptation Conference', 'Conference', 'Argentina'); CREATE TABLE communication (id INT, campaign_id INT... | Which climate adaptation campaigns reached the most people in South America? | SELECT campaign_id, MAX(reach) as max_reach FROM communication GROUP BY campaign_id HAVING country = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE courses (course_id INT, name TEXT, mental_health_rating FLOAT); INSERT INTO courses (course_id, name, mental_health_rating) VALUES (1, 'Intro to Psychology', 4.5), (2, 'Yoga for Wellness', 3.8), (3, 'Mindfulness Meditation', 4.7); | Which courses have a mental health support rating above 4 but less than 5? | SELECT course_id, name FROM courses WHERE mental_health_rating > 4 AND mental_health_rating < 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, author VARCHAR(50), year INT, journal VARCHAR(50), graduate_student VARCHAR(50)); INSERT INTO publications (id, author, year, journal, graduate_student) VALUES (1, 'Jamal', 2019, 'Journal of Social Sciences', 'Yes'), (2, 'Sophia', 2018, 'Journal of Natural Sciences', 'No'), (3, 'Hiros... | What is the total number of publications in the Journal of Social Sciences by graduate students? | SELECT COUNT(*) FROM publications WHERE journal = 'Journal of Social Sciences' AND graduate_student = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales(id INT, country VARCHAR, sale_date DATE, equipment VARCHAR, value FLOAT); INSERT INTO military_sales(id, country, sale_date, equipment, value) VALUES (1, 'China', '2020-01-15', 'Tanks', 12000000.00), (2, 'China', '2020-01-30', 'Aircraft', 30000000.00), (3, 'China', '2020-02-01', 'Missiles', ... | Update the sale_date of military equipment sales to China made in January 2020 to the first day of the month. | UPDATE military_sales SET sale_date = '2020-01-01' WHERE country = 'China' AND sale_date >= '2020-01-01' AND sale_date < '2020-02-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_flights (id INT, model VARCHAR(50), flight_hours DECIMAL(5,2), year INT); INSERT INTO aircraft_flights (id, model, flight_hours, year) VALUES (1, 'Boeing 737', 3500.5, 2019), (2, 'Airbus A320', 3200.2, 2019), (3, 'Boeing 787', 3800.8, 2018); | What is the total number of flight hours for each aircraft model by year? | SELECT model, YEAR(flight_date) as year, SUM(flight_hours) as total_flight_hours FROM aircraft_flights GROUP BY model, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(50), founder_ethnicity VARCHAR(50)); CREATE TABLE exit_strategy (id INT, company_id INT, valuation INT); INSERT INTO company (id, name, founder_ethnicity) VALUES (1, 'Acme Corp', 'Latinx'); INSERT INTO exit_strategy (id, company_id, valuation) VALUES (1, 1, 1000000); INSERT IN... | What is the maximum exit strategy valuation for companies founded by Latinx individuals? | SELECT MAX(es.valuation) AS max_exit_strategy_valuation FROM company c JOIN exit_strategy es ON c.id = es.company_id WHERE c.founder_ethnicity = 'Latinx'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, employee_id INT, loan_id INT, transaction_type TEXT, amount INT); INSERT INTO transactions (id, employee_id, loan_id, transaction_type, amount) VALUES (1, 1, 1, 'Disbursement', 15000), (2, 1, NULL, 'Salary', 50000), (3, 2, 2, 'Disbursement', 25000), (4, 2, NULL, 'Salary', 40000), (5, ... | List the salaries of employees who made no Shariah-compliant loans? | SELECT employees.salary FROM employees LEFT JOIN loans ON employees.id = loans.employee_id WHERE loans.id IS NULL AND loans.is_shariah_compliant IS TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, City VARCHAR(50), Gender VARCHAR(10)); INSERT INTO Members (MemberID, City, Gender) VALUES (1,'New York','Male'),(2,'Los Angeles','Female'),(3,'Chicago','Male'); | What is the number of male and female members in each city? | SELECT City, Gender, COUNT(*) FROM Members GROUP BY City, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (clinic_id INT, provider_name TEXT, provider_specialty TEXT); INSERT INTO rural_clinics (clinic_id, provider_name, provider_specialty) VALUES (1, 'Dr. Smith', 'General Practitioner'), (2, 'Dr. Johnson', 'Pediatrician'); CREATE TABLE urban_clinics (clinic_id INT, provider_name TEXT, provider_s... | Show the number of rural and urban healthcare providers, separated by provider specialty. | SELECT 'Rural' AS location, provider_specialty, COUNT(*) AS provider_count FROM rural_clinics GROUP BY provider_specialty UNION SELECT 'Urban', provider_specialty, COUNT(*) FROM urban_clinics GROUP BY provider_specialty; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants(RestaurantID INT, Name VARCHAR(50), City VARCHAR(50), Vegetarian BOOLEAN);INSERT INTO Restaurants VALUES (1, 'Veggie Delight', 'New York', TRUE), (2, 'Budget Bites', 'Los Angeles', FALSE), (3, 'Sushi Spot', 'San Francisco', FALSE), (4, 'Greens', 'Chicago', TRUE); | Show the number of restaurants serving vegetarian options in each city? | SELECT City, COUNT(*) FROM Restaurants WHERE Vegetarian = TRUE GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE Collection_Y (Artifact_ID INT, Material VARCHAR(255), Weight INT); INSERT INTO Collection_Y (Artifact_ID, Material, Weight) VALUES (1, 'Ceramic', 500); | What is the total weight of ceramic artifacts in 'Collection Y'? | SELECT SUM(Weight) FROM Collection_Y WHERE Material = 'Ceramic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investors (id INT, region TEXT, shariah_assets DECIMAL); INSERT INTO investors (id, region, shariah_assets) VALUES (1, 'Middle East', 15000), (2, 'Asia', 22000), (3, 'Africa', 10000); | What is the total value of Shariah-compliant assets held by investors in Asia? | SELECT SUM(shariah_assets) as total_assets FROM investors WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_plants (plant_id INT, plant_name VARCHAR(50), country VARCHAR(50), safety_violation_cost DECIMAL(10,2)); INSERT INTO chemical_plants (plant_id, plant_name, country, safety_violation_cost) VALUES (1, 'Plant A', 'Brazil', 5000), (2, 'Plant B', 'Brazil', 8000), (3, 'Plant C', 'USA', 3000); | What is the difference between the maximum and minimum safety violation costs for chemical plants in Brazil? | SELECT MAX(safety_violation_cost) - MIN(safety_violation_cost) FROM chemical_plants WHERE country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE natural_ingredients (id INT, product VARCHAR(255), natural_ingredients BOOLEAN, sales INT, country VARCHAR(255)); INSERT INTO natural_ingredients (id, product, natural_ingredients, sales, country) VALUES (1, 'Shampoo', true, 50, 'Canada'), (2, 'Conditioner', false, 75, 'Canada'), (3, 'Lotion', true, 100, '... | What is the total number of beauty products that contain natural ingredients and were sold in Canada? | SELECT SUM(sales) FROM natural_ingredients WHERE natural_ingredients = true AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2), FOREIGN KEY (EmployeeID) REFERENCES Projects(EmployeeID)); | Add a new employee to the Employees table with the specified details. | INSERT INTO Employees (EmployeeID, FirstName, LastName, Position, Department, Salary) VALUES (4, 'Aaliyah', 'Johnson', 'Architect', 'Green Building', 85000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); | Who were the top 5 donors in terms of total donation amount for 2021? | SELECT donor_id, SUM(donation_amount) AS total_donation_amount FROM donations WHERE YEAR(donation_date) = 2021 GROUP BY donor_id ORDER BY total_donation_amount DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, country TEXT); INSERT INTO users (id, name, country) VALUES (1, 'Ade', 'Nigeria'), (2, 'Bisi', 'Nigeria'), (3, 'Chinwe', 'Nigeria'), (4, 'Deji', 'South Africa'); CREATE TABLE posts (id INT, user_id INT, likes INT, timestamp DATETIME); INSERT INTO posts (id, user_id, likes, timesta... | What is the minimum number of likes on posts by users from Nigeria, in the last month? | SELECT MIN(posts.likes) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country = 'Nigeria' AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(50), data_usage FLOAT, state VARCHAR(50)); | What is the maximum monthly data usage for customers in the state of California? | SELECT MAX(data_usage) FROM customers WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SensorData (ID INT, SensorID INT, Timestamp DATETIME, MoistureLevel FLOAT); CREATE VIEW LastMonthSensorData AS SELECT * FROM SensorData WHERE Timestamp BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE(); CREATE VIEW Field2Sensors AS SELECT * FROM SensorData WHERE FieldID = 2; CREATE VIEW Field2LastMonthSe... | Identify the top 3 sensors with the highest moisture levels in 'Field2' for the last month. | SELECT SensorID, MoistureLevel, RANK() OVER (PARTITION BY FieldID ORDER BY MoistureLevel DESC) AS MoistureRank FROM Field2LastMonthSensorData WHERE MoistureRank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response.sectors_expanded (sector_id INT, sector_name VARCHAR(255), disaster_count INT); INSERT INTO disaster_response.sectors_expanded (sector_id, sector_name, disaster_count) VALUES (1, 'Education', 30), (2, 'Health', 50), (3, 'Water', 20), (4, 'Shelter', 40); | What is the total number of unique sectors and the number of disasters in each sector in the 'disaster_response' schema? | SELECT * FROM disaster_response.sectors_expanded; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, post_count INT); INSERT INTO users (id, name, post_count) VALUES (1, 'Charlie', 50); INSERT INTO users (id, name, post_count) VALUES (2, 'Diana', 200); | Update user types based on post count | UPDATE users SET user_type = 'Power User' WHERE post_count > 100; UPDATE users SET user_type = 'Regular User' WHERE post_count <= 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE TrainingPrograms (ProgramID INT, ProgramName VARCHAR(20), Participants VARCHAR(20)); INSERT INTO TrainingPrograms (ProgramID, ProgramName, Participants) VALUES (1, 'SQL', 'Female,Male,Non-binary'), (2, 'Python', 'Female,Female,Male'), (3, 'HR Analytics', 'Male,Female,Female,Non-binary'), (4, 'Data Visualiz... | Which training programs had more than 5 participants from underrepresented groups? | SELECT ProgramName FROM TrainingPrograms WHERE ARRAY_LENGTH(STRING_TO_ARRAY(Participants, ',')) - ARRAY_LENGTH(STRING_TO_ARRAY(REPLACE(Participants, ',Non-binary', ''), ',')) > 5 AND ARRAY_LENGTH(STRING_TO_ARRAY(Participants, ',')) - ARRAY_LENGTH(STRING_TO_ARRAY(REPLACE(Participants, ',Female', ''), ',')) > 5 AND ARRAY... | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation_systems (id INT, system VARCHAR(50)); INSERT INTO transportation_systems (id, system) VALUES (1, 'Subway'), (2, 'Bus'), (3, 'Tram'), (4, 'Ferry'); | Show all the transportation systems in the database. | SELECT * FROM transportation_systems; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), age INT, salary DECIMAL(10,2), PRIMARY KEY (id)); INSERT INTO employees (id, first_name, last_name, job_title, department, age, salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 35, 80000.... | Update the salary of all employees in the 'employees' table with the job title 'Engineer' to $83,000. | UPDATE employees SET salary = 83000.00 WHERE job_title = 'Engineer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR(50), population INT); INSERT INTO City (id, name, population) VALUES (1, 'CityA', 60000); INSERT INTO City (id, name, population) VALUES (2, 'CityB', 80000); CREATE TABLE Department (id INT, city_id INT, name VARCHAR(50)); INSERT INTO Department (id, city_id, name) VALUES (1, 1, ... | Which services in CityA have a frequency greater than 7? | SELECT s.name FROM Service s JOIN Department d ON s.department_id = d.id JOIN City c ON d.city_id = c.id WHERE c.name = 'CityA' AND s.frequency > 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE recipients (recipient_id INT, recipient_name TEXT, donation_amount DECIMAL); INSERT INTO recipients (recipient_id, recipient_name, donation_amount) VALUES (1, 'Recipient X', 800.00), (2, 'Recipient Y', 300.00), (3, 'Recipient Z', 600.00); | List the top 5 recipients of donations in H1 2021, along with the total amount donated to each? | SELECT recipient_name, SUM(donation_amount) as total_donation FROM donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY recipient_name ORDER BY total_donation DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_training_hours (org_id INT, sector VARCHAR(20), hours INT); INSERT INTO ai_training_hours (org_id, sector, hours) VALUES (1, 'education', 40), (2, 'healthcare', 35), (3, 'education', 45); | What is the maximum number of hours spent on training AI models by organizations in the education sector? | SELECT MAX(hours) FROM ai_training_hours WHERE sector = 'education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10), State VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender, State) VALUES (1, 34, 'Female', 'California'), (2, 42, 'Male', 'Texas'), (3, 50, 'Female', 'California'), (4, 48, 'Non-binary', 'New York'); | What is the percentage of community health workers who identify as non-binary, by state? | SELECT State, 100.0 * COUNT(CASE WHEN Gender = 'Non-binary' THEN 1 END) / COUNT(*) as Percentage FROM CommunityHealthWorkers GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, content TEXT, publication_date DATE, newspaper TEXT); | What is the total number of articles published in "The Washington Post" that mention "climate change" in the title or content? | SELECT COUNT(*) FROM articles WHERE (title LIKE '%climate change%' OR content LIKE '%climate change%') AND newspaper = 'The Washington Post'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50), profession VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, location) VALUES (1, 'John Doe', 35, 'Male', 'USA'), (2, 'Jane Smith', 40, 'Female', 'Canada'); | Update the profession for farmers with id 1 and 2 in the 'farmers' table | UPDATE farmers SET profession = 'Farmer' WHERE id IN (1, 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT, SalePrice DECIMAL(10,2)); CREATE TABLE Sales (SaleID INT PRIMARY KEY, SaleDate DATE); | What is the average sale price of artworks by African artists? | SELECT AVG(Artworks.SalePrice) AS AverageSalePrice FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID INNER JOIN Sales ON Artworks.ArtworkID = Sales.ArtworkID WHERE Artists.Nationality = 'African'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, country VARCHAR(50), asset_type VARCHAR(50), value DECIMAL(10, 2)); INSERT INTO transactions (id, country, asset_type, value) VALUES (1, 'USA', 'Stablecoin', 1000), (2, 'China', 'Stablecoin', 2000), (3, 'India', 'Crypto', 3000); | Which countries have the highest number of cross-border transactions in stablecoins? | SELECT country, SUM(value) as total_value FROM transactions WHERE asset_type = 'Stablecoin' GROUP BY country ORDER BY total_value DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_programs (id INT, location TEXT, year INT, programs INT); | What is the total number of community education programs held in each continent in the year 2022? | SELECT location, COUNT(programs) FROM education_programs WHERE year = 2022 GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers(id INT, name TEXT, age INT, gender TEXT, country TEXT); INSERT INTO farmers(id, name, age, gender, country) VALUES (1, 'Jane', 45, 'female', 'Kenya'); INSERT INTO farmers(id, name, age, gender, country) VALUES (2, 'Mary', 30, 'female', 'Kenya'); CREATE TABLE programs(id INT, farmer_id INT, program ... | What is the average age of female farmers in Kenya who have participated in agricultural innovation programs? | SELECT AVG(age) FROM farmers f INNER JOIN programs p ON f.id = p.farmer_id WHERE f.gender = 'female' AND f.country = 'Kenya'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), owner_gender VARCHAR(50), country_risk VARCHAR(50)); | Insert a new supplier that is woman-owned from a low-risk country | INSERT INTO suppliers (supplier_id, supplier_name, owner_gender, country_risk) VALUES (105, 'Supplier V', 'Female', 'Low'); | gretelai_synthetic_text_to_sql |
CREATE TABLE material_recycling(material_type VARCHAR(255), year INT, recycling_rate FLOAT); INSERT INTO material_recycling(material_type, year, recycling_rate) VALUES('MaterialA', 2020, 12.3), ('MaterialB', 2020, 45.6); | What is the recycling rate in percentage for each material type in the year 2020? | SELECT material_type, AVG(recycling_rate) FROM material_recycling WHERE year = 2020 GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (id INT PRIMARY KEY, location VARCHAR(50), area FLOAT, preservation_status VARCHAR(50)); | Update the preservation status of the habitat with id 2 to 'Critical' | UPDATE habitats SET preservation_status = 'Critical' WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE aid (id INT, organization VARCHAR(255), location VARCHAR(255), amount DECIMAL(10, 2), provide_date DATE); INSERT INTO aid (id, organization, location, amount, provide_date) VALUES (1, 'World Vision', 'South America', 500.00, '2019-02-12'), (2, 'CARE', 'South America', 800.25, '2019-04-01'), (3, 'UNHCR', 'S... | What is the total amount of aid provided by all organizations in South America in 2019? | SELECT SUM(amount) as total_amount FROM aid WHERE location = 'South America' AND YEAR(provide_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location TEXT, acidity FLOAT); INSERT INTO ocean_acidification (location, acidity) VALUES ('Caribbean Sea', 8.2), ('Pacific Ocean', 8.1), ('Atlantic Ocean', 8.0); | Update the ocean_acidification table to reflect a decrease in acidity by 0.1 units in all records | UPDATE ocean_acidification SET acidity = acidity - 0.1; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (id INT, program_name TEXT, location TEXT, facilitator TEXT, participants INT); INSERT INTO restorative_justice_programs (id, program_name, location, facilitator, participants) VALUES (1, 'Victim Offender Mediation', 'Chicago', 'John Smith', 15), (2, 'Restorative Circles', 'Los... | What is the total number of restorative justice programs by location, and the number of programs facilitated by 'Sarah Lee'? | SELECT location, COUNT(*) AS total_programs, SUM(CASE WHEN facilitator = 'Sarah Lee' THEN 1 ELSE 0 END) AS sarah_lee_programs FROM restorative_justice_programs GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sydney_Neighborhoods (Neighborhood_Name TEXT, Co_Ownership BOOLEAN); INSERT INTO Sydney_Neighborhoods (Neighborhood_Name, Co_Ownership) VALUES ('Sydney CBD', true), ('Surry Hills', false), ('Darlinghurst', true), ('Potts Point', false); CREATE TABLE Sydney_Properties (Neighborhood_Name TEXT, Property_Price... | What is the total property value in co-owned properties in Sydney? | SELECT SUM(Sydney_Properties.Property_Price) FROM Sydney_Properties INNER JOIN Sydney_Neighborhoods ON Sydney_Properties.Neighborhood_Name = Sydney_Neighborhoods.Neighborhood_Name WHERE Sydney_Neighborhoods.Co_Ownership = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (year INT, location VARCHAR(255), material VARCHAR(255), weight_tons INT); INSERT INTO waste_generation (year, location, material, weight_tons) VALUES (2022, 'New York', 'Plastic', 15000), (2022, 'New York', 'Paper', 20000), (2022, 'New York', 'Glass', 10000); | What is the total waste generation by material type in 2022 for New York? | SELECT material, SUM(weight_tons) as total_weight FROM waste_generation WHERE year = 2022 AND location = 'New York' GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_projects (id INT PRIMARY KEY, project_name VARCHAR(100), location VARCHAR(50)); | Add a new carbon offset project called 'Tropical Forest Conservation' to the 'carbon_offset_projects' table | INSERT INTO carbon_offset_projects (project_name, location) VALUES ('Tropical Forest Conservation', 'Amazon Rainforest'); | gretelai_synthetic_text_to_sql |
CREATE TABLE port_visits (id INT, ship_id INT, port_id INT, visit_date DATE); INSERT INTO port_visits (id, ship_id, port_id, visit_date) VALUES (1, 1, 1, '2022-01-01'), (2, 2, 2, '2022-01-15'), (3, 3, 1, '2022-02-05'); CREATE TABLE ports (id INT, name VARCHAR(50)); INSERT INTO ports (id, name) VALUES (1, 'Port of New Y... | Which cargo ships have visited the Port of New York in the last 30 days? | SELECT port_visits.ship_id, cargo_ships.name, port_visits.visit_date FROM port_visits JOIN ports ON port_visits.port_id = ports.id JOIN cargo_ships ON port_visits.ship_id = cargo_ships.id WHERE ports.name = 'Port of New York' AND port_visits.visit_date >= DATEADD(day, -30, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (subsystem VARCHAR(255), risk_level VARCHAR(255), days_to_patch INT); INSERT INTO vulnerabilities (subsystem, risk_level, days_to_patch) VALUES ('applications', 'high', 10), ('server', 'critical', 5), ('network', 'medium', 7); | What is the minimum number of days to patch critical vulnerabilities in the 'server' subsystem? | SELECT MIN(days_to_patch) FROM vulnerabilities WHERE subsystem = 'server' AND risk_level = 'critical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), state VARCHAR(50), height FLOAT); INSERT INTO Infrastructure (id, name, type, state, height) VALUES (1, 'Golden Gate Bridge', 'Bridge', 'California', 227.0); INSERT INTO Infrastructure (id, name, type, state, height) VALUES (2, 'Hoover Dam', 'Dam... | Calculate the average height of all dams in the United States | SELECT AVG(height) FROM Infrastructure WHERE type = 'Dam'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name TEXT, region TEXT, avg_donation_amount DECIMAL(10,2)); INSERT INTO organizations (id, name, region, avg_donation_amount) VALUES (1, 'Organization A', 'Asia-Pacific', 50.00), (2, 'Organization B', 'Europe', 75.00); | Find the top 5 organizations with the highest average donation amount in the Asia-Pacific region. | SELECT name, avg_donation_amount FROM organizations WHERE region = 'Asia-Pacific' ORDER BY avg_donation_amount DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID int, Name varchar(50), Age int); INSERT INTO Customers (CustomerID, Name, Age) VALUES (1, 'John Smith', 35), (2, 'Jane Doe', 42); CREATE TABLE Transactions (TransactionID int, CustomerID int, Amount decimal(10,2)); INSERT INTO Transactions (TransactionID, CustomerID, Amount) VALUES (1... | Find the average transaction amount for each customer's transactions? | SELECT Contexts.CustomerID, AVG(Transactions.Amount) as AvgTransactionAmount FROM Contexts JOIN Transactions ON Contexts.CustomerID = Transactions.CustomerID GROUP BY Contexts.CustomerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (id INT, name TEXT, location TEXT, num_workers INT, avg_age FLOAT, gender TEXT); INSERT INTO rural_clinics (id, name, location, num_workers, avg_age, gender) VALUES (1, 'Rural Clinic A', 'Rural Area 1', 10, 45.3, 'Male'), (2, 'Rural Clinic B', 'Rural Area 2', 15, 42.8, 'Female'), (3, 'Rural C... | What is the difference in average age between male and female healthcare workers in 'rural_clinics' table? | SELECT (SELECT AVG(avg_age) FROM rural_clinics WHERE gender = 'Male') - (SELECT AVG(avg_age) FROM rural_clinics WHERE gender = 'Female') AS difference; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_sources (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_sources (id, name, country, capacity) VALUES (1, 'Wind', 'China', 300); INSERT INTO renewable_sources (id, name, country, capacity) VALUES (2, 'Solar', 'US', 250); INSERT INTO renewable_sources (id, name, country, ca... | Find the average capacity (MW) of renewable energy sources for each country | SELECT country, AVG(capacity) FROM renewable_sources GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accidents(id INT, department VARCHAR(20), date DATE); | How many accidents have occurred in the last month in the Mining department? | SELECT COUNT(*) FROM Accidents WHERE department = 'Mining' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'IT', 'Male', 70000), (2, 'HR', 'Female', 60000), (3, 'IT', 'Female', 75000), (4, 'IT', 'Male', 78000), (5, 'Finance', 'Male', 85000); | Update the gender of employee with ID 4 to Non-binary. | UPDATE Employees SET Gender = 'Non-binary' WHERE EmployeeID = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_access(drug_name TEXT, market_country TEXT, strategy_description TEXT); INSERT INTO market_access(drug_name, market_country, strategy_description) VALUES('DrugB', 'Japan', 'Direct to consumer'); | What was the market access strategy for 'DrugB' in Japan? | SELECT strategy_description FROM market_access WHERE drug_name = 'DrugB' AND market_country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(50), region VARCHAR(50), conservation_status VARCHAR(50)); INSERT INTO marine_species (id, name, region, conservation_status) VALUES (1, 'Krill', 'Southern Ocean', 'Least Concern'), (2, 'Blue Whale', 'Southern Ocean', 'Endangered'); CREATE TABLE conservation_status (id ... | What are the marine species and their conservation statuses in the Southern Ocean? | SELECT marine_species.name, marine_species.conservation_status FROM marine_species INNER JOIN conservation_status ON marine_species.conservation_status = conservation_status.name WHERE marine_species.region = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE States (StateID INT, Name VARCHAR(50)); CREATE TABLE EmergencyCalls (CallID INT, StateID INT); | What is the total number of emergency calls in each state? | SELECT S.Name, COUNT(EC.CallID) as NumCalls FROM States S INNER JOIN EmergencyCalls EC ON S.StateID = EC.StateID GROUP BY S.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationDate DATE, CauseCategory VARCHAR(50), DonationAmount NUMERIC(15,2)); | What is the total donation amount per cause category in Q2 of 2022? | SELECT CauseCategory, SUM(DonationAmount) as TotalDonations FROM Donations WHERE DonationDate >= '2022-04-01' AND DonationDate < '2022-07-01' GROUP BY CauseCategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE Geopolitical_Risk_Assessments (assessment_id INT, assessment_date DATE, country VARCHAR(50)); INSERT INTO Geopolitical_Risk_Assessments (assessment_id, assessment_date, country) VALUES (1, '2019-05-12', 'Brazil'), (2, '2020-07-03', 'Brazil'), (3, '2021-11-28', 'Brazil'); | How many geopolitical risk assessments were conducted for Brazil in 2019 and 2020? | SELECT COUNT(assessment_id) FROM Geopolitical_Risk_Assessments WHERE country = 'Brazil' AND YEAR(assessment_date) IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, DonorID int, Amount decimal, DonationDate date); CREATE TABLE ProgramDonations (DonationID int, ProgramID int); CREATE TABLE Programs (ProgramID int, ProgramName varchar(50)); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 1000, '2022-01-01'); INS... | Which programs had the highest total donations in H1 2022? | SELECT ProgramName, SUM(Donations.Amount) as TotalDonations FROM Donations JOIN ProgramDonations ON Donations.DonationID = ProgramDonations.DonationID JOIN Programs ON ProgramDonations.ProgramID = Programs.ProgramID WHERE YEAR(DonationDate) = 2022 AND MONTH(DonationDate) <= 6 GROUP BY ProgramName ORDER BY TotalDonation... | gretelai_synthetic_text_to_sql |
CREATE TABLE route_planning (id INT, vehicle_type VARCHAR(20), route_date DATE, num_riders INT); INSERT INTO route_planning (id, vehicle_type, route_date, num_riders) VALUES (1, 'Bus', '2021-08-22', 150), (2, 'Tram', '2021-08-24', 200), (3, 'Train', '2021-08-26', 250); | How many riders used each vehicle type in the last week of August 2021? | SELECT vehicle_type, SUM(num_riders) as total_riders FROM route_planning WHERE route_date BETWEEN '2021-08-22' AND '2021-08-28' GROUP BY vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkoutTypes (Id INT PRIMARY KEY, WorkoutType VARCHAR(50)); | Delete the workout type "Pilates" from the "WorkoutTypes" table | DELETE FROM WorkoutTypes WHERE WorkoutType = 'Pilates'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (violation_id INT, violation_date DATE, community_id INT); INSERT INTO mental_health_parity (violation_id, violation_date, community_id) VALUES (1, '2021-01-01', 1), (2, '2021-02-01', 2), (3, '2021-03-01', 1); | What is the total number of mental health parity violations for each community? | SELECT community_id, COUNT(violation_id) FROM mental_health_parity GROUP BY community_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name TEXT, city TEXT); INSERT INTO attorneys (id, name, city) VALUES (1, 'Catherine Piper', 'Washington D.C.'); CREATE TABLE cases (id INT, attorney_id INT, result TEXT, city TEXT); INSERT INTO cases (id, attorney_id, result, city) VALUES (1, 1, 'lost', 'Washington D.C.'); | List the names of attorneys who have not won a case in Washington D.C. | SELECT attorneys.name FROM attorneys LEFT JOIN cases ON attorneys.id = cases.attorney_id AND cases.result = 'won' WHERE attorneys.city = 'Washington D.C' AND cases.id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE DisabilitySupportPrograms (ProgramID INT, ProgramName VARCHAR(255), Budget DECIMAL(10,2), Year INT); INSERT INTO DisabilitySupportPrograms (ProgramID, ProgramName, Budget, Year) VALUES (1, 'Sign Language Interpretation', 50000, 2023), (2, 'Assistive Technology', 75000, 2023), (3, 'Accessible Transportation... | Update the budget for the 'Accessible Transportation' program in the year 2023 to 130,000. | UPDATE DisabilitySupportPrograms SET Budget = 130000 WHERE ProgramName = 'Accessible Transportation' AND Year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workshops (WorkshopID INT, Name VARCHAR(50), Date DATE, Description TEXT); CREATE TABLE StudentWorkshops (StudentID INT, WorkshopID INT); CREATE TABLE Students (StudentID INT, Disability VARCHAR(50), Name VARCHAR(50)); | Which students with disabilities have attended more than 4 workshops in the last 6 months? | SELECT s.StudentID, s.Name, s.Disability FROM Students s JOIN StudentWorkshops sw ON s.StudentID = sw.StudentID JOIN Workshops w ON sw.WorkshopID = w.WorkshopID WHERE w.Date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY s.StudentID HAVING COUNT(sw.WorkshopID) > 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_spending (id INT, country VARCHAR(255), year INT, spending FLOAT); INSERT INTO military_spending (id, country, year, spending) VALUES (1, 'Algeria', 2020, 12.34), (2, 'Angola', 2020, 14.56), (3, 'Egypt', 2020, 17.68), (4, 'Nigeria', 2020, 20.34); CREATE VIEW africa_countries AS SELECT * FROM milit... | What was the total military spending by African countries in 2020? | SELECT SUM(spending) FROM africa_countries WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (drug_name TEXT, country TEXT, sales INTEGER, sale_date DATE); | What was the sales of 'DrugF' in 'Japan' in Q2 2021? | SELECT SUM(sales) FROM sales_data WHERE drug_name = 'DrugF' AND country = 'Japan' AND EXTRACT(MONTH FROM sale_date) BETWEEN 4 AND 6 AND EXTRACT(YEAR FROM sale_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_arg (id INT, customer_id INT, product VARCHAR(20), price DECIMAL(5,2)); CREATE TABLE suppliers_ar (id INT, product VARCHAR(20), country VARCHAR(20), sustainability_rating INT); INSERT INTO sales_arg (id, customer_id, product, price) VALUES (1, 1, 'Scarf', 29.99); INSERT INTO sales_arg (id, customer_i... | Which products are sold to customers from Argentina and have a sustainability_rating greater than 80? | SELECT sales_arg.product FROM sales_arg JOIN suppliers_ar ON sales_arg.product = suppliers_ar.product WHERE suppliers_ar.country = 'Argentina' AND suppliers_ar.sustainability_rating > 80; | 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.