context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE MitigationActions (Country TEXT, Investment_Amount NUMERIC); INSERT INTO MitigationActions (Country, Investment_Amount) VALUES ('South Africa', 2000000), ('Egypt', 1500000), ('Morocco', 1000000);
Which countries have invested in climate mitigation in Africa?
SELECT DISTINCT Country FROM MitigationActions WHERE Investment_Amount IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE residential_buildings (id INT, city VARCHAR(100), state VARCHAR(50), energy_efficiency_rating FLOAT, construction_period DATE); INSERT INTO residential_buildings (id, city, state, energy_efficiency_rating, construction_period) VALUES (1, 'City A', 'California', 80, '2000-01-01'); INSERT INTO residential_buildings (id, city, state, energy_efficiency_rating, construction_period) VALUES (2, 'City B', 'California', 85, '2005-01-01');
What is the average energy efficiency rating of residential buildings in California, grouped by city and construction period?
SELECT city, YEAR(construction_period) AS construction_year, AVG(energy_efficiency_rating) AS avg_rating FROM residential_buildings WHERE state = 'California' GROUP BY city, YEAR(construction_period);
gretelai_synthetic_text_to_sql
CREATE TABLE taxi_trips (trip_id INT, vehicle_type VARCHAR(20), total_fare DECIMAL(10,2)); CREATE TABLE vehicles (vehicle_id INT, vehicle_type VARCHAR(20), is_wheelchair_accessible BOOLEAN); INSERT INTO taxi_trips (trip_id, vehicle_type, total_fare) VALUES (1, 'Taxi', 25.00), (2, 'Wheelchair Accessible Taxi', 30.00); INSERT INTO vehicles (vehicle_id, vehicle_type, is_wheelchair_accessible) VALUES (1, 'Taxi', false), (2, 'Wheelchair Accessible Taxi', true);
What is the total revenue generated from wheelchair accessible taxis in New York city?
SELECT SUM(tt.total_fare) FROM taxi_trips tt JOIN vehicles v ON tt.vehicle_type = v.vehicle_type WHERE v.is_wheelchair_accessible = true AND tt.vehicle_type = 'Wheelchair Accessible Taxi';
gretelai_synthetic_text_to_sql
CREATE TABLE brute_force_attacks (id INT, ip_address VARCHAR(50), attack_type VARCHAR(50), timestamp TIMESTAMP); INSERT INTO brute_force_attacks (id, ip_address, attack_type, timestamp) VALUES (1, '192.168.1.100', 'ssh', '2022-01-01 10:00:00'), (2, '10.0.0.2', 'ftp', '2022-01-02 12:00:00');
List all the unique IP addresses that attempted a brute force attack in the last week, and the corresponding attack type.
SELECT DISTINCT ip_address, attack_type FROM brute_force_attacks WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE Investment_Strategies (strategy_id INT, strategy_name VARCHAR(30), AUM DECIMAL(12,2)); INSERT INTO Investment_Strategies (strategy_id, strategy_name, AUM) VALUES (1, 'Equity', 5000000.00), (2, 'Fixed Income', 3000000.00), (3, 'Alternatives', 2000000.00);
What are the total assets under management (AUM) for each investment strategy, including a 3% management fee?
SELECT strategy_name, SUM(AUM * 1.03) AS total_AUM FROM Investment_Strategies GROUP BY strategy_name;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups(id INT, company_name TEXT, location TEXT, funding_amount DECIMAL(10,2), quarter INT, year INT);
Delete records for biotech startups from India that received no funding.
DELETE FROM biotech_startups WHERE location = 'India' AND funding_amount = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name TEXT, year INT, participants INT); INSERT INTO community_development (id, initiative_name, year, participants) VALUES (1, 'Adult Literacy Program', 2020, 500), (2, 'Youth Job Training', 2020, 300), (3, 'Solar Energy Workshop', 2021, 400), (4, 'Women in Agriculture Conference', 2021, 600);
List the top 2 community development initiatives by the number of participants, in descending order, for each year in the 'community_development' schema?
SELECT initiative_name, year, participants, RANK() OVER (PARTITION BY year ORDER BY participants DESC) AS rank FROM community_development;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_units (id INT, city VARCHAR(20), units INT); INSERT INTO housing_units (id, city, units) VALUES (1, 'New York', 200), (2, 'Seattle', 100), (3, 'Oakland', 300), (4, 'Berkeley', 150);
How many inclusive housing units are available in each city?
SELECT city, SUM(units) FROM housing_units GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), runtime INT, release_year INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO tv_shows (id, title, runtime, release_year, country, genre) VALUES (1, 'Show1', 120, 2016, 'Mexico', 'Comedy'), (2, 'Show2', 90, 2017, 'Mexico', 'Drama'), (3, 'Show3', 105, 2018, 'Mexico', 'Action');
What is the total runtime of the TV shows produced in Mexico and released after 2015, categorized by genre?
SELECT genre, SUM(runtime) FROM tv_shows WHERE release_year > 2015 AND country = 'Mexico' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE football_players (id INT, name VARCHAR(50), age INT, sport VARCHAR(50));
Who is the oldest football player in the NFL?
SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY age DESC) as rank FROM football_players WHERE sport = 'NFL') subquery WHERE rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE city_education (city TEXT, num_schools INTEGER, num_libraries INTEGER); INSERT INTO city_education (city, num_schools, num_libraries) VALUES ('CityA', 35, 20), ('CityB', 20, 30), ('CityC', 40, 15), ('CityD', 10, 35);
Which cities have a higher number of schools than libraries?
SELECT city FROM city_education WHERE num_schools > num_libraries;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_figures (drug VARCHAR(255), country VARCHAR(255), sales INT); INSERT INTO sales_figures (drug, country, sales) VALUES ('Drug Y', 'Canada', 1000000);
What is the total sales of drug Y in Canada?
SELECT drug, SUM(sales) FROM sales_figures WHERE drug = 'Drug Y' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (City varchar(20)); CREATE TABLE Properties (PropertyID int, City varchar(20), Sustainable varchar(5)); INSERT INTO Cities (City) VALUES ('Seattle'); INSERT INTO Properties (PropertyID, City, Sustainable) VALUES (1, 'Seattle', 'Yes'); INSERT INTO Properties (PropertyID, City, Sustainable) VALUES (2, 'Portland', 'No'); INSERT INTO Properties (PropertyID, City, Sustainable) VALUES (3, 'Seattle', 'Yes');
What is the total number of properties in each city that have sustainable features?
SELECT Properties.City, COUNT(Properties.PropertyID) FROM Properties INNER JOIN Cities ON Properties.City = Cities.City WHERE Properties.Sustainable = 'Yes' GROUP BY Properties.City;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, age INT, region TEXT); INSERT INTO clients (id, name, age, region) VALUES (1, 'Fatima Fernandez', 40, 'Florida'); CREATE TABLE attorneys (id INT, name TEXT, region TEXT, title TEXT); INSERT INTO attorneys (id, name, region, title) VALUES (1, 'Ricardo Rodriguez', 'Florida', 'Partner');
What is the average age of clients in the 'Florida' region?
SELECT AVG(age) FROM clients WHERE region = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), organic BOOLEAN, weight FLOAT, supplier_id INT);
Show the total weight of organic products supplied by each supplier.
SELECT s.name, SUM(p.weight) FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id WHERE p.organic = 't' GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), sector VARCHAR(50));
How many climate adaptation projects have been implemented in Small Island Developing States?
SELECT COUNT(*) FROM climate_projects WHERE location LIKE '%Small Island Developing States%' AND sector = 'adaptation';
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact ( id INT PRIMARY KEY, element VARCHAR(10), impact_score INT );
Delete all records from the environmental_impact table that have a value less than 5 for the impact_score column
DELETE FROM environmental_impact WHERE impact_score < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (museum_id INT, name VARCHAR(50), city VARCHAR(50), opening_year INT); INSERT INTO museums (museum_id, name, city, opening_year) VALUES (1, 'Tate Modern', 'London', 2000); CREATE TABLE exhibitions (exhibition_id INT, title VARCHAR(50), year INT, museum_id INT, art_count INT); INSERT INTO exhibitions (exhibition_id, title, year, museum_id, art_count) VALUES (1, 'First Exhibition', 2000, 1, 100);
Insert new records for an exhibition held at the Tate Modern in London.
INSERT INTO exhibitions (exhibition_id, title, year, museum_id, art_count) VALUES (2, 'New Artists', 2023, 1, 75);
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), dob DATE);CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE);
What is the number of clients who have made a transaction on their birthday in Q3 2023?
SELECT COUNT(*) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE DATE_FORMAT(t.transaction_date, '%Y') - DATE_FORMAT(c.dob, '%Y') = (YEAR(CURDATE()) - YEAR(c.dob)) AND MONTH(t.transaction_date) = MONTH(c.dob) AND DAY(t.transaction_date) = DAY(c.dob) AND t.transaction_date BETWEEN '2023-07-01' AND '2023-09-30'
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (nid INT, name VARCHAR(255)); CREATE TABLE events (eid INT, nid INT, date DATE, type VARCHAR(255)); INSERT INTO neighborhoods VALUES (1, 'Westside'), (2, 'Eastside'); INSERT INTO events VALUES (1, 1, '2021-01-01', 'Community meeting'), (2, 2, '2021-02-01', 'Neighborhood watch');
How many community policing events were held in each neighborhood in the last year?
SELECT n.name, YEAR(e.date) as year, COUNT(e.eid) as num_events FROM neighborhoods n JOIN events e ON n.nid = e.nid WHERE e.date >= '2021-01-01' GROUP BY n.nid, year;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), manufacturer VARCHAR(50), rating DECIMAL(3,2));
What is the average rating for each garment manufacturer?
SELECT manufacturer, AVG(rating) as avg_rating FROM products GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Gender, Department, Salary, HireDate) VALUES (1, 'Male', 'IT', 70000, '2021-01-01'), (2, 'Female', 'IT', 65000, '2021-01-01'), (3, 'Male', 'HR', 60000, '2021-01-01'), (4, 'Female', 'Marketing', 80000, '2021-01-01');
What is the total salary cost for the HR department in 2021?
SELECT SUM(Salary) FROM Employees WHERE Department = 'HR' AND YEAR(HireDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE network_type (network_type VARCHAR(20)); INSERT INTO network_type (network_type) VALUES ('5G'), ('4G'), ('3G'); CREATE TABLE customers (customer_id INT, name VARCHAR(50), geographic_area VARCHAR(20), network_type VARCHAR(20)); INSERT INTO customers (customer_id, name, geographic_area, network_type) VALUES (1, 'John Doe', 'urban', '5G'); CREATE TABLE mobile_data_usage (customer_id INT, month INT, data_usage INT); INSERT INTO mobile_data_usage (customer_id, month, data_usage) VALUES (1, 1, 1500);
What is the average data usage per mobile subscriber in the 'urban' geographic area, grouped by network type?
SELECT network_type, AVG(data_usage) FROM mobile_data_usage JOIN customers ON mobile_data_usage.customer_id = customers.customer_id JOIN network_type ON customers.network_type = network_type.network_type WHERE customers.geographic_area = 'urban' GROUP BY network_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Data (flight_date DATE, aircraft_model VARCHAR(255), flight_time TIME); INSERT INTO Flight_Data (flight_date, aircraft_model, flight_time) VALUES ('2020-01-01', 'Airbus A320', '05:00:00'), ('2020-02-01', 'Boeing 737', '04:00:00'), ('2020-03-01', 'Airbus A320', '05:30:00'), ('2020-04-01', 'Boeing 747', '07:00:00'), ('2020-05-01', 'Airbus A320', '04:45:00');
What is the average flight time for Airbus A320 aircraft?
SELECT AVG(EXTRACT(EPOCH FROM flight_time)) / 60.0 AS avg_flight_time FROM Flight_Data WHERE aircraft_model = 'Airbus A320';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, sector, funding) VALUES (3, 'StartupC', 'France', 'Biotechnology', 3000000);
What is the minimum funding obtained by startups in the biotechnology sector located in France?
SELECT MIN(funding) FROM startups WHERE sector = 'Biotechnology' AND location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE journalists_extended (name VARCHAR(50), gender VARCHAR(10), years_experience INT, salary DECIMAL(10,2)); INSERT INTO journalists_extended (name, gender, years_experience, salary) VALUES ('Alice Johnson', 'Female', 12, 55000.00), ('Bob Smith', 'Male', 8, 45000.00), ('Charlie Brown', 'Male', 15, 65000.00), ('Dana Rogers', 'Female', 20, 75000.00), ('Evan Green', 'Male', 7, 35000.00);
Who are the journalists with more than 10 years of experience?
SELECT name, years_experience FROM journalists_extended WHERE years_experience > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, year INT, programs INT); INSERT INTO education_programs (id, year, programs) VALUES (1, 2019, 120), (2, 2020, 150), (3, 2021, 250), (4, 2022, 300);
How many community education programs were held in 2021 and 2022?
SELECT SUM(programs) FROM education_programs WHERE year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE CityG_Fares (fare_id INT, fare FLOAT, payment_type VARCHAR(20), route_type VARCHAR(20)); INSERT INTO CityG_Fares (fare_id, fare, payment_type, route_type) VALUES (1, 2.5, 'Cash', 'Bus'), (2, 3.2, 'Card', 'Train'), (3, 1.8, 'Cash', 'Tram'), (4, 4.1, 'Card', 'Bus');
What is the minimum fare for public transportation in CityG?
SELECT MIN(fare) FROM CityG_Fares;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_temperature (id INT, crop VARCHAR(50), temperature FLOAT, record_date DATE); INSERT INTO crop_temperature (id, crop, temperature, record_date) VALUES (1, 'Corn', 30.5, '2022-04-01'), (2, 'Soybeans', 20.2, '2022-04-01'), (3, 'Cotton', 40.0, '2022-04-01'), (4, 'Wheat', 15.7, '2022-04-01'), (5, 'Corn', 32.1, '2022-04-02'), (6, 'Soybeans', 22.8, '2022-04-02'), (7, 'Cotton', 41.5, '2022-04-02'), (8, 'Wheat', 17.3, '2022-04-02'), (9, 'Corn', 35.0, '2022-04-03'), (10, 'Soybeans', 25.6, '2022-04-03');
What is the average temperature recorded for corn crops in India over the last month?
SELECT AVG(temperature) FROM crop_temperature WHERE crop = 'Corn' AND record_date IN (SELECT record_date FROM satellite_images WHERE farm_id IN (SELECT id FROM farmers WHERE location = 'India')) AND record_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name TEXT);CREATE TABLE emergencies (id INT, city_id INT, response_time INT);
What is the maximum response time for emergency calls in each city, in minutes?
SELECT c.name, MAX(e.response_time)/60.0 AS max_response_time_minutes FROM cities c JOIN emergencies e ON c.id = e.city_id GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_materials (id INT, name VARCHAR(255), recycling_rate DECIMAL(5,2)); INSERT INTO waste_materials (id, name, recycling_rate) VALUES (1, 'Glass', 40), (2, 'Plastic', 25), (3, 'Paper', 60), (4, 'Metal', 70);
How can I update the recycling rate for 'Glass' material to 45%?
UPDATE waste_materials SET recycling_rate = 45 WHERE name = 'Glass';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, ExhibitionName VARCHAR(255)); INSERT INTO Exhibitions (ExhibitionID, ExhibitionName) VALUES (1, 'Modern Art'); INSERT INTO Exhibitions (ExhibitionID, ExhibitionName) VALUES (2, 'Natural History'); CREATE TABLE Visitors (VisitorID INT, ExhibitionID INT, HasCompletedSurvey BOOLEAN); INSERT INTO Visitors (VisitorID, ExhibitionID, HasCompletedSurvey) VALUES (1, 1, true); INSERT INTO Visitors (VisitorID, ExhibitionID, HasCompletedSurvey) VALUES (2, 1, false); INSERT INTO Visitors (VisitorID, ExhibitionID, HasCompletedSurvey) VALUES (3, 2, true); CREATE TABLE SurveyResults (SurveyID INT, VisitorID INT, ExhibitionRating INT); INSERT INTO SurveyResults (SurveyID, VisitorID, ExhibitionRating) VALUES (1, 1, 9); INSERT INTO SurveyResults (SurveyID, VisitorID, ExhibitionRating) VALUES (2, 3, 8);
What is the average rating for each exhibition from visitors who have completed a survey?
SELECT E.ExhibitionName, AVG(SR.ExhibitionRating) as AverageRating FROM Exhibitions E INNER JOIN Visitors V ON E.ExhibitionID = V.ExhibitionID INNER JOIN SurveyResults SR ON V.VisitorID = SR.VisitorID WHERE V.HasCompletedSurvey = true GROUP BY E.ExhibitionName;
gretelai_synthetic_text_to_sql
CREATE TABLE podcasts (title VARCHAR(255), host VARCHAR(255), date DATE, duration INT);
What is the average duration of podcasts in the podcasts table published by 'Eva'?
SELECT AVG(duration) FROM podcasts WHERE host = 'Eva';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (asset_name VARCHAR(255), regulation_name VARCHAR(255), region VARCHAR(255)); INSERT INTO regulatory_frameworks (asset_name, regulation_name, region) VALUES ('CryptoKitties', 'CK Regulation 1.0', 'Global'), ('CryptoPunks', 'CP Regulation 1.0', 'Asia');
List all transactions associated with smart contracts in the 'Asia' region.
SELECT t.tx_hash FROM transactions t INNER JOIN smart_contracts s ON t.smart_contract_id = s.id INNER JOIN regulatory_frameworks r ON s.asset_name = r.asset_name WHERE r.region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerDate date, Program varchar(50)); INSERT INTO Volunteers (VolunteerID, VolunteerDate, Program) VALUES (1, '2022-01-01', 'Education'), (2, '2022-02-01', 'Healthcare'), (3, '2022-01-15', 'Food Support');
Count the number of volunteers who engaged in each program in H1 2022, grouped by program.
SELECT Program, COUNT(*) as NumberOfVolunteers FROM Volunteers WHERE YEAR(VolunteerDate) = 2022 AND MONTH(VolunteerDate) <= 6 GROUP BY Program;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_creatures (id INT, creature_name TEXT, discovery_date DATE); INSERT INTO deep_sea_creatures (id, creature_name, discovery_date) VALUES (1, 'Snailfish', '2014-08-04'); INSERT INTO deep_sea_creatures (id, creature_name, discovery_date) VALUES (2, 'Yeti Crab', '2005-03-26');
List all deep-sea creatures discovered since 2010.
SELECT creature_name FROM deep_sea_creatures WHERE discovery_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE academic_publications (id INT, faculty_id INT, author_gender VARCHAR(50)); INSERT INTO academic_publications (id, faculty_id, author_gender) VALUES (1, 1, 'Female'), (2, 2, 'Male'), (3, 3, 'Non-binary'), (4, 4, 'Female'), (5, 5, 'Male');
What is the total number of academic publications by female faculty members?
SELECT COUNT(*) FROM academic_publications WHERE author_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, TotalDonation FLOAT); INSERT INTO Donors (DonorID, DonorName, TotalDonation) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00), (3, 'Alice Johnson', 800.00);
Identify the top 3 donors by total donation amount in Q1 2021.
SELECT DonorName, SUM(TotalDonation) AS TotalDonation FROM Donors WHERE DonationDate BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY DonorName ORDER BY TotalDonation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE completed_training (worker_id INT, training_type VARCHAR(50)); INSERT INTO completed_training (worker_id, training_type) VALUES (1, 'Cultural Competency'), (2, 'Cultural Competency'), (3, 'Cultural Competency'), (4, 'Diversity Training');
What is the average age of community health workers who have completed cultural competency training?
SELECT AVG(age) as avg_age FROM community_health_workers chw INNER JOIN completed_training ct ON chw.worker_id = ct.worker_id;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID INT, Ethnicity VARCHAR(20), Training VARCHAR(30), Salary DECIMAL(10,2)); INSERT INTO EmployeeTraining (EmployeeID, Ethnicity, Training, Salary) VALUES (1, 'Indigenous', 'Cultural Sensitivity', 70000.00), (2, 'African', 'Cultural Sensitivity', 75000.00);
What is the minimum salary for employees who identify as Indigenous and have completed cultural sensitivity training?
SELECT MIN(Salary) FROM EmployeeTraining WHERE Ethnicity = 'Indigenous' AND Training = 'Cultural Sensitivity';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature_data (data_id INT, date DATE, temperature FLOAT);
Display the earliest recorded date in the 'ocean_temperature_data' table.
SELECT MIN(date) FROM ocean_temperature_data;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT PRIMARY KEY, home_team VARCHAR(50), away_team VARCHAR(50), city VARCHAR(50), stadium VARCHAR(50), game_date DATE);
Insert a new record for a baseball game between the "Yankees" and "Red Sox" into the "games" table
INSERT INTO games (game_id, home_team, away_team, city, stadium, game_date) VALUES (101, 'Yankees', 'Red Sox', 'New York', 'Yankee Stadium', '2022-07-01');
gretelai_synthetic_text_to_sql
CREATE SCHEMA renewable_energy; CREATE TABLE solar_projects (project_name VARCHAR(255), installed_capacity INT); INSERT INTO solar_projects (project_name, installed_capacity) VALUES ('Sunrise Solar Farm', 100000), ('Windy Solar Park', 120000), ('Solar Bliss Ranch', 75000);
What are the total installed solar capacities for all renewable energy projects in the renewable_energy schema?
SELECT SUM(installed_capacity) FROM renewable_energy.solar_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, name VARCHAR(50), address VARCHAR(50)); INSERT INTO users (user_id, name, address) VALUES (1, 'John Doe', 'rural'), (2, 'Jane Smith', 'urban'); CREATE TABLE adoptions (adoption_id INT, animal_id INT, user_id INT); INSERT INTO adoptions (adoption_id, animal_id, user_id) VALUES (1, 101, 1), (2, 102, 2); CREATE TABLE animals (animal_id INT, animal_name VARCHAR(50)); INSERT INTO animals (animal_id, animal_name) VALUES (101, 'Dog'), (102, 'Cat');
What is the average number of animals adopted by users in 'urban' areas?
SELECT AVG(adoptions.adoption_id) FROM adoptions INNER JOIN users ON adoptions.user_id = users.user_id WHERE users.address = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE victims (victim_id INT, first_name VARCHAR(20), last_name VARCHAR(20));
Insert new records into the 'victims' table with victim_id 2001, 2002, first_name 'Victoria', 'Victor', last_name 'Martin'
INSERT INTO victims (victim_id, first_name, last_name) VALUES (2001, 'Victoria', 'Martin'), (2002, 'Victor', 'Martin');
gretelai_synthetic_text_to_sql
CREATE TABLE Studio (studio_id INT, studio_name VARCHAR(50), city VARCHAR(50)); INSERT INTO Studio (studio_id, studio_name, city) VALUES (1, 'DreamWorks', 'Los Angeles'), (2, 'Warner Bros.', 'Los Angeles'); CREATE TABLE Movie (movie_id INT, title VARCHAR(50), rating DECIMAL(2,1), studio_id INT); INSERT INTO Movie (movie_id, title, rating, studio_id) VALUES (1, 'Shrek', 7.8, 1), (2, 'The Matrix', 8.7, 1), (3, 'Casablanca', 8.5, 2);
What is the average rating of movies produced by studios located in 'Los Angeles'?
SELECT AVG(m.rating) FROM Movie m JOIN Studio s ON m.studio_id = s.studio_id WHERE s.city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE VoterData (id INT, name VARCHAR(50), age INT, state VARCHAR(50), registered BOOLEAN); INSERT INTO VoterData (id, name, age, state, registered) VALUES (1, 'John Doe', 75, 'New York', true), (2, 'Jane Smith', 45, 'California', true), (3, 'Bob Johnson', 72, 'Florida', true), (4, 'Alice Williams', 55, 'Texas', false), (5, 'Jim Brown', 71, 'New York', true);
What is the total number of registered voters in the "VoterData" table, per state, for voters who are over 70 years old?
SELECT state, COUNT(*) as num_voters FROM VoterData WHERE age > 70 AND registered = true GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (country VARCHAR(20), sector VARCHAR(20), co2_emissions INT); INSERT INTO co2_emissions (country, sector, co2_emissions) VALUES ('Japan', 'transportation', 240000), ('South Africa', 'transportation', 180000);
Compare the CO2 emissions of the transportation sector in Japan and South Africa.
SELECT co2_emissions FROM co2_emissions WHERE country = 'Japan' INTERSECT SELECT co2_emissions FROM co2_emissions WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE membership_data (member_id INT, join_date DATE); INSERT INTO membership_data (member_id, join_date) VALUES (1, '2021-01-05'), (2, '2021-02-12'), (3, '2021-03-20'), (4, '2021-04-28'), (5, '2021-05-03');
How many members joined in each month of 2021?
SELECT EXTRACT(MONTH FROM join_date) AS month, COUNT(*) AS members_joined FROM membership_data WHERE join_date >= '2021-01-01' AND join_date < '2022-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Genres (id INT, genre VARCHAR(50)); CREATE TABLE Movies (id INT, title VARCHAR(100), genre_id INT, runtime INT, release_year INT); INSERT INTO Genres (id, genre) VALUES (1, 'Animated'), (2, 'Action'); INSERT INTO Movies (id, title, genre_id, runtime, release_year) VALUES (1, 'Movie1', 1, 80, 2012), (2, 'Movie2', 1, 100, 2013), (3, 'Movie3', 2, 120, 2016);
What is the average runtime of animated movies released between 2010 and 2015?
SELECT AVG(runtime) FROM Movies WHERE genre_id = (SELECT id FROM Genres WHERE genre = 'Animated') AND release_year BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(50), eco_friendly BOOLEAN);
List all garment manufacturers that use eco-friendly materials, ordered alphabetically.
SELECT name FROM manufacturers WHERE eco_friendly = TRUE ORDER BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (id INT, institution_name VARCHAR(255), country VARCHAR(255), assets FLOAT, ROA FLOAT); INSERT INTO socially_responsible_lending (id, institution_name, country, assets, ROA) VALUES (1, 'Green Lending Brazil', 'Brazil', 1500000.0, 0.06), (2, 'Sustainable Finance Argentina', 'Argentina', 2000000.0, 0.05), (3, 'Eco Lending Chile', 'Chile', 1000000.0, 0.07);
Calculate the total assets of socially responsible lending institutions in South America with a ROA greater than 5%.
SELECT SUM(assets) FROM socially_responsible_lending WHERE country LIKE 'South America' AND ROA > 0.05;
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (id INT, publication_year INT, topic VARCHAR(255)); INSERT INTO research_papers (id, publication_year, topic) VALUES (1, 2012, 'AI Safety'), (2, 2013, 'Explainable AI'), (3, 2018, 'Algorithmic Fairness'), (4, 2019, 'Creative AI'), (5, 2020, 'AI Safety'), (6, 2021, 'AI Safety'), (7, 2021, 'AI Safety'), (8, 2021, 'AI Safety');
Determine the maximum number of AI safety research papers published in a single year
SELECT MAX(publication_year) FROM research_papers WHERE topic = 'AI Safety';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (ProductID int, Price decimal, FairTrade boolean);
What is the total revenue generated from the sale of fair trade certified products?
SELECT SUM(Price) FROM Sales WHERE FairTrade = true;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (plant_id INT, state VARCHAR(20), operational_date DATE); INSERT INTO plants (plant_id, state, operational_date) VALUES (1, 'New York', '2001-01-01'), (2, 'New York', '2011-01-01'), (3, 'California', '1991-01-01');
How many water treatment plants in the state of New York have been operational for more than 20 years?
SELECT COUNT(*) FROM plants WHERE state = 'New York' AND operational_date < DATE_SUB(CURDATE(), INTERVAL 20 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, domain TEXT, members INT); INSERT INTO unions (id, name, domain, members) VALUES (1, 'International Association of Machinists and Aerospace Workers', 'Aerospace, Defense, Machinists', 350000); INSERT INTO unions (id, name, domain, members) VALUES (2, 'National Association of Government Employees', 'Government, Defense', 200000);
Delete all records of unions that focus on 'Defense' and have less than 250,000 members.
DELETE FROM unions WHERE domain = 'Defense' AND members < 250000;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (id INT PRIMARY KEY, region VARCHAR(20), initiative TEXT);
Insert new records into 'conservation_initiatives' table
INSERT INTO conservation_initiatives (id, region, initiative) VALUES (1, 'Central', 'Rainwater Harvesting'), (2, 'Great Lakes', 'Smart Irrigation Systems'), (3, 'Plains', 'Greywater Recycling');
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParityViolations (Id INT, State VARCHAR(2), Year INT, ViolationCount INT); INSERT INTO MentalHealthParityViolations (Id, State, Year, ViolationCount) VALUES (1, 'CA', 2020, 120), (2, 'TX', 2020, 150), (3, 'CA', 2021, 145), (4, 'TX', 2021, 175), (5, 'NY', 2020, 105), (6, 'FL', 2021, 130);
How many mental health parity violations were reported in California and Texas in 2020 and 2021?
SELECT State, SUM(ViolationCount) as TotalViolations FROM MentalHealthParityViolations WHERE State IN ('CA', 'TX') AND Year BETWEEN 2020 AND 2021 GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Chicago'), (2, 'Houston'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, destination VARCHAR(255)); INSERT INTO packages (id, warehouse_id, weight, destination) VALUES (1, 1, 50.3, 'Texas'), (2, 1, 30.1, 'California'), (3, 2, 70.0, 'Texas');
What is the average weight of packages shipped to Texas from warehouse 1?
SELECT AVG(weight) FROM packages WHERE warehouse_id = 1 AND destination = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE population (id INT, state VARCHAR(20), population INT); INSERT INTO population (id, state, population) VALUES (1, 'New South Wales', 8000000), (2, 'New South Wales', 8500000), (3, 'New South Wales', 9000000); CREATE TABLE water_consumption (id INT, state VARCHAR(20), consumption FLOAT); INSERT INTO water_consumption (id, state, consumption) VALUES (1, 'New South Wales', 300000000), (2, 'New South Wales', 325000000), (3, 'New South Wales', 350000000);
What is the average water consumption per capita in New South Wales?
SELECT AVG(consumption / population) FROM water_consumption, population WHERE water_consumption.state = population.state AND state = 'New South Wales';
gretelai_synthetic_text_to_sql
CREATE TABLE mlb_homeruns (player_id INT, player_name TEXT, team_id INT, league TEXT, homeruns INT); INSERT INTO mlb_homeruns (player_id, player_name, team_id, league, homeruns) VALUES (1, 'Aaron Judge', 19, 'MLB', 62), (2, 'Paul Goldschmidt', 14, 'MLB', 35);
What is the average number of home runs hit by the top 3 home run hitters in the 2022 MLB season?
SELECT AVG(homeruns) AS avg_homeruns FROM (SELECT homeruns FROM mlb_homeruns ORDER BY homeruns DESC LIMIT 3) AS top_3_hitters;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10)); CREATE TABLE MentalHealthConditions (ConditionID INT, PatientID INT, Condition VARCHAR(50));
What are the patient demographics and their respective mental health conditions?
SELECT Patients.Age, Patients.Gender, MentalHealthConditions.Condition FROM Patients INNER JOIN MentalHealthConditions ON Patients.PatientID = MentalHealthConditions.PatientID;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (MetricID INT, Metric VARCHAR(50)); CREATE TABLE MentalHealthScores (MH_ID INT, MetricID INT, MentalHealthScore INT); INSERT INTO HealthEquityMetrics (MetricID, Metric) VALUES (1, 'Low'), (2, 'Medium'), (3, 'High'); INSERT INTO MentalHealthScores (MH_ID, MetricID, MentalHealthScore) VALUES (1, 1, 85), (2, 1, 90), (3, 2, 75), (4, 2, 70), (5, 3, 80), (6, 3, 85), (7, 1, 65), (8, 1, 70), (9, 2, 80), (10, 2, 85);
What is the maximum mental health score by patient's health equity metric score?
SELECT m.Metric, MAX(mhs.MentalHealthScore) as Max_Score FROM MentalHealthScores mhs JOIN HealthEquityMetrics m ON mhs.MetricID = m.MetricID GROUP BY m.Metric;
gretelai_synthetic_text_to_sql
CREATE TABLE DailyStreams(id INT, genre VARCHAR(10), region VARCHAR(10), streams INT, date DATE);
What is the number of streams per day for the "electronic" genre in the North American region for the year 2020?
SELECT date, AVG(CAST(streams AS FLOAT)/COUNT(date)) AS streams_per_day FROM DailyStreams WHERE genre = 'electronic' AND region = 'North American' AND year = 2020 GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), avg_depth FLOAT); INSERT INTO marine_species (species_id, species_name, avg_depth) VALUES (1, 'Shark', 500), (2, 'Clownfish', 10);
What is the average depth (in meters) for 'Shark' species?
SELECT AVG(avg_depth) FROM marine_species WHERE species_name = 'Shark';
gretelai_synthetic_text_to_sql
CREATE TABLE DisabilityAccommodations (AccommodationID INT, DisabilityType VARCHAR(50), AccommodationDate DATE); INSERT INTO DisabilityAccommodations VALUES (1, 'Mobility Impairment', '2022-01-01'), (2, 'Visual Impairment', '2022-01-05'), (3, 'Hearing Impairment', '2022-01-10'), (4, 'Mobility Impairment', '2022-02-15'), (5, 'Learning Disability', '2022-03-01');
How many disability accommodations were provided per month in 2022?
SELECT DATE_TRUNC('month', AccommodationDate) as Month, COUNT(*) as NumAccommodations FROM DisabilityAccommodations WHERE YEAR(AccommodationDate) = 2022 GROUP BY Month ORDER BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE orbital_speed (id INT, satellite_name VARCHAR(50), orbital_speed FLOAT); INSERT INTO orbital_speed (id, satellite_name, orbital_speed) VALUES (1, 'ISS', 7662), (2, 'GPS', 14000), (3, 'Starlink', 9000);
What is the minimum orbital speed required for a satellite to maintain orbit around Earth?
SELECT MIN(orbital_speed) FROM orbital_speed;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(100), domain VARCHAR(50)); INSERT INTO Projects (id, name, domain) VALUES (1, 'Dam Construction', 'Water Supply'), (2, 'Road Pavement', 'Transportation'), (3, 'Building Foundation', 'Construction');
What is the average construction cost for projects in the water supply domain?
SELECT AVG(construction_cost) FROM Projects WHERE domain = 'Water Supply';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (region VARCHAR(20), efficiency INT);CREATE TABLE carbon_pricing (region VARCHAR(20), price DECIMAL(5,2));
Provide a cross-tabulation of energy efficiency and carbon pricing by region
SELECT e.region, e.efficiency, c.price FROM energy_efficiency e JOIN carbon_pricing c ON e.region = c.region;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_records (employee_id INT PRIMARY KEY, name TEXT, position TEXT, leaving_date DATE); INSERT INTO employee_records (employee_id, name, position, leaving_date) VALUES (1, 'John Doe', 'CTO', '2018-01-01'); INSERT INTO employee_records (employee_id, name, position, leaving_date) VALUES (2, 'Jane Smith', 'COO', '2019-05-15'); INSERT INTO employee_records (employee_id, name, position, leaving_date) VALUES (3, 'Alice Johnson', 'Data Analyst', '2020-03-20');
Update the position of the employee with ID 2 in the "employee_records" table
UPDATE employee_records SET position = 'VP of Operations' WHERE employee_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE aid_delivery_times (id INT, country VARCHAR(20), person_id INT, aid_date DATE, delivery_time INT);
What is the average time taken to provide aid to people in need in Brazil and Argentina?
SELECT country, AVG(delivery_time) as avg_delivery_time FROM aid_delivery_times GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_temperature (crop_name VARCHAR(50), measurement_date DATE, temperature DECIMAL(5,2));
Find the average temperature for all crops in April
SELECT AVG(temperature) FROM crop_temperature WHERE EXTRACT(MONTH FROM measurement_date) = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE content_creators (creator_id INT, creator_name VARCHAR(255));CREATE TABLE posts (post_id INT, creator_id INT, post_date DATE, post_text TEXT);CREATE TABLE hashtags (hashtag_id INT, hashtag_name VARCHAR(255));CREATE TABLE post_hashtags (post_id INT, hashtag_id INT);
What is the average number of daily posts, per content creator, containing the hashtag "#climatechange" in the past year, broken down by month?
SELECT EXTRACT(MONTH FROM p.post_date) AS month, AVG(COUNT(p.post_id)) as avg_posts FROM content_creators cc JOIN posts p ON cc.creator_id = p.creator_id JOIN post_hashtags ph ON p.post_id = ph.post_id JOIN hashtags h ON ph.hashtag_id = h.hashtag_id WHERE h.hashtag_name = '#climatechange' AND p.post_date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_name VARCHAR(255), project_type VARCHAR(255), state VARCHAR(255), installed_capacity FLOAT);
Get the number of renewable energy projects in each state of the United States
SELECT state, COUNT(*) as num_projects FROM projects WHERE state IN (SELECT state FROM (SELECT DISTINCT state FROM projects WHERE state = 'United States') as temp) GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, days_in_jail INT, release_date DATE); INSERT INTO offenders (id, days_in_jail, release_date) VALUES (1, 30, '2021-03-23'), (2, 60, '2021-04-15');
What is the minimum number of days served in jail for offenders who were released?
SELECT MIN(days_in_jail) FROM offenders WHERE release_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers_competency (id INT, name VARCHAR(50), region VARCHAR(20), cultural_competency_score INT); INSERT INTO healthcare_providers_competency (id, name, region, cultural_competency_score) VALUES (1, 'Dr. Jane Doe', 'Northeast', 85), (2, 'Dr. John Smith', 'Southeast', 90), (3, 'Dr. Maria Garcia', 'Southwest', 95);
What is the distribution of cultural competency scores for healthcare providers in each region, and how many providers are in each region?
SELECT region, AVG(cultural_competency_score) as avg_score, COUNT(*) as provider_count FROM healthcare_providers_competency GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_capacity (id INT, project TEXT, country TEXT, capacity FLOAT, year INT); INSERT INTO solar_capacity (id, project, country, capacity, year) VALUES (1, 'Aguascalientes Solar Park', 'Mexico', 36.5, 2018), (2, 'Puerto Libertad Solar Park', 'Mexico', 45.7, 2019);
What is the maximum solar capacity (MW) added in Mexico each year?
SELECT year, MAX(capacity) FROM solar_capacity WHERE country = 'Mexico' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk (country VARCHAR, risk_level VARCHAR, assessment_date DATE);
What is the geopolitical risk assessment for country Y?
SELECT risk_level FROM geopolitical_risk WHERE country = 'Country Y';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(50)); CREATE TABLE sourcing (sourcing_id INT, country_id INT, product_id INT, is_organic BOOLEAN);
What is the total number of products sourced from organic farming, grouped by country of origin, in descending order?
SELECT s.country_id, c.country_name, COUNT(s.product_id) as organic_product_count FROM sourcing s JOIN countries c ON s.country_id = c.country_id WHERE s.is_organic = true GROUP BY s.country_id, c.country_name ORDER BY organic_product_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (country VARCHAR(255), year INT, amount DECIMAL(10,2)); INSERT INTO climate_finance (country, year, amount) VALUES ('France', 2015, 100.0), ('France', 2016, 110.0), ('France', 2017, 120.0), ('France', 2018, 130.0), ('France', 2019, 140.0), ('France', 2020, 150.0), ('Germany', 2015, 200.0), ('Germany', 2016, 220.0), ('Germany', 2017, 240.0), ('Germany', 2018, 260.0), ('Germany', 2019, 280.0), ('Germany', 2020, 300.0);
What is the total amount of climate finance provided by France and Germany between 2015 and 2020?
SELECT SUM(amount) FROM climate_finance WHERE country IN ('France', 'Germany') AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (id INT PRIMARY KEY, title VARCHAR(255), description TEXT, start_date DATE, end_date DATE); INSERT INTO climate_projects (id, title, description, start_date, end_date) VALUES (1, 'Coastal Flood Protection', 'Construction of a coastal flood protection system.', '2020-01-01', '2021-12-31');
Update the name of the 'Coastal Flood Protection' project to 'Coastal Flood Resilience' in the climate_projects table.
UPDATE climate_projects SET title = 'Coastal Flood Resilience' WHERE title = 'Coastal Flood Protection';
gretelai_synthetic_text_to_sql
CREATE TABLE Intelligence (IntelligenceID INT, IntelligenceType VARCHAR(50), IntelligenceData VARCHAR(255), IntelligenceDate DATE, ThreatLevel VARCHAR(50), PRIMARY KEY (IntelligenceID));
List all threat intelligence data with a threat level of 'High' for the past 6 months.
SELECT Intelligence.IntelligenceType, Intelligence.IntelligenceData, Intelligence.IntelligenceDate, Intelligence.ThreatLevel FROM Intelligence WHERE Intelligence.ThreatLevel = 'High' AND Intelligence.IntelligenceDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(255), population INT); CREATE TABLE ResourceManagement (id INT PRIMARY KEY, location VARCHAR(255), manager VARCHAR(255));
What is the species name, population, and management location for species with a population over 800?
SELECT Species.name, Species.population, ResourceManagement.location FROM Species INNER JOIN ResourceManagement ON 1=1 WHERE Species.population > 800;
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_applications (app_id serial, app_name varchar(20), regulatory_framework varchar(20)); INSERT INTO decentralized_applications (app_id, app_name, regulatory_framework) VALUES (1, 'AppA', 'GDPR'), (2, 'AppB', 'HIPAA'), (3, 'AppC', 'GDPR'), (4, 'AppD', 'GDPR');
How many decentralized applications are associated with the 'HIPAA' regulatory framework?
SELECT COUNT(*) FROM decentralized_applications WHERE regulatory_framework = 'HIPAA';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (household_id INT, city VARCHAR(30), year INT, waste_amount FLOAT);
What is the average water waste per household in New York City in 2021?
SELECT AVG(waste_amount) FROM wastewater_treatment WHERE city='New York City' AND year=2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donation_id INT, region VARCHAR(20), amount DECIMAL(10,2), donation_year INT); INSERT INTO Donations (donation_id, region, amount, donation_year) VALUES (1, 'Great Lakes', 5000.00, 2020), (2, 'Southeast', 3000.00, 2020);
What was the total donation amount for the year 2020 in the 'Great Lakes' region?
SELECT SUM(amount) FROM Donations WHERE region = 'Great Lakes' AND donation_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_sources (country VARCHAR(255), source_type VARCHAR(255), capacity INT); INSERT INTO energy_sources (country, source_type, capacity) VALUES ('Germany', 'Wind', 62874);
What is the total installed capacity of wind energy in Germany?
SELECT SUM(capacity) FROM energy_sources WHERE country = 'Germany' AND source_type = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (StreamID INT, UserID INT, ArtistID INT); INSERT INTO Streams (StreamID, UserID, ArtistID) VALUES (1, 101, 1), (2, 101, 2), (3, 102, 3), (4, 102, 4), (5, 103, 1), (6, 103, 3);
Find the number of unique users who have streamed songs from artists in both 'Rock' and 'Jazz' genres?
SELECT COUNT(DISTINCT UserID) AS UniqueUsers FROM (SELECT UserID FROM Streams JOIN Artists ON Streams.ArtistID = Artists.ArtistID WHERE Genre IN ('Rock', 'Jazz') GROUP BY UserID HAVING COUNT(DISTINCT Genre) = 2);
gretelai_synthetic_text_to_sql
CREATE TABLE sector_18_19_consumption (year INT, sector TEXT, consumption FLOAT); INSERT INTO sector_18_19_consumption (year, sector, consumption) VALUES (2018, 'residential', 123.5), (2018, 'agricultural', 234.6), (2019, 'residential', 345.7), (2019, 'agricultural', 456.8);
What is the combined water consumption by the residential and agricultural sectors in 2018 and 2019?
SELECT consumption FROM sector_18_19_consumption WHERE sector IN ('residential', 'agricultural') AND year IN (2018, 2019)
gretelai_synthetic_text_to_sql
CREATE TABLE Policies (PolicyNumber INT, PolicyholderID INT, PolicyState VARCHAR(20)); INSERT INTO Policies (PolicyNumber, PolicyholderID, PolicyState) VALUES (1001, 3, 'California'), (1002, 4, 'California'), (1003, 5, 'Texas'), (1004, 6, 'Texas');
Find the difference in the number of policies between 'California' and 'Texas'.
SELECT (COUNT(CASE WHEN PolicyState = 'California' THEN 1 END) - COUNT(CASE WHEN PolicyState = 'Texas' THEN 1 END)) AS PolicyDifference FROM Policies;
gretelai_synthetic_text_to_sql
CREATE TABLE Landfill (Location VARCHAR(50), Material VARCHAR(50), Quantity INT, Year INT); INSERT INTO Landfill (Location, Material, Quantity, Year) VALUES ('LandfillA', 'Plastic', 1000, 2019), ('LandfillA', 'Glass', 1500, 2019), ('LandfillA', 'Plastic', 1200, 2020), ('LandfillA', 'Glass', 1800, 2020);
Display the recycling rates for each material type in the landfill for 2019 and 2020, along with the average recycling rate.
SELECT Material, AVG(RecyclingRate) FROM (SELECT Material, Year, Quantity, (Quantity / (Quantity + LandfillCapacity)) * 100 AS RecyclingRate FROM Landfill) AS LandfillData GROUP BY Material;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (city VARCHAR(20), category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Events (city, category, price) VALUES ('New York', 'Musical', 120.50), ('New York', 'Musical', 150.00), ('New York', 'Opera', 200.50), ('Chicago', 'Musical', 90.00);
What is the average ticket price for musicals and operas in New York?
SELECT AVG(price) FROM Events WHERE city = 'New York' AND category IN ('Musical', 'Opera');
gretelai_synthetic_text_to_sql
CREATE TABLE HolmiumMarketPrices (quarter VARCHAR(10), year INT, price DECIMAL(5,2)); INSERT INTO HolmiumMarketPrices (quarter, year, price) VALUES ('Q1', 2020, 110.00), ('Q1', 2020, 112.50), ('Q1', 2021, 120.00), ('Q1', 2021, 122.50), ('Q1', 2022, 130.00), ('Q1', 2022, 132.50);
Find the average market price of Holmium for the first quarter of each year from 2020 to 2022.
SELECT AVG(price) FROM HolmiumMarketPrices WHERE year IN (2020, 2021, 2022) AND quarter = 'Q1';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name VARCHAR(255), region VARCHAR(255), water_ph FLOAT, stock_count INT); INSERT INTO fish_farms (id, name, region, water_ph, stock_count) VALUES (1, 'Farm D', 'Asia', 7.4, 6000), (2, 'Farm E', 'Asia', 7.8, 4500), (3, 'Farm F', 'Asia', 8.1, 5200);
How many fish farms in Asia have a water pH level between 7.0 and 8.0, and stock more than 5000 individuals?
SELECT COUNT(*) FROM fish_farms WHERE region = 'Asia' AND water_ph >= 7.0 AND water_ph <= 8.0 AND stock_count > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (org_id INT, org_name TEXT); CREATE TABLE Donors (donor_id INT, donor_name TEXT, org_id INT, donation_amount DECIMAL(10,2));
What is the total amount donated to each organization and the number of unique donors who have donated to each organization?
SELECT O.org_name, SUM(D.donation_amount) as total_donations, COUNT(DISTINCT D.donor_id) as total_donors FROM Organizations O INNER JOIN Donors D ON O.org_id = D.org_id GROUP BY O.org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (Id INT, ProgramName VARCHAR(50), Budget DECIMAL(10,2), StartDate DATE, EndDate DATE);
Insert new program with budget
INSERT INTO Programs (Id, ProgramName, Budget, StartDate, EndDate) VALUES (3, 'Arts', 7000.00, '2022-01-01', '2022-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE Farm(id INT, country VARCHAR(20), biomass FLOAT); INSERT INTO Farm(id, country, biomass) VALUES (1, 'Norway', 350000.0), (2, 'Chile', 420000.0);
What is the total biomass of salmon farmed in Norway and Chile?
SELECT SUM(biomass) FROM Farm WHERE country IN ('Norway', 'Chile') AND species = 'Salmon';
gretelai_synthetic_text_to_sql
CREATE TABLE network_type_broadband (network_type VARCHAR(20)); INSERT INTO network_type_broadband (network_type) VALUES ('Fiber'), ('Cable'), ('DSL'); CREATE TABLE mobile_subscribers (subscriber_id INT, name VARCHAR(50), country VARCHAR(50), network_type VARCHAR(20)); CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(50), country VARCHAR(50), network_type VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, name, country, network_type) VALUES (1, 'John Doe', 'USA', '5G'); INSERT INTO broadband_subscribers (subscriber_id, name, country, network_type) VALUES (2, 'Jane Doe', 'Canada', 'Fiber');
Count the number of mobile and broadband subscribers for each network type in each country.
SELECT mobile_subscribers.country, mobile_subscribers.network_type, COUNT(mobile_subscribers.subscriber_id) + COUNT(broadband_subscribers.subscriber_id) AS total_subscribers FROM mobile_subscribers JOIN broadband_subscribers ON mobile_subscribers.country = broadband_subscribers.country JOIN network_type_broadband ON mobile_subscribers.network_type = network_type_broadband.network_type WHERE mobile_subscribers.network_type = broadband_subscribers.network_type GROUP BY mobile_subscribers.country, mobile_subscribers.network_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity_2 (region TEXT, acidity NUMERIC); INSERT INTO ocean_acidity_2 (region, acidity) VALUES ('Atlantic Ocean', '8.4'); INSERT INTO ocean_acidity_2 (region, acidity) VALUES ('Atlantic Ocean', '8.35');
What is the maximum ocean acidity level recorded in the Atlantic Ocean?
SELECT MAX(acidity) FROM ocean_acidity_2 WHERE region = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_projects (project_id INT, project_name VARCHAR(50), region VARCHAR(20), cost DECIMAL(10,2)); INSERT INTO green_building_projects (project_id, project_name, region, cost) VALUES (1, 'Green Office', 'Asia', 15000000.00), (2, 'Sustainable Apartments', 'Asia', 12000000.00), (3, 'Eco-friendly Mall', 'Europe', 18000000.00);
List all Green building projects in the Asian region and their respective costs.
SELECT project_name, cost FROM green_building_projects WHERE region = 'Asia';
gretelai_synthetic_text_to_sql