context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE community_education (id INT, program VARCHAR(255), attendance INT); INSERT INTO community_education (id, program, attendance) VALUES (1, 'Biodiversity', 30), (2, 'Climate Change', 40), (3, 'Habitat Restoration', 60);
Update the program of 'Biodiversity' in the 'community_education' table to 'Biodiversity and Wildlife Conservation'.
UPDATE community_education SET program = 'Biodiversity and Wildlife Conservation' WHERE program = 'Biodiversity';
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, city VARCHAR(255), date DATE, type VARCHAR(255), description TEXT); INSERT INTO crimes (id, city, date, type, description) VALUES (1, 'Paris', '2022-01-01', 'Theft', 'Bicycle theft'), (2, 'Paris', '2022-02-01', 'Vandalism', 'Graffiti');
What is the most common type of crime in Paris, and how many times did it occur?
SELECT type, COUNT(*) FROM crimes WHERE city = 'Paris' GROUP BY type ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Protected_Habitats (id INT, animal_species VARCHAR(50), habitat_id INT, animal_count INT);
What is the maximum number of animals in a protected habitat for each animal species?
SELECT animal_species, MAX(animal_count) FROM Protected_Habitats GROUP BY animal_species;
gretelai_synthetic_text_to_sql
CREATE TABLE Licenses (License_ID INT, License_Type TEXT, Issue_Date DATE); INSERT INTO Licenses (License_ID, License_Type, Issue_Date) VALUES (1, 'Cultivation', '2021-01-01');
List the number of cultivation licenses issued per month in 2021.
SELECT DATE_TRUNC('month', Issue_Date) as Month, COUNT(*) as Count FROM Licenses WHERE License_Type = 'Cultivation' AND YEAR(Issue_Date) = 2021 GROUP BY Month ORDER BY Month;
gretelai_synthetic_text_to_sql
CREATE SCHEMA telecom; CREATE TABLE customer_complaints (customer_id INT, complaint_type TEXT, complaint_date DATE);
Create a new table 'customer_complaints' with columns 'customer_id', 'complaint_type', 'complaint_date'
CREATE TABLE telecom.customer_complaints (customer_id INT, complaint_type TEXT, complaint_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10)); INSERT INTO graduate_students VALUES (1, 'Alice Johnson', 'Physics', 'Female'); INSERT INTO graduate_students VALUES (2, 'Bob Brown', 'Physics', 'Male'); INSERT INTO graduate_students VALUES (3, 'Charlie Davis', 'Chemistry', 'Male'); CREATE TABLE grants_graduate_students (grant_id INT, student_id INT, amount DECIMAL(10, 2), year INT); INSERT INTO grants_graduate_students VALUES (1, 1, 50000, 2016); INSERT INTO grants_graduate_students VALUES (2, 2, 75000, 2017); INSERT INTO grants_graduate_students VALUES (3, 2, 60000, 2018); INSERT INTO grants_graduate_students VALUES (4, 1, 65000, 2019);
What is the number of research grants awarded to female graduate students in the Physics department since 2016?
SELECT COUNT(*) FROM grants_graduate_students g INNER JOIN graduate_students s ON g.student_id = s.student_id WHERE s.department = 'Physics' AND s.gender = 'Female' AND g.year >= 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget_Allocation (budget_id INT, category VARCHAR(50), amount DECIMAL(10,2), district_id INT, allocated_date DATE); INSERT INTO Budget_Allocation (budget_id, category, amount, district_id, allocated_date) VALUES (5, 'Parks and Recreation', 25000.00, 7, '2021-04-10');
What is the budget allocation for 'Parks and Recreation' in the district with the highest budget allocation?
SELECT ba.amount FROM Budget_Allocation ba WHERE ba.category = 'Parks and Recreation' AND ba.district_id = (SELECT MAX(ba2.district_id) FROM Budget_Allocation ba2);
gretelai_synthetic_text_to_sql
CREATE TABLE Asset_Smart_Contracts (id INT PRIMARY KEY, digital_asset_id INT, smart_contract_id INT, FOREIGN KEY (digital_asset_id) REFERENCES Digital_Assets(id), FOREIGN KEY (smart_contract_id) REFERENCES Smart_Contracts(id)); INSERT INTO Asset_Smart_Contracts (id, digital_asset_id, smart_contract_id) VALUES (1, 1, 2); INSERT INTO Asset_Smart_Contracts (id, digital_asset_id, smart_contract_id) VALUES (2, 2, 4);
List all digital assets and their respective smart contract names in the Gaming category.
SELECT da.name, sc.name FROM Digital_Assets da INNER JOIN Asset_Smart_Contracts asc ON da.id = asc.digital_asset_id INNER JOIN Smart_Contracts sc ON asc.smart_contract_id = sc.id WHERE sc.category = 'Gaming';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists VisitorStatisticsByYear (Year INT, Country VARCHAR(50), Visitors INT); INSERT INTO VisitorStatisticsByYear (Year, Country, Visitors) VALUES (2021, 'Germany', 1000000), (2022, 'Germany', 950000), (2021, 'Spain', 800000), (2022, 'Spain', 780000), (2021, 'France', 900000), (2022, 'France', 920000);
Which countries had a decrease in visitors to their capital cities from 2021 to 2022?
SELECT a.Country, (b.Visitors - a.Visitors) AS VisitorChange FROM VisitorStatisticsByYear a, VisitorStatisticsByYear b WHERE a.Country = b.Country AND a.Year = 2021 AND b.Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Sensors (SensorID varchar(5), SensorName varchar(10), LastDataSent timestamp); INSERT INTO Sensors (SensorID, SensorName, LastDataSent) VALUES ('1', 'Sensor 1', '2022-06-22 12:30:00'), ('2', 'Sensor 2', '2022-06-25 16:45:00'), ('3', 'Sensor 3', '2022-06-28 09:10:00');
Which sensors in the precision agriculture system have not sent data in the past week?
SELECT SensorName FROM Sensors WHERE LastDataSent < NOW() - INTERVAL '7 days';
gretelai_synthetic_text_to_sql
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, Sold DATE, PropertyPrice INT);
What is the average property price for each neighborhood in the last 6 months?
SELECT NeighborhoodName, AVG(PropertyPrice) AS AvgPropertyPrice FROM Properties JOIN Neighborhoods ON Properties.NeighborhoodID = Neighborhoods.NeighborhoodID WHERE Sold >= DATEADD(month, -6, CURRENT_TIMESTAMP) GROUP BY NeighborhoodName;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_arrivals (vessel_id INT, arrival_date DATE, arrival_delay INT, port VARCHAR(255));
What was the average delay in minutes for vessels arriving in Japan in Q3 2021?
SELECT AVG(arrival_delay) FROM vessel_arrivals WHERE port = 'Japan' AND QUARTER(arrival_date) = 3 AND YEAR(arrival_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255)); CREATE TABLE ingredients (ingredient_id INT, ingredient_name VARCHAR(255), dish_id INT, is_organic BOOLEAN); INSERT INTO dishes VALUES (1, 'Caprese Salad'); INSERT INTO ingredients VALUES (1, 'Fresh Mozzarella', 1, false); INSERT INTO ingredients VALUES (2, 'Tomatoes', 1, true);
What is the percentage of organic ingredients used in each dish, excluding dishes with fewer than 5 organic ingredients?
SELECT dish_name, ROUND(COUNT(ingredient_id) * 100.0 / (SELECT COUNT(ingredient_id) FROM ingredients i2 WHERE i2.dish_id = i.dish_id), 2) as organic_percentage FROM ingredients i WHERE is_organic = true GROUP BY dish_id HAVING COUNT(ingredient_id) >= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10), Region VARCHAR(2)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender, Region) VALUES (1, 35, 'F', 'NY'), (2, 40, 'M', 'CA'), (3, 45, 'F', 'NY'), (4, 50, 'M', 'IL'), (5, 55, 'M', 'IL');
Update the Gender of the community health worker with Age 55 to 'Non-binary'.
UPDATE CommunityHealthWorkers SET Gender = 'Non-binary' WHERE Age = 55;
gretelai_synthetic_text_to_sql
use rural_health; CREATE TABLE medical_conditions (id int, patient_id int, county text, condition text); INSERT INTO medical_conditions (id, patient_id, county, condition) VALUES (1, 1, 'Green', 'Diabetes'); INSERT INTO medical_conditions (id, patient_id, county, condition) VALUES (2, 1, 'Green', 'Hypertension'); INSERT INTO medical_conditions (id, patient_id, county, condition) VALUES (3, 2, 'Blue', 'Asthma');
In which rural counties are specific medical conditions most prevalent?
SELECT county, condition, COUNT(*) as count FROM rural_health.medical_conditions GROUP BY county, condition ORDER BY count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE frameworks (id INT, country VARCHAR(50), date DATE, type VARCHAR(50)); INSERT INTO frameworks (id, country, date, type) VALUES (1, 'UAE', '2021-01-01', 'Blockchain'), (2, 'Saudi Arabia', '2021-02-01', 'Blockchain'), (3, 'Egypt', '2021-03-01', 'Cryptocurrency');
How many regulatory frameworks related to blockchain have been implemented in the Middle East and North Africa?
SELECT COUNT(*) FROM frameworks WHERE country IN ('UAE', 'Saudi Arabia', 'Egypt') AND type = 'Blockchain';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition (id INT, name VARCHAR(100), Visitor_id INT, country VARCHAR(50)); INSERT INTO Exhibition (id, name, Visitor_id, country) VALUES (1, 'Ancient Civilizations', 1, 'USA'), (2, 'Modern Art', 2, 'Canada'), (3, 'Nature Photography', 3, 'Mexico'), (4, 'Wildlife', 4, 'Brazil'), (5, 'Robotics', 5, 'USA');
Identify the top 5 most active countries in terms of exhibition visits in the last quarter.
SELECT Exhibition.country, COUNT(DISTINCT Exhibition.Visitor_id) as visit_count FROM Exhibition WHERE Exhibition.interaction_date >= CURDATE() - INTERVAL 3 MONTH GROUP BY Exhibition.country ORDER BY visit_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE SoilMoistureData (moisture FLOAT, time DATETIME, crop VARCHAR(255));
What is the maximum soil moisture level recorded for each crop type in the past week?
SELECT crop, MAX(moisture) FROM SoilMoistureData WHERE time > DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK) GROUP BY crop;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, registered_date DATE);CREATE TABLE investments (id INT, client_id INT, investment_date DATE); INSERT INTO clients (id, registered_date) VALUES (1, '2020-01-01'), (2, '2019-01-01'), (3, '2018-01-01'), (4, '2017-01-01'), (5, '2016-01-01'); INSERT INTO investments (id, client_id, investment_date) VALUES (1, 1, '2021-02-01'), (2, 1, '2021-03-01'), (3, 2, '2020-04-01'), (4, 3, '2019-05-01'), (5, 4, '2018-06-01'), (6, 1, '2021-02-02'), (7, 1, '2021-02-03'), (8, 5, '2021-03-01'), (9, 2, '2021-02-01'), (10, 3, '2021-03-01');
What is the total number of clients who have made an investment in each month of the past year?
SELECT DATE_TRUNC('month', investment_date) AS investment_month, COUNT(DISTINCT c.id) AS num_clients FROM clients c JOIN investments i ON c.id = i.client_id WHERE i.investment_date >= c.registered_date + INTERVAL '1 year' GROUP BY investment_month;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Rural'), (2, 'Urban'), (3, 'Suburban'); CREATE TABLE students (student_id INT, student_name TEXT, district_id INT, mental_health_score INT, student_gender TEXT); INSERT INTO students (student_id, student_name, district_id, mental_health_score, student_gender) VALUES (1, 'Alex', 1, 75, 'Female'), (2, 'Bella', 2, 80, 'Female'), (3, 'Charlie', 3, 70, 'Male'), (4, 'Danielle', 1, 60, 'Female'), (5, 'Eli', 3, 65, 'Male');
What is the average number of students in each district, and what is the minimum mental health score for students in each district, grouped by student gender?
SELECT students.student_gender, districts.district_name, AVG(students.student_id) AS avg_students, MIN(students.mental_health_score) AS min_mental_health_score FROM districts JOIN students ON districts.district_id = students.district_id GROUP BY students.student_gender, districts.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovations (id INT, innovation VARCHAR(255), type VARCHAR(255)); CREATE TABLE technology_providers (id INT, provider VARCHAR(255), specialization VARCHAR(255));
Which military innovations are not associated with any technology provider?
SELECT innovation FROM military_innovations mi LEFT JOIN technology_providers tp ON mi.id = tp.id WHERE tp.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Parks (City VARCHAR(20), Year INT, Number INT); INSERT INTO Parks (City, Year, Number) VALUES ('CityI', 2019, 5);
How many parks were opened in 'CityI' in the year 2019?
SELECT Number FROM Parks WHERE City = 'CityI' AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (name VARCHAR(30), gender VARCHAR(10), nationality VARCHAR(20)); INSERT INTO Astronauts (name, gender, nationality) VALUES ('Valentina Tereshkova', 'Female', 'Russia');
What is the name of the first female astronaut from Russia?
SELECT name FROM Astronauts WHERE gender = 'Female' AND nationality = 'Russia' LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE funding(id INT, organization VARCHAR(255), amount FLOAT, year INT);
Add a new column year to the funding table and update values
ALTER TABLE funding ADD COLUMN year INT;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), launch_date DATETIME, launch_failure BOOLEAN);
Get the number of successful satellite launches per country
SELECT country, COUNT(*) AS successful_launches FROM satellites WHERE launch_failure = FALSE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE medications (patient_id INT, medication VARCHAR(20)); INSERT INTO medications (patient_id, medication) VALUES (1, 'Prozac'); INSERT INTO medications (patient_id, medication) VALUES (2, 'Lexapro'); INSERT INTO medications (patient_id, medication) VALUES (3, 'Zoloft');
What is the total number of patients who have been prescribed medication?
SELECT COUNT(DISTINCT patient_id) FROM medications;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (contractor VARCHAR(255), project VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO defense_projects (contractor, project, start_date, end_date) VALUES ('Boeing', 'Project A', '2015-01-01', '2017-12-31'), ('Boeing', 'Project B', '2016-07-01', '2018-06-30'), ('Boeing', 'Project C', '2017-03-01', '2019-02-28'), ('Boeing', 'Project D', '2018-09-01', '2020-08-31'), ('Boeing', 'Project E', '2019-11-01', '2021-10-31');
What is the maximum number of defense projects that Boeing has been involved in simultaneously in any given year?
SELECT COUNT(project) FROM defense_projects dp1 WHERE YEAR(dp1.start_date) <= YEAR(dp1.end_date) AND NOT EXISTS (SELECT 1 FROM defense_projects dp2 WHERE dp2.contractor = dp1.contractor AND dp2.project != dp1.project AND YEAR(dp2.start_date) < YEAR(dp1.end_date) AND YEAR(dp2.end_date) > YEAR(dp1.start_date));
gretelai_synthetic_text_to_sql
CREATE TABLE processes (id INT, name TEXT, type TEXT, carbon_footprint FLOAT); INSERT INTO processes (id, name, type, carbon_footprint) VALUES (1, 'manufacturing', 'manufacturing', 1000.0), (2, 'transportation', 'transportation', 2000.0), (3, 'manufacturing', 'manufacturing', 1500.0);
What is the total 'carbon footprint' of 'manufacturing' in 'China'?
SELECT SUM(carbon_footprint) FROM processes WHERE type = 'manufacturing' AND location = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE customer_demographics (customer_id INT, age_group VARCHAR(255), network_type VARCHAR(255)); INSERT INTO customer_demographics (customer_id, age_group, network_type) VALUES (1, '18-24', '3G'), (2, '25-34', '4G'); CREATE TABLE usage_patterns (customer_id INT, usage_minutes INT); INSERT INTO usage_patterns (customer_id, usage_minutes) VALUES (1, 300), (2, 450);
What is the breakdown of customer usage patterns by age group and network type?
SELECT a.age_group, b.network_type, AVG(usage_minutes) FROM customer_demographics a JOIN usage_patterns b ON a.customer_id = b.customer_id GROUP BY a.age_group, b.network_type;
gretelai_synthetic_text_to_sql
CREATE TABLE TicketSales (ticketID INT, saleDate DATE, performance VARCHAR(20), numTickets INT); INSERT INTO TicketSales (ticketID, saleDate, performance, numTickets) VALUES (1, '2022-04-01', 'Dance Performance', 100), (2, '2022-05-10', 'Theater Play', 50), (3, '2022-06-20', 'Dance Performance', 150);
What is the total number of tickets sold for the dance performance in the last year?
SELECT SUM(numTickets) FROM TicketSales WHERE performance = 'Dance Performance' AND saleDate >= '2022-04-01' AND saleDate <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_technology (id INT, project_name VARCHAR(50), description TEXT, location VARCHAR(50)); INSERT INTO biosensor_technology (id, project_name, description, location) VALUES (1, 'Project1', 'Biosensor for glucose detection', 'Canada'); INSERT INTO biosensor_technology (id, project_name, description, location) VALUES (2, 'Project2', 'Biosensor for protein detection', 'Australia');
What is the name and description of each biosensor technology project in Canada and Australia?
SELECT project_name, description FROM biosensor_technology WHERE location IN ('Canada', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE Site (site_id INT, site_name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Site (site_id, site_name, country, start_date, end_date) VALUES (1, 'Mohenjo-Daro', 'Indus Valley', '2500 BC', '1900 BC'), (2, 'Harappa', 'Indus Valley', '2600 BC', '1900 BC'); CREATE TABLE Artifact (artifact_id INT, artifact_name VARCHAR(255), site_id INT, date_found DATE); INSERT INTO Artifact (artifact_id, artifact_name, site_id, date_found) VALUES (1, 'Bronze Dagger', 1, '1922-02-01'), (2, 'Terracotta Bull', 2, '1920-12-12'); CREATE TABLE Preservation (preservation_id INT, method VARCHAR(255), artifact_id INT); INSERT INTO Preservation (preservation_id, method, artifact_id) VALUES (1, 'Coating', 1), (2, 'Conservation', 2); CREATE VIEW ArtifactPreservation AS SELECT * FROM Artifact JOIN Preservation ON Artifact.artifact_id = Preservation.artifact_id;
Show artifacts found in the 'Indus Valley' that were preserved using the 'Coating' method.
SELECT * FROM ArtifactPreservation WHERE country = 'Indus Valley' AND method = 'Coating';
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (ingredient_name VARCHAR(50)); INSERT INTO ingredients (ingredient_name) VALUES ('Water'), ('Mineral Powder'), ('Chemical X'), ('Chemical Y');
What are the names of all ingredients that are used in both cruelty-free certified products and products not certified as cruelty-free?
SELECT ingredients.ingredient_name FROM ingredients JOIN product_ingredients ON ingredients.ingredient_name = product_ingredients.ingredient WHERE product_ingredients.ingredient_source IN (SELECT ingredient_source FROM product_ingredients WHERE product_ingredients.product_name IN (SELECT products.product_name FROM products WHERE products.is_cruelty_free = true)) AND ingredients.ingredient_name IN (SELECT ingredient FROM product_ingredients WHERE product_ingredients.product_name NOT IN (SELECT products.product_name FROM products WHERE products.is_cruelty_free = true)) GROUP BY ingredients.ingredient_name HAVING COUNT(DISTINCT product_ingredients.ingredient_source) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE field_1 (id INT PRIMARY KEY, x_coordinate INT, y_coordinate INT, crop_type TEXT, area_hectares FLOAT); INSERT INTO field_1 (id, x_coordinate, y_coordinate, crop_type, area_hectares) VALUES (1, 100, 200, 'soybeans', 5.3), (2, 150, 250, 'wheat', 3.2), (3, 200, 300, 'cotton', 7.1);
Update the 'crop_type' column to 'corn' for all records in the 'field_1' table
UPDATE field_1 SET crop_type = 'corn';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_name TEXT, approval_status TEXT); INSERT INTO drug_approval (drug_name, approval_status) VALUES ('DrugA', 'approved'), ('DrugB', 'approved'), ('DrugC', 'pending'), ('DrugD', 'approved'); CREATE TABLE manufacturing_costs (drug_name TEXT, cost_per_unit INTEGER); INSERT INTO manufacturing_costs (drug_name, cost_per_unit) VALUES ('DrugA', 185), ('DrugB', 210), ('DrugC', 150), ('DrugD', 256); CREATE TABLE drug_sales (drug_name TEXT, sales INTEGER, therapeutic_area TEXT); INSERT INTO drug_sales (drug_name, sales, therapeutic_area) VALUES ('DrugA', 30000000, 'neurology'), ('DrugB', 45000000, 'neurology'), ('DrugC', 0, 'neurology'), ('DrugD', 55000000, 'neurology');
What are the total sales for drugs with a manufacturing cost of more than $200 per unit and in the neurology therapeutic area?
SELECT SUM(sales) FROM drug_sales INNER JOIN drug_approval ON drug_sales.drug_name = drug_approval.drug_name INNER JOIN manufacturing_costs ON drug_sales.drug_name = manufacturing_costs.drug_name WHERE drug_approval.approval_status = 'approved' AND manufacturing_costs.cost_per_unit > 200 AND drug_sales.therapeutic_area = 'neurology';
gretelai_synthetic_text_to_sql
CREATE TABLE PublicServices (ID INT, Service TEXT, Description TEXT, Availability TEXT);
Delete a record from the "PublicServices" table based on the provided criteria
WITH service_to_delete AS (DELETE FROM PublicServices WHERE ID = 4001 AND Service = 'Senior Transportation' RETURNING ID, Service, Description, Availability) SELECT * FROM service_to_delete;
gretelai_synthetic_text_to_sql
CREATE TABLE refugees (id INT, country TEXT, year INT, num_refugees INT); INSERT INTO refugees
How many refugees were helped in Colombia in 2017?
SELECT COUNT(*) FROM refugees WHERE country = 'Colombia' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE insured_homes (id INT, state VARCHAR(2), policy_type VARCHAR(20), claim_amount DECIMAL(10,2)); INSERT INTO insured_homes (id, state, policy_type, claim_amount) VALUES (1, 'TX', 'Homeowners', 5000), (2, 'TX', 'Homeowners', 12000), (3, 'TX', 'Renters', 800);
What is the average claim amount for homeowners insurance in Texas?
SELECT AVG(claim_amount) FROM insured_homes WHERE state = 'TX' AND policy_type = 'Homeowners';
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (ChemicalID INT, CO2Emissions INT, CH4Emissions INT, N2OEmissions INT); INSERT INTO EnvironmentalImpact (ChemicalID, CO2Emissions, CH4Emissions, N2OEmissions) VALUES (1, 100, 20, 30), (2, 150, 30, 40), (3, 50, 10, 20);
List the chemical names and the total greenhouse gas emissions for each chemical.
SELECT ChemicalID, CO2Emissions + CH4Emissions + N2OEmissions AS TotalEmissions, ChemicalName FROM EnvironmentalImpact INNER JOIN Chemicals ON EnvironmentalImpact.ChemicalID = Chemicals.ChemicalID;
gretelai_synthetic_text_to_sql
CREATE TABLE program_funding (program_category VARCHAR(15), funding_source VARCHAR(15), amount INT);
What is the total funding from private and public sources for each program category?
SELECT program_category, SUM(CASE WHEN funding_source = 'private' THEN 1 ELSE 0 END) + SUM(CASE WHEN funding_source = 'public' THEN 1 ELSE 0 END) AS total_funding FROM program_funding GROUP BY program_category;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT); INSERT INTO clients (client_id, name) VALUES (1, 'Jane Doe'), (2, 'John Smith'), (3, 'Sara Connor'), (4, 'Tom Williams'); CREATE TABLE cases (case_id INT, client_id INT, billing_amount INT, paid_in_full BOOLEAN); INSERT INTO cases (case_id, client_id, billing_amount, paid_in_full) VALUES (1, 1, 12000, TRUE), (2, 2, 8000, FALSE), (3, 3, 20000, TRUE), (4, 4, 5000, FALSE);
List all clients who have paid their bills in full for cases with a billing amount greater than $10,000.
SELECT clients.name FROM clients INNER JOIN cases ON clients.client_id = cases.client_id WHERE cases.billing_amount > 10000 AND cases.paid_in_full = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255)); INSERT INTO regulations (id, name, region) VALUES (1, 'Regulation1', 'European Union'), (2, 'Regulation2', 'United States');
List all regulatory frameworks in the European Union.
SELECT name FROM regulations WHERE region = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_prices (price DECIMAL(5,2), team_id INT, game_id INT, game_type VARCHAR(255)); INSERT INTO ticket_prices (price, team_id, game_id, game_type) VALUES (25.00, 4, 201, 'Regular Season'), (30.00, 4, 202, 'Regular Season'), (35.00, 5, 203, 'Regular Season'), (20.00, 5, 204, 'Regular Season'); CREATE TABLE teams (team_id INT, team_name VARCHAR(255), sport VARCHAR(255)); INSERT INTO teams (team_id, team_name, sport) VALUES (4, 'Spirit', 'Soccer'), (5, 'Courage', 'Soccer'); CREATE TABLE games (game_id INT, home_team_id INT, game_type VARCHAR(255)); INSERT INTO games (game_id, home_team_id, game_type) VALUES (201, 4, 'Home'), (202, 4, 'Home'), (203, 5, 'Home'), (204, 5, 'Home');
What is the average ticket price for women's soccer team home games?
SELECT t.team_name, AVG(price) avg_price FROM ticket_prices tp JOIN teams t ON tp.team_id = t.team_id JOIN games g ON tp.game_id = g.game_id WHERE t.team_id = g.home_team_id AND tp.game_type = 'Home' AND t.sport = 'Soccer' AND tp.price IS NOT NULL GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, publication_date DATE); INSERT INTO articles (article_id, publication_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2022-01-03');
What is the number of articles published per day for the last week?
SELECT DATEPART(day, publication_date) AS day_of_week, COUNT(article_id) FROM articles WHERE publication_date >= DATEADD(week, -1, GETDATE()) GROUP BY DATEPART(day, publication_date);
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), response_time FLOAT); INSERT INTO emergency_calls (id, city, response_time) VALUES (1, 'Toronto', 4.5), (2, 'Toronto', 3.9), (3, 'Montreal', 5.1);
What is the minimum response time for emergency calls in the city of Toronto?
SELECT MIN(response_time) FROM emergency_calls WHERE city = 'Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE news_reporters (reporter_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), hire_date DATE);
Show the number of male and female reporters in the 'news_reporters' table, grouped by their age.
SELECT gender, age, COUNT(*) FROM news_reporters GROUP BY gender, age;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, total_donations DECIMAL(10, 2)); INSERT INTO donors (id, name, total_donations) SELECT donor_id, donor_name, SUM(amount) FROM donations GROUP BY donor_id; CREATE TABLE donations (id INT, donor_id INT, donor_name TEXT, amount DECIMAL(10, 2));
What is the total amount donated by each donor in the 'donors' and 'donations' tables?
SELECT d.name, SUM(d2.amount) FROM donors d INNER JOIN donations d2 ON d.id = d2.donor_id GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (sensor_id INT, water_level FLOAT, timestamp TIMESTAMP);
Find the sensor with the minimum water level in the 'sensor_data' table
SELECT sensor_id, MIN(water_level) as min_water_level FROM sensor_data;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_features (id INT, hotel_name TEXT, location TEXT, ai_features INT); INSERT INTO hotel_features (id, hotel_name, location, ai_features) VALUES (1, 'Hotel A', 'Asia', 5), (2, 'Hotel B', 'Europe', 7), (3, 'Hotel C', 'Americas', 3), (4, 'Hotel D', 'Africa', 6), (5, 'Hotel E', 'Europe', 8), (6, 'Hotel F', 'Asia', 4);
What is the maximum number of AI-powered features in hotels in Europe?
SELECT MAX(ai_features) FROM hotel_features WHERE location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, restaurant_id INT, name VARCHAR(255), revenue DECIMAL(10, 2), cuisine VARCHAR(255));
Identify the menu items that have a higher than average revenue for their respective cuisine category.
SELECT m.name, AVG(o.revenue) OVER (PARTITION BY m.cuisine) AS avg_revenue FROM menu_items m JOIN orders o ON m.menu_item_id = o.menu_item_id WHERE m.revenue > AVG(o.revenue) OVER (PARTITION BY m.cuisine);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, cause_area VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, donation_date, cause_area) VALUES (1, 1, 500.00, '2021-01-01', 'Healthcare'); INSERT INTO donations (id, donor_id, donation_amount, donation_date, cause_area) VALUES (2, 2, 1000.00, '2021-03-31', 'Environment'); INSERT INTO donations (id, donor_id, donation_amount, donation_date, cause_area) VALUES (3, 3, 1500.00, '2021-12-31', 'Education');
Which cause area received the most donations in 2021?
SELECT cause_area, SUM(donation_amount) as total_donation FROM donations WHERE YEAR(donation_date) = 2021 GROUP BY cause_area ORDER BY total_donation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(20), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Male', 'IT'), (2, 'Female', 'IT'), (3, 'Indigenous', 'Finance'), (4, 'Transgender Male', 'Marketing'), (5, 'Lesbian', 'Marketing');
What is the percentage of employees who identify as Indigenous in the Finance department?
SELECT (COUNT(*) / (SELECT COUNT(*) FROM Employees WHERE Department = 'Finance')) * 100 FROM Employees WHERE Department = 'Finance' AND Gender = 'Indigenous';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy(country1 VARCHAR(50), country2 VARCHAR(50), year INT, event VARCHAR(255)); INSERT INTO defense_diplomacy(country1, country2, year, event) VALUES('Saudi Arabia', 'France', 2019, 'Joint military exercise'), ('Israel', 'Germany', 2021, 'Defense technology cooperation'), ('UAE', 'Italy', 2020, 'Military equipment purchase'), ('Iran', 'Spain', 2018, 'Diplomatic visit by defense minister'), ('Qatar', 'UK', 2019, 'Joint naval exercise');
List the defense diplomacy events between Middle Eastern and European countries in the past 3 years.
SELECT country1, country2, event FROM defense_diplomacy WHERE (country1 IN ('Saudi Arabia', 'Israel', 'UAE', 'Iran', 'Qatar') AND country2 IN ('France', 'Germany', 'Italy', 'Spain', 'UK')) OR (country1 IN ('France', 'Germany', 'Italy', 'Spain', 'UK') AND country2 IN ('Saudi Arabia', 'Israel', 'UAE', 'Iran', 'Qatar')) AND year BETWEEN 2018 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(100), Country varchar(50), SignupDate date); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country, SignupDate) VALUES (1, 'Jane Doe', 'Brazil', '2021-01-01');
What is the total number of volunteers who signed up in 'Brazil' in the year 2021?
SELECT COUNT(*) FROM Volunteers WHERE Country = 'Brazil' AND YEAR(SignupDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO machinery (id, name, type, manufacturer) VALUES (1, 'Bulldozer', 'Heavy', 'Caterpillar'); INSERT INTO machinery (id, name, type, manufacturer) VALUES (2, 'Excavator', 'Heavy', 'Komatsu'); INSERT INTO machinery (id, name, type, manufacturer) VALUES (3, 'Drill', 'Light', 'Caterpillar');
Delete all records from the 'machinery' table where the 'manufacturer' is 'Caterpillar'
DELETE FROM machinery WHERE manufacturer = 'Caterpillar';
gretelai_synthetic_text_to_sql
CREATE TABLE RegionalSales (id INT, vehicle_type VARCHAR(50), quantity INT, region VARCHAR(50)); INSERT INTO RegionalSales (id, vehicle_type, quantity, region) VALUES (1, 'Hybrid', 12000, 'US'), (2, 'Hybrid', 8000, 'Canada'), (3, 'Electric', 15000, 'US'), (4, 'Electric', 9000, 'Canada');
What is the total number of hybrid vehicles sold in the US and Canada?
SELECT SUM(quantity) FROM RegionalSales WHERE vehicle_type = 'Hybrid' AND (region = 'US' OR region = 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives(year INT, country VARCHAR(20), initiative VARCHAR(50)); INSERT INTO circular_economy_initiatives VALUES (2017, 'Germany', 'Initiative A'), (2018, 'Germany', 'Initiative B'), (2019, 'Germany', 'Initiative C'), (2020, 'Germany', 'Initiative D');
How many circular economy initiatives were launched in Germany between 2017 and 2020?
SELECT COUNT(*) as total_initiatives FROM circular_economy_initiatives WHERE country = 'Germany' AND year BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE sleep (id INT, user_id INT, duration INT, heart_rate INT, region VARCHAR(10)); INSERT INTO sleep (id, user_id, duration, heart_rate, region) VALUES (1, 1, 360, 75, 'Midwest'), (2, 2, 420, 65, 'South'), (3, 3, 480, 90, 'Midwest'), (4, 1, 450, 80, 'Midwest'), (5, 2, 300, 70, 'South');
What is the minimum sleep duration for users with a heart rate above 80 BPM who live in the Midwest?
SELECT MIN(duration) FROM sleep WHERE heart_rate > 80 AND region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech (region VARCHAR(20), initiatives INT); INSERT INTO accessible_tech (region, initiatives) VALUES ('Africa', 50), ('Asia', 75), ('South America', 100);
What is the number of accessible technology initiatives in South America?
SELECT initiatives FROM accessible_tech WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (id INT, year INT, country VARCHAR(50), vehicle_make VARCHAR(50), vehicle_model VARCHAR(50), quantity INT);
What is the most common make of electric vehicle sold in China?
SELECT vehicle_make, MAX(quantity) FROM SalesData WHERE year >= 2015 AND country = 'China' AND vehicle_type = 'Electric' GROUP BY vehicle_make;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy_capacity_mx (state VARCHAR(50), capacity INT); INSERT INTO wind_energy_capacity_mx (state, capacity) VALUES ('Oaxaca', 2000), ('Tamaulipas', 1500), ('Jalisco', 1200), ('Veracruz', 1000), ('Yucatan', 800);
What is the total installed capacity of wind energy in Mexico, ranked by capacity, for the top 5 states?
SELECT state, capacity, RANK() OVER (ORDER BY capacity DESC) as capacity_rank FROM wind_energy_capacity_mx WHERE state IN ('Oaxaca', 'Tamaulipas', 'Jalisco', 'Veracruz', 'Yucatan') ORDER BY capacity_rank;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_open_date DATE);
How many cases were opened in 'january' 2020?
SELECT COUNT(*) FROM cases WHERE case_open_date BETWEEN '2020-01-01' AND '2020-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, FirstName varchar(50), LastName varchar(50), Email varchar(50)); INSERT INTO Donors (DonorID, FirstName, LastName, Email) VALUES (1, 'John', 'Doe', 'john.doe@example.com');
Update the email address of donor with DonorID 1 in the Donors table.
UPDATE Donors SET Email = 'new.email@example.com' WHERE DonorID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities.buildings (id INT, city VARCHAR(255), co2_emissions INT); CREATE VIEW smart_cities.buildings_view AS SELECT id, city, co2_emissions FROM smart_cities.buildings;
Update the CO2 emissions of buildings in the 'smart_cities' schema with IDs 1, 3, and 5 to the new_emissions value.
UPDATE smart_cities.buildings SET co2_emissions = new_emissions FROM ( SELECT id, 800 as new_emissions FROM generate_series(1, 5) as seq WHERE seq % 2 = 1 ) AS subquery WHERE smart_cities.buildings.id = subquery.id;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE sales (dispensary_id INT, strain_id INT, quantity INT, price DECIMAL(10,2), sale_date DATE); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Arizona'); INSERT INTO sales (dispensary_id, strain_id, quantity, price, sale_date) VALUES (1, 1, 10, 50, '2023-01-01'); INSERT INTO sales (dispensary_id, strain_id, quantity, price, sale_date) VALUES (1, 2, 15, 60, '2023-01-15');
Delete all records of dispensary sales in 2023 that are priced above the average price
DELETE FROM sales WHERE (dispensary_id, price, sale_date) IN (SELECT dispensary_id, AVG(price), sale_date FROM sales WHERE sale_date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY dispensary_id, sale_date HAVING price > AVG(price));
gretelai_synthetic_text_to_sql
CREATE TABLE sales_revenue (drug_name TEXT, country TEXT, sales_revenue NUMERIC, month DATE); INSERT INTO sales_revenue (drug_name, country, sales_revenue, month) VALUES ('Drug1', 'France', 250000, '2020-03-01'), ('Drug2', 'Italy', 300000, '2020-02-01'), ('Drug3', 'France', 150000, '2020-01-01'), ('Drug4', 'Italy', 200000, '2020-03-01'), ('Drug5', 'France', 350000, '2020-02-01');
Find the maximum sales revenue for a drug in France and Italy, for each drug.
SELECT drug_name, MAX(sales_revenue) FROM sales_revenue WHERE country IN ('France', 'Italy') GROUP BY drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, student_name VARCHAR(255), age INT); CREATE TABLE accommodations (accommodation_id INT, student_id INT, accommodation_date DATE);
Identify the number of accommodations provided for students in each age group, and the percentage of total accommodations for each age group?
SELECT s.age, COUNT(a.accommodation_id) as accommodations_count, ROUND(COUNT(a.accommodation_id) * 100.0 / (SELECT COUNT(*) FROM accommodations) , 2) as percentage_of_total FROM students s JOIN accommodations a ON s.student_id = a.student_id GROUP BY s.age;
gretelai_synthetic_text_to_sql
CREATE TABLE HeavyFish (id INT, species VARCHAR(255), weight FLOAT, length FLOAT); INSERT INTO HeavyFish (id, species, weight, length) VALUES (1, 'Shark', 350.5, 250.3); INSERT INTO HeavyFish (id, species, weight, length) VALUES (2, 'Marlin', 200.3, 300.6); INSERT INTO HeavyFish (id, species, weight, length) VALUES (3, 'Swordfish', 250.8, 280.5); INSERT INTO HeavyFish (id, species, weight, length) VALUES (4, 'Tuna', 180.2, 200.7);
Calculate the average length of fish for each species that weigh more than 150kg in the 'HeavyFish' table
SELECT species, AVG(length) FROM HeavyFish WHERE weight > 150 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_id INT, depth FLOAT, size INT, country VARCHAR(255)); INSERT INTO marine_protected_areas (name, area_id, depth, size, country) VALUES ('Norwegian Arctic Archipelago', 23, 300, 196000, 'Norway'), ('Gulf of Leptev Sea', 24, 400, 320000, 'Russia');
What is the total depth of marine protected areas in the Arctic?
SELECT SUM(depth) FROM marine_protected_areas WHERE country = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE retailers(retailer_id INT, name TEXT, last_purchase_date DATE); INSERT INTO retailers(retailer_id, name, last_purchase_date) VALUES (101, 'Retailer A', '2021-12-01'), (102, 'Retailer B', '2022-02-15'), (103, 'Retailer C', NULL), (104, 'Retailer D', '2022-03-01');
Delete retailers that have not made a purchase in the last year
DELETE FROM retailers WHERE last_purchase_date < (CURRENT_DATE - INTERVAL '1 year');
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, job_title VARCHAR(20)); INSERT INTO attorneys (attorney_id, job_title) VALUES (1, 'Senior Attorney'), (2, 'Junior Attorney'), (3, 'Associate'); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 2), (3, 3);
How many cases were handled by attorneys who have the word 'junior' in their job title?
SELECT COUNT(*) FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.job_title LIKE '%junior%';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_site (site_id INT, name TEXT, city TEXT, country TEXT, is_open BOOLEAN); INSERT INTO cultural_site (site_id, name, city, country, is_open) VALUES (3, 'Rio Cultural Center', 'Rio de Janeiro', 'Brazil', false);
Delete cultural sites in Rio de Janeiro that have been closed.
DELETE FROM cultural_site WHERE city = 'Rio de Janeiro' AND is_open = false;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT, DonationDate DATE); CREATE TABLE VolunteerHours (ProgramID INT, VolunteerHours INT); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Food Security'), (2, 'Climate Change'); INSERT INTO Donations (DonationID, DonorID, ProgramID, DonationDate) VALUES (1, 1, 1, '2023-01-15'); INSERT INTO VolunteerHours (ProgramID, VolunteerHours) VALUES (2, 50);
Which programs received donations within the last month but have no reported volunteer hours?
SELECT p.ProgramName FROM Programs p LEFT JOIN Donations d ON p.ProgramID = d.ProgramID LEFT JOIN VolunteerHours v ON p.ProgramID = v.ProgramID WHERE d.DonationDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND v.ProgramID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, genre TEXT, country TEXT); CREATE TABLE streams (id INT, song_id INT, artist_id INT, platform TEXT, streams INT); CREATE TABLE songs (id INT, title TEXT, artist_id INT); INSERT INTO artists (id, name, genre, country) VALUES (1, 'Taylor Swift', 'Country Pop', 'USA'), (2, 'Eminem', 'Hip Hop', 'USA'), (3, 'BTS', 'KPop', 'South Korea'); INSERT INTO streams (id, song_id, artist_id, platform, streams) VALUES (1, 1, 1, 'Spotify', 10000000), (2, 2, 2, 'Spotify', 5000000), (3, 3, 3, 'Spotify', 20000000), (4, 4, 3, 'Apple Music', 15000000);
How many streams did BTS get from Spotify?
SELECT SUM(streams) FROM streams WHERE artist_id = (SELECT id FROM artists WHERE name = 'BTS' AND platform = 'Spotify');
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_loans (id INT, client_name VARCHAR(50), issue_date DATE, amount FLOAT);
What is the maximum amount of Shariah-compliant loans issued in a single month?
SELECT MAX(amount) FROM (SELECT DATE_TRUNC('month', issue_date) as month, SUM(amount) as amount FROM shariah_loans GROUP BY month) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city VARCHAR(255), year INT, material_type VARCHAR(255), amount INT); INSERT INTO waste_generation (city, year, material_type, amount) VALUES ('Mumbai', 2019, 'Plastic', 2000), ('Mumbai', 2019, 'Paper', 3000), ('Mumbai', 2019, 'Glass', 1500);
What is the total waste generation by material type in the city of Mumbai in 2019?
SELECT material_type, SUM(amount) FROM waste_generation WHERE city = 'Mumbai' AND year = 2019 GROUP BY material_type;
gretelai_synthetic_text_to_sql
CREATE TABLE meal_descriptions (description_id INT, meal_id INT, description TEXT); INSERT INTO meal_descriptions (description_id, meal_id, description) VALUES (1, 1, 'Healthy quinoa salad with chicken'), (2, 2, 'Spicy lentil soup with vegetables'), (3, 3, 'Rich and creamy chickpea curry'), (4, 4, 'Tofu stir fry with bell peppers'), (5, 5, 'Grilled chicken salad with vinaigrette'), (6, 6, 'Beef tacos with salsa');
How many times is 'chicken' mentioned in the meal_descriptions table?
SELECT COUNT(*) FROM meal_descriptions WHERE description LIKE '%chicken%';
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (VisitorID INT, Age INT, City VARCHAR(255)); CREATE TABLE Visits (VisitID INT, VisitorID INT, ExhibitionID INT);
What is the most common age range of visitors to exhibitions in London?
SELECT City, NTILE(4) OVER(ORDER BY Age) as AgeRange FROM Visitors WHERE City = 'London';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists research;CREATE TABLE if not exists research.studies(id INT, title VARCHAR(255), year INT, country VARCHAR(255), category VARCHAR(255)); INSERT INTO research.studies VALUES (1, 'StudyA', 2020, 'Canada', 'Genetics'); INSERT INTO research.studies VALUES (2, 'StudyB', 2019, 'Canada', 'Genetics'); INSERT INTO research.studies VALUES (3, 'StudyC', 2020, 'USA', 'Bioprocess');
How many genetic research studies were conducted in Canada by year?
SELECT year, COUNT(*) FROM research.studies WHERE country = 'Canada' AND category = 'Genetics' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_item_name VARCHAR(255), daily_sales INT, co2_emissions INT, is_seasonal BOOLEAN);
Determine the percentage of menu items prepared with seasonal ingredients and the average CO2 emissions.
SELECT menu_item_name, AVG(co2_emissions) as avg_co2, (SUM(CASE WHEN is_seasonal THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) as seasonal_percentage FROM menus GROUP BY menu_item_name;
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousVehicles (ID INT, Manufacturer VARCHAR(255), SafetyRating FLOAT); INSERT INTO AutonomousVehicles (ID, Manufacturer, SafetyRating) VALUES (1, 'Wayve', 4.3), (2, 'Nuro', 4.5), (3, 'Tesla', 4.1), (4, 'Cruise', 4.7), (5, 'Zoox', 4.6);
What is the average safety rating for all autonomous vehicles, grouped by manufacturer?
SELECT Manufacturer, AVG(SafetyRating) as Avg_Safety_Rating FROM AutonomousVehicles GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, location VARCHAR(50), Neodymium_prod FLOAT); INSERT INTO mines (id, location, Neodymium_prod) VALUES (1, 'Bayan Obo', 12000.0), (2, 'Mount Weld', 3500.0), (3, 'Thunder Bay', 4500.0);
What is the average production quantity of Neodymium in 2020, grouped by mine location?
SELECT location, AVG(Neodymium_prod) FROM mines WHERE YEAR(datetime) = 2020 AND Neodymium_prod IS NOT NULL GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (country VARCHAR(255), num_veterans INT, employment_year INT); INSERT INTO veteran_employment (country, num_veterans, employment_year) VALUES ('USA', 2000000, 2021), ('Canada', 150000, 2021), ('UK', 1200000, 2021), ('Australia', 55000, 2021), ('Germany', 800000, 2021), ('USA', 2100000, 2022), ('Canada', 160000, 2022), ('UK', 1250000, 2022), ('Australia', 58000, 2022), ('Germany', 850000, 2022);
What is the total number of veteran employment in 2022 for each country?
SELECT country, SUM(num_veterans) as total_num_veterans FROM veteran_employment WHERE employment_year = 2022 GROUP BY country ORDER BY total_num_veterans DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE military_vehicles (company VARCHAR(50), region VARCHAR(50), production_year INT, quantity INT); INSERT INTO military_vehicles (company, region, production_year, quantity) VALUES ('Company A', 'Asia-Pacific', 2010, 500), ('Company B', 'Asia-Pacific', 2015, 700), ('Company C', 'Europe', 2012, 600), ('Company D', 'Americas', 2018, 800);
What is the total number of military vehicles produced by companies based in the Asia-Pacific region in the 'military_vehicles' table?
SELECT SUM(quantity) FROM military_vehicles WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE banks (bank_id INT, bank_name VARCHAR(50), total_assets FLOAT, region_id INT);CREATE TABLE loans (loan_id INT, bank_id INT, loan_amount FLOAT, socially_responsible BOOLEAN);
What is the total amount of socially responsible loans issued by each bank in a specific region?
SELECT b.bank_name, SUM(l.loan_amount) as total_loans FROM banks b INNER JOIN loans l ON b.bank_id = l.bank_id WHERE b.region_id = 1 AND l.socially_responsible = TRUE GROUP BY b.bank_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_research_vessels (org_name TEXT, vessel_name TEXT, vessel_type TEXT); INSERT INTO marine_research_vessels (org_name, vessel_name, vessel_type) VALUES ('Ocean Explorers', 'Sea Surveyor', 'Research Vessel'), ('Ocean Explorers', 'Ocean Odyssey', 'Research Vessel'), ('Ocean Adventures', 'Marine Marvel', 'Research Vessel');
How many marine research vessels does the "Ocean Explorers" organization have in total?
SELECT COUNT(*) FROM marine_research_vessels WHERE org_name = 'Ocean Explorers';
gretelai_synthetic_text_to_sql
CREATE TABLE violations (violation_id INT, violation_date DATE, violation_details VARCHAR(255), fine_amount INT);
What is the average mental health parity violation fine amount by state and year?
SELECT EXTRACT(YEAR FROM violation_date) as year, state_id, AVG(fine_amount) as avg_fine_amount FROM violations GROUP BY year, state_id;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (species VARCHAR(50), animal_count INT);
Find the number of animals by species in the 'animal_population' table
SELECT species, SUM(animal_count) FROM animal_population GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE BudgetPrices (hotel_id INT, ota TEXT, city TEXT, hotel_class TEXT, price_per_night FLOAT); INSERT INTO BudgetPrices (hotel_id, ota, city, hotel_class, price_per_night) VALUES (1, 'Expedia', 'Tokyo', 'budget', 80), (2, 'Expedia', 'Tokyo', 'budget', 85), (3, 'Expedia', 'Tokyo', 'non-budget', 120);
What is the average price per night for 'budget' hotels in 'Tokyo' on 'Expedia'?
SELECT AVG(price_per_night) FROM BudgetPrices WHERE ota = 'Expedia' AND city = 'Tokyo' AND hotel_class = 'budget';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_id INT, city VARCHAR(20), country VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id, city, country) VALUES (1, 'Rio de Janeiro', 'Brazil'), (2, 'Sao Paulo', 'Brazil'); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO Visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 15), (2, 1, 18), (3, 2, 20), (4, 2, 25);
What is the minimum age of visitors who attended exhibitions in Rio de Janeiro or Sao Paulo?
SELECT MIN(age) FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.city IN ('Rio de Janeiro', 'Sao Paulo');
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (id INT PRIMARY KEY, location VARCHAR(255), pH DECIMAL(3,2), timestamp TIMESTAMP); INSERT INTO ocean_acidification (id, location, pH, timestamp) VALUES (1, 'Pacific Ocean', 7.8, '2021-08-01 12:00:00'), (2, 'Atlantic Ocean', 8.0, '2021-08-02 15:30:00'); CREATE VIEW ocean_acidification_view AS SELECT * FROM ocean_acidification;
List all records from the ocean acidification view
SELECT * FROM ocean_acidification_view;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_programs (program_id INT, program_name VARCHAR(50), launch_date DATE, program_type VARCHAR(50)); INSERT INTO justice_programs (program_id, program_name, launch_date, program_type) VALUES (1, 'Youth Restorative Justice Program', '2018-01-01', 'Restorative Justice'), (2, 'Community Healing Initiative', '2019-07-01', 'Restorative Justice'), (3, 'Criminal Justice Reform Task Force', '2020-04-15', 'Criminal Justice'), (4, 'Legal Technology Innovation Lab', '2021-10-01', 'Legal Technology');
How many restorative justice programs were launched in each year?
SELECT EXTRACT(YEAR FROM launch_date) as year, COUNT(*) as num_programs FROM justice_programs WHERE program_type = 'Restorative Justice' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_name VARCHAR(255), artist VARCHAR(255), genre VARCHAR(255), release_year INT); INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Dynamite', 'BTS', 'K-Pop', 2020), ('Butter', 'BTS', 'K-Pop', 2021);
Insert a new record for a song by artist 'BTS' from genre 'K-Pop' released in 2022
INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Yet To Come', 'BTS', 'K-Pop', 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets.building_energy_consumption (building VARCHAR(50), consumption FLOAT); INSERT INTO carbon_offsets.building_energy_consumption (building, consumption) VALUES ('Sequoia Building', 123.5), ('Redwood Building', 234.6), ('Pine Building', 345.7);
What is the minimum energy consumption of a building in the 'carbon_offsets' schema?
SELECT MIN(consumption) FROM carbon_offsets.building_energy_consumption;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (site_name VARCHAR(50), country VARCHAR(50), visitors INT); INSERT INTO HeritageSites (site_name, country, visitors) VALUES ('Angkor Wat', 'Cambodia', 2000000), ('Great Wall', 'China', 10000000), ('Taj Mahal', 'India', 8000000), ('Sydney Opera House', 'Australia', 3000000), ('Petra', 'Jordan', 600000);
List the top 3 heritage sites with the highest visitor count in the Asia-Pacific region.
SELECT site_name, visitors FROM HeritageSites WHERE country IN ('Cambodia', 'China', 'India', 'Australia', 'Jordan') AND region = 'Asia-Pacific' ORDER BY visitors DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, company_id INT, sector VARCHAR(255), year INT, amount FLOAT); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (1, 1, 'Healthcare', 2019, 400000.0); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (2, 2, 'Healthcare', 2019, 500000.0); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (3, 3, 'Healthcare', 2019, 600000.0);
What is the minimum investment in a single company in the 'Healthcare' sector in the year 2019?
SELECT MIN(amount) FROM investments WHERE sector = 'Healthcare' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism_initiatives (country VARCHAR(255), year INT, num_initiatives INT); INSERT INTO sustainable_tourism_initiatives (country, year, num_initiatives) VALUES ('Canada', 2021, 30), ('USA', 2021, 40), ('Mexico', 2021, 50);
How many sustainable tourism initiatives were implemented in North America in 2021?
SELECT SUM(num_initiatives) FROM sustainable_tourism_initiatives WHERE country IN ('Canada', 'USA', 'Mexico') AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite (id INT, name VARCHAR(255), manufacturer_id INT, launch_date DATE); INSERT INTO Satellite (id, name, manufacturer_id, launch_date) VALUES (1, 'GOES-R', 1, '2016-11-19'); INSERT INTO Satellite (id, name, manufacturer_id, launch_date) VALUES (2, 'Sentinel-2B', 2, '2017-03-07'); INSERT INTO Satellite (id, name, manufacturer_id, launch_date) VALUES (3, 'GSAT-19', 3, '2017-06-28'); CREATE TABLE Manufacturer (id INT, name VARCHAR(255), country VARCHAR(255), year_founded INT); INSERT INTO Manufacturer (id, name, country, year_founded) VALUES (1, 'Boeing', 'USA', 1916); INSERT INTO Manufacturer (id, name, country, year_founded) VALUES (2, 'Airbus', 'Europe', 1970); INSERT INTO Manufacturer (id, name, country, year_founded) VALUES (3, 'China National Space Administration', 'China', 1993);
What is the most recent launch date for satellites manufactured by China National Space Administration (CNSA)?
SELECT MAX(launch_date) FROM Satellite s JOIN Manufacturer m ON s.manufacturer_id = m.id WHERE m.name = 'China National Space Administration';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, revenue FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, revenue) VALUES (1, 'Hotel X', 'USA', 1000000), (2, 'Hotel Y', 'Canada', 800000), (3, 'Hotel Z', 'Mexico', 700000), (4, 'Hotel A', 'USA', 1200000), (5, 'Hotel B', 'Canada', 900000);
What is the average revenue generated by hotels in each country?
SELECT country, AVG(revenue) as avg_revenue FROM hotels GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (name TEXT, budget INTEGER, beds INTEGER, state TEXT); INSERT INTO hospitals (name, budget, beds, state) VALUES ('HospitalA', 500000, 75, 'New York'), ('HospitalB', 400000, 60, 'New York'), ('HospitalC', 600000, 50, 'New York'), ('HospitalD', 300000, 80, 'New York'), ('HospitalE', 700000, 100, 'New York');
What is the name of the hospital with the smallest budget in New York?
SELECT name FROM hospitals WHERE state = 'New York' ORDER BY budget ASC LIMIT 1;
gretelai_synthetic_text_to_sql