context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Visitors (id INT, community_identifier VARCHAR(255), visit_date DATE); CREATE TABLE CommunityIdentifiers (id INT, name VARCHAR(255));
|
What is the number of visitors from historically underrepresented communities who visited the museum in 2021?
|
SELECT COUNT(*) FROM Visitors INNER JOIN CommunityIdentifiers ON Visitors.community_identifier = CommunityIdentifiers.name WHERE CommunityIdentifiers.name IN ('Historically Underrepresented Community 1', 'Historically Underrepresented Community 2') AND Visitors.visit_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (factory_id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), avg_labor_cost DECIMAL(5,2)); INSERT INTO Factories (factory_id, name, country, avg_labor_cost) VALUES (1, 'Star Textile', 'Bangladesh', 1.50), (2, 'Green Garments', 'India', 2.00);
|
What is the average labor cost for factories in Bangladesh?
|
SELECT avg_labor_cost FROM Factories WHERE country = 'Bangladesh';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_weather (id INT, date DATE, temperature FLOAT, region VARCHAR(50));
|
What is the minimum temperature recorded in the 'arctic_weather' table for each month in the year 2020, broken down by region ('region' column in the 'arctic_weather' table)?
|
SELECT MONTH(date) AS month, region, MIN(temperature) AS min_temp FROM arctic_weather WHERE YEAR(date) = 2020 GROUP BY month, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE neodymium_prices (country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO neodymium_prices (country, price) VALUES ('Australia', 95.50), ('Australia', 97.25), ('China', 76.30);
|
What is the average market price of Neodymium produced in Australia?
|
SELECT AVG(price) FROM neodymium_prices WHERE country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, type VARCHAR(20), location VARCHAR(20), report_date DATE); INSERT INTO crimes (id, type, location, report_date) VALUES (1, 'theft', 'downtown', '2021-12-01');
|
What is the total number of reported crimes in the 'downtown' and 'uptown' precincts in the month of December 2021, grouped by crime type?
|
SELECT type, COUNT(*) FROM crimes WHERE location IN ('downtown', 'uptown') AND report_date BETWEEN '2021-12-01' AND '2021-12-31' GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurant (id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO Restaurant (id, name, city) VALUES (1, 'Austin Eats', 'Austin'); INSERT INTO Restaurant (id, name, city) VALUES (2, 'BBQ Bites', 'Dallas'); CREATE TABLE Menu (id INT, restaurant_id INT, name VARCHAR(50), carbs INT); INSERT INTO Menu (id, restaurant_id, name, carbs) VALUES (1, 1, 'Veggie Burger', 30); INSERT INTO Menu (id, restaurant_id, name, carbs) VALUES (2, 1, 'Salad', 10); INSERT INTO Menu (id, restaurant_id, name, carbs) VALUES (3, 2, 'Brisket', 50); INSERT INTO Menu (id, restaurant_id, name, carbs) VALUES (4, 2, 'Sausage', 40);
|
Which restaurants in Austin, TX serve dishes with low carbohydrate content?
|
SELECT r.name FROM Restaurant r JOIN Menu m ON r.id = m.restaurant_id WHERE r.city = 'Austin' AND m.carbs < 20;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vaccinations (country VARCHAR(255), region VARCHAR(255), year INT, percentage DECIMAL(5,2)); INSERT INTO vaccinations (country, region, year, percentage) VALUES ('Country A', 'Northern Europe', 2020, 0.8), ('Country B', 'Northern Europe', 2020, 0.9);
|
What is the percentage of people vaccinated in Northern Europe in 2020?
|
SELECT AVG(percentage) FROM vaccinations WHERE region = 'Northern Europe' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restorative_justice (id INT, case_type VARCHAR(20), location VARCHAR(50), date DATE); INSERT INTO restorative_justice (id, case_type, location, date) VALUES (1, 'Mediation', 'New York', '2021-01-01'); CREATE TABLE criminal_justice (id INT, case_type VARCHAR(20), location VARCHAR(50), date DATE); INSERT INTO criminal_justice (id, case_type, location, date) VALUES (1, 'Prosecution', 'Los Angeles', '2021-01-02');
|
What is the total number of cases in the 'restorative_justice' and 'criminal_justice' tables?
|
SELECT COUNT(*) FROM (SELECT * FROM restorative_justice UNION ALL SELECT * FROM criminal_justice) AS total_cases;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_productivity (site_id INT, date DATE, workers_on_site INT, total_production FLOAT); INSERT INTO labor_productivity (site_id, date, workers_on_site, total_production) VALUES (1, '2021-01-01', 200, 5000), (1, '2021-01-02', 210, 5150), (2, '2021-01-01', 150, 3000), (2, '2021-01-02', 160, 3200);
|
What is the daily production per worker for site 2?
|
SELECT date, AVG(total_production/workers_on_site) as avg_daily_production FROM labor_productivity WHERE site_id = 2 GROUP BY date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SiteG (site_id INT, artifact_name VARCHAR(50), description TEXT); INSERT INTO SiteG (site_id, artifact_name, description) VALUES (101, 'Clay Pot', 'Fragments of ancient pottery'), (102, 'Bronze Amulet', 'An ancient protective amulet');
|
Which site has the 'Clay Pot' artifact?
|
SELECT site_id FROM SiteG WHERE artifact_name = 'Clay Pot';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(255), vulnerability_level VARCHAR(255), occurrence_count INT, occurrence_date DATE); INSERT INTO vulnerabilities (id, sector, vulnerability_level, occurrence_count, occurrence_date) VALUES (1, 'Government', 'Critical', 10, '2021-07-01');
|
How many critical vulnerabilities were found in the government sector in Europe in Q3 2021?
|
SELECT SUM(occurrence_count) AS total_critical_vulnerabilities FROM vulnerabilities WHERE sector = 'Government' AND vulnerability_level = 'Critical' AND occurrence_date >= '2021-07-01' AND occurrence_date < '2021-10-01' AND region = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing (id INT, date DATE, outreach_hours INT, PRIMARY KEY(id));
|
Insert new record '2022-03-01' for 'community_policing' table
|
INSERT INTO community_policing (id, date, outreach_hours) VALUES (1, '2022-03-01', 5);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drought_impact (region_id INT, drought_status VARCHAR(50), water_usage FLOAT);
|
Identify the number of drought-affected regions in the 'drought_impact' table with a water usage of more than 1000 cubic meters
|
SELECT COUNT(*) as num_drought_affected_regions FROM drought_impact WHERE drought_status = 'affected' AND water_usage > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Gender VARCHAR(10)); INSERT INTO Artists (ArtistID, ArtistName, Gender) VALUES (1, 'Taylor Swift', 'Female'), (2, 'Green Day', 'Male'); CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), ArtistID INT); INSERT INTO Songs (SongID, SongName, ArtistID) VALUES (1, 'Love Story', 1), (2, 'American Idiot', 2); CREATE TABLE Albums (AlbumID INT, AlbumName VARCHAR(100), ArtistID INT); INSERT INTO Albums (AlbumID, AlbumName, ArtistID) VALUES (1, 'Fearless', 1), (2, 'American Idiot', 2);
|
What is the total number of songs and albums released by female artists?
|
SELECT COUNT(DISTINCT s.SongID) + COUNT(DISTINCT a.AlbumID) AS TotalReleases FROM Artists a JOIN Songs s ON a.ArtistID = s.ArtistID JOIN Albums al ON a.ArtistID = al.ArtistID WHERE a.Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_training (country VARCHAR(255), trainee_count INT, training_date DATE);
|
Who are the top 3 countries that have received military training from Japan since 2015?
|
SELECT country, SUM(trainee_count) as total_trained FROM military_training WHERE training_date >= '2015-01-01' GROUP BY country ORDER BY total_trained DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soil (id INT PRIMARY KEY, type VARCHAR(50), nutrients VARCHAR(50), location VARCHAR(50)); INSERT INTO soil (id, type, nutrients, location) VALUES (1, 'Clay', 'Nitrogen, Phosphorus, Potassium', 'Winterfield');
|
What is the soil type and nutrients for the farms located in 'Winterfield'?
|
SELECT soil.type, soil.nutrients FROM soil WHERE soil.location = 'Winterfield';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_genres (genre_id INT, genre VARCHAR(50), PRIMARY KEY (genre_id)); INSERT INTO game_genres VALUES (1, 'Action'), (2, 'Adventure'), (3, 'RPG'), (4, 'Strategy'), (5, 'Simulation'); CREATE TABLE game_ratings (game_id INT, genre_id INT, player_rating FLOAT, PRIMARY KEY (game_id)); INSERT INTO game_ratings VALUES (1, 1, 8.5), (2, 1, 9.2), (3, 2, 7.8), (4, 2, 8.3), (5, 3, 9.0), (6, 3, 8.8), (7, 4, 7.5), (8, 4, 8.1), (9, 5, 9.2), (10, 5, 9.5);
|
Find the top 5 genres by average player rating in the gaming industry
|
SELECT g.genre, AVG(gr.player_rating) as avg_rating FROM game_genres g INNER JOIN game_ratings gr ON g.genre_id = gr.genre_id GROUP BY g.genre ORDER BY avg_rating DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), join_date DATE, total_likes INT); CREATE TABLE posts (id INT, user_id INT, content TEXT, posted_at TIMESTAMP, likes INT); INSERT INTO users (id, name, join_date, total_likes) VALUES (1, 'Alice', '2020-01-01', 100), (2, 'Bob', '2019-05-15', 150), (3, 'Charlie', '2021-03-03', 250); INSERT INTO posts (id, user_id, content, posted_at, likes) VALUES (1, 1, 'Hello World!', '2021-03-02 10:30:00', 20), (2, 2, 'Social Media', '2021-02-18 14:45:00', 30), (3, 3, 'Programming', '2021-03-01 09:00:00', 50), (4, 3, 'AI', '2021-03-01 10:00:00', 150);
|
Find users who liked a post with 'AI' in the content
|
SELECT u.id, u.name, p.content, p.likes FROM users u JOIN posts p ON u.id = p.user_id WHERE p.content LIKE '%AI%' AND u.id IN (SELECT user_id FROM posts WHERE content LIKE '%AI%');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rare_earth_elements_production (element VARCHAR(50), year INT, quantity INT); INSERT INTO rare_earth_elements_production (element, year, quantity) VALUES ('Neodymium', 2019, 125000), ('Praseodymium', 2019, 90000), ('Dysprosium', 2019, 4000), ('Lanthanum', 2019, 180000), ('Cerium', 2019, 250000);
|
How many Rare Earth Elements were produced in total in 2019?
|
SELECT SUM(quantity) FROM rare_earth_elements_production WHERE year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EuropiumProduction (id INT PRIMARY KEY, year INT, market_price DECIMAL(10,2));
|
What is the maximum market price of Europium in the last 3 years?
|
SELECT MAX(market_price) FROM EuropiumProduction WHERE year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garments (id INT, name VARCHAR(100), price DECIMAL(5,2), category VARCHAR(50));
|
List all garments and their corresponding categories, with prices greater than 30.00, from the garments table
|
SELECT id, name, category, price FROM garments WHERE price > 30.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Songs (SongID int, SongName varchar(100), Duration int, Language varchar(50), ArtistID int); INSERT INTO Songs VALUES (1, 'Viva la Vida', 250, 'Spanish', 1); INSERT INTO Songs VALUES (2, 'Hasta Siempre', 300, 'Spanish', 2); INSERT INTO Songs VALUES (3, 'Shape of You', 200, 'English', 3);
|
What is the total duration of songs released in Spanish?
|
SELECT SUM(Duration) FROM Songs WHERE Language = 'Spanish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifact_Types (Artifact_Type TEXT, Quantity INT);INSERT INTO Artifact_Types (Artifact_Type, Quantity) VALUES ('Pottery', 1200);INSERT INTO Artifact_Types (Artifact_Type, Quantity) VALUES ('Jewelry', 800);INSERT INTO Artifact_Types (Artifact_Type, Quantity) VALUES ('Bone Tools', 600);INSERT INTO Artifact_Types (Artifact_Type, Quantity) VALUES ('Stone Tools', 400);
|
What are the most common artifact types in our database?
|
SELECT Artifact_Type, Quantity FROM Artifact_Types ORDER BY Quantity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region_stats_2 (region TEXT, year INT, visitors INT); INSERT INTO region_stats_2 (region, year, visitors) VALUES ('Oceania', 2021, 50000), ('Europe', 2021, 80000), ('North America', 2021, 50000), ('New Zealand', 2021, 200000);
|
Determine the percentage of international visitors to New Zealand that are from the Oceania region.
|
SELECT 100.0 * SUM(CASE WHEN region = 'Oceania' THEN visitors ELSE 0 END) / SUM(visitors) as percentage FROM region_stats_2 WHERE year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Country (CountryName TEXT, Population INT); INSERT INTO Country VALUES ('India', 1390000000);
|
What is the population of India?
|
SELECT Population FROM Country WHERE CountryName = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE department_budgets (department TEXT, budget INT, year INT); INSERT INTO department_budgets (department, budget, year) VALUES ('research', 1000000, 2019), ('development', 1200000, 2019), ('research', 1100000, 2020), ('development', 1300000, 2020);
|
What is the difference in budget between the 'research' and 'development' departments for the year 2019?
|
SELECT LAG(budget, 1, 0) OVER (ORDER BY year) as prev_budget, budget, budget - LAG(budget, 1, 0) OVER (ORDER BY year) as budget_diff FROM department_budgets WHERE department IN ('research', 'development') AND year = 2019 AND budget IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workers (id INT, industry VARCHAR(255), salary FLOAT, union_member BOOLEAN); INSERT INTO workers (id, industry, salary, union_member) VALUES (1, 'Manufacturing', 50000.0, true), (2, 'Transportation', 90000.0, false), (3, 'Retail', 30000.0, false);
|
What is the maximum salary of workers in the 'Transportation' industry who are not part of a union?
|
SELECT MAX(salary) FROM workers WHERE industry = 'Transportation' AND union_member = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_projects (id INT PRIMARY KEY, project_name VARCHAR(255), status VARCHAR(255), planned_start_date DATE);
|
List all defense projects that have not started yet and their planned start dates, ordered by the planned start date in ascending order.
|
SELECT project_name, planned_start_date FROM defense_projects WHERE status != 'In Progress' AND status != 'Completed' ORDER BY planned_start_date ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE professionals (name TEXT, title TEXT, location TEXT); INSERT INTO professionals (name, title, location) VALUES ('Dr. Smith', 'Doctor', 'Rural Japan'), ('Nurse Johnson', 'Nurse', 'Rural Japan'), ('Dr. Brown', 'Doctor', 'Rural Japan');
|
How many healthcare professionals work in rural areas of Japan and how many of them are doctors?
|
SELECT COUNT(*), SUM(CASE WHEN title = 'Doctor' THEN 1 ELSE 0 END) FROM professionals WHERE location = 'Rural Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pipelines (pipeline_id INT, pipeline_name TEXT, start_point TEXT, end_point TEXT, length INT); INSERT INTO pipelines (pipeline_id, pipeline_name, start_point, end_point, length) VALUES (1, 'Pipeline A', 'Country A', 'Country B', 500), (2, 'Pipeline B', 'Country C', 'Country D', 600);
|
List all the gas pipelines and their respective lengths in the Middle East region.
|
SELECT pipeline_name, length FROM pipelines WHERE start_point = 'Country A' OR end_point = 'Country A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE qatar_platforms (platform_id INT, platform_name VARCHAR(50), location VARCHAR(50), operational_status VARCHAR(15)); INSERT INTO qatar_platforms VALUES (1, 'Qatargas 1', 'Qatar', 'Active'); INSERT INTO qatar_platforms VALUES (2, 'RasGas 1', 'Qatar', 'Active'); CREATE TABLE lng_production (platform_id INT, year INT, production FLOAT); INSERT INTO lng_production VALUES (1, 2015, 12000000); INSERT INTO lng_production VALUES (1, 2016, 13000000); INSERT INTO lng_production VALUES (2, 2015, 10000000); INSERT INTO lng_production VALUES (2, 2016, 11000000);
|
What is the total liquefied natural gas (LNG) production for each platform in Qatar?
|
SELECT platform_id, SUM(production) FROM lng_production JOIN qatar_platforms ON lng_production.platform_id = qatar_platforms.platform_id GROUP BY platform_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, water_type TEXT, water_temperature DECIMAL(5,2)); INSERT INTO fish_farms (id, name, location, water_type, water_temperature) VALUES (1, 'Tuna Farm', 'Australia', 'tropical', 24.5), (2, 'Patagonian Toothfish Farm', 'Argentina', 'cold', 4.0);
|
What is the average water temperature in fish farms located in the Southern Hemisphere in July?
|
SELECT AVG(water_temperature) FROM fish_farms WHERE EXTRACT(MONTH FROM date) = 7 AND ABS(latitude) > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EmployeeData (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2)); INSERT INTO EmployeeData VALUES (1, 'John', 'Doe', 'IT', 50000); INSERT INTO EmployeeData VALUES (2, 'Jane', 'Doe', 'HR', 75000); INSERT INTO EmployeeData VALUES (3, 'Mike', 'Johnson', 'Finance', 60000); INSERT INTO EmployeeData VALUES (4, 'Fatima', 'Khan', 'Admin', 45000);
|
Update the salary of all employees in the 'Admin' department by 5% and insert a new record with an ID of 6, a salary of 48000, and the same first and last name as the employee with the highest salary in that department.
|
UPDATE EmployeeData SET Salary = Salary * 1.05 WHERE Department = 'Admin'; INSERT INTO EmployeeData (EmployeeID, FirstName, LastName, Department, Salary) SELECT EmployeeID, FirstName, LastName, 'Admin', MAX(Salary) * 0.95 FROM EmployeeData WHERE Department = 'Admin';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Branch (BranchID INT PRIMARY KEY, Name VARCHAR(50)); INSERT INTO Branch (BranchID, Name) VALUES (1, 'Army'), (2, 'Navy'), (3, 'Air Force'); CREATE TABLE Drone (DroneID INT PRIMARY KEY, Name VARCHAR(50), BranchID INT, FOREIGN KEY (BranchID) REFERENCES Branch(BranchID)); INSERT INTO Drone (DroneID, Name, BranchID) VALUES (1, 'Predator', 1), (2, 'Sea Hunter', 2), (3, 'Global Hawk', 3);
|
Which military branches have acquired drone technology?
|
SELECT Branch.Name FROM Branch INNER JOIN Drone ON Branch.BranchID = Drone.BranchID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (id INT, city VARCHAR(20), sustainable BOOLEAN); INSERT INTO initiatives (id, city, sustainable) VALUES (1, 'Tokyo', TRUE), (2, 'Osaka', FALSE);
|
What is the total number of sustainable urbanism initiatives in Tokyo?
|
SELECT COUNT(*) FROM initiatives WHERE city = 'Tokyo' AND sustainable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workouts (id INT, user_location VARCHAR(50), workout_date DATE, avg_heart_rate INT); INSERT INTO workouts (id, user_location, workout_date, avg_heart_rate) VALUES (1, 'Tokyo', '2022-01-01', 130), (2, 'Sydney', '2022-01-02', 75);
|
How many users have a heart rate over 100 during their workouts in each location?
|
SELECT user_location, COUNT(*) FROM workouts WHERE avg_heart_rate > 100 GROUP BY user_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE health_equity_metrics (id INT, metric_name VARCHAR(255), score INT);
|
Update the 'health_equity_metrics' table and change the 'Score' to 95 where 'Metric_Name' is 'Language Accessibility'
|
UPDATE health_equity_metrics SET score = 95 WHERE metric_name = 'Language Accessibility';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (brand VARCHAR(255), has_size_inclusion BOOLEAN, price DECIMAL(10,2)); INSERT INTO Products (brand, has_size_inclusion, price) VALUES ('BrandA', TRUE, 55.00), ('BrandB', FALSE, 35.00), ('BrandC', TRUE, 80.00), ('BrandD', FALSE, 40.00), ('BrandE', TRUE, 65.00), ('BrandF', FALSE, 20.00), ('BrandG', TRUE, 70.00), ('BrandH', FALSE, 45.00);
|
What is the average price of size-inclusive products for each brand?
|
SELECT brand, AVG(price) as avg_price FROM Products WHERE has_size_inclusion = TRUE GROUP BY brand;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_productivity (site_id INT, date DATE, workers_on_site INT, total_production FLOAT); INSERT INTO labor_productivity (site_id, date, workers_on_site, total_production) VALUES (9, '2021-04-01', 210, 5500), (9, '2021-04-02', 215, 5650), (9, '2021-04-03', 208, 5450), (9, '2021-05-01', 220, 5800), (9, '2021-05-02', 225, 5950), (9, '2021-05-03', 218, 5750), (9, '2021-06-01', 230, 6000), (9, '2021-06-02', 235, 6150), (9, '2021-06-03', 228, 6050);
|
What's the maximum daily production for site 9 in the second quarter of 2021?
|
SELECT MAX(total_production) FROM labor_productivity WHERE site_id = 9 AND date BETWEEN '2021-04-01' AND '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TVShows (ShowID INT, Title VARCHAR(255), ReleaseYear INT, Genre VARCHAR(50), IMDbRating DECIMAL(3,2));
|
How many TV shows were released per year in the 'Drama' genre and their average IMDb ratings?
|
SELECT ReleaseYear, Genre, COUNT(Title) AS Number_Of_Shows, AVG(IMDbRating) AS Avg_Rating FROM TVShows WHERE Genre = 'Drama' GROUP BY ReleaseYear, Genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AdoptionStatistics (Id INT, Country VARCHAR(100), Year INT, AdoptionRate FLOAT); INSERT INTO AdoptionStatistics (Id, Country, Year, AdoptionRate) VALUES (1, 'China', 2018, 2.1), (2, 'Japan', 2018, 1.8), (3, 'China', 2019, 3.2), (4, 'Japan', 2019, 2.3);
|
What is the average adoption rate of electric vehicles in Asia?
|
SELECT AVG(AdoptionRate) FROM AdoptionStatistics WHERE Country IN ('China', 'Japan') AND Year >= 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_wellbeing (id INT, name VARCHAR(50), financial_score INT, date DATE); INSERT INTO financial_wellbeing (id, name, financial_score, date) VALUES (5, 'Zainab', 70, '2022-05-01'), (5, 'Zainab', 75, '2022-06-01');
|
Insert new records for customer 1006 into the financial_wellbeing table with a financial_score of 70 for May 2022 and 75 for June 2022.
|
INSERT INTO financial_wellbeing (id, name, financial_score, date) VALUES (5, 'Zainab', 70, '2022-05-01'), (5, 'Zainab', 75, '2022-06-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Orders (OrderID INT, SupplierID INT, OrderDate DATE); INSERT INTO Orders (OrderID, SupplierID, OrderDate) VALUES (1, 1, '2021-02-15'), (2, 2, '2021-03-01'), (3, 1, '2021-07-05');
|
How many times has 'Farm Fresh' delivered since January 2021?
|
SELECT COUNT(*) FROM Orders WHERE SupplierID = (SELECT SupplierID FROM Suppliers WHERE SupplierName = 'Farm Fresh') AND OrderDate >= '2021-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW field_temperatures AS SELECT fields.field_name, field_sensors.temperature, field_sensors.measurement_date FROM fields JOIN field_sensors ON fields.id = field_sensors.field_id;
|
What is the maximum temperature for each field in the 'field_temperatures' view?
|
SELECT field_name, MAX(temperature) as max_temp FROM field_temperatures GROUP BY field_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geothermal_energy_projects (id INT, project_name VARCHAR(50), state VARCHAR(50), carbon_offset FLOAT); INSERT INTO geothermal_energy_projects (id, project_name, state, carbon_offset) VALUES (1, 'California Geothermal Power Plant', 'California', 10000);
|
What is the average carbon offset of geothermal energy projects in the state of California?
|
SELECT AVG(carbon_offset) FROM geothermal_energy_projects WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, actor_id INT); INSERT INTO movies (id, title, genre, release_year, actor_id) VALUES (1, 'Movie1', 'Comedy', 2020, 101); INSERT INTO movies (id, title, genre, release_year, actor_id) VALUES (2, 'Movie2', 'Drama', 2019, 101); INSERT INTO movies (id, title, genre, release_year, actor_id) VALUES (3, 'Movie3', 'Action', 2018, 102);
|
Who are the actors that have acted in both 'Comedy' and 'Drama' genres?
|
SELECT actor_id FROM movies WHERE genre = 'Comedy' INTERSECT SELECT actor_id FROM movies WHERE genre = 'Drama';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DysprosiumMarketPrices (quarter VARCHAR(10), year INT, price DECIMAL(5,2)); INSERT INTO DysprosiumMarketPrices (quarter, year, price) VALUES ('Q2', 2022, 260.50), ('Q2', 2022, 262.30), ('Q3', 2022, 270.00), ('Q3', 2022, 268.80);
|
Find the average market price of Dysprosium in Q2 and Q3 2022.
|
SELECT AVG(price) FROM DysprosiumMarketPrices WHERE quarter IN ('Q2', 'Q3') AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name TEXT, location TEXT); CREATE TABLE patients (id INT, name TEXT, hospital_id INT); INSERT INTO hospitals (id, name, location) VALUES (1, 'Hospital A', 'Rural Oregon'); INSERT INTO hospitals (id, name, location) VALUES (7, 'Hospital G', 'Rural Oregon'); INSERT INTO patients (id, name, hospital_id) VALUES (1, 'Patient A', 1); INSERT INTO patients (id, name, hospital_id) VALUES (2, 'Patient B', 1); INSERT INTO patients (id, name, hospital_id) VALUES (3, 'Patient C', 7);
|
What is the number of patients in each hospital in rural Oregon?
|
SELECT hospitals.name, COUNT(patients.id) FROM hospitals INNER JOIN patients ON hospitals.id = patients.hospital_id WHERE hospitals.location = 'Rural Oregon' GROUP BY hospitals.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_facilities (id INT, city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), type VARCHAR(255), capacity INT);
|
Update the 'capacity' of the recycling facility in 'Toronto', 'Ontario', 'Canada' to 200,000 tons
|
UPDATE recycling_facilities SET capacity = 200000 WHERE city = 'Toronto' AND state = 'Ontario' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, region TEXT, funding FLOAT); INSERT INTO companies (id, name, region, funding) VALUES (1, 'Startup A', 'west_coast', 5000000), (2, 'Startup B', 'east_coast', 3000000), (3, 'Startup C', 'west_coast', 7000000), (4, 'Startup D', 'east_coast', 8000000), (5, 'Startup E', 'south', 6000000), (6, 'Startup F', 'midwest', 9000000);
|
Find the region with the highest average funding amount
|
SELECT region FROM companies GROUP BY region HAVING AVG(funding) = (SELECT MAX(avg_funding) FROM (SELECT AVG(funding) AS avg_funding FROM companies GROUP BY region) AS subquery);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trips(id INT, ship_id INT, month INT, year INT, containers INT); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (1, 1, 1, 2021, 3000); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (2, 1, 2, 2021, 3500); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (3, 1, 3, 2021, 4000); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (4, 1, 4, 2021, 4500); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (5, 2, 1, 2021, 5000); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (6, 2, 2, 2021, 5500); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (7, 2, 3, 2021, 6000); INSERT INTO trips(id, ship_id, month, year, containers) VALUES (8, 2, 4, 2021, 6500);
|
What is the total number of containers transported by the fleet between January and April 2021?
|
SELECT SUM(containers) FROM trips WHERE month BETWEEN 1 AND 4 AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Sneaker 1', 'sneakers'), (2, 'Sneaker 2', 'sandals'); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); INSERT INTO users (user_id, user_country) VALUES (1, 'USA'), (2, 'Canada'); CREATE TABLE orders (order_id INT, user_id INT, product_id INT, order_date DATE, revenue DECIMAL(10, 2)); INSERT INTO orders (order_id, user_id, product_id, order_date, revenue) VALUES (1, 1, 1, '2022-01-01', 100), (2, 2, 1, '2022-01-05', 120);
|
What was the total revenue from users in the US and Canada for the 'sneakers' product category in Q1 2022?
|
SELECT SUM(revenue) FROM orders o JOIN products p ON o.product_id = p.product_id JOIN users u ON o.user_id = u.user_id WHERE u.user_country IN ('USA', 'Canada') AND p.category = 'sneakers' AND o.order_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grades_gender (grade_id INT, grade_level INT, student_id INT, mental_health_score INT, gender VARCHAR(10)); INSERT INTO grades_gender (grade_id, grade_level, student_id, mental_health_score, gender) VALUES (1, 11, 1, 75, 'Female'), (2, 10, 2, 85, 'Male'), (3, 11, 3, 80, 'Female'), (4, 12, 4, 70, 'Non-binary'), (5, 11, 5, 85, 'Male');
|
What is the distribution of mental health scores for students in grade 11 by gender?
|
SELECT grade_level, gender, AVG(mental_health_score) as avg_score FROM grades_gender WHERE grade_level = 11 GROUP BY grade_level, gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Irrigation (id INT, farm_id INT, date DATE, duration INT); INSERT INTO Irrigation (id, farm_id, date, duration) VALUES (1, 1, '2022-05-01', 60); INSERT INTO Irrigation (id, farm_id, date, duration) VALUES (2, 2, '2022-05-05', 90); INSERT INTO Irrigation (id, farm_id, date, duration) VALUES (3, 3, '2022-05-03', 75); INSERT INTO Irrigation (id, farm_id, date, duration) VALUES (4, 4, '2022-05-02', 55);
|
Which farmers in Argentina have more than 50 irrigation events?
|
SELECT f.name FROM Farmers f JOIN Irrigation i ON f.id = i.farm_id WHERE f.country = 'Argentina' GROUP BY f.name HAVING COUNT(i.id) > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists rural_healthcare; USE rural_healthcare; CREATE TABLE Hospitals (id INT, name VARCHAR(100), location VARCHAR(100), beds INT, community_type VARCHAR(50)); INSERT INTO Hospitals VALUES (1, 'Rural General Hospital', 'Smalltown', 50, 'Indigenous'), (2, 'Mountain View Clinic', 'Mountain Village', 15, 'Non-Indigenous'), (3, 'Seaside Health Center', 'Coastal City', 25, 'Non-Indigenous'), (4, 'Northern Lights Hospital', 'Remote Arctic', 10, 'Indigenous');
|
What is the average number of hospital beds in Indigenous communities?
|
SELECT AVG(beds) FROM Hospitals WHERE community_type = 'Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teacher_pd (teacher_id INT, course_id INT, completion_date DATE); INSERT INTO teacher_pd (teacher_id, course_id, completion_date) VALUES (1, 1001, '2020-01-01'), (1, 1002, '2020-06-01'), (2, 1001, '2019-12-31'), (3, 1003, '2021-03-15'), (3, 1004, '2019-09-01');
|
What is the percentage of professional development courses completed by teachers in the last year out of the total number of courses they completed?
|
SELECT teacher_id, 100.0 * SUM(CASE WHEN completion_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) THEN 1 ELSE 0 END) / COUNT(*) AS pct_last_year FROM teacher_pd GROUP BY teacher_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE annual_timber_production (id INT, species VARCHAR(255), volume FLOAT); INSERT INTO annual_timber_production (id, species, volume) VALUES (1, 'Oak', 500), (2, 'Maple', 400), (3, 'Pine', 600);
|
Identify the total volume of timber produced by each species in the 'annual_timber_production' table.
|
SELECT species, SUM(volume) FROM annual_timber_production GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meals_served (id INT PRIMARY KEY, camp VARCHAR(50), month VARCHAR(20), day INT, number INT); INSERT INTO meals_served (id, camp, month, day, number) VALUES (1, 'Camp A', 'April', 1, 1500), (2, 'Camp B', 'April', 1, 1200), (3, 'Camp A', 'April', 2, 1600), (4, 'Camp B', 'April', 2, 1400), (5, 'Camp A', 'Ramadan', 1, 1700), (6, 'Camp B', 'Ramadan', 1, 1500);
|
What is the average number of meals served daily in refugee camps during Ramadan?
|
SELECT AVG(number) FROM meals_served WHERE month = 'Ramadan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fair_labor_practices (practice_id INT, brand_id INT, region TEXT, workers_benefitted INT); CREATE VIEW fair_labor_practices_summary AS SELECT region, SUM(workers_benefitted) AS total_workers FROM fair_labor_practices GROUP BY region;
|
How many workers benefitted from fair labor practices in each region?
|
SELECT region, total_workers FROM fair_labor_practices_summary;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_agencies (agency_id INT, name VARCHAR(255), country VARCHAR(255), satellites_launched INT); INSERT INTO space_agencies (agency_id, name, country, satellites_launched) VALUES (1, 'SpaceX', 'USA', 1900);
|
How many defunct satellites has each space agency launched?
|
SELECT agency_id, name, country, SUM(CASE WHEN type = 'Defunct Satellite' THEN 1 ELSE 0 END) as defunct_satellites FROM space_agencies s JOIN space_debris d ON s.agency_id = d.source GROUP BY agency_id, name, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_year INT, gender VARCHAR(10));
|
Insert a new donor with donor_id 4, donation amount $8000 in 2021, and gender 'non-binary'.
|
INSERT INTO donors (donor_id, donation_amount, donation_year, gender) VALUES (4, 8000.00, 2021, 'non-binary');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Temp_Trend (date DATE, temperature INT, crop_type VARCHAR(20));
|
What is the trend in temperature for each crop type over the past 5 years?
|
SELECT crop_type, temperature, ROW_NUMBER() OVER(PARTITION BY crop_type ORDER BY date DESC) as rank, AVG(temperature) OVER(PARTITION BY crop_type ORDER BY date ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) as avg_temp FROM Temp_Trend WHERE date >= DATEADD(year, -5, CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accommodations (ID INT, Type VARCHAR(50), Cost FLOAT, Region VARCHAR(50)); INSERT INTO Accommodations (ID, Type, Cost, Region) VALUES (1, 'Note-taking Services', 15000.0, 'Northeast'), (2, 'Accessible Furniture', 20000.0, 'Northeast');
|
What is the total budget allocated for accommodations in the Northeast?
|
SELECT SUM(Cost) FROM Accommodations WHERE Region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), establishment_date DATE); INSERT INTO Suppliers (id, name, country, establishment_date) VALUES (1, 'Supplier A', 'USA', '2000-01-01'); INSERT INTO Suppliers (id, name, country, establishment_date) VALUES (2, 'Supplier B', 'Canada', '2005-01-01'); INSERT INTO Suppliers (id, name, country, establishment_date) VALUES (3, 'Supplier C', 'UK', '1998-04-03'); CREATE TABLE Products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES Suppliers(id)); INSERT INTO Products (id, name, category, supplier_id) VALUES (1, 'Product A', 'Tops', 1); INSERT INTO Products (id, name, category, supplier_id) VALUES (2, 'Product B', 'Bottoms', 2); INSERT INTO Products (id, name, category, supplier_id) VALUES (4, 'Product D', 'Shoes', 3);
|
What are the products supplied by a UK-based supplier?
|
SELECT Products.name FROM Products INNER JOIN Suppliers ON Products.supplier_id = Suppliers.id WHERE Suppliers.country = 'UK'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Articles (id INT, title VARCHAR(255), publish_date DATE); INSERT INTO Articles (id, title, publish_date) VALUES (1, 'Article 1', '2023-01-01'), (2, 'Article 2', '2023-01-02'), (3, 'Article 3', '2023-01-03'), (4, 'Article 4', '2023-01-04'), (5, 'Article 5', '2023-01-05'), (6, 'Article 6', '2023-01-06'), (7, 'Article 7', '2023-01-07'), (8, 'Article 8', '2023-01-08'), (9, 'Article 9', '2023-01-09'), (10, 'Article 10', '2023-01-10');
|
What is the earliest date an article was published?
|
SELECT MIN(publish_date) FROM Articles;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sf_prop(id INT, owner1 VARCHAR(20), owner2 VARCHAR(20), owner3 VARCHAR(20)); INSERT INTO sf_prop VALUES (1, 'Irene', 'Jack', 'Kevin'), (2, 'Lena', 'Michael', 'Nina');
|
Display the property co-owners in San Francisco who share a property with more than one other co-owner.
|
SELECT owner1, owner2, owner3 FROM sf_prop WHERE (owner1 <> owner2 AND owner1 <> owner3) OR (owner2 <> owner1 AND owner2 <> owner3) GROUP BY owner1, owner2, owner3 HAVING COUNT(*) > 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, donation_date DATE); INSERT INTO donors (id, name, donation_date) VALUES (1, 'John Doe', '2022-01-15'), (2, 'Jane Smith', '2022-02-10'), (3, 'Michael Brown', '2022-02-25'), (4, 'Sara Johnson', '2022-03-05'); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 500.00), (2, 1, 250.00), (3, 2, 100.00), (4, 3, 800.00), (5, 3, 1200.00), (6, 4, 1500.00);
|
Find the top 3 donors by total donation amount in Q1 2022.
|
SELECT d.name, SUM(donations.amount) as total_donation FROM donors d INNER JOIN donations ON d.id = donations.donor_id WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY d.id ORDER BY total_donation DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_techniques (application VARCHAR(255), technique VARCHAR(255)); INSERT INTO ai_techniques (application, technique) VALUES ('CreativeApp1', 'ExplainableTech1'); INSERT INTO ai_techniques (application, technique) VALUES ('CreativeApp2', 'ExplainableTech2');
|
What are the explainable AI techniques used in creative AI applications, grouped by technique?
|
SELECT technique, COUNT(*) as num_applications FROM ai_techniques WHERE application LIKE '%Creative%' GROUP BY technique ORDER BY num_applications DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, title VARCHAR(255), artist VARCHAR(255), period VARCHAR(255), price FLOAT); INSERT INTO Artworks (id, title, artist, period, price) VALUES (2, 'Starry Night Over the Rhone', 'Van Gogh', 'Post-Impressionism', 7300000);
|
Update the title of the artwork with ID 2 to 'The Starry Night'.
|
UPDATE Artworks SET title = 'The Starry Night' WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY, contract_name VARCHAR(100), contract_language VARCHAR(50), contract_size INT);
|
Delete records from the 'smart_contracts' table where the 'contract_language' is 'Go' and the 'contract_size' is greater than 20000
|
DELETE FROM smart_contracts WHERE contract_language = 'Go' AND contract_size > 20000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite_Agency (Satellite_Name VARCHAR(50), Agency VARCHAR(50), Launch_Date DATETIME); INSERT INTO Satellite_Agency (Satellite_Name, Agency, Launch_Date) VALUES ('Galileo', 'ESA', '2011-10-21'), ('Sentinel-1A', 'ESA', '2014-04-03'), ('Sentinel-2A', 'ESA', '2015-06-23'), ('Terra', 'NASA', '1999-12-18');
|
Identify the number of satellites launched by each agency and their earliest launched satellite.
|
SELECT Agency, COUNT(Satellite_Name) AS Number_Of_Satellites, MIN(Launch_Date) AS Earliest_Launched_Satellite FROM Satellite_Agency GROUP BY Agency;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE travel_advisories (id INT, title TEXT, country TEXT, risk_level INT, date DATE);
|
Insert new travel advisories for 'Canada' with a risk level of 2 and a date of '2023-03-15'.
|
INSERT INTO travel_advisories (id, title, country, risk_level, date) VALUES (1, 'Advisory 1', 'Canada', 2, '2023-03-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers2022 (VolunteerID int, VolunteerName varchar(50), VolunteerDate date, Community varchar(50)); INSERT INTO Volunteers2022 (VolunteerID, VolunteerName, VolunteerDate, Community) VALUES (1, 'Alice Johnson', '2022-01-01', 'African American'); INSERT INTO Volunteers2022 (VolunteerID, VolunteerName, VolunteerDate, Community) VALUES (2, 'Bob Brown', '2022-02-15', 'Hispanic');
|
How many volunteers joined in H1 2022 from historically marginalized communities?
|
SELECT COUNT(*) FROM Volunteers2022 WHERE VolunteerDate BETWEEN '2022-01-01' AND '2022-06-30' AND Community IN ('African American', 'Hispanic', 'Native American', 'LGBTQ+', 'People with Disabilities');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (id INT PRIMARY KEY, species VARCHAR(255), population INT, year INT);
|
Find animal species with declining population trends
|
SELECT species, population FROM animal_population WHERE population < (SELECT population FROM animal_population WHERE species = a.species AND year = (SELECT MAX(year) FROM animal_population WHERE species = a.species)) AND year < (SELECT MAX(year) FROM animal_population WHERE species = a.species);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_vehicles (id INT, model VARCHAR(50), manufacturing_country VARCHAR(50));
|
Insert new data into the 'autonomous_vehicles' table
|
INSERT INTO autonomous_vehicles (id, model, manufacturing_country) VALUES (1, 'Nuro', 'United States');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product VARCHAR(255), price DECIMAL(10,2), vegetarian BOOLEAN); INSERT INTO products (product, price, vegetarian) VALUES ('Bruschetta', 7.99, true), ('Calamari', 8.99, false), ('Lasagna', 15.99, false), ('Risotto', 16.99, true), ('Tiramisu', 6.99, false), ('Cheesecake', 7.99, false);
|
Determine the average price of vegetarian products
|
SELECT AVG(price) as avg_price FROM products WHERE vegetarian = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tv_show_ratings (title VARCHAR(255), release_year INT, rating DECIMAL(3,2)); INSERT INTO tv_show_ratings (title, release_year, rating) VALUES ('TVShow1', 2016, 8.3), ('TVShow2', 2017, 8.7), ('TVShow3', 2018, 7.9), ('TVShow4', 2019, 8.9), ('TVShow5', 2020, 9.1), ('TVShow6', 2021, 8.5), ('TVShow7', 2022, 8.6);
|
Get the top 5 TV shows with the highest ratings released after 2015.
|
SELECT title, rating FROM tv_show_ratings WHERE release_year > 2015 ORDER BY rating DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME, HistoricalSignificance TEXT); INSERT INTO Artifacts (ArtifactID, Name, CreationDate, HistoricalSignificance) VALUES (1, 'Ancient Dagger', '1500-01-01', 'Ceremonial weapon of ancient civilization'), (2, 'Modern Artifact', '2022-01-01', 'Artifact from recent excavation');
|
What is the historical significance of the artifact with the latest creation date?
|
SELECT HistoricalSignificance FROM (SELECT Name, CreationDate, HistoricalSignificance, ROW_NUMBER() OVER (ORDER BY CreationDate DESC) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE refugees (id INT, organization VARCHAR(255), location VARCHAR(255), assist_date DATE, gender VARCHAR(10), age INT); INSERT INTO refugees (id, organization, location, assist_date, gender, age) VALUES (1, 'UNHCR', 'Asia', '2017-02-12'), (2, 'Red Cross', 'Asia', '2017-04-01'), (3, 'Save the Children', 'Asia', '2018-03-21');
|
How many refugees were assisted by the Red Cross in Asia in 2017?
|
SELECT COUNT(*) as number_of_refugees FROM refugees WHERE organization = 'Red Cross' AND location = 'Asia' AND YEAR(assist_date) = 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_sources (cuisine VARCHAR(255), sustainability_score DECIMAL(10,2)); INSERT INTO sustainable_sources (cuisine, sustainability_score) VALUES ('Italian', 8.50), ('Mexican', 7.80), ('Italian', 8.70), ('Mexican', 7.90);
|
What is the average sustainable sourcing score for each cuisine type?
|
SELECT cuisine, AVG(sustainability_score) as avg_score FROM sustainable_sources GROUP BY cuisine;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Industrial_Buildings (state VARCHAR(255), rating INT); INSERT INTO Industrial_Buildings (state, rating) VALUES ('New South Wales', 70), ('Victoria', 75), ('Queensland', 65);
|
What is the average energy efficiency rating for industrial buildings in Australia, grouped by state?
|
SELECT state, AVG(rating) AS avg_rating FROM Industrial_Buildings GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, FavoriteGenre VARCHAR(50), VRPossible BOOLEAN); INSERT INTO Players (PlayerID, Name, Age, FavoriteGenre, VRPossible) VALUES (1, 'John Doe', 25, 'Action', false), (2, 'Jane Smith', 28, 'Adventure', false), (3, 'James Johnson', 30, 'Simulation', true), (4, 'Emily Davis', 24, 'Strategy', false);
|
What's the average age of players who play action games on non-VR platforms?
|
SELECT AVG(Age) FROM Players WHERE FavoriteGenre = 'Action' AND VRPossible = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE theater_performances (performance_id INT, performance_name VARCHAR(50), performance_date DATE); CREATE TABLE audience_demographics (visitor_id INT, performance_id INT, age INT); INSERT INTO theater_performances (performance_id, performance_name, performance_date) VALUES (1, 'Shakespeare Play', '2022-01-01'), (2, 'Opera Night', '2022-03-15'), (3, 'Musical', '2022-12-31'); INSERT INTO audience_demographics (visitor_id, performance_id, age) VALUES (1, 1, 45), (2, 1, 30), (3, 2, 50), (4, 2, 60), (5, 3, 25), (6, 3, 35);
|
What is the average age of visitors who attended theater performances in the last year?
|
SELECT AVG(age) as avg_age FROM audience_demographics d INNER JOIN theater_performances p ON d.performance_id = p.performance_id WHERE p.performance_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Intelligence_Operations (Name VARCHAR(255), Location VARCHAR(255)); INSERT INTO Intelligence_Operations (Name, Location) VALUES ('Operation Desert Spy', 'Middle East'), ('Operation Desert Shield', 'Middle East'), ('Operation Desert Storm', 'Middle East');
|
What are the names of the intelligence operations in the Middle East?
|
SELECT Name FROM Intelligence_Operations WHERE Location = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rigs (id INT PRIMARY KEY, name TEXT, status TEXT, location TEXT); INSERT INTO rigs (id, name, status, location) VALUES (1, 'Rig A', 'Active', 'Gulf of Mexico'), (2, 'Rig B', 'Inactive', 'Gulf of Mexico'), (3, 'Rig C', 'Active', 'Gulf of Mexico'), (4, 'Rig D', 'Inactive', 'North Sea'); CREATE TABLE rig_history (rig_id INT, year INT, active_rigs INT); INSERT INTO rig_history (rig_id, year, active_rigs) VALUES (1, 2019, 1), (1, 2020, 1), (2, 2019, 0), (2, 2020, 0), (3, 2019, 1), (3, 2020, 1), (4, 2019, 0), (4, 2020, 0);
|
Determine the number of active rigs in the Gulf of Mexico in 2020
|
SELECT COUNT(*) as num_active_rigs FROM rig_history rh JOIN rigs r ON rh.rig_id = r.id WHERE r.location = 'Gulf of Mexico' AND rh.year = 2020 AND r.status = 'Active';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy (initiative VARCHAR(50), impact INT);
|
Delete all records from circular_economy table
|
DELETE FROM circular_economy;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_transportation (project_id INT, project_name TEXT, country TEXT, project_type TEXT); INSERT INTO sustainable_transportation (project_id, project_name, country, project_type) VALUES (1, 'Bicycle Lanes Initiative', 'USA', 'Transportation'), (2, 'Electric Bus Program', 'Canada', 'Transportation');
|
What is the total number of sustainable transportation projects in each country?
|
SELECT country, COUNT(*) AS total_projects FROM sustainable_transportation WHERE project_type = 'Transportation' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), creation_date DATE); INSERT INTO digital_assets (asset_id, asset_name, creation_date) VALUES (1, 'Asset1', '2021-02-01'), (2, 'Asset2', '2020-12-20'); CREATE TABLE smart_contracts (contract_id INT, asset_id INT, contract_name VARCHAR(50), creation_date DATE); INSERT INTO smart_contracts (contract_id, asset_id, contract_name, creation_date) VALUES (101, 1, 'Contract1', '2021-02-05'), (102, 2, 'Contract2', '2019-12-22');
|
What is the total number of smart contracts associated with digital assets that were created after '2021-01-01'?
|
SELECT COUNT(*) FROM smart_contracts INNER JOIN digital_assets ON smart_contracts.asset_id = digital_assets.asset_id WHERE smart_contracts.creation_date > '2021-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ny_events (id INT, num_attendees INT); CREATE TABLE ny_event_types (id INT, event_type VARCHAR(15)); INSERT INTO ny_events (id, num_attendees) VALUES (1, 1500), (2, 2000); INSERT INTO ny_event_types (id, event_type) VALUES (1, 'Art'), (2, 'Theater');
|
What is the total number of attendees at arts events in New York and how many unique events have there been?
|
SELECT SUM(ne.num_attendees), COUNT(DISTINCT net.event_type) FROM ny_events ne INNER JOIN ny_event_types net ON TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Green_Buildings (id INT, project_cost FLOAT, city VARCHAR(20)); INSERT INTO Green_Buildings (id, project_cost, city) VALUES (1, 3000000, 'Chicago');
|
What is the minimum project cost for green buildings in the city of Chicago?
|
SELECT MIN(project_cost) FROM Green_Buildings WHERE city = 'Chicago';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (supplier_id INT, name TEXT); INSERT INTO Suppliers (supplier_id, name) VALUES (1, 'Supplier A'), (2, 'Supplier B'), (3, 'Supplier C'); CREATE TABLE BrandSuppliers (brand_id INT, supplier_id INT, ethical INT); INSERT INTO BrandSuppliers (brand_id, supplier_id, ethical) VALUES (1, 1, 1), (1, 2, 0), (2, 2, 0), (3, 3, 1);
|
List the names of all suppliers that supply to both ethical and non-ethical fashion brands.
|
SELECT Suppliers.name FROM Suppliers INNER JOIN BrandSuppliers ON Suppliers.supplier_id = BrandSuppliers.supplier_id WHERE ethical = 1 INTERSECT SELECT Suppliers.name FROM Suppliers INNER JOIN BrandSuppliers ON Suppliers.supplier_id = BrandSuppliers.supplier_id WHERE ethical = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_profiles (union_name VARCHAR(30), has_cba BOOLEAN); INSERT INTO union_profiles (union_name, has_cba) VALUES ('UnionA', true), ('UnionB', false), ('UnionC', true);
|
What is the total number of members in unions that have a collective bargaining agreement (CBA) in place? * Assume a column named 'has_cba' exists in the 'union_profiles' table with 'true' or 'false' values.
|
SELECT COUNT(*) FROM union_profiles WHERE has_cba = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_services (id INT, name TEXT, state TEXT, location TEXT, cost FLOAT);
|
What is the minimum cost of healthcare services in rural areas of Montana?
|
SELECT MIN(cost) FROM healthcare_services WHERE state = 'Montana' AND location = 'rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_capability_programs (id INT, program_type VARCHAR(255), region VARCHAR(255));
|
Determine the number of financial capability programs in the Northeast region
|
SELECT COUNT(*) FROM financial_capability_programs WHERE region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibitions (id INT, name TEXT, pieces INT, visitors INT); INSERT INTO exhibitions (id, name, pieces, visitors) VALUES (1, 'Modern Art', 150, 1200);
|
What is the minimum number of pieces in an art exhibition that had over 1000 visitors?
|
SELECT MIN(pieces) FROM exhibitions WHERE visitors > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_features (hotel_id INT, city TEXT, contactless_checkout BOOLEAN);
|
Display the number of hotels that offer contactless check-out by city
|
SELECT city, COUNT(*) as num_hotels FROM hotel_features WHERE contactless_checkout = TRUE GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (Artwork VARCHAR(255), ArtMovement VARCHAR(255), SalePrice DECIMAL(10,2)); INSERT INTO Artworks (Artwork, ArtMovement, SalePrice) VALUES ('Artwork 1', 'Post-Impressionism', 500.00), ('Artwork 2', 'Post-Impressionism', 400.00), ('Artwork 3', 'Pop Art', 750.00), ('Artwork 4', 'Pop Art', 1000.00);
|
What was the average sale price for artworks in each art movement?
|
SELECT ArtMovement, AVG(SalePrice) as AvgSalePrice FROM Artworks GROUP BY ArtMovement;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, brand VARCHAR(255), sustainable_materials DECIMAL(10,2));
|
List the top 3 brands with the highest percentage of sustainable materials used in their products.
|
SELECT brand, sustainable_materials, ROUND(sustainable_materials * 100, 2) as percentage FROM products GROUP BY brand ORDER BY percentage DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists(id INT, name VARCHAR(255), birthplace VARCHAR(255)); CREATE TABLE Artworks(id INT, title VARCHAR(255), artist_id INT, art_style VARCHAR(255)); INSERT INTO Artists(id, name, birthplace) VALUES (1, 'Vincent van Gogh', 'Zundert, Netherlands'); INSERT INTO Artists(id, name, birthplace) VALUES (2, 'Paul Gauguin', 'Paris, France'); INSERT INTO Artworks(id, title, artist_id, art_style) VALUES (1, 'Starry Night', 1, 'Post-Impressionism'); INSERT INTO Artworks(id, title, artist_id, art_style) VALUES (2, 'The Yellow Christ', 2, 'Post-Impressionism');
|
What are the names and birthplaces of all artists who created Post-Impressionist artworks?
|
SELECT Artists.name, Artists.birthplace FROM Artists INNER JOIN Artworks ON Artists.id = Artworks.artist_id WHERE Artworks.art_style = 'Post-Impressionism';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT, name VARCHAR, genre VARCHAR, revenue FLOAT); CREATE TABLE streams (artist_id INT, year INT, month INT, streams INT); INSERT INTO artists VALUES (1, 'BTS', 'K-Pop', 1000000); INSERT INTO streams VALUES (1, 2021, 8, 10000000); INSERT INTO streams VALUES (1, 2021, 7, 15000000);
|
How many songs were streamed by K-Pop artists in the last month?
|
SELECT SUM(streams.streams) FROM streams JOIN artists ON streams.artist_id = artists.id WHERE artists.genre = 'K-Pop' AND streams.year = YEAR(CURDATE()) AND streams.month = MONTH(CURDATE());
|
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.