context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE hubble_history (id INT, event TEXT, launch_date DATE); INSERT INTO hubble_history (id, event, launch_date) VALUES (1, 'Launch', '1990-04-24'), (2, 'First Servicing Mission', '1993-12-02'), (3, 'Second Servicing Mission', '1997-02-11'), (4, 'Third Servicing Mission', '2002-03-01'), (5, 'Fourth Servicing Mis...
What is the earliest launch date in the Hubble Space Telescope's history?
SELECT MIN(launch_date) FROM hubble_history;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), element VARCHAR(255), amount INT, year INT); INSERT INTO production (country, element, amount, year) VALUES ('China', 'Praseodymium', 180000, 2020), ('China', 'Neodymium', 140000, 2020), ('Australia', 'Praseodymium', 5000, 2020), ('Australia', 'Neodymium', 3000, 2020), ('U...
What is the total production of Praseodymium and Neodymium in 2020, by country?
SELECT country, SUM(amount) as total_production FROM production WHERE (element = 'Praseodymium' OR element = 'Neodymium') AND year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE chinese_satellites (id INT, satellite_name VARCHAR(255), launch_date DATE, orbit_type VARCHAR(255)); INSERT INTO chinese_satellites (id, satellite_name, launch_date, orbit_type) VALUES (1, 'ChinaSat 1A', '1985-04-06', 'GEO');
Which Chinese satellites are in geostationary orbit (GEO)?
SELECT * FROM chinese_satellites WHERE orbit_type = 'GEO';
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteID INT, SiteName VARCHAR(100), Location VARCHAR(100), Visits INT); INSERT INTO HeritageSites (SiteID, SiteName, Location, Visits) VALUES (1, 'Great Pyramid of Giza', 'Egypt', 14000000);
What's the name and location of the top 3 most visited heritage sites in Africa?
SELECT SiteName, Location FROM (SELECT SiteName, Location, ROW_NUMBER() OVER (ORDER BY Visits DESC) as rn FROM HeritageSites WHERE Location LIKE 'Africa%') AS sub WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ConservationInitiatives (Initiative VARCHAR(50), Location VARCHAR(50), Cost INT); INSERT INTO ConservationInitiatives (Initiative, Location, Cost) VALUES ('Rainwater Harvesting', 'New York', 60000), ('Greywater Recycling', 'New York', 80000), ('Smart Irrigation Systems', 'New York', 110000), ('Toilet Rebat...
What is the total cost of water conservation initiatives in New York?
SELECT Initiative, SUM(Cost) as TotalCost FROM ConservationInitiatives WHERE Location = 'New York' GROUP BY Initiative;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(10), Name VARCHAR(20), Type VARCHAR(20), Max_Speed FLOAT); INSERT INTO Vessels (ID, Name, Type, Max_Speed) VALUES ('1', 'Vessel A', 'Cargo', 20.5);
What was the average speed of Vessel A?
SELECT AVG(Max_Speed) FROM Vessels WHERE Name = 'Vessel A';
gretelai_synthetic_text_to_sql
CREATE TABLE facilities_mn (id INT, name VARCHAR(50), state VARCHAR(50), capacity FLOAT); INSERT INTO facilities_mn (id, name, state, capacity) VALUES (1, 'Duluth Mill', 'Minnesota', 800000); CREATE TABLE facilities_wi (id INT, name VARCHAR(50), state VARCHAR(50), capacity FLOAT); INSERT INTO facilities_wi (id, name, s...
Identify timber production facilities in Minnesota and Wisconsin with a production capacity above 700000 cubic meters.
SELECT f.name, f.capacity FROM facilities_mn f WHERE f.capacity > 700000 UNION ALL SELECT f.name, f.capacity FROM facilities_wi f WHERE f.capacity > 700000;
gretelai_synthetic_text_to_sql
CREATE TABLE TreeSpecies (id INT, name VARCHAR(255)); INSERT INTO TreeSpecies (id, name) VALUES (1, 'Pine'), (2, 'Oak'), (3, 'Maple'), (4, 'Birch'); CREATE TABLE Planting (id INT, tree_species_id INT, year INT); INSERT INTO Planting (id, tree_species_id, year) VALUES (1, 1, 2000), (2, 1, 2001), (3, 2, 2000), (4, 2, 200...
How many planting records are there for each tree species?
SELECT ts.name, COUNT(p.id) AS planting_records FROM TreeSpecies ts JOIN Planting p ON ts.id = p.tree_species_id GROUP BY ts.id;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, company_name VARCHAR(255), location VARCHAR(255), focus VARCHAR(255), funding FLOAT); CREATE TABLE founders (id INT, companies_id INT, founder_name VARCHAR(255));
Who are the founders of technology companies that focus on ethical AI and have received more than $10 million in funding?
SELECT founders.founder_name, companies.company_name FROM companies INNER JOIN founders ON companies.id = founders.companies_id WHERE companies.focus LIKE '%ethical AI%' AND companies.funding > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_habitats (habitat_name TEXT, species TEXT, biomass FLOAT);
What is the number of species in each marine habitat and their total biomass?
SELECT marine_habitats.habitat_name, COUNT(DISTINCT marine_habitats.species) AS num_species, SUM(marine_habitats.biomass) AS total_biomass FROM marine_habitats GROUP BY marine_habitats.habitat_name;
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArt (ArtID int, ArtName varchar(50), ArtType varchar(50)); INSERT INTO TraditionalArt (ArtID, ArtName, ArtType) VALUES (1, 'Pottery', 'Ceramics'), (2, 'Woven Rug', 'Textiles'), (3, 'Calligraphy', 'Writing'), (4, 'Dance Performance', 'Performance');
How many unique traditional art forms are represented in the TraditionalArt table?
SELECT COUNT(DISTINCT ArtType) FROM TraditionalArt;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (id INT, name TEXT, location TEXT, num_workers INT, avg_age FLOAT);
What is the average age of healthcare workers in the 'rural_clinics' table?
SELECT AVG(avg_age) FROM rural_clinics;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name TEXT, category TEXT, yield FLOAT); INSERT INTO strains (id, name, category, yield) VALUES (1, 'Purple Kush', 'Indica', 0.5), (2, 'Northern Lights', 'Indica', 0.6), (3, 'Granddaddy Purple', 'Indica', 0.7), (4, 'Sour Diesel', 'Sativa', 0.6), (5, 'Blue Dream', 'Hybrid', 0.7), (6, 'Green ...
What is the average yield for strains in each category?
SELECT category, AVG(yield) FROM strains GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, garmentID INT, quantity INT, saleDate DATE, isSustainable BOOLEAN); INSERT INTO Sales (id, garmentID, quantity, saleDate, isSustainable) VALUES (1, 101, 7, '2021-01-10', true), (2, 102, 4, '2021-02-15', false), (3, 103, 6, '2021-03-20', true), (4, 104, 5, '2021-04-12', true); CREATE TABLE Ga...
What is the total revenue generated from sustainable fashion sales in Europe?
SELECT SUM(quantity * price) FROM Sales INNER JOIN Garments ON Sales.garmentID = Garments.garmentID WHERE isSustainable = true AND Garments.country IN ('France', 'Germany', 'Spain', 'Italy');
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name TEXT, department TEXT, advisor TEXT); INSERT INTO graduate_students (id, name, department, advisor) VALUES (1, 'Alice', 'CS', 'Prof. Smith'), (2, 'Bob', 'Physics', 'Prof. Johnson'), (3, 'Charlie', 'Math', 'Prof. Brown');
Insert new graduate student records into the graduate_students table
INSERT INTO graduate_students (id, name, department, advisor) VALUES (4, 'David', 'CS', 'Prof. Jones'), (5, 'Eve', 'Physics', 'Prof. Lee'), (6, 'Frank', 'Math', 'Prof. Davis');
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty (FacultyID INT, Name VARCHAR(50), ResearchInterest VARCHAR(50)); INSERT INTO Faculty VALUES (1, 'John Doe', 'Machine Learning'); CREATE TABLE Publications (PublicationID INT, Title VARCHAR(50), FacultyID INT, PublishDate DATE); INSERT INTO Publications VALUES (1, 'Paper 1', 1, '2021-01-01'); INSERT...
What are the names and research interests of all faculty members who have not published any papers in the past year?
SELECT Faculty.Name, Faculty.ResearchInterest FROM Faculty LEFT JOIN Publications ON Faculty.FacultyID = Publications.FacultyID WHERE Publications.PublicationID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_reduction (id INT, source TEXT, reduction FLOAT); INSERT INTO co2_reduction (id, source, reduction) VALUES (1, 'solar', 12.5), (2, 'wind', 18.6), (3, 'hydro', 9.8);
What is the average CO2 emission reduction for wind power?
SELECT AVG(reduction) FROM co2_reduction WHERE source = 'wind';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityDevelopment (ProjectID INT, Country VARCHAR(100), InitiativeType VARCHAR(100), Budget DECIMAL(10,2)); INSERT INTO CommunityDevelopment VALUES (1,'India','Education',50000),(2,'Nepal','Healthcare',75000),(3,'Bangladesh','Agriculture',100000),(4,'Pakistan','Energy',125000),(5,'SriLanka','Transportat...
What is the average budget for community development initiatives, partitioned by country and initiative type?
SELECT Country, InitiativeType, AVG(Budget) AS AvgBudget FROM CommunityDevelopment GROUP BY Country, InitiativeType;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600);
What is the minimum and maximum number of beds in hospitals by state?
SELECT state, MIN(beds) as min_beds, MAX(beds) as max_beds FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE probono_billing (attorney_id INT, client_id INT, hours FLOAT); INSERT INTO probono_billing (attorney_id, client_id, hours) VALUES (4, 104, 15), (5, 105, 20), (6, 106, 18);
List the total pro-bono hours for each attorney in the 'probono_billing' table?
SELECT attorney_id, SUM(hours) FROM probono_billing GROUP BY attorney_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Candidates (CandidateID INT, Gender VARCHAR(10), Position VARCHAR(20)); INSERT INTO Candidates (CandidateID, Gender, Position) VALUES (1, 'Female', 'Marketing'), (2, 'Male', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Female', 'Marketing'), (5, 'Male', 'IT');
How many female candidates were interviewed for the marketing position?
SELECT COUNT(*) FROM Candidates WHERE Gender = 'Female' AND Position = 'Marketing';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes( process_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), labor_practice_score INT, circular_supply_chain BOOLEAN); INSERT INTO manufacturing_processes (process_id, name, location, labor_practice_score, circular_supply_chain) VALUES (1, 'Process 1', 'Location 1', 80, FA...
Insert data into 'manufacturing_processes' table with 'circular_supply_chain' value
INSERT INTO manufacturing_processes (process_id, name, location, labor_practice_score, circular_supply_chain) VALUES (6, 'Process 6', 'Location 6', 90, TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_fuel_consumption (vessel_name TEXT, fuel_consumption_litres INTEGER, journey_id INTEGER); INSERT INTO vessel_fuel_consumption (vessel_name, fuel_consumption_litres, journey_id) VALUES ('VesselG', 200, 1001); INSERT INTO vessel_fuel_consumption (vessel_name, fuel_consumption_litres, journey_id) VALUE...
What is the average fuel consumption per journey for 'VesselG'?
SELECT AVG(fuel_consumption_litres) FROM vessel_fuel_consumption WHERE vessel_name = 'VesselG';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO wind_farms (id, name, country, capacity) VALUES (1, 'Robert Chase Wind Farm', 'US', 150.1);
Find the total capacity (MW) of Wind Farms in the US
SELECT SUM(capacity) FROM wind_farms WHERE country = 'US' AND name = 'Robert Chase Wind Farm';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, revenue) VALUES (1, 'Asian Fusion', 'New York', 50000.00), (2, 'Bella Italia', 'Los Angeles', 60000.00), (3, 'Sushi House', 'New York', 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 800...
Identify restaurants that have a higher revenue than the average revenue for their city.
SELECT name, city, revenue FROM Restaurants r WHERE revenue > (SELECT AVG(revenue) FROM Restaurants WHERE city = r.city);
gretelai_synthetic_text_to_sql
CREATE TABLE EventAttendance (event_name VARCHAR(255), attendee_age INT, attendee_gender VARCHAR(50)); INSERT INTO EventAttendance (event_name, attendee_age, attendee_gender) VALUES ('Jazz Night', 40, 'Male'), ('Jazz Night', 45, 'Female'), ('Classical Music Concert', 50, 'Male'), ('Classical Music Concert', 55, 'Female...
What is the difference in average attendee age between 'Jazz Night' and 'Classical Music Concert'?
SELECT AVG(attendee_age) - (SELECT AVG(attendee_age) FROM EventAttendance WHERE event_name = 'Classical Music Concert') AS age_difference FROM EventAttendance WHERE event_name = 'Jazz Night';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT);
Insert new company with id 5, sector 'healthcare', ESG 78.
INSERT INTO companies (id, sector, ESG_rating) VALUES (5, 'healthcare', 78);
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', 'Pacific', 200000), ('Gray Whale', 'Pacific', 150000), ('Humpback Whale', 'Pacific', 300000);
What is the total biomass of all whale species in the Pacific, excluding gray whales?
SELECT SUM(biomass) FROM whale_biomass WHERE species != 'Gray Whale' AND location = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), age INT, region VARCHAR(20)); INSERT INTO customers (customer_id, name, age, region) VALUES (1, 'John Doe', 35, 'Southeast'), (2, 'Jane Smith', 45, 'Northeast'), (3, 'Mike Johnson', 50, 'Southeast'), (4, 'Alice Davis', 25, 'Midwest');
How many customers are there in each region?
SELECT region, COUNT(*) FROM customers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperatures (ocean VARCHAR(255), location VARCHAR(255), temperature FLOAT); INSERT INTO ocean_temperatures (ocean, location, temperature) VALUES ('Antarctic', 'Location 1', -2.0), ('Antarctic', 'Location 2', -1.9), ('Atlantic', 'Location 3', 20.0), ('Pacific', 'Location 4', 25.0);
What is the minimum temperature recorded in the Antarctic Ocean?
SELECT MIN(temperature) FROM ocean_temperatures WHERE ocean = 'Antarctic';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, department VARCHAR(50), amount DECIMAL(10,2), date DATE); INSERT INTO grants (id, department, amount, date) VALUES (1, 'Mathematics', 50000.00, '2020-03-15'), (2, 'Physics', 100000.00, '2019-06-20'), (3, 'Mathematics', 75000.00, '2020-11-05');
How many research grants were awarded to the Mathematics department in the year 2020?
SELECT COUNT(*) FROM grants WHERE department = 'Mathematics' AND YEAR(date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE AnimalPopulation (AnimalID int, AnimalName varchar(50), Population int); INSERT INTO AnimalPopulation (AnimalID, AnimalName, Population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 500), (3, 'Giraffe', 1200);
What is the total number of animals in the 'AnimalPopulation' table for each 'AnimalName' with a Population greater than 1000?
SELECT AnimalName, SUM(Population) FROM AnimalPopulation WHERE Population > 1000 GROUP BY AnimalName;
gretelai_synthetic_text_to_sql
CREATE TABLE extraction (mine_id INT, extraction_date DATE, mineral TEXT, quantity INT); INSERT INTO extraction (mine_id, extraction_date, mineral, quantity) VALUES (1, '2021-01-01', 'Gold', 150), (1, '2021-01-01', 'Silver', 200), (2, '2021-01-02', 'Gold', 220), (2, '2021-01-02', 'Silver', 250), (3, '2021-01-03', 'Gold...
What is the total amount of minerals extracted per mine?
SELECT mine_id, SUM(quantity) FROM extraction GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_tourism_destinations (id INT, name VARCHAR, country VARCHAR, visits INT); INSERT INTO eco_tourism_destinations (id, name, country, visits) VALUES (1, 'Serengeti National Park', 'Tanzania', 15000); CREATE TABLE eco_tourists (id INT, destination VARCHAR); INSERT INTO eco_tourists (id, destination) VALUES...
What is the most visited destination in Africa for eco-tourism?
SELECT destination FROM eco_tourism_destinations e JOIN eco_tourists t ON e.name = t.destination GROUP BY destination ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE packages (id INT, shipment_id INT, weight FLOAT); CREATE TABLE shipments (id INT, origin_country TEXT);
Show the total weight of goods and the number of packages shipped from each country, grouped by country.
SELECT s.origin_country, SUM(p.weight) as total_weight, COUNT(*) as total_packages FROM packages p JOIN shipments s ON p.shipment_id = s.id GROUP BY s.origin_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Operations.Pollution_Initiatives ( id INT, initiative_name VARCHAR(255), budget INT, budget_category VARCHAR(255) );
Find the number of marine pollution initiatives in the 'Operations' schema's 'Pollution_Initiatives' table, grouped by their corresponding budget categories
SELECT budget_category, COUNT(*) FROM Operations.Pollution_Initiatives GROUP BY budget_category;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, signup_date DATE, country VARCHAR(50));CREATE TABLE posts (post_id INT, user_id INT, likes INT);
What is the average number of likes on posts created by users from the United States, who have signed up for a social media platform in 2021?
SELECT AVG(posts.likes) FROM users INNER JOIN posts ON users.user_id = posts.user_id WHERE users.country = 'United States' AND YEAR(users.signup_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(255), incident_count INT, region VARCHAR(255), occurrence_date DATE); INSERT INTO security_incidents (id, incident_type, incident_count, region, occurrence_date) VALUES (1, 'Data Breach', 25, 'APAC', '2020-01-15');
How many security incidents were there per month in the APAC region in 2020?
SELECT EXTRACT(MONTH FROM occurrence_date) AS month, SUM(incident_count) AS total_incidents FROM security_incidents WHERE region = 'APAC' AND occurrence_date >= '2020-01-01' AND occurrence_date < '2021-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE rigs (rig_id INT, rig_name VARCHAR(255), status VARCHAR(255), region VARCHAR(255)); INSERT INTO rigs (rig_id, rig_name, status, region) VALUES (1, 'Rig1', 'active', 'Alaska'), (2, 'Rig2', 'inactive', 'Alaska'), (3, 'Rig3', 'active', 'North Sea');
How many inactive rigs are there in the 'North Sea' region?
SELECT COUNT(*) FROM rigs WHERE status = 'inactive' AND region = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature (temperature REAL, depth INTEGER); INSERT INTO ocean_temperature (temperature, depth) VALUES (-1.5, 100), (0.2, 200), (-2.1, 300);
What is the average temperature of the ocean for each depth in the 'ocean_temperature' table?
SELECT depth, AVG(temperature) FROM ocean_temperature GROUP BY depth;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(255), price DECIMAL(5,2));
Delete records of menu items with a price greater than $20
DELETE FROM menu_items WHERE price > 20.00;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name TEXT, location TEXT, ethical BOOLEAN); INSERT INTO factories (id, name, location, ethical) VALUES (1, 'Factory A', 'Country A', true), (2, 'Factory B', 'Country B', false); CREATE TABLE products (id INT, name TEXT, factory_id INT, delivery_time INT); INSERT INTO products (id, name, ...
What is the average delivery time for products sourced from ethical factories?
SELECT AVG(delivery_time) FROM products INNER JOIN factories ON products.factory_id = factories.id WHERE factories.ethical = true;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT);
Create a table named 'habitats'
CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT);
gretelai_synthetic_text_to_sql
CREATE TABLE safety_records (vessel_id INT, incident_date DATE, incident_type VARCHAR(255));
Display safety incidents by vessel and month in the 'safety_records' table
SELECT vessel_id, DATE_FORMAT(incident_date, '%Y-%m') AS month, incident_type, COUNT(*) FROM safety_records GROUP BY vessel_id, month, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS events (id INT, name VARCHAR(255), type VARCHAR(255), year INT, visitors INT); INSERT INTO events (id, name, type, year, visitors) VALUES (1, 'EventA', 'Dance', 2022, 600), (2, 'EventB', 'Dance', 2022, 700), (3, 'EventC', 'Dance', 2022, 800);
What is the maximum number of visitors for dance events in 2022?
SELECT MAX(visitors) FROM events WHERE type = 'Dance' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, financial_wellbeing_score INT, socially_responsible_loan DECIMAL(10, 2)); INSERT INTO clients (client_id, financial_wellbeing_score, socially_responsible_loan) VALUES (1, 85, 12000.00), (2, 70, 9000.00), (3, 90, 15000.00);
List all clients who have a financial wellbeing score above 80 and a socially responsible loan amount greater than 10000.
SELECT client_id FROM clients WHERE financial_wellbeing_score > 80 AND socially_responsible_loan > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE Classes (ClassID int, ClassType varchar(10), ClassDuration int, ClassDate date); INSERT INTO Classes (ClassID, ClassType, ClassDuration, ClassDate) VALUES (1, 'Pilates', 60, '2021-04-01'), (2, 'Yoga', 45, '2021-04-05');
What is the total duration of Pilates classes offered in the entire month of April 2021?
SELECT SUM(ClassDuration) FROM Classes WHERE ClassType = 'Pilates' AND MONTH(ClassDate) = 4 AND YEAR(ClassDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE national_security_incidents (id INT, incident_date DATE, category VARCHAR(255), region VARCHAR(255)); INSERT INTO national_security_incidents (id, incident_date, category, region) VALUES (1, '2018-01-01', 'Terrorism', 'Europe'), (2, '2019-05-15', 'Cyberattack', 'Europe');
Identify the number of national security incidents and their categories in Europe over the last 3 years.
SELECT COUNT(*), category FROM national_security_incidents WHERE region = 'Europe' AND incident_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities_by_type (id INT, asset_type VARCHAR(50), vuln_count INT); INSERT INTO vulnerabilities_by_type (id, asset_type, vuln_count) VALUES (1, 'network', 200), (2, 'server', 150), (3, 'workstation', 100);
What is the total number of vulnerabilities found for each asset type?
SELECT asset_type, SUM(vuln_count) as total_vulnerabilities FROM vulnerabilities_by_type GROUP BY asset_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Astrophysics_Observations (id INT, observation VARCHAR(100), researcher VARCHAR(100), observation_region VARCHAR(100), observation_date DATE); INSERT INTO Astrophysics_Observations (id, observation, researcher, observation_region, observation_date) VALUES (1, 'Gamma Ray Burst', 'Dr. J. Doe', 'Arctic', '202...
What are the unique astrophysics observations made in the Antarctic region?
SELECT DISTINCT observation FROM Astrophysics_Observations WHERE observation_region = 'Antarctic';
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (booking_id INT, tour_type TEXT, booking_date DATE); INSERT INTO bookings (booking_id, tour_type, booking_date) VALUES (1, 'Virtual', '2023-03-01');
How many virtual tours were booked in the last month?
SELECT COUNT(booking_id) FROM bookings WHERE tour_type = 'Virtual' AND booking_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE CoOwnershipProperties (id INT PRIMARY KEY, city VARCHAR(50), state VARCHAR(50), property_type VARCHAR(50));
Drop the CoOwnershipProperties table
DROP TABLE CoOwnershipProperties;
gretelai_synthetic_text_to_sql
CREATE TABLE usage_data (subscriber_id INT, region VARCHAR(20), country VARCHAR(20), usage_gb DECIMAL(10,2)); INSERT INTO usage_data (subscriber_id, region, country, usage_gb) VALUES (1, 'West', NULL, 10.5), (2, NULL, 'Canada', 7.3), (5, 'South', NULL, 12.6), (6, NULL, 'Mexico', 9.8);
What is the combined data usage in GB for the 'South' region and 'Mexico' country for the last quarter?
SELECT SUM(usage_gb) FROM usage_data WHERE region = 'South' OR country = 'Mexico' AND usage_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE DancePerformances (eventID INT, visitorAge INT, visitDate DATE); INSERT INTO DancePerformances (eventID, visitorAge, visitDate) VALUES (1, 32, '2022-02-05'), (2, 45, '2022-03-10'), (3, 30, '2022-01-20');
What is the minimum age of visitors who attended dance performances in the last month?
SELECT MIN(visitorAge) FROM DancePerformances WHERE visitDate >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE well_gas_production (id INT, location VARCHAR(50), daily_production FLOAT); INSERT INTO well_gas_production (id, location, daily_production) VALUES (1, 'Timor Sea', 20000), (2, 'Timor Sea', 25000);
Maximum daily gas production (mmcf) for wells in the Timor Sea.
SELECT MAX(daily_production) FROM well_gas_production WHERE location = 'Timor Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, Type VARCHAR(50), Quantity INT); INSERT INTO Artifacts (ArtifactID, Type, Quantity) VALUES (1, 'Pottery', 120); INSERT INTO Artifacts (ArtifactID, Type, Quantity) VALUES (2, 'Tools', 65); INSERT INTO Artifacts (ArtifactID, Type, Quantity) VALUES (3, 'Beads', 80);
How many artifacts of each type have been found in total?
SELECT A.Type, SUM(A.Quantity) FROM Artifacts A GROUP BY A.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_gender TEXT); INSERT INTO company (id, name, industry, founder_gender) VALUES (1, 'HealCo', 'Healthcare', 'Female'); CREATE TABLE investment_round (id INT, company_id INT, amount_raised FLOAT); INSERT INTO investment_round (id, company_id, amount_raised) V...
What is the total funding received by female founders in the healthcare sector?
SELECT SUM(ir.amount_raised) FROM company c JOIN investment_round ir ON c.id = ir.company_id WHERE c.founder_gender = 'Female' AND c.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (MemberID INT, Age INT, WorkoutType VARCHAR(20), Duration INT); INSERT INTO Workouts (MemberID, Age, WorkoutType, Duration) VALUES (1, 35, 'Yoga', 60), (2, 45, 'Pilates', 45), (3, 28, 'Yoga', 75);
What is the total duration of 'Yoga' workouts in minutes for members aged 30-40?
SELECT SUM(Duration) FROM Workouts WHERE Age BETWEEN 30 AND 40 AND WorkoutType = 'Yoga';
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), PRIMARY KEY(id)); INSERT INTO heritage_sites (id, name, location, type) VALUES (1, 'Sydney Opera House', 'Australia', 'Modern'), (2, 'Uluru', 'Australia', 'Ancient'), (3, 'Port Arthur', 'Australia', 'Historic'); CREATE TABLE ...
What is the average preservation cost for each heritage site in Australia, considering the sites with the highest preservation costs?
SELECT hs.name, hs.location, hs.type, AVG(pr.cost) AS avg_cost FROM heritage_sites hs JOIN preservation_costs pr ON hs.id = pr.heritage_site_id WHERE hs.location = 'Australia' GROUP BY hs.name, hs.location, hs.type ORDER BY avg_cost DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (id INT, state VARCHAR(2), clinic_name VARCHAR(50), num_beds INT); INSERT INTO rural_clinics (id, state, clinic_name, num_beds) VALUES (1, 'AZ', 'Sedona Medical Center', 15); CREATE TABLE states (state_abbr VARCHAR(2), state_name VARCHAR(20)); INSERT INTO states (state_abbr, state_name) VALUE...
What is the total number of rural clinics in each state, and the average number of clinic beds?
SELECT r.state, COUNT(r.id) AS num_clinics, AVG(r.num_beds) AS avg_beds FROM rural_clinics r JOIN states s ON r.state = s.state_abbr GROUP BY r.state;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (preference_id INT, consumer_id INT, product_id INT, shade VARCHAR(255)); INSERT INTO consumer_preferences (preference_id, consumer_id, product_id, shade) VALUES (1, 1, 1, 'Light Beige'), (2, 2, 1, 'Medium Beige'), (3, 3, 2, 'Dark Beige');
What is the most preferred foundation shade among consumers?
SELECT shade, COUNT(*) AS preference_count FROM consumer_preferences WHERE product_id = 1 GROUP BY shade ORDER BY preference_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, satellite_name VARCHAR(50), agency VARCHAR(50)); INSERT INTO satellites VALUES (1, 'Jason-3', 'NASA'), (2, 'Sentinel-1A', 'ESA'), (3, 'MetOp-C', 'EUMETSAT'), (4, 'KOMPSAT-5', 'KARI');
Show the number of satellites that each space agency has launched
SELECT agency, COUNT(*) as num_satellites FROM satellites GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE national_security_events_dates (id INT, event VARCHAR, impact VARCHAR, event_date DATE); INSERT INTO national_security_events_dates (id, event, impact, event_date) VALUES (1, 'Terrorist Attack', 'High', '2022-01-01'), (2, 'Cyber Espionage', 'Medium', '2022-02-15'), (3, 'Nuclear Missile Test', 'Low', '2022-...
Identify the national security events with their dates and calculate the average impact level for each month.
SELECT DATEPART(YEAR, event_date) as year, DATEPART(MONTH, event_date) as month, AVG(CASE WHEN impact = 'High' THEN 1.0 ELSE 0.0 END) as avg_high, AVG(CASE WHEN impact = 'Medium' THEN 1.0 ELSE 0.0 END) as avg_medium, AVG(CASE WHEN impact = 'Low' THEN 1.0 ELSE 0.0 END) as avg_low FROM national_security_events_dates GROU...
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'Canada'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (4, 'Raj Patel', 'In...
What is the average donation amount by donors from India in the year 2020?
SELECT AVG(DonationAmount) FROM Donations D INNER JOIN Donors DON ON D.DonorID = DON.DonorID WHERE DON.Country = 'India' AND YEAR(D.DonationDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE CO2Emission (mill TEXT, country TEXT, co2_kg FLOAT); INSERT INTO CO2Emission (mill, country, co2_kg) VALUES ('MillA', 'China', 120.5), ('MillB', 'Bangladesh', 80.3), ('MillC', 'Vietnam', 160.1), ('MillD', 'India', 95.6);
What is the average CO2 emission of each textile mill, grouped by country and displayed in ascending order based on the emission amount?
SELECT country, AVG(co2_kg) as avg_co2 FROM CO2Emission GROUP BY country ORDER BY avg_co2 ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes( process_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), labor_practice_score INT); INSERT INTO manufacturing_processes (process_id, name, location, labor_practice_score) VALUES (1, 'Process 1', 'Location 1', 80);
Insert data into 'manufacturing_processes' table
INSERT INTO manufacturing_processes (process_id, name, location, labor_practice_score) VALUES (2, 'Process 2', 'Location 2', 85);
gretelai_synthetic_text_to_sql
CREATE TABLE VesselSafety (VesselID INT, SafetyScore DECIMAL(3,1)); INSERT INTO VesselSafety (VesselID, SafetyScore) VALUES (1, 85.2), (2, 91.1), (3, 76.3), (4, NULL);
What is the minimum safety score of vessels with a safety score?
SELECT MIN(SafetyScore) FROM VesselSafety WHERE SafetyScore IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics( clinic_id INT PRIMARY KEY, name VARCHAR(255), beds INT, doctor_count INT); INSERT INTO rural_clinics(clinic_id, name, beds, doctor_count) VALUES (1, 'Clinic A', 5, 3), (2, 'Clinic B', 3, 2), (3, 'Clinic C', 4, 3);
Select all records from 'rural_clinics' table
SELECT * FROM rural_clinics;
gretelai_synthetic_text_to_sql
CREATE TABLE military_expenditure (expenditure_id INT, country TEXT, year INT, amount FLOAT); INSERT INTO military_expenditure (expenditure_id, country, year, amount) VALUES (1, 'United States', 2017, 610), (2, 'United States', 2018, 649), (3, 'United Kingdom', 2017, 47), (4, 'Germany', 2018, 43);
What is the total military expenditure by NATO members in the last 5 years?
SELECT SUM(amount) FROM military_expenditure WHERE year >= (SELECT YEAR(GETDATE()) - 5) AND country IN (SELECT member_state FROM nato_members)
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(255), country VARCHAR(255), date_registered DATE); CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE);
Delete player records from the "players" table who have not played any game
DELETE FROM players WHERE player_id NOT IN (SELECT player_id FROM player_scores);
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (id INT, company VARCHAR(255), quantity INT, time DATETIME); INSERT INTO Shipments (id, company, quantity, time) VALUES (1, 'Oceanic Corp', 50, '2020-01-01 10:00:00'), (2, 'Oceanic Corp', 75, '2020-02-15 15:30:00'); CREATE TABLE Time (id INT, date DATE, quarter INT); INSERT INTO Time (id, date, q...
What is the total number of containers shipped by company "Oceanic Corp" in the first quarter of 2020?
SELECT SUM(quantity) FROM Shipments S JOIN Time T ON S.time = T.date WHERE company = 'Oceanic Corp' AND quarter = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_lgbtq BOOLEAN, num_employees INT);
What is the average number of employees for startups founded by LGBTQ+ founders in the sustainability industry?
SELECT AVG(num_employees) FROM companies WHERE founder_lgbtq = TRUE AND industry = 'sustainability';
gretelai_synthetic_text_to_sql
CREATE TABLE dentists (id INTEGER, state VARCHAR(255), city VARCHAR(255), count INTEGER);
What is the number of dentists per 1000 rural residents by state?
SELECT state, AVG(count / population * 1000) AS dentists_per_1000_residents FROM dentists JOIN (SELECT state, SUM(population) AS population FROM rural_population GROUP BY state) AS population_table ON dentists.state = population_table.state GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (id INT, name TEXT, location TEXT, size FLOAT);
Add a new farm 'Green Valley' in Canada with size 180
INSERT INTO farms (name, location, size) VALUES ('Green Valley', 'Canada', 180);
gretelai_synthetic_text_to_sql
CREATE TABLE businesses_india_bihar (business_id INT, state TEXT, owner_gender TEXT, sustainable_practices BOOLEAN); INSERT INTO businesses_india_bihar (business_id, state, owner_gender, sustainable_practices) VALUES (1, 'Bihar', 'Female', TRUE), (2, 'Bihar', 'Male', FALSE), (3, 'Bihar', 'Female', TRUE);
What is the number of rural women-led businesses in the state of Bihar, India, that have adopted sustainable agricultural practices?
SELECT COUNT(*) as num_women_led_sustainable FROM businesses_india_bihar WHERE state = 'Bihar' AND owner_gender = 'Female' AND sustainable_practices = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_projects (project_name VARCHAR(255), contractor_name VARCHAR(255));
Which contractors have worked on more than one project in the 'construction_projects' table?
select contractor_name, count(distinct project_name) as project_count from construction_projects group by contractor_name having count(distinct project_name) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions_data (id INT, country VARCHAR(50), year INT, emissions DECIMAL); INSERT INTO emissions_data (id, country, year, emissions) VALUES (1, 'USA', 2018, 5134.5); INSERT INTO emissions_data (id, country, year, emissions) VALUES (2, 'China', 2018, 13136.4);
Which countries have the highest greenhouse gas emissions in 2018?
SELECT country, emissions FROM emissions_data WHERE year = 2018 ORDER BY emissions DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (id INT, location TEXT, pH FLOAT, year INT); INSERT INTO ocean_acidity (id, location, pH, year) VALUES (1, 'Indian Ocean', 7.8, 2015), (2, 'Indian Ocean', 7.7, 2016), (3, 'Indian Ocean', 7.9, 2017);
What is the average ocean acidity level (pH value) in the Indian Ocean over the last 7 years?
SELECT AVG(pH) FROM ocean_acidity WHERE location = 'Indian Ocean' AND year BETWEEN 2015 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), ocean VARCHAR(255), depth INT); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (1, 'Southern Ocean Squid', 'Southern', 3000);
Update the depth of the 'Southern Ocean Squid' to 3500 meters in the marine_species table.
UPDATE marine_species SET depth = 3500 WHERE species_name = 'Southern Ocean Squid';
gretelai_synthetic_text_to_sql
CREATE TABLE VulnAssessments (id INT, system VARCHAR(255), vulnerability VARCHAR(255), severity VARCHAR(255), date DATE); INSERT INTO VulnAssessments (id, system, vulnerability, severity, date) VALUES (1, 'Web Server', 'SQL Injection', 'High', '2022-01-01');
What is the count of high severity vulnerabilities for each system in the VulnAssessments table in January 2022?
SELECT system, COUNT(*) FROM VulnAssessments WHERE severity = 'High' AND date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY system;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholder (PolicyholderID INT, State VARCHAR(255), ClaimAmount DECIMAL(10,2)); INSERT INTO Policyholder VALUES (1, 'NY', 5000), (2, 'NJ', 7000), (3, 'NY', 8000), (4, 'NJ', 6000), (5, 'NY', 9000);
find the number of policyholders from each state who have the highest average claim amount
SELECT State, AVG(ClaimAmount) as AvgClaimAmount FROM Policyholder GROUP BY State HAVING AVG(ClaimAmount) = (SELECT MAX(AvgClaimAmount) FROM (SELECT State, AVG(ClaimAmount) as AvgClaimAmount FROM Policyholder GROUP BY State) AS SubQuery);
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_country (project_name TEXT, country TEXT, funding INTEGER);INSERT INTO mitigation_country (project_name, country, funding) VALUES ('Green Technology', 'USA', 2000000), ('Carbon Reduction', 'Canada', 3000000);
What is the total funding allocated for climate mitigation projects in each country in North America?
SELECT country, SUM(funding) as total_funding FROM mitigation_country WHERE region = 'North America' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE disputes_strikes_2020 (id INT, state VARCHAR(255), dispute_count INT, strike_count INT); INSERT INTO disputes_strikes_2020 (id, state, dispute_count, strike_count) VALUES (1, 'California', 50, 10), (2, 'New York', 35, 5), (3, 'Texas', 40, 8);
What is the percentage of labor disputes in each state that resulted in a strike, based on the 'disputes_strikes_2020' table?
SELECT state, (SUM(strike_count) * 100.0 / SUM(dispute_count)) as strike_percentage FROM disputes_strikes_2020 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (city VARCHAR(20), transport_type VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO public_transportation VALUES ('New York City', 'Bus', 2.75);
What is the average fare for public buses in New York City?
SELECT AVG(fare) FROM public_transportation WHERE city = 'New York City' AND transport_type = 'Bus';
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50)); CREATE TABLE species (species_id INT, name VARCHAR(50), ocean_id INT); INSERT INTO oceans VALUES (1, 'Atlantic'), (2, 'Pacific'), (3, 'Indian'); INSERT INTO species VALUES (1, 'Clownfish', 2), (2, 'Salmon', 1), (3, 'Clownfish', 3), (4, 'Dolphin', 1), (5, 'Turtle', 3...
Find the number of marine species unique to each ocean.
SELECT ocean_id, COUNT(DISTINCT species_id) FROM species GROUP BY ocean_id;
gretelai_synthetic_text_to_sql
CREATE TABLE education (id INT, year INT, violations INT); INSERT INTO education (id, year, violations) VALUES (1, 2018, 10), (2, 2019, 15), (3, 2020, 20);
What is the average number of workplace safety violations per year in the education sector?
SELECT AVG(violations / COUNT(*)) FROM education;
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name VARCHAR(50), gender VARCHAR(10), company_id INT); CREATE TABLE funding (id INT, company_id INT, amount INT);
What is the average funding received by companies with at least 2 female founders?
SELECT AVG(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id GROUP BY funding.company_id HAVING COUNT(DISTINCT founders.id) >= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (id INT, event_name VARCHAR(255), country VARCHAR(255), attendance INT); INSERT INTO CulturalEvents (id, event_name, country, attendance) VALUES (1, 'Event A', 'USA', 1000), (2, 'Event B', 'Canada', 800), (3, 'Event C', 'Mexico', 1200), (4, 'Event D', 'USA', 1500);
What is the maximum attendance for cultural events in each country?
SELECT country, MAX(attendance) FROM CulturalEvents GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), city VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, date DATE, attendees INT); INSERT INTO teams VALUES (1, 'Lakers', 'Los Angeles'); INSERT INTO teams VALUES (2, 'Warriors', 'San Francisco'); INSERT INTO games VALUES (1, 1, '2022-03-15', 15000); INSER...
How many fans attended home games per team in the last 30 days, ranked by the highest number of attendees?
SELECT team_id, SUM(attendees) as total_attendees FROM games WHERE date >= CURRENT_DATE - INTERVAL '30 days' GROUP BY team_id ORDER BY total_attendees DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_show (tv_show_id INT, title VARCHAR(100), genre VARCHAR(50)); INSERT INTO tv_show (tv_show_id, title, genre) VALUES (1, 'The Forgotten', 'Drama');
Update the genre of the TV show 'The Forgotten' to 'Mystery'.
UPDATE tv_show SET genre = 'Mystery' WHERE title = 'The Forgotten';
gretelai_synthetic_text_to_sql
CREATE TABLE garment_type_cost (id INT, garment_type VARCHAR(255), production_cost DECIMAL(10,2));
Show the number of garments made from ethical materials, grouped by garment type.
SELECT garment_type, COUNT(*) AS garment_count FROM garment_type_cost GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_sessions_2023 (patient_id INT, session_date DATE); INSERT INTO therapy_sessions_2023 (patient_id, session_date) VALUES (5, '2023-02-03'), (6, '2023-03-17'), (7, '2023-06-28'), (8, '2023-04-01');
What is the total number of patients who have completed therapy sessions in '2023'?
SELECT COUNT(*) FROM (SELECT patient_id, session_date FROM therapy_sessions_2023 WHERE YEAR(session_date) = 2023 AND patient_id IS NOT NULL) AS completed_sessions WHERE session_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature (id INT PRIMARY KEY, location VARCHAR(255), temperature FLOAT);
Insert a new record into the "ocean_temperature" table with the following data: 4, "Arctic Ocean", -1.5
INSERT INTO ocean_temperature (id, location, temperature) VALUES (4, 'Arctic Ocean', -1.5);
gretelai_synthetic_text_to_sql
CREATE TABLE diversification_projects (id INT, project_name VARCHAR(50), completion_year INT); INSERT INTO diversification_projects (id, project_name, completion_year) VALUES (1, 'Handicraft Training', 2021), (2, 'Local Tourism', 2022);
How many economic diversification projects were completed in 2021 in the 'diversification_projects' table?
SELECT COUNT(*) FROM diversification_projects WHERE completion_year = 2021;
gretelai_synthetic_text_to_sql
CREATE SCHEMA forestry; CREATE TABLE trees (id INT, species VARCHAR(50), carbon FLOAT); INSERT INTO trees (id, species, carbon) VALUES (1, 'oak', 4.2), (2, 'pine', 3.8), (3, 'eucalyptus', 5.0), (4, 'oak', 4.5), (5, 'maple', 3.5);
find the lowest and highest carbon sequestration values among tree species
SELECT MIN(carbon), MAX(carbon) FROM forestry.trees;
gretelai_synthetic_text_to_sql
CREATE TABLE Neighborhoods (neighborhood_id INT, name VARCHAR(50));CREATE TABLE Properties (property_id INT, neighborhood_id INT, year_built INT, co_owners INT);
How many properties in each neighborhood have been co-owned by at least two unrelated individuals since 2015?
SELECT n.name, COUNT(p.property_id) as co_owned_properties FROM Neighborhoods n JOIN Properties p ON n.neighborhood_id = p.neighborhood_id WHERE p.co_owners >= 2 AND p.year_built >= 2015 GROUP BY n.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Humidity (field VARCHAR(50), date DATE, humidity FLOAT); INSERT INTO Humidity (field, date, humidity) VALUES ('Field F', '2022-06-01', 55.2), ('Field F', '2022-06-02', 52.1), ('Field F', '2022-06-03', 58.6);
What is the average humidity in field F during the last 3 days?
SELECT AVG(humidity) FROM Humidity WHERE field = 'Field F' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), habitat VARCHAR(255)); INSERT INTO marine_species (id, name, habitat) VALUES (1, 'Polar Bear', 'Arctic Ocean'), (2, 'Beluga Whale', 'Arctic Ocean');
What is the total number of marine species observed in the Arctic Ocean?
SELECT COUNT(*) FROM marine_species WHERE habitat = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_yield (id INT, crop_type VARCHAR(20), year INT, production INT);
What is the maximum production in the 'crop_yield' table for each crop type?
SELECT crop_type, MAX(production) FROM crop_yield GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(100), donation INT, campaign VARCHAR(50)); INSERT INTO donors (id, name, donation, campaign) VALUES (1, 'Donor 1', 5000, 'Campaign 1'); INSERT INTO donors (id, name, donation, campaign) VALUES (2, 'Donor 2', 7000, 'Campaign 2'); INSERT INTO donors (id, name, donation, campaign)...
Who are the top 5 donors to political campaigns in Canada?
SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY donation DESC) as row_num FROM donors) donors_ranked WHERE row_num <= 5;
gretelai_synthetic_text_to_sql