context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE HeritageSites (ID INT, Name TEXT, Description TEXT, Designation TEXT); INSERT INTO HeritageSites (ID, Name, Description, Designation) VALUES (1, 'Petra', 'An archaeological city in southern Jordan', 'UNESCO World Heritage');
|
What are the names and descriptions of all heritage sites in 'Middle East' with a UNESCO World Heritage designation?
|
SELECT Name, Description FROM HeritageSites WHERE Designation = 'UNESCO World Heritage' AND Region = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE health_equity_metrics (id INT, metric_name VARCHAR(50), add_date DATE); INSERT INTO health_equity_metrics (id, metric_name, add_date) VALUES (1, 'Income Inequality', '2021-02-03'), (2, 'Race-based Disparities', '2021-04-05'), (3, 'Healthcare Access', '2021-06-07'), (4, 'Education Levels', '2021-08-09'), (5, 'Language Access', '2021-10-11'), (6, 'Transportation Access', '2021-12-13');
|
What is the number of health equity metrics added per quarter, starting from Q1 2021?
|
SELECT DATE_FORMAT(add_date, '%Y-Q') as quarter, COUNT(*) as num_metrics FROM health_equity_metrics WHERE add_date >= '2021-01-01' GROUP BY quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmers (id INT, name VARCHAR(50), age INT, region VARCHAR(20), innovation_score FLOAT);
|
Show the number of farmers in each region, sorted by the number of farmers
|
SELECT region, COUNT(*) as num_farmers FROM Farmers GROUP BY region ORDER BY num_farmers DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE journalists (id INT, name VARCHAR(50), articles_published INT); INSERT INTO journalists (id, name, articles_published) VALUES (1, 'John Doe', 15), (2, 'Jane Smith', 5);
|
List the names of journalists who have published more than 10 articles.
|
SELECT name FROM journalists WHERE articles_published > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asia_visitors (id INT, country VARCHAR(10), arrival_date DATE); INSERT INTO asia_visitors (id, country, arrival_date) VALUES (1, 'Japan', '2022-01-01'); INSERT INTO asia_visitors (id, country, arrival_date) VALUES (2, 'China', '2022-02-15'); INSERT INTO asia_visitors (id, country, arrival_date) VALUES (3, 'India', '2022-03-20'); INSERT INTO asia_visitors (id, country, arrival_date) VALUES (4, 'South Korea', '2022-04-01');
|
Find the number of visitors who traveled to Asia but not to China or India in 2022.
|
SELECT COUNT(*) FROM asia_visitors WHERE country NOT IN ('China', 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE protected_forests (state VARCHAR(20), area FLOAT); INSERT INTO protected_forests (state, area) VALUES ('California', 12345.6), ('Oregon', 7890.1);
|
What is the total area of protected forests in California and Oregon, in square kilometers?
|
SELECT SUM(area) FROM protected_forests WHERE state IN ('California', 'Oregon');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inspections (restaurant_id INT, inspection_date DATE, score INT); INSERT INTO inspections (restaurant_id, inspection_date, score) VALUES (1, '2022-01-01', 95), (1, '2022-04-01', 90), (2, '2022-01-01', 85), (2, '2022-04-01', 88);
|
What is the safety inspection score for a given restaurant?
|
SELECT score FROM inspections WHERE restaurant_id = 1 AND inspection_date = (SELECT MAX(inspection_date) FROM inspections WHERE restaurant_id = 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing_jobs (id INT, country VARCHAR(50), job VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO manufacturing_jobs (id, country, job, salary) VALUES (1, 'USA', 'Engineer', 80000.00), (2, 'Mexico', 'Assembler', 15000.00);
|
Which countries have the highest and lowest average salary in the manufacturing sector, and what are those amounts?
|
SELECT country, AVG(salary) as avg_salary FROM manufacturing_jobs GROUP BY country ORDER BY avg_salary DESC LIMIT 1; SELECT country, AVG(salary) as avg_salary FROM manufacturing_jobs GROUP BY country ORDER BY avg_salary LIMIT 1 OFFSET 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE multimodal_trips (id INT, cost FLOAT, city VARCHAR(50));
|
What is the average cost of a multimodal trip in Sydney?
|
SELECT AVG(cost) FROM multimodal_trips WHERE city = 'Sydney';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargos (id INT PRIMARY KEY, name VARCHAR(50), weight INT);
|
What is the maximum cargo weight in the 'cargos' table?
|
SELECT MAX(weight) FROM cargos;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hospital (Name TEXT, Region TEXT); INSERT INTO Hospital (Name, Region) VALUES ('Hospital A', 'Northeast'); INSERT INTO Hospital (Name, Region) VALUES ('Hospital B', 'South');
|
How many hospitals are there in the Northeast region of the US?
|
SELECT COUNT(*) FROM Hospital WHERE Region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sensor_installation (sensor_id INT, install_date DATE); INSERT INTO sensor_installation (sensor_id, install_date) VALUES (1001, '2021-04-03'), (1002, '2021-06-17'), (1003, '2021-04-01'), (1004, '2021-06-15'), (1005, '2021-03-30');
|
How many IoT humidity sensors were installed in June?
|
SELECT COUNT(*) FROM sensor_installation WHERE install_date >= '2021-06-01' AND install_date < '2021-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_adaptation_funding (project_id INT, sector TEXT, region TEXT, amount FLOAT); INSERT INTO climate_adaptation_funding (project_id, sector, region, amount) VALUES (1, 'Climate Adaptation', 'Caribbean', 3000000); INSERT INTO climate_adaptation_funding (project_id, sector, region, amount) VALUES (2, 'Climate Adaptation', 'Central America', 4000000); INSERT INTO climate_adaptation_funding (project_id, sector, region, amount) VALUES (3, 'Climate Adaptation', 'South America', 5000000);
|
List the top 3 regions with the highest climate adaptation funding in Latin America and the Caribbean.
|
SELECT region, SUM(amount) AS total_funding FROM climate_adaptation_funding WHERE sector = 'Climate Adaptation' AND region IN ('Caribbean', 'Central America', 'South America') GROUP BY region ORDER BY total_funding DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT);CREATE TABLE worker_salaries (factory_id INT, avg_salary DECIMAL); INSERT INTO factories VALUES (1, 'Factory A', 'City A'); INSERT INTO worker_salaries VALUES (1, 3000);
|
What are the names and locations of all factories with an average worker salary above the industry standard?
|
SELECT f.name, f.location FROM factories f INNER JOIN worker_salaries w ON f.factory_id = w.factory_id WHERE w.avg_salary > (SELECT AVG(ws.avg_salary) FROM worker_salaries ws);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence (threat_id INT, state TEXT, incident_date DATE); INSERT INTO threat_intelligence (threat_id, state, incident_date) VALUES (6, 'Pennsylvania', '2022-01-15'), (7, 'Michigan', '2022-02-20'), (8, 'Ohio', '2022-03-05');
|
What are the top 3 states with the most threat intelligence incidents in Q1 2022?
|
SELECT state, COUNT(*) as num_incidents FROM threat_intelligence WHERE incident_date >= '2022-01-01' AND incident_date < '2022-04-01' GROUP BY state ORDER BY num_incidents DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oil_wells (well_id INT, location VARCHAR(20), daily_production FLOAT); INSERT INTO oil_wells (well_id, location, daily_production) VALUES (1, 'Campos Basin', 1200.1), (2, 'Campos Basin', 1300.2), (3, 'Campos Basin', 1100.3);
|
Count the number of oil wells in the Campos Basin and their total daily production
|
SELECT location, COUNT(*), SUM(daily_production) FROM oil_wells WHERE location = 'Campos Basin' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment_sales (id INT, garment_id INT, category VARCHAR(20), quantity INT, price DECIMAL(5,2), sale_date DATE);INSERT INTO garment_sales (id, garment_id, category, quantity, price, sale_date) VALUES (1, 101, 'Tops', 50, 45.99, '2021-06-01');CREATE VIEW top_selling_garments_by_category AS SELECT category, garment_id, SUM(quantity) as total_sold FROM garment_sales GROUP BY category, garment_id;
|
What is the average quantity sold and ranking of garments by category?
|
SELECT category, garment_id, total_sold, AVG(quantity) as avg_quantity, RANK() OVER (PARTITION BY category ORDER BY total_sold DESC) as sales_rank FROM top_selling_garments_by_category, garment_sales WHERE top_selling_garments_by_category.category = garment_sales.category AND top_selling_garments_by_category.garment_id = garment_sales.garment_id GROUP BY category, garment_id, total_sold, price ORDER BY category, sales_rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, GameName VARCHAR(50), ReleaseYear INT, Genre VARCHAR(50), Price DECIMAL(5, 2)); INSERT INTO Games (GameID, GameName, ReleaseYear, Genre, Price) VALUES (1, 'GameA', 2020, 'Action', 60.00), (2, 'GameB', 2019, 'Adventure', 50.00), (3, 'GameC', 2018, 'RPG', 40.00);
|
What is the total revenue for games released before 2020, by genre?
|
SELECT Genre, SUM(Price) AS TotalRevenue FROM Games WHERE ReleaseYear < 2020 GROUP BY Genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_data (id INT, field_id VARCHAR(10), temperature FLOAT, timestamp TIMESTAMP); INSERT INTO temperature_data (id, field_id, temperature, timestamp) VALUES (1, 'Field008', 22.5, '2022-03-01 10:00:00'), (2, 'Field008', 20.3, '2022-03-05 10:00:00');
|
What is the average temperature recorded in 'Field008' in the past month?
|
SELECT AVG(temperature) FROM temperature_data WHERE field_id = 'Field008' AND timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CARGO (ID INT, VESSEL_ID INT, CARGO_NAME VARCHAR(50), WEIGHT INT);
|
Insert a new record of cargo with a weight of 8000 tons and cargo name 'grain' into the CARGO table
|
INSERT INTO CARGO (ID, VESSEL_ID, CARGO_NAME, WEIGHT) VALUES (1, 123, 'grain', 8000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (member_id INT, member_name VARCHAR(50), age INT, area_id INT); CREATE TABLE agriculture_innovation (farmer_id INT, farmer_name VARCHAR(50), member_id INT);
|
Count the number of community members participating in agricultural innovation programs in 'rural_area_3' from the 'community_development' and 'agriculture_innovation' tables
|
SELECT COUNT(c.member_id) FROM community_development c INNER JOIN agriculture_innovation a ON c.member_id = a.member_id WHERE c.area_id IN (SELECT area_id FROM community_development WHERE area_name = 'rural_area_3');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (id INT, company_id INT, investor TEXT, year INT, amount FLOAT); INSERT INTO investment (id, company_id, investor, year, amount) VALUES (1, 1, 'Sequoia Capital', 2022, 30000000.0); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder TEXT, PRIMARY KEY (id)); INSERT INTO company (id, name, industry, founder) VALUES (1, 'EcomEmpire', 'E-commerce', 'Latinx');
|
What is the maximum investment amount received by Latinx-founded startups in the e-commerce industry?
|
SELECT MAX(i.amount) FROM investment i JOIN company c ON i.company_id = c.id WHERE c.founder = 'Latinx' AND c.industry = 'E-commerce';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE activity_time (member_id INT, activity VARCHAR(20), time_spent INT); INSERT INTO activity_time (member_id, activity, time_spent) VALUES (1, 'Running', 60), (1, 'Cycling', 45), (2, 'Cycling', 90), (2, 'Yoga', 30), (3, 'Yoga', 60), (3, 'Swimming', 45);
|
What is the total time spent on activities for each member?
|
SELECT member_id, SUM(time_spent) AS total_time_spent FROM activity_time GROUP BY member_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, student_name VARCHAR(255), state_id INT); CREATE TABLE mental_health_appointments (appointment_id INT, student_id INT, appointment_date DATE);
|
What is the average mental health appointment frequency for students in the state of California?
|
SELECT AVG(appointment_count) FROM (SELECT student_id, COUNT(appointment_id) as appointment_count FROM mental_health_appointments GROUP BY student_id) as appointments INNER JOIN students ON appointments.student_id = students.student_id WHERE students.state_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, garment_id INT, purchase_date DATE, quantity INT, total DECIMAL(5,2)); CREATE TABLE garments (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), quantity INT, supplier_id INT); CREATE TABLE customers (id INT, first_name VARCHAR(255), last_name VARCHAR(255), email VARCHAR(255), gender VARCHAR(255), country VARCHAR(255)); INSERT INTO garments (id, name, category, price, quantity, supplier_id) VALUES (2, 'Garment Y', 'Tops', 35.99, 20, 2); INSERT INTO sales (id, garment_id, purchase_date, quantity, total) VALUES (2, 2, '2021-09-01', 15, 539.85); INSERT INTO customers (id, first_name, last_name, email, gender, country) VALUES (2, 'Jane', 'Doe', '[jane.doe@mail.com](mailto:jane.doe@mail.com)', 'Female', 'Canada');
|
What is the total sales for garment Y?
|
SELECT SUM(sales.total) FROM sales JOIN garments ON sales.garment_id = garments.id WHERE garments.name = 'Garment Y';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteer_Hours (id INT, hours INT, volunteer_id INT, month INT);
|
What is the total number of volunteer hours per month?
|
SELECT month, SUM(hours) as total_hours FROM Volunteer_Hours GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_production (well_id INT, date DATE, type VARCHAR(10), quantity INT, region VARCHAR(50)); INSERT INTO daily_production (well_id, date, type, quantity, region) VALUES (1, '2022-01-01', 'Oil', 100, 'Asian'), (1, '2022-01-02', 'Oil', 105, 'Asian'), (2, '2022-01-01', 'Gas', 200, 'Asian'), (2, '2022-01-02', 'Gas', 205, 'Asian');
|
Determine the average daily production quantity for each well in the Asian region
|
SELECT well_id, AVG(quantity) as avg_daily_production FROM daily_production WHERE region = 'Asian' GROUP BY well_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE population (city VARCHAR(255), race_ethnicity VARCHAR(255), population INT); INSERT INTO population (city, race_ethnicity, population) VALUES ('City A', 'White', 500000), ('City A', 'Black', 300000), ('City A', 'Hispanic', 200000), ('City B', 'White', 400000), ('City B', 'Black', 100000), ('City B', 'Hispanic', 300000);
|
What is the percentage of the population in each city that is of a certain race/ethnicity?
|
SELECT s1.city, (s1.population * 100.0 / (SELECT SUM(population) FROM population s2 WHERE s2.city = s1.city)) as pct_race_ethnicity FROM population s1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, artist VARCHAR(50), title VARCHAR(50), year INT, type VARCHAR(50)); INSERT INTO Artworks (id, artist, title, year, type) VALUES (1, 'Indigenous Artist 1', 'Artwork 1', 2000, 'Painting'); INSERT INTO Artworks (id, artist, title, year, type) VALUES (2, 'Indigenous Artist 2', 'Artwork 2', 2005, 'Sculpture');
|
How many artworks were created by Indigenous artists each year since 2000?
|
SELECT year, COUNT(*) AS artworks_per_year FROM Artworks WHERE artist LIKE 'Indigenous Artist%' AND year >= 2000 GROUP BY year ORDER BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Visitors_Japan (id INT, year INT, country VARCHAR(50), expenditure FLOAT); INSERT INTO Visitors_Japan (id, year, country, expenditure) VALUES (1, 2021, 'Japan', 2000), (2, 2021, 'Japan', 2100), (3, 2021, 'Japan', 2200);
|
What is the number of international visitors to Japan in 2021 and their average expenditures?
|
SELECT AVG(Visitors_Japan.expenditure) FROM Visitors_Japan WHERE Visitors_Japan.country = 'Japan' AND Visitors_Japan.year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE program_funding_3 (program_id INT, amount DECIMAL(10,2), year INT); INSERT INTO program_funding_3 (program_id, amount, year) VALUES (1, 5000.00, 2022), (2, 7000.00, 2022), (3, 3000.00, 2023);
|
Calculate the total funding by year
|
SELECT year, SUM(amount) FROM program_funding_3 GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Tunnels (name TEXT, cost FLOAT, location TEXT);
|
What are the names of tunnels with a cost similar to the "Eisenhower Tunnel"?
|
SELECT name FROM Tunnels WHERE cost BETWEEN (SELECT cost FROM Tunnels WHERE name = 'Eisenhower Tunnel' * 0.9) AND (SELECT cost FROM Tunnels WHERE name = 'Eisenhower Tunnel' * 1.1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExtractionData (ExtractionDataID INT, MineID INT, Date DATE, Mineral TEXT, Quantity INT);
|
What is the total quantity of mineral extracted for each mine in a specific month of a specific year?
|
SELECT MineID, SUM(Quantity) FROM ExtractionData WHERE Date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY MineID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE traffic_violations (id INT, age_group VARCHAR(10), convicted BOOLEAN, violation_date DATE);
|
What is the total number of traffic violations and the percentage of violations resulting in a conviction, by age group?
|
SELECT age_group, COUNT(*) number_of_violations, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY NULL) AS percentage_convicted FROM traffic_violations WHERE convicted = TRUE GROUP BY age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_city_projects (project_id INT, project_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO smart_city_projects (project_id, project_name, city, state) VALUES (1, 'New York Smart Grid', 'New York', 'NY'); INSERT INTO smart_city_projects (project_id, project_name, city, state) VALUES (2, 'Buffalo Intelligent Transport', 'Buffalo', 'NY');
|
How many smart city projects are in the state of New York?
|
SELECT COUNT(*) FROM smart_city_projects WHERE state = 'NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_revenue (customer_id INT, revenue FLOAT, state VARCHAR(20)); CREATE TABLE broadband_revenue (customer_id INT, revenue FLOAT, state VARCHAR(20)); INSERT INTO mobile_revenue (customer_id, revenue, state) VALUES (1, 50, 'New Jersey'); INSERT INTO broadband_revenue (customer_id, revenue, state) VALUES (1, 60, 'New Jersey');
|
What is the total revenue generated from mobile and broadband services in New Jersey?
|
SELECT SUM(mobile_revenue.revenue) + SUM(broadband_revenue.revenue) FROM mobile_revenue INNER JOIN broadband_revenue ON mobile_revenue.customer_id = broadband_revenue.customer_id WHERE mobile_revenue.state = 'New Jersey' AND broadband_revenue.state = 'New Jersey';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_projects (project_id INT, project_name TEXT, location TEXT, project_type TEXT, start_year INT); INSERT INTO climate_projects (project_id, project_name, location, project_type, start_year) VALUES (1, 'Mitigation 1', 'USA', 'climate mitigation', 2010), (2, 'Adaptation 1', 'Canada', 'climate adaptation', 2012), (3, 'Communication 1', 'Mexico', 'climate communication', 2015);
|
Identify the number of climate mitigation projects in North America for each year since 2010.
|
SELECT start_year, COUNT(*) as project_count FROM climate_projects WHERE project_type = 'climate mitigation' AND location LIKE 'North America%' AND start_year >= 2010 GROUP BY start_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteGeneration (material VARCHAR(50), date DATE, waste_quantity INT); INSERT INTO WasteGeneration VALUES ('Plastic', '2021-01-01', 1500), ('Plastic', '2021-01-02', 1700), ('Paper', '2021-01-01', 1200), ('Paper', '2021-01-02', 1300), ('Glass', '2021-01-01', 800), ('Glass', '2021-01-02', 900), ('Metal', '2021-01-01', 500), ('Metal', '2021-01-02', 550);
|
What is the total waste generation by material in the past month?
|
SELECT material, SUM(waste_quantity) FROM WasteGeneration WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CybersecurityIncidents (Id INT, Month VARCHAR(50), Incidents INT, Year INT); INSERT INTO CybersecurityIncidents (Id, Month, Incidents, Year) VALUES (1, 'January', 25, 2021); INSERT INTO CybersecurityIncidents (Id, Month, Incidents, Year) VALUES (2, 'February', 30, 2021);
|
What is the total number of cybersecurity incidents recorded for each month in 2021?
|
SELECT SUM(Incidents), Month FROM CybersecurityIncidents WHERE Year = 2021 GROUP BY Month;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA HumanitarianAid; CREATE TABLE Schools (id INT, name VARCHAR, country VARCHAR); INSERT INTO Schools (id, name, country) VALUES (1, 'School1', 'Country1'), (2, 'School2', 'Country2'); CREATE TABLE Hospitals (id INT, name VARCHAR, country VARCHAR); INSERT INTO Hospitals (id, name, country) VALUES (1, 'Hospital1', 'Country1'), (2, 'Hospital2', 'Country2');
|
What is the total number of schools and hospitals in the 'HumanitarianAid' schema, ordered by the number of facilities?
|
SELECT 'Schools' as facility_type, COUNT(*) as total_facilities FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY id) as rn FROM HumanitarianAid.Schools) as t WHERE rn > 0 UNION ALL SELECT 'Hospitals' as facility_type, COUNT(*) as total_facilities FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY id) as rn FROM HumanitarianAid.Hospitals) as t WHERE rn > 0 ORDER BY total_facilities DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_compliant_finance (id INT, client_id INT, date DATE); CREATE TABLE financial_capability_programs (id INT, program_name VARCHAR(255), client_id INT, date DATE);
|
Identify clients who received Shariah-compliant financing and participated in financial capability programs in 2021.
|
SELECT DISTINCT shariah_compliant_finance.client_id FROM shariah_compliant_finance INNER JOIN financial_capability_programs ON shariah_compliant_finance.client_id = financial_capability_programs.client_id WHERE shariah_compliant_finance.date BETWEEN '2021-01-01' AND '2021-12-31' AND financial_capability_programs.date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City_Budget (City VARCHAR(20), Department VARCHAR(20), Budget INT); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityC', 'Education', 5000000); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityC', 'Healthcare', 7000000); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityD', 'Education', 6000000); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityD', 'Healthcare', 8000000);
|
What is the total budget for education and healthcare in CityC and CityD?
|
SELECT City, SUM(CASE WHEN Department = 'Education' THEN Budget ELSE 0 END) AS 'Education Budget', SUM(CASE WHEN Department = 'Healthcare' THEN Budget ELSE 0 END) AS 'Healthcare Budget' FROM City_Budget WHERE City IN ('CityC', 'CityD') GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE NeodymiumPrices(month DATE, price DECIMAL(5,2)); INSERT INTO NeodymiumPrices(month, price) VALUES ('2021-01-01', 120.50), ('2021-02-01', 125.00), ('2021-03-01', 118.75), ('2021-04-01', 132.25), ('2021-05-01', 140.00);
|
What are the average monthly prices of Neodymium for the past year?
|
SELECT AVG(price) FROM NeodymiumPrices WHERE month >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY EXTRACT(MONTH FROM month);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellites (Id INT, Name VARCHAR(50), LaunchYear INT, Country VARCHAR(50)); INSERT INTO Satellites (Id, Name, LaunchYear, Country) VALUES (1, 'Sat1', 2018, 'USA'), (2, 'Sat2', 2019, 'USA'), (3, 'Sat3', 2020, 'USA'), (4, 'Sat4', 2020, 'China'), (5, 'Sat5', 2020, 'Russia'), (6, 'Sat6', 2018, 'Germany'), (7, 'Sat7', 2019, 'India'), (8, 'Sat8', 2020, 'India'), (9, 'Sat9', 2020, 'India');
|
What are the names of all satellites launched by India?
|
SELECT Name FROM Satellites WHERE Country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_transactions (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_date DATE); INSERT INTO customer_transactions (transaction_id, customer_id, transaction_value, transaction_date) VALUES (1, 1, 12000, '2021-07-01'), (2, 2, 35000, '2021-06-15'), (3, 1, 8000, '2021-05-05'), (4, 3, 5000, '2021-04-20');
|
Show the total number of transactions per customer in the last quarter, ordered by the number of transactions in descending order?
|
SELECT customer_id, COUNT(transaction_id) as transaction_count FROM customer_transactions WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY customer_id ORDER BY transaction_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Innovations (id INT PRIMARY KEY, name VARCHAR(50), region VARCHAR(20), adoption_rate FLOAT);
|
Identify the top 5 agricultural innovations with the highest adoption rates in Africa.
|
SELECT name, adoption_rate FROM (SELECT name, adoption_rate, ROW_NUMBER() OVER (PARTITION BY region ORDER BY adoption_rate DESC) rn FROM Innovations WHERE region = 'Africa') tmp WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TransportationProjects (ProjectID INT, Name VARCHAR(100), Budget DECIMAL(10,2), Year INT, State VARCHAR(50)); INSERT INTO TransportationProjects (ProjectID, Name, Budget, Year, State) VALUES (1, 'Subway Expansion', 50000000, 2021, 'New York'), (2, 'Bus Maintenance Facility', 1000000, 2021, 'New York'), (3, 'Railway Upgrade', 20000000, 2020, 'California');
|
What is the maximum budget allocated to any transportation project in the state of New York in the year 2021?
|
SELECT MAX(Budget) FROM TransportationProjects WHERE Year = 2021 AND State = 'New York' AND Name LIKE '%transportation%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_employment (state VARCHAR(2), unemployment_rate DECIMAL(4,2), snapshot_date DATE); INSERT INTO veteran_employment VALUES ('CA', 3.2, '2021-07-15'), ('TX', 4.1, '2021-07-15'), ('NY', 5.0, '2021-07-15');
|
List veteran employment statistics by state for the most recent month, ordered by unemployment rate.
|
SELECT state, unemployment_rate FROM veteran_employment WHERE snapshot_date = (SELECT MAX(snapshot_date) FROM veteran_employment) ORDER BY unemployment_rate;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO customer_transactions VALUES (1, 1, 100.00, '2022-02-01'); INSERT INTO customer_transactions VALUES (2, 1, 200.00, '2022-02-15'); INSERT INTO customer_transactions VALUES (3, 2, 75.00, '2022-02-03'); INSERT INTO customer_transactions VALUES (4, 2, 250.00, '2022-02-28');
|
What is the total transaction amount for each customer in the past month?
|
SELECT customer_id, SUM(amount) as total_amount FROM customer_transactions WHERE transaction_date >= DATEADD(month, -1, GETDATE()) GROUP BY customer_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (id INT, supplier VARCHAR(255)); INSERT INTO Suppliers (id, supplier) VALUES (1, 'SupplierA'), (2, 'SupplierB'), (3, 'SupplierC'); CREATE TABLE Products (id INT, product VARCHAR(255), category VARCHAR(255), supplier_id INT, ethical_labor_practices BOOLEAN); INSERT INTO Products (id, product, category, supplier_id, ethical_labor_practices) VALUES (1, 'Product1', 'CategoryA', 1, true), (2, 'Product2', 'CategoryA', 1, false), (3, 'Product3', 'CategoryB', 2, true), (4, 'Product4', 'CategoryB', 2, true), (5, 'Product5', 'CategoryC', 3, false), (6, 'Product6', 'CategoryC', 3, false);
|
What is the count of products with ethical labor practices, by category and supplier?
|
SELECT p.category, s.supplier, COUNT(p.id) AS count FROM Products p JOIN Suppliers s ON p.supplier_id = s.id WHERE p.ethical_labor_practices = true GROUP BY p.category, s.supplier;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SmartCities.Buildings (id INT, city VARCHAR(50), energy_consumption FLOAT); INSERT INTO SmartCities.Buildings (id, city, energy_consumption) VALUES (1, 'NYC', 1200.5), (2, 'LA', 800.2), (3, 'SF', 1000.7), (4, 'NYC', 900.3), (5, 'LA', 1100.0);
|
Identify the buildings with energy consumption higher than the average energy consumption per building in the 'SmartCities' schema.
|
SELECT id, city, energy_consumption FROM SmartCities.Buildings WHERE energy_consumption > (SELECT AVG(energy_consumption) FROM SmartCities.Buildings);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (product_id INT, product_category VARCHAR(255), is_ethically_sourced BOOLEAN, price DECIMAL(5,2)); INSERT INTO Products (product_id, product_category, is_ethically_sourced, price) VALUES (1, 'Clothing', true, 50.00), (2, 'Clothing', false, 40.00), (3, 'Electronics', true, 60.00), (4, 'Electronics', false, 30.00), (5, 'Furniture', true, 55.00);
|
Identify the top 3 product categories with the highest average price of ethically sourced items.
|
SELECT product_category, AVG(price) as avg_price FROM Products WHERE is_ethically_sourced = true GROUP BY product_category ORDER BY avg_price DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions_6 (transaction_id INT, amount DECIMAL(10, 2)); INSERT INTO transactions_6 (transaction_id, amount) VALUES (1, 500.00), (2, 750.00), (3, 100000.00), (4, 9000.00);
|
Delete all transactions with an amount greater than $50,000.
|
DELETE FROM transactions_6 WHERE amount > 50000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (SaleID int, Genre varchar(50), SalesDate date, Revenue decimal(10,2)); INSERT INTO Sales VALUES (1, 'K-Pop', '2021-01-01', 5000); INSERT INTO Sales VALUES (2, 'K-Pop', '2021-02-01', 7000); INSERT INTO Sales VALUES (3, 'K-Pop', '2021-03-01', 6000);
|
What is the total revenue generated by K-Pop music worldwide in 2021?
|
SELECT SUM(Revenue) as TotalRevenue FROM Sales WHERE Genre = 'K-Pop' AND YEAR(SalesDate) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Defense_Diplomacy (Event_ID INT, Event_Name VARCHAR(50), Start_Date DATE); INSERT INTO Defense_Diplomacy (Event_ID, Event_Name, Start_Date) VALUES (1, 'Defense Summit', '2000-01-01');
|
What is the earliest start date for a defense diplomacy event?
|
SELECT MIN(Start_Date) as Earliest_Date FROM Defense_Diplomacy;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat_preservation (id INT, species VARCHAR(255), area INT);
|
Find the total habitat area for each species in 'habitat_preservation' table.
|
SELECT species, SUM(area) FROM habitat_preservation GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT PRIMARY KEY, co_owned BOOLEAN, address VARCHAR(50));
|
How many co-owned properties are in the historic district?
|
SELECT COUNT(*) FROM property WHERE co_owned = TRUE AND address LIKE '%historic district%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameName VARCHAR(50), Win BIT);
|
Find the total number of games won by each player in the 'PlayerGames' table
|
SELECT PlayerID, SUM(Win) as TotalWins FROM PlayerGames GROUP BY PlayerID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ContractorHiring (id INT, contractor VARCHAR(255), year INT, veterans INT); INSERT INTO ContractorHiring (id, contractor, year, veterans) VALUES (1, 'Lockheed Martin', 2018, 200), (2, 'Raytheon', 2018, 150), (3, 'Boeing', 2018, 250), (4, 'Northrop Grumman', 2018, 220), (5, 'Lockheed Martin', 2019, 250), (6, 'Raytheon', 2019, 200), (7, 'Boeing', 2019, 300), (8, 'Northrop Grumman', 2019, 280), (9, 'Lockheed Martin', 2020, 300), (10, 'Raytheon', 2020, 250), (11, 'Boeing', 2020, 350), (12, 'Northrop Grumman', 2020, 330);
|
How many veterans were hired by the top 5 defense contractors between 2018 and 2020?
|
SELECT contractor, SUM(veterans) FROM ContractorHiring WHERE year BETWEEN 2018 AND 2020 GROUP BY contractor;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (id INT, city VARCHAR(50), offset_type VARCHAR(50), amount FLOAT); INSERT INTO carbon_offsets (id, city, offset_type, amount) VALUES (1, 'Mumbai', 'Tree Planting', 1000.0), (2, 'Rio de Janeiro', 'Reforestation', 1500.0), (3, 'Johannesburg', 'Energy Efficiency', 1200.0); CREATE TABLE smart_cities (id INT, city VARCHAR(50), adoption_year INT); INSERT INTO smart_cities (id, city, adoption_year) VALUES (1, 'Mumbai', 2017), (2, 'Rio de Janeiro', 2018), (3, 'Johannesburg', 2019);
|
What is the total amount of carbon offset and adoption year for each offset type in each city?
|
SELECT co.city, co.offset_type, sc.adoption_year, SUM(co.amount) as total_amount FROM carbon_offsets co JOIN smart_cities sc ON co.city = sc.city GROUP BY co.city, co.offset_type, sc.adoption_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturer_sales (id INT, manufacturer VARCHAR(50), vehicle_type VARCHAR(20), sale_year INT, quantity INT); INSERT INTO manufacturer_sales (id, manufacturer, vehicle_type, sale_year, quantity) VALUES (1, 'Tesla', 'EV', 2021, 30000), (2, 'Tesla', 'EV', 2022, 50000), (3, 'Toyota', 'Hybrid', 2021, 20000), (4, 'Toyota', 'Hybrid', 2022, 25000), (5, 'Ford', 'EV', 2022, 10000);
|
Identify the manufacturer with the most electric vehicle sales in 2022
|
SELECT manufacturer, SUM(quantity) FROM manufacturer_sales WHERE vehicle_type = 'EV' AND sale_year = 2022 GROUP BY manufacturer ORDER BY SUM(quantity) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (name VARCHAR(30), city VARCHAR(30)); CREATE TABLE ticket_sales (team VARCHAR(30), revenue INT); INSERT INTO teams (name, city) VALUES ('Knicks', 'New York'), ('Lakers', 'Los Angeles'); INSERT INTO ticket_sales (team, revenue) VALUES ('Knicks', 1000000), ('Lakers', 1200000);
|
What is the total revenue from ticket sales for each team in the 'teams' and 'ticket_sales' tables?
|
SELECT teams.name, SUM(ticket_sales.revenue) FROM teams INNER JOIN ticket_sales ON teams.name = ticket_sales.team GROUP BY teams.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Company (id INT, name VARCHAR(20)); INSERT INTO Company (id, name) VALUES (1, 'GreenBuild'); CREATE TABLE Permit (id INT, company_id INT, cost INT, sustainable VARCHAR(5));
|
What is the total cost of sustainable projects completed by 'GreenBuild' company?
|
SELECT SUM(Permit.cost) AS total_cost FROM Permit INNER JOIN Company ON Permit.company_id = Company.id WHERE Company.name = 'GreenBuild' AND Permit.sustainable = 'yes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_type VARCHAR(255), investment_type VARCHAR(255)); INSERT INTO customers (id, name) VALUES (1, 'John Doe'); INSERT INTO transactions (id, customer_id, amount, transaction_type, investment_type) VALUES (1, 1, 500.00, 'Investment', 'Stocks'); INSERT INTO transactions (id, customer_id, amount, transaction_type, investment_type) VALUES (2, 1, 300.00, 'Investment', 'Bonds');
|
What is the total transaction amount by investment type for each customer?
|
SELECT c.name, t.investment_type, SUM(t.amount) as total_amount FROM customers c JOIN transactions t ON c.id = t.customer_id WHERE t.transaction_type = 'Investment' GROUP BY c.name, t.investment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lifelong_learning (student_id INT, learning_score INT, date DATE); INSERT INTO lifelong_learning (student_id, learning_score, date) VALUES (1, 90, '2022-06-01'), (2, 95, '2022-06-02'), (3, 80, '2022-06-03');
|
What is the minimum lifelong learning score of students in 'Summer 2022'?
|
SELECT MIN(learning_score) FROM lifelong_learning WHERE date = '2022-06-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ZeroBudgetPrograms (ProgramID INT, ProgramName TEXT, Volunteers INT, Budget DECIMAL(10,2)); INSERT INTO ZeroBudgetPrograms (ProgramID, ProgramName, Volunteers, Budget) VALUES (1, 'Feeding America', 75, 0);
|
Identify the programs with zero budget and more than 50 volunteers?
|
SELECT ProgramID, ProgramName FROM ZeroBudgetPrograms WHERE Budget = 0 AND Volunteers > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DysprosiumProduction (Company VARCHAR(50), Year INT, Production FLOAT); INSERT INTO DysprosiumProduction(Company, Year, Production) VALUES ('CompanyA', 2018, 75.3), ('CompanyA', 2019, 82.7), ('CompanyA', 2020, 90.1), ('CompanyB', 2018, 63.9), ('CompanyB', 2019, 68.1), ('CompanyB', 2020, 73.8), ('CompanyC', 2018, 86.4), ('CompanyC', 2019, 88.2), ('CompanyC', 2020, 89.6);
|
What is the average annual dysprosium production for each company from 2018 to 2020?
|
SELECT Company, AVG(Production) as Avg_Production FROM DysprosiumProduction WHERE Year IN (2018, 2019, 2020) GROUP BY Company;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LandfillCapacity (capacity_id INT, region VARCHAR(255), capacity DECIMAL(10,2)); INSERT INTO LandfillCapacity (capacity_id, region, capacity) VALUES (1, 'North America', 2500), (2, 'South America', 3000), (3, 'Europe', 1800), (4, 'Asia-Pacific', 2200);
|
What is the minimum landfill capacity in the Asia-Pacific region?
|
SELECT MIN(capacity) FROM LandfillCapacity WHERE region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue_data (revenue_date DATE, manufacturer VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO revenue_data (revenue_date, manufacturer, revenue) VALUES ('2022-01-01', 'Manufacturer A', 1000), ('2022-01-02', 'Manufacturer B', 2000), ('2022-01-03', 'Manufacturer A', 1500), ('2022-02-01', 'Manufacturer B', 2500), ('2022-02-02', 'Manufacturer C', 3000), ('2022-02-03', 'Manufacturer B', 3500), ('2022-03-01', 'Manufacturer C', 4000), ('2022-03-02', 'Manufacturer A', 4500), ('2022-03-03', 'Manufacturer C', 5000);
|
What is the total revenue generated by each manufacturer in the current year?
|
SELECT manufacturer, SUM(revenue) OVER (PARTITION BY manufacturer) as total_revenue FROM revenue_data WHERE revenue_date >= DATEADD(year, DATEDIFF(year, 0, CURRENT_DATE), 0);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VehicleSafetyTests (vehicle_id INT, model VARCHAR(100), passed BOOLEAN, country VARCHAR(50), year INT); INSERT INTO VehicleSafetyTests (vehicle_id, model, passed, country, year) VALUES (1, 'Model X', true, 'India', 2019), (2, 'Corolla', false, 'India', 2019);
|
What are the names of all vehicles that passed safety tests in India in 2019?
|
SELECT model FROM VehicleSafetyTests WHERE passed = true AND country = 'India' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget (dept VARCHAR(50), program VARCHAR(50), amount INT);
|
Add a new record for 'Wheelchair Tennis' program with a budget of $45,000 in the 'Adaptive Sports' department.
|
INSERT INTO budget (dept, program, amount) VALUES ('Adaptive Sports', 'Wheelchair Tennis', 45000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (id INT, equipment_name TEXT, sale_date DATE, quantity INT, total_cost FLOAT);
|
remove all records with total cost greater than 50000000 from sales_data
|
DELETE FROM sales_data WHERE total_cost > 50000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Falcon9Missions (id INT, launch_date DATE, delay INT);
|
What is the average delivery delay for SpaceX's Falcon 9 missions?
|
SELECT AVG(delay) FROM Falcon9Missions WHERE delay IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MonthlyRevenue (restaurant_id INT, month INT, year INT, revenue INT); INSERT INTO MonthlyRevenue (restaurant_id, month, year, revenue) VALUES (4, 1, 2021, 5000), (4, 2, 2021, 6000);
|
What is the average monthly revenue for 'Healthy Habits' in 2021?
|
SELECT AVG(revenue) FROM MonthlyRevenue WHERE restaurant_id = 4 AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (equipment_type VARCHAR(255), acquisition_cost INT, acquisition_year INT, country VARCHAR(255)); INSERT INTO military_equipment (equipment_type, acquisition_cost, acquisition_year, country) VALUES ('Fighter Jet', 50000000, 2017, 'China'), ('Submarine', 1000000000, 2019, 'Japan');
|
Calculate the total cost of military equipment for Asian countries in the last 5 years
|
SELECT country, SUM(acquisition_cost) FROM military_equipment WHERE country LIKE 'Asia%' AND acquisition_year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_tourism_brazil (id INT, initiative VARCHAR(20), country VARCHAR(20), local_jobs INT); INSERT INTO sustainable_tourism_brazil (id, initiative, country, local_jobs) VALUES (1, 'Eco-Lodge', 'Brazil', 15), (2, 'Hiking Tours', 'Brazil', 12), (3, 'Bird Watching Tours', 'Brazil', 18);
|
What is the minimum local job creation per sustainable tourism initiative in Brazil?
|
SELECT MIN(local_jobs) FROM sustainable_tourism_brazil WHERE country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, sector VARCHAR(20), location VARCHAR(20), amount DECIMAL(10,2), date DATE);
|
What is the difference in waste generation between the residential and industrial sectors in Chicago since 2019?
|
SELECT residential.location, residential.amount - industrial.amount FROM waste_generation AS residential INNER JOIN waste_generation AS industrial ON residential.location = industrial.location AND residential.date = industrial.date WHERE residential.sector = 'residential' AND industrial.sector = 'industrial' AND residential.date >= '2019-01-01';
|
gretelai_synthetic_text_to_sql
|
Products (product_id, name, rating, cruelty_free)
|
Add new cruelty-free products to the database
|
INSERT INTO Products (name, rating, cruelty_free) SELECT 'new product', 4.7, 'yes' FROM dual WHERE NOT EXISTS (SELECT * FROM Products WHERE name = 'new product')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (year INT, sector VARCHAR(20), usage INT); INSERT INTO water_usage (year, sector, usage) VALUES (2020, 'residential', 12000), (2020, 'commercial', 15000), (2020, 'industrial', 20000), (2021, 'residential', 11000), (2021, 'commercial', 14000), (2021, 'industrial', 18000);
|
What is the water usage in the commercial sector for the year 2021?
|
SELECT usage FROM water_usage WHERE sector = 'commercial' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_sales (product_id INT, product_name TEXT, country TEXT, total_sales FLOAT, sale_quarter INT); INSERT INTO product_sales (product_id, product_name, country, total_sales, sale_quarter) VALUES (1, 'Product I', 'Germany', 25000, 1), (2, 'Product J', 'Germany', 30000, 2), (3, 'Product K', 'Germany', 20000, 3), (4, 'Product L', 'Germany', 28000, 4);
|
Calculate the average total sales for chemical products in Germany, partitioned by quarter in ascending order.
|
SELECT sale_quarter, AVG(total_sales) as avg_total_sales, RANK() OVER (PARTITION BY country ORDER BY AVG(total_sales)) as rank FROM product_sales WHERE country = 'Germany' GROUP BY sale_quarter ORDER BY rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50), TotalBilling FLOAT); INSERT INTO Attorneys (AttorneyID, Name, TotalBilling) VALUES (1, 'John Smith', 5000.00), (2, 'Jane Doe', 7000.00);
|
What is the total billing amount for each attorney, ordered by total billing amount in descending order?
|
SELECT AttorneyID, Name, TotalBilling FROM Attorneys ORDER BY TotalBilling DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biosensor_funding(id INT, project VARCHAR(50), date DATE, amount DECIMAL(10,2)); INSERT INTO biosensor_funding VALUES (1, 'ProjectA', '2021-07-15', 250000.00), (2, 'ProjectB', '2021-10-30', 350000.00), (3, 'ProjectC', '2021-08-28', 300000.00);
|
What is the average funding per biosensor technology project in Q3 2021?
|
SELECT AVG(amount) FROM biosensor_funding WHERE date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT PRIMARY KEY, company_id INT, gender TEXT, minority TEXT, year INT, location TEXT); CREATE VIEW diversity_metrics_summary AS SELECT location, MAX(year) as max_year FROM diversity_metrics GROUP BY location;
|
What is the most recent diversity metric reporting year for founders in 'Washington'?
|
SELECT s.location, s.max_year FROM diversity_metrics_summary s JOIN company_founding c ON c.location = s.location WHERE s.location = 'Washington';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE actors (name VARCHAR(255), gender VARCHAR(10), movies INTEGER, production_country VARCHAR(100)); INSERT INTO actors (name, gender, movies, production_country) VALUES ('ActorA', 'Female', 12, 'Canada'), ('ActorB', 'Male', 15, 'USA'), ('ActorC', 'Female', 8, 'France'), ('ActorD', 'Male', 20, 'USA'), ('ActorE', 'Female', 18, 'Germany'), ('ActorF', 'Male', 10, 'Canada'), ('ActorG', 'Male', 11, 'USA');
|
Who are the male actors that have acted in a movie produced in the USA?
|
SELECT name FROM actors WHERE gender = 'Male' AND production_country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (id INT, name VARCHAR(50), location VARCHAR(50), yearsOfExperience INT); INSERT INTO CommunityHealthWorkers (id, name, location, yearsOfExperience) VALUES (1, 'Jamal Johnson', 'Atlanta', 7), (2, 'Aaliyah Brown', 'New York', 6);
|
Who are the community health workers with more than 5 years of experience in New York?
|
SELECT * FROM CommunityHealthWorkers WHERE location = 'New York' AND yearsOfExperience > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE designers (designer_id INT PRIMARY KEY, name VARCHAR(255), origin_country VARCHAR(100)); CREATE TABLE materials (material_id INT PRIMARY KEY, designer_id INT, fabric VARCHAR(100), order_date DATE);
|
Which designers are from the USA and have more than 10 different fabric types in their collections?
|
SELECT d.name FROM designers d INNER JOIN materials m ON d.designer_id = m.designer_id WHERE d.origin_country = 'USA' GROUP BY d.name HAVING COUNT(DISTINCT m.fabric) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE explainable_ai_apps (app_id INT, app_name VARCHAR(255), launch_date DATE, country VARCHAR(255)); INSERT INTO explainable_ai_apps (app_id, app_name, launch_date, country) VALUES (1, 'App1', '2021-01-01', 'UK'), (2, 'App2', '2021-03-15', 'Canada'), (3, 'App3', '2021-05-07', 'UK');
|
Find the number of explainable AI applications launched per month in 2021, for applications launched in the UK.
|
SELECT EXTRACT(MONTH FROM launch_date) AS month, COUNT(*) AS apps_launched_per_month FROM explainable_ai_apps WHERE country = 'UK' AND EXTRACT(YEAR FROM launch_date) = 2021 GROUP BY month ORDER BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DispensarySales (dispensary_id INT, product_type TEXT, quantity_sold INT, state TEXT);
|
What is the total quantity of edibles sold in dispensaries located in the state of California?
|
SELECT SUM(quantity_sold) FROM DispensarySales WHERE product_type = 'edibles' AND state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, artist VARCHAR(50), title VARCHAR(100), year INT, medium VARCHAR(50), width FLOAT, height FLOAT);
|
Insert a new artwork record for 'Frida Kahlo' with the title 'The Two Fridas'.
|
INSERT INTO Artworks (id, artist, title, year, medium, width, height) VALUES (2, 'Frida Kahlo', 'The Two Fridas', 1939, 'Oil on canvas', 173.7, 159.8);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerName TEXT); INSERT INTO Players (PlayerID, PlayerName) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE Games (GameID INT, PlayerID INT, GameDateTime TIMESTAMP); INSERT INTO Games (GameID, PlayerID, GameDateTime) VALUES (1, 1, '2021-01-01 10:00:00'), (2, 1, '2021-02-03 14:00:00'), (3, 2, '2021-01-15 09:00:00');
|
List all players who have played a game after 2021-02-01
|
SELECT Players.PlayerName FROM Players JOIN Games ON Players.PlayerID = Games.PlayerID WHERE Games.GameDateTime > '2021-02-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_for_good (id INT, country VARCHAR(255), year INT, contributions INT); INSERT INTO ai_for_good (id, country, year, contributions) VALUES (1, 'Brazil', 2021, 100); INSERT INTO ai_for_good (id, country, year, contributions) VALUES (2, 'Argentina', 2021, 80); INSERT INTO ai_for_good (id, country, year, contributions) VALUES (3, 'Colombia', 2021, 60);
|
Who are the top 2 contributors to AI for good projects in Latin America in 2021?
|
SELECT country, contributions FROM ai_for_good WHERE year = 2021 ORDER BY contributions DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Q1ContractNegotiations (negotiation_date DATE, parties TEXT); INSERT INTO Q1ContractNegotiations (negotiation_date, parties) VALUES ('2022-02-01', 'ABC Corp - Military'), ('2022-03-15', 'DEF Inc - Government'), ('2022-01-20', 'GHI Ltd - Defense Agency');
|
How many defense contract negotiations occurred in Q1 2022?
|
SELECT COUNT(*) FROM Q1ContractNegotiations WHERE negotiation_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50)); CREATE TABLE container_types (container_type_id INT, container_type VARCHAR(50), capacity INT); CREATE TABLE container_inventory (id INT, vessel_id INT, container_type_id INT, quantity INT);
|
What is the maximum number of containers that can be carried by each vessel, grouped by container type?
|
SELECT v.vessel_name, ct.container_type, MAX(ci.quantity) as max_capacity FROM container_inventory ci JOIN vessels v ON ci.vessel_id = v.vessel_id JOIN container_types ct ON ci.container_type_id = ct.container_type_id GROUP BY v.vessel_name, ct.container_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists irrigation_data (id INT PRIMARY KEY, farm_id INT, water_usage FLOAT, usage_date DATE); CREATE TABLE if not exists recycled_water_usage (id INT PRIMARY KEY, sector VARCHAR(50), water_volume FLOAT, usage_date DATE); CREATE VIEW if not exists water_demand_recycled AS SELECT id.farm_id as farm_id, id.usage_date as usage_date, id.water_usage as water_demand, rwu.sector as sector, rwu.water_volume as recycled_water_volume FROM irrigation_data id JOIN recycled_water_usage rwu ON 1=1;
|
What is the total water demand and recycled water volume by sector for the past month?
|
SELECT sector, SUM(water_demand) as total_water_demand, SUM(recycled_water_volume) as total_recycled_water_volume FROM water_demand_recycled WHERE usage_date >= DATEADD(day, -30, CURRENT_DATE()) GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Berlin'), (2, 'Hamburg'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT); INSERT INTO packages (id, warehouse_id, weight) VALUES (1, 1, 50.3), (2, 1, 30.1), (3, 2, 70.0), (4, 2, 4.0);
|
What is the minimum weight of packages shipped from each warehouse, excluding shipments under 5 kg?
|
SELECT warehouse_id, MIN(weight) as min_weight FROM packages WHERE weight >= 5 GROUP BY warehouse_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (menu_id INT PRIMARY KEY, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), last_ordered TIMESTAMP);
|
Update menu item prices in the 'Appetizers' category that have not been ordered in the last month by 10%
|
UPDATE menu_items SET price = price * 1.1 WHERE category = 'Appetizers' AND last_ordered < NOW() - INTERVAL 1 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Bud Mart', 'OR'), (2, 'Green Earth', 'WA'), (3, 'Emerald City', 'WA');
|
How many dispensaries are there in Oregon and Washington?
|
SELECT COUNT(*) as dispensary_count FROM Dispensaries WHERE state IN ('OR', 'WA');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses (WarehouseID INT, City VARCHAR(20)); INSERT INTO Warehouses (WarehouseID, City) VALUES (1, 'New York'), (2, 'Los Angeles'); CREATE TABLE Shipments (ShipmentID INT, OriginWarehouseID INT, DestinationWarehouseID INT, Pallets INT); INSERT INTO Shipments (ShipmentID, OriginWarehouseID, DestinationWarehouseID, Pallets) VALUES (1, 1, 2, 50), (2, 1, 2, 75);
|
Show the total number of pallets for all shipments from 'New York' to 'Los Angeles'.
|
SELECT SUM(Shipments.Pallets) AS TotalPallets FROM Shipments JOIN Warehouses ON Shipments.OriginWarehouseID = Warehouses.WarehouseID WHERE Warehouses.City = 'New York' JOIN Warehouses AS DestinationWarehouses ON Shipments.DestinationWarehouseID = DestinationWarehouses.WarehouseID WHERE DestinationWarehouses.City = 'Los Angeles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryPersonnel (id INT, contractor VARCHAR(50), country VARCHAR(50), personnel INT); INSERT INTO MilitaryPersonnel (id, contractor, country, personnel) VALUES (1, 'Larsen & Toubro', 'India', 10000), (2, 'Tata Advanced Systems', 'India', 8000), (3, 'Bharat Electronics', 'India', 9000);
|
What is the maximum number of military personnel employed by a defense contractor in India?
|
SELECT MAX(personnel) FROM MilitaryPersonnel WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name TEXT, department TEXT, salary INT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'Engineering', 70000), (2, 'Jane Smith', 'Management', 90000), (3, 'Bob Johnson', 'Assembly', 50000), (4, 'Alice Williams', 'Engineering', 75000), (5, 'Charlie Brown', 'Assembly', 55000), (6, 'Janet Doe', 'Quality', 60000), (7, 'Jim Smith', 'Management', 85000), (8, 'Jake Johnson', 'Assembly', 60000);
|
Find the total number of employees in each department who earn a salary greater than the average salary for that department.
|
SELECT department, COUNT(*) as total_employees FROM employees WHERE salary > (SELECT AVG(salary) FROM employees WHERE department = e.department) GROUP BY department;
|
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.