context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE users (id INT, username VARCHAR(50), last_login TIMESTAMP);
What's the number of users who logged in for the first time in the last week in the 'gaming' schema?
SELECT COUNT(*) FROM users WHERE last_login >= DATE_SUB(NOW(), INTERVAL 1 WEEK) AND last_login < NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide (id INT PRIMARY KEY, problem VARCHAR(50), description TEXT); INSERT INTO digital_divide (id, problem, description) VALUES (1, 'Lack of internet access', 'High-speed internet unavailable in many rural areas'), (2, 'Expensive devices', 'Cost of devices is a barrier for low-income households'), (3, 'Literacy and skills', 'Limited computer literacy and digital skills');
Insert a new record into the 'digital_divide' table with an id of 4, a problem of 'Lack of digital resources in schools', and a description of 'Many schools do not have access to digital resources'
INSERT INTO digital_divide (id, problem, description) VALUES (4, 'Lack of digital resources in schools', 'Many schools do not have access to digital resources');
gretelai_synthetic_text_to_sql
CREATE TABLE chicago_events(id INT, category VARCHAR(30), attendees INT); INSERT INTO chicago_events VALUES (1, 'Theater', 600); INSERT INTO chicago_events VALUES (2, 'Concert', 400);
What is the number of performances in each category that had more than 500 attendees in Chicago?
SELECT category, COUNT(*) FROM chicago_events WHERE attendees > 500 GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Fields (id INT PRIMARY KEY, name VARCHAR(255), acres FLOAT, location VARCHAR(255)); INSERT INTO Fields (id, name, acres, location) VALUES (1, 'FieldA', 5.6, 'US-MN'), (2, 'FieldB', 3.2, 'US-CA'); CREATE TABLE Satellite_Imagery (id INT PRIMARY KEY, location VARCHAR(255), nitrogen_level FLOAT); INSERT INTO Satellite_Imagery (id, location, nitrogen_level) VALUES (1, 'US-MN', 3.5), (2, 'US-CA', 4.1); CREATE TABLE IoT_Sensors (id INT PRIMARY KEY, Field_id INT, temperature FLOAT, humidity FLOAT); INSERT INTO IoT_Sensors (id, Field_id, temperature, humidity) VALUES (1, 1, 20.5, 60.3), (2, 2, 25.3, 70.2);
Which fields have nitrogen_level greater than 4.5 and temperature lower than 25.0?
SELECT Fields.name FROM Fields INNER JOIN Satellite_Imagery ON Fields.location = Satellite_Imagery.location INNER JOIN IoT_Sensors ON Fields.id = IoT_Sensors.Field_id WHERE Satellite_Imagery.nitrogen_level > 4.5 AND IoT_Sensors.temperature < 25.0;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_model (id INT, name VARCHAR(255), type VARCHAR(255), fairness_score FLOAT); INSERT INTO ai_model (id, name, type, fairness_score) VALUES (1, 'AdaNet', 'Supervised Learning', 0.85), (2, 'DeepDetect', 'Deep Learning', 0.90), (3, 'XGBoost', 'Supervised Learning', 0.95);
What is the minimum fairness score for each type of AI model?
SELECT type, MIN(fairness_score) as min_fairness FROM ai_model GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE terbium_producers (producer_id INT, name VARCHAR(255), year INT, terbium_production INT); INSERT INTO terbium_producers (producer_id, name, year, terbium_production) VALUES (1, 'Canada', 2015, 120), (2, 'Mexico', 2015, 110), (3, 'USA', 2015, 100), (4, 'Canada', 2016, 130), (5, 'Mexico', 2016, 120), (6, 'USA', 2016, 110), (7, 'Canada', 2017, 140), (8, 'Mexico', 2017, 130), (9, 'USA', 2017, 120);
Calculate the total Terbium production by year for the top 3 producers, and rank them by production volume.
SELECT name, year, SUM(terbium_production) AS total_production, RANK() OVER (PARTITION BY year ORDER BY SUM(terbium_production) DESC) AS production_rank FROM terbium_producers GROUP BY name, year ORDER BY year, total_production DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, country TEXT, virtual_tour BOOLEAN, ai_concierge BOOLEAN);
What is the number of hotels in 'Cape Town' with virtual tours and an AI concierge?
SELECT city, COUNT(*) as num_hotels FROM hotels WHERE city = 'Cape Town' AND virtual_tour = TRUE AND ai_concierge = TRUE GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShows (Id INT, Name VARCHAR(100), Location VARCHAR(100), StartDate DATE, EndDate DATE); CREATE TABLE Exhibits (Id INT, AutoShowId INT, VehicleId INT, VehicleType VARCHAR(50)); CREATE TABLE Vehicles (Id INT, Name VARCHAR(100), Type VARCHAR(50)); INSERT INTO AutoShows (Id, Name, Location, StartDate, EndDate) VALUES (1, 'Paris Motor Show', 'Paris', '2021-10-17', '2021-10-24'); INSERT INTO Exhibits (Id, AutoShowId, VehicleId, VehicleType) VALUES (1, 1, 1, 'Electric'); INSERT INTO Exhibits (Id, AutoShowId, VehicleId, VehicleType) VALUES (2, 1, 2, 'Electric');
List all auto shows in Europe and the number of electric vehicles exhibited in each one.
SELECT AutoShows.Name, COUNT(Exhibits.VehicleId) FROM AutoShows INNER JOIN Exhibits ON AutoShows.Id = Exhibits.AutoShowId INNER JOIN Vehicles ON Exhibits.VehicleId = Vehicles.Id WHERE Vehicles.Type = 'Electric' AND AutoShows.Location LIKE 'Europe%' GROUP BY AutoShows.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, cargo_weight INT, country VARCHAR(20), shipment_date DATE); INSERT INTO imports (id, cargo_weight, country, shipment_date) VALUES (1, 25000, 'Germany', '2021-03-03'); INSERT INTO imports (id, cargo_weight, country, shipment_date) VALUES (2, 18000, 'Germany', '2021-03-05'); INSERT INTO imports (id, cargo_weight, country, shipment_date) VALUES (3, 22000, 'Indonesia', '2021-03-07');
List the countries with more than 20000 kg of imported cargo in March 2021.
SELECT country FROM imports WHERE shipment_date >= '2021-03-01' AND shipment_date < '2021-04-01' GROUP BY country HAVING SUM(cargo_weight) > 20000;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (record_id INT PRIMARY KEY, mine_name VARCHAR(20), productivity_score INT); INSERT INTO production_data (record_id, mine_name, productivity_score) VALUES (1, 'Platinum Plus', 88), (2, 'Iron Ore Inc.', 82), (3, 'Golden Nuggets', 85), (4, 'Iron Ore Inc.', 83);
Update the "production_data" table to set the "productivity_score" to 88 for all records where the "mine_name" is 'Iron Ore Inc.'
UPDATE production_data SET productivity_score = 88 WHERE mine_name = 'Iron Ore Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_sourcing (restaurant_name VARCHAR(255), sourcing_record VARCHAR(255)); INSERT INTO sustainable_sourcing (restaurant_name, sourcing_record) VALUES ('Pizza Palace', 'Organic Tomatoes'), ('Pizza Palace', 'Local Cheese'), ('Pizza Palace', 'Fair Trade Pepperoni');
How many sustainable sourcing records are there for 'Pizza Palace'?
SELECT COUNT(*) FROM sustainable_sourcing WHERE restaurant_name = 'Pizza Palace';
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyInspections (InspectionID INT, VesselID INT, InspectionDate DATE);
Insert new safety inspection records for vessels with the specified details.
INSERT INTO SafetyInspections (InspectionID, VesselID, InspectionDate) VALUES (3, 1, '2021-06-01'), (4, 4, '2021-07-01');
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (state VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (state, year, recycling_rate) VALUES ('Alabama', 2019, 15.2), ('Alaska', 2019, 20.5), ('Arizona', 2019, 25.0), ('Arkansas', 2019, 12.7), ('California', 2019, 50.1);
What is the recycling rate in percentage for each state in the USA in 2019?
SELECT state, recycling_rate FROM recycling_rates WHERE year = 2019 AND state IN ('Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(255), artist_id INT); INSERT INTO Artwork (artwork_id, artwork_name, artist_id) VALUES (1, 'The Sun Rises', 4), (2, 'Moon Dance', 5);
Insert records of artworks by underrepresented artists into the 'Artwork' table.
INSERT INTO Artwork (artwork_id, artwork_name, artist_id) VALUES (3, ' Ancestral Wisdom', 6), (4, 'Resilience', 7);
gretelai_synthetic_text_to_sql
CREATE TABLE data_types_summary (dept_name TEXT, column_name TEXT, data_type TEXT, record_count INTEGER); INSERT INTO data_types_summary (dept_name, column_name, data_type, record_count) VALUES ('Human Services Department', 'age', 'INTEGER', 60), ('Human Services Department', 'gender', 'TEXT', 60), ('Human Services Department', 'income', 'FLOAT', 60), ('Education Department', 'school_name', 'TEXT', 45), ('Education Department', 'student_count', 'INTEGER', 45);
What is the total number of records for each data type across all departments?
SELECT column_name, data_type, SUM(record_count) FROM data_types_summary GROUP BY column_name, data_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ngo_tech (name TEXT, budget INTEGER); INSERT INTO ngo_tech (name, budget) VALUES ('AIforGood', 400000), ('EthicsNG', 500000), ('Tech4Change', 600000);
What is the total budget for ethical AI initiatives by companies in the non-profit sector?
SELECT SUM(budget) FROM ngo_tech WHERE name IN ('AIforGood', 'EthicsNG', 'Tech4Change') AND sector = 'non-profit';
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); CREATE TABLE strains (id INT, name TEXT, cultivator_id INT); CREATE TABLE inventory (id INT, strain_id INT, dispensary_id INT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Emerald Family Farms', 'California'), (2, 'Good Chemistry', 'Colorado'); INSERT INTO strains (id, name, cultivator_id) VALUES (1, 'Gelato 33', 1), (2, 'Gelato Cake', 1), (3, 'Sunset Sherbet', 2); INSERT INTO inventory (id, strain_id, dispensary_id) VALUES (1, 1, 1), (2, 3, 1);
Which cultivators have supplied a dispensary with a strain containing 'Gelato' in its name?
SELECT DISTINCT c.name FROM cultivators c JOIN strains s ON c.id = s.cultivator_id JOIN inventory i ON s.id = i.strain_id WHERE i.dispensary_id = 1 AND s.name LIKE '%Gelato%';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, customer_id INT, transaction_date DATE, amount FLOAT); CREATE TABLE customers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO transactions (id, customer_id, transaction_date, amount) VALUES (1, 1, '2022-02-01', 1000.00), (2, 2, '2022-02-02', 2000.00), (3, 1, '2022-02-03', 1500.00), (4, 2, '2022-02-04', 3000.00), (5, 1, '2022-02-05', 500.00), (6, 3, '2022-02-01', 100.00), (7, 3, '2022-02-03', 200.00), (8, 4, '2022-02-05', 50.00), (9, 4, '2022-02-06', 75.00); INSERT INTO customers (id, name, country) VALUES (1, 'Jacob Smith', 'Canada'), (2, 'Emily Chen', 'China'), (3, 'Carlos Alvarez', 'Mexico'), (4, 'Nina Patel', 'Canada');
Calculate the average daily transaction amount for the past week for customers from Canada
SELECT AVG(amount) FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE t.transaction_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() AND c.country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits_TX (id INT, permit_type VARCHAR(255), state VARCHAR(255), quarter VARCHAR(255)); INSERT INTO Building_Permits_TX (id, permit_type, state, quarter) VALUES (1, 'Residential', 'Texas', 'Q2 2022'); INSERT INTO Building_Permits_TX (id, permit_type, state, quarter) VALUES (2, 'Commercial', 'Texas', 'Q2 2022'); INSERT INTO Building_Permits_TX (id, permit_type, state, quarter) VALUES (3, 'Residential', 'Texas', 'Q2 2022');
What is the total number of building permits issued in Texas in Q2 2022 grouped by permit type?
SELECT permit_type, COUNT(*) FROM Building_Permits_TX WHERE state = 'Texas' AND quarter = 'Q2 2022' GROUP BY permit_type;
gretelai_synthetic_text_to_sql
CREATE TABLE fertilizer (id INT, name VARCHAR(255), unit_price DECIMAL(10, 2)); CREATE TABLE inventory (id INT, fertilizer_id INT, quantity INT, timestamp TIMESTAMP); INSERT INTO fertilizer VALUES (1, 'Urea', 450), (2, 'Ammonium Nitrate', 300); INSERT INTO inventory VALUES (1, 1, 1000, '2022-03-01 10:00:00'), (2, 2, 800, '2022-03-01 10:00:00');
List the total quantity of each fertilizer used in the past month, along with its corresponding unit price and total cost.
SELECT f.name, SUM(i.quantity) as total_quantity, f.unit_price, SUM(i.quantity * f.unit_price) as total_cost FROM fertilizer f INNER JOIN inventory i ON f.id = i.fertilizer_id WHERE i.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW() GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyStorage (id INT, state VARCHAR(50), technology VARCHAR(50), capacity FLOAT); INSERT INTO EnergyStorage (id, state, technology, capacity) VALUES (1, 'Texas', 'Batteries', 12.3), (2, 'Texas', 'Pumped Hydro', 18.7), (3, 'California', 'Batteries', 21.5);
What is the total energy storage capacity (in GWh) in Texas, grouped by technology?
SELECT technology, SUM(capacity) FROM EnergyStorage WHERE state = 'Texas' GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(255)); INSERT INTO Vessels (id, name) VALUES (1, 'Blue Whale'); CREATE TABLE FuelConsumption (vessel_id INT, fuel_consumption INT, timestamp TIMESTAMP); INSERT INTO FuelConsumption (vessel_id, fuel_consumption, timestamp) VALUES (1, 500, '2022-07-01 10:00:00'), (1, 800, '2022-07-01 22:00:00');
Calculate the average fuel consumption per hour for the vessel 'Blue Whale' in the 'Tankers' fleet in the past week.
SELECT AVG(fuel_consumption / DATEDIFF(HOUR, LAG(timestamp) OVER (PARTITION BY vessel_id ORDER BY timestamp), timestamp)) as avg_fuel_consumption_per_hour FROM FuelConsumption WHERE vessel_id = 1 AND timestamp >= DATEADD(week, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE field_sensors (field_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); INSERT INTO field_sensors (field_id, sensor_type, value, timestamp) VALUES (10, 'moisture', 18.5, '2023-02-25 10:00:00'), (10, 'moisture', 22.0, '2023-02-25 11:00:00');
Delete records from field_sensors table where sensor_type is 'moisture' and value is below 20.
DELETE FROM field_sensors WHERE sensor_type = 'moisture' AND value < 20;
gretelai_synthetic_text_to_sql
CREATE TABLE water_aid (id INT PRIMARY KEY, agency_id INT, water_aid_amount INT); INSERT INTO water_aid (id, agency_id, water_aid_amount) VALUES (1, 1, 100000); INSERT INTO water_aid (id, agency_id, water_aid_amount) VALUES (2, 2, 200000); INSERT INTO water_aid (id, agency_id, water_aid_amount) VALUES (3, 3, 300000); INSERT INTO water_aid (id, agency_id, water_aid_amount) VALUES (4, 4, 400000);
What is the total number of water_aid_amount records for agency_id 4 in the water_aid table?
SELECT SUM(water_aid_amount) FROM water_aid WHERE agency_id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_registrations (registration_date DATE, is_ev BOOLEAN, PRIMARY KEY (registration_date, is_ev)); INSERT INTO vehicle_registrations (registration_date, is_ev) VALUES ('2018-01-01', true); INSERT INTO vehicle_registrations (registration_date, is_ev) VALUES ('2018-01-05', false);
What is the average number of vehicles registered per month in the 'vehicle_registrations' table since 2018?
SELECT AVG(registrations_per_month) FROM (SELECT EXTRACT(MONTH FROM registration_date) AS month, COUNT(*) AS registrations_per_month FROM vehicle_registrations WHERE registration_date >= '2018-01-01' GROUP BY month) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE threats (id INT, department VARCHAR(20), risk_score FLOAT, detection_date DATE); INSERT INTO threats (id, department, risk_score, detection_date) VALUES (1, 'Sales', 15.5, '2022-01-15'); INSERT INTO threats (id, department, risk_score, detection_date) VALUES (2, 'Marketing', 12.2, '2022-02-07'); INSERT INTO threats (id, department, risk_score, detection_date) VALUES (3, 'Sales', 18.1, '2022-03-20');
What is the total risk score of threats detected in the 'Sales' department in Q1 2022?
SELECT SUM(risk_score) FROM threats WHERE department = 'Sales' AND detection_date >= '2022-01-01' AND detection_date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE run_data (id INT, user_id INT, distance FLOAT); INSERT INTO run_data (id, user_id, distance) VALUES (1, 17, 4.5); INSERT INTO run_data (id, user_id, distance) VALUES (2, 18, 6.2); CREATE TABLE workout_groups (id INT, user_id INT, group_label VARCHAR(10)); INSERT INTO workout_groups (id, user_id, group_label) VALUES (1, 17, 'Intermediate'); INSERT INTO workout_groups (id, user_id, group_label) VALUES (2, 18, 'Advanced');
What is the minimum distance covered by users in the 'Intermediate' workout group?
SELECT MIN(distance) FROM run_data JOIN workout_groups ON run_data.user_id = workout_groups.user_id WHERE group_label = 'Intermediate';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (id INT, name VARCHAR(50), type VARCHAR(50), cost DECIMAL(5,2)); INSERT INTO equipment (id, name, type, cost) VALUES (1, 'Equipment1', 'Sequencer', 50000.00); INSERT INTO equipment (id, name, type, cost) VALUES (2, 'Equipment2', 'Microscope', 20000.00);
What is the name, type, and cost of the equipment with a cost greater than the average cost plus one standard deviation of all equipment?
SELECT name, type, cost FROM equipment WHERE cost > (SELECT AVG(cost) FROM equipment) + (SELECT STDDEV(cost) FROM equipment);
gretelai_synthetic_text_to_sql
CREATE TABLE lending_applications (id INT, application_date DATE, approved BOOLEAN); INSERT INTO lending_applications (id, application_date, approved) VALUES (1, '2021-04-02', FALSE), (2, '2021-05-15', TRUE), (3, '2021-06-01', FALSE);
How many socially responsible lending applications were rejected in Q2 2021?
SELECT COUNT(*) as num_rejected FROM lending_applications WHERE approved = FALSE AND application_date >= '2021-04-01' AND application_date < '2021-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_force (mine_name VARCHAR(255), employee_count INT, turnover_rate FLOAT); INSERT INTO labor_force (mine_name, employee_count, turnover_rate) VALUES ('Green Valley', 250, 0.09); INSERT INTO labor_force (mine_name, employee_count, turnover_rate) VALUES ('Blue Hills', 300, 0.07);
What are the mines with labor turnover rates higher than 0.08?
SELECT mine_name FROM labor_force WHERE turnover_rate > 0.08;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (name VARCHAR(255), type VARCHAR(255), flag_state VARCHAR(255)); CREATE TABLE inspections (inspection_id INT, vessel_name VARCHAR(255), inspection_date DATE, region VARCHAR(255)); CREATE TABLE caribbean_sea (name VARCHAR(255), region_type VARCHAR(255)); INSERT INTO vessels (name, type, flag_state) VALUES ('VESSEL1', 'Cargo', 'Italy'), ('VESSEL2', 'Passenger', 'Spain'); INSERT INTO inspections (inspection_id, vessel_name, inspection_date, region) VALUES (1, 'VESSEL1', '2022-01-01', 'Caribbean Sea'), (2, 'VESSEL3', '2022-02-01', 'Caribbean Sea'); INSERT INTO caribbean_sea (name, region_type) VALUES ('VESSEL1', 'Caribbean Sea');
What is the number of vessels inspected in the Caribbean sea?
SELECT COUNT(*) FROM inspections i INNER JOIN caribbean_sea cs ON i.region = cs.region;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_launch_dates (spacecraft_name TEXT, launch_date DATE); INSERT INTO spacecraft_launch_dates (spacecraft_name, launch_date) VALUES ('Voyager 1', '1977-09-05'), ('Voyager 2', '1977-08-20'), ('Cassini', '1997-10-15');
What is the earliest launched spacecraft in the database?
SELECT spacecraft_name, MIN(launch_date) as earliest_launch_date FROM spacecraft_launch_dates;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_address VARCHAR(42), deployment_date DATE); INSERT INTO smart_contracts (contract_address, deployment_date) VALUES ('0x123', '2022-01-01'), ('0x456', '2022-01-15'), ('0x789', '2022-02-01'), ('0xabc', '2022-02-15'), ('0xdef', '2022-03-01');
How many smart contracts were deployed in each month of 2022?
SELECT EXTRACT(MONTH FROM deployment_date) AS month, COUNT(*) FROM smart_contracts GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, birthdate DATE); INSERT INTO artists (id, name, birthdate) VALUES (1, 'Sarah Johnson', '1900-01-01'), (2, 'Maria Rodriguez', '1980-05-05'), (3, 'Yumi Lee', '1968-11-11');
What is the average age of artists who have created artworks in the 'painting' category?
SELECT AVG(YEAR(CURRENT_DATE) - YEAR(birthdate)) as avg_age FROM artists JOIN artworks ON artists.id = artworks.artist WHERE category = 'painting';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellite_deployment (id, name, country, launch_date) VALUES (1, 'Sentinel-1A', 'Europe', '2014-04-03'), (2, 'TechSat', 'United States', '2022-09-01');
List all satellites launched in the year 2014
SELECT name FROM satellite_deployment WHERE YEAR(launch_date) = 2014;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists fundings;CREATE TABLE if not exists fundings.dates (id INT, startup_id INT, funding_date DATE); INSERT INTO fundings.dates (id, startup_id, funding_date) VALUES (1, 1, '2021-06-01'), (2, 2, '2022-02-14'), (3, 1, '2021-12-15'), (4, 3, '2022-08-05');
What is the most recent funding date for each biotech startup?
SELECT d.startup_id, MAX(d.funding_date) max_funding_date FROM fundings.dates d GROUP BY d.startup_id;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions_reduction (project_id INT, project_name VARCHAR(255), co2_reduction FLOAT, reduction_year INT);
Calculate the total CO2 emissions reduction achieved by renewable energy projects since 2010
SELECT SUM(co2_reduction) FROM co2_emissions_reduction WHERE reduction_year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_hours (employee_id INT, department VARCHAR(20), hours_worked INT, work_date DATE); INSERT INTO employee_hours (employee_id, department, hours_worked, work_date) VALUES (1, 'mining', 8, '2021-01-15'), (2, 'geology', 7, '2021-01-20'), (3, 'engineering', 9, '2021-03-01'), (4, 'administration', 6, '2020-12-14'), (5, 'mining', 10, '2021-02-15'), (6, 'geology', 8, '2021-02-20');
What is the total number of employee hours worked in each department in the last month?
SELECT department, SUM(hours_worked) FROM employee_hours WHERE work_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE GROUP BY department
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genomic Solutions', 'USA', 5000000), (2, 'BioTech Innovations', 'Europe', 7000000);
What is the total funding received by biotech startups located in Europe?
SELECT SUM(funding) FROM startups WHERE location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.donors (donor_id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), donation DECIMAL(10,2));INSERT INTO arts_culture.donors (donor_id, name, type, donation) VALUES (1, 'John Doe', 'Individual', 50.00), (2, 'Jane Smith', 'Individual', 100.00), (3, 'Google Inc.', 'Corporation', 5000.00);
What is the average donation amount by donor type?
SELECT type, AVG(donation) as avg_donation FROM arts_culture.donors GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE VIEW OrganicProducts AS SELECT * FROM Products WHERE is_organic = TRUE; INSERT INTO Products (id, name, is_organic) VALUES (1, 'Product1', TRUE), (2, 'Product2', FALSE), (3, 'Product3', TRUE);
Delete all records from 'OrganicProducts' view
DELETE FROM OrganicProducts;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft(id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT); INSERT INTO spacecraft VALUES(1, 'Voyager 1', 'Galactic Inc.', 770.), (2, 'Voyager 2', 'Galactic Inc.', 778.);
What is the average mass of spacecraft manufactured by 'Galactic Inc.'?
SELECT AVG(mass) FROM spacecraft WHERE manufacturer = 'Galactic Inc.'
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT, country VARCHAR(255), efficiency FLOAT); INSERT INTO energy_efficiency (id, country, efficiency) VALUES (1, 'Germany', 0.35), (2, 'France', 0.32), (3, 'United Kingdom', 0.31), (4, 'Italy', 0.29), (5, 'Spain', 0.28);
What is the energy efficiency of the top 5 countries in Europe?
SELECT country, efficiency FROM energy_efficiency ORDER BY efficiency DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE FlightLogs (flight_id INT, aircraft_model VARCHAR(50), flight_date DATE); INSERT INTO FlightLogs (flight_id, aircraft_model, flight_date) VALUES (1, 'B747', '2022-01-01'), (2, 'A320', '2021-05-01'), (3, 'B747', '2022-03-01');
What is the most recent flight for each aircraft model in the FlightLogs table?
SELECT aircraft_model, MAX(flight_date) AS most_recent_flight FROM FlightLogs GROUP BY aircraft_model;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParityViolations (ViolationID INT, ProviderID INT); INSERT INTO MentalHealthParityViolations (ViolationID, ProviderID) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 1);
What is the total number of mental health parity violations by provider?
SELECT ProviderID, COUNT(*) FROM MentalHealthParityViolations GROUP BY ProviderID;
gretelai_synthetic_text_to_sql
CREATE TABLE fund (id INT, name VARCHAR(50), strategy VARCHAR(20), roi DECIMAL(5,2), year INT); INSERT INTO fund (id, name, strategy, roi, year) VALUES (1, 'Gender Equality Fund', 'gender lens investing', 12.5, 2017); INSERT INTO fund (id, name, strategy, roi, year) VALUES (2, 'Sustainable Impact Fund', 'gender lens investing', 8.2, 2018);
Identify the 5-year return on investment (ROI) for gender lens investing funds.
SELECT roi FROM fund WHERE strategy = 'gender lens investing' AND year BETWEEN 2016 AND 2020;
gretelai_synthetic_text_to_sql
ALTER TABLE Visitors ADD COLUMN last_event_date DATE, event_count INT;
What is the number of visitors who have attended more than three events in the last year?
SELECT COUNT(*) FROM Visitors WHERE last_event_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY Visitors.id HAVING COUNT(*) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_id INT PRIMARY KEY, menu_item VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), region VARCHAR(255));
Update the price of all vegetarian dishes by 10% in the Texas region.
UPDATE Menu SET price = price * 1.10 WHERE category = 'Vegetarian' AND region = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (ProviderId INT, Score INT, Community VARCHAR(255)); INSERT INTO HealthEquityMetrics (ProviderId, Score, Community) VALUES (1, 85, 'Miami'); INSERT INTO HealthEquityMetrics (ProviderId, Score, Community) VALUES (2, 90, 'New York'); INSERT INTO HealthEquityMetrics (ProviderId, Score, Community) VALUES (3, 80, 'Los Angeles'); INSERT INTO HealthEquityMetrics (ProviderId, Score, Community) VALUES (4, 95, 'Toronto');
What is the average health equity metric score for providers serving linguistically diverse communities?
SELECT AVG(Score) FROM HealthEquityMetrics WHERE Community IN ('Miami', 'New York', 'Los Angeles');
gretelai_synthetic_text_to_sql
CREATE TABLE Completed (id INT, name VARCHAR(50), organization VARCHAR(50), quarter INT, year INT, category VARCHAR(50)); INSERT INTO Completed (id, name, organization, quarter, year, category) VALUES (1, 'AI for Accessibility', 'Equal Tech', 1, 2020, 'Social Good'), (2, 'Ethical AI Education', 'Tech Learning', 2, 2019, 'Social Good'), (3, 'Digital Divide Research', 'Global Connect', 3, 2021, 'Social Good');
What is the maximum number of technology for social good projects completed in a single quarter by organizations in North America?
SELECT MAX(COUNT(*)) FROM Completed WHERE category = 'Social Good' GROUP BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_data.juvenile_offenders (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), offense VARCHAR(50), restorative_justice_program BOOLEAN);
What is the total number of juvenile offenders in the justice_data schema's juvenile_offenders table who have been referred to restorative justice programs?
SELECT COUNT(*) FROM justice_data.juvenile_offenders WHERE restorative_justice_program = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, genre VARCHAR(255), country VARCHAR(255), sales_amount DECIMAL(10,2));
What are the total sales for each genre of music in the United States?
SELECT genre, SUM(sales_amount) FROM sales WHERE country = 'United States' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, username VARCHAR(255)); CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_date DATE, likes INT);
Identify users who have mentioned 'data privacy' in their posts in the past week, and the number of likes for each post.
SELECT u.username, p.post_id, p.content, p.post_date, p.likes FROM users u INNER JOIN posts p ON u.user_id = p.user_id WHERE p.content LIKE '%data privacy%' AND p.post_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE mine_workers (id INT, name VARCHAR(50), age INT, mine_type VARCHAR(20)); INSERT INTO mine_workers (id, name, age, mine_type) VALUES (1, 'John Doe', 35, 'Open-pit'); INSERT INTO mine_workers (id, name, age, mine_type) VALUES (2, 'Jane Smith', 28, 'Underground');
What's the average age of employees working in open-pit mines?
SELECT AVG(age) FROM mine_workers WHERE mine_type = 'Open-pit';
gretelai_synthetic_text_to_sql
CREATE TABLE food_items (item_id INT, name VARCHAR(50), organic BOOLEAN, calories INT); INSERT INTO food_items (item_id, name, organic, calories) VALUES (1, 'Apple', true, 95), (2, 'Broccoli', true, 55), (3, 'Chips', false, 154), (4, 'Soda', false, 140);
What is the total calorie intake from organic food items?
SELECT SUM(calories) FROM food_items WHERE organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_routes (route_id INT, route_name TEXT, fare FLOAT, weekly_maintenance_cost FLOAT); INSERT INTO bus_routes (route_id, route_name, fare, weekly_maintenance_cost) VALUES (1, 'Red Line', 2.5, 400), (2, 'Green Line', 3.0, 600), (3, 'Blue Line', 2.0, 550);
What is the average fare for bus routes that have a weekly maintenance cost above $500?
SELECT AVG(fare) FROM bus_routes WHERE weekly_maintenance_cost > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_resources (id INT, name VARCHAR(50), category VARCHAR(50), total_resources_depleted DECIMAL(10, 2)); INSERT INTO mining_resources (id, name, category, total_resources_depleted) VALUES (1, 'Mining Operation 1', 'Coal', 25000.00), (2, 'Mining Operation 2', 'Coal', 30000.00);
What's the total resources depleted in the 'Coal' category?
SELECT SUM(total_resources_depleted) FROM mining_resources WHERE category = 'Coal';
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (property_id INT, size_sqft INT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO co_ownership (property_id, size_sqft, city, state) VALUES (1, 1200, 'Portland', 'OR'); INSERT INTO co_ownership (property_id, size_sqft, city, state) VALUES (2, 1500, 'Portland', 'OR');
What is the average size in square feet of properties with co-ownership in Portland, OR?
SELECT AVG(size_sqft) FROM co_ownership WHERE city = 'Portland' AND state = 'OR' AND property_id IN (SELECT property_id FROM co_ownership WHERE city = 'Portland' AND state = 'OR' GROUP BY property_id HAVING COUNT(*) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), PRIMARY KEY (name)); INSERT INTO neighborhoods (name, city, state, country) VALUES ('Bernal Heights', 'San Francisco', 'CA', 'USA');
What is the average listing price per square foot for each neighborhood in San Francisco?
SELECT name, AVG(listing_price/square_footage) as avg_price_per_sqft FROM real_estate_listings WHERE city = 'San Francisco' GROUP BY name ORDER BY avg_price_per_sqft DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (sale_id INT PRIMARY KEY, team_id INT, sale_date DATE, quantity INT);
Insert data into ticket_sales table
INSERT INTO ticket_sales (sale_id, team_id, sale_date, quantity) VALUES (1, 101, '2022-02-15', 500);
gretelai_synthetic_text_to_sql
CREATE TABLE model (model_id INT, name VARCHAR(50), organization_id INT, safety_score INT, creativity_score INT); INSERT INTO model VALUES (1, 'ModelA', 1, 85, 80), (2, 'ModelB', 2, 90, 85), (3, 'ModelC', 3, 80, 95), (4, 'ModelD', 1, 92, 88), (5, 'ModelE', 3, 88, 92); CREATE TABLE organization (organization_id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO organization VALUES (1, 'TechCo', 'for-profit'), (2, 'AI Inc.', 'non-profit'), (3, 'Alpha Corp.', 'for-profit');
What is the maximum safety score of a creative AI model developed by a for-profit organization?
SELECT MAX(model.safety_score) FROM model JOIN organization ON model.organization_id = organization.organization_id WHERE organization.type = 'for-profit' AND model.creativity_score >= 90;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, beds INT, rural BOOLEAN, built DATE); INSERT INTO hospitals (id, name, location, beds, rural, built) VALUES (1, 'Hospital A', 'Connecticut', 150, true, '2005-01-01'), (2, 'Hospital B', 'Connecticut', 200, true, '2008-01-01');
What is the total number of hospital beds in rural hospitals of Connecticut that were built before 2010?
SELECT SUM(beds) FROM hospitals WHERE location = 'Connecticut' AND rural = true AND built < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255)); INSERT INTO department (id, name) VALUES (1, 'Parks'); INSERT INTO department (id, name) VALUES (2, 'Transportation'); CREATE TABLE initiative (id INT, name VARCHAR(255), department_id INT, status VARCHAR(255)); INSERT INTO initiative (id, name, department_id, status) VALUES (1, 'Bike Share', 2, 'open'); INSERT INTO initiative (id, name, department_id, status) VALUES (2, 'Tree Inventory', 1, 'closed'); INSERT INTO initiative (id, name, department_id, status) VALUES (3, 'Park Improvements', 1, 'open');
What is the total number of open data initiatives by department in the city of Toronto?
SELECT SUM(i.id) FROM initiative i JOIN department d ON i.department_id = d.id WHERE d.name = 'Toronto' AND i.status = 'open';
gretelai_synthetic_text_to_sql
CREATE TABLE case_resolutions (resolution_id INT, case_id INT, resolution_date DATE); INSERT INTO case_resolutions (resolution_id, case_id, resolution_date) VALUES (1, 1, '2022-02-01'), (2, 2, '2022-04-15'), (3, 1, '2022-05-01');
What is the average time to resolution for cases, by case type, in the last year?
SELECT cases.case_type, AVG(DATEDIFF(case_resolutions.resolution_date, cases.open_date)) as avg_time_to_resolution FROM cases INNER JOIN case_resolutions ON cases.case_id = case_resolutions.case_id WHERE cases.open_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY cases.case_type;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, financially_vulnerable BOOLEAN); INSERT INTO clients (id, financially_vulnerable) VALUES (1, true), (2, false), (3, true);
Delete the record for a financially vulnerable individual.
DELETE FROM clients WHERE financially_vulnerable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Bears'), (2, 'Bills'); CREATE TABLE games (game_id INT, home_team_id INT, away_team_id INT, home_team_attendance INT); INSERT INTO games (game_id, home_team_id, away_team_id, home_team_attendance) VALUES (1, 1, 2, 45000), (2, 2, 1, 30000);
What is the average home game attendance for each team in the 2020 season?
SELECT t.team_name, AVG(g.home_team_attendance) FROM games g JOIN teams t ON g.home_team_id = t.team_id GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturing (id INT, spacecraft_name VARCHAR(50), cost INT); INSERT INTO spacecraft_manufacturing (id, spacecraft_name, cost) VALUES (1, 'Aries', 5000000), (2, 'Atlas', 7000000), (3, 'Titan', 9000000);
What is the average cost of manufacturing spacecrafts in the 'spacecraft_manufacturing' table?
SELECT AVG(cost) FROM spacecraft_manufacturing;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (id INT, name VARCHAR(255), species_type VARCHAR(255)); INSERT INTO fish_species (id, name, species_type) VALUES (1, 'Salmon', 'Coldwater'), (2, 'Tilapia', 'Tropical'); CREATE TABLE temperature_data (id INT, fish_id INT, record_date DATE, water_temp DECIMAL(5,2)); INSERT INTO temperature_data (id, fish_id, record_date, water_temp) VALUES (1, 1, '2022-01-01', 5.2), (2, 1, '2022-01-15', 4.9), (3, 2, '2022-01-01', 25.1), (4, 2, '2022-01-15', 25.6);
What is the minimum water temperature for coldwater fish species in January?
SELECT MIN(water_temp) FROM temperature_data JOIN fish_species ON temperature_data.fish_id = fish_species.id WHERE fish_species.species_type = 'Coldwater' AND MONTH(record_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mature_forest (id INT, tree_type VARCHAR(255), planted_date DATE, volume INT, tree_carbon_seq INT);
What is the total volume of timber produced by tree species with a carbon sequestration value greater than 30, grouped by tree type, in the mature_forest table?
SELECT tree_type, SUM(volume) FROM mature_forest WHERE tree_carbon_seq > 30 GROUP BY tree_type;
gretelai_synthetic_text_to_sql
CREATE TABLE trends (id INT PRIMARY KEY, trend_name VARCHAR(50));
Insert a new fashion trend 'Pleats' into the 'trends' table
INSERT INTO trends (id, trend_name) VALUES (2, 'Pleats');
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, item_name VARCHAR(255), quantity INT, shipping_date DATE, origin_country VARCHAR(50), destination_country VARCHAR(50));
Delete all records of refrigerator shipments to Mexico in December 2021 from the shipments table.
DELETE FROM shipments WHERE item_name = 'refrigerator' AND origin_country = 'USA' AND destination_country = 'Mexico' AND shipping_date BETWEEN '2021-12-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE condition_records (patient_id INT, condition VARCHAR(50)); INSERT INTO condition_records (patient_id, condition) VALUES (1, 'Anxiety'), (2, 'Depression'), (3, 'PTSD'), (4, 'Depression'), (5, 'Depression'), (6, 'Bipolar Disorder'), (7, 'Anxiety'), (8, 'Depression'); CREATE TABLE patient_location (patient_id INT, location VARCHAR(50)); INSERT INTO patient_location (patient_id, location) VALUES (1, 'California'), (2, 'Utah'), (3, 'Texas'), (4, 'Utah'), (5, 'Utah'), (6, 'Florida'), (7, 'California'), (8, 'Utah');
How many patients have been treated for depression in Utah?
SELECT COUNT(DISTINCT patient_id) FROM condition_records JOIN patient_location ON condition_records.patient_id = patient_location.patient_id WHERE condition = 'Depression' AND location = 'Utah';
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (name VARCHAR(255), ocean VARCHAR(255), date DATE); INSERT INTO deep_sea_expeditions (name, ocean, date) VALUES ('Challenger Expedition', 'Indian Ocean', '1872-12-07'), ('Galathea Expedition', 'Indian Ocean', '1845-12-24');
List all deep-sea expeditions and their dates in the Indian Ocean.
SELECT name, date FROM deep_sea_expeditions WHERE ocean = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE tourists (tourist_id INT, name TEXT, country TEXT, visit_date DATE); INSERT INTO tourists (tourist_id, name, country, visit_date) VALUES (1, 'John Doe', 'France', '2022-01-01'), (2, 'Jane Smith', 'Brazil', '2022-02-01'), (3, 'Minh Nguyen', 'Vietnam', '2021-12-31'), (4, 'Pierre Dupont', 'France', '2022-01-01'), (5, 'Emily Chen', 'Australia', '2022-02-01');
How many tourists visited each country in the last year?
SELECT country, COUNT(DISTINCT tourist_id) FROM tourists WHERE visit_date >= DATEADD(year, -1, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, report_date DATE, industry TEXT, incident_count INT); INSERT INTO incidents (id, report_date, industry, incident_count) VALUES (1, '2022-03-01', 'Construction', 15); INSERT INTO incidents (id, report_date, industry, incident_count) VALUES (2, '2022-04-01', 'Manufacturing', 20);
Which industries in the United States have the highest workplace safety incident rate in the last quarter?
SELECT industry, AVG(incident_count) as avg_incidents FROM incidents WHERE report_date >= DATE_TRUNC('quarter', NOW() - INTERVAL '1 quarter') GROUP BY industry ORDER BY avg_incidents DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain (id INTEGER, product_id VARCHAR(10), shipped_date DATE, expiration_date DATE);
Delete expired shipments from the supply_chain table.
DELETE FROM supply_chain WHERE shipped_date + INTERVAL '30 days' < CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, WorkoutDate DATE, Duration INT, WorkoutType VARCHAR(20)); INSERT INTO Workouts (WorkoutID, WorkoutDate, Duration, WorkoutType) VALUES (1, '2023-01-01', 60, 'Yoga'), (2, '2023-01-02', 90, 'Cycling'), (3, '2023-01-03', 75, 'Yoga');
What is the total workout time for yoga workouts in the month of January?
SELECT SUM(Duration) FROM Workouts WHERE WorkoutType = 'Yoga' AND WorkoutDate >= '2023-01-01' AND WorkoutDate <= '2023-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE bioprocess_engineering (id INT, region VARCHAR(50), information FLOAT); INSERT INTO bioprocess_engineering (id, region, information) VALUES (1, 'North America', 3500); INSERT INTO bioprocess_engineering (id, region, information) VALUES (2, 'Europe', 2800); INSERT INTO bioprocess_engineering (id, region, information) VALUES (3, 'Asia', 4200);
Show the total bioprocess engineering information for each region.
SELECT region, SUM(information) FROM bioprocess_engineering GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE football_matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), location VARCHAR(50), date DATE, attendance INT); INSERT INTO football_matches (id, home_team, away_team, location, date, attendance) VALUES (1, 'Real Madrid', 'Barcelona', 'Madrid', '2022-05-01', 65000); INSERT INTO football_matches (id, home_team, away_team, location, date, attendance) VALUES (2, 'Manchester United', 'Liverpool', 'Manchester', '2022-05-05', 70000);
How many football matches were held in the 'football_matches' table with a total attendance greater than 50000?
SELECT COUNT(*) FROM football_matches WHERE attendance > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_projects (id INT, project_name TEXT, state TEXT, material_cost FLOAT); INSERT INTO construction_projects (id, project_name, state, material_cost) VALUES (1, 'Park Plaza', 'Texas', 50000.00), (2, 'Downtown Tower', 'California', 150000.00), (3, 'Galleria Mall', 'Texas', 80000.00);
What is the average cost of construction materials per project in Texas?
SELECT AVG(material_cost) FROM construction_projects WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE RevenueByProduct (product VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO RevenueByProduct (product, revenue) VALUES ('Flower', 50000), ('Concentrates', 35000), ('Edibles', 40000), ('Topicals', 25000);
What is the total revenue generated by each product type, sorted by the total revenue in descending order?
SELECT product, SUM(revenue) as total_revenue FROM RevenueByProduct GROUP BY product ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_violations (violation_id INT, region VARCHAR(255)); INSERT INTO mental_health_parity_violations (violation_id, region) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'West'), (5, 'Northeast'), (6, 'Southeast'), (7, 'Midwest'), (8, 'West');
What is the total number of mental health parity violations by region?
SELECT region, COUNT(*) as total_violations FROM mental_health_parity_violations GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_records (id INT, company_id INT, funding_amount INT, funding_date DATE); INSERT INTO funding_records (id, company_id, funding_amount, funding_date) VALUES (7, 3, 700000, '2018-01-01'); INSERT INTO funding_records (id, company_id, funding_amount, funding_date) VALUES (8, 4, 400000, '2017-01-01');
What is the maximum funding amount for startups founded in 2019?
SELECT MAX(funding_amount) FROM funding_records JOIN companies ON funding_records.company_id = companies.id WHERE companies.founding_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Project_Timeline (id INT, project VARCHAR(30), phase VARCHAR(20), start_date DATE, end_date DATE, labor_cost FLOAT); INSERT INTO Project_Timeline (id, project, phase, start_date, end_date, labor_cost) VALUES (1, 'Green Tower', 'Planning', '2021-05-01', '2021-07-31', 50000.00), (2, 'Green Tower', 'Construction', '2021-08-01', '2022-05-31', 750000.00);
Update the timeline of the 'Green Tower' project to reflect a 10% increase in labor cost.
UPDATE Project_Timeline SET labor_cost = labor_cost * 1.10 WHERE project = 'Green Tower';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50));CREATE TABLE Investments (CustomerID INT, InvestmentType VARCHAR(10), Sector VARCHAR(10));INSERT INTO Customers VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Bob Johnson');INSERT INTO Investments VALUES (1,'Stocks','Technology'),(1,'Stocks','Healthcare'),(2,'Stocks','Technology'),(2,'Stocks','Healthcare'),(3,'Stocks','Healthcare');
What are the names of customers who have invested in both the technology and healthcare sectors?
SELECT DISTINCT c.Name FROM Customers c INNER JOIN Investments i ON c.CustomerID = i.CustomerID WHERE i.Sector IN ('Technology', 'Healthcare') GROUP BY c.CustomerID, c.Name HAVING COUNT(DISTINCT i.Sector) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (equipment_id INT, customer_country VARCHAR(50), sale_date DATE); INSERT INTO MilitaryEquipmentSales (equipment_id, customer_country, sale_date) VALUES (1, 'United States', '2014-01-01'), (2, 'United States', '2018-03-04');
Which military equipment was sold to the United States before 2015 and after 2017?
SELECT equipment_id FROM MilitaryEquipmentSales WHERE customer_country = 'United States' AND sale_date < '2015-01-01' UNION SELECT equipment_id FROM MilitaryEquipmentSales WHERE customer_country = 'United States' AND sale_date > '2017-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'HR'), (2, 'Operations'), (3, 'Engineering'); CREATE TABLE employees (id INT, name VARCHAR(255), gender VARCHAR(50), department_id INT); INSERT INTO employees (id, name, gender, department_id) VALUES (1, 'John', 'Male', 2), (2, 'Jane', 'Female', 3), (3, 'Mike', 'Male', 1), (4, 'Lucy', 'Female', 2), (5, 'Tom', 'Male', 2), (6, 'Sara', 'Female', 3), (7, 'Emma', 'Female', 1);
What is the percentage of female employees in each department for the mining company?
SELECT e.department_id, COUNT(CASE WHEN e.gender = 'Female' THEN 1 END) * 100.0 / COUNT(e.id) as female_percentage FROM employees e GROUP BY e.department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country TEXT, trial_success_rate REAL, therapeutic_area TEXT); INSERT INTO clinical_trials (country, trial_success_rate, therapeutic_area) VALUES ('Canada', 0.62, 'infectious diseases'), ('Brazil', 0.67, 'infectious diseases'), ('Russia', 0.58, 'infectious diseases'), ('India', 0.64, 'infectious diseases'), ('South Africa', 0.69, 'infectious diseases');
Which countries have the lowest average clinical trial success rate in infectious diseases?
SELECT country, AVG(trial_success_rate) as avg_trial_success_rate FROM clinical_trials WHERE therapeutic_area = 'infectious diseases' GROUP BY country ORDER BY avg_trial_success_rate ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_reports (id INT, title VARCHAR(255), author VARCHAR(255), published_date DATE);
What is the distribution of articles published by month in the 'monthly_reports' table?
SELECT MONTHNAME(published_date) as month, COUNT(*) as articles_published FROM monthly_reports GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance(customer_id INT, join_date DATE); INSERT INTO shariah_compliant_finance VALUES (1, '2022-04-01'), (2, '2022-03-15'), (3, '2022-01-01'), (4, '2022-05-10');
Determine the number of Shariah-compliant finance customers who joined after the first quarter of the year.
SELECT COUNT(*) FROM shariah_compliant_finance WHERE join_date > (SELECT MIN(join_date) + INTERVAL '3 months' FROM shariah_compliant_finance);
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, student_name VARCHAR(50), gender VARCHAR(10), prefers_open_pedagogy BOOLEAN); INSERT INTO students (student_id, student_name, gender, prefers_open_pedagogy) VALUES (1, 'John Doe', 'Male', true), (2, 'Jane Smith', 'Female', true);
What is the number of students who prefer open pedagogy by gender?
SELECT gender, SUM(prefers_open_pedagogy) FROM students GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE fare_collection (route_id INT, payment_type VARCHAR(10), fare DECIMAL(5,2)); INSERT INTO fare_collection (route_id, payment_type, fare) VALUES (1, 'Cash', 2.50), (1, 'Card', 3.00), (2, 'Cash', 2.75), (2, 'Card', 3.25);
Find the total fare collected from each payment type
SELECT payment_type, SUM(fare) as total_fare FROM fare_collection GROUP BY payment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_protocols (id INT PRIMARY KEY, chemical_name VARCHAR(100), protocol VARCHAR(500));
Add a new safety protocol for chemical LMN to the safety_protocols table.
INSERT INTO safety_protocols (id, chemical_name, protocol) VALUES (5, 'LMN', 'Use in a well-ventilated area. Keep away from heat and open flames.');
gretelai_synthetic_text_to_sql
CREATE TABLE Beds (Country TEXT, BedsPer1000 FLOAT); INSERT INTO Beds VALUES ('Russia', 8.1);
What is the number of hospital beds per 1000 people in Russia?
SELECT BedsPer1000 FROM Beds WHERE Country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE philanthropic_trends (organization_name TEXT, donation_amount INTEGER); INSERT INTO philanthropic_trends (organization_name, donation_amount) VALUES ('Effctive Altruism Funds', 50000), ('GiveWell', 40000), ('The Life You Can Save', 30000), ('Schistosomiasis Control Initiative', 10000);
Update the donation amount for 'GiveWell' to $55,000 in the 'philanthropic_trends' table.
UPDATE philanthropic_trends SET donation_amount = 55000 WHERE organization_name = 'GiveWell';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, tourism_type VARCHAR(255), expenditure DECIMAL(10, 2)); INSERT INTO tourism_stats (country, year, tourism_type, expenditure) VALUES ('Costa Rica', 2020, 'Eco-tourism', 500000), ('Costa Rica', 2020, 'Eco-tourism', 600000), ('Belize', 2020, 'Eco-tourism', 400000), ('Belize', 2020, 'Eco-tourism', 450000);
What was the total expenditure of eco-tourists in Costa Rica and Belize in 2020?
SELECT SUM(expenditure) AS total_expenditure FROM tourism_stats WHERE country IN ('Costa Rica', 'Belize') AND tourism_type = 'Eco-tourism' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams VALUES (1, 'Barcelona'); INSERT INTO teams VALUES (2, 'Real Madrid'); CREATE TABLE goals (team_id INT, goals_scored INT, season VARCHAR(10)); INSERT INTO goals VALUES (1, 85, '2020'); INSERT INTO goals VALUES (2, 90, '2020');
Find the number of goals scored by each team in the 2020 football season
SELECT teams.team_name, SUM(goals) as goals_scored FROM goals JOIN teams ON goals.team_id = teams.team_id WHERE goals.season = '2020' GROUP BY teams.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, type VARCHAR(10), region VARCHAR(10)); INSERT INTO customers (id, type, region) VALUES (1, 'postpaid', 'North'), (2, 'prepaid', 'North'), (3, 'postpaid', 'South'), (4, 'prepaid', 'South'); CREATE TABLE usage (customer_id INT, data_usage FLOAT); INSERT INTO usage (customer_id, data_usage) VALUES (1, 3.5), (2, 2.2), (3, 4.7), (4, 1.8);
What is the maximum data usage in GB for postpaid mobile customers in each region?
SELECT customers.region, MAX(usage.data_usage) FROM usage JOIN customers ON usage.customer_id = customers.id WHERE customers.type = 'postpaid' GROUP BY customers.region;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, CoverageLimit DECIMAL(10,2), RiskAssessmentScore INT); INSERT INTO Policyholders (PolicyID, CoverageLimit, RiskAssessmentScore) VALUES (1, 750000.00, 400), (2, 400000.00, 350), (4, 50000.00, 250); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 5000.00), (2, 4, 2500.00);
Update the risk assessment score for policyholder 4 to 600 based on their recent claim activity.
WITH UpdatedScores AS (UPDATE Policyholders SET RiskAssessmentScore = 600 WHERE PolicyID = 4 RETURNING *) SELECT * FROM UpdatedScores;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, player_name VARCHAR(255)); INSERT INTO players VALUES (1, 'Player 1'); INSERT INTO players VALUES (2, 'Player 2'); CREATE TABLE fouls (player_id INT, fouls INT, season VARCHAR(20)); INSERT INTO fouls VALUES (1, 3, '2021-2022'); INSERT INTO fouls VALUES (2, 4, '2021-2022');
Show the total number of fouls committed by each player in the 2021-2022 basketball season
SELECT players.player_name, SUM(fouls.fouls) as total_fouls FROM players JOIN fouls ON players.player_id = fouls.player_id WHERE fouls.season = '2021-2022' GROUP BY players.player_name;
gretelai_synthetic_text_to_sql