Dataset Viewer
Auto-converted to Parquet Duplicate
category
stringclasses
2 values
source_dataset
stringclasses
2 values
language
stringclasses
2 values
prompt
stringlengths
62
1.36k
thought
stringlengths
28
747
code
stringlengths
19
502k
timestamp
int64
1.79B
1.79B
sql_database
gretelai/synthetic_text_to_sql
sql
List the top 3 most streamed songs for users from South America. Context: CREATE TABLE artists (id INT PRIMARY KEY, name VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); CREATE TABLE songs (id INT PRIMARY KEY, title VARCHAR(255), artist_id INT, released DATE); CREATE TABLE streams (id INT PRIMARY KEY, song_id I...
This query retrieves the top 3 most streamed songs for users from South America by joining the streams and users tables on the user ID. It then filters the results for users from South America, groups the results by song title, and calculates the total number of streams for each song. Finally, it orders the results by ...
SELECT s.title, COUNT(s.id) AS total_streams FROM streams s JOIN users u ON s.user_id = u.id WHERE u.country = 'South America' GROUP BY s.title ORDER BY total_streams DESC LIMIT 3;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total number of articles and the percentage of articles in the 'politics' category, for each country? Context: CREATE TABLE articles (article_id INT, title VARCHAR(50), category VARCHAR(20), country VARCHAR(20)); INSERT INTO articles (article_id, title, category, country) VALUES (1, 'Politics in 2022', 'pol...
First, we use the COUNT function with the GROUP BY clause to calculate the number of articles for each country. Then, we use the COUNT and CASE clauses to calculate the number of articles in the 'politics' category for each country. Finally, we calculate the percentage by dividing the number of articles in the 'politic...
SELECT country, COUNT(*) as article_count, 100.0 * COUNT(CASE WHEN category = 'politics' THEN 1 END) / COUNT(*) as politics_percentage FROM articles GROUP BY country;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List all states that have mental health parity laws Context: CREATE TABLE mental_health_parity (id INT PRIMARY KEY, state VARCHAR(2), parity_law TEXT, year INT);
1. The 'state' column is being selected from the 'mental_health_parity' table. 2. Only rows with a non-null 'parity_law' value are returned.
SELECT state FROM mental_health_parity WHERE parity_law IS NOT NULL;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Insert a new record into the 'survey_results' table with ID '001', mine_id 'Mine_001', survey_date '2022-03-15', and result 'Satisfactory' Context: CREATE TABLE survey_results (id VARCHAR(10), mine_id VARCHAR(10), survey_date DATE, result VARCHAR(50));
This query inserts a new record into the 'survey_results' table with ID '001', mine_id 'Mine_001', survey_date '2022-03-15', and result 'Satisfactory'.
INSERT INTO survey_results (id, mine_id, survey_date, result) VALUES ('001', 'Mine_001', '2022-03-15', 'Satisfactory');
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total amount donated by donors with an age between 20 and 30? Context: CREATE TABLE donors (id INT, name TEXT, age INT, donation FLOAT); INSERT INTO donors (id, name, age, donation) VALUES (1, 'John Doe', 35, 500.00); INSERT INTO donors (id, name, age, donation) VALUES (2, 'Jane Smith', 25, 200.00); INSERT ...
This query calculates the total amount donated by donors with an age between 20 and 30 by using the SUM() function with a WHERE clause to filter the records based on the age.
SELECT SUM(donation) FROM donors WHERE age BETWEEN 20 AND 30;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the percentage of total workplace injuries for Union D, in the year 2021? Context: CREATE TABLE union_table_2021 (union_name VARCHAR(255), total_injuries INT); INSERT INTO union_table_2021 (union_name, total_injuries) VALUES ('Union A', 350), ('Union B', 450), ('Union C', 550), ('Union D', 600);
This SQL query calculates the percentage of total workplace injuries for Union D in the year 2021. It does this by dividing the sum of the total_injuries for Union D in the year 2021 by the sum of the total_injuries for all unions in the year 2021 and then multiplying the result by 100. This gives the percentage of tot...
SELECT (SUM(total_injuries) / (SELECT SUM(total_injuries) FROM union_table_2021) * 100) as injury_percentage FROM union_table_2021 WHERE union_name = 'Union D' AND YEAR(incident_date) = 2021;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the number of vaccinated individuals and total population in each state, ordered by the percentage of vaccinated individuals, descending? Context: CREATE TABLE states (id INT, name TEXT, total_population INT, vaccinated_individuals INT); INSERT INTO states (id, name, total_population, vaccinated_individuals) VA...
The SQL query creates a table named states with relevant columns and data. It then calculates the percentage of vaccinated individuals for each state by dividing the number of vaccinated individuals by the total population and multiplying by 100.0. The result is ordered by the vaccination_percentage column in descendin...
SELECT name, total_population, vaccinated_individuals, (vaccinated_individuals * 100.0 / total_population) as vaccination_percentage FROM states ORDER BY vaccination_percentage DESC;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Who are the top 5 donors to community development initiatives in Guatemala? Context: CREATE TABLE donors(id INT, name TEXT, country TEXT, donation INT); INSERT INTO donors(id, name, country, donation) VALUES (1, 'USAID', 'USA', 50000), (2, 'European Union', 'Belgium', 40000); CREATE TABLE donations(id INT, donor_id INT...
This query lists the top 5 donors to community development initiatives in Guatemala. It does this by creating a subquery that calculates the total donation of each donor and orders them in descending order. Then, it joins the donors table with the subquery on the donor_id column and selects the name column to display.
SELECT d.name FROM donors d JOIN (SELECT donor_id, SUM(amount) as total_donation FROM donations GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5) dd ON d.id = dd.donor_id;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which cultural heritage sites in Mexico and Peru had over 15000 visitors in 2021? Context: CREATE TABLE sites (site_id INT, site_name VARCHAR(50), country VARCHAR(50), year INT, visitors INT); INSERT INTO sites (site_id, site_name, country, year, visitors) VALUES (1, 'Chichen Itza', 'Mexico', 2021, 18000), (2, 'Teotihu...
The SQL query counts the number of cultural heritage sites in Mexico and Peru that had over 15000 visitors in 2021 by selecting all rows where the country is either Mexico or Peru, the year is 2021, and the visitors column is greater than 15000.
SELECT COUNT(*) FROM sites WHERE country IN ('Mexico', 'Peru') AND year = 2021 AND visitors > 15000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Present the total number of cases and billing amount for each attorney. Context: CREATE TABLE AttorneyInfo (AttorneyID INT, Cases INT, Amount DECIMAL(10,2)); INSERT INTO AttorneyInfo (AttorneyID, Cases, Amount) VALUES (1, 1000, 5000), (2, 1500, 7000);
Calculate the total number of cases and billing amount for each attorney by using the SUM function and group them by Name.
SELECT a.Name, SUM(a.Cases) AS TotalCases, SUM(a.Amount) AS TotalBilling FROM AttorneyInfo a GROUP BY a.Name;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average number of containers handled per day by each crane in 'Hong Kong'? Context: CREATE TABLE port (port_id INT, name TEXT, created_at DATETIME);CREATE TABLE crane (crane_id INT, port_id INT, name TEXT);CREATE TABLE container (container_id INT, crane_id INT, weight INT, created_at DATETIME);INSERT INTO p...
The SQL query joins the 'crane' and 'container' tables using the 'crane_id' and then filters the results by the 'port' table to only include records from the 'Hong Kong' port. It then groups the results by crane name and the date the container was handled, and calculates the average number of containers handled per day...
SELECT crane.name, AVG(COUNT(container.container_id)) FROM crane JOIN port ON crane.port_id = port.port_id JOIN container ON crane.crane_id = container.crane_id WHERE port.name = 'Hong Kong' GROUP BY crane.name, DATE(container.created_at);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total number of oil wells in the 'Onshore' and 'Offshore' regions? Context: CREATE TABLE if not exists oil_wells (id INT PRIMARY KEY, well_name TEXT, region TEXT, type TEXT); INSERT INTO oil_wells (id, well_name, region, type) VALUES (1, 'Well A', 'Onshore', 'Oil'), (2, 'Well B', 'Offshore', 'Oil'), (3, 'We...
This SQL query counts the number of oil wells in the 'Onshore' and 'Offshore' regions by selecting all records with region 'Onshore' or 'Offshore' and type 'Oil', and then counting the number of rows returned by the query.
SELECT COUNT(*) FROM oil_wells WHERE region IN ('Onshore', 'Offshore') AND type = 'Oil';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many labor hours have been spent on mining site A in each month of the past year? Context: CREATE TABLE mining_site_labor_hours (site_id INT, hours INT, labor_date DATE); INSERT INTO mining_site_labor_hours (site_id, hours, labor_date) VALUES (1, 250, '2022-01-01'), (1, 275, '2022-01-02'), (1, 300, '2022-02-01'), (...
This SQL query calculates the number of labor hours spent on mining site A in each month of the past year by using a GROUP BY clause to group the results by the month (formatted as YYYY-MM), and calculating the sum of hours using the SUM() function.
SELECT DATE_FORMAT(labor_date, '%Y-%m') AS month, SUM(hours) FROM mining_site_labor_hours WHERE site_id = 1 AND labor_date >= '2022-01-01' AND labor_date < '2023-01-01' GROUP BY month;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the number of unique users who have streamed songs from artists who have released a new album in the last year? Context: CREATE TABLE user_streams (user_id INT, artist_id INT, stream_date DATE); CREATE TABLE artist_albums (artist_id INT, release_date DATE);
The SQL query joins the user_streams and artist_albums tables on the artist_id column, filters the records based on the release_date column, and then calculates the number of unique users who have streamed songs from artists who have released a new album in the last year.
SELECT COUNT(DISTINCT u.user_id) FROM user_streams u JOIN artist_albums a ON u.artist_id = a.artist_id WHERE a.release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average sentiment score for African American authors' books? Context: CREATE TABLE authors (id INT, name VARCHAR(255), ethnicity VARCHAR(255)); INSERT INTO authors (id, name, ethnicity) VALUES (1, 'Toni Morrison', 'African American'); CREATE TABLE books (id INT, title VARCHAR(255), sentiment FLOAT, author_i...
Calculate the average sentiment score of books written by African American authors.
SELECT AVG(sentiment) FROM books JOIN authors ON books.author_id = authors.id WHERE authors.ethnicity = 'African American'
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total revenue for each menu category this month, with a 15% discount applied? Context: CREATE TABLE menu (category VARCHAR(255), price NUMERIC); INSERT INTO menu (category, price) VALUES ('Appetizers', 10), ('Entrees', 20), ('Desserts', 15);
This SQL query calculates the total revenue for each menu category this month with a 15% discount applied by selecting the category and sum of price multiplied by 0.85 (100% - 15%) from the menu table. It does not filter the data by date as the current date is not provided in the context, but it groups the results by m...
SELECT category, SUM(price * 0.85) FROM menu GROUP BY category;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Show the vehicles that were tested in safety tests but not included in autonomous driving research. Context: CREATE TABLE SafetyTestingVehicle (TestID INT, Vehicle VARCHAR(20), TestResult VARCHAR(10)); CREATE TABLE AutonomousDrivingData (TestID INT, Vehicle VARCHAR(20), MaxSpeed FLOAT, MinSpeed FLOAT);
The query uses a subquery to find the vehicles that were tested in safety tests but not included in autonomous driving research.
SELECT Vehicle FROM SafetyTestingVehicle WHERE Vehicle NOT IN (SELECT Vehicle FROM AutonomousDrivingData);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which rural infrastructure projects have a higher budget than any community development project? Context: CREATE TABLE rural_infrastructure (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, name, type, budget) VALUES (1, 'Solar Irrigation', 'Agricultural Innovation', 1500...
This query uses a subquery to find the maximum budget from the community_development table, and then compares the budgets of the rural_infrastructure table against this value. The SELECT statement retrieves the name and budget columns from the rural_infrastructure table where the budget is greater than the maximum budg...
SELECT name, budget FROM rural_infrastructure WHERE budget > (SELECT MAX(budget) FROM community_development);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Find the number of vegan nail polish products sold in the USA in Q2 2021. Context: CREATE TABLE cosmetics_sales (product VARCHAR(255), country VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255), vegan BOOLEAN); CREATE TABLE countries (countr...
This query calculates the number of vegan nail polish products sold in the USA in Q2 2021 by joining the q2_sales, cosmetics, and countries tables. It filters the data where the product_category is 'Nail Polishes', the vegan flag is true, the country is USA, and the quarter of the sale_date is Q2 2021 and then calculat...
SELECT COUNT(*) FROM q2_sales JOIN cosmetics ON q2_sales.product = cosmetics.product JOIN countries ON q2_sales.country = countries.country WHERE cosmetics.product_category = 'Nail Polishes' AND cosmetics.vegan = true AND countries.country = 'USA';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total donation amount for organizations with the word "effective" in their names, in the 'Donations' and 'Organizations' tables? Context: CREATE TABLE Organizations (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50));
This query performs an inner join between the 'Donations' and 'Organizations' tables and calculates the total donation amount for organizations with the word "effective" in their names.
SELECT SUM(amount) as total_effective_donations FROM Donations JOIN Organizations ON Donations.organization_id = Organizations.id WHERE Organizations.name LIKE '%effective%';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the percentage of the population that is African American in Louisiana? Context: CREATE TABLE racial_composition (id INT, state VARCHAR(50), population INT, african_american INT); INSERT INTO racial_composition (id, state, population, african_american) VALUES (1, 'Louisiana', 4648794, 1168666);
This SQL query calculates the percentage of the population that is African American in Louisiana by dividing the number of African Americans by the total population and multiplying by 100.0.
SELECT (african_american * 100.0 / population) FROM racial_composition WHERE state = 'Louisiana';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which spacecraft have a mass between 5000 and 7000 tons? Context: CREATE TABLE SpacecraftManufacturing (id INT, company VARCHAR(255), mass FLOAT); INSERT INTO SpacecraftManufacturing (id, company, mass) VALUES (1, 'Aerospace Inc.', 5000.0), (2, 'Galactic Corp.', 7000.0), (3, 'Space Tech', 6500.0);
This query retrieves all spacecraft with a mass between 5000 and 7000 tons by selecting all records with a mass between 5000 and 7000.
SELECT * FROM SpacecraftManufacturing WHERE mass BETWEEN 5000 AND 7000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Find the minimum transaction date for each investment strategy in the "InvestmentStrategies" table. Context: CREATE TABLE InvestmentStrategies (InvestmentStrategyID INT, CustomerID INT, TransactionDate DATE, TransactionAmount DECIMAL(10,2));
This query calculates the minimum transaction date for each investment strategy in the InvestmentStrategies table. It groups the transactions by InvestmentStrategyID and then calculates the minimum transaction date for each group.
SELECT InvestmentStrategyID, MIN(TransactionDate) as MinTransactionDate FROM InvestmentStrategies GROUP BY InvestmentStrategyID;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total time spent in space for astronauts with flight experience in military aviation? Context: CREATE TABLE Astronaut (Id INT, Name VARCHAR(50), SpaceMissionId INT, FlightExperience VARCHAR(50), TotalTimeInSpace INT);
The SQL query calculates the sum of TotalTimeInSpace from the Astronaut table, filtering results by the FlightExperience column containing the phrase 'military aviation'.
SELECT SUM(TotalTimeInSpace) FROM Astronaut WHERE FlightExperience LIKE '%military%aviation%';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Show the total number of community health workers Context: CREATE TABLE healthcare.CommunityHealthWorker( worker_id INT PRIMARY KEY, name VARCHAR(100), cultural_competency_score FLOAT); INSERT INTO healthcare.CommunityHealthWorker (worker_id, name, cultural_competency_score) VALUES (1, 'Jane Smith', 85.5), (2, 'Maria G...
This SQL statement counts all records in the 'CommunityHealthWorker' table in the 'healthcare' schema and returns the total number of community health workers.
SELECT COUNT(*) FROM healthcare.CommunityHealthWorker;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the percentage of energy generated from fossil fuels in Mexico? Context: CREATE TABLE energy_generation (country VARCHAR(255), energy_source VARCHAR(255), percentage INT); INSERT INTO energy_generation (country, energy_source, percentage) VALUES ('Mexico', 'Fossil Fuels', 80), ('Mexico', 'Renewable', 20);
This query calculates the percentage of energy generated from fossil fuels in Mexico by selecting the percentage column in the energy_generation table where the country is 'Mexico' and the energy_source is 'Fossil Fuels'.
SELECT percentage FROM energy_generation WHERE country = 'Mexico' AND energy_source = 'Fossil Fuels';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total value of assets for institutional clients? Context: CREATE TABLE clients (id INT, client_type VARCHAR(20), asset_value DECIMAL(15, 2)); INSERT INTO clients (id, client_type, asset_value) VALUES (1, 'Institutional', 5000000.00), (2, 'Retail', 100000.00), (3, 'Institutional', 7000000.00);
The SQL query calculates the total value of assets for institutional clients by using the SUM function on the asset_value column and filtering by the client type Institutional.
SELECT SUM(asset_value) FROM clients WHERE client_type = 'Institutional';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many renewable energy projects were completed in each region in the past 3 years? Context: CREATE TABLE renewable_projects (id INT, region VARCHAR(50), completion_year INT);
This query calculates the number of renewable energy projects completed in each region in the past 3 years. It filters the renewable_projects table to only include records from the past 3 years, counts the number of projects for each region, and groups the results by region.
SELECT region, COUNT(*) FROM renewable_projects WHERE completion_year >= YEAR(CURRENT_DATE) - 3 GROUP BY region;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the daily transaction volume for high-risk customers in the past week? Context: CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50), risk_level INT); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE);
The SQL query calculates the daily transaction volume for high-risk customers in the past week by joining the 'transactions' table and the 'customers' table on the 'customer_id' column. It then filters high-risk customers and transactions within the past week and groups them by 'transaction_date' and 'customer_id' to c...
SELECT t.transaction_date, c.customer_id, COUNT(t.transaction_id) as transaction_count FROM transactions t INNER JOIN customers c ON t.customer_id = c.customer_id WHERE c.risk_level > 7 AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) GROUP BY t.transaction_date, c.customer_id;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the maximum number of public transportation trips taken in a single day in each city? Context: CREATE TABLE Daily_Transportation (id INT, city VARCHAR(50), trips INT, date DATE);
This query identifies the maximum number of public transportation trips taken in a single day in each city by grouping the Daily_Transportation table by the city column, and then selecting the city column and the maximum value of the trips column.
SELECT city, MAX(trips) FROM Daily_Transportation GROUP BY city;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What was the total revenue for each cuisine type in June 2021? Context: CREATE TABLE restaurant_revenue (date DATE, cuisine VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO restaurant_revenue (date, cuisine, revenue) VALUES ('2021-06-01', 'Italian', 5000.00), ('2021-06-01', 'Mexican', 7000.00), ('2021-06-02', 'Italian...
This query calculates the total revenue for each cuisine type in June 2021. It filters the data to only include records from June 2021, then groups the data by cuisine type, and finally calculates the total revenue for each cuisine type.
SELECT cuisine, SUM(revenue) as total_revenue FROM restaurant_revenue WHERE date in ('2021-06-01', '2021-06-02') GROUP BY cuisine;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Delete all records in the "tech_companies" table where the "industry" is "cloud computing" Context: CREATE TABLE tech_companies (name TEXT, industry TEXT, year_founded INTEGER, location TEXT); INSERT INTO tech_companies (name, industry, year_founded, location) VALUES ('Google', 'Cloud Computing', 1998, 'Mountain View')...
This SQL query deletes all records in the "tech_companies" table where the "industry" is "cloud computing".
DELETE FROM tech_companies WHERE industry = 'Cloud Computing';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total revenue generated from ticket sales for each sport in the 'ticket_sales' table? Context: CREATE TABLE ticket_sales (id INT PRIMARY KEY, event_id INT, sport VARCHAR(50), tickets_sold INT, price DECIMAL(5,2)); CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(100), date DATE, location VARCHAR(100));
This SQL query calculates the total revenue generated from ticket sales for each sport by using a join between the 'ticket_sales' and 'events' tables on the 'event_id' column. It then groups the results by the 'sport' column and calculates the total revenue for each sport using the SUM function.
SELECT t.sport, SUM(t.price * t.tickets_sold) as total_revenue FROM ticket_sales t JOIN events e ON t.event_id = e.id GROUP BY t.sport;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Identify the most common types of crimes in each district. Context: CREATE TABLE districts (district_id INT, district_name VARCHAR(255));CREATE TABLE crimes (id INT, district_id INT, crime_type VARCHAR(255), crime_date DATE, crime_count INT);
This query calculates the total number of crimes for each type of crime in each district by joining the districts table with the crimes table on the district_id column. It then groups the results by the district_name and crime_type and calculates the total number of crimes for each group. Finally, it orders the results...
SELECT district_name, crime_type, SUM(crime_count) AS total_crimes FROM districts d JOIN crimes c ON d.district_id = c.district_id GROUP BY district_name, crime_type ORDER BY total_crimes DESC;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the maximum account balance for customers in the Retail division, excluding customers with account balances below $10,000? Context: CREATE TABLE Retail (customer_id INT, name VARCHAR(50), division VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO Retail (customer_id, name, division, account_balance) VALU...
Calculate the maximum account balance for customers in the Retail division with account balances of $10,000 or more.
SELECT MAX(account_balance) FROM Retail WHERE division = 'Retail' AND account_balance >= 10000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total amount of relief aid provided by 'UNICEF' for disasters in 'Country X'? Context: CREATE TABLE Relief_Aid (id INT, disaster_id INT, organization VARCHAR(50), amount FLOAT, date DATE); INSERT INTO Relief_Aid (id, disaster_id, organization, amount, date) VALUES (4, 5, 'UNICEF', 9000, '2021-09-05'); CRE...
This query finds the total amount of relief aid provided by 'UNICEF' for disasters in 'Country X'. It uses a subquery to get the ids of disasters in 'Country X', then sums the amount of relief aid provided by 'UNICEF' in the main query.
SELECT SUM(Relief_Aid.amount) FROM Relief_Aid WHERE Relief_Aid.organization = 'UNICEF' AND Relief_Aid.disaster_id IN (SELECT Disaster.id FROM Disaster WHERE Disaster.location = 'Country X')
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What's the total number of players from North America and Europe? Context: CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Country) VALUES (1, 'John Doe', 25, 'USA'), (2, 'Jane Smith', 28, 'Canada'), (3, 'James Johnson', 30, 'England'), (4,...
This query counts the total number of players from the four countries specified in the context. It does this by using the WHERE clause to filter the rows where the Country column matches any of the specified countries. Finally, it counts the rows using the COUNT() aggregate function.
SELECT COUNT(*) FROM Players WHERE Country IN ('USA', 'Canada', 'England', 'France');
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Calculate the total revenue for the museum's online store for the last year Context: CREATE TABLE OnlineStore (id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO OnlineStore (id, date, revenue) VALUES (1, '2022-01-01', 500.00); INSERT INTO OnlineStore (id, date, revenue) VALUES (2, '2022-01-02', 750.00);
This query calculates the sum of the revenue for the last year from the current date.
SELECT SUM(revenue) FROM OnlineStore WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 365 DAY) AND CURRENT_DATE;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total funding received by art programs for unrepresented communities in New York and California? Context: CREATE TABLE Funding (id INT, state VARCHAR(2), program VARCHAR(20), amount FLOAT); INSERT INTO Funding (id, state, program, amount) VALUES (1, 'NY', 'Art for All', 150000.00), (2, 'CA', 'Art Reach', 20...
The SQL query first selects the sum of the amount column from the Funding table, filtering for rows where the state is New York or California and the program is Art for All, Art Reach, or Unseen Art. The subquery then filters the states further to only include those with underrepresented communities.
SELECT SUM(amount) FROM Funding WHERE state IN ('NY', 'CA') AND program IN ('Art for All', 'Art Reach', 'Unseen Art') AND state IN (SELECT state FROM Communities WHERE underrepresented = 'yes');
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the population trend in Arctic indigenous communities since 2000? Context: CREATE TABLE community_population (community VARCHAR(50), year INT, population INT); INSERT INTO community_population (community, year, population) VALUES ('Inuit', 2000, 50000), ('Inuit', 2001, 50500);
The SQL query calculates the population trend by comparing the current year's population with the previous year's population for each community.
SELECT c.community, c.year, c.population, LAG(c.population) OVER (PARTITION BY c.community ORDER BY c.year) as prev_year_population FROM community_population c;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Determine the number of veterans hired in the 'IT' sector in the last financial year. Context: CREATE TABLE veteran_employment (id INT, sector TEXT, hire_date DATE); INSERT INTO veteran_employment (id, sector, hire_date) VALUES (1, 'IT', '2021-10-01'), (2, 'Finance', '2021-04-01');
The SQL query filters the veteran_employment table based on the 'IT' sector and hire dates within the last financial year. It then counts the number of records that meet these criteria, giving the final result.
SELECT COUNT(*) FROM veteran_employment WHERE sector = 'IT' AND hire_date >= DATEADD(year, -1, GETDATE());
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Delete records in the menu_items table where the item_name is 'Fish Tacos' Context: CREATE TABLE menu_items (item_name VARCHAR(255), price DECIMAL(5,2));
This SQL query deletes records in the menu_items table where the item_name is 'Fish Tacos'. It uses the DELETE statement to remove records that meet the specified conditions.
DELETE FROM menu_items WHERE item_name = 'Fish Tacos';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List all athletes who have won a gold medal in any sport. Context: CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50), medals_won INT, medal VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport, medals_won, medal) VALUES (1, 'Serena Williams', 'Tennis', 23, 'Gold'), (2, 'Roger Federer', '...
The query selects all athletes with a gold medal by filtering the data using WHERE and returns their names.
SELECT name FROM athletes WHERE medal = 'Gold';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What was the average cargo weight for vessels in the North sea in the past week? Context: CREATE TABLE cargos(id INT, vessel_id INT, cargo_weight FLOAT); CREATE TABLE vessel_locations(id INT, vessel_id INT, location VARCHAR(50), timestamp TIMESTAMP);
The SQL query calculates the average cargo weight for vessels in the North sea in the past week by joining the cargos and vessel_locations tables on vessel_id, filtering the joined table to only include rows with the location containing 'North Sea' and a timestamp later than 1 week ago, and then computing the average o...
SELECT AVG(cargo_weight) FROM cargos JOIN vessel_locations ON cargos.vessel_id = vessel_locations.vessel_id WHERE location LIKE '%North Sea%' AND timestamp > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Identify the artist with the most works displayed in galleries located in Tokyo, and show the number of works and gallery names. Context: CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Works (id INT, artist_id INT, title VARCHAR(50)); CREATE TABLE Gallery_Works (id INT, gallery_id INT, work_id INT); CREA...
This query identifies the artist with the most works displayed in galleries located in Tokyo by joining the Artists, Works, Gallery_Works, and Galleries tables on their respective IDs. It then groups the data by artist name, concatenates the names of the galleries where each artist's works are displayed, and counts the...
SELECT a.name, COUNT(w.id) as num_works, GROUP_CONCAT(g.name) as gallery_names FROM Artists a JOIN Works w ON a.id = w.artist_id JOIN Gallery_Works gw ON w.id = gw.work_id JOIN Galleries g ON gw.gallery_id = g.id WHERE g.city = 'Tokyo' GROUP BY a.name ORDER BY num_works DESC LIMIT 1;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Who is the manufacturer with the highest safety rating for vehicles produced in the UK? Context: CREATE TABLE Vehicle_Manufacturers (id INT, name TEXT, safety_rating FLOAT, production_country TEXT); INSERT INTO Vehicle_Manufacturers (id, name, safety_rating, production_country) VALUES (1, 'Manufacturer1', 4.3, 'UK'); I...
This SQL query retrieves the name of the manufacturer with the highest safety rating for vehicles produced in the UK by filtering rows using the WHERE clause for production_country equals 'UK', sorting the rows using the ORDER BY clause with the safety_rating column in descending order, and returning a single row using...
SELECT name FROM Vehicle_Manufacturers WHERE production_country = 'UK' ORDER BY safety_rating DESC LIMIT 1;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the maximum number of beds available in hospitals in India? Context: CREATE TABLE hospitals_india (id INT, name TEXT, beds INT); INSERT INTO hospitals_india (id, name, beds) VALUES (1, 'Hospital X', 500);
Find the maximum number of beds available in hospitals in India by selecting the maximum value of the 'beds' column from the 'hospitals_india' table.
SELECT MAX(beds) FROM hospitals_india;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Identify the top 3 countries with the highest number of marine protected areas in the Atlantic Ocean. Context: CREATE TABLE marine_protected_areas (country VARCHAR(255), region VARCHAR(255), number_of_sites INT); INSERT INTO marine_protected_areas (country, region, number_of_sites) VALUES ('Norway', 'Atlantic Ocean', 5...
This query assigns row numbers based on the number of marine protected areas in descending order for countries in the Atlantic Ocean. It then returns the top 3 countries with the highest number of marine protected areas.
SELECT country, number_of_sites, ROW_NUMBER() OVER (ORDER BY number_of_sites DESC) as rn FROM marine_protected_areas WHERE region = 'Atlantic Ocean' LIMIT 3;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the number of open pedagogy courses offered in '2022' grouped by subject area? Context: CREATE TABLE courses (course_id INT, academic_year INT, subject_area VARCHAR(50), pedagogy_type VARCHAR(50)); INSERT INTO courses (course_id, academic_year, subject_area, pedagogy_type) VALUES (1, 2022, 'Math', 'Open'), (2, ...
The query counts the number of open pedagogy courses offered in '2022' grouped by subject area. It selects courses from the 'courses' table where the academic year is 2022 and the pedagogy type is 'Open', and then groups the results by subject area.
SELECT subject_area, COUNT(*) AS number_of_courses FROM courses WHERE academic_year = 2022 AND pedagogy_type = 'Open' GROUP BY subject_area;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many patients have been vaccinated in Sydney with AstraZeneca this year? Context: CREATE TABLE vaccinations (id INT, patient_id INT, vaccine VARCHAR(50), date DATE, city VARCHAR(50)); INSERT INTO vaccinations (id, patient_id, vaccine, date, city) VALUES (5, 5, 'AstraZeneca', '2022-02-15', 'Sydney'); INSERT INTO vac...
Count the number of patients vaccinated with AstraZeneca in Sydney this year by getting the count of records in the vaccinations table where city is 'Sydney', vaccine is 'AstraZeneca', and date is greater than or equal to '2022-01-01'.
SELECT COUNT(*) FROM vaccinations WHERE city = 'Sydney' AND vaccine = 'AstraZeneca' AND date >= '2022-01-01';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What are the names and production quantities of all gas wells in the 'GAS_WELLS' table? Context: CREATE TABLE GAS_WELLS (WELL_NAME VARCHAR(255), PRODUCTION_QTY INT);
This query selects the 'WELL_NAME' and 'PRODUCTION_QTY' columns from the 'GAS_WELLS' table, displaying the names and production quantities of all gas wells.
SELECT WELL_NAME, PRODUCTION_QTY FROM GAS_WELLS;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average year of creation for artworks in the 'Cubism' gallery? Context: CREATE TABLE Artworks (artwork_id INT, year_created INT, gallery_name VARCHAR(50)); INSERT INTO Artworks (artwork_id, year_created, gallery_name) VALUES (1, 1907, 'Cubism'), (2, 1912, 'Cubism');
The SQL query calculates the average year_created for artworks in the 'Cubism' gallery.
SELECT AVG(year_created) FROM Artworks WHERE gallery_name = 'Cubism';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which museums in Paris and Rome have more than 5000 artworks in their collections? Context: CREATE TABLE museums (id INT, name VARCHAR(50), city VARCHAR(50), artworks_count INT); INSERT INTO museums (id, name, city, artworks_count) VALUES (1, 'Louvre Museum', 'Paris', 55000); INSERT INTO museums (id, name, city, artwor...
This query selects the name and city columns from the museums table for rows where the city is either 'Paris' or 'Rome' and the artworks_count is greater than 5000.
SELECT name, city FROM museums WHERE city IN ('Paris', 'Rome') AND artworks_count > 5000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which countries have greenhouse gas emissions from rare earth element production greater than 3000? Context: CREATE TABLE emissions (country VARCHAR(50), emissions INT); INSERT INTO emissions (country, emissions) VALUES ('China', 12000), ('USA', 3500), ('Australia', 1800), ('India', 500), ('Brazil', 200);
This query retrieves the names of the countries with greenhouse gas emissions from rare earth element production greater than 3000 by filtering the emissions table based on the condition that the emissions are greater than 3000.
SELECT country FROM emissions WHERE emissions > 3000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many spacecraft were manufactured per year by each manufacturer? Context: CREATE TABLE spacecraft_manufacturing (id INT, year INT, manufacturer VARCHAR(255), quantity INT);
For each manufacturer and year, calculate the average number of spacecraft manufactured. Averages are obtained by summing all quantity values and dividing by the count of quantity values for a given manufacturer and year.
SELECT manufacturer, year, AVG(quantity) as avg_yearly_production FROM spacecraft_manufacturing GROUP BY manufacturer, year;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the name and organization of volunteers who have provided support in the education sector? Context: CREATE TABLE volunteers (id INT, name TEXT, organization TEXT, sector TEXT); INSERT INTO volunteers (id, name, organization, sector) VALUES (1, 'John Doe', 'UNICEF', 'Education'), (2, 'Jane Smith', 'Save the Chil...
The SQL query selects the name and organization columns from the volunteers table where the sector is equal to 'Education'. This returns the names and organizations of volunteers who have provided support in the education sector.
SELECT name, organization FROM volunteers WHERE sector = 'Education';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average rating of each hotel in the asia_hotels view? Context: CREATE VIEW asia_hotels AS SELECT * FROM hotels WHERE continent = 'Asia'; CREATE TABLE hotel_ratings (hotel_id INT, rating INT);
This query joins the asia_hotels view with the hotel_ratings table on the id column, then calculates the average rating for each hotel by grouping by the hotel_name column.
SELECT h.hotel_name, AVG(hr.rating) FROM asia_hotels h JOIN hotel_ratings hr ON h.id = hr.hotel_id GROUP BY h.hotel_name;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average speed of buses, by route? Context: CREATE TABLE Routes (RouteID int, RouteType varchar(10), StartingLocation varchar(20), Length float); CREATE TABLE VehicleSpeeds (VehicleID int, RouteID int, Speed float); INSERT INTO Routes VALUES (1, 'Bus', 'City Center', 20.0), (2, 'Tram', 'City Center', 15.0), ...
This query first joins the Routes and VehicleSpeeds tables on the RouteID field. It then filters for rows where the RouteType is 'Bus'. Finally, it groups the results by route ID and calculates the average speed for each route.
SELECT Routes.RouteID, Routes.RouteType, AVG(VehicleSpeeds.Speed) as avg_speed FROM Routes INNER JOIN VehicleSpeeds ON Routes.RouteID = VehicleSpeeds.RouteID WHERE Routes.RouteType = 'Bus' GROUP BY Routes.RouteID;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many defense contracts were awarded to minority-owned businesses in 2019? Context: CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(50), minority_owned BOOLEAN, award_year INT, contract_value DECIMAL(10, 2)); INSERT INTO defense_contracts (contract_id, company_name, minority_owned, award_year, ...
This SQL query counts the number of defense contracts awarded to minority-owned businesses in 2019. It uses the COUNT aggregation function to count the rows that meet the specified conditions, which are defined in the WHERE clause.
SELECT COUNT(*) FROM defense_contracts WHERE minority_owned = TRUE AND award_year = 2019;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List the total number of labor rights violations for each type in the 'LaborRightsViolations' table Context: CREATE TABLE LaborRightsViolations (id INT, type VARCHAR(50), violation VARCHAR(50)); INSERT INTO LaborRightsViolations (id, type, violation) VALUES (1, 'TypeA', 'Violation1'), (2, 'TypeB', 'Violation2'), (3, 'T...
This query calculates the total number of labor rights violations for each type in the LaborRightsViolations table by grouping the records based on type and then counting the number of records in each group.
SELECT type, COUNT(*) as total_violations FROM LaborRightsViolations GROUP BY type;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average carbon offset for each energy efficiency rating? Context: CREATE TABLE EnergyEfficiencyRatings (RatingID int, RatingName varchar(50)); CREATE TABLE GreenBuildings (BuildingID int, RatingID int, CarbonOffsets int);
This SQL query calculates the average carbon offset for each energy efficiency rating. It performs an inner join between the EnergyEfficiencyRatings and GreenBuildings tables on the RatingID field. Then, it groups the results by RatingName and calculates the avg of the CarbonOffsets field for each group.
SELECT EnergyEfficiencyRatings.RatingName, AVG(GreenBuildings.CarbonOffsets) as AvgCarbonOffsets FROM EnergyEfficiencyRatings INNER JOIN GreenBuildings ON EnergyEfficiencyRatings.RatingID = GreenBuildings.RatingID GROUP BY EnergyEfficiencyRatings.RatingName;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Determine the average rating of beauty products that are both cruelty-free and vegan. Context: CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_cruelty_free BOOLEAN, is_vegan BOOLEAN, rating DECIMAL(2,1)); INSERT INTO products (product_id, product_name, is_cruelty_free, is_vegan, rating) VALUES (1, ...
The SQL query determines the average rating of beauty products that are both cruelty-free and vegan by filtering the products table for products that are both cruelty-free and vegan and then calculating the average rating using the AVG function.
SELECT AVG(rating) FROM products WHERE is_cruelty_free = true AND is_vegan = true;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Insert a new record into the refinery_table for 'Promethium' with the given data: year = 2022, production_volume = 125 Context: CREATE TABLE refinery_table (rare_earth_element VARCHAR(20), year INT, production_volume INT);
This query inserts a new record into the refinery_table for the rare earth element 'Promethium' with the specified data for the year and production volume.
INSERT INTO refinery_table (rare_earth_element, year, production_volume) VALUES ('Promethium', 2022, 125);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average environmental factor score for projects in the education sector with an investment amount greater than $700,000? Context: CREATE TABLE impact_investments (id INT, project VARCHAR(50), location VARCHAR(50), investment_amount DECIMAL(10,2), impact_score INT, primary_sector VARCHAR(50)); INSERT INTO im...
Calculate the average environmental factor score for projects in the education sector with an investment amount greater than $700,000.
SELECT AVG(e.environmental_factor) as avg_env_factor FROM esg_factors e JOIN impact_investments i ON e.investment_id = i.id WHERE i.primary_sector = 'Education' AND i.investment_amount > 700000;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the average number of employees per mining operation? Context: CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT);
This query calculates the average number of employees per mining operation by taking the average of the 'num_employees' column in the 'mining_operations' table.
SELECT AVG(num_employees) FROM mining_operations;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
How many heritage sites are in Mexico? Context: CREATE TABLE HeritageSites (SiteID INT, Name TEXT, Country TEXT); INSERT INTO HeritageSites (SiteID, Name, Country) VALUES (1, 'Palenque', 'Mexico'); INSERT INTO HeritageSites (SiteID, Name, Country) VALUES (2, 'Teotihuacan', 'Mexico');
The SQL query counts the number of rows in the HeritageSites table where the Country column is equal to 'Mexico'. This gives the total number of heritage sites in Mexico.
SELECT COUNT(*) FROM HeritageSites WHERE Country = 'Mexico';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the highest number of goals scored by the 'India' women's field hockey team in a single match in the 'Asian Games'? Context: CREATE TABLE teams (team_id INT, team_name TEXT, league TEXT, sport TEXT); INSERT INTO teams (team_id, team_name, league, sport) VALUES (1, 'India', 'Asian Games', 'Field Hockey'); CREATE...
This query calculates the highest number of goals scored by the 'India' women's field hockey team in a single match in the 'Asian Games' by selecting the max of 'goals' where the 'team_id' matches 'India' and the 'league' is 'Asian Games'.
SELECT MAX(goals) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'India') AND league = 'Asian Games';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total number of accessible technology initiatives by region? Context: CREATE TABLE initiatives (id INT, name VARCHAR(50), region VARCHAR(50), accessibility_rating INT);
This query selects the region and counts the number of accessible technology initiatives for each region. It filters the results where the accessibility rating of the initiative is greater than 6. Lastly, it groups the results by region and counts the number of records for each group.
SELECT region, COUNT(*) as count FROM initiatives WHERE accessibility_rating > 6 GROUP BY region;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What are the names of the excavation sites that have 'Tools' as an artifact type? Context: CREATE TABLE SiteF (site_id INT, site_name TEXT, artifact_type TEXT); INSERT INTO SiteF (site_id, site_name, artifact_type) VALUES (1, 'SiteA', 'Pottery'), (2, 'SiteB', 'Tools'), (3, 'SiteC', 'Jewelry'); INSERT INTO SiteF (site_i...
The SQL query selects the site_name from the SiteF table where the artifact_type is 'Tools'.
SELECT site_name FROM SiteF WHERE artifact_type = 'Tools';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Identify the top 3 industries with the highest average funding amounts Context: CREATE TABLE funding (id INT, company_id INT, amount INT, industry TEXT); INSERT INTO funding (id, company_id, amount, industry) VALUES (1, 1, 50000, 'Technology'); INSERT INTO funding (id, company_id, amount, industry) VALUES (2, 2, 75000,...
This query calculates the average funding amount for each industry and orders the results in descending order, then returns the top 3 industries by average funding amount.
SELECT industry, AVG(amount) as avg_funding FROM funding GROUP BY industry ORDER BY avg_funding DESC LIMIT 3
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Find the number of graduate students from African and Asian backgrounds who have not received any research grants. Context: CREATE TABLE students (student_id INT, student_name VARCHAR(255), student_community VARCHAR(255)); CREATE TABLE research_grants (grant_id INT, student_id INT, grant_amount DECIMAL(10,2), grant_s...
This query lists the number of unique graduate students from African and Asian backgrounds who have not received any research grants. It performs a LEFT JOIN between the students and research_grants tables on the student_id column to include all students, regardless of grant receipt. The WHERE clause filters the record...
SELECT COUNT(DISTINCT s.student_id) FROM students s LEFT JOIN research_grants rg ON s.student_id = rg.student_id WHERE rg.grant_id IS NULL AND s.student_community IN ('African', 'Asian');
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Count the number of 'Bus' records in the 'PublicTransit' table where 'city' is 'New York' Context: CREATE TABLE PublicTransit (transit_id INT, transit_type VARCHAR(20), city VARCHAR(20)); INSERT INTO PublicTransit (transit_id, transit_type, city) VALUES (1, 'Bus', 'New York'), (2, 'Subway', 'New York'), (3, 'Train', 'L...
This query counts the number of records in the 'PublicTransit' table where 'transit_type' is 'Bus' and 'city' is 'New York'. It uses the COUNT aggregation function to count the number of records, and the WHERE clause filters the records by the conditions 'transit_type' = 'Bus' and 'city' = 'New York'.
SELECT COUNT(*) FROM PublicTransit WHERE transit_type = 'Bus' AND city = 'New York';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total amount donated by new donors in H2 2019? Context: CREATE TABLE Donors (DonorID int, DonationDate date, DonationAmount numeric);
A subquery is used to select donations made by new donors in H2 2019. The outer query calculates the total donation amount from the result of the subquery.
SELECT SUM(DonationAmount) FROM (SELECT DonationAmount FROM Donors WHERE DonationDate BETWEEN '2019-07-01' AND '2019-12-31' AND DonorID NOT IN (SELECT DonorID FROM Donors WHERE DonationDate < '2019-07-01')) AS NewDonors;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which customers have not placed an order in the last 3 months? Context: CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE); INSERT INTO customers (customer_id, customer_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO or...
This query first left joins the customers table with the orders table on their common column customer_id. It then filters the results to only include rows where the order_date is older than 3 months ago (i.e., the customer has not placed an order in the last 3 months). Finally, it selects the customer_name column from ...
SELECT c.customer_name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH) IS NULL;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Who are the top 3 customers with the highest quantity of sustainable garments purchased? Context: CREATE TABLE customer_purchases(customer_id INT, garment_id INT, quantity INT, sustainable BOOLEAN); INSERT INTO customer_purchases(customer_id, garment_id, quantity, sustainable) VALUES (101, 1, 2, true), (102, 2, 1, fals...
The SQL query calculates the total quantity of sustainable garments purchased by each customer and returns the top 3 customers with the highest total quantity.
SELECT customer_id, SUM(quantity) as total_quantity FROM customer_purchases WHERE sustainable = true GROUP BY customer_id ORDER BY total_quantity DESC LIMIT 3;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total quantity of recycled polyester used by brands with a 'fair trade' certification? Context: CREATE TABLE brands (brand_id INT, brand_name TEXT, country TEXT, certification TEXT); INSERT INTO brands (brand_id, brand_name, country, certification) VALUES (1, 'EcoBrand', 'Germany', 'fair trade'), (2, 'Green...
Join the brands and material_usage tables on brand_id, filter for brands with 'fair trade' certification, and calculate the total quantity of recycled polyester used.
SELECT SUM(mu.quantity) AS total_quantity FROM brands b JOIN material_usage mu ON b.brand_id = mu.brand_id WHERE b.certification = 'fair trade' AND mu.material_type = 'recycled_polyester';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total investment in climate mitigation projects in Sub-Saharan Africa in 2020? Context: CREATE TABLE climate_mitigation_projects (project_id INT, location VARCHAR(50), investment_amount FLOAT, investment_year INT); INSERT INTO climate_mitigation_projects (project_id, location, investment_amount, investment_...
This SQL query calculates the total investment in climate mitigation projects in Sub-Saharan Africa in 2020 by using the SUM() aggregation function on the investment_amount column, filtering the data by the location column containing the string 'Sub-Saharan Africa' and the investment_year column being equal to 2020.
SELECT SUM(investment_amount) FROM climate_mitigation_projects WHERE location LIKE 'Sub-Saharan Africa' AND investment_year = 2020;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List all the record labels and their respective countries that have signed more than 10 new artists in any quarter of 2021. Context: CREATE TABLE RecordLabels (LabelName TEXT, Country TEXT, Quarter TEXT(2), Year INTEGER, NewArtists INTEGER); INSERT INTO RecordLabels (LabelName, Country, Quarter, Year, NewArtists) VALUE...
The SQL query groups the RecordLabels table data by label name and country, and filters the results for the year 2021. It then uses the HAVING clause to only show record labels that have signed more than 10 new artists in any quarter.
SELECT LabelName, Country FROM RecordLabels WHERE Year = 2021 GROUP BY LabelName, Country HAVING SUM(NewArtists) > 10;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Insert a new record in the table "deep_sea_exploration" with values 'Indian Ocean', 6000, '2022-03-04' Context: CREATE TABLE deep_sea_exploration (id INT, location VARCHAR(50), depth INT, date DATE);
This query inserts a new record in the "deep_sea_exploration" table with values 'Indian Ocean', 6000, '2022-03-04'.
INSERT INTO deep_sea_exploration (location, depth, date) VALUES ('Indian Ocean', 6000, '2022-03-04');
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the minimum age of all animals in the 'animal_population' table? Context: CREATE TABLE animal_population (animal_id INT, animal_type VARCHAR(10), age INT); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (1, 'zebra', 7); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (2, '...
This query finds the minimum age of all animals in the 'animal_population' table. It does this by using the MIN function, which returns the smallest value in a numeric column. In this case, it finds the smallest age value in the table.
SELECT MIN(age) FROM animal_population;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the distribution of space debris by location? Context: CREATE TABLE space_debris (debris_id INT, name VARCHAR(255), type VARCHAR(255), location POINT); INSERT INTO space_debris (debris_id, name, type, location) VALUES (1, 'Defunct Satellite', 'Satellite', ST_POINT(0, 0));
This SQL query groups space debris by type and location (longitude and latitude), and aggregates the count for each group.
SELECT type, ST_X(location) as longitude, ST_Y(location) as latitude, COUNT(*) as count FROM space_debris GROUP BY type, ST_X(location), ST_Y(location);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Which clinics in Texas need to increase their pediatric vaccine stock? Context: CREATE TABLE clinics (clinic_id INT, clinic_name TEXT, state TEXT); INSERT INTO clinics (clinic_id, clinic_name, state) VALUES (1, 'Rural Health Clinic', 'Texas');
This query first selects the clinic names from the 'clinics' table where the state is 'Texas'. Then, it filters the clinics that have pediatric vaccine stock less than 500 units by using a subquery and the 'NOT IN' operator.
SELECT clinic_name FROM clinics WHERE state = 'Texas' AND clinic_id NOT IN (SELECT clinic_id FROM vaccine_stocks WHERE vaccine_type = 'Pediatric' AND quantity >= 500);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Identify the agricultural innovation metrics that have the lowest average score in Central America and the Caribbean. Context: CREATE TABLE innovation_metrics (id INT, name TEXT, score INT, region TEXT); INSERT INTO innovation_metrics (id, name, score, region) VALUES (1, 'Soil Monitoring', 7, 'Central America'), (2, 'I...
This query first calculates the average score for each innovation metric in Central America and the Caribbean by grouping by the 'name' column and using the AVG function. It then orders the results in ascending order based on the average score and returns the name of the metric with the lowest average score.
SELECT name, AVG(score) as avg_score FROM innovation_metrics WHERE region IN ('Central America', 'Caribbean') GROUP BY name ORDER BY avg_score LIMIT 1;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What are the total sales for approved drugs with a manufacturing cost of less than $100 per unit? Context: CREATE TABLE drug_approval (drug_name TEXT, approval_status TEXT); INSERT INTO drug_approval (drug_name, approval_status) VALUES ('DrugA', 'approved'), ('DrugB', 'approved'), ('DrugC', 'pending'), ('DrugD', 'appro...
This query calculates the total sales for approved drugs with a manufacturing cost of less than $100 per unit. It does so by summing the sales from the drug_sales table where the drug is present in the drug_approval table with an approval status of approved and the manufacturing cost is less than $100.
SELECT SUM(sales) FROM drug_sales INNER JOIN drug_approval ON drug_sales.drug_name = drug_approval.drug_name INNER JOIN manufacturing_costs ON drug_sales.drug_name = manufacturing_costs.drug_name WHERE drug_approval.approval_status = 'approved' AND manufacturing_costs.cost_per_unit < 100;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Update the temperature for the record with date '2022-02-02' in the AquaticFarm table to 22.5 degrees. Context: CREATE TABLE AquaticFarm (date DATE, temperature FLOAT); INSERT INTO AquaticFarm (date, temperature) VALUES ('2022-02-01', 21.0), ('2022-02-02', 22.0), ('2022-02-03', 23.0);
This query updates the temperature for the record with date '2022-02-02' in the AquaticFarm table to 22.5 degrees. It does this by filtering the records for the given date and updating the temperature using the SET clause and the WHERE clause to filter the records for the given date.
UPDATE AquaticFarm SET temperature = 22.5 WHERE date = '2022-02-02';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What are the total CVE scores and number of scans for each system in the Security department in the last month, and which systems were scanned the most? Context: CREATE TABLE systems (system_id INT, system_name VARCHAR(255), department VARCHAR(255));CREATE TABLE cve_scores (system_id INT, score INT, scan_date DATE);CRE...
This query joins the systems, cve_scores, and scan_dates tables on their respective ID columns. It filters for systems in the Security department and with scan dates in the past month. Then, it calculates the total CVE score and number of scans for each system and groups them by system_name. Additionally, it assigns a ...
SELECT s.system_name, SUM(c.score) as total_score, COUNT(sd.scan_date) as scan_count, ROW_NUMBER() OVER (ORDER BY COUNT(sd.scan_date) DESC) as scan_rank FROM systems s INNER JOIN cve_scores c ON s.system_id = c.system_id INNER JOIN scan_dates sd ON s.system_id = sd.system_id WHERE s.department = 'Security' AND sd.scan_...
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total number of criminal cases filed in each county in Texas in the last 5 years? Context: CREATE TABLE criminal_cases (case_id INT, filing_date DATE, county VARCHAR(50)); INSERT INTO criminal_cases (case_id, filing_date, county) VALUES (1, '2020-01-01', 'Harris'), (2, '2019-02-01', 'Dallas'), (3, '2018-03-...
This query calculates the total number of criminal cases filed in each county in Texas in the last 5 years using the COUNT function with a filter for cases filed in the last 5 years. The WHERE clause is used to filter for cases filed in the last 5 years.
SELECT county, COUNT(*) FILTER (WHERE filing_date >= NOW() - INTERVAL '5 years') AS total_cases FROM criminal_cases GROUP BY county;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the balance for the savings account with the highest balance? Context: CREATE TABLE savings (account_number INT, customer_name VARCHAR(50), balance DECIMAL(10, 2), is_shariah_compliant BOOLEAN); INSERT INTO savings (account_number, customer_name, balance, is_shariah_compliant) VALUES (1, 'Ahmed', 5000, true), (...
This SQL query finds the balance for the savings account with the highest balance by using the MAX function on the balance column.
SELECT MAX(balance) FROM savings;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Delete all emergency records with a response time greater than 60 minutes in the 'Northside' district. Context: CREATE TABLE districts (district_id INT, district_name TEXT);CREATE TABLE emergencies (emergency_id INT, district_id INT, response_time INT);
The SQL query performs an inner join between the districts and emergencies tables, joining them on the district_id column. It then deletes records from the emergencies table where the response_time is greater than 60 minutes and the district_name is 'Northside'.
DELETE e FROM emergencies e INNER JOIN districts d ON e.district_id = d.district_id WHERE d.district_name = 'Northside' AND e.response_time > 60;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the maximum sustainable sourcing score for 'Asian' menu items? Context: CREATE TABLE MenuItems (category VARCHAR(20), sourcing_score FLOAT); INSERT INTO MenuItems (category, sourcing_score) VALUES ('Asian', 9.5),('Asian', 10.0),('Asian', 9.2);
The SQL query finds the maximum sustainable sourcing score for 'Asian' menu items by selecting the maximum sourcing_score value where the category is 'Asian'.
SELECT MAX(sourcing_score) FROM MenuItems WHERE category = 'Asian';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total claim amount for each risk level? Context: CREATE TABLE Claims (Claim_Amount NUMERIC, Risk_Level TEXT); INSERT INTO Claims (Claim_Amount, Risk_Level) VALUES (2500, 'High'), (3000, 'Very High'), (2000, 'Medium'), (1500, 'Low');
This query calculates the total claim amount for each risk level. It does this by using the GROUP BY statement to group the data by the Risk_Level column, and then calculates the sum of the Claim_Amount column for each group using the SUM function.
SELECT Risk_Level, SUM(Claim_Amount) FROM Claims GROUP BY Risk_Level;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Update the price of the 'Quinoa Salad' in Restaurant A to $15.49. Context: CREATE TABLE menu (restaurant_id INT, item_name TEXT, item_type TEXT, price DECIMAL); INSERT INTO menu (restaurant_id, item_name, item_type, price) VALUES (1, 'Spaghetti', 'Entree', 12.99), (1, 'Quinoa Salad', 'Entree', 14.99), (1, 'Garden Burge...
This query updates the price of the 'Quinoa Salad' in Restaurant A to $15.49. It filters the menu table by restaurant_id and item_name and then updates the price for those items.
UPDATE menu SET price = 15.49 WHERE restaurant_id = 1 AND item_name = 'Quinoa Salad';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List the top 10 miners with the highest transaction fees earned in the EFG blockchain. Context: CREATE TABLE EFG_transaction (transaction_hash VARCHAR(255), block_number INT, transaction_index INT, from_address VARCHAR(255), to_address VARCHAR(255), value DECIMAL(18,2), gas_price DECIMAL(18,2), gas_limit INT, timestamp...
Calculate the total transaction fees earned by each miner in the EFG blockchain. First, group the transaction data by miner, and calculate the total transaction fees earned by multiplying the gas price and gas limit. Then, order the result by total fees earned and return the top 10 rows.
SELECT miner, SUM(gas_price * gas_limit) AS total_fees_earned FROM EFG_transaction GROUP BY miner ORDER BY total_fees_earned DESC LIMIT 10;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
Calculate the average age of digital assets (in days) grouped by their asset type. Context: CREATE TABLE digital_assets (asset_id INT PRIMARY KEY, name VARCHAR(255), creation_date DATETIME, asset_type VARCHAR(50)); INSERT INTO digital_assets (asset_id, name, creation_date, asset_type) VALUES (1, 'Asset1', '2022-01-01 1...
The query uses the AVG() and DATEDIFF() functions along with GROUP BY to calculate the average age of digital assets in days grouped by asset_type.
SELECT asset_type, AVG(DATEDIFF(CURRENT_DATE, creation_date)) AS avg_age_days FROM digital_assets GROUP BY asset_type;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the sum of transportation emissions for all products in the Transportation_Emissions view? Context: CREATE VIEW Transportation_Emissions AS SELECT product_id, product_name, transportation_emissions FROM Products; INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, pac...
The SQL query calculates the sum of transportation emissions for all products in the Transportation_Emissions view by selecting all records from the view and computing the sum of their transportation_emissions values.
SELECT SUM(transportation_emissions) FROM Transportation_Emissions;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What's the total production budget for the superhero genre? Context: CREATE TABLE movies(movie_id INT, title VARCHAR(50), genre VARCHAR(20), release_year INT, budget INT, gross INT); INSERT INTO movies(movie_id, title, genre, release_year, budget, gross) VALUES (1, 'Avatar', 'Sci-Fi', 2009, 237000000, 2787965087), (2, ...
Summarizes the total production budget for the superhero genre.
SELECT SUM(budget) FROM movies WHERE genre = 'Superhero';
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the total energy generation from solar and wind in the province of Alberta for the year 2022? Context: CREATE TABLE energy_generation (province VARCHAR(20), energy_source VARCHAR(20), generation INT, year INT); INSERT INTO energy_generation (province, energy_source, generation, year) VALUES ('Alberta', 'Solar',...
This SQL query calculates the total energy generation from solar and wind in Alberta for the year 2022 by summing up the 'generation' column where the 'province' is Alberta and the 'energy_source' is either Solar or Wind, and the year is 2022.
SELECT SUM(generation) FROM energy_generation WHERE province = 'Alberta' AND (energy_source = 'Solar' OR energy_source = 'Wind') AND year = 2022;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
List the names of countries that have both eco-friendly hotels and cultural heritage sites, but no virtual tours or museums. Context: CREATE TABLE eco_hotels (hotel_id INT, country VARCHAR(20), name VARCHAR(50)); INSERT INTO eco_hotels (hotel_id, country, name) VALUES (1, 'India', 'Green Resort'), (2, 'Mexico', 'Eco Re...
Find the countries that have eco-friendly hotels and cultural heritage sites, but no virtual tours or museums, using INTERSECT and EXCEPT.
(SELECT country FROM eco_hotels WHERE name IS NOT NULL) INTERSECT (SELECT country FROM cultural_sites WHERE type = 'heritage') EXCEPT (SELECT country FROM (SELECT * FROM virtual_tours WHERE type = 'virtual' UNION ALL SELECT * FROM museums WHERE type = 'museum') AS combined_data);
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the minimum biomass of fish for each species in the Asia-Pacific region? Context: CREATE TABLE fish_stock (id INT, species VARCHAR, biomass FLOAT, country VARCHAR); INSERT INTO fish_stock (id, species, biomass, country) VALUES (1, 'Tilapia', 500.0, 'Indonesia'), (2, 'Salmon', 800.0, 'Norway'), (3, 'Trout', 300....
This query calculates the minimum biomass of fish for each species in the Asia-Pacific region by grouping the records by the species column and finding the minimum biomass value for each group, and filtering the records to only include those from countries in the Asia-Pacific region.
SELECT species, MIN(biomass) FROM fish_stock WHERE country IN ('Indonesia', 'Thailand', 'New Zealand') GROUP BY species;
1,788,754,867
sql_database
gretelai/synthetic_text_to_sql
sql
What is the name of the author who has published the most articles? Context: CREATE TABLE authors_articles (author_id INT, article_id INT); INSERT INTO authors_articles (author_id, article_id) VALUES (1, 1), (1, 2), (2, 3);CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'Alice...
This query finds the name of the author who has published the most articles. It does so by using a subquery to first count the number of articles for each author, grouped by author_id. It then orders the results by the count in descending order and returns the top result. Finally, it joins the result of the subquery wi...
SELECT authors.name FROM authors JOIN (SELECT author_id, COUNT(*) as article_count FROM authors_articles GROUP BY author_id ORDER BY article_count DESC LIMIT 1) as article_counts ON authors.id = article_counts.author_id;
1,788,754,867
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
14