context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE bus_ridership (user_id INT, trip_date DATE, trip_bus_route VARCHAR(20)); INSERT INTO bus_ridership (user_id, trip_date, trip_bus_route) VALUES (1, '2022-03-01', '38'), (2, '2022-03-01', '159');
Identify the number of public transit users in London by bus route.
SELECT trip_bus_route, COUNT(DISTINCT user_id) AS unique_users FROM bus_ridership GROUP BY trip_bus_route;
gretelai_synthetic_text_to_sql
CREATE TABLE Times (PlayerID INT, Game TEXT, Duration INT); INSERT INTO Times (PlayerID, Game, Duration) VALUES (1, 'Cybernetic Chess', 150), (2, 'Cybernetic Chess', 120), (3, 'Cybernetic Chess', 180);
List the names of players who have played "Cybernetic Chess" for more than 2 hours in total.
SELECT PlayerID, PlayerName FROM Players INNER JOIN Times ON Players.PlayerID = Times.PlayerID WHERE Game = 'Cybernetic Chess' GROUP BY PlayerID HAVING SUM(Duration) > 2 * 60;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (round_name VARCHAR(50), investment_year INT, investment_amount INT, investment_type VARCHAR(50));
Delete all records from the "investment_rounds" table where the investment year is before 2010
DELETE FROM investment_rounds WHERE investment_year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(255));CREATE TABLE products (product_id INT, product_category VARCHAR(255), price DECIMAL(10,2));
What are the product categories with the lowest sales price across all stores?
SELECT product_category, MIN(price) as min_price FROM products JOIN stores ON products.store_id = stores.store_id GROUP BY product_category ORDER BY min_price ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE vegan_restaurants (restaurant_id INT, cuisine VARCHAR(255), avg_calories DECIMAL(5,2));
What is the average calorie intake for meals served in 'vegan_restaurants' table, grouped by cuisine type?
SELECT cuisine, AVG(avg_calories) FROM vegan_restaurants GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE certifications(certification_id INT, product_id INT, certification_type VARCHAR(50), certified_date DATE);
What percentage of cosmetics products are certified cruelty-free in the haircare category?
SELECT 100.0 * COUNT(product_id) / (SELECT COUNT(product_id) FROM cosmetics_products WHERE category = 'haircare') as cruelty_free_percentage FROM certifications JOIN cosmetics_products ON certifications.product_id = cosmetics_products.product_id WHERE certifications.certification_type = 'cruelty-free' AND cosmetics_pro...
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2), policy_type VARCHAR(50), claim_date DATE, policy_holder_state VARCHAR(50)); CREATE TABLE policies (policy_id INT, policy_holder_id INT, policy_type VARCHAR(50));
Identify policyholders with multiple auto insurance claims in the state of Texas in 2021.
SELECT policy_holder_id FROM claims c JOIN policies p ON c.policy_id = p.policy_id WHERE policy_type = 'auto' AND policy_holder_state = 'Texas' AND EXTRACT(YEAR FROM claim_date) = 2021 GROUP BY policy_holder_id HAVING COUNT(claim_id) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, transparency_score DECIMAL(3,2), country VARCHAR(50)); INSERT INTO products (product_id, transparency_score, country) VALUES (1, 8.5, 'USA'), (2, 9.2, 'Canada'), (3, 7.8, 'Mexico');
Which country has the highest average product transparency score?
SELECT country, AVG(transparency_score) AS avg_score FROM products GROUP BY country ORDER BY avg_score DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA ethical_fashion; CREATE TABLE factories (factory_id INT, country VARCHAR(255), water_consumption FLOAT, year INT); INSERT INTO factories VALUES (1,'France',1200,2020),(2,'France',1250,2019),(3,'Germany',1400,2020),(4,'Germany',1350,2019),(5,'Italy',1100,2020),(6,'Italy',1050,2019);
What is the average water consumption of the factories, partitioned by country, for the last 3 years?
SELECT country, AVG(water_consumption) OVER (PARTITION BY country) FROM ethical_fashion.factories WHERE year BETWEEN 2019 AND 2021 ORDER BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE airports (id INT, name VARCHAR(50), location VARCHAR(50), num_employees INT); INSERT INTO airports (id, name, location, num_employees) VALUES (1, 'Calgary International Airport', 'Alberta', 150);
Count the number of airports in 'Alberta' with more than 100 employees
SELECT COUNT(*) FROM airports WHERE location = 'Alberta' GROUP BY location HAVING COUNT(*) > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE Coral (Name VARCHAR(255), Region VARCHAR(255), Health_Status VARCHAR(255));
Insert a new record into the Coral table for the Elkhorn Coral, with the region being the Caribbean and a health status of Vulnerable.
INSERT INTO Coral (Name, Region, Health_Status) VALUES ('Elkhorn Coral', 'Caribbean', 'Vulnerable');
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (id INT, city VARCHAR(20), country VARCHAR(20), date DATE);
What is the average number of virtual tours conducted per month in Paris, France?
SELECT AVG(COUNT(*)) FROM virtual_tours WHERE city = 'Paris' AND country = 'France' GROUP BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT, start_location VARCHAR(50), end_location VARCHAR(50), distance INT, cost INT); INSERT INTO routes VALUES (1, 'Location A', 'Location B', 100, 1500), (2, 'Location A', 'Location C', 200, 2000), (3, 'Location B', 'Location C', 150, 1200);
Find the top 3 routes by cost efficiency.
SELECT start_location, end_location, (distance * 1.0 / cost) as cost_efficiency FROM routes ORDER BY cost_efficiency DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (dish_id INT, dish_name VARCHAR(50)); CREATE TABLE Ingredients (ingredient_id INT, dish_id INT, quantity INT); INSERT INTO Dishes (dish_id, dish_name) VALUES (1, 'Quinoa Salad'), (2, 'Cheeseburger'), (3, 'Veggie Burger'); INSERT INTO Ingredients (ingredient_id, dish_id, quantity) VALUES (1, 1, 2), (...
What is the total quantity of ingredients for each dish in the inventory?
SELECT D.dish_name, SUM(I.quantity) as total_quantity FROM Dishes D JOIN Ingredients I ON D.dish_id = I.dish_id GROUP BY D.dish_name;
gretelai_synthetic_text_to_sql
CREATE TABLE StudentMentalHealth (id INT, name TEXT, mental_health_score INT, ethnicity TEXT); INSERT INTO StudentMentalHealth (id, name, mental_health_score, ethnicity) VALUES (1, 'Jessica', 75, 'Latinx'), (2, 'Lucas', 85, 'Asian'), (3, 'Oliver', 95, 'Latinx');
What is the minimum mental health score for students who identify as Latinx in the 'StudentMentalHealth' table?
SELECT MIN(mental_health_score) FROM StudentMentalHealth WHERE ethnicity = 'Latinx';
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSalesByCountry (equipmentName VARCHAR(255), country VARCHAR(255)); INSERT INTO EquipmentSalesByCountry (equipmentName, country) VALUES ('Littoral Combat Ship', 'United States'); INSERT INTO EquipmentSalesByCountry (equipmentName, country) VALUES ('Littoral Combat Ship', 'Philippines');
Which naval equipment has been sold to the most countries?
SELECT equipmentName, COUNT(DISTINCT country) AS country_count FROM EquipmentSalesByCountry GROUP BY equipmentName ORDER BY country_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (name text, cuisine text); INSERT INTO Restaurants (name, cuisine) VALUES ('Global Fusion', 'Asian'), ('Global Fusion', 'Mexican'), ('Global Fusion', 'Italian'), ('Vegan Delight', 'Vegan'), ('Farm Fresh', 'American');
Show the number of different cuisine types served in each restaurant.
SELECT name, COUNT(DISTINCT cuisine) FROM Restaurants GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(255), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('New York', 2019, 33);
Update the recycling rate for the city of New York in 2019 to 35%.
UPDATE recycling_rates SET recycling_rate = 35 WHERE city = 'New York' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, date DATE, team1 TEXT, team2 TEXT, goals1 INT, goals2 INT);
What is the average number of goals scored by a team in a single English Premier League match?
SELECT AVG(goals1 + goals2) FROM matches;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), donation_date DATE, program_id INT); CREATE TABLE programs (program_id INT, program_name TEXT); INSERT INTO programs VALUES (1, 'Food Bank'); INSERT INTO programs VALUES (2, 'Education Support');
What was the total donation amount for each program in 2020?
SELECT program_id, program_name, SUM(donation_amount) as total_donation FROM donations JOIN programs ON donations.program_id = programs.program_id WHERE YEAR(donation_date) = 2020 GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Fields (id INT, location VARCHAR(255), crop_type VARCHAR(255), area FLOAT); INSERT INTO Fields (id, location, crop_type, area) VALUES (1, 'USA', 'Corn', 500.0), (2, 'USA', 'Wheat', 300.0), (3, 'Canada', 'Corn', 250.0);
What is the total area of cornfields in the United States?
SELECT SUM(area) FROM Fields WHERE crop_type = 'Corn' AND location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (song_genre VARCHAR(255), city VARCHAR(255), stream_count INT, stream_date DATE); INSERT INTO Streams (song_genre, city, stream_count, stream_date) VALUES ('country', 'Nashville', 1000, '2022-01-01'), ('rock', 'Los Angeles', 800, '2022-01-02');
What is the minimum number of streams for any country song in Nashville?
SELECT MIN(stream_count) FROM Streams WHERE song_genre = 'country' AND city = 'Nashville';
gretelai_synthetic_text_to_sql
CREATE TABLE Outlets (OutletID INT, OutletName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Outlets (OutletID, OutletName, Location) VALUES (1, 'Cafe Central', 'New York'), (2, 'Bistro Bio', 'Paris'); CREATE TABLE WasteData (WasteID INT, OutletID INT, WasteQuantity DECIMAL(5,2), WasteDate DATE); INSERT INTO WasteDat...
What is the total waste generated by our outlets in the last quarter?
SELECT SUM(WasteQuantity) FROM WasteData WHERE WasteDate BETWEEN DATEADD(quarter, -1, GETDATE()) AND GETDATE() GROUP BY OutletID;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(255), initiative_date DATE, community_type VARCHAR(255)); CREATE TABLE impact (initiative_id INT, student_id INT);
List all policy advocacy initiatives that impacted historically underrepresented communities, along with the number of students impacted, and show the top 5 initiatives with the highest number of students impacted?
SELECT i.initiative_name, COUNT(DISTINCT imp.student_id) as students_impacted FROM initiatives i JOIN impact imp ON i.initiative_id = imp.initiative_id WHERE i.community_type = 'historically_underrepresented' GROUP BY i.initiative_name ORDER BY students_impacted DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(position VARCHAR(50), country VARCHAR(20), amount DECIMAL(10,2));INSERT INTO investments(position, country, amount) VALUES('Bioprocess Engineer', 'Germany', 2000000.00), ('Bioprocess Engineer', 'UK', 3000000.00), ('Chemical Engineer', 'Germany', 4000000.00);
What is the total investment in bioprocess engineering positions in Germany?
SELECT SUM(amount) FROM investments WHERE position = 'Bioprocess Engineer' AND country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Wholesale_Prices (Wholesale_Price_ID INT, Strain TEXT, Wholesale_Price DECIMAL); INSERT INTO Wholesale_Prices (Wholesale_Price_ID, Strain, Wholesale_Price) VALUES (1, 'Purple Haze', 5.00); CREATE TABLE Sales (Sale_ID INT, Strain TEXT, Retail_Price DECIMAL); INSERT INTO Sales (Sale_ID, Strain, Retail_Price)...
Determine the difference between the average wholesale price and average retail price per gram for each strain of cannabis flower in Oregon.
SELECT Wholesale_Prices.Strain, AVG(Wholesale_Price) as Avg_Wholesale_Price, AVG(Retail_Price) as Avg_Retail_Price, AVG(Retail_Price) - AVG(Wholesale_Price) as Price_Difference FROM Wholesale_Prices JOIN Sales ON Wholesale_Prices.Strain = Sales.Strain WHERE Sales.Strain IN (SELECT Strain FROM Sales WHERE State = 'OR') ...
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, founded_year INT, industry TEXT, founder_gender TEXT, founder_race TEXT, funding FLOAT);
What is the average funding for startups founded by black men?
SELECT AVG(funding) FROM startups WHERE founder_gender = 'male' AND founder_race = 'black';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (year INT, project_type VARCHAR(255), spending FLOAT); INSERT INTO rural_infrastructure (year, project_type, spending) VALUES (2018, 'Roads', 500000), (2018, 'Bridges', 300000), (2019, 'Roads', 550000), (2019, 'Bridges', 320000), (2020, 'Roads', 600000), (2020, 'Bridges', 350000);
What was the total spending on rural infrastructure projects in 2020, grouped by project type?
SELECT project_type, SUM(spending) FROM rural_infrastructure WHERE year = 2020 GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnelByCountry (country VARCHAR(255), branch VARCHAR(255), personnel_count INT, population INT); INSERT INTO MilitaryPersonnelByCountry (country, branch, personnel_count, population) VALUES ('United States', 'Army', 500000, 331002651), ('China', 'Army', 2000000, 1439323776), ('India', 'Army', 1...
What is the total number of military personnel in each branch of the armed forces, for countries with a population of over 100 million?
SELECT country, branch, SUM(personnel_count) FROM MilitaryPersonnelByCountry WHERE population > 100000000 GROUP BY country, branch;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(255)); CREATE TABLE songs (song_id INT, title VARCHAR(255), genre_id INT, release_date DATE, artist_id INT); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, stream_date DATE, revenue DECIMAL(10,2));
What is the daily revenue of the top 3 artists with the highest total revenue?
SELECT a.artist_name, st.stream_date, SUM(s.revenue) as daily_revenue FROM artists a JOIN songs s ON a.artist_id = s.artist_id JOIN streams st ON s.song_id = st.song_id WHERE a.artist_id IN (SELECT a.artist_id FROM artists a JOIN songs s ON a.artist_id = s.artist_id JOIN streams st ON s.song_id = st.song_id GROUP BY a....
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, name VARCHAR(255), location VARCHAR(255), revenue FLOAT); INSERT INTO concerts (id, name, location, revenue) VALUES (1, 'ConcertA', 'New York City', 5000.0), (2, 'ConcertB', 'Los Angeles', 7000.0), (3, 'ConcertC', 'New York City', 6000.0);
What is the total revenue for concerts held in New York City and Los Angeles?
SELECT location, SUM(revenue) AS total_revenue FROM concerts WHERE location IN ('New York City', 'Los Angeles') GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), category VARCHAR(20), rating DECIMAL(2,1)); INSERT INTO hotels (hotel_id, name, category, rating) VALUES (1, 'The Urban Chic', 'boutique', 4.5), (2, 'The Artistic Boutique', 'boutique', 4.7), (3, 'The Cozy Inn', 'budget', 4.2), (4, 'The Grand Palace', 'luxury', 4.8),...
What is the most popular hotel category based on the number of hotels?
SELECT category, COUNT(*) AS hotel_count, RANK() OVER (ORDER BY COUNT(*) DESC) AS rank FROM hotels GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridge_Info (bridge_id INT, bridge_name VARCHAR(50), location VARCHAR(50), length FLOAT, height FLOAT); INSERT INTO Bridge_Info (bridge_id, bridge_name, location, length, height) VALUES (1, 'Golden Gate Bridge', 'City A', 2737.00, 227.00); INSERT INTO Bridge_Info (bridge_id, bridge_name, location, length, ...
What are the names and locations of all bridges in the Bridge_Info table?
SELECT bridge_name, location FROM Bridge_Info;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (vehicle_id INT, model VARCHAR(255), manufacturer VARCHAR(255), state VARCHAR(255));
how many autonomous vehicles are there in California?
SELECT COUNT(*) FROM autonomous_vehicles WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectParticipation (ParticipationID INT, Contractor VARCHAR(255), ProjectID INT); INSERT INTO ProjectParticipation (ParticipationID, Contractor, ProjectID) VALUES (1, 'Contractor R', 1), (2, 'Contractor S', 1);
Find all defense projects that Contractor R and Contractor S worked on together.
SELECT pp1.ProjectID FROM ProjectParticipation pp1 INNER JOIN ProjectParticipation pp2 ON pp1.ProjectID = pp2.ProjectID WHERE pp1.Contractor = 'Contractor R' AND pp2.Contractor = 'Contractor S';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment_plants (id INT, country VARCHAR(20)); INSERT INTO wastewater_treatment_plants (id, country) VALUES (1, 'Canada'), (2, 'USA'), (3, 'Mexico');
How many wastewater treatment plants are there in Canada?
SELECT COUNT(*) FROM wastewater_treatment_plants WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), salary DECIMAL(5,2), manager_id INT, FOREIGN KEY (manager_id) REFERENCES employees(id)); CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(50), manager_id INT, FOREIGN KEY (manager_id) REFERENCES employe...
Who are the managers in the production department with the lowest salary?
SELECT employees.name AS manager_name, employees.salary AS salary FROM employees INNER JOIN departments ON employees.department = departments.name WHERE departments.name = 'Production' AND employees.position = 'Manager' AND employees.salary = (SELECT MIN(employees.salary) FROM employees WHERE employees.department = dep...
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (id INT, actor VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO threat_actors (id, actor, incident_type) VALUES (1, 'APT28', 'spear phishing'), (2, 'APT33', 'DDoS'), (3, 'APT29', 'malware');
List all unique threat actors and their corresponding incident types.
SELECT actor, incident_type FROM threat_actors;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_projects (project_id INT, project_name TEXT, location TEXT, project_type TEXT, start_date DATE, end_date DATE);
Identify the top 3 countries with the highest number of climate adaptation projects in South America.
SELECT location, COUNT(project_id) AS project_count FROM climate_adaptation_projects WHERE project_type = 'climate_adaptation' AND location LIKE '%South America%' GROUP BY location ORDER BY project_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Name, Age, MembershipType) VALUES (1, 'John Doe', 30, 'Premium'); INSERT INTO Members (MemberID, Name, Age, MembershipType) VALUES (2, 'Jane Smith', 40, 'Basic');
What is the average age of members who have a premium membership?
SELECT AVG(Age) FROM Members WHERE MembershipType = 'Premium';
gretelai_synthetic_text_to_sql
CREATE TABLE Experience (EmployeeID INT, Department VARCHAR(20), YearsOfExperience INT, Salary DECIMAL(10, 2)); INSERT INTO Experience (EmployeeID, Department, YearsOfExperience, Salary) VALUES (1, 'Marketing', 5, 80000.00), (2, 'Marketing', 3, 70000.00), (3, 'IT', 2, 75000.00);
What is the minimum salary for employees in the Marketing department with more than 3 years of experience?
SELECT MIN(Salary) FROM Experience WHERE Department = 'Marketing' AND YearsOfExperience > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255), college VARCHAR(255));CREATE TABLE grant (id INT, department_id INT, title VARCHAR(255), amount DECIMAL(10,2), year INT);
What is the minimum year in which a research grant was awarded to the Department of Mechanical Engineering in the College of Engineering?
SELECT MIN(g.year) FROM grant g JOIN department d ON g.department_id = d.id WHERE d.name = 'Department of Mechanical Engineering' AND d.college = 'College of Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (project_id INT, project_name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE funding_agency (agency_id INT, agency_name VARCHAR(50), project_id INT); INSERT INTO climate_adaptation (project_id, project_name, location, start_date, end_date) VALUES (1, 'Co...
List the climate adaptation projects in Europe and North America, along with their start and end dates and the funding agency name.
SELECT ca.project_name, ca.start_date, ca.end_date, fa.agency_name FROM climate_adaptation ca INNER JOIN funding_agency fa ON ca.project_id = fa.project_id WHERE ca.location IN ('Europe', 'North America');
gretelai_synthetic_text_to_sql
CREATE TABLE open_data_portals (id INT, name VARCHAR(255), continent VARCHAR(255)); INSERT INTO open_data_portals (id, name, continent) VALUES (1, 'data.gov', 'North America'), (2, 'data.gov.uk', 'Europe'), (3, 'data.gouv.fr', 'Europe');
How many open data portals exist in each continent?
SELECT continent, COUNT(*) FROM open_data_portals GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE permit_data (permit_number INT, city VARCHAR(20), category VARCHAR(20), cost INT, issue_date DATE); INSERT INTO permit_data (permit_number, city, category, cost, issue_date) VALUES (1, 'San Francisco', 'Residential', 5000, '2020-01-01'); INSERT INTO permit_data (permit_number, city, category, cost, issue_d...
What was the total cost of permits issued in 'San Francisco' in the 'Residential' category for the year 2020?
SELECT SUM(cost) FROM permit_data WHERE city = 'San Francisco' AND category = 'Residential' AND EXTRACT(YEAR FROM issue_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists investors (id INT PRIMARY KEY, name TEXT, location TEXT, investment_goal TEXT); INSERT INTO investors (id, name, location, investment_goal) VALUES (1, 'John Doe', 'New York', 'Climate Change'); CREATE TABLE if not exists investments (id INT PRIMARY KEY, investor_id INT, nonprofit_id INT, amou...
Who invested more than $15000 in Q1 2021?
SELECT i.name, investment.amount FROM investors i JOIN investments investment ON i.id = investment.investor_id WHERE investment_date BETWEEN '2021-01-01' AND '2021-03-31' AND investment.amount > 15000;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, well_name VARCHAR(100), location VARCHAR(50), status VARCHAR(20)); INSERT INTO wells VALUES (1, 'Well A', 'North Sea', 'Producing'); INSERT INTO wells VALUES (2, 'Well B', 'Gulf of Mexico', 'Abandoned'); INSERT INTO wells VALUES (3, 'Well C', 'Gulf of Mexico', 'Producing'); INSERT INTO wells...
Identify the producing wells in the North Sea and Gulf of Mexico
SELECT well_name FROM wells WHERE (location = 'North Sea' OR location = 'Gulf of Mexico') AND status = 'Producing';
gretelai_synthetic_text_to_sql
CREATE TABLE WaterSources (Location VARCHAR(100), Type VARCHAR(50), Volume FLOAT); INSERT INTO WaterSources (Location, Type, Volume) VALUES ('Nairobi', 'Surface Water', 12000), ('Cape Town', 'Surface Water', 15000);
What is the total volume of surface water in Nairobi and Cape Town?
SELECT Location, SUM(Volume) FROM WaterSources WHERE Type = 'Surface Water' GROUP BY Location;
gretelai_synthetic_text_to_sql
CREATE TABLE Store (id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO Store (id, name, city) VALUES (1, 'Green Earth', 'New York'); INSERT INTO Store (id, name, city) VALUES (2, 'Healthy Harvest', 'Los Angeles'); CREATE TABLE Inventory (id INT, store_id INT, item VARCHAR(50), is_local BOOLEAN, is_organic BOOLEAN...
Which organic grocery stores in New York City sell locally sourced fruits?
SELECT s.name FROM Store s JOIN Inventory i ON s.id = i.store_id WHERE s.city = 'New York' AND i.is_local = TRUE AND i.is_organic = TRUE AND i.item LIKE 'F%';
gretelai_synthetic_text_to_sql
CREATE TABLE military_patents (id INT, country TEXT, filing_date DATE); INSERT INTO military_patents (id, country, filing_date) VALUES (1, 'China', '2018-01-01');
What is the total number of military innovation patents filed by 'China' in the last 5 years?
SELECT COUNT(*) FROM military_patents WHERE country = 'China' AND filing_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, improvement TEXT, therapy TEXT); INSERT INTO patients (id, improvement, therapy) VALUES (1, 'Improved', 'CBT'); INSERT INTO patients (id, improvement, therapy) VALUES (2, 'Not Improved', 'Talk Therapy');
What is the percentage of patients who experienced improvement after cognitive behavioral therapy?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patients)) AS percentage FROM patients WHERE improvement = 'Improved' AND therapy = 'CBT';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates_london(year INT, material_type VARCHAR(20), recycling_rate DECIMAL(5,4)); INSERT INTO recycling_rates_london VALUES (2019, 'Plastic', 0.30), (2020, 'Plastic', 0.35), (2021, 'Plastic', 0.40), (2019, 'Paper', 0.55), (2020, 'Paper', 0.60), (2021, 'Paper', 0.65), (2019, 'Glass', 0.45), (2020, '...
What is the recycling rate for each material type in the last 3 years in London?'
SELECT material_type, AVG(recycling_rate) FROM recycling_rates_london WHERE city = 'London' GROUP BY material_type;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_rights (member_id INT, name VARCHAR(50), union_joined_date DATE); INSERT INTO labor_rights (member_id, name, union_joined_date) VALUES (25, 'Charlotte Brown', '2021-07-18'), (26, 'Ethan Wilson', '2020-01-10'), (27, 'Harper Johnson', '2019-06-29'), (28, 'Madison Davis', '2018-12-04');
What is the latest union membership date for the 'labor_rights' union?
SELECT MAX(union_joined_date) FROM labor_rights;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT, name VARCHAR(255)); INSERT INTO Country (id, name) VALUES (1, 'Canada'), (2, 'Mexico'), (3, 'Brazil'); CREATE TABLE Crop (id INT, name VARCHAR(255), yield INT); INSERT INTO Crop (id, name, yield) VALUES (1, 'Potato', 25), (2, 'Corn', 75), (3, 'Potato', 15);
What is the average yield of potato crops across different countries?
SELECT AVG(Crop.yield) FROM Crop INNER JOIN Country ON Crop.id = Country.id WHERE Crop.name = 'Potato';
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_websites (id INT, url VARCHAR(50), domain VARCHAR(20), screen_reader_friendly BOOLEAN, alt_text_available BOOLEAN); INSERT INTO accessible_websites (id, url, domain, screen_reader_friendly, alt_text_available) VALUES (2, 'example2.com', 'com', true, false);
How many accessible websites are there for each domain?
SELECT domain, COUNT(*) as accessible_websites FROM accessible_websites WHERE screen_reader_friendly = true GROUP BY domain;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (project_type VARCHAR(20), labor_cost DECIMAL(5,2)); INSERT INTO labor_costs (project_type, labor_cost) VALUES ('Residential', 12000), ('Commercial', 25000), ('Public', 18000);
What is the minimum labor cost for each project type?
SELECT project_type, MIN(labor_cost) as min_labor_cost FROM labor_costs GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, disability BOOLEAN, region VARCHAR(255)); INSERT INTO users (id, disability, region) VALUES (1, true, 'North America'), (2, false, 'South America'), (3, true, 'Europe'), (4, false, 'Asia'), (5, true, 'North America'), (6, false, 'Africa');
What is the average number of users with disabilities per region?
SELECT AVG(disability) FROM (SELECT COUNT(*) AS disability, region FROM users GROUP BY region) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_number VARCHAR(10), issue_date DATE); INSERT INTO building_permits (permit_number, issue_date) VALUES ('N-12345', '2021-03-01'), ('A-54321', '2021-06-15'), ('P-98765', '2021-09-30');
List all permits that were issued in the same month as the permit with permit number 'N-12345'
SELECT permit_number FROM building_permits WHERE EXTRACT(MONTH FROM issue_date) = EXTRACT(MONTH FROM '2021-03-01'::DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT, garment_id INT, location_id INT, sale_date DATE);CREATE TABLE Garments (garment_id INT, trend_id INT, fabric_source_id INT, size VARCHAR(50), style VARCHAR(255));CREATE TABLE FabricSources (source_id INT, fabric_type VARCHAR(255), country_of_origin VARCHAR(255), ethical_rating DECIMAL(3...
What is the total sales volume for Recycled fabric garments in London during 2019?
SELECT SUM(sales_volume) FROM LondonRecycledGarments WHERE sale_date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_name TEXT, launch_date DATE); INSERT INTO space_missions (mission_name, launch_date) VALUES ('Sputnik 1', '1957-10-04'), ('Explorer 1', '1958-01-31'), ('Vostok 1', '1961-04-12');
What are the names and launch dates of the first ten space missions?
SELECT mission_name, launch_date FROM space_missions ORDER BY launch_date LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255), author_name VARCHAR(255));
Find the number of unique authors who have published articles in the 'articles' table.
SELECT COUNT(DISTINCT author_name) AS unique_authors FROM articles;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), age INT, race VARCHAR(20), years_of_experience INT); INSERT INTO community_health_workers (worker_id, name, age, race, years_of_experience) VALUES (1, 'John Doe', 45, 'White', 10); INSERT INTO community_health_workers (worker_id, name, age, race, y...
List the number of community health workers and their total years of experience by race, for workers in California.
SELECT race, SUM(years_of_experience) as total_experience, COUNT(*) as num_workers FROM community_health_workers WHERE state = 'California' GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE fair_trade_factories (factory_id INT, factory_name VARCHAR(50), country VARCHAR(50), num_workers INT); INSERT INTO fair_trade_factories (factory_id, factory_name, country, num_workers) VALUES (1, 'Green Manufacturing', 'USA', 500), (2, 'Eco-Friendly Production', 'Canada', 600), (3, 'Sustainable Assembly', ...
What is the total number of workers employed in fair trade certified factories by country?
SELECT country, SUM(num_workers) FROM fair_trade_factories GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE rugby_teams (team_id INT, team_name VARCHAR(50), region VARCHAR(50)); INSERT INTO rugby_teams (team_id, team_name, region) VALUES (1, 'Crusaders', 'Southern Hemisphere'), (2, 'Bulls', 'Southern Hemisphere'), (3, 'Chiefs', 'Southern Hemisphere'); CREATE TABLE rugby_ticket_sales (team_id INT, sale_date DATE,...
Who are the top 3 rugby teams with the highest average ticket sales revenue per game in the Southern Hemisphere?
SELECT rt.team_name, AVG(rt.revenue/rt.quantity) as avg_revenue_per_game FROM rugby_ticket_sales rt JOIN rugby_teams rtt ON rt.team_id = rtt.team_id WHERE rtt.region = 'Southern Hemisphere' GROUP BY rt.team_name ORDER BY avg_revenue_per_game DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_data_usage(subscriber_id INT, usage FLOAT, region VARCHAR(50), date DATE);
What is the average daily data usage for the top 5 data consuming mobile customers in the Southeast region?
SELECT subscriber_id, AVG(usage) FROM daily_data_usage WHERE date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND region = 'Southeast' GROUP BY subscriber_id ORDER BY AVG(usage) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (id INT, project_state TEXT, project_type TEXT, labor_cost DECIMAL(10,2)); INSERT INTO labor_costs (id, project_state, project_type, labor_cost) VALUES (1, 'Florida', 'Residential', 15000.00), (2, 'Florida', 'Commercial', 25000.00), (3, 'California', 'Sustainable', 12000.00);
What is the total labor cost for all building projects in Florida?
SELECT SUM(labor_cost) FROM labor_costs WHERE project_state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE Ethical_AI (project_id INT, project_name VARCHAR(100), region VARCHAR(50), completion_year INT); INSERT INTO Ethical_AI (project_id, project_name, region, completion_year) VALUES (1, 'Project X', 'Oceania', 2021), (2, 'Project Y', 'Latin America', 2022), (3, 'Project Z', 'Europe', 2021);
How many ethical AI projects were completed in Oceania in 2022?
SELECT COUNT(*) FROM Ethical_AI WHERE region = 'Oceania' AND completion_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE policy (policy_number INT, coverage_amount INT, policyholder_age INT); INSERT INTO policy VALUES (1, 50000, 70); INSERT INTO policy VALUES (2, 75000, 30);
What is the average coverage amount for policies with a policyholder age greater than or equal to 65?
SELECT AVG(coverage_amount) FROM policy WHERE policyholder_age >= 65;
gretelai_synthetic_text_to_sql
CREATE TABLE Contractors (ContractorID INT, ContractorName TEXT); CREATE TABLE BuildingPermits (PermitID INT, ContractorID INT, PermitType TEXT, DateIssued DATE);
List the names of contractors who have been issued both residential and commercial building permits in the last 6 months.
SELECT ContractorName FROM Contractors C JOIN BuildingPermits BP1 ON C.ContractorID = BP1.ContractorID JOIN BuildingPermits BP2 ON C.ContractorID = BP2.ContractorID WHERE BP1.PermitType = 'Residential' AND BP2.PermitType = 'Commercial' AND BP1.DateIssued >= DATEADD(month, -6, GETDATE()) AND BP2.DateIssued >= DATEADD(mo...
gretelai_synthetic_text_to_sql
CREATE TABLE animals (animal_id SERIAL PRIMARY KEY, name VARCHAR(255), species VARCHAR(255));
Create a view named "animal_view" based on the "animals" table
CREATE VIEW animal_view AS SELECT animal_id, name, species FROM animals;
gretelai_synthetic_text_to_sql
CREATE TABLE RainfallData (rainfall FLOAT, time DATETIME, crop VARCHAR(255));
What is the total amount of rainfall for each crop type this year?
SELECT crop, SUM(rainfall) FROM RainfallData WHERE YEAR(time) = YEAR(CURRENT_DATE()) GROUP BY crop;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, date DATE, engagement INT); INSERT INTO virtual_tours (tour_id, tour_name, date, engagement) VALUES (1, 'Tour A', '2022-01-01', 100), (2, 'Tour B', '2022-01-05', 150); CREATE TABLE online_travel_agencies (ota_id INT, ota_name TEXT, tour_id INT); INSERT INTO onlin...
How many virtual tours were engaged in the last month for each online travel agency?
SELECT ota_name, COUNT(*) as engagements FROM online_travel_agencies INNER JOIN virtual_tours ON online_travel_agencies.tour_id = virtual_tours.tour_id WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY ota_name;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT PRIMARY KEY, policy_name VARCHAR(100), last_updated DATE); INSERT INTO policies (policy_id, policy_name, last_updated) VALUES (1, 'Acceptable Use Policy', '2020-12-31'), (2, 'Incident Response Policy', '2021-02-14');
List all cybersecurity policies that were last updated in '2020'.
SELECT policy_name, last_updated FROM policies WHERE last_updated LIKE '2020-%';
gretelai_synthetic_text_to_sql
CREATE TABLE city_donations (donation_id INT, donation_amount FLOAT, donation_date DATE, city VARCHAR(50)); INSERT INTO city_donations (donation_id, donation_amount, donation_date, city) VALUES (1, 500, '2021-01-01', 'Tokyo'), (2, 600, '2021-01-02', 'Seoul');
What is the maximum donation amount in 'city_donations' table for 'Asia'?
SELECT MAX(donation_amount) FROM city_donations WHERE city = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), country VARCHAR(50));
Create a table for fan demographics
CREATE TABLE if not exists fan_stats (id INT PRIMARY KEY, fan_id INT, tickets_purchased INT, total_spent DECIMAL(10,2));
gretelai_synthetic_text_to_sql
CREATE TABLE esports_matches (match_id INT, team_id INT, match_result VARCHAR(10));
Add a new column 'total_prize_money' to the 'esports_matches' table
ALTER TABLE esports_matches ADD COLUMN total_prize_money DECIMAL(10,2);
gretelai_synthetic_text_to_sql
CREATE TABLE scooters (id INT PRIMARY KEY, type VARCHAR(20), fare FLOAT, city VARCHAR(20));
What is the average fare of electric scooters in Berlin?
SELECT AVG(fare) FROM scooters WHERE type = 'Electric' AND city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel (Id INT IDENTITY(1,1) PRIMARY KEY, Name VARCHAR(50), Type VARCHAR(50), MaxCapacity INT);
Add new records to the Vessel table for the following vessels: 'Sea Whisperer' (Type: Cargo, MaxCapacity: 12000 tons), 'Aqua Wanderer' (Type: Passenger, MaxCapacity: 1800)
INSERT INTO Vessel (Name, Type, MaxCapacity) VALUES ('Sea Whisperer', 'Cargo', 12000), ('Aqua Wanderer', 'Passenger', 1800);
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(255), SafetyScore INT, LastSafetyCheck DATETIME); INSERT INTO Vessels (ID, Name, SafetyScore, LastSafetyCheck) VALUES (1, 'Globe Master', 95, '2022-02-15'), (2, 'Polaris', 90, '2022-02-10');
What is the rank of the vessel 'Globe Master' based on its safety score in the last month?
SELECT Name, SafetyScore, RANK() OVER (ORDER BY SafetyScore DESC) as Rank FROM Vessels WHERE LastSafetyCheck >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Infectious_Diseases (ID INT, Year INT, Type TEXT, Cases INT); INSERT INTO Infectious_Diseases (ID, Year, Type, Cases) VALUES (1, 2020, 'Flu', 500); INSERT INTO Infectious_Diseases (ID, Year, Type, Cases) VALUES (2, 2021, 'COVID-19', 1000);
What is the total number of infectious diseases recorded in 2020 and 2021, separated by type?
SELECT Type, SUM(Cases) FROM Infectious_Diseases WHERE Year = 2020 GROUP BY Type UNION SELECT Type, SUM(Cases) FROM Infectious_Diseases WHERE Year = 2021 GROUP BY Type;
gretelai_synthetic_text_to_sql
CREATE TABLE PreservationProjects (id INT, name TEXT, country TEXT, revenue FLOAT); INSERT INTO PreservationProjects (id, name, country, revenue) VALUES (1, 'Acropolis Restoration', 'Greece', 8000000), (2, 'Greek Museum Renovation', 'Greece', 9000000);
How much revenue was generated by cultural heritage preservation projects in Greece?
SELECT SUM(revenue) FROM PreservationProjects WHERE country = 'Greece';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates(material_type TEXT, recycling_rate DECIMAL(3,2), recycling_year INT); INSERT INTO recycling_rates(material_type, recycling_rate, recycling_year) VALUES('Plastic', 0.35, 2020), ('Glass', 0.60, 2020), ('Paper', 0.75, 2020);
Identify the recycling rates for each material type in 2020, and calculate the overall recycling rate for that year.
SELECT SUM(recycling_rate) / COUNT(DISTINCT material_type) FROM recycling_rates WHERE recycling_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, country VARCHAR(20), project_name VARCHAR(50), project_cost FLOAT); INSERT INTO agricultural_projects (id, country, project_name, project_cost) VALUES (1, 'Nigeria', 'Crop Rotation', 45000.00), (2, 'Nigeria', 'Livestock Management', 60000.00);
Update the name of the agricultural project with ID 3 to 'Soil Conservation' and increase its cost by 10% in the Nigeria table.
UPDATE agricultural_projects SET project_name = 'Soil Conservation', project_cost = project_cost * 1.10 WHERE id = 3 AND country = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName VARCHAR(50), Region VARCHAR(50), JoinDate DATE);
How many volunteers are there in each region who joined in 2020?
SELECT Region, COUNT(VolunteerID) FROM Volunteers WHERE YEAR(JoinDate) = 2020 GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (accommodation_id INT, name TEXT, type TEXT, city TEXT); INSERT INTO accommodations (accommodation_id, name, type, city) VALUES (1, 'Eco Hotel', 'hotel', 'Sydney'), (2, 'Green Apartment', 'apartment', 'Sydney');
What is the total number of eco-friendly accommodations in Sydney?
SELECT COUNT(*) FROM accommodations WHERE city = 'Sydney' AND type = 'hotel' OR type = 'apartment' AND type LIKE '%eco%';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (union_id INT, union_name TEXT, advocacy TEXT, region TEXT, members INT); INSERT INTO unions (union_id, union_name, advocacy, region, members) VALUES (1001, 'United Steelworkers', 'workplace safety', 'Western', 4000); INSERT INTO unions (union_id, union_name, advocacy, region, members) VALUES (1002,...
What is the total number of unions advocating for workplace safety and their total number of members in the Western region?
SELECT u.advocacy, SUM(u.members), COUNT(u.union_id) FROM unions u WHERE u.advocacy = 'workplace safety' AND u.region = 'Western' GROUP BY u.advocacy;
gretelai_synthetic_text_to_sql
CREATE TABLE labour_productivity (mine_location VARCHAR(255), violation_count INT); INSERT INTO labour_productivity (mine_location, violation_count) VALUES ('North America', 15), ('South America', 22), ('Asia', 30), ('Europe', 10);
What is the total number of labor violations reported for all mines in the 'labour_productivity' table?
SELECT SUM(violation_count) FROM labour_productivity;
gretelai_synthetic_text_to_sql
CREATE TABLE program_volunteers (program_volunteer_id INT, program TEXT, volunteer_name TEXT, volunteer_date DATE); INSERT INTO program_volunteers (program_volunteer_id, program, volunteer_name, volunteer_date) VALUES (1, 'Feeding the Homeless', 'Alice', '2022-01-05'); INSERT INTO program_volunteers (program_volunteer_...
What is the total number of volunteers for each program?
SELECT program, COUNT(DISTINCT volunteer_name) as num_volunteers FROM program_volunteers GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, framework_name VARCHAR(255)); CREATE TABLE smart_contracts_frameworks (contract_id INT, framework_id INT);
What is the average number of transactions for each regulatory framework, along with the number of smart contracts associated with each framework? If there are no associated smart contracts, display '0'.
SELECT rf.framework_name, AVG(sc.total_transactions) as avg_transactions, SUM(CASE WHEN scf.contract_id IS NOT NULL THEN 1 ELSE 0 END) as num_contracts FROM regulatory_frameworks rf LEFT JOIN smart_contracts_frameworks scf ON rf.framework_id = scf.framework_id LEFT JOIN smart_contracts sc ON scf.contract_id = sc.contra...
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 7.5), (2, 'finance', 8.2), (3, 'technology', 6.8);
Update the ESG rating of company with id 2 to 8.0
UPDATE companies SET ESG_rating = 8.0 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, order_date DATE, region VARCHAR(50)); CREATE TABLE order_details (order_id INT, menu_id INT, quantity_sold INT); CREATE TABLE menu (menu_id INT, menu_name VARCHAR(255), is_sustainable BOOLEAN, price DECIMAL(5,2)); INSERT INTO orders (order_id, order_date, region) VALUES (1, '2022-01-0...
Calculate the revenue for sustainable menu items in the North region.
SELECT SUM(quantity_sold * price) as revenue FROM order_details od JOIN menu m ON od.menu_id = m.menu_id WHERE is_sustainable = TRUE AND region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE login_attempts (id INT, ip_address VARCHAR(255), attempt_time TIMESTAMP); INSERT INTO login_attempts (id, ip_address, attempt_time) VALUES (1, '192.168.1.1', '2022-01-20 12:30:00'), (2, '192.168.1.2', '2022-01-10 14:15:00'), (3, '192.168.1.3', '2022-01-05 09:20:00');
What are the distinct IP addresses that have made login attempts in the last week?
SELECT DISTINCT ip_address FROM login_attempts WHERE attempt_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), training VARCHAR(30)); CREATE TABLE circular_economy (id INT, training VARCHAR(30)); INSERT INTO workers (id, name, training) VALUES (1, 'John Smith', 'Recycling'), (2, 'Jane Doe', 'Upcycling'), (3, 'Bob Johnson', 'Waste Reduction'), (4, 'Alice Williams', 'Composting'); I...
Display the names of all workers who have completed workforce development training in the circular economy, along with the type of training they received.
SELECT w.name, c.training FROM workers w INNER JOIN circular_economy c ON w.training = c.training;
gretelai_synthetic_text_to_sql
CREATE TABLE Materials (id INT, material VARCHAR(255)); INSERT INTO Materials (id, material) VALUES (1, 'Cotton'), (2, 'Polyester'), (3, 'Nylon'), (4, 'Viscose'); CREATE TABLE Waste_Generation (id INT, material_id INT, quarter INT, year INT, waste INT); INSERT INTO Waste_Generation (id, material_id, quarter, year, wast...
What is the total waste generated by each material type in Q1 of 2021?
SELECT m.material, SUM(w.waste) FROM Waste_Generation w JOIN Materials m ON w.material_id = m.id WHERE w.quarter = 1 AND w.year = 2021 GROUP BY m.material;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name TEXT, region TEXT, title TEXT); INSERT INTO attorneys (id, name, region, title) VALUES (1, 'John Doe', 'Boston', 'Senior Partner'); CREATE TABLE cases (id INT, attorney_id INT, billing_amount INT); INSERT INTO cases (id, attorney_id, billing_amount) VALUES (1, 1, 5000);
What is the average billing amount for cases handled by attorneys in the 'Boston' region?
SELECT AVG(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.region = 'Boston';
gretelai_synthetic_text_to_sql
CREATE TABLE States (State VARCHAR(50), HospitalCount INT); INSERT INTO States (State, HospitalCount) VALUES ('California', 401), ('Texas', 417), ('New York', 212), ('Florida', 214);
How many hospitals are there in each state of the USA?
SELECT State, HospitalCount FROM States;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesigners (DesignerID INT, Name VARCHAR(30), Country VARCHAR(20), VRAdoption BOOLEAN);CREATE TABLE Games (GameID INT, GameName VARCHAR(30), Rating INT, DesignerID INT);
Insert new records for a game designer from Japan who has adopted virtual reality technology, and the games they have created with a rating of 9 or higher.
INSERT INTO GameDesigners (DesignerID, Name, Country, VRAdoption) VALUES (1, 'Hiroshi Tanaka', 'Japan', TRUE);INSERT INTO Games (GameID, GameName, Rating, DesignerID) VALUES (1, 'Samurai Sword', 9, 1), (2, 'Ninja Scroll', 10, 1);
gretelai_synthetic_text_to_sql
CREATE TABLE WorkplaceAccidents (id INT, CompanyType TEXT, Industry TEXT, Year INT, Accidents INT);
What is the average number of workplace accidents per year for union companies in the 'Manufacturing' industry?
SELECT AVG(Accidents) FROM WorkplaceAccidents WHERE CompanyType = 'Union' AND Industry = 'Manufacturing' GROUP BY Industry, Year;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_growth (country VARCHAR(255), growth INT); INSERT INTO visitor_growth (country, growth) VALUES ('Brazil', 250000), ('India', 300000), ('Indonesia', 400000), ('Mexico', 200000), ('South Korea', 350000), ('United States', 150000);
Which countries had the highest visitor growth in 2021 compared to 2020?
SELECT country, growth FROM visitor_growth ORDER BY growth DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_permits (id INT PRIMARY KEY, permit_number VARCHAR(255), company_name VARCHAR(255), mine_location VARCHAR(255), element_type VARCHAR(255));
Display mining permit numbers and companies for Yttrium in Australia.
SELECT permit_number, company_name FROM mining_permits WHERE element_type = 'Yttrium' AND mine_location = 'Australia';
gretelai_synthetic_text_to_sql