context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE courts (court_id INT, court_name VARCHAR(255), PRIMARY KEY (court_id)); CREATE TABLE court_cases (court_id INT, case_id INT, PRIMARY KEY (court_id, case_id), FOREIGN KEY (court_id) REFERENCES courts(court_id), FOREIGN KEY (case_id) REFERENCES cases(case_id)); INSERT INTO courts (court_id, court_name) VALUES (1, 'Court 1'), (2, 'Court 2'), (3, 'Court 3'); INSERT INTO court_cases (court_id, case_id) VALUES (1, 1), (1, 2), (2, 3), (3, 4);
Show the total number of cases handled by each court in the justice system
SELECT c.court_name, COUNT(cc.court_id) FROM courts c INNER JOIN court_cases cc ON c.court_id = cc.court_id GROUP BY c.court_name;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, institution_name VARCHAR(100), country VARCHAR(50));
How many Shariah-compliant financial institutions are there in South America?
SELECT COUNT(*) FROM shariah_compliant_finance WHERE country LIKE 'South America%';
gretelai_synthetic_text_to_sql
CREATE TABLE client (client_id INT, name TEXT, country TEXT, financial_wellbeing_score INT); INSERT INTO client (client_id, name, country, financial_wellbeing_score) VALUES (15, 'Sophia Rodriguez', 'Brazil', 75); CREATE VIEW brazil_clients AS SELECT * FROM client WHERE country = 'Brazil';
Delete the record for client with ID 15 from the database.
DELETE FROM client WHERE client_id = 15;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT); INSERT INTO company (id, name, industry, founding_date, founder_gender) VALUES (1, 'Xi Inc', 'Technology', '2018-01-01', 'Female'); INSERT INTO company (id, name, industry, founding_date, founder_gender) VALUES (2, 'Omicron Corp', 'Healthcare', '2019-01-01', 'Male');
Which industries had the highest number of female-founded startups in 2018?
SELECT industry, COUNT(*) as num_female_startups FROM company WHERE founding_date >= '2018-01-01' AND founder_gender = 'Female' GROUP BY industry ORDER BY num_female_startups DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE guides (guide_id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), num_virtual_tours INT); INSERT INTO guides (guide_id, name, city, country, num_virtual_tours) VALUES (1, 'John Doe', 'Paris', 'France', 60), (2, 'Jane Smith', 'Paris', 'France', 45);
What is the average number of virtual tours conducted per month by each guide in Paris, France, for the year 2022, for guides who have conducted more than 50 virtual tours?
SELECT city, country, AVG(num_virtual_tours) FROM guides WHERE city = 'Paris' AND country = 'France' AND YEAR(visit_date) = 2022 GROUP BY city, country HAVING COUNT(guide_id) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE ev_cars (car_id INT, car_name VARCHAR(255), horsepower INT, state VARCHAR(255));
Retrieve the top 2 electric vehicles with the highest horsepower in each state
SELECT car_name, horsepower, state FROM (SELECT car_name, horsepower, state, ROW_NUMBER() OVER (PARTITION BY state ORDER BY horsepower DESC) as rn FROM ev_cars) t WHERE rn = 1 OR rn = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, strain_id INT, quantity INT, date DATE, total_sales DECIMAL(10,2)); INSERT INTO sales (id, strain_id, quantity, date, total_sales) VALUES (1, 6, 50, '2022-04-01', 750.00), (2, 7, 40, '2022-04-02', 600.00);
Find the top 5 strains with the highest percentage of sales from all strains sold in Michigan dispensaries in Q2 2022.
SELECT strain_id, name, SUM(quantity)*100.0/SUM(SUM(quantity)) OVER (PARTITION BY NULL) as percentage FROM sales s JOIN strains st ON s.strain_id = st.id WHERE state = 'Michigan' AND date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY strain_id, name ORDER BY percentage DESC FETCH NEXT 5 ROWS ONLY;
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 a new employee record with ID 5, first name 'Jack', last name 'Lee', department 'Marketing', and salary 65000.
INSERT INTO EmployeeData VALUES (5, 'Jack', 'Lee', 'Marketing', 65000);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_type VARCHAR(20)); INSERT INTO customers (customer_id, customer_type) VALUES (1, 'Retail'), (2, 'Wholesale'), (3, 'Institutional'); CREATE TABLE transactions (transaction_date DATE, customer_id INT, transaction_value DECIMAL(10, 2)); INSERT INTO transactions (transaction_date, customer_id, transaction_value) VALUES ('2022-01-01', 1, 500.00), ('2022-01-02', 1, 750.00), ('2022-01-03', 2, 3000.00), ('2022-01-04', 3, 15000.00), ('2022-02-05', 1, 200.00), ('2022-02-06', 2, 1200.00), ('2022-02-07', 3, 800.00);
What is the average transaction value per day for the past month for customers in the 'Wholesale' customer type?
SELECT AVG(transactions.transaction_value) as avg_transaction_value FROM transactions JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND customers.customer_type = 'Wholesale';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, city TEXT, partnership BOOLEAN); INSERT INTO renewable_projects (id, city, partnership) VALUES (1, 'São Paulo', true), (2, 'Rio de Janeiro', false);
How many renewable energy projects in 'São Paulo' and 'Rio de Janeiro' are part of a cross-state partnership?
SELECT COUNT(*) FROM renewable_projects WHERE city IN ('São Paulo', 'Rio de Janeiro') AND partnership = true;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, extraction_date DATE, quantity_minerals INT); INSERT INTO mine (id, name, location, extraction_date, quantity_minerals) VALUES (1, 'Golden Gorge', 'CA', '2022-01-01', 500), (2, 'Silver Ridge', 'NV', '2022-01-05', 300), (3, 'Bronze Basin', 'CO', '2022-01-10', 400), (4, 'Golden Gorge', 'CA', '2022-02-01', 600), (5, 'Silver Ridge', 'NV', '2022-02-05', 350), (6, 'Bronze Basin', 'CO', '2022-02-10', 450), (7, 'Platinum Point', 'AZ', '2022-03-15', 700), (8, 'Golden Gorge', 'CA', '2022-03-20', 800), (9, 'Silver Ridge', 'NV', '2022-03-25', 750), (10, 'Bronze Basin', 'CO', '2022-03-30', 850);
Report the total quantity of minerals extracted by each mine in 2022
SELECT name, SUM(quantity_minerals) FROM mine WHERE EXTRACT(YEAR FROM extraction_date) = 2022 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(20), sold_out BOOLEAN); INSERT INTO Concerts (id, city, sold_out) VALUES (1, 'Chicago', TRUE), (2, 'Chicago', FALSE), (3, 'New York', TRUE);
What was the total number of concerts sold out in a specific city?
SELECT COUNT(*) FROM Concerts WHERE city = 'Chicago' AND sold_out = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE victims (victim_id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), race VARCHAR(50), ethnicity VARCHAR(50), date_of_birth DATE);
Insert a new victim record into the 'victims' table
INSERT INTO victims (victim_id, name, age, gender, race, ethnicity, date_of_birth) VALUES (1001, 'Jamal Johnson', 35, 'Male', 'African American', 'African American', '1987-03-24');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtWorkSales (Artist VARCHAR(255), ArtWork VARCHAR(255), Year INT, Revenue DECIMAL(10,2)); INSERT INTO ArtWorkSales (Artist, ArtWork, Year, Revenue) VALUES ('Van Gogh', 'Starry Night', 1889, 1000.00), ('Van Gogh', 'Sunflowers', 1888, 800.00), ('Warhol', 'Campbell Soup Can', 1962, 750.00), ('Warhol', 'Marilyn Diptych', 1962, 1500.00);
What was the total revenue for each artist's work sold in the year 2020?
SELECT Artist, SUM(Revenue) as TotalRevenue FROM ArtWorkSales WHERE Year = 2020 GROUP BY Artist;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty_computer_science (id INT, name VARCHAR(50), department VARCHAR(50), tenure_status VARCHAR(50), num_publications INT); INSERT INTO faculty_computer_science (id, name, department, tenure_status, num_publications) VALUES (1, 'Julia', 'School of Computer Science', 'Tenured', 15), (2, 'Kai', 'School of Computer Science', 'Tenured', 21), (3, 'Lila', 'School of Computer Science', 'Not Tenured', 10);
What is the minimum number of publications for faculty members in the School of Computer Science who are tenured?
SELECT MIN(num_publications) FROM faculty_computer_science WHERE department = 'School of Computer Science' AND tenure_status = 'Tenured';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_projects_2 (project_id INT, name VARCHAR(50), location VARCHAR(50), capacity_mw FLOAT); INSERT INTO wind_projects_2 (project_id, name, location, capacity_mw) VALUES (1, 'Wind Farm 2', 'Texas', 50.0);
Show the installed capacity of Wind Power projects in Texas
SELECT SUM(capacity_mw) FROM wind_projects_2 WHERE location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(50), model VARCHAR(50), date_purchased DATE);
Update the 'model' column for 'equipment_id' 1001 in the 'equipment' table to 'NextSeq 550DX'
WITH cte1 AS (UPDATE equipment SET model = 'NextSeq 550DX' WHERE equipment_id = 1001) SELECT * FROM cte1;
gretelai_synthetic_text_to_sql
CREATE TABLE startup_funding (fund_id INT, startup_name VARCHAR(50), funding_year INT, funding_amount FLOAT); INSERT INTO startup_funding (fund_id, startup_name, funding_year, funding_amount) VALUES (1, 'BioGenesis', 2018, 3000000), (2, 'InnoLife', 2019, 5000000), (3, 'CellSolutions', 2020, 2500000), (4, 'BioGenesis', 2019, 1000000), (5, 'CellSolutions', 2021, 6000000);
What is the total funding for each biotech startup by year?
SELECT startup_name, funding_year, SUM(funding_amount) as total_funding FROM startup_funding GROUP BY startup_name, funding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE securities (security_id INT PRIMARY KEY, security_symbol VARCHAR(10), security_name VARCHAR(100));
Update the security name for the security with a security symbol of 'ABC' to 'ABC International'
UPDATE securities SET security_name = 'ABC International' WHERE security_symbol = 'ABC';
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (dapp_id INT, dapp_name VARCHAR(255), total_transactions INT, industry_category VARCHAR(255));
What is the total number of transactions for each industry category, sorted by the total transaction count in descending order?
SELECT industry_category, SUM(total_transactions) as total_transactions FROM dapps GROUP BY industry_category ORDER BY total_transactions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, institution_name VARCHAR(255), country VARCHAR(255)); INSERT INTO shariah_compliant_finance (id, institution_name, country) VALUES (1, 'Bank Islam Malaysia', 'Malaysia'), (2, 'CIMB Islamic', 'Malaysia'), (3, 'Maybank Islamic', 'Malaysia');
How many Shariah-compliant financial institutions are there in Malaysia?
SELECT COUNT(*) FROM shariah_compliant_finance WHERE country = 'Malaysia';
gretelai_synthetic_text_to_sql
CREATE TABLE brand_cruelty_rating (brand_name VARCHAR(100), cruelty_free_rating DECIMAL(3,2)); INSERT INTO brand_cruelty_rating (brand_name, cruelty_free_rating) VALUES ('Lush', 4.8), ('The Body Shop', 4.6), ('Pacifica', 4.9), ('Kat Von D', 5.0), ('Cover FX', 4.5);
What is the average cruelty-free rating for cosmetic brands?
SELECT AVG(cruelty_free_rating) FROM brand_cruelty_rating WHERE is_cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean (id INT, name VARCHAR(50)); CREATE TABLE level (id INT, value FLOAT, ocean_id INT); INSERT INTO ocean (id, name) VALUES (1, 'Atlantic'), (2, 'Pacific'); INSERT INTO level (id, value, ocean_id) VALUES (1, 7.8, 1), (2, 7.9, 2), (3, 7.7, 2);
What is the maximum and minimum ocean acidification level ('level') in the Pacific Ocean ('ocean')?
SELECT MAX(level.value), MIN(level.value) FROM level INNER JOIN ocean ON level.ocean_id = ocean.id WHERE ocean.name = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE OntarioBudget (service VARCHAR(30), year INT, budget INT); INSERT INTO OntarioBudget (service, year, budget) VALUES ('Education', 2019, 10000000), ('Healthcare', 2019, 15000000), ('Education', 2020, 12000000), ('Healthcare', 2020, 18000000);
What is the total budget for education and healthcare services in Ontario in 2019 and 2020?
SELECT service, SUM(budget) FROM OntarioBudget WHERE service IN ('Education', 'Healthcare') AND year IN (2019, 2020) GROUP BY service;
gretelai_synthetic_text_to_sql
CREATE TABLE greenhouse_gas_emissions (country VARCHAR(50), year INT, total_emissions INT); INSERT INTO greenhouse_gas_emissions (country, year, total_emissions) VALUES ('China', 2020, 10500), ('United States', 2020, 5100), ('India', 2020, 2700), ('Russia', 2020, 2600), ('Japan', 2020, 1200), ('Germany', 2020, 750);
List the top 3 countries with the highest greenhouse gas emissions in 2020.
SELECT country, total_emissions FROM greenhouse_gas_emissions WHERE year = 2020 ORDER BY total_emissions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselSafety (VesselID INT, SafetyScore INT, Region VARCHAR(20)); INSERT INTO VesselSafety (VesselID, SafetyScore, Region) VALUES (1, 90, 'North Pacific'), (2, 60, 'North Atlantic'), (3, 85, 'North Pacific'); CREATE TABLE CargoTransport (TransportID INT, VesselID INT, CargoWeight INT); INSERT INTO CargoTransport (TransportID, VesselID, CargoWeight) VALUES (1, 1, 500), (2, 2, 300), (3, 3, 700);
What is the total cargo weight transported by vessels with a good safety record in the North Pacific?
SELECT SUM(CargoWeight) FROM CargoTransport CT JOIN VesselSafety VS ON CT.VesselID = VS.VesselID WHERE VS.SafetyScore >= 80 AND VS.Region = 'North Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE TrainingSessions (SessionID INT, SessionName VARCHAR(50), SessionDate DATE, NumberOfAttendees INT);
How many diversity and inclusion training sessions were conducted in the first half of 2021?
SELECT COUNT(*) as TotalSessions FROM TrainingSessions WHERE SessionDate BETWEEN '2021-01-01' AND '2021-06-30' AND SessionName = 'Diversity and Inclusion';
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (user_id INT, member_type VARCHAR(20)); INSERT INTO memberships (user_id, member_type) VALUES (101, 'Gold'), (102, 'Platinum'), (103, 'Silver'), (104, 'Bronze'), (105, 'Gold');
How many users have a membership type of 'Gold' or 'Silver'?
SELECT COUNT(*) as num_users FROM memberships WHERE member_type IN ('Gold', 'Silver');
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), sector VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO workers (id, name, sector, salary) VALUES (1, 'John Doe', 'Circular Economy', 70000.00), (2, 'Jane Smith', 'Circular Economy', 75000.00), (3, 'Mike Johnson', 'Circular Economy', 80000.00);
What is the highest salary of a worker in the circular economy sector?
SELECT MAX(salary) FROM workers WHERE sector = 'Circular Economy';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (id INT AUTO_INCREMENT, company_name VARCHAR(50), country VARCHAR(50), certification_level VARCHAR(50), PRIMARY KEY(id));
Insert a new record in the 'circular_economy' table with values: 'Company A', 'USA', 'Platinum'
INSERT INTO circular_economy (company_name, country, certification_level) VALUES ('Company A', 'USA', 'Platinum');
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policyholder_id INT, first_name VARCHAR(20), last_name VARCHAR(20), email VARCHAR(30), date_of_birth DATE); INSERT INTO policyholders (policyholder_id, first_name, last_name, email, date_of_birth) VALUES (1, 'John', 'Doe', 'johndoe@example.com', '1985-05-15'), (2, 'Jane', 'Doe', 'janedoe@example.com', '1990-08-08'), (3, 'Bob', 'Smith', 'bobsmith@example.com', '1976-11-12');
Display policyholders with their age
SELECT policyholder_id, first_name, last_name, DATEDIFF(CURDATE(), date_of_birth)/365 AS age FROM policyholders;
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, city VARCHAR(20), trip_date DATE, mode VARCHAR(20), distance INT); INSERT INTO trips VALUES (1, 'nyc', '2022-01-01', 'subway', 10); INSERT INTO trips VALUES (2, 'nyc', '2022-01-05', 'bus', 15); INSERT INTO trips VALUES (3, 'la', '2022-01-10', 'light_rail', 8);
What is the total number of public transportation trips taken in 'nyc' in January 2022?
SELECT SUM(distance) FROM trips WHERE city = 'nyc' AND YEAR(trip_date) = 2022 AND MONTH(trip_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (name VARCHAR(255), tribe VARCHAR(255), crop_yield INT); INSERT INTO farmers (name, tribe, crop_yield) VALUES ('John Smith', 'Navajo', 1000), ('Jane Doe', 'Navajo', 1200), ('Mike Johnson', 'Navajo', 1500), ('Sara Williams', 'Navajo', 800), ('David Brown', 'Navajo', 1300);
Who are the top 5 farmers in terms of crop yield in the Navajo Nation?
SELECT name, crop_yield FROM farmers WHERE tribe = 'Navajo' ORDER BY crop_yield DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (year INT, efficiency FLOAT); INSERT INTO wastewater_treatment (year, efficiency) VALUES (2018, 0.85), (2018, 0.88), (2019, 0.87), (2019, 0.89), (2019, 0.90), (2022, 0.91), (2022, 0.92), (2023, 0.93), (2023, 0.94);
Determine the average wastewater treatment efficiency in 2022 and 2023.
SELECT AVG(efficiency) FROM wastewater_treatment WHERE year IN (2022, 2023);
gretelai_synthetic_text_to_sql
CREATE TABLE DeliveryTimes (delivery_id INT, delivery_time INT, eco_friendly_packaging BOOLEAN);
What is the average delivery time for eco-friendly packaging in Australia?
SELECT AVG(delivery_time) FROM DeliveryTimes WHERE eco_friendly_packaging = TRUE AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE member_heart_rate (member_id INT, workout_id INT, heart_rate INT); INSERT INTO member_heart_rate (member_id, workout_id, heart_rate) VALUES (1, 1, 120), (1, 2, 130), (2, 3, 150), (2, 4, 140), (3, 5, 110); CREATE TABLE premium_members (member_id INT, is_premium BOOLEAN); INSERT INTO premium_members (member_id, is_premium) VALUES (1, TRUE), (2, TRUE), (3, FALSE);
What is the average heart rate during workouts for members who have a premium membership?
SELECT AVG(heart_rate) FROM member_heart_rate JOIN premium_members ON member_heart_rate.member_id = premium_members.member_id WHERE is_premium = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE contract_negotiators(id INT, name VARCHAR(255), contract_value FLOAT);
Who are the top 3 contract negotiators based on the total value of contracts they have negotiated?
SELECT name, SUM(contract_value) FROM contract_negotiators GROUP BY name ORDER BY SUM(contract_value) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (4, 'Herbal Haven'); CREATE TABLE sales (sale_id INT, dispensary_id INT, product_id INT, quantity INT, sale_date DATE); INSERT INTO sales (sale_id, dispensary_id, product_id, quantity, sale_date) VALUES (20, 4, 2, 2, '2021-12-31');
Delete sales records from 'Herbal Haven' dispensary before 2022.
DELETE FROM sales WHERE dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Herbal Haven') AND sale_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE user_access (id INT, user_account VARCHAR(20), access_type VARCHAR(20), timestamp TIMESTAMP);
Which user accounts have accessed sensitive data without authorization in the last year?
SELECT user_account FROM user_access WHERE access_type = 'unauthorized' AND timestamp >= NOW() - INTERVAL 1 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_ethics (region VARCHAR(255), tool VARCHAR(255), usage FLOAT, updated_on DATE);
Insert new record with ethical AI tool 'EthicalToolC' in ai_ethics table
INSERT INTO ai_ethics (region, tool, usage, updated_on) VALUES ('Global', 'EthicalToolC', 85.6, CURDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE crypto_transactions (transaction_id INT, digital_asset VARCHAR(20), transaction_amount DECIMAL(10,2), transaction_time DATETIME);
What is the total transaction amount for each digital asset in the 'crypto_transactions' table, partitioned by day and ordered by the total transaction amount in descending order?
SELECT digital_asset, SUM(transaction_amount) as total_transaction_amount, DATE_TRUNC('day', transaction_time) as day FROM crypto_transactions GROUP BY digital_asset, day ORDER BY total_transaction_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, MenuItemName varchar(50), SaleAmount numeric(10, 2), SustainabilityRating int); INSERT INTO MenuItems (MenuItemID, RestaurantID, MenuItemName, SaleAmount, SustainabilityRating) VALUES (1, 1, 'Quinoa Salad', 2000, 5); INSERT INTO MenuItems (MenuItemID, RestaurantID, MenuItemName, SaleAmount, SustainabilityRating) VALUES (2, 1, 'Chickpea Curry', 3000, 4); INSERT INTO MenuItems (MenuItemID, RestaurantID, MenuItemName, SaleAmount, SustainabilityRating) VALUES (3, 2, 'Tofu Stir Fry', 4000, 5); INSERT INTO MenuItems (MenuItemID, RestaurantID, MenuItemName, SaleAmount, SustainabilityRating) VALUES (4, 2, 'Vegetable Sushi', 1000, 3); CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(50), City varchar(50)); INSERT INTO Restaurants (RestaurantID, RestaurantName, City) VALUES (1, 'The Green Garden', 'San Francisco'); INSERT INTO Restaurants (RestaurantID, RestaurantName, City) VALUES (2, 'Healthy Bites', 'Los Angeles');
Calculate the percentage of menu items with sustainable sourcing ratings above 3 for each restaurant.
SELECT R.RestaurantName, (COUNT(M.MenuItemID) * 100.0 / (SELECT COUNT(MenuItemID) FROM MenuItems WHERE RestaurantID = R.RestaurantID)) AS Percentage FROM MenuItems M JOIN Restaurants R ON M.RestaurantID = R.RestaurantID WHERE M.SustainabilityRating > 3 GROUP BY R.RestaurantName;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_violations (id INT PRIMARY KEY, algorithm_name VARCHAR(50), violation_type VARCHAR(20), violation_date DATE, risk_level VARCHAR(10)); CREATE TABLE algorithm_details (id INT PRIMARY KEY, algorithm_name VARCHAR(50), developer VARCHAR(50), release_year INT);
List all AI safety violations for algorithms released in 2021 and their corresponding risk levels
SELECT algorithm_details.algorithm_name, ai_safety_violations.violation_type, ai_safety_violations.violation_date, ai_safety_violations.risk_level FROM algorithm_details JOIN ai_safety_violations ON algorithm_details.algorithm_name = ai_safety_violations.algorithm_name WHERE algorithm_details.release_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE donations_update (donor_id INT, donor_name VARCHAR(255), donation_amount INT); INSERT INTO donations_update (donor_id, donor_name, donation_amount) VALUES (1, 'John Doe', 5000), (2, 'Jane Smith', 7000), (3, 'Alice Johnson', 8000);
Update the donation amount for donor 'John Doe' to $6000.
UPDATE donations_update SET donation_amount = 6000 WHERE donor_name = 'John Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE LanguagePreservation (id INT, country VARCHAR(50), language VARCHAR(50), status VARCHAR(50)); INSERT INTO LanguagePreservation (id, country, language, status) VALUES (1, 'Vanuatu', 'Bislama', 'Vulnerable');
What languages are preserved in Vanuatu?
SELECT DISTINCT language FROM LanguagePreservation WHERE country = 'Vanuatu';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), region VARCHAR(50), completed INT); INSERT INTO courses (course_id, course_name, region, completed) VALUES (1, 'Python Programming', 'North', 100), (2, 'Data Science', 'South', 150), (3, 'Open Education', 'East', 200), (4, 'Lifelong Learning', 'West', 250);
How many open pedagogy courses have been completed by region?
SELECT region, SUM(completed) AS total_completed FROM courses GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255)); CREATE TABLE schools (id INT, city_id INT, name VARCHAR(255), budget INT);
What is the average budget for all public schools in each city?
SELECT c.name, AVG(s.budget) AS avg_budget FROM cities c JOIN schools s ON c.id = s.city_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors VALUES (1, 'John Doe', 50.00, '2020-01-01'); INSERT INTO donors VALUES (2, 'Jane Smith', 100.00, '2020-02-01');
What was the total amount donated by individual donors from California in the year 2020?
SELECT SUM(donation_amount) FROM donors WHERE donor_state = 'California' AND YEAR(donation_date) = 2020 AND donor_id NOT IN (SELECT donor_id FROM organizations);
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, name TEXT, state TEXT); INSERT INTO workplaces (id, name, state) VALUES (1, 'RST Company', 'Florida');
Update the name of the workplace with ID 1 to 'TUV Company'.
UPDATE workplaces SET name = 'TUV Company' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Participants (ParticipantID INT, Ethnicity VARCHAR(255)); CREATE TABLE Programs (ProgramID INT, ParticipantID INT);
What is the average number of restorative justice programs attended by participants, partitioned by ethnicity?
SELECT Ethnicity, AVG(COUNT(*)) OVER(PARTITION BY Ethnicity) FROM Participants JOIN Programs ON Participants.ParticipantID = Programs.ParticipantID GROUP BY Ethnicity, Participants.ParticipantID;
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS animal_introductions (animal_id INT, habitat_id INT); INSERT INTO animal_introductions (animal_id, habitat_id) VALUES (1, 1); INSERT INTO animal_introductions (animal_id, habitat_id) VALUES (2, 2); INSERT INTO animal_introductions (animal_id, habitat_id) VALUES (3, 3); INSERT INTO animal_introductions (animal_id, habitat_id) VALUES (4, 1); CREATE TABLE if NOT EXISTS animal_region (animal_id INT, animal_name VARCHAR(50), habitat_id INT); INSERT INTO animal_region (animal_id, animal_name, habitat_id) VALUES (1, 'Tiger', 1); INSERT INTO animal_region (animal_id, animal_name, habitat_id) VALUES (2, 'Leopard', 2); INSERT INTO animal_region (animal_id, animal_name, habitat_id) VALUES (3, 'Jaguar', 3); INSERT INTO animal_region (animal_id, animal_name, habitat_id) VALUES (4, 'Tiger', 4);
Find the habitats that are shared by both the Tiger and the Leopard.
SELECT habitat_id FROM animal_region WHERE animal_name = 'Tiger' INTERSECT SELECT habitat_id FROM animal_region WHERE animal_name = 'Leopard';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name TEXT, vegan BOOLEAN); INSERT INTO products (id, name, vegan) VALUES (1, 'Shirt', 1), (2, 'Pants', 0);
How many items are made of vegan materials?
SELECT COUNT(*) FROM products WHERE vegan = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (exhibition_id INT, name VARCHAR(255)); INSERT INTO exhibitions (exhibition_id, name) VALUES (1, 'Art of the Renaissance'); CREATE TABLE visitors (visitor_id INT, exhibition_id INT, visit_date DATE); INSERT INTO visitors (visitor_id, exhibition_id, visit_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-01-02'), (3, 1, '2022-01-03'), (4, 1, '2022-01-05');
How many visitors attended the Art of the Renaissance exhibition on each day in January 2022?
SELECT visit_date, COUNT(visitor_id) as num_visitors FROM visitors WHERE exhibition_id = 1 AND visit_date >= '2022-01-01' AND visit_date <= '2022-01-31' GROUP BY visit_date;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region VARCHAR(255), sites INTEGER, arts INTEGER); INSERT INTO regions (region, sites, arts) VALUES ('Region A', 5, 3); INSERT INTO regions (region, sites, arts) VALUES ('Region B', 8, 2);
Find the number of heritage sites and traditional art forms in each region.
SELECT region, SUM(sites), SUM(arts) FROM regions GROUP BY region
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name TEXT, ocean TEXT, avg_depth REAL);
What is the average depth of all marine protected areas in the Pacific and Indian oceans?
SELECT AVG(avg_depth) FROM marine_protected_areas WHERE ocean IN ('Pacific', 'Indian');
gretelai_synthetic_text_to_sql
CREATE TABLE state (id INT, name VARCHAR(255)); INSERT INTO state (id, name) VALUES (1, 'California'); CREATE TABLE restaurant (id INT, name VARCHAR(255), state_id INT, type VARCHAR(255)); INSERT INTO restaurant (id, name, state_id, type) VALUES (1, 'Green Vegan', 1, 'vegan'), (2, 'Steak House', 1, 'non-vegan'); CREATE TABLE menu (id INT, item VARCHAR(255), price DECIMAL(5,2), daily_sales INT, restaurant_id INT);
Identify the daily sales and revenue for 'vegan' menu items in 'California' restaurants
SELECT r.name, m.item, m.daily_sales, m.price * m.daily_sales as revenue FROM menu m JOIN restaurant r ON m.restaurant_id = r.id JOIN state s ON r.state_id = s.id WHERE s.name = 'California' AND r.type = 'vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistsOceania (id INT, name TEXT, region TEXT); INSERT INTO ArtistsOceania (id, name, region) VALUES (1, 'Alice Johnson', 'Oceania'), (2, 'Bob Brown', 'Oceania'); CREATE TABLE ArtPiecesOceania (id INT, artist_id INT, title TEXT); INSERT INTO ArtPiecesOceania (id, artist_id, title) VALUES (1, 1, 'Ocean Waves'), (2, 1, 'Coral Reef'), (3, 2, 'Aboriginal Art');
What is the minimum number of art pieces created by an artist in Oceania?
SELECT MIN(art_count) FROM (SELECT COUNT(ArtPiecesOceania.id) AS art_count FROM ArtPiecesOceania JOIN ArtistsOceania ON ArtPiecesOceania.artist_id = ArtistsOceania.id GROUP BY ArtistsOceania.id) AS ArtCountPerArtistOceania
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), region VARCHAR(20)); INSERT INTO patients (id, name, age, gender, region) VALUES (1, 'John Doe', 35, 'Male', 'Urban East');
What is the average age of male patients in urban areas?
SELECT AVG(age) FROM patients WHERE gender = 'Male' AND region = 'Urban East';
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID INT, Name VARCHAR(50), Disability BOOLEAN); INSERT INTO Students VALUES (1, 'John Doe', true); CREATE TABLE Accommodations (AccommodationID INT, AccommodationType VARCHAR(50), StudentID INT); INSERT INTO Accommodations VALUES (1, 'Note Taker', 1);
What is the total number of students who have utilized disability support programs and their accommodation types?
SELECT COUNT(DISTINCT s.StudentID), a.AccommodationType FROM Students s INNER JOIN Accommodations a ON s.StudentID = a.StudentID WHERE s.Disability = true GROUP BY a.AccommodationType;
gretelai_synthetic_text_to_sql
CREATE TABLE Sports_Game_E (player_id INT, name VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO Sports_Game_E (player_id, name, age, gender) VALUES (1, 'John Doe', 28, 'Male'), (3, 'Alice Johnson', 27, 'Female'), (10, 'Jessica White', 31, 'Female');
List all players who have played "Sports Game E" and are over 25 years old.
SELECT * FROM Sports_Game_E WHERE age > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE membership (member_id INT, membership_type VARCHAR(20), gender VARCHAR(10)); INSERT INTO membership (member_id, membership_type, gender) VALUES (1, 'Platinum', 'Female'), (2, 'Gold', 'Male'), (3, 'Platinum', 'Non-binary'); CREATE TABLE activity_data (member_id INT, steps INT, timestamp TIMESTAMP); INSERT INTO activity_data (member_id, steps, timestamp) VALUES (1, 5000, '2022-01-01 10:00:00'), (1, 7000, '2022-01-01 11:00:00'), (2, 8000, '2022-01-01 10:00:00'), (2, 9000, '2022-01-01 11:00:00'), (3, 4000, '2022-01-01 10:00:00'), (3, 6000, '2022-01-01 11:00:00');
How many steps did members take in total, in the past week, separated by membership type?
SELECT membership_type, SUM(steps) as total_steps FROM activity_data a JOIN membership m ON a.member_id = m.member_id WHERE timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-08 23:59:59' GROUP BY membership_type;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS service_data (service_id int, revenue float, company varchar(30), region varchar(30)); INSERT INTO service_data (service_id, revenue, company, region) VALUES (1, 25000, 'SecureSphere', 'Americas'), (2, 30000, 'SecureSphere', 'Americas'), (3, 28000, 'SecureSphere', 'Americas');
What is the total revenue generated by cybersecurity services offered by SecureSphere in the Americas?
SELECT SUM(revenue) FROM service_data WHERE service LIKE '%cybersecurity%' AND company = 'SecureSphere' AND region = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (org_id INT, name VARCHAR(50));CREATE TABLE Initiatives (initiative_id INT, org_id INT, status VARCHAR(50), success_rate DECIMAL(3,2));INSERT INTO Organizations (org_id, name) VALUES (1, 'Community Development Fund'), (2, 'Rural Growth Foundation'), (3, 'Empowerment Network');INSERT INTO Initiatives (initiative_id, org_id, status, success_rate) VALUES (1, 1, 'completed', 0.85), (2, 2, 'completed', 0.92), (3, 3, 'in_progress', NULL), (4, 1, 'completed', 0.95), (5, 3, 'in_progress', NULL);
Identify the number of community development initiatives implemented by each organization and their respective success rates.
SELECT Organizations.name, COUNT(Initiatives.initiative_id), AVG(Initiatives.success_rate) FROM Organizations LEFT JOIN Initiatives ON Organizations.org_id = Initiatives.org_id GROUP BY Organizations.name;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, gender VARCHAR(6), school VARCHAR(10)); INSERT INTO faculty (id, gender, school) VALUES (1, 'male', 'Arts'), (2, 'female', 'Engineering'), (3, 'male', 'Physics'); CREATE TABLE schools (id INT, school VARCHAR(10)); INSERT INTO schools (id, school) VALUES (1, 'Arts'), (2, 'Engineering'), (3, 'Physics');
What is the percentage of female faculty members in each school?
SELECT school, (COUNT(*) FILTER (WHERE gender = 'female')) * 100.0 / COUNT(*) AS percentage FROM faculty JOIN schools ON faculty.school = schools.school GROUP BY school;
gretelai_synthetic_text_to_sql
CREATE TABLE sustain_activities (activity_id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO sustain_activities (activity_id, name, location) VALUES (1, 'Hiking in Eco-Parks', 'New Zealand'), (2, 'Birdwatching Tours', 'New Zealand');
Which sustainable tourism activities are available in New Zealand?
SELECT name FROM sustain_activities WHERE location = 'New Zealand';
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, department VARCHAR(20), city VARCHAR(20), number_of_calls INT); INSERT INTO emergency_calls (id, department, city, number_of_calls) VALUES (1, 'Police', 'Miami', 3000), (2, 'Fire', 'Miami', 2000), (3, 'Police', 'New York', 4000);
What is the total number of emergency calls received by the police department in the city of Miami?
SELECT SUM(number_of_calls) FROM emergency_calls WHERE department = 'Police' AND city = 'Miami';
gretelai_synthetic_text_to_sql
CREATE TABLE transit (id INT, goods_id INT, weight INT, origin_country VARCHAR(50), carrier VARCHAR(50)); INSERT INTO transit (id, goods_id, weight, origin_country, carrier) VALUES (1, 101, 25, 'Canada', 'Carrier A'), (2, 102, 35, 'Mexico', 'Carrier B'), (3, 103, 45, 'China', 'Carrier A');
What is the total weight of goods in transit on each route, grouped by the origin country and the carrier?
SELECT origin_country, carrier, SUM(weight) as total_weight FROM transit GROUP BY origin_country, carrier;
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (vendor_id INT, vendor_name VARCHAR(50), state VARCHAR(50), ethical_labor BOOLEAN); INSERT INTO vendors VALUES (1, 'VendorA', 'New York', true); INSERT INTO vendors VALUES (2, 'VendorB', 'Texas', false); CREATE TABLE products (product_id INT, product_name VARCHAR(50), vendor_id INT); INSERT INTO products VALUES (1, 'Product1', 1); INSERT INTO products VALUES (2, 'Product2', 1); INSERT INTO products VALUES (3, 'Product3', 2);
How many products are sold by vendors in New York with ethical labor practices?
SELECT COUNT(DISTINCT products.product_id) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE vendors.ethical_labor = true AND vendors.state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousDrivingResearch (Country VARCHAR(50), Studies INT); INSERT INTO AutonomousDrivingResearch (Country, Studies) VALUES ('Sweden', 18), ('Germany', 30), ('Norway', 16), ('Finland', 14), ('Denmark', 12);
How many autonomous driving research studies have been conducted in Sweden?
SELECT Studies FROM AutonomousDrivingResearch WHERE Country = 'Sweden';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (ID INT, Name VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO CommunityHealthWorkers (ID, Name, Age, Country) VALUES (1, 'John Doe', 35, 'USA'), (2, 'Jane Smith', 40, 'USA');
What is the average age of community health workers in the United States?
SELECT AVG(Age) FROM CommunityHealthWorkers WHERE Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE VIEW sales_data AS SELECT o.order_id, c.customer_gender, g.garment_size, g.garment_type, g.price, g.quantity, EXTRACT(MONTH FROM o.order_date) AS order_month FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN garments g ON oi.garment_id = g.garment_id;
Identify the top 3 most popular garment sizes, based on quantity sold, for each gender, from the 'sales_data' view, for the spring season.
SELECT customer_gender, garment_size, SUM(quantity) FROM sales_data WHERE order_month IN (3, 4, 5, 6) GROUP BY customer_gender, garment_size HAVING SUM(quantity) IN (SELECT MAX(SUM(quantity)) FROM sales_data WHERE order_month IN (3, 4, 5, 6) GROUP BY customer_gender, garment_size) LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_records (record_id INT, incident_count INT, vessel_id INT); CREATE TABLE vessels (vessel_id INT, vessel_name TEXT);
Display safety records with the number of incidents and corresponding vessel names for vessels 'M' and 'N' from the 'safety_records' and 'vessels' tables
SELECT v.vessel_name, s.incident_count FROM safety_records s INNER JOIN vessels v ON s.vessel_id = v.vessel_id WHERE v.vessel_name IN ('M', 'N');
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, stars INT, revenue FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, stars, revenue) VALUES (1, 'Hotel V', 'Japan', 4, 12000), (2, 'Hotel W', 'Japan', 5, 18000), (3, 'Hotel X', 'Japan', 4, 15000); CREATE TABLE otas (ota_id INT, ota_name TEXT, hotel_id INT, otas_revenue FLOAT); INSERT INTO otas (ota_id, ota_name, hotel_id, otas_revenue) VALUES (1, 'OTA1', 1, 8000), (2, 'OTA2', 2, 10000), (3, 'OTA3', 3, 13000), (4, 'OTA4', 1, 10000);
What is the maximum revenue generated by a single OTA for a hotel in Japan with a 4-star rating?
SELECT MAX(otas_revenue) FROM otas JOIN hotels ON otas.hotel_id = hotels.hotel_id WHERE hotels.country = 'Japan' AND hotels.stars = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE esports.tournaments (id INT, title VARCHAR(50), country VARCHAR(20));
How many esports tournaments were held in each country in the 'esports' schema?
SELECT country, COUNT(*) AS tournaments_count FROM esports.tournaments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE TechEmployment(company VARCHAR(255), country VARCHAR(255), disabled BOOLEAN);INSERT INTO TechEmployment(company, country, disabled) VALUES('TechCo', 'Canada', TRUE), ('InnoTech', 'Canada', FALSE), ('AIforGood', 'UK', TRUE), ('TechGiant', 'UK', FALSE);
What is the percentage of disabled individuals employed in tech companies in Canada and the UK?
SELECT country, SUM(CASE WHEN disabled THEN 1 ELSE 0 END) / COUNT(*) * 100 AS disabled_percentage FROM TechEmployment GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE grant (id INT, title VARCHAR(100)); CREATE TABLE publication (id INT, title VARCHAR(100), journal_name VARCHAR(50), impact_factor DECIMAL(3,1));
What are the research grant titles that have been published in journals with impact factors below 3?
SELECT g.title FROM grant g JOIN publication p ON g.title = p.title WHERE p.impact_factor < 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Operations (id INT, name VARCHAR(50), description TEXT, domain VARCHAR(30)); INSERT INTO Operations (id, name, description, domain) VALUES (1, 'Operation Red Sparrow', 'Counterterrorism operation in the Middle East.', 'Counterterrorism'), (2, 'Operation Nightfall', 'Cyber intelligence operation against a foreign government.', 'Cyber Intelligence'), (3, 'Operation Silver Shield', 'Intelligence operation to gather information about a rogue nation.', 'Counterintelligence'), (4, 'Operation Iron Curtain', 'Cybersecurity operation to protect critical infrastructure.', 'Cybersecurity');
Show the details of intelligence operations related to 'Counterterrorism' and 'Cyber Intelligence'.
SELECT * FROM Operations WHERE domain IN ('Counterterrorism', 'Cyber Intelligence');
gretelai_synthetic_text_to_sql
CREATE TABLE ReverseLogistics (id INT, customer VARCHAR(255), region VARCHAR(255), delivery_time FLOAT, quarter INT, year INT);
What is the average delivery time for reverse logistics shipments in the European Union in Q3 2022?
SELECT AVG(delivery_time) FROM ReverseLogistics WHERE region = 'European Union' AND quarter = 3 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (country VARCHAR(50), year INT, projects INT); INSERT INTO military_innovation (country, year, projects) VALUES ('India', 2018, 65), ('India', 2019, 75), ('India', 2020, 85), ('India', 2021, 95);
What is the average number of military innovation projects completed by 'india' annually from 2018 to 2021?
SELECT country, AVG(projects) as avg_projects FROM military_innovation WHERE country = 'India' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_jobs (id INT, state VARCHAR(50), application_date DATE); INSERT INTO veteran_jobs (id, state, application_date) VALUES (1, 'Texas', '2021-02-15'), (2, 'California', '2021-04-10'), (3, 'Texas', '2022-01-05'), (4, 'California', '2022-03-08');
What is the total number of veteran job applications in California in the last year?
SELECT COUNT(*) FROM veteran_jobs WHERE state = 'California' AND application_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE language_preservation_programs (id INT, program_name VARCHAR(100), language VARCHAR(50)); INSERT INTO language_preservation_programs (id, program_name, language) VALUES (1, 'Endangered Languages Program', 'Quechua'), (2, 'Indigenous Languages Initiative', 'Navajo'), (3, 'Minority Language Support', 'Gaelic');
How many languages are preserved in each language preservation program?
SELECT program_name, COUNT(DISTINCT language) as num_languages FROM language_preservation_programs GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE us_vehicle_count (id INT, type VARCHAR(20), city VARCHAR(20), count INT); INSERT INTO us_vehicle_count (id, type, city, count) VALUES (1, 'electric', 'New York', 3000), (2, 'gasoline', 'New York', 15000), (3, 'electric', 'Los Angeles', 4000), (4, 'gasoline', 'Los Angeles', 12000);
What is the adoption rate of electric vehicles in New York and Los Angeles?
SELECT (SUM(CASE WHEN city = 'New York' AND type = 'electric' THEN count ELSE 0 END) + SUM(CASE WHEN city = 'Los Angeles' AND type = 'electric' THEN count ELSE 0 END)) * 100.0 / (SUM(CASE WHEN city = 'New York' THEN count ELSE 0 END) + SUM(CASE WHEN city = 'Los Angeles' THEN count ELSE 0 END)) FROM us_vehicle_count;
gretelai_synthetic_text_to_sql
CREATE TABLE production(year INT, region VARCHAR(20), element VARCHAR(10), quantity INT); INSERT INTO production VALUES(2021, 'Africa', 'Yttrium', 1200), (2021, 'Europe', 'Yttrium', 800), (2021, 'Asia', 'Yttrium', 400);
What is the percentage of Yttrium production that comes from 'Africa' in 2021?
SELECT (SUM(CASE WHEN region = 'Africa' THEN quantity ELSE 0 END) / SUM(quantity)) * 100.0 FROM production WHERE element = 'Yttrium' AND year = 2021
gretelai_synthetic_text_to_sql
CREATE TABLE song_releases (song_id INT, artist_name VARCHAR(50), genre VARCHAR(20));
Show the artists with the most songs released in the latin genre.
SELECT artist_name, COUNT(*) as num_songs FROM song_releases WHERE genre = 'latin' GROUP BY artist_name ORDER BY num_songs DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName text); INSERT INTO Donors VALUES (1, 'John Doe'); INSERT INTO Donors VALUES (2, 'Jane Smith');CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount numeric, Cause text); INSERT INTO Donations VALUES (1, 1, 500, 'Education'); INSERT INTO Donations VALUES (2, 2, 1000, 'Health');CREATE TABLE Causes (CauseID int, Cause text); INSERT INTO Causes VALUES (1, 'Education'); INSERT INTO Causes VALUES (2, 'Health');
What's the sum of donations for each cause?
SELECT C.Cause, SUM(D.DonationAmount) FROM Donors D INNER JOIN Donations DD ON D.DonorID = DD.DonorID INNER JOIN Causes C ON DD.Cause = C.Cause GROUP BY C.Cause;
gretelai_synthetic_text_to_sql
CREATE TABLE field (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE gas_production (field_id INT, date DATE, gas_production FLOAT);
List all the fields that have a natural gas production of over 10000 cubic meters per day
SELECT f.name FROM field f JOIN gas_production gp ON f.id = gp.field_id WHERE gp.gas_production > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE wellbeing (id INT, region VARCHAR(20), gender VARCHAR(10), score DECIMAL(3,1)); INSERT INTO wellbeing (id, region, gender, score) VALUES (1, 'South America', 'Female', 75.5), (2, 'Southeast Asia', 'Male', 80.0), (3, 'Asia-Pacific', 'Female', 72.0);
What is the maximum financial wellbeing score for women in South America and Southeast Asia?
SELECT MAX(score) FROM wellbeing WHERE region IN ('South America', 'Southeast Asia') AND gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE SCHEMA community_development; Use community_development; CREATE TABLE comm_dev_initiatives (initiative_code VARCHAR(20), budget DECIMAL(10, 2)); INSERT INTO comm_dev_initiatives (initiative_code, budget) VALUES ('CD1', 15000.00), ('CD2', 20000.00), ('CD3', 12000.00);
List all unique community development initiative codes and their corresponding budgets in the 'community_development' schema, sorted by budget in descending order.
SELECT DISTINCT initiative_code, budget FROM community_development.comm_dev_initiatives ORDER BY budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (location VARCHAR(255), longitude FLOAT, depth FLOAT);
What is the average depth of the ocean by longitude range?
SELECT AVG(depth) FROM ocean_depths WHERE longitude BETWEEN -180 AND -90 OR longitude BETWEEN 90 AND 180;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), position VARCHAR(50), left_company BOOLEAN);
Delete all records of employees who left the company, but keep the table
DELETE FROM Employees WHERE left_company = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, state VARCHAR(2), workers INT); CREATE VIEW collective_bargaining AS SELECT * FROM unions WHERE issue = 'collective_bargaining';
What is the minimum number of workers in unions involved in collective bargaining in Ohio?
SELECT MIN(workers) FROM collective_bargaining WHERE state = 'OH';
gretelai_synthetic_text_to_sql
CREATE TABLE post_likes (post_id INT, content_type VARCHAR(20), likes INT); INSERT INTO post_likes (post_id, content_type, likes) VALUES (1, 'photo', 100), (2, 'video', 200), (3, 'link', 150), (4, 'photo', 250), (5, 'video', 300);
What is the maximum number of likes received by a post in each content type in the past week?
SELECT content_type, MAX(likes) AS max_likes FROM post_likes WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY content_type;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_produce_sales (supplier_id INT, sale_date DATE, revenue DECIMAL(5,2));
Find the top 3 suppliers with the highest total revenue from 'organic_produce_sales' table, considering only transactions from 2021?
SELECT supplier_id, SUM(revenue) FROM organic_produce_sales WHERE YEAR(sale_date) = 2021 GROUP BY supplier_id ORDER BY SUM(revenue) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE coral_reefs (name VARCHAR(255), depth FLOAT); INSERT INTO coral_reefs (name, depth) VALUES ('Great Barrier Reef', 15.0), ('Belize Barrier Reef', 10.0);
What is the minimum depth at which coral reefs are found?
SELECT MIN(depth) FROM coral_reefs;
gretelai_synthetic_text_to_sql
CREATE TABLE union_table (union_name VARCHAR(255), total_injuries INT); INSERT INTO union_table (union_name, total_injuries) VALUES ('Union A', 300), ('Union B', 400), ('Union C', 500);
What is the total number of workplace injuries for each union, by union name, in the year 2020?
SELECT union_name, SUM(total_injuries) as total_injuries FROM union_table WHERE YEAR(incident_date) = 2020 GROUP BY union_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_representatives (sales_representative_id INT, name TEXT); CREATE TABLE sales (sale_id INT, sales_representative_id INT, revenue FLOAT); INSERT INTO sales_representatives (sales_representative_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mike Johnson'); INSERT INTO sales (sale_id, sales_representative_id, revenue) VALUES (1, 1, 500.5), (2, 2, 350.2), (3, 3, 700.3), (4, 1, 600.1), (5, 2, 450.7), (6, 3, 800.0), (7, 1, 250.9);
What is the total revenue for each sales representative?
SELECT sr.name, SUM(s.revenue) as total_revenue FROM sales_representatives sr JOIN sales s ON sr.sales_representative_id = s.sales_representative_id GROUP BY sr.sales_representative_id;
gretelai_synthetic_text_to_sql
CREATE TABLE gas_wells (well_id INT, well_name VARCHAR(50), gas_production FLOAT); INSERT INTO gas_wells (well_id, well_name, gas_production) VALUES (1, 'Delta', 2000), (2, 'Echo', 2500), (3, 'Foxtrot', 3000), (4, 'Gamma', 1800), (5, 'Hotel', 1200);
Identify the top 3 wells with the highest gas production in 2019
SELECT well_id, well_name, gas_production FROM (SELECT well_id, well_name, gas_production, ROW_NUMBER() OVER (ORDER BY gas_production DESC) as rank FROM gas_wells WHERE YEAR(timestamp) = 2019) t WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE WellProduction (well_id INT, well_name TEXT, region TEXT, production_qty REAL); INSERT INTO WellProduction (well_id, well_name, region, production_qty) VALUES (1, 'Delta', 'CaspianSea', 1200), (2, 'Echo', 'CaspianSea', 1800), (3, 'Foxtrot', 'CaspianSea', 1600);
What is the total production in the 'CaspianSea' for wells with a production quantity above 1500?
SELECT SUM(production_qty) FROM WellProduction WHERE region = 'CaspianSea' AND production_qty > 1500
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'Tesla', 'Technology', 85.0), (2, 'Microsoft', 'Technology', 82.5), (3, 'IBM', 'Technology', 78.0), (4, 'Pfizer', 'Healthcare', 90.0), (5, 'Johnson & Johnson', 'Healthcare', 92.5), (6, 'Merck', 'Healthcare', 87.5), (7, 'ExxonMobil', 'Energy', 60.0), (8, 'Chevron', 'Energy', 62.5), (9, 'Shell', 'Energy', 65.0), (10, 'JPMorgan Chase', 'Financial', 75.0), (11, 'Bank of America', 'Financial', 77.5), (12, 'Citi', 'Financial', 72.5), (13, 'Wells Fargo', 'Financial', 70.0); CREATE TABLE sector_counts (sector VARCHAR(255), count INT);
What is the total number of companies in each sector with an ESG score above 80?
INSERT INTO sector_counts (sector, count) SELECT sector, COUNT(*) FROM companies WHERE ESG_score > 80 GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance_history (id INT PRIMARY KEY, equipment_id INT, maintenance_date DATE, maintenance_type VARCHAR(50), maintenance_status VARCHAR(20));
Generate a table 'equipment_maintenance_history' to store historical maintenance records for military equipment
CREATE TABLE equipment_maintenance_history (id INT PRIMARY KEY, equipment_id INT, maintenance_date DATE, maintenance_type VARCHAR(50), maintenance_status VARCHAR(20));
gretelai_synthetic_text_to_sql