context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE waste_generation (country VARCHAR(50), year INT, waste_generation_grams INT);
|
Insert a new record for India's waste generation in 2020 with a value of 8000000 grams.
|
INSERT INTO waste_generation (country, year, waste_generation_grams) VALUES ('India', 2020, 8000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regulatory_Violations (Violation_ID INT, Asset_ID INT, Issuer_Country VARCHAR(50)); INSERT INTO Regulatory_Violations (Violation_ID, Asset_ID, Issuer_Country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 1, 'Brazil'), (4, 3, 'USA'), (5, 4, 'France');
|
What is the total number of regulatory violations by companies based in the Americas and Europe?
|
SELECT SUM(CASE WHEN Issuer_Country IN ('USA', 'Canada', 'Brazil', 'France') THEN 1 ELSE 0 END) AS Total_Violations FROM Regulatory_Violations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); CREATE TABLE Menu (MenuID int, ItemName varchar(50), Category varchar(50)); CREATE TABLE MenuSales (MenuID int, RestaurantID int, QuantitySold int, Revenue decimal(5,2), SaleDate date);
|
Update the quantity sold for MenuID 2001 to 150 in the MenuSales table for RestaurantID 1001 on November 15, 2021.
|
UPDATE MenuSales SET QuantitySold = 150 WHERE MenuID = 2001 AND RestaurantID = 1001 AND SaleDate = '2021-11-15';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asian_treatment_centers (id INT, name VARCHAR(255), patients INT, condition VARCHAR(255)); INSERT INTO asian_treatment_centers (id, name, patients, condition) VALUES (1, 'Lotus Mental Health', 200, 'Depression'); INSERT INTO asian_treatment_centers (id, name, patients, condition) VALUES (2, 'Rice Field Care', 250, 'Depression'); INSERT INTO asian_treatment_centers (id, name, patients, condition) VALUES (3, 'Mountain Peak Therapy', 300, 'Anxiety Disorder');
|
What is the total number of patients treated for depression in Asia?
|
SELECT SUM(patients) FROM asian_treatment_centers WHERE condition = 'Depression';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_divide (id INT, region VARCHAR, index_value DECIMAL);
|
Which regions have the highest and lowest digital divide index?
|
SELECT region, index_value FROM digital_divide ORDER BY index_value ASC LIMIT 1; SELECT region, index_value FROM digital_divide ORDER BY index_value DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wearable_metrics (member_id INT, heart_rate INT, workout_date DATE); INSERT INTO wearable_metrics (member_id, heart_rate, workout_date) VALUES (1, 120, '2022-01-01'), (1, 130, '2022-01-02'), (2, 140, '2022-01-01'), (2, 150, '2022-01-03'), (3, 160, '2022-01-02'), (3, 170, '2022-01-03'), (3, 180, '2022-01-04'), (4, 190, '2022-01-04');
|
What is the maximum heart rate for each member during a workout?
|
SELECT member_id, MAX(heart_rate) FROM wearable_metrics GROUP BY member_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE, join_date DATE); INSERT INTO members (member_id, name, gender, dob, join_date) VALUES (1, 'Jose Hernandez', 'Male', '1995-07-12', '2021-04-10'); INSERT INTO members (member_id, name, gender, dob, join_date) VALUES (2, 'Li Xiang', 'Female', '1987-03-04', '2022-01-15');
|
What is the average age of male members who joined in 2021?
|
SELECT AVG(DATEDIFF(CURDATE(), dob)/365) AS avg_age FROM members WHERE gender = 'Male' AND YEAR(join_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse_costs (warehouse_id INT, warehouse_location VARCHAR(255), cost DECIMAL(10,2), quarter INT, year INT); INSERT INTO warehouse_costs (warehouse_id, warehouse_location, cost, quarter, year) VALUES (1, 'NYC Warehouse', 2800.00, 1, 2023), (2, 'LA Warehouse', 3200.00, 1, 2023), (3, 'CHI Warehouse', 2200.00, 1, 2023);
|
Find the average warehouse management costs for the Chicago and New York warehouses in Q1 2023?
|
SELECT warehouse_location, AVG(cost) as avg_cost FROM warehouse_costs WHERE warehouse_location IN ('NYC Warehouse', 'CHI Warehouse') AND quarter = 1 AND year = 2023 GROUP BY warehouse_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE railways (id INT, name TEXT, country TEXT, build_year INT); INSERT INTO railways (id, name, country, build_year) VALUES (1, 'AU-QLD Railway', 'AU', 2005); INSERT INTO railways (id, name, country, build_year) VALUES (2, 'IN-MH Mumbai Suburban Railway', 'IN', 2010);
|
How many railway projects in total were constructed in Australia and India?
|
SELECT COUNT(*) FROM railways WHERE (country = 'AU' OR country = 'IN');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (id INT, name VARCHAR(255)); INSERT INTO Manufacturers (id, name) VALUES (1, 'Manufacturer A'), (2, 'Manufacturer B'); CREATE TABLE Production (id INT, manufacturer_id INT, quantity INT, production_date DATE); INSERT INTO Production (id, manufacturer_id, quantity, production_date) VALUES (1, 1, 500, '2020-01-01'), (2, 1, 700, '2020-02-01'), (3, 2, 300, '2020-01-15'), (4, 2, 400, '2020-03-10');
|
Calculate the total quantity of garments produced by each manufacturer in the year 2020
|
SELECT m.name, SUM(p.quantity) as total_quantity FROM Manufacturers m JOIN Production p ON m.id = p.manufacturer_id WHERE YEAR(p.production_date) = 2020 GROUP BY m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE underwater_volcanoes (id INT, name VARCHAR(255), region VARCHAR(50), depth INT); INSERT INTO underwater_volcanoes (id, name, region, depth) VALUES (1, 'Atlantic Volcano 1', 'Atlantic', 3500), (2, 'Atlantic Volcano 2', 'Atlantic', 4000);
|
What is the average depth of underwater volcanoes in the Atlantic region?
|
SELECT AVG(depth) FROM underwater_volcanoes WHERE region = 'Atlantic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, state VARCHAR(20), year INT, budget FLOAT, renewable BOOLEAN); INSERT INTO projects (id, state, year, budget, renewable) VALUES (1, 'California', 2016, 8000000, true), (2, 'California', 2018, 15000000, true), (3, 'Oregon', 2019, 12000000, false);
|
How many renewable energy projects were completed in the state of California in 2018, with a budget over $10 million?
|
SELECT COUNT(*) FROM projects WHERE state = 'California' AND year = 2018 AND budget > 10000000 AND renewable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE loans (bank_name VARCHAR(255), loan_amount DECIMAL(10,2), interest_rate DECIMAL(4,2), loan_date DATE, country VARCHAR(255));
|
What is the total amount of interest earned from loans in each country and year?
|
SELECT country, DATE_TRUNC('year', loan_date) AS year, SUM(loan_amount * interest_rate) FROM loans GROUP BY country, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (id INT, sector VARCHAR, production_capacity INT);
|
What is the maximum production capacity of factories in the organic materials sector?
|
SELECT MAX(production_capacity) FROM Factories WHERE sector = 'organic materials';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales(id INT, country VARCHAR, sale_date DATE, equipment VARCHAR, value FLOAT); INSERT INTO military_sales(id, country, sale_date, equipment, value) VALUES (1, 'US', '2020-07-01', 'Tanks', 20000000.00), (2, 'US', '2020-08-15', 'Aircraft', 60000000.00), (3, 'Canada', '2020-09-01', 'Missiles', 10000000.00), (4, 'Mexico', '2020-07-15', 'Tanks', 5000000.00), (5, 'Brazil', '2020-08-01', 'Aircraft', 30000000.00);
|
What is the rank of the United States in terms of military equipment sales value in Q3 2020, compared to other countries?
|
SELECT country, SUM(value) AS total_value, RANK() OVER (ORDER BY SUM(value) DESC) AS rank FROM military_sales WHERE sale_date >= '2020-07-01' AND sale_date < '2020-10-01' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_brazil (id INT, customer_id INT, product VARCHAR(20), price DECIMAL(5,2)); CREATE TABLE suppliers_br (id INT, product VARCHAR(20), country VARCHAR(20), sustainability_rating INT); INSERT INTO sales_brazil (id, customer_id, product, price) VALUES (1, 1, 'Shoes', 59.99); INSERT INTO sales_brazil (id, customer_id, product, price) VALUES (2, 2, 'Jacket', 99.99); INSERT INTO suppliers_br (id, product, country, sustainability_rating) VALUES (1, 'Shoes', 'Brazil', 82); INSERT INTO suppliers_br (id, product, country, sustainability_rating) VALUES (2, 'Pants', 'Brazil', 75);
|
Which products are sold to customers from Brazil and have a sustainability_rating greater than 80?
|
SELECT sales_brazil.product FROM sales_brazil JOIN suppliers_br ON sales_brazil.product = suppliers_br.product WHERE suppliers_br.country = 'Brazil' AND suppliers_br.sustainability_rating > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE corn_yield (country VARCHAR(255), year INT, yield FLOAT); INSERT INTO corn_yield (country, year, yield) VALUES ('United States', 2000, 98.2), ('United States', 2001, 99.1), ('United States', 2002, 101.3);
|
What is the average yield per hectare for corn crops in the United States?
|
SELECT AVG(yield) FROM corn_yield WHERE country = 'United States'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE polar_bears (id INT, name VARCHAR(20), species VARCHAR(20), weight INT, gender VARCHAR(10)); INSERT INTO polar_bears (id, name, species, weight, gender) VALUES (1, 'Ice', 'Polar Bear', 900, 'Male'); INSERT INTO polar_bears (id, name, species, weight, gender) VALUES (2, 'Snow', 'Polar Bear', 600, 'Female');
|
What is the minimum weight of female polar bears in the "polar_bears" table?
|
SELECT MIN(weight) FROM polar_bears WHERE gender = 'Female' AND species = 'Polar Bear';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels_port_visits_region (vessel_id INT, port_id INT, region TEXT); INSERT INTO vessels_port_visits_region VALUES (1, 1, 'Asia Pacific'), (1, 2, 'Americas'), (1, 3, 'Europe'), (2, 3, 'Europe'), (2, 4, 'Americas');
|
What are the names of vessels that have visited all three regions (Asia Pacific, Americas, and Europe)?
|
SELECT vessels_port_visits_region.vessel_id FROM vessels_port_visits_region WHERE vessels_port_visits_region.region IN ('Asia Pacific', 'Americas', 'Europe') GROUP BY vessels_port_visits_region.vessel_id HAVING COUNT(DISTINCT vessels_port_visits_region.region) = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, likes INT, created_at TIMESTAMP);
|
What was the maximum number of likes received by a post in each month of 2022?
|
SELECT MONTH(created_at) AS month, MAX(likes) AS max_likes FROM posts WHERE YEAR(created_at) = 2022 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_inventory (id INT PRIMARY KEY, chemical_name VARCHAR(100), safety_stock INT); INSERT INTO chemical_inventory (id, chemical_name, safety_stock) VALUES (1, 'Hydrochloric Acid', 75), (2, 'Sulfuric Acid', 60), (3, 'Sodium Hydroxide', 45);
|
Delete records in the chemical_inventory table where the chemical's safety_stock is below 50.
|
DELETE FROM chemical_inventory WHERE safety_stock < 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museum_visitors (id INT, visitor VARCHAR(50), gender VARCHAR(50)); INSERT INTO museum_visitors (id, visitor, gender) VALUES (1, 'Alice Johnson', 'Female'), (2, 'Bob Smith', 'Male'), (3, 'Charlie Brown', 'Male');
|
What is the distribution of museum visitors by gender?
|
SELECT gender, COUNT(*) as num_visitors FROM museum_visitors GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CityA_BusRoutes (route_id INT, avg_speed FLOAT, vehicle_type VARCHAR(20)); INSERT INTO CityA_BusRoutes (route_id, avg_speed, vehicle_type) VALUES (1, 45.6, 'Bus'), (2, 38.2, 'Bus'), (3, 48.7, 'Bus');
|
What is the average speed of public buses in CityA?
|
SELECT AVG(avg_speed) FROM CityA_BusRoutes WHERE vehicle_type = 'Bus';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Streaming (song VARCHAR(50), artist VARCHAR(50), genre VARCHAR(20), streams INT); INSERT INTO Streaming (song, artist, genre, streams) VALUES ('Heat Waves', 'Glass Animals', 'Indie Rock', 500), ('Drivers License', 'Olivia Rodrigo', 'Pop', 700), ('Good 4 U', 'Olivia Rodrigo', 'Pop', 600);
|
What was the total number of streams for a specific artist in a specific genre?
|
SELECT SUM(streams) FROM Streaming WHERE artist = 'Olivia Rodrigo' AND genre = 'Pop';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (id INT, donor_id INT, donor_religion VARCHAR(50)); INSERT INTO Donors (id, donor_id, donor_religion) VALUES (1, 1001, 'Islam'); INSERT INTO Donors (id, donor_id, donor_religion) VALUES (2, 1002, 'Christianity'); CREATE TABLE Donations (id INT, donor_id INT, donation_date DATE); INSERT INTO Donations (id, donor_id, donation_date) VALUES (1, 1001, '2022-04-03'); INSERT INTO Donations (id, donor_id, donation_date) VALUES (2, 1002, '2022-05-10');
|
What was the number of donations received in the month of Ramadan 1443 (April 2022) from Muslim donors?
|
SELECT COUNT(*) FROM Donations JOIN Donors ON Donations.donor_id = Donors.donor_id WHERE Donors.donor_religion = 'Islam' AND MONTH(Donation_date) = 4 AND YEAR(Donation_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Wastewater_Plant (id INT, name VARCHAR(30), region VARCHAR(20)); INSERT INTO Wastewater_Plant (id, name, region) VALUES (1, 'Plant1', 'RegionC'), (2, 'Plant2', 'RegionD'), (3, 'Plant3', 'RegionC');
|
List all wastewater treatment plants in 'RegionC'
|
SELECT * FROM Wastewater_Plant WHERE region = 'RegionC';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Incident (IID INT, Type VARCHAR(50), Timestamp TIMESTAMP); INSERT INTO Incident (IID, Type, Timestamp) VALUES (1, 'Phishing', '2022-01-01 10:00:00'), (2, 'Malware', '2022-01-02 15:30:00'), (3, 'Phishing', '2022-01-05 09:00:00');
|
What is the average time between cybersecurity incidents for each type of incident?
|
SELECT Type, AVG(DATEDIFF('ss', LAG(Timestamp) OVER (PARTITION BY Type ORDER BY Timestamp), Timestamp)) as AvgTimeBetween FROM Incident GROUP BY Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists AvCount(state CHAR(2), count INT); INSERT INTO AvCount(state, count) VALUES ('TX', 1200), ('TX', 1250), ('FL', 1500), ('FL', 1450);
|
Compare the number of autonomous vehicles in Texas and Florida.
|
SELECT COUNT(*) FROM AvCount WHERE state IN ('TX', 'FL') GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offset_programs (id INT, program_name TEXT, country TEXT, year INT, co2_emissions_reduction_tons INT);
|
What is the average CO2 emissions reduction (in tons) achieved by carbon offset programs in the United Kingdom in 2019?
|
SELECT AVG(carbon_offset_programs.co2_emissions_reduction_tons) FROM carbon_offset_programs WHERE carbon_offset_programs.country = 'United Kingdom' AND carbon_offset_programs.year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArtForms (id INT, art_form VARCHAR(50), country VARCHAR(50)); INSERT INTO TraditionalArtForms (id, art_form, country) VALUES (1, 'Ukiyo-e', 'Japan'); INSERT INTO TraditionalArtForms (id, art_form, country) VALUES (2, 'Madhubani', 'India');
|
What are the names of the traditional art forms in Asia?
|
SELECT TraditionalArtForms.art_form FROM TraditionalArtForms WHERE TraditionalArtForms.country IN ('Afghanistan', 'Bahrain', 'Bangladesh', 'Bhutan', 'Brunei', 'Cambodia', 'China', 'Cyprus', 'Egypt', 'India', 'Indonesia', 'Iran', 'Iraq', 'Israel', 'Japan', 'Jordan', 'Kazakhstan', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Lebanon', 'Malaysia', 'Maldives', 'Mongolia', 'Myanmar', 'Nepal', 'North Korea', 'Oman', 'Pakistan', 'Philippines', 'Qatar', 'Russia', 'Saudi Arabia', 'Singapore', 'South Korea', 'Sri Lanka', 'Syria', 'Tajikistan', 'Thailand', 'Turkey', 'Turkmenistan', 'United Arab Emirates', 'Uzbekistan', 'Vietnam', 'Yemen');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CaffeineExpress (id INT, importer VARCHAR(20), country VARCHAR(20), product VARCHAR(20), weight FLOAT); INSERT INTO CaffeineExpress (id, importer, country, product, weight) VALUES (1, 'Caffeine Express', 'Colombia', 'Coffee', 500.0), (2, 'Caffeine Express', 'Brazil', 'Coffee', 600.0);
|
What is the total weight of coffee imported by 'Caffeine Express' from Colombia?
|
SELECT SUM(weight) FROM CaffeineExpress WHERE importer = 'Caffeine Express' AND country = 'Colombia' AND product = 'Coffee';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drought_impact(state VARCHAR(20), drought_impact DECIMAL(5,2)); INSERT INTO drought_impact VALUES('Florida', 0.15);
|
What is the impact of drought in Florida?
|
SELECT drought_impact FROM drought_impact WHERE state = 'Florida';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_wellbeing (customer_id INT, score DECIMAL(3,2)); INSERT INTO financial_wellbeing (customer_id, score) VALUES (12345, 75.2), (98765, 82.6), (11121, 88.9), (22232, 93.1);
|
Find the financial wellbeing score for the customer with ID 22232?
|
SELECT score FROM financial_wellbeing WHERE customer_id = 22232;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodation (student_id INT, accommodation_type TEXT, accommodation_date DATE); INSERT INTO accommodation (student_id, accommodation_type, accommodation_date) VALUES (1, 'Extended Testing Time', '2022-05-01'), (2, 'Note Taker', '2022-04-15'), (3, 'Assistive Technology', '2022-03-01'), (4, 'Sign Language Interpreter', '2022-05-10');
|
Count the number of students who received accommodations in the last 3 months and group them by the accommodation type.
|
SELECT accommodation_type, COUNT(*) as count FROM accommodation WHERE accommodation_date >= DATEADD(month, -3, GETDATE()) GROUP BY accommodation_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE us_rj_cases(id INT, location VARCHAR(255), result VARCHAR(255));CREATE TABLE canada_rj_cases(id INT, location VARCHAR(255), result VARCHAR(255));
|
What is the total number of cases heard by restorative justice programs in the US and Canada, and how many of those cases resulted in a full or partial agreement?
|
SELECT SUM(total_cases), SUM(agreements) FROM (SELECT COUNT(*) AS total_cases, CASE WHEN result IN ('Full Agreement', 'Partial Agreement') THEN 1 ELSE 0 END AS agreements FROM us_rj_cases UNION ALL SELECT COUNT(*), CASE WHEN result IN ('Full Agreement', 'Partial Agreement') THEN 1 ELSE 0 END FROM canada_rj_cases) AS total;
|
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, 'Rare Element Resources', 'United States', 100, 2019, 'europium'), (2, 'Avalon Rare Metals', 'Canada', 150, 2019, 'europium'), (3, 'Greenland Minerals and Energy', 'Greenland', 50, 2019, 'europium');
|
What is the production quantity of europium in 2019 for mines that produced more europium than the average europium production quantity in 2019?
|
SELECT production_quantity FROM mines WHERE year = 2019 AND element = 'europium' AND production_quantity > (SELECT AVG(production_quantity) FROM mines WHERE year = 2019 AND element = 'europium');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE access_to_justice_programs (id INT, program_name TEXT, budget INT, region TEXT); INSERT INTO access_to_justice_programs (id, program_name, budget, region) VALUES (1, 'Legal Aid Chicago', 500000, 'Midwest'); INSERT INTO access_to_justice_programs (id, program_name, budget, region) VALUES (2, 'Legal Aid Minnesota', 750000, 'Midwest');
|
What is the average budget for access to justice programs in the Midwest region?
|
SELECT AVG(budget) FROM access_to_justice_programs WHERE region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_usage (date DATE, game_id INT, daus INT, PRIMARY KEY (date, game_id)); INSERT INTO daily_usage VALUES ('2022-01-01', 1, 1000), ('2022-01-01', 2, 2000), ('2022-01-01', 3, 3000), ('2022-01-02', 1, 1100), ('2022-01-02', 2, 2100), ('2022-01-02', 3, 3100); CREATE TABLE game_titles (game_id INT, title VARCHAR(50), PRIMARY KEY (game_id)); INSERT INTO game_titles VALUES (1, 'Fortnite'), (2, 'Minecraft'), (3, 'Among Us');
|
Identify the average number of daily active users (DAU) for the last 30 days in 'Fortnite'
|
SELECT AVG(du.daus) as avg_dau FROM daily_usage du INNER JOIN game_titles gt ON du.game_id = gt.game_id WHERE gt.title = 'Fortnite' AND du.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinics(id INT, name TEXT, location TEXT, specialty TEXT); INSERT INTO clinics(id, name, location, specialty) VALUES (1, 'Clinic A', 'Montana Remote', 'Family Medicine'), (2, 'Clinic B', 'Montana Remote', 'Internal Medicine'), (3, 'Clinic C', 'Montana Urban', 'Cardiology'), (4, 'Clinic D', 'Montana Urban', 'Dermatology');
|
What is the number of clinics and their respective specialties in remote areas of Montana?
|
SELECT COUNT(*) as clinic_count, specialty FROM clinics WHERE location LIKE '%Montana Remote%' GROUP BY specialty;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Languages (LanguageID INT PRIMARY KEY, Name VARCHAR(50), Status VARCHAR(20), Region VARCHAR(50)); INSERT INTO Languages (LanguageID, Name, Status, Region) VALUES (1, 'Quechua', 'Vulnerable', 'South America'), (2, 'Mapudungun', 'Endangered', 'South America');
|
How many endangered languages are there in South America?
|
SELECT COUNT(*) FROM Languages WHERE Status IN ('Vulnerable', 'Endangered') AND Region = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stablecoins (id INT, name VARCHAR(255), max_supply INT, min_supply INT); INSERT INTO stablecoins (id, name, max_supply, min_supply) VALUES (1, 'USDT', 100000000, 100000000), (2, 'USDC', 50000000, 50000000), (3, 'DAI', 20000000, 20000000);
|
What's the maximum and minimum supply of each stablecoin?
|
SELECT name, MAX(max_supply) AS max_supply, MIN(min_supply) AS min_supply FROM stablecoins;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CybersecurityIncidents (Year INT, Incident VARCHAR(255)); INSERT INTO CybersecurityIncidents (Year, Incident) VALUES (2019, 'Capital One Data Breach'), (2019, 'Equifax Data Breach'), (2022, 'SolarWinds Hack'), (2022, 'Colonial Pipeline Ransomware Attack');
|
What cybersecurity incidents were reported in 2019 and 2022?
|
SELECT Incident FROM CybersecurityIncidents WHERE Year IN (2019, 2022);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'India', 6000000), (2, 'StartupB', 'India', 5000000);
|
Update the country of a specific biotech startup
|
UPDATE biotech.startups SET location = 'USA' WHERE name = 'StartupA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT, DonationAmount DECIMAL(10,2), DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, ProgramID, DonationAmount, DonationDate) VALUES (1, 1, 1, 5000.00, '2021-03-30'), (2, 2, 2, 3500.00, '2021-02-15'), (3, 3, 3, 7000.00, '2021-01-01');
|
What is the maximum donation amount made in the last quarter?
|
SELECT MAX(DonationAmount) FROM Donations WHERE DonationDate >= DATEADD(quarter, -1, GETDATE())
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ddos_attacks (id INT, ip_address VARCHAR(15), region VARCHAR(100), attack_date DATE); INSERT INTO ddos_attacks (id, ip_address, region, attack_date) VALUES (1, '192.168.1.1', 'Middle East', '2022-01-01'), (2, '10.0.0.1', 'Europe', '2022-01-15'), (3, '192.168.1.1', 'Middle East', '2022-01-20');
|
Delete all records of DDoS attacks originating from the 'Middle East' region in the past week.
|
DELETE FROM ddos_attacks WHERE region = 'Middle East' AND attack_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name TEXT, nationality TEXT, points INT, season INT); INSERT INTO players (player_id, name, nationality, points, season) VALUES (1, 'Eve Thompson', 'Australia', 300, 2020), (2, 'Frank Lee', 'New Zealand', 400, 2020);
|
What are the total points scored by players from Australia and New Zealand in the 2020 season?
|
SELECT SUM(points) FROM players WHERE (nationality = 'Australia' OR nationality = 'New Zealand') AND season = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.properties (id SERIAL PRIMARY KEY, property_address VARCHAR(255), property_owner_id INTEGER, property_owner_email VARCHAR(255)); INSERT INTO public.properties (property_address, property_owner_id, property_owner_email) VALUES ('123 Main St', 1, 'john.smith@example.com'), ('456 Elm St', 2, 'jane.doe@example.com'), ('789 Oak St', 3, 'mary.major@example.com');
|
Update the property owner's email address in the properties table
|
WITH updated_email AS (UPDATE public.properties SET property_owner_email = 'mary.major@newemail.com' WHERE property_address = '789 Oak St' RETURNING *) INSERT INTO public.properties (property_address, property_owner_id, property_owner_email) SELECT property_address, property_owner_id, property_owner_email FROM updated_email;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), DiversityTraining BOOLEAN); INSERT INTO Employees (EmployeeID, Department, DiversityTraining) VALUES (1, 'IT', true), (2, 'IT', false), (3, 'HR', true), (4, 'Sales', true), (5, 'IT', true);
|
Count the number of employees who have completed diversity and inclusion training and are in the IT department.
|
SELECT COUNT(*) FROM Employees WHERE Department = 'IT' AND DiversityTraining = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trucks (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT); CREATE VIEW truck_list AS SELECT 1 AS id, 'Tesla' AS make, 'Semi' AS model, 2025 AS year UNION SELECT 2 AS id, 'Rivian' AS make, 'R1T' AS model, 2023 AS year;
|
Insert new records into the "trucks" table using data from the "truck_list" view
|
INSERT INTO trucks (id, make, model, year) SELECT * FROM truck_list;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing (id INT, garment_id INT, garment_material VARCHAR(50), co2_emissions DECIMAL(10, 2), process_date DATE);
|
What is the total CO2 emissions of all manufacturing processes for wool garments, in the 'manufacturing' table, during the last year?
|
SELECT SUM(co2_emissions) AS total_co2_emissions FROM manufacturing WHERE garment_material = 'wool' AND process_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE government_agencies (agency_id INT, agency_name VARCHAR(50), city VARCHAR(20), year INT, cases_open INT); INSERT INTO government_agencies (agency_id, agency_name, city, year, cases_open) VALUES (1, 'Chicago Parks Department', 'Chicago', 2019, 200);
|
List the names and number of open cases for each government agency in the city of Chicago for the year 2019
|
SELECT agency_name, cases_open FROM government_agencies WHERE city = 'Chicago' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), age INT, team_id INT);
|
What is the average age of athletes by team?
|
SELECT t.team_name, AVG(a.age) as avg_age FROM athletes a JOIN teams t ON a.team_id = t.team_id GROUP BY t.team_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trams (id INT, city VARCHAR(20), model VARCHAR(20)); INSERT INTO trams (id, city, model) VALUES (1, 'Melbourne', 'Citadis'), (2, 'Melbourne', 'Flexity'), (3, 'Sydney', 'Citadis');
|
How many trams are there in total in the city of Melbourne?
|
SELECT COUNT(*) FROM trams WHERE city = 'Melbourne';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), price FLOAT); INSERT INTO events (id, name, date, category, price) VALUES (1, 'Concert', '2022-06-01', 'Music', 50.00), (2, 'Play', '2022-07-01', 'Theater', 30.00), (3, 'Festival', '2022-08-01', 'Music', 75.00);
|
What is the average ticket price for events in the "Music" category?
|
SELECT AVG(price) FROM events WHERE category = 'Music';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT);
|
Create a table named 'mitigation_projects' to store climate mitigation project data
|
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, name TEXT, location TEXT); INSERT INTO Dispensaries (id, name, location) VALUES (1, 'Cloud Nine', 'Denver'), (2, 'Euphoria', 'Boulder'), (3, 'Heavenly Buds', 'Colorado Springs'); CREATE TABLE Sales (dispensary_id INT, sale_date DATE, quantity INT); INSERT INTO Sales (dispensary_id, sale_date, quantity) VALUES (1, '2022-01-01', 50), (1, '2022-01-02', 60), (2, '2022-01-01', 40), (2, '2022-01-02', 70), (3, '2022-01-01', 30), (3, '2022-01-02', 40);
|
What is the total quantity sold for each dispensary?
|
SELECT d.name, SUM(quantity) AS total_quantity_sold FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id GROUP BY d.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE whale_biomass (species TEXT, location TEXT, biomass INTEGER); INSERT INTO whale_biomass (species, location, biomass) VALUES ('Blue Whale', 'Atlantic', 300000), ('Humpback Whale', 'Atlantic', 80000), ('Blue Whale', 'Pacific', 250000), ('Humpback Whale', 'Pacific', 90000), ('Blue Whale', 'Indian', 200000), ('Humpback Whale', 'Indian', 70000);
|
What is the average biomass of humpback whales in all oceans?
|
SELECT AVG(biomass) FROM whale_biomass WHERE species = 'Humpback Whale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FINANCIAL_CAPABILITY_PROGRAMS (BANK_NAME VARCHAR(50), PROGRAM_NAME VARCHAR(50), START_DATE DATE); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank P', 'Program A', '2022-01-15'); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank Q', 'Program B', '2022-02-20'); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank P', 'Program C', '2022-03-05'); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank R', 'Program D', '2022-01-01');
|
List the banks with the highest number of financial capability programs offered in Q1 2022, in descending order?
|
SELECT BANK_NAME, COUNT(*) TOTAL_PROGRAMS FROM FINANCIAL_CAPABILITY_PROGRAMS WHERE START_DATE >= '2022-01-01' AND START_DATE < '2022-04-01' GROUP BY BANK_NAME ORDER BY TOTAL_PROGRAMS DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage_projects (year INT, region VARCHAR(255), num_projects INT); INSERT INTO energy_storage_projects (year, region, num_projects) VALUES (2021, 'South America', 10), (2021, 'Asia', 15), (2022, 'South America', 13);
|
How many energy storage projects were initiated in South America in 2021?
|
SELECT num_projects FROM energy_storage_projects WHERE year = 2021 AND region = 'South America'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Infrastructure_Projects (Project_ID INT, Project_Name VARCHAR(255), Project_Type VARCHAR(255), Cost FLOAT, Year INT, State VARCHAR(255));
|
What is the minimum cost of each type of infrastructure project in New York for the year 2021?
|
SELECT Project_Type, MIN(Cost) FROM Infrastructure_Projects WHERE Year = 2021 AND State = 'New York' GROUP BY Project_Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name TEXT, habitat_type TEXT, avg_depth FLOAT, water_temp FLOAT); INSERT INTO marine_species (id, species_name, habitat_type, avg_depth, water_temp) VALUES (1, 'Anglerfish', 'Trenches', 6000, 5);
|
find the average depth of all marine species habitats where water temperature is above 25 degrees Celsius, grouped by habitat type
|
SELECT habitat_type, AVG(avg_depth) FROM marine_species WHERE water_temp > 25 GROUP BY habitat_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name VARCHAR(50), last_name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO players (player_id, name, last_name, age, sport) VALUES (1, 'David', 'Johnson', 25, 'Soccer'), (2, 'Sophia', 'Williams', 28, 'Basketball'), (3, 'Mia', 'Garcia', 30, 'Rugby');
|
Find the average age of all players in the database.
|
SELECT AVG(age) FROM players;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE open_pedagogy_projects (id INT PRIMARY KEY, project_id INT, title VARCHAR(255), description TEXT, submission_date DATE);
|
List the total number of open pedagogy projects per month in 2021
|
SELECT DATE_FORMAT(submission_date, '%Y-%m') AS month, COUNT(*) AS total_projects FROM open_pedagogy_projects WHERE YEAR(submission_date) = 2021 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rovers (id INT, name VARCHAR(255), country VARCHAR(255), landing_date DATE, launch_date DATE); INSERT INTO rovers (id, name, country, landing_date, launch_date) VALUES (1, 'Spirit', 'USA', '2004-01-04', '2003-06-10'); INSERT INTO rovers (id, name, country, landing_date, launch_date) VALUES (2, 'Curiosity', 'USA', '2012-08-06', '2011-11-26'); INSERT INTO rovers (id, name, country, landing_date, launch_date) VALUES (4, 'Zhurong', 'China', '2021-05-15', '2020-07-23');
|
Which countries have launched rovers between 2000 and 2020?
|
SELECT DISTINCT country FROM rovers WHERE launch_date BETWEEN '2000-01-01' AND '2020-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_life (species TEXT, ocean TEXT); INSERT INTO marine_life (species, ocean) VALUES ('Blue Whale', 'Atlantic Ocean'), ('Clownfish', 'Pacific Ocean'), ('Dolphin', 'Atlantic Ocean');
|
Delete all records from marine_life that are not from the Atlantic Ocean.
|
DELETE FROM marine_life WHERE ocean != 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessel (ID INT, Name TEXT, AverageSpeed DECIMAL);
|
Insert a new record with ID 5, Name 'VesselE', and AverageSpeed 22.5 into the Vessel table.
|
INSERT INTO Vessel (ID, Name, AverageSpeed) VALUES (5, 'VesselE', 22.5);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA IF NOT EXISTS rural_development;CREATE TABLE IF NOT EXISTS rural_development.agriculture_projects (type VARCHAR(255), id INT);INSERT INTO rural_development.agriculture_projects (type, id) VALUES ('organic_farming', 1), ('permaculture', 2), ('livestock_rearing', 3), ('aquaculture', 4);
|
What are the unique types of agricultural projects and their corresponding IDs, excluding those related to 'livestock'?
|
SELECT DISTINCT type, id FROM rural_development.agriculture_projects WHERE type NOT LIKE '%livestock%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SafetyPatents (Id INT, Company VARCHAR(255), Patent VARCHAR(255), Date DATE); INSERT INTO SafetyPatents (Id, Company, Patent, Date) VALUES (1, 'Volvo', 'Autonomous Emergency Braking', '2018-01-01'), (2, 'Subaru', 'EyeSight Driver Assist Technology', '2019-01-01'), (3, 'Volvo', '360° Surround View Camera', '2017-01-01'), (4, 'Subaru', 'Rear Vehicle Detection', '2020-01-01');
|
What is the total number of safety testing patents filed by Volvo and Subaru?
|
SELECT COUNT(*) FROM SafetyPatents WHERE Company IN ('Volvo', 'Subaru') AND Patent LIKE '%Safety%'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country (id INT, name TEXT); CREATE TABLE resource (id INT, country_id INT, date DATE, quantity INT);
|
What is the total quantity of resources extracted in each country, in the last quarter?
|
SELECT country.name, SUM(resource.quantity) as total_quantity FROM country INNER JOIN resource ON country.id = resource.country_id WHERE resource.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY country.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ingredient_Sources (Source_ID INT PRIMARY KEY, Source_Name TEXT, Country_Name TEXT, Organic BOOLEAN); INSERT INTO Ingredient_Sources (Source_ID, Source_Name, Country_Name, Organic) VALUES (1, 'Farm A', 'United States', TRUE), (2, 'Farm B', 'Canada', TRUE), (3, 'Farm C', 'Mexico', FALSE), (4, 'Farm D', 'Brazil', TRUE), (5, 'Farm E', 'Argentina', FALSE), (6, 'Farm F', 'Australia', TRUE), (7, 'Farm G', 'New Zealand', TRUE), (8, 'Farm H', 'India', FALSE);
|
Which countries of origin have the most organic ingredients in total?
|
SELECT Country_Name, SUM(Organic) FROM Ingredient_Sources WHERE Organic = TRUE GROUP BY Country_Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_materials (project_id INT, state VARCHAR(2), material_cost DECIMAL(5,2)); INSERT INTO sustainable_materials (project_id, state, material_cost) VALUES (1, 'CA', 25000.00), (2, 'CA', 30000.50), (3, 'AZ', 22000.00);
|
What is the average cost of sustainable building materials for residential projects in California?
|
SELECT AVG(material_cost) FROM sustainable_materials WHERE state = 'CA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fairness_issues (id INT, model_id INT, severity INT, issue_description TEXT); INSERT INTO fairness_issues (id, model_id, severity, issue_description) VALUES (1, 1, 5, 'Imbalanced dataset'); CREATE TABLE models (id INT, name TEXT); INSERT INTO models (id, name) VALUES (1, 'ModelA'), (2, 'ModelB');
|
Insert a new fairness issue with ID 1, severity 5, and description 'Imbalanced dataset' for ModelA.
|
INSERT INTO fairness_issues (id, model_id, severity, issue_description) VALUES (1, (SELECT id FROM models WHERE name = 'ModelA'), 5, 'Imbalanced dataset');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (area_name VARCHAR(50), country_name VARCHAR(50)); CREATE TABLE countries (country_name VARCHAR(50), population INT);
|
What is the number of marine protected areas in each country in the 'marine_protected_areas' and 'countries' tables?"
|
SELECT mpa.country_name, COUNT(*) as num_areas FROM marine_protected_areas mpa JOIN countries c ON mpa.country_name = c.country_name GROUP BY mpa.country_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL(10,2), DonationDate DATE); INSERT INTO Donations VALUES (1, 1, 1000.00, '2021-01-01'), (2, 1, 2000.00, '2021-02-01'), (3, 2, 3000.00, '2021-03-01');
|
What is the maximum donation amount received in each month of 2021?
|
SELECT MONTH(DonationDate), MAX(Amount) FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY MONTH(DonationDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, name VARCHAR, description TEXT, cvss_score FLOAT);
|
Add a record of a new vulnerability in the 'vulnerabilities' table
|
INSERT INTO vulnerabilities (id, name, description, cvss_score) VALUES (1, 'SQLi Vulnerability', 'SQL injection vulnerability in login page', 7.5);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO organizations (id, sector, ESG_rating) VALUES (1, 'Healthcare', 7.5), (2, 'Technology', 8.2), (3, 'Healthcare', 8.0), (4, 'Renewable Energy', 9.0); CREATE TABLE investments (id INT, organization_id INT); INSERT INTO investments (id, organization_id) VALUES (1, 1), (2, 2), (3, 3), (4, 4);
|
Insert a new organization 'Education' with ESG rating 8.7 and ID 5.
|
INSERT INTO organizations (id, sector, ESG_rating) VALUES (5, 'Education', 8.7);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (state TEXT, project_type TEXT, year INT, permits_issued INT); INSERT INTO building_permits (state, project_type, year, permits_issued) VALUES ('California', 'commercial', 2018, 1200), ('California', 'commercial', 2019, 1500), ('California', 'commercial', 2020, 1700);
|
What is the total number of building permits issued for commercial projects in 'California' in the 'building_permits' table?
|
SELECT SUM(permits_issued) FROM building_permits WHERE state = 'California' AND project_type = 'commercial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Player (PlayerID int, PlayerName varchar(50), TeamID int); CREATE TABLE Goal (GoalID int, PlayerID int, Goals int, MatchDate date); INSERT INTO Player (PlayerID, PlayerName, TeamID) VALUES (1, 'Messi', 1), (2, 'Neymar', 1), (3, 'Mbappe', 1), (4, 'Ronaldo', 2); INSERT INTO Goal (GoalID, PlayerID, Goals, MatchDate) VALUES (1, 1, 5, '2022-04-01'), (2, 1, 3, '2022-04-05'), (3, 2, 2, '2022-04-01'), (4, 3, 4, '2022-04-05'), (5, 4, 6, '2022-04-01');
|
Who are the top 3 goal scorers for each team?
|
SELECT p.TeamID, p.PlayerName, SUM(g.Goals) AS TotalGoals, ROW_NUMBER() OVER (PARTITION BY p.TeamID ORDER BY SUM(g.Goals) DESC) AS Ranking FROM Player p JOIN Goal g ON p.PlayerID = g.PlayerID GROUP BY p.TeamID, p.PlayerName HAVING Ranking <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_consumption (customer_id INT, category VARCHAR(20), consumption FLOAT, month INT, year INT, city VARCHAR(20)); INSERT INTO water_consumption (customer_id, category, consumption, month, year, city) VALUES (1, 'residential', 15, 1, 2020, 'San Francisco'); INSERT INTO water_consumption (customer_id, category, consumption, month, year, city) VALUES (2, 'residential', 12, 1, 2020, 'San Francisco');
|
What is the average monthly water consumption per customer in the residential category for the year 2020 in the city of San Francisco?
|
SELECT AVG(consumption) FROM water_consumption WHERE category = 'residential' AND year = 2020 AND city = 'San Francisco' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AirportDelays (Airport VARCHAR(255), Delay INT, Year INT);
|
Identify the airports with a significant increase in flight delays compared to the previous year.
|
SELECT Airport, (Delay - LAG(Delay) OVER (PARTITION BY Airport ORDER BY Year)) / ABS(LAG(Delay) OVER (PARTITION BY Airport ORDER BY Year)) AS Increase FROM AirportDelays WHERE Year > 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_pollution (pollutant TEXT, year INTEGER, quantity REAL); INSERT INTO ocean_pollution (pollutant, year, quantity) VALUES ('plastic', 2008, 1200.5), ('oil', 2010, 800.2), ('plastic', 2012, 1500.3);
|
Delete all records from the 'ocean_pollution' table where the pollutant is 'plastic' and the year is before 2010.
|
DELETE FROM ocean_pollution WHERE pollutant = 'plastic' AND year < 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_scores (company_id INT, name TEXT, sustainability_score INT); INSERT INTO company_scores (company_id, name, sustainability_score) VALUES (1, 'Company A', 85), (2, 'Company B', 92), (3, 'Company C', 70), (4, 'Company D', 60), (5, 'Company E', 50);
|
Update the records related to companies that have a sustainability score below 70 with a sustainability score of 0.
|
UPDATE company_scores SET sustainability_score = 0 WHERE sustainability_score < 70;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SafetyRatings (Model VARCHAR(50), Rating INT); INSERT INTO SafetyRatings (Model, Rating) VALUES ('Tesla Model 3', 5), ('Chevrolet Bolt', 5), ('Nissan Leaf', 4);
|
Which electric vehicle models have the highest safety ratings?
|
SELECT Model, Rating FROM SafetyRatings ORDER BY Rating DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE juvenile_cases (case_id INT, case_type VARCHAR(255), year INT, diversion BOOLEAN); INSERT INTO juvenile_cases (case_id, case_type, year, diversion) VALUES (1, 'Vandalism', 2020, TRUE), (2, 'Trespassing', 2019, FALSE);
|
What is the percentage of cases resolved through diversion programs, by type and year, for juvenile offenders?
|
SELECT case_type, year, ROUND(SUM(CASE WHEN diversion THEN 1 ELSE 0 END) * 100.0 / COUNT(*), 2) as pct_diversion FROM juvenile_cases WHERE diversion IS NOT NULL GROUP BY case_type, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicleFuelEfficiency(Model VARCHAR(50), Make VARCHAR(50), MilesPerGallon FLOAT);
|
What is the average fuel efficiency of electric vehicles by model?
|
SELECT Model, AVG(MilesPerGallon) FROM ElectricVehicleFuelEfficiency GROUP BY Model;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipments (id INT, source VARCHAR(50), destination VARCHAR(50), weight FLOAT, ship_date DATE, delivery_date DATE); INSERT INTO Shipments (id, source, destination, weight, ship_date, delivery_date) VALUES (30, 'Australia', 'Germany', 400, '2022-11-01', '2022-11-10'); INSERT INTO Shipments (id, source, destination, weight, ship_date, delivery_date) VALUES (31, 'Australia', 'France', 300, '2022-11-15', '2022-11-25'); INSERT INTO Shipments (id, source, destination, weight, ship_date, delivery_date) VALUES (32, 'Australia', 'UK', 600, '2022-11-30', '2022-12-15');
|
Identify the top 3 destinations in Europe with the longest delivery times for shipments from Australia in November 2022
|
SELECT destination, AVG(DATEDIFF(day, ship_date, delivery_date)) as avg_delivery_time FROM Shipments WHERE source = 'Australia' AND ship_date BETWEEN '2022-11-01' AND '2022-11-30' GROUP BY destination ORDER BY avg_delivery_time DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offset_programs (id INT, country VARCHAR(255), project VARCHAR(255), carbon_offsets INT); INSERT INTO carbon_offset_programs (id, country, project, carbon_offsets) VALUES (1, 'Canada', 'Project A', 1000), (2, 'Canada', 'Project B', 1500), (3, 'Canada', 'Project C', 1200);
|
What is the average carbon offset per project in the carbon offset program in Canada?
|
SELECT AVG(carbon_offsets) FROM carbon_offset_programs WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crop (id INT, type VARCHAR(255), region VARCHAR(255), yield FLOAT); INSERT INTO crop (id, type, region, yield) VALUES (1, 'corn', 'Midwest', 150.3), (2, 'wheat', 'Great Plains', 120.5), (3, 'rice', 'Southeast', 180.7), (4, 'corn', 'Midwest', 165.2), (5, 'corn', 'Northeast', 145.8);
|
What is the average yield for each crop type in the 'agriculture' database, grouped by crop type and region?
|
SELECT type, region, AVG(yield) as avg_yield FROM crop GROUP BY type, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stops (stop_id INT, stop_name VARCHAR(255), stop_lat DECIMAL(9,6), stop_lon DECIMAL(9,6)); INSERT INTO stops (stop_id, stop_name, stop_lat, stop_lon) VALUES (100, 'Times Sq', 40.7570, -73.9857), (101, '34 St - Penn Station', 40.7484, -73.9857), (102, '23 St', 40.7410, -73.9857), (110, '9 Av', 40.7454, -73.9934);
|
Delete records in the stops table that have a stop_id greater than 120
|
DELETE FROM stops WHERE stop_id > 120;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MiningOperations (OperationID INT, OperationType VARCHAR(50), StartDate DATE, EndDate DATE, TotalProduction DECIMAL(10,2)); INSERT INTO MiningOperations (OperationID, OperationType, StartDate, EndDate, TotalProduction) VALUES (1, 'Underground', '2021-01-01', '2021-12-31', 1200.00), (2, 'Surface', '2021-01-01', '2021-12-31', 1500.00);
|
What was the total production of surface mining operations in 2021?
|
SELECT SUM(TotalProduction) FROM MiningOperations WHERE OperationType = 'Surface' AND YEAR(StartDate) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Delivery (id INT, item VARCHAR(50), delivered_date DATE, source_country VARCHAR(50), destination_country VARCHAR(50), delivery_time INT); INSERT INTO Delivery (id, item, delivered_date, source_country, destination_country, delivery_time) VALUES (1, 'Quux', '2022-01-02', 'China', 'Brazil', 10), (2, 'Corge', '2022-01-04', 'Brazil', 'China', 12);
|
What is the average delivery time for freight forwarded from China to Brazil?
|
SELECT AVG(delivery_time) FROM Delivery WHERE source_country = 'China' AND destination_country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT, name TEXT, location TEXT, type TEXT); INSERT INTO genetics.research_projects (id, name, location, type) VALUES (1, 'ProjectA', 'UK', 'Genetic'), (2, 'ProjectB', 'US', 'Genomic'), (3, 'ProjectC', 'DE', 'Genetic'), (4, 'ProjectD', 'FR', 'Genomic');
|
How many genetic research projects are being conducted in France and Germany combined?
|
SELECT COUNT(*) FROM genetics.research_projects WHERE (location = 'DE' OR location = 'FR') AND type = 'Genetic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (game_id INT, team1 VARCHAR(50), team2 VARCHAR(50), league VARCHAR(50), season INT, year INT, result VARCHAR(50)); INSERT INTO games (game_id, team1, team2, league, season, year, result) VALUES (5, 'Barcelona', 'Real Madrid', 'La Liga', 2010, 2010, 'Tie');
|
Find the number of ties in the 'La Liga' league since the year 2010.
|
SELECT COUNT(*) FROM games WHERE league = 'La Liga' AND year >= 2010 AND result = 'Tie';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (1, 'USA', 'Japan', '2022-01-01', 35), (2, 'USA', 'Japan', '2022-02-10', 28);
|
What is the average age of tourists visiting Japan from the USA in 2022?
|
SELECT AVG(age) FROM tourism_data WHERE country = 'USA' AND destination = 'Japan' AND YEAR(arrival_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project_timelines (city VARCHAR(20), days INT); INSERT INTO project_timelines (city, days) VALUES ('Denver', 160), ('Seattle', 180), ('Boston', 200); CREATE TABLE city (city_id INT, city VARCHAR(20));
|
Which cities have the longest average project timeline?
|
SELECT city, AVG(days) as avg_days FROM project_timelines JOIN city ON project_timelines.city = city.city GROUP BY city ORDER BY avg_days DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Classes (ClassID INT, ClassType VARCHAR(20), ClassDate DATE); INSERT INTO Classes (ClassID, ClassType, ClassDate) VALUES (1, 'Yoga', '2022-01-05'), (2, 'Pilates', '2022-01-07'), (3, 'Zumba', '2022-02-03');
|
What is the total number of 'Zumba' classes offered?
|
SELECT COUNT(ClassID) FROM Classes WHERE ClassType = 'Zumba';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_buses (bus_id INT, registration_date DATE, city TEXT, in_operation BOOLEAN);
|
How many autonomous buses are currently in operation in Tokyo?
|
SELECT COUNT(*) FROM autonomous_buses WHERE city = 'Tokyo' AND in_operation = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_mammals (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), population INT, conservation_status VARCHAR(255)); INSERT INTO marine_mammals (id, name, species, population, conservation_status) VALUES (1, 'Blue Whale', 'Balaenoptera musculus', 10000, 'Endangered');
|
Show the name, species, and conservation_status of all records in the table "marine_mammals"
|
SELECT name, species, conservation_status FROM marine_mammals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients(id INT, name TEXT, country TEXT, financial_capability_score INT);
|
What is the average financial capability score for clients in each country?
|
SELECT c.country, AVG(c.financial_capability_score) FROM clients c GROUP BY c.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id INT, name VARCHAR(255), region VARCHAR(255), temperature FLOAT, humidity FLOAT); INSERT INTO crops (id, name, region, temperature, humidity) VALUES (1, 'corn', 'south', 25.5, 60.0), (2, 'soybean', 'north', 20.0, 70.0);
|
Find the average temperature and humidity for all crops in the 'south' region for the month of July, 2021
|
SELECT AVG(temperature), AVG(humidity) FROM crops WHERE region = 'south' AND EXTRACT(MONTH FROM DATE '2021-07-01') = EXTRACT(MONTH FROM crops.timestamp);
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.