context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE ConcertTicketSales (id INT, city VARCHAR(20), revenue FLOAT); INSERT INTO ConcertTicketSales (id, city, revenue) VALUES (1, 'Los Angeles', 50000.0), (2, 'New York', 75000.0);
What was the total revenue from concert ticket sales in New York?
SELECT SUM(revenue) FROM ConcertTicketSales WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, source VARCHAR(20), destination VARCHAR(20), weight FLOAT); INSERT INTO shipments (id, source, destination, weight) VALUES (1, 'China', 'United States', 50.5), (2, 'China', 'Canada', 30.3), (3, 'Mexico', 'United States', 45.6), (4, 'Canada', 'United States', 25.8), (5, 'Canada', 'Mexico'...
What is the total number of shipments from Mexico to the United States or Canada?
SELECT COUNT(*) FROM shipments WHERE (destination = 'United States' AND source = 'Mexico') OR (destination = 'Canada' AND source = 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE public.patient_data (id SERIAL PRIMARY KEY, age INTEGER, diagnosis TEXT); INSERT INTO public.patient_data (age, diagnosis) VALUES (45, 'Diabetes'), (60, 'Hypertension'), (55, 'Diabetes');
What is the average age of patients diagnosed with diabetes in the state of Texas?
SELECT AVG(age) FROM public.patient_data WHERE diagnosis = 'Diabetes';
gretelai_synthetic_text_to_sql
CREATE TABLE public.demographics (id SERIAL PRIMARY KEY, age INT, gender TEXT, race TEXT, education TEXT); INSERT INTO public.demographics (age, gender, race, education) VALUES (34, 'Male', 'Caucasian', 'High School'), (42, 'Female', 'African American', 'College'), (28, 'Non-binary', 'Asian', 'Graduate School');
What is the distribution of age and education level for females, grouped by age?
SELECT age, education, COUNT(*) FILTER (WHERE gender = 'Female') AS female_count FROM public.demographics GROUP BY age, education;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, Email TEXT, Phone TEXT); INSERT INTO Donors (DonorID, DonorName, Country, Email, Phone) VALUES (1, 'John Doe', 'USA', 'johndoe@mail.com', '123-456-7890'); INSERT INTO Donors (DonorID, DonorName, Country, Email, Phone) VALUES (2, 'Santiago Mendoza', 'Mexico...
Update contact info for donor 'Santiago Mendoza' from 'Mexico'
UPDATE Donors SET Email = 'santiago_mendoza@mail.com', Phone = '098-765-4321' WHERE DonorName = 'Santiago Mendoza' AND Country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_projects (id INT, project VARCHAR(50), co2_emission_reduction FLOAT); INSERT INTO climate_adaptation_projects (id, project, co2_emission_reduction) VALUES (1, 'Green Roofs', 85000), (2, 'Urban Forests', 120000), (3, 'Coastal Wetlands', 150000);
What is the maximum CO2 emission reduction achieved by any climate adaptation project?
SELECT MAX(co2_emission_reduction) FROM climate_adaptation_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_date DATE, resolution_date DATE);
What is the average time to resolution for security incidents in the last 30 days, and how does it compare to the average time to resolution for security incidents in the last 60 days?
SELECT AVG(DATEDIFF(resolution_date, incident_date)) as avg_resolution_time_30_days FROM incidents WHERE incident_date >= NOW() - INTERVAL 30 DAY; SELECT AVG(DATEDIFF(resolution_date, incident_date)) as avg_resolution_time_60_days FROM incidents WHERE incident_date >= NOW() - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, branch_id INT, rank_id INT, years_of_service INT, personnel_date DATE); INSERT INTO military_personnel (id, branch_id, rank_id, years_of_service, personnel_date) VALUES (1, 1, 1, 4, '2021-03-15'); INSERT INTO military_personnel (id, branch_id, rank_id, years_of_service, personne...
What is the number of military personnel and the average years of service for each branch, partitioned by rank and ordered by the number of military personnel in descending order?
SELECT b.name as branch, r.name as rank, COUNT(mp.id) as num_military_personnel, AVG(mp.years_of_service) as avg_years_of_service, ROW_NUMBER() OVER (PARTITION BY b.name ORDER BY COUNT(mp.id) DESC) as rank FROM military_personnel mp JOIN branch b ON mp.branch_id = b.id JOIN rank r ON mp.rank_id = r.id GROUP BY b.name, ...
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_diversity (id INT, name VARCHAR(50), position VARCHAR(50), community VARCHAR(50));
How many workers in the 'workforce_diversity' table are from historically underrepresented communities?
SELECT COUNT(*) FROM workforce_diversity WHERE community IN ('indigenous', 'black', 'latino', 'asian');
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerPrograms (VolunteerID INT, VolunteerAge INT, VolunteerGender VARCHAR(10), ProgramID INT); INSERT INTO VolunteerPrograms (VolunteerID, VolunteerAge, VolunteerGender, ProgramID) VALUES (20, 25, 'Female', 5), (21, 30, 'Male', 6), (22, 22, 'Female', 7), (23, 45, 'Male', 8), (24, 35, 'Female', 9), (25,...
What is the maximum and minimum age of volunteers in each program?
SELECT ProgramID, MIN(VolunteerAge), MAX(VolunteerAge) FROM VolunteerPrograms GROUP BY ProgramID;
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Scores (id INT, building_id INT, year INT, efficiency_score INT); INSERT INTO Building_Scores VALUES (1, 1, 2020, 75), (2, 1, 2021, 80), (3, 2, 2020, 60), (4, 2, 2021, 65), (5, 3, 2020, 80), (6, 3, 2021, 85), (7, 4, 2020, 85), (8, 4, 2021, 90), (9, 5, 2020, 65), (10, 5, 2021, 70);
What is the change in energy efficiency scores for each building, between the most recent and the previous year, using a window function to calculate the difference?
SELECT building_id, year, efficiency_score, LAG(efficiency_score) OVER (PARTITION BY building_id ORDER BY year) as previous_efficiency_score, efficiency_score - LAG(efficiency_score) OVER (PARTITION BY building_id ORDER BY year) as difference FROM Building_Scores;
gretelai_synthetic_text_to_sql
CREATE TABLE vaccine_administered (patient_id INT, vaccine_name VARCHAR(255), state VARCHAR(255)); CREATE TABLE patients (patient_id INT, age INT); INSERT INTO vaccine_administered (patient_id, vaccine_name, state) VALUES (1, 'Johnson & Johnson', 'Florida'); INSERT INTO patients (patient_id, age) VALUES (1, 45);
What is the minimum age of patients who received the Johnson & Johnson vaccine in Florida?
SELECT MIN(y.age) FROM patients y INNER JOIN vaccine_administered a ON y.patient_id = a.patient_id WHERE a.vaccine_name = 'Johnson & Johnson' AND a.state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_initiatives (brand VARCHAR(50), initiative VARCHAR(50), budget FLOAT); INSERT INTO recycling_initiatives (brand, initiative, budget) VALUES ('Brand N', 'Recycled Fabrics', 500000.00), ('Brand N', 'Clothing Recycling Program', 750000.00), ('Brand O', 'Recycled Buttons', 150000.00), ('Brand O', 'Cl...
What are the recycling initiatives and their respective budgets for the top 2 clothing brands committed to sustainability?
SELECT initiative, budget FROM recycling_initiatives WHERE brand IN ('Brand N', 'Brand O') ORDER BY budget DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE SupplierMaterials (SupplierID int, Material varchar(50));
How many unique suppliers are there for each material type?
SELECT Material, COUNT(DISTINCT SupplierID) AS SupplierCount FROM SupplierMaterials GROUP BY Material;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50), Salary FLOAT, Remote BOOLEAN); INSERT INTO Employees (EmployeeID, Name, Department, Position, Salary, Remote) VALUES (1, 'Alex Brown', 'Engineering', 'Software Engineer', 95000.00, true), (2, 'Sophia Lee', 'IT', 'Dat...
What is the average salary of remote employees, by job role?
SELECT Position, AVG(Salary) FROM Employees WHERE Remote = true GROUP BY Position;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTech (id INT, name VARCHAR(50), type VARCHAR(50), country VARCHAR(50), cost FLOAT); INSERT INTO MilitaryTech (id, name, type, country, cost) VALUES (1, 'F-35 Lightning II', 'Fighter', 'USA', 1010000000);
What is the total cost of military technologies per country?
SELECT country, SUM(cost) FROM MilitaryTech GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE startup_funding (id INT PRIMARY KEY, startup_name VARCHAR(255), industry VARCHAR(255), funding_amount FLOAT, funding_date DATE); INSERT INTO startup_funding (id, startup_name, industry, funding_amount, funding_date) VALUES (1, 'BioInnovate', 'Biotechnology', 5000000, '2021-03-15'), (2, 'GenetiX', 'Biotechn...
Identify the funding amount and date for biotech startups that raised over $5M in 2021.
SELECT startup_name, funding_amount, funding_date FROM startup_funding WHERE industry = 'Biotechnology' AND funding_amount > 5000000 AND funding_date >= '2021-01-01' AND funding_date <= '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE tiktok_videos (video_id INT, user_id INT, video_date DATE, num_likes INT);
What is the maximum number of likes on a single TikTok video by a user in a single day?
SELECT user_id, MAX(num_likes) as max_num_likes FROM (SELECT user_id, DATE(video_date) as video_date, SUM(num_likes) as num_likes FROM tiktok_videos GROUP BY user_id, video_date) subquery GROUP BY user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, name VARCHAR(50), is_recycled BOOLEAN); INSERT INTO materials (material_id, name, is_recycled) VALUES (1, 'Recycled Plastic', true), (2, 'Virgin Plastic', false), (3, 'Recycled Paper', true); CREATE TABLE products_materials (product_id INT, material_id INT); INSERT INTO products...
What is the total number of products made from recycled materials?
SELECT COUNT(DISTINCT products_materials.product_id) FROM products_materials JOIN materials ON products_materials.material_id = materials.material_id WHERE materials.is_recycled = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT, name VARCHAR(50), description TEXT, allergens TEXT); INSERT INTO Menu (id, name, description, allergens) VALUES (1, 'Chicken Alfredo', 'Creamy fettuccine with chicken', 'Milk, Eggs'), (2, 'Beef Tacos', 'Soft corn tortillas filled with seasoned beef', 'Wheat'), (3, 'Veggie Burger', 'Grilled ve...
List all menu items with their descriptions and allergens.
SELECT name, description, allergens FROM Menu;
gretelai_synthetic_text_to_sql
CREATE TABLE regional_chemicals_production (id INT, chemical_name VARCHAR(255), region VARCHAR(255), production_rate FLOAT); INSERT INTO regional_chemicals_production (id, chemical_name, region, production_rate) VALUES (1, 'Hydrogen Peroxide', 'Antarctic', 400.0);
What is the minimum production rate of a single chemical in the Antarctic region?
SELECT MIN(production_rate) FROM regional_chemicals_production WHERE region = 'Antarctic';
gretelai_synthetic_text_to_sql
CREATE TABLE WellExplorationCosts (well_id INT, drill_year INT, region TEXT, exploration_cost REAL); INSERT INTO WellExplorationCosts (well_id, drill_year, region, exploration_cost) VALUES (1, 2010, 'GulfOfMexico', 2500000), (2, 2012, 'GulfOfMexico', 2800000), (3, 2015, 'GulfOfMexico', 2200000);
Identify the well with the lowest exploration cost in the 'GulfOfMexico' for wells drilled between 2010 and 2015.
SELECT well_id, exploration_cost FROM WellExplorationCosts WHERE region = 'GulfOfMexico' AND drill_year BETWEEN 2010 AND 2015 ORDER BY exploration_cost ASC LIMIT 1
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets (discovery_date DATE, discovery_details VARCHAR(100), planet_name VARCHAR(50), host_star VARCHAR(50), distance_from_sun FLOAT); INSERT INTO exoplanets VALUES ('2010-01-01', 'Discovered by Kepler', 'Planet A', 'Star 1', 0.5), ('2010-01-01', 'Discovered by Kepler', 'Planet B', 'Star 1', 0.75), ('2...
What is the average distance from the sun for exoplanets, grouped by discovery date in the exoplanets table?
SELECT discovery_date, AVG(distance_from_sun) OVER (PARTITION BY discovery_date) FROM exoplanets;
gretelai_synthetic_text_to_sql
CREATE TABLE harvests (id INT, farm TEXT, strain TEXT, weight DECIMAL, harvest_date DATE); INSERT INTO harvests (id, farm, strain, weight, harvest_date) VALUES (1, 'Happy Trails', 'OG Kush', 100.0, '2020-01-01'), (2, 'Happy Trails', 'Purple Punch', 150.0, '2020-05-01');
What is the total weight of indica flower harvested by Happy Trails farm in 2020?
SELECT SUM(weight) FROM harvests WHERE farm = 'Happy Trails' AND strain = 'indica' AND harvest_date >= '2020-01-01' AND harvest_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableFoods (order_id INT, dish_name VARCHAR(50)); INSERT INTO SustainableFoods (order_id, dish_name) VALUES (1, 'Gluten-Free Pasta'), (2, 'Veggie Burger'), (3, 'Gluten-Free Pasta'), (4, 'Salad');
How many times has 'Gluten-Free Pasta' been ordered from 'SustainableFoods'?
SELECT COUNT(*) FROM SustainableFoods WHERE dish_name = 'Gluten-Free Pasta';
gretelai_synthetic_text_to_sql
CREATE TABLE demographics (id INT, city VARCHAR, age_group INT, gender VARCHAR, obesity_rate DECIMAL);
Identify cities with the highest obesity rates, by age group and gender.
SELECT d.city, d.age_group, d.gender, AVG(d.obesity_rate) AS avg_obesity_rate FROM demographics d GROUP BY d.city, d.age_group, d.gender ORDER BY avg_obesity_rate DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyRecords (VesselId INT, IsCompliant VARCHAR(10)); CREATE TABLE Vessel (Id INT PRIMARY KEY, Name VARCHAR(50), Type VARCHAR(50), MaxCapacity INT);
Update the SafetyRecords table, setting the 'IsCompliant' column to 'Yes' for vessels with a maximum capacity of under 5000 tons
UPDATE SafetyRecords SET IsCompliant = 'Yes' WHERE VesselId IN (SELECT Id FROM Vessel WHERE MaxCapacity < 5000);
gretelai_synthetic_text_to_sql
CREATE TABLE Articles (ArticleID int, Title varchar(100), PubDate date, Likes int); INSERT INTO Articles (ArticleID, Title, PubDate, Likes) VALUES (1, 'Article 1', '2021-01-01', 10); INSERT INTO Articles (ArticleID, Title, PubDate, Likes) VALUES (2, 'Article 2', '2021-02-01', 15); INSERT INTO Articles (ArticleID, Title...
What is the average number of likes per article for articles published in 2021?
SELECT AVG(Likes) as AvgLikes FROM Articles WHERE YEAR(PubDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE student_exam_results (student_id INT, country VARCHAR(255), exam_id INT, pass INT); INSERT INTO student_exam_results VALUES (1, 'USA', 1, 1), (2, 'Canada', 1, 1), (3, 'USA', 2, 0);
What is the percentage of students who passed the lifelong learning exam in each country in the last year, by exam?
SELECT country, exam_id, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER(PARTITION BY country) as pass_percentage FROM student_exam_results WHERE pass = 1 AND date >= DATEADD(year, -1, GETDATE()) GROUP BY country, exam_id;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance) VALUES (1, 'Savings', 'New York', 5000.00), (2, 'Checking', 'New York', 7000.00), (3, 'Checking', 'Atlanta', 2000.00), (4, 'Savings', 'Atlanta',...
What is the minimum checking account balance in the Atlanta branch?
SELECT MIN(balance) FROM accounts WHERE account_type = 'Checking' AND branch = 'Atlanta';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareProviders (Id INT, Name TEXT, Location TEXT, Specialty TEXT); INSERT INTO HealthcareProviders (Id, Name, Location, Specialty) VALUES (1, 'Dr. Smith', 'City X', 'Family Medicine'); INSERT INTO HealthcareProviders (Id, Name, Location, Specialty) VALUES (2, 'Dr. Johnson', 'City X', 'Cardiology'); IN...
How many healthcare providers are there in each specialty?
SELECT Specialty, COUNT(*) FROM HealthcareProviders GROUP BY Specialty;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (VolunteerID INT, VolunteerName VARCHAR(50), Hours INT); INSERT INTO VolunteerHours (VolunteerID, VolunteerName, Hours) VALUES (1, 'Sophia Garcia', 20), (2, 'Ali Hassan', 15), (3, 'Lea Kim', 25);
What is the average number of hours volunteered per volunteer in the 'VolunteerHours' table?
SELECT AVG(Hours) as AverageHours FROM VolunteerHours;
gretelai_synthetic_text_to_sql
CREATE TABLE baltic_sea_fields (field_id INT, field_name VARCHAR(50), oil_production FLOAT, datetime DATETIME); INSERT INTO baltic_sea_fields (field_id, field_name, oil_production, datetime) VALUES (1, 'Baltic Sea Field A', 1500000, '2019-01-01 00:00:00'), (2, 'Baltic Sea Field B', 1800000, '2019-02-01 00:00:00');
List the names of the fields with the highest oil production in the Baltic Sea in Q1 2019.
SELECT field_name FROM baltic_sea_fields WHERE oil_production = (SELECT MAX(oil_production) FROM baltic_sea_fields WHERE QUARTER(datetime) = 1 AND YEAR(datetime) = 2019) AND QUARTER(datetime) = 1 AND YEAR(datetime) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Agencies (Agency_ID INT, Agency VARCHAR(50)); INSERT INTO Space_Agencies (Agency_ID, Agency) VALUES (1, 'NASA'), (2, 'ESA'), (3, 'CNES'); CREATE TABLE Agency_Satellites (Agency VARCHAR(50), Satellite_Name VARCHAR(50), Launch_Date DATETIME); INSERT INTO Agency_Satellites (Agency, Satellite_Name, Launc...
List all space agencies that have launched satellites before 2000 and their associated astronauts.
SELECT sa.Agency, a.Name, s.Satellite_Name FROM Space_Agencies sa INNER JOIN Agency_Satellites s ON sa.Agency = s.Agency INNER JOIN Astronauts a ON sa.Agency = a.Agency WHERE s.Launch_Date < '2000-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Humanitarian_Assistance (Country VARCHAR(255), Donor VARCHAR(255), Equipment VARCHAR(255), Year INT);
What is the total number of military equipment provided by the US and China to African countries through humanitarian assistance in the last 5 years?
SELECT SUM(Equipment) FROM (SELECT Equipment FROM Humanitarian_Assistance WHERE Donor IN ('US', 'China') AND Year BETWEEN (YEAR(CURRENT_DATE)-5) AND YEAR(CURRENT_DATE) AND Country IN (SELECT DISTINCT Country FROM Africa_Countries) GROUP BY Equipment, Year) AS Total_Equipment;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (id INT, source_name VARCHAR(50), source_type VARCHAR(50), amount DECIMAL(10,2));
Insert a new record in the 'funding_sources' table with id 5, source_name 'Sustainable Future Fund', source_type 'Private', amount 2000000.00
INSERT INTO funding_sources (id, source_name, source_type, amount) VALUES (5, 'Sustainable Future Fund', 'Private', 2000000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance_incomes (id INT, country VARCHAR(255), income DECIMAL(10,2)); INSERT INTO shariah_compliant_finance_incomes (id, country, income) VALUES (1, 'Saudi Arabia', 50000.00), (2, 'UAE', 70000.00), (3, 'Qatar', 60000.00);
What is the total Shariah-compliant finance income in the Middle East?
SELECT SUM(income) FROM shariah_compliant_finance_incomes WHERE country IN ('Saudi Arabia', 'UAE', 'Qatar');
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, approval_year INT); INSERT INTO drugs VALUES (1, 2010), (2, 2012); CREATE TABLE clinical_trials (trial_id INT, trial_year INT); INSERT INTO clinical_trials VALUES (123, 2011);
Identify drugs that were approved in the same year as Clinical Trial 123, which is stored in the "clinical_trials" table.
SELECT d.drug_id, d.approval_year FROM drugs d WHERE d.approval_year = (SELECT ct.trial_year FROM clinical_trials ct WHERE ct.trial_id = 123);
gretelai_synthetic_text_to_sql
CREATE TABLE Events (ID INT PRIMARY KEY, Category TEXT, Date DATE, Location TEXT, Attendees INT);
Show the number of attendees for events in the 'Music' category
SELECT Category, SUM(Attendees) FROM Events WHERE Category = 'Music' GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (Department VARCHAR(50), Year INT, Allocation DECIMAL(10,2)); INSERT INTO Budget (Department, Year, Allocation) VALUES ('Education', 2022, 50000.00), ('Environment', 2022, 75000.00);
What is the total budget allocated for programs in the Education and Environment departments in 2022?
SELECT Department, SUM(Allocation) as TotalAllocation FROM Budget WHERE Year = 2022 AND Department IN ('Education', 'Environment') GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, name TEXT, rating_prev FLOAT, rating FLOAT); INSERT INTO projects (project_id, name, rating_prev, rating) VALUES (1, 'Solar Farm', 1.7, 1.8), (2, 'Wind Turbine', 2.1, 2.2), (3, 'Geothermal Plant', 1.9, 2.0);
What is the change in energy efficiency rating for each renewable energy project?
SELECT project_id, name, rating - rating_prev AS change FROM projects;
gretelai_synthetic_text_to_sql
CREATE TABLE visits (visit_id INT, patient_id INT, hospital_id INT, visit_date DATE, location VARCHAR(20));
What is the total number of hospital visits in rural areas of each state?
SELECT hospital_id, COUNT(*) FROM visits WHERE location = 'Rural' GROUP BY hospital_id;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_quantity INT, year INT, element TEXT); INSERT INTO mines (id, name, location, production_quantity, year, element) VALUES (1, 'Lynas Corporation', 'Australia', 1200, 2019, 'praseodymium'), (2, 'Alkane Resources', 'Australia', 800, 2019, 'praseodymium');
What is the maximum production quantity of praseodymium in 2019 for mines located in Australia?
SELECT MAX(production_quantity) FROM mines WHERE location = 'Australia' AND year = 2019 AND element = 'praseodymium';
gretelai_synthetic_text_to_sql
CREATE TABLE areas (id INT, name VARCHAR(20)); INSERT INTO areas (id, name) VALUES (1, 'Urban'), (2, 'Rural'); CREATE TABLE feedback (id INT, service VARCHAR(20), area_id INT, date DATE); INSERT INTO feedback (id, service, area_id, date) VALUES (1, 'Public Transportation', 1, '2022-01-01'), (2, 'Public Transportation',...
How many citizen feedback records were received in the last month for public transportation services in urban areas?
SELECT COUNT(*) FROM feedback WHERE service = 'Public Transportation' AND area_id = (SELECT id FROM areas WHERE name = 'Urban') AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE gas_fields (field_id INT, field_name VARCHAR(100), location VARCHAR(100), gas_capacity FLOAT); INSERT INTO gas_fields (field_id, field_name, location, gas_capacity) VALUES (1, 'Yamal', 'Russia', 4500), (2, 'South Pars', 'Iran', 14000);
Show all gas fields with capacity > 5000
SELECT * FROM gas_fields WHERE gas_capacity > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE news (id INT, title VARCHAR(100), views INT, date DATE);
How many news stories were published in total for each month in the year 2020?
SELECT MONTH(date) AS month, COUNT(*) AS total_stories FROM news WHERE YEAR(date) = 2020 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE product (product_id VARCHAR(10), name VARCHAR(50), price DECIMAL(5,2), supplier_id VARCHAR(10), primary key (product_id));
Update the price of product 'A' to $50 in 'product' table
UPDATE product SET price = 50 WHERE product_id = 'A';
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, Gender TEXT, Diagnosis TEXT, State TEXT); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, State) VALUES (1, 34, 'Female', 'Influenza', 'California');
What is the average age of patients diagnosed with influenza in the state of California?
SELECT AVG(Age) FROM Patients WHERE Diagnosis = 'Influenza' AND State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE workout_schedule (id INT, member_id INT, workout_date DATE, workout_duration INT); CREATE TABLE members (id INT, name VARCHAR(50), email VARCHAR(50));
Delete records of members who have not logged in for over a month from the members table and workout_schedule table
DELETE FROM members WHERE id IN (SELECT member_id FROM workout_schedule WHERE workout_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH)); DELETE FROM workout_schedule WHERE workout_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT PRIMARY KEY, name TEXT, location TEXT); INSERT INTO wells (id, name, location) VALUES (1, 'Well A', 'Gulf of Mexico'), (2, 'Well B', 'Gulf of Mexico'), (3, 'Well C', 'North Sea'), (4, 'Well D', 'Gulf of Mexico'); CREATE TABLE oil_production (well_id INT, year INT, production REAL); INSERT INT...
Identify the top 5 oil-producing wells in the Gulf of Mexico
SELECT w.name, SUM(op.production) as total_production FROM wells w JOIN oil_production op ON w.id = op.well_id WHERE w.location = 'Gulf of Mexico' GROUP BY w.name ORDER BY total_production DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_database (id INT, department TEXT, gender TEXT, training_completed TEXT); INSERT INTO employee_database (id, department, gender, training_completed) VALUES (1, 'HR', 'Female', 'Inclusion'), (2, 'HR', 'Male', 'Diversity'), (3, 'HR', 'Female', 'Inclusion');
What is the percentage of female employees in the HR department who have completed inclusion training?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employee_database WHERE department = 'HR' AND gender = 'Female')) as percentage FROM employee_database WHERE department = 'HR' AND gender = 'Female' AND training_completed = 'Inclusion';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, artist_id INT, city VARCHAR(50), revenue DECIMAL(10,2));
What is the average revenue per concert by city?
SELECT city, AVG(revenue) AS avg_revenue FROM Concerts GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (route_name VARCHAR(20), fare_date DATE, fare FLOAT); INSERT INTO fares (route_name, fare_date, fare) VALUES ('Green Line', '2021-02-01', 1.75), ('Red Line', '2021-03-02', 2.50), ('Red Line', '2021-03-03', 2.55), ('Blue Line', '2021-03-05', 3.25), ('Red Line', '2021-03-06', 2.45);
What was the average fare for the 'Red Line' in March 2021?
SELECT AVG(fare) FROM fares WHERE route_name = 'Red Line' AND fare_date BETWEEN '2021-03-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_date DATE, donation_amount DECIMAL); INSERT INTO donations (id, donor_id, donation_date, donation_amount) VALUES (1, 1, '2019-01-01', 50.00), (2, 2, '2018-01-01', 100.00), (3, 3, '2019-12-31', 250.00);
What is the maximum donation amount made by a single donor?
SELECT MAX(donation_amount) FROM donations;
gretelai_synthetic_text_to_sql
CREATE TABLE Rocket (id INT, name VARCHAR, height_meters FLOAT, diameter_meters FLOAT, launch_site VARCHAR); INSERT INTO Rocket (id, name, height_meters, diameter_meters, launch_site) VALUES (1, 'Saturn V', 110.6, 10.06, 'Kennedy Space Center');
What is the average height of rockets launched from the Kennedy Space Center?
SELECT AVG(height_meters) FROM Rocket WHERE launch_site = 'Kennedy Space Center';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, Division VARCHAR(20)); INSERT INTO Customers (CustomerID, Division) VALUES (1, 'Retail Banking'), (2, 'Retail Banking'), (3, 'Corporate Banking'); CREATE TABLE Transactions (TransactionID INT, CustomerID INT, Amount DECIMAL(10,2)); INSERT INTO Transactions (TransactionID, Custome...
What is the average transaction amount per customer in the 'Retail Banking' division?
SELECT AVG(Amount) FROM Transactions INNER JOIN Customers ON Transactions.CustomerID = Customers.CustomerID WHERE Customers.Division = 'Retail Banking';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, city VARCHAR(20), capacity INT);
Add a new warehouse in Seattle with a capacity of 2000
INSERT INTO warehouse (id, city, capacity) VALUES (4, 'Seattle', 2000);
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT PRIMARY KEY, title TEXT, year INT, genre TEXT, creator TEXT); INSERT INTO tv_shows (id, title, year, genre, creator) VALUES (1, 'TVShow1', 2020, 'Comedy', 'Sofia Garcia'), (2, 'TVShow2', 2019, 'Drama', 'Kevin Jones');
Insert a new TV show with diverse creators and genres.
INSERT INTO tv_shows (id, title, year, genre, creator) VALUES (3, 'TVShow3', 2021, 'Action', 'Fatima Ahmed'), (4, 'TVShow4', 2020, 'Sci-Fi', 'Hassan Patel');
gretelai_synthetic_text_to_sql
CREATE TABLE power_projects (id INT, city VARCHAR(20), country VARCHAR(20), year INT, project_type VARCHAR(20)); INSERT INTO power_projects (id, city, country, year, project_type) VALUES (1, 'New Delhi', 'India', 2010, 'Solar'), (2, 'New Delhi', 'India', 2011, 'Wind'), (3, 'New Delhi', 'India', 2012, 'Solar'), (4, 'New...
What is the total number of solar power projects in New Delhi, India, since 2010?
SELECT COUNT(*) FROM power_projects WHERE city = 'New Delhi' AND country = 'India' AND project_type = 'Solar' AND year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_soil_moisture (farm_id INTEGER, date DATE, moisture INTEGER);
What is the average soil moisture level for each farm in the past week?
SELECT farm_id, AVG(moisture) as avg_moisture FROM farm_soil_moisture WHERE date >= DATEADD(day, -7, GETDATE()) GROUP BY farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE EcoTourismAwards (award_id INT, location VARCHAR(50), award_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO EcoTourismAwards (award_id, location, award_name, start_date, end_date) VALUES (1, 'Sydney', 'Green Travel Award', '2022-01-01', '2022-12-31'); CREATE TABLE SustainableTourismActivitie...
What hotels are located in cities with at least one eco-tourism award and one sustainable tourism activity?
SELECT DISTINCT hl.location FROM HotelLocations hl JOIN EcoTourismAwards ea ON hl.location = ea.location INTERSECT SELECT DISTINCT sta.location FROM SustainableTourismActivities sta;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, art_category VARCHAR(255), artist_name VARCHAR(255), year INT, art_medium VARCHAR(255), price DECIMAL(10,2));
What is the total number of artworks in the 'Artworks' table, where the art_medium is 'Painting' or 'Sculpture'?
SELECT COUNT(*) as total FROM Artworks WHERE art_medium IN ('Painting', 'Sculpture');
gretelai_synthetic_text_to_sql
CREATE TABLE WildlifeTypes (id INT, name VARCHAR(255)); INSERT INTO WildlifeTypes (id, name) VALUES (1, 'Penguin'), (2, 'Kangaroo'), (3, 'Emu'), (4, 'Wallaby'); CREATE TABLE WildlifeHabitats (wildlife_type_id INT, region_id INT, count INT); INSERT INTO WildlifeHabitats (wildlife_type_id, region_id, count) VALUES (1, 1,...
What is the total number of wildlife habitats in each region for 'Penguin' and 'Kangaroo'?
SELECT Wh.region_id, SUM(Wh.count) as total_habitats FROM WildlifeHabitats Wh WHERE Wh.wildlife_type_id IN (1, 2) GROUP BY Wh.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, Title TEXT, Year INT, City TEXT);
Delete all exhibitions that took place before 1850 and display the remaining exhibitions.
DELETE FROM Exhibitions WHERE Year < 1850; SELECT * FROM Exhibitions;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist_id INT, city VARCHAR(50), country VARCHAR(50), revenue FLOAT); INSERT INTO concerts (id, artist_id, city, country, revenue) VALUES (1, 1, 'Los Angeles', 'USA', 500000), (2, 1, 'New York', 'USA', 700000), (3, 2, 'Seoul', 'South Korea', 800000), (4, 2, 'Tokyo', 'Japan', 900000), (5, ...
What is the average revenue per concert by country in 'Europe'?
SELECT country, AVG(revenue) as avg_revenue FROM concerts WHERE country IN ('France', 'Germany', 'Spain', 'UK') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE enrollments (student_id INT, course_name TEXT); INSERT INTO enrollments (student_id, course_name) VALUES (123, 'English Composition');
How many students are enrolled in 'English Composition'?
SELECT COUNT(*) FROM enrollments WHERE course_name = 'English Composition';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), TotalDonation DECIMAL(10,2));
Delete records with a TotalDonation less than $100.
DELETE FROM Donors WHERE TotalDonation < 100;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (farm_id INT, farm_name VARCHAR(255), farm_type VARCHAR(255), region VARCHAR(255)); INSERT INTO farms (farm_id, farm_name, farm_type, region) VALUES (1, 'Farm 1', 'organic', 'Region A'), (2, 'Farm 2', 'conventional', 'Region A'), (3, 'Farm 3', 'organic', 'Region B'), (4, 'Farm 4', 'conventional', 'Re...
How many 'organic' and 'conventional' farms are in each region?
SELECT region, COUNT(*) as num_farms FROM farms WHERE farm_type IN ('organic', 'conventional') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Adoption (id INT, state VARCHAR(50), adoption_rate FLOAT);
What is the adoption rate of electric vehicles in each state in the US?
SELECT state, adoption_rate FROM EV_Adoption WHERE state IN (SELECT DISTINCT state FROM Vehicles) ORDER BY adoption_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), treatment VARCHAR(50)); CREATE TABLE treatments (treatment VARCHAR(50), cost INT);
How many patients received a certain treatment type?
SELECT COUNT(DISTINCT p.name) FROM patients p WHERE p.treatment = 'certain_treatment';
gretelai_synthetic_text_to_sql
CREATE TABLE state_requests (request_id INT, state_name VARCHAR(50), request_date DATE); INSERT INTO state_requests VALUES (1, 'StateD', '2022-02-01'), (2, 'StateE', '2022-02-03'), (3, 'StateD', '2022-02-05'), (4, 'StateF', '2022-02-07'), (5, 'StateE', '2022-02-09');
How many public service requests were made in each state in the last month?
SELECT state_name, COUNT(*) as num_requests FROM state_requests WHERE request_date >= DATEADD(month, -1, GETDATE()) GROUP BY state_name;
gretelai_synthetic_text_to_sql
CREATE TABLE highways (highway_id INT, highway_name VARCHAR(50), state VARCHAR(50), speed_limit INT);
What is the average speed limit of a highway in the 'highways' table?
SELECT AVG(speed_limit) FROM highways;
gretelai_synthetic_text_to_sql
CREATE TABLE Sites (id INT, site_name VARCHAR(50), location VARCHAR(50), period VARCHAR(50), type VARCHAR(50)); INSERT INTO Sites (id, site_name, location, period, type) VALUES (1, 'Site1', 'Location1', 'Period1', 'Settlement'), (2, 'Site2', 'Location2', 'Period2', 'Village'); CREATE TABLE Reports (id INT, site_name VA...
What is the maximum number of views for a report on a site from Period2, and the type of report with that view count?
SELECT r.type, r.views FROM Reports r JOIN Sites s ON r.site_name = s.site_name WHERE s.period = 'Period2' AND r.views = (SELECT MAX(views) FROM Reports WHERE site_name IN (SELECT site_name FROM Sites WHERE period = 'Period2'));
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), country VARCHAR(50));
Identify the top 5 countries with the most donors
SELECT d.country, COUNT(d.id) as num_donors FROM donors d GROUP BY d.country ORDER BY num_donors DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Coral (id INT, species VARCHAR(255), location VARCHAR(255), depth FLOAT, temperature FLOAT); INSERT INTO Coral (id, species, location, depth, temperature) VALUES (1, 'Stony Coral', 'Caribbean Sea', 15, 26);
What is the average depth of Stony Coral?
SELECT AVG(depth) as avg_depth FROM Coral WHERE species = 'Stony Coral';
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, ReleaseYear INT, Revenue INT); INSERT INTO Games (GameID, ReleaseYear, Revenue) VALUES (1, 2017, 5000); INSERT INTO Games (GameID, ReleaseYear, Revenue) VALUES (2, 2018, 6000); INSERT INTO Games (GameID, ReleaseYear, Revenue) VALUES (3, 2019, 7000); INSERT INTO Games (GameID, ReleaseYear...
What is the total revenue of games released in the last 5 years?
SELECT SUM(Games.Revenue) FROM Games WHERE Games.ReleaseYear BETWEEN YEAR(CURRENT_DATE)-5 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE digital_asset (id INT, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE market_capitalization (id INT, asset_id INT, value INT); INSERT INTO digital_asset (id, name, category) VALUES (1, 'Asset1', 'Crypto'), (2, 'Asset2', 'Crypto'), (3, 'Asset3', 'Security'), (4, 'Asset4', 'Security'), (5, 'Asset5',...
List the top 3 digital assets with the highest market capitalization, ordered by market capitalization in descending order.
SELECT a.name, m.value FROM digital_asset a JOIN market_capitalization m ON a.id = m.asset_id WHERE a.id IN (SELECT asset_id FROM market_capitalization ORDER BY value DESC LIMIT 3) ORDER BY m.value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT PRIMARY KEY, title TEXT, topic TEXT, author TEXT, publication_date DATE);
Insert a new article with the title "AI in Journalism" and topic "Ethics" into the news_articles table.
INSERT INTO news_articles (title, topic, author, publication_date) VALUES ('AI in Journalism', 'Ethics', 'John Doe', '2022-08-15');
gretelai_synthetic_text_to_sql
CREATE TABLE inventory(id INT PRIMARY KEY, product VARCHAR(50), quantity INT); INSERT INTO inventory(id, product, quantity) VALUES (1, 'apple', 100), (2, 'banana', 200), (3, 'orange', 150); CREATE TABLE products(id INT PRIMARY KEY, name VARCHAR(50), market_price DECIMAL(5,2)); INSERT INTO products(id, name, market_pric...
List all the products that are not present in the inventory, along with their average market price.
SELECT p.name, p.market_price FROM products p LEFT JOIN inventory i ON p.name = i.product WHERE i.product IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_data_usage (id INT, customer_id INT, usage_date DATE, data_usage FLOAT);
What is the average data usage per day for each mobile customer in the last month?
SELECT customer_id, AVG(data_usage / DATEDIFF(usage_date, DATE_SUB(usage_date, INTERVAL 1 MONTH))) FROM mobile_data_usage WHERE usage_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE factory_data (factory_id INT, region VARCHAR(20), sustainability_score FLOAT, year INT); INSERT INTO factory_data (factory_id, region, sustainability_score, year) VALUES (1, 'Asia', 85, 2019), (2, 'Asia', 90, 2019), (3, 'Europe', 92, 2019);
What was the maximum sustainability score for factories in region "Europe" in 2019?
SELECT MAX(sustainability_score) FROM factory_data WHERE region = 'Europe' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (country TEXT, initiative TEXT, success BOOLEAN); INSERT INTO conservation_initiatives (country, initiative, success) VALUES ('Canada', 'Rainwater harvesting', true), ('Canada', 'Low-flow appliances', true), ('Mexico', 'Smart irrigation', false), ('Brazil', 'Leak detection', true);
What is the success rate of water conservation initiatives in each country?
SELECT country, AVG(success) as success_rate FROM conservation_initiatives GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE olympic_medals (country VARCHAR(50), year INT, medal VARCHAR(10));
Find the total number of medals won by each country in the 'olympic_medals' table.
SELECT country, SUM(medal IN ('Gold', 'Silver', 'Bronze')) AS total_medals FROM olympic_medals GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (DishID INT, Name VARCHAR(50), WastePercentage DECIMAL(3,2)); CREATE TABLE Ingredients (IngredientID INT, DishID INT, WastePercentage DECIMAL(3,2)); INSERT INTO Dishes (DishID, Name, WastePercentage) VALUES (1, 'Beef Tacos', 35), (2, 'Chicken Stir Fry', 25); INSERT INTO Ingredients (IngredientID, Di...
Which menu items contribute most to food waste and their associated waste percentages?
SELECT d.Name, SUM(i.WastePercentage) + d.WastePercentage AS TotalWaste FROM Dishes d JOIN Ingredients i ON d.DishID = i.DishID GROUP BY d.Name ORDER BY TotalWaste DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE public.trips (trip_id SERIAL PRIMARY KEY, passenger_type VARCHAR(20), fare DECIMAL(5,2), route_type_id INTEGER, FOREIGN KEY (route_type_id) REFERENCES public.route_type(route_type_id)); INSERT INTO public.trips (passenger_type, fare, route_type_id) VALUES ('adult', 3.00, 1), ('child', 1.50, 1), ('adult', 3...
How many 'child' passengers traveled on 'bus' routes in March 2022?
SELECT COUNT(*) FROM public.trips WHERE passenger_type = 'child' AND route_type_id = (SELECT route_type_id FROM public.route_type WHERE route_type = 'bus') AND fare_date >= '2022-03-01' AND fare_date <= '2022-03-31'
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovations (innovation_id INT, innovation_name VARCHAR(50), region VARCHAR(50)); CREATE TABLE farmers_adopting_innovations (farmer_id INT, innovation_id INT, region VARCHAR(50)); INSERT INTO agricultural_innovations (innovation_id, innovation_name, region) VALUES (1, 'Drip Irrigation', 'Midwe...
List all agricultural innovation metrics in the 'rural_development' database, along with the number of farmers who have adopted each innovation.
SELECT agricultural_innovations.innovation_name, COUNT(farmers_adopting_innovations.farmer_id) FROM agricultural_innovations LEFT JOIN farmers_adopting_innovations ON agricultural_innovations.innovation_id = farmers_adopting_innovations.innovation_id GROUP BY agricultural_innovations.innovation_name;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, country VARCHAR(255));CREATE TABLE treatments (id INT, patient_id INT, treatment VARCHAR(255)); INSERT INTO patients (id, country) VALUES (1, 'Asia'), (2, 'USA'), (3, 'Canada'); INSERT INTO treatments (id, patient_id, treatment) VALUES (1, 1, 'Medication'), (2, 2, 'CBT'), (3, 3, 'DBT'), (...
What percentage of patients in Asia have been treated with medication or therapy?
SELECT 100.0 * COUNT(DISTINCT CASE WHEN treatments.treatment IN ('Medication', 'Therapy') THEN patients.id END) / COUNT(DISTINCT patients.id) AS percentage FROM patients LEFT JOIN treatments ON patients.id = treatments.patient_id WHERE patients.country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data_3 (sale_id INT, product_id INT, sale_date DATE, price DECIMAL(5,2), quantity INT); INSERT INTO sales_data_3 (sale_id, product_id, sale_date, price, quantity) VALUES (11, 1, '2021-07-01', 12.50, 10), (12, 2, '2021-08-02', 13.00, 15), (13, 3, '2021-09-03', 12.75, 12), (14, 4, '2021-10-04', 45.00, ...
Find the top 3 product categories with the highest total sales revenue
SELECT category, SUM(price * quantity) AS total_sales_revenue FROM sales_data_3 JOIN products ON sales_data_3.product_id = products.product_id GROUP BY category ORDER BY total_sales_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ContractNegotiations (id INT PRIMARY KEY, negotiation_date DATE, contract_status VARCHAR(50));
How many defense contracts were negotiated in Q1 2022?
SELECT COUNT(*) FROM ContractNegotiations WHERE negotiation_date >= '2022-01-01' AND negotiation_date < '2022-04-01' AND contract_status = 'negotiated';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT, name TEXT, location TEXT);CREATE TABLE products(id INT, supplier_id INT, company_id INT, product_name TEXT);INSERT INTO suppliers(id, name, location) VALUES (1, 'Supplier A', 'City A'), (2, 'Supplier B', 'City B'); INSERT INTO products(id, supplier_id, company_id, product_name) VALUES (1,...
List all suppliers who have not provided any products to the company.
SELECT s.* FROM suppliers s LEFT JOIN products p ON s.id = p.supplier_id WHERE p.company_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Sydney Warehouse', 'west'), (2, 'Melbourne Warehouse', 'west'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, state TEXT); INSERT INTO packages (id, warehouse_id, weight, state) VALUES (1, 1,...
Find the warehouse with the lowest average package weight in the 'west' region.
SELECT w.name FROM warehouses w JOIN (SELECT warehouse_id, MIN(avg_weight) as avg_weight FROM (SELECT warehouse_id, AVG(weight) as avg_weight FROM packages GROUP BY warehouse_id) sub) min_weight ON w.id = min_weight.warehouse_id WHERE w.region = 'west';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR(20), listing_price INT, sustainable BOOLEAN); INSERT INTO properties (id, city, listing_price, sustainable) VALUES (1, 'Chicago', 1000000, true); INSERT INTO properties (id, city, listing_price, sustainable) VALUES (2, 'Chicago', 800000, false);
What is the maximum listing price for sustainable properties in Chicago?
SELECT MAX(listing_price) FROM properties WHERE city = 'Chicago' AND sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (sequestration_id INT, species VARCHAR(50), co2_sequestration FLOAT);
Find the species with the lowest CO2 sequestration in the carbon_sequestration table?
SELECT species, MIN(co2_sequestration) FROM carbon_sequestration GROUP BY species ORDER BY co2_sequestration ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_conservation_orgs (org_name TEXT, country TEXT, year_founded INTEGER);
Delete all records from the marine_conservation_orgs table
DELETE FROM marine_conservation_orgs;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_temperature (month TEXT, temperature FLOAT, other_data TEXT);
What are the names and average temperatures of the top 3 warmest months in the 'monthly_temperature' table?
SELECT mt1.month, AVG(mt1.temperature) as avg_temp FROM monthly_temperature mt1 JOIN (SELECT month, MAX(temperature) as max_temp FROM monthly_temperature GROUP BY month LIMIT 3) mt2 ON mt1.month = mt2.month GROUP BY mt1.month ORDER BY avg_temp DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, joined_date DATE); INSERT INTO users (id, joined_date) VALUES (1, '2021-01-01'), (2, '2020-05-12'), (3, '2019-10-05'), (4, '2021-07-14'); CREATE TABLE posts (id INT, user_id INT, posted_date DATE); INSERT INTO posts (id, user_id, posted_date) VALUES (1, 1, '2022-06-12'), (2, 1, '2022-05-25')...
How many users have interacted with posts related to LGBTQ+ rights in the past year?
SELECT COUNT(DISTINCT users.id) FROM users INNER JOIN posts ON users.id = posts.user_id INNER JOIN post_tags ON posts.id = post_tags.post_id WHERE post_tags.tag = 'LGBTQ+ rights' AND users.joined_date <= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), completion_year INT); INSERT INTO infrastructure_projects (id, project_name, location, completion_year) VALUES (1, 'Highway 101 Expansion', 'California', 2022), (2, 'Bridge Replacement', 'New York', 2021), (3, 'Transit System ...
How many infrastructure projects were completed in 2021 and 2022?
SELECT completion_year, COUNT(*) as num_projects FROM infrastructure_projects WHERE completion_year IN (2021, 2022) GROUP BY completion_year;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policyholder_id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(50), zip_code VARCHAR(10));
Create a view 'policyholders_by_age' that displays the number of policyholders by age range
CREATE VIEW policyholders_by_age AS SELECT CASE WHEN age < 25 THEN '0-24' WHEN age < 35 THEN '25-34' WHEN age < 45 THEN '35-44' WHEN age < 55 THEN '45-54' ELSE '55+' END as age_range, COUNT(*) as num_policyholders FROM policyholders GROUP BY age_range;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, state VARCHAR(2), city VARCHAR(20), attendees INT, event_date DATE); INSERT INTO Events (id, state, city, attendees, event_date) VALUES (1, 'OH', 'Columbus', 500, '2022-01-01'), (2, 'MI', 'Detroit', 300, '2022-02-01'), (3, 'OH', 'Cleveland', 400, '2022-03-01'); CREATE TABLE Zipcodes (zip IN...
Insert a new record for an event with 250 attendees in 'Portland', OR on '2023-01-15' for a 'Community Art' program, which is not in an underrepresented area.
INSERT INTO Events (id, state, city, attendees, event_date) VALUES (4, 'OR', 'Portland', 250, '2023-01-15');
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item_name VARCHAR(255), warehouse_location VARCHAR(255));
Insert a new warehouse location for item with ID 111
INSERT INTO inventory (id, item_name, warehouse_location) VALUES (111, 'Thingamajig', 'Aisle 9');
gretelai_synthetic_text_to_sql