context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE SCHEMA water_access; CREATE TABLE country (code CHAR(3), name TEXT, population BigInt); CREATE TABLE water_source (code CHAR(3), source TEXT, population BigInt, percent_clean BigInt); INSERT INTO country VALUES ('AFG', 'Afghanistan', 37173242); INSERT INTO water_source VALUES ('AFG', 'well', 10000000, 75);
What is the percentage of the population that has access to clean water in the 'water_access' schema?
SELECT c.name, (ws.population / c.population::float) * 100 as clean_water_percentage FROM water_access.country c JOIN water_access.water_source ws ON c.code = ws.code;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT PRIMARY KEY, program_name TEXT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Feeding the Hungry'), (2, 'Tutoring Kids');
Update program name
WITH new_name AS (UPDATE programs SET program_name = 'Tutoring for Success' WHERE program_name = 'Tutoring Kids' RETURNING program_id) SELECT * FROM new_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MarketCapitalization (asset_id INT, asset_name VARCHAR(255), regulatory_status VARCHAR(255), market_capitalization DECIMAL(18,2)); INSERT INTO MarketCapitalization (asset_id, asset_name, regulatory_status, market_capitalization) VALUES (1, 'BTC', 'approved', 1000000.00), (2, 'ETH', 'pending', 200000.00), (...
What is the regulatory status (approved, pending, rejected) of the digital assets with the highest market capitalization, and what is their market capitalization?
SELECT regulatory_status, market_capitalization FROM (SELECT regulatory_status, market_capitalization, RANK() OVER (ORDER BY market_capitalization DESC) as rank FROM MarketCapitalization WHERE regulatory_status IN ('approved', 'pending', 'rejected')) AS ranked_assets WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR, size INT, sustainable_urbanism BOOLEAN);
What is the sum of square footage of properties with sustainable urbanism certifications in Los Angeles?
SELECT SUM(size) FROM properties WHERE city = 'Los Angeles' AND sustainable_urbanism = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE otas_q3_2022 (ota TEXT, revenue FLOAT); INSERT INTO otas_q3_2022 (ota, revenue) VALUES ('Airbnb', 500000), ('Booking.com', 550000), ('Expedia', 400000);
What is the revenue difference between 'Airbnb' and 'Booking.com' in 'Q3 2022'?
SELECT (a.revenue - b.revenue) AS revenue_diff FROM otas_q3_2022 a, otas_q3_2022 b WHERE a.ota = 'Airbnb' AND b.ota = 'Booking.com';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, judge_id INT, type VARCHAR(255)); INSERT INTO cases (id, judge_id, type) VALUES (1, 1, 'Civil'); INSERT INTO cases (id, judge_id, type) VALUES (2, 2, 'Criminal');
What is the number of cases heard by each judge, ordered by the number of cases?
SELECT judge_id, type, COUNT(*) as case_count, ROW_NUMBER() OVER(PARTITION BY judge_id ORDER BY COUNT(*) DESC) as sequence FROM cases GROUP BY judge_id, type;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(50), state VARCHAR(50), certification_level VARCHAR(50), carbon_offsets FLOAT); INSERT INTO green_buildings (building_id, building_name, state, certification_level, carbon_offsets) VALUES (1, 'Green Building 1', 'StateA', 'Gold', 100.0), (2, 'Green Bu...
Which green buildings have the highest carbon offsets in each state?
SELECT state, MAX(carbon_offsets) FROM green_buildings GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_growth_2 (country VARCHAR(255), growth INT); INSERT INTO visitor_growth_2 (country, growth) VALUES ('Canada', -50000), ('Japan', -100000), ('Germany', -150000), ('France', -200000), ('United Kingdom', -250000);
Which countries had the lowest visitor growth in 2021 compared to 2020?
SELECT country, growth FROM visitor_growth_2 ORDER BY growth ASC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, type TEXT, country TEXT, revenue FLOAT); INSERT INTO tours (id, type, country, revenue) VALUES (1, 'Virtual Tour of the Grand Canyon', 'United States', 10000.0), (2, 'In-person Tour of the Statue of Liberty', 'United States', 8000.0);
What is the total revenue of virtual tours in the United States?
SELECT SUM(revenue) FROM tours WHERE type = 'Virtual Tour' AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (ce_id INT, country_id INT, year INT, participants INT, region VARCHAR(255)); INSERT INTO community_engagement VALUES (1, 1, 2015, 5000, 'Oceania'), (2, 1, 2016, 5500, 'Oceania'), (3, 2, 2015, 7000, 'Europe'), (4, 2, 2016, 8000, 'Europe'), (5, 3, 2015, 6000, 'Asia'), (6, 3, 2016, 7000,...
What is the total number of community engagement events in Oceania?
SELECT SUM(participants) FROM community_engagement WHERE region = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE nyc_neighborhoods (id INT, name VARCHAR(50), is_affordable_housing BOOLEAN); INSERT INTO nyc_neighborhoods (id, name, is_affordable_housing) VALUES (1, 'Manhattan', false), (2, 'Brooklyn', true); CREATE TABLE properties (id INT, neighborhood_id INT, price INT, num_units INT); INSERT INTO properties (id, ne...
What is the total number of affordable housing units in New York City?
SELECT SUM(properties.num_units) FROM properties INNER JOIN nyc_neighborhoods ON properties.neighborhood_id = nyc_neighborhoods.id WHERE nyc_neighborhoods.is_affordable_housing = true;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, gender VARCHAR(10)); INSERT INTO users (id, age, gender) VALUES (1, 25, 'Male'); INSERT INTO users (id, age, gender) VALUES (2, 30, 'Female'); CREATE TABLE workouts (id INT, user_id INT, heart_rate INT); INSERT INTO workouts (id, user_id, heart_rate) VALUES (1, 1, 75); INSERT INTO w...
What is the average heart rate of users aged 25-30 during their workouts?
SELECT AVG(heart_rate) FROM workouts JOIN users ON workouts.user_id = users.id WHERE users.age BETWEEN 25 AND 30;
gretelai_synthetic_text_to_sql
CREATE TABLE tax_rates_2 (id INT, city TEXT, state TEXT, property_type TEXT, rate FLOAT);
What is the lowest property tax in New York City?
SELECT MIN(rate) FROM tax_rates_2 WHERE city = 'New York City' AND property_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE MonthlyRevenue (Month VARCHAR(10), Revenue INT); INSERT INTO MonthlyRevenue (Month, Revenue) VALUES ('January', 5000), ('February', 6000), ('March', 7000);
Show the total revenue for each month in 2022.
SELECT Month, SUM(Revenue) FROM MonthlyRevenue WHERE Month IN ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') AND YEAR(STR_TO_DATE(Month, '%B')) = 2022 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE sites (id INT, name TEXT, country TEXT, year INT, visitor_count INT); INSERT INTO sites (id, name, country, year, visitor_count) VALUES (1, 'Mount Fuji', 'Japan', 2022, 1000000); INSERT INTO sites (id, name, country, year, visitor_count) VALUES (2, 'Hiroshima Peace Memorial Park', 'Japan', 2022, 800000); I...
Find the top 3 most visited cultural heritage sites in Japan for 2022.
SELECT name, visitor_count FROM (SELECT name, visitor_count, ROW_NUMBER() OVER (ORDER BY visitor_count DESC) AS rank FROM sites WHERE country = 'Japan' AND year = 2022) AS ranked_sites WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name VARCHAR(255), country VARCHAR(255));INSERT INTO unions (id, name, country) VALUES (1, 'CUT', 'Chile'), (2, 'CNT', 'Uruguay'), (3, 'CGT', 'Argentina'), (4, 'FORA', 'Argentina');CREATE TABLE agreements (id INT, union_id INT, success INT, year INT);INSERT INTO agreements (id, union_id, su...
Which unions have the highest and lowest collective bargaining success rates, and how many collective bargaining agreements did they sign?
SELECT unions.name, SUM(CASE WHEN agreements.success = 1 THEN 1 ELSE 0 END) as successes, COUNT(agreements.id) as total_agreements FROM unions JOIN agreements ON unions.id = agreements.union_id GROUP BY unions.name ORDER BY successes DESC, total_agreements ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE sf_firefighters (firefighter_id INT, name VARCHAR(255), rank VARCHAR(255)); INSERT INTO sf_firefighters (firefighter_id, name, rank) VALUES (1, 'Jose Garcia', 'Captain'), (2, 'Hannah Nguyen', 'Firefighter'), (3, 'Liam Brown', 'Lieutenant'); CREATE TABLE structure_fires (fire_id INT, firefighter_id INT, dat...
Who is the firefighter with the most structure fires in the city of San Francisco?
SELECT firefighter_id, name, COUNT(*) as total_structure_fires FROM structure_fires WHERE firefighter_id IS NOT NULL GROUP BY firefighter_id, name ORDER BY total_structure_fires DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE patient (patient_id INT, age INT, gender VARCHAR(10), state VARCHAR(10)); INSERT INTO patient (patient_id, age, gender, state) VALUES (1, 45, 'Female', 'California'); INSERT INTO patient (patient_id, age, gender, state) VALUES (2, 50, 'Male', 'California');
What is the average age of patients who received a flu shot in the last 6 months in California?
SELECT AVG(age) FROM (SELECT patient_id, age, state FROM patient WHERE state = 'California' AND flu_shot_date >= DATEADD(month, -6, GETDATE())) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE production_costs (item VARCHAR(255), material VARCHAR(255), cost DECIMAL(10, 2)); INSERT INTO production_costs (item, material, cost) VALUES ('cotton t-shirt', 'cotton', 7.50), ('jeans', 'cotton', 12.00);
What is the average production cost of cotton t-shirts?
SELECT AVG(cost) FROM production_costs WHERE item = 'cotton t-shirt';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health_history (student_id INT, score INT, date DATE); INSERT INTO student_mental_health_history VALUES (1, 60, '2022-04-01'), (1, 55, '2022-07-01'), (2, 80, '2022-04-01'), (2, 75, '2022-07-01');
How many students have decreased their mental health score by more than 5% in the last 3 months?
SELECT COUNT(*) FROM (SELECT student_id, (LAG(score) OVER(PARTITION BY student_id ORDER BY date) - score) / LAG(score) OVER(PARTITION BY student_id ORDER BY date) * 100.0 as decrease_percentage FROM student_mental_health_history WHERE date >= DATEADD(month, -3, GETDATE())) t WHERE decrease_percentage > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Albums (album_id INT, album_name VARCHAR(255)); INSERT INTO Albums (album_id, album_name) VALUES (1, 'Album1'), (2, 'Album2'), (3, 'Album3'), (4, 'Album4'), (5, 'Album5'); CREATE TABLE Songs (song_id INT, album_id INT, song_name VARCHAR(255)); INSERT INTO Songs (song_id, album_id, song_name) VALUES (1, 1, ...
What are the top 5 albums with the most songs?
SELECT a.album_name, COUNT(s.song_id) AS song_count FROM Albums a JOIN Songs s ON a.album_id = s.album_id GROUP BY a.album_name ORDER BY song_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE materials_sourcing (id INT, industry VARCHAR(50), supplier_type VARCHAR(50), value DECIMAL(10,2), financial_year INT); INSERT INTO materials_sourcing (id, industry, supplier_type, value, financial_year) VALUES (1, 'Automotive', 'Ethical', 100000.00, 2021), (2, 'Aerospace', 'Non-Ethical', 200000.00, 2021), ...
What is the total value of materials sourced from ethical suppliers for the automotive industry in the last financial year?
SELECT SUM(value) FROM materials_sourcing WHERE industry = 'Automotive' AND supplier_type = 'Ethical' AND financial_year = 2021;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.satellites (id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE);
Insert a new satellite into the database
INSERT INTO aerospace.satellites (id, name, launch_country, launch_date) VALUES (3, 'Sat3', 'India', '2022-03-01');
gretelai_synthetic_text_to_sql
CREATE TABLE mineral_extraction (extraction_id INT, extraction_kg FLOAT, year INT, state VARCHAR(20)); INSERT INTO mineral_extraction (extraction_id, extraction_kg, year, state) VALUES (1, 5000, 2010, 'Andhra Pradesh'), (2, 7000, 2011, 'Telangana'), (3, 6500, 2012, 'Karnataka');
What is the total mineral extraction in India, by state, in the last 2 years?
SELECT state, SUM(extraction_kg) as total_mineral_extraction FROM mineral_extraction WHERE year BETWEEN YEAR(DATE_SUB(CURDATE(), INTERVAL 2 YEAR)) AND YEAR(CURDATE()) GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_transactions (customer_id INT, transaction_date DATE, region VARCHAR(50)); INSERT INTO customer_transactions (customer_id, transaction_date, region) VALUES (1, '2022-01-01', 'East'), (1, '2022-02-01', 'West'), (2, '2022-03-01', 'East'), (3, '2022-04-01', 'West');
Identify customers who have made purchases in both the East and West regions
SELECT ct1.customer_id FROM customer_transactions ct1 JOIN customer_transactions ct2 ON ct1.customer_id = ct2.customer_id WHERE ct1.region <> ct2.region GROUP BY ct1.customer_id HAVING COUNT(DISTINCT ct1.region) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_date DATE, team VARCHAR(50), player VARCHAR(50), points INT); INSERT INTO games (game_date, team, player, points) VALUES ('2022-01-01', 'Bulls', 'Johnson', 30), ('2022-01-01', 'Bulls', 'Brown', 20), ('2022-01-02', 'Bulls', 'Johnson', 35), ('2022-01-02', 'Bulls', 'Brown', 15);
Which basketball players have the most total points scored in each game for the last 30 days?
SELECT game_date, player, SUM(points) AS total_points FROM games WHERE game_date >= DATEADD(day, -30, GETDATE()) GROUP BY game_date, player
gretelai_synthetic_text_to_sql
SELECT AVG(Age) as AverageAge FROM Students;
Calculate the overall average age of students
SELECT AVG(Age) as AverageAge FROM Students;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_data (subscriber_id INT, plan_id INT, age INT); INSERT INTO subscriber_data (subscriber_id, plan_id, age) VALUES (1, 1, 25), (2, 2, 35), (3, 3, 45), (4, 1, 30), (5, 2, 40), (6, 3, 50);
What is the average age of subscribers for each mobile plan?
SELECT plan_id, AVG(age) AS avg_age FROM subscriber_data GROUP BY plan_id;
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarders (id INT, name VARCHAR(255));CREATE TABLE shipments (id INT, forwarder_id INT);INSERT INTO freight_forwarders (id, name) VALUES (1, 'ABC Freight'), (2, 'XYZ Logistics'), (3, 'DEF Freight');INSERT INTO shipments (id, forwarder_id) VALUES (1, 1), (2, 1), (3, 2);
Which freight forwarders have not handled any shipments?
SELECT f.name FROM freight_forwarders f LEFT JOIN shipments s ON f.id = s.forwarder_id WHERE s.forwarder_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_preparedness (region_id INT, preparedness_score INT); INSERT INTO disaster_preparedness (region_id, preparedness_score) VALUES (1, 70), (2, 60), (3, 90);
Update the "disaster_preparedness" table to set the "preparedness_score" to 80 for the "region_id" 2
UPDATE disaster_preparedness SET preparedness_score = 80 WHERE region_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategies (id INT, company_id INT, exit_type TEXT, exit_date DATE);
How many startups have had an exit event in the biotechnology industry?
SELECT COUNT(DISTINCT company_id) FROM exit_strategies JOIN company ON exit_strategies.company_id = company.id WHERE company.industry = 'Biotechnology';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, country VARCHAR(50), region VARCHAR(50), area_ha FLOAT); INSERT INTO organic_farms (id, country, region, area_ha) VALUES (1, 'United States', 'North America', 12345.6); INSERT INTO organic_farms (id, country, region, area_ha) VALUES (2, 'Canada', 'North America', 7890.1);
What is the total area of land used for organic farming in the region 'North America'?
SELECT SUM(area_ha) FROM organic_farms WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE garage (garage_id INT, name VARCHAR(255)); CREATE TABLE vehicle (vehicle_id INT, garage_id INT, model VARCHAR(255)); INSERT INTO garage (garage_id, name) VALUES (1, 'Garage A'), (2, 'Garage B'); INSERT INTO vehicle (vehicle_id, garage_id, model) VALUES (1, 1, 'Bus A'), (2, 1, 'Bus B'), (3, 2, 'Bus C');
How many vehicles are assigned to each garage?
SELECT g.garage_id, g.name, COUNT(v.vehicle_id) AS vehicle_count FROM garage g JOIN vehicle v ON g.garage_id = v.garage_id GROUP BY g.garage_id;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, region VARCHAR(255), date DATE, oil_production INT); INSERT INTO production (id, region, date, oil_production) VALUES (1, 'North Sea', '2021-01-01', 1200); INSERT INTO production (id, region, date, oil_production) VALUES (2, 'North Sea', '2021-01-02', 1300);
Calculate the average daily production of oil in the North Sea for the last 3 months
SELECT region, AVG(oil_production) as avg_daily_production FROM production WHERE region = 'North Sea' AND date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (3, 'Greenhills'); CREATE TABLE community_policing_events (id INT, district_id INT, event_date DATE); INSERT INTO community_policing_events (id, district_id, event_date) VALUES (3001, 3, '2020-01-02'), (3002, 3, '2020-01-03'), (...
Delete all community policing events in district 3 before '2020-01-01'
DELETE FROM community_policing_events WHERE event_date < '2020-01-01' AND district_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CargoWeights (id INT, vessel_id INT, cargo_weight INT, transaction_time TIMESTAMP); INSERT INTO CargoWeights (id, vessel_id, cargo_weight, transaction_time) VALUES (1, 345, 12000, '2021-05-08 16:30:00');
Find the average weight of the top 5 heaviest cargos transported by vessel 345, for the entire year of 2021.
SELECT AVG(cargo_weight) as avg_weight FROM CargoWeights WHERE vessel_id = 345 AND transaction_time > '2021-01-01 00:00:00' AND transaction_time < '2022-01-01 00:00:00' AND cargo_weight IN (SELECT cargo_weight FROM (SELECT cargo_weight FROM CargoWeights WHERE vessel_id = 345 GROUP BY cargo_weight ORDER BY SUM(cargo_wei...
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists renewables; CREATE TABLE if not exists renewables.wind_projects (project_id int, name varchar(255), location varchar(255), installed_capacity float); INSERT INTO renewables.wind_projects (project_id, name, location, installed_capacity) VALUES (1, 'Wind Farm 1', 'Country A', 100.0), (2, 'Wind...
What is the total installed capacity of wind energy projects in the 'renewables' schema?
SELECT SUM(installed_capacity) FROM renewables.wind_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), state VARCHAR(2)); INSERT INTO claims (policyholder_id, claim_amount, state) VALUES (1, 500, 'CO'), (2, 200, 'CO'), (3, 500, 'CO');
What is the most common claim amount for policyholders in Colorado
SELECT claim_amount, COUNT(*) FROM claims WHERE state = 'CO' GROUP BY claim_amount ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeDemographics (EmployeeID INT, Age INT, Nationality VARCHAR(50)); INSERT INTO EmployeeDemographics (EmployeeID, Age, Nationality) VALUES (1, 30, 'American'), (2, 40, 'Canadian'), (3, 35, 'British'), (4, 28, 'Mexican'), (5, 45, 'German'), (6, 32, 'Indian');
What is the age and nationality distribution of employees?
SELECT Nationality, Age, COUNT(*) FROM EmployeeDemographics GROUP BY Nationality, Age;
gretelai_synthetic_text_to_sql
CREATE TABLE train_lines (line_id INT, line_name VARCHAR(255), fare DECIMAL(5,2)); INSERT INTO train_lines (line_id, line_name, fare) VALUES (1, 'Red Line', 2.00), (2, 'Blue Line', 1.50), (3, 'Green Line', 2.50), (4, 'Orange Line', 2.25);
Which train lines have the highest and lowest fare rates?
SELECT line_name, fare AS highest_fare FROM train_lines ORDER BY fare DESC LIMIT 1; SELECT line_name, fare AS lowest_fare FROM train_lines ORDER BY fare ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Smart_Contracts (contract_name TEXT, transaction_value NUMERIC, developer_country TEXT); INSERT INTO Smart_Contracts (contract_name, transaction_value, developer_country) VALUES ('Contract A', 50, 'USA'), ('Contract B', 75, 'Canada'), ('Contract C', 100, 'Nigeria'), ('Contract D', 25, 'South Africa'), ('Co...
What is the average transaction value for Smart Contracts created by developers from Africa?
SELECT AVG(transaction_value) FROM Smart_Contracts WHERE developer_country IN ('Nigeria', 'South Africa', 'Kenya');
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_fines (id INT, amount INT, issuance_date DATE, description TEXT); INSERT INTO regulatory_fines (id, amount, issuance_date, description) VALUES (1, 10000, '2021-01-01', 'Fine1'), (2, 20000, '2021-12-01', 'Fine2');
What is the maximum regulatory fine issued in '2021'?
SELECT MAX(regulatory_fines.amount) AS max_fine FROM regulatory_fines INNER JOIN (SELECT * FROM dates WHERE year = 2021) AS dates ON regulatory_fines.issuance_date = dates.date
gretelai_synthetic_text_to_sql
CREATE TABLE hr.job_applications (id INT, job_id INT, applicant_id INT, applied_date DATE);
Count the number of job applications in the 'hr' schema's 'job_applications' table per job id
SELECT job_id, COUNT(*) FROM hr.job_applications GROUP BY job_id;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, safety_rating INT, product_type TEXT); INSERT INTO products (product_id, safety_rating, product_type) VALUES (1, 9, 'Mascara'), (2, 7, 'Lipstick'), (3, 8, 'Mascara');
What is the difference in safety ratings between the best and worst rated mascaras?
SELECT MAX(safety_rating) - MIN(safety_rating) FROM products WHERE product_type = 'Mascara';
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManuf (id INT, manufacturer VARCHAR(20), launch_year INT, avg_speed FLOAT);
What is the average speed of spacecraft manufactured by SpaceTech, grouped by year?
SELECT manufacturer, AVG(avg_speed) FROM SpacecraftManuf WHERE manufacturer = 'SpaceTech' GROUP BY launch_year;
gretelai_synthetic_text_to_sql
CREATE TABLE SpeciesData (SpeciesID INT, SpeciesName VARCHAR(50), Population INT, Habitat VARCHAR(50), LastSurvey DATE); INSERT INTO SpeciesData (SpeciesID, SpeciesName, Population, Habitat, LastSurvey) VALUES (1, 'Coral', 3000, 'Tropical Reefs', '2020-08-01');
What is the average population of coral species that were surveyed in the Pacific Ocean in the last 5 years?
SELECT AVG(s.Population) FROM SpeciesData s WHERE s.SpeciesName = 'Coral' AND s.Habitat LIKE '%Pacific%' AND s.LastSurvey BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, cve VARCHAR(100), severity VARCHAR(10), description TEXT, discovery_date DATE); INSERT INTO vulnerabilities (id, cve, severity, description, discovery_date) VALUES (1, 'CVE-2021-1234', 'High', 'High severity vulnerability description', '2021-09-01'), (2, 'CVE-2021-5678', 'Medium', ...
Identify any vulnerabilities in the 'vulnerabilities' table that have a severity level of 'High' and were discovered in the last week, using the 'discovery_date' column.
SELECT * FROM vulnerabilities WHERE severity = 'High' AND discovery_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_data (id INT, date DATE, water_consumption INT); INSERT INTO environmental_data (id, date, water_consumption) VALUES (1, '2022-01-01', 5000); INSERT INTO environmental_data (id, date, water_consumption) VALUES (2, '2022-01-02', 5500);
What is the maximum amount of water consumed in a single day in the 'environmental_data' table?
SELECT MAX(water_consumption) as max_water_consumption FROM environmental_data;
gretelai_synthetic_text_to_sql
CREATE TABLE Stars (id INT, name VARCHAR(255), constellation VARCHAR(255), right_ascension VARCHAR(255), declination VARCHAR(255), spectral_type VARCHAR(255), absolute_magnitude DECIMAL(5,2)); INSERT INTO Stars (id, name, constellation, right_ascension, declination, spectral_type, absolute_magnitude) VALUES (5, 'Alnita...
What is the maximum absolute magnitude for O-type stars?
SELECT spectral_type, MAX(absolute_magnitude) as max_absolute_magnitude FROM Stars WHERE spectral_type = 'O9.5Iab' GROUP BY spectral_type;
gretelai_synthetic_text_to_sql
CREATE TABLE olympics (athlete TEXT, country TEXT, medal TEXT);
What is the total number of medals won by athletes from India in the Olympics?
SELECT SUM(CASE WHEN medal = 'Gold' THEN 1 WHEN medal = 'Silver' THEN 0.5 WHEN medal = 'Bronze' THEN 0.25 ELSE 0 END) as total_medals FROM olympics WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_sites (site_id INT, site_name TEXT, country TEXT, has_virtual_tour BOOLEAN); INSERT INTO cultural_sites (site_id, site_name, country, has_virtual_tour) VALUES (1, 'Colosseum', 'Italy', true), (2, 'Roman Forum', 'Italy', false);
Count the number of virtual tours in Italy's cultural heritage sites.
SELECT COUNT(*) FROM cultural_sites WHERE country = 'Italy' AND has_virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE military_spending (country VARCHAR(50), continent VARCHAR(50), year INT, amount FLOAT); INSERT INTO military_spending (country, continent, year, amount) VALUES ('Nigeria', 'Africa', 2020, 2.5), ('Algeria', 'Africa', 2020, 10.3), ('South Africa', 'Africa', 2020, 6.7);
What is the total military spending by countries in Africa for the year 2020?
SELECT SUM(amount) FROM military_spending WHERE continent = 'Africa' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_categories (category VARCHAR(255)); INSERT INTO sports_categories (category) VALUES ('Basketball'), ('Football'), ('Soccer'); CREATE TABLE tickets (sport_category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO tickets (sport_category, price) VALUES ('Basketball', 50.99), ('Basketball', 55.49), ('Foo...
What is the average ticket price for each sports category?
SELECT sport_category, AVG(price) as avg_price FROM tickets GROUP BY sport_category;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (project_id INT, infrastructure_type TEXT, cost FLOAT); INSERT INTO renewable_energy (project_id, infrastructure_type, cost) VALUES (1, 'solar farm', 500000.0), (1, 'wind farm', 700000.0), (2, 'geothermal plant', 900000.0), (2, 'hydroelectric dam', 1000000.0);
What is the average cost of renewable energy infrastructure for projects in the 'renewable_energy' schema, grouped by infrastructure type?
SELECT infrastructure_type, AVG(cost) FROM renewable_energy WHERE project_id IN (SELECT project_id FROM projects WHERE schema_name = 'renewable_energy') GROUP BY infrastructure_type;
gretelai_synthetic_text_to_sql
CREATE TABLE workout_data (user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO workout_data (user_id, workout_type, duration) VALUES (1, 'Running', 30), (1, 'Cycling', 60), (2, 'Yoga', 45), (3, 'Pilates', 50), (1, 'Cycling', 45), (2, 'Yoga', 60), (3, 'Pilates', 75);
What is the average duration of 'Cycling' workouts in the 'workout_data' table?
SELECT AVG(duration) as avg_duration FROM workout_data WHERE workout_type = 'Cycling';
gretelai_synthetic_text_to_sql
CREATE TABLE well_info (id INT, location VARCHAR(50), water_depth FLOAT); INSERT INTO well_info (id, location, water_depth) VALUES (1, 'Gulf of Guinea', 2000), (2, 'Gulf of Guinea', 3000);
Average water depth of wells in the Gulf of Guinea.
SELECT AVG(water_depth) FROM well_info WHERE location = 'Gulf of Guinea';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, team_id INT, player_id INT, touchdowns INT, sport VARCHAR(50)); INSERT INTO games (id, team_id, player_id, touchdowns, sport) VALUES (1, 101, 1, 3, 'Football'); INSERT INTO games (id, team_id, player_id, touchdowns, sport) VALUES (2, 102, 2, 4, 'Football');
What is the average number of touchdowns scored by football players in the last 5 games they have played?
SELECT AVG(touchdowns) FROM games WHERE sport = 'Football' AND id IN (SELECT game_id FROM last_5_games);
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, mineral TEXT, productivity INT); INSERT INTO mine (id, name, location, mineral, productivity) VALUES (1, 'Ruhrkohle AG', 'Germany', 'Coal', 1500), (2, 'RAG Anthrazit', 'Germany', 'Coal', 1000);
How many coal mines are there in Germany with productivity above 1200?
SELECT COUNT(*) FROM mine WHERE mineral = 'Coal' AND location = 'Germany' AND productivity > 1200;
gretelai_synthetic_text_to_sql
CREATE TABLE Pollution ( id INT PRIMARY KEY, location VARCHAR(255), pollutant VARCHAR(255), level FLOAT);
Which pollution records have a pollutant level equal to or higher than the average pollutant level across all records?
SELECT * FROM Pollution WHERE level >= (SELECT AVG(level) FROM Pollution);
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_framework (id INT, name VARCHAR(255)); CREATE TABLE smart_contracts (id INT, name VARCHAR(255), framework_id INT); INSERT INTO regulatory_framework (id, name) VALUES (1, 'EU GDPR'), (2, 'US CFTC'), (3, 'Japan FSA'), (4, 'UK FCA'), (5, 'China CSRC'); INSERT INTO smart_contracts (id, name, framewo...
Delete the regulatory framework 'China CSRC' as it has not been associated with any smart contract.
DELETE FROM regulatory_framework WHERE name = 'China CSRC';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ratings (hotel_id INT, hotel_name TEXT, stars INT, rating FLOAT); INSERT INTO hotel_ratings (hotel_id, hotel_name, stars, rating) VALUES (1, 'Hotel Royal', 4, 8.5), (2, 'Hotel Paris', 5, 9.0), (3, 'Hotel Tokyo', 4, 8.7), (4, 'Hotel Rome', 3, 7.5), (5, 'Hotel Beijing', 5, 9.2);
What is the average hotel rating by star rating?
SELECT stars, AVG(rating) as avg_rating FROM hotel_ratings GROUP BY stars;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralHealthFacilities (facility_id INT, facility_name VARCHAR(50), state VARCHAR(20), physician_type VARCHAR(20)); INSERT INTO RuralHealthFacilities (facility_id, facility_name, state, physician_type) VALUES (1, 'RuralClinicCA', 'California', 'Mental Health Specialist'), (2, 'RuralHospitalNY', 'New York', ...
Delete all mental health specialists from 'RuralHealthFacilities' table located in 'California' and 'New York'.
DELETE FROM RuralHealthFacilities WHERE physician_type = 'Mental Health Specialist' AND state IN ('California', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), num_employees INT, role VARCHAR(50)); INSERT INTO mining_operations (id, name, num_employees, role) VALUES (1, 'Gold Rush Inc.', 100, 'Manager'), (1, 'Gold Rush Inc.', 50, 'Engineer'), (2, 'Silver Strike Ltd.', 75, 'Manager'), (2, 'Silver Strike Ltd.', 25, 'Engi...
How many employees work in the 'Engineer' role in each mining operation?
SELECT name, role, COUNT(*) FROM mining_operations WHERE role = 'Engineer' GROUP BY name, role;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_skills (employee_id INT, skill_name VARCHAR(50), experience_years INT); INSERT INTO employee_skills (employee_id, skill_name, experience_years) VALUES (1, 'sustainable_manufacturing', 3), (2, 'quality_control', 1), (3, 'sustainable_manufacturing', 5);
What is the average experience of employees in 'quality_control' skill?
SELECT AVG(experience_years) FROM employee_skills WHERE skill_name = 'quality_control';
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (DepartmentID INT, Name TEXT, Budget FLOAT); INSERT INTO Departments (DepartmentID, Name, Budget) VALUES (1, 'Education', 5000.00), (2, 'Community Outreach', 8000.00);
What is the total budget for the 'Community Outreach' department?
SELECT SUM(Budget) as TotalBudget FROM Departments WHERE Name = 'Community Outreach';
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionSources (SourceID INT PRIMARY KEY, SourceName TEXT, AddedDate DATE);
List all pollution sources from the 'PollutionSources' table, ordered by the date they were added to the database.
SELECT SourceName FROM PollutionSources ORDER BY AddedDate;
gretelai_synthetic_text_to_sql
CREATE TABLE well_production_norwegian_sea (id INT, rate FLOAT); INSERT INTO well_production_norwegian_sea (id, rate) VALUES (1, 5000), (2, 6000), (3, 7000);
Minimum production rate (bpd) for wells in the Norwegian Sea.
SELECT MIN(rate) FROM well_production_norwegian_sea;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_name VARCHAR(50), department_name VARCHAR(50), salary DECIMAL(10,2));
What is the name of the department with the lowest average salary in the employees table?
SELECT department_name FROM employees WHERE (SELECT AVG(salary) FROM employees AS e2 WHERE e1.department_name = e2.department_name) = (SELECT MIN(avg_salary) FROM (SELECT department_name, AVG(salary) AS avg_salary FROM employees GROUP BY department_name) AS e3);
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO renewable_energy (id, project_name, location, cost) VALUES (1, 'Solar Farm', 'Miami', 10000000); INSERT INTO renewable_energy (id, project_name, location, cost) VALUES (2, 'Wind Farm', 'Seattle', 6000000);
What is the average cost of projects in 'Seattle' in the 'renewable_energy' table?
SELECT AVG(cost) FROM renewable_energy WHERE location = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE guardian (id INT, title VARCHAR(255), section VARCHAR(255), content TEXT, pub_date DATE); INSERT INTO guardian (id, title, section, content, pub_date) VALUES (1, 'Title1', 'Opinion', 'Content1', '2022-01-01'); INSERT INTO guardian (id, title, section, content, pub_date) VALUES (2, 'Title2', 'News', 'Conten...
List all the articles published by 'The Guardian' before January 1, 2022, excluding the articles published in the 'Opinion' section.
SELECT * FROM guardian WHERE pub_date < '2022-01-01' AND section != 'Opinion';
gretelai_synthetic_text_to_sql
CREATE TABLE agroecology_zones (zone TEXT, area_ha INT, biodiversity_index FLOAT); INSERT INTO agroecology_zones (zone, area_ha, biodiversity_index) VALUES ('Zone 1', 2000, 0.8), ('Zone 2', 2500, 0.7), ('Zone 3', 1500, 0.9), ('Zone 4', 3000, 0.6);
What is the total area and average biodiversity index for each agroecology zone?
SELECT zone, SUM(area_ha) as total_area, AVG(biodiversity_index) as avg_biodiversity FROM agroecology_zones GROUP BY zone;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, garment_id INT, quantity INT); CREATE TABLE garments (id INT, name VARCHAR(100), price DECIMAL(5,2), category VARCHAR(50));
Calculate the total quantity of each garment in the inventory table, grouped by category
SELECT garments.category, SUM(inventory.quantity) as total_quantity FROM inventory JOIN garments ON inventory.garment_id = garments.id GROUP BY garments.category;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE Sales (dispid INT, date DATE, cannabinoid TEXT, price DECIMAL(10,2)); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Michigan'); INSERT INTO Dispensaries (id, name, state) VALUES (2, 'Dispensary B', 'Michigan'); INSERT INTO ...
What was the average price per gram for each cannabinoid type (THC, CBD, CBG) sold at dispensaries in Michigan in Q3 2022?
SELECT s.cannabinoid, AVG(s.price) as avg_price_per_gram, ROW_NUMBER() OVER (ORDER BY AVG(s.price) DESC) as rank FROM Dispensaries d JOIN Sales s ON d.id = s.dispid WHERE d.state = 'Michigan' AND QUARTER(s.date) = 3 GROUP BY s.cannabinoid HAVING COUNT(s.cannabinoid) > 1 ORDER BY rank;
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicleTransportation (EVID INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Distance DECIMAL(5,2), State VARCHAR(50));
What is the average distance traveled by electric vehicles in California?
SELECT AVG(Distance) AS AvgDistance FROM ElectricVehicleTransportation WHERE State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE language_donors (id INT, name VARCHAR(50), donation INT, location VARCHAR(50)); INSERT INTO language_donors (id, name, donation, location) VALUES (1, 'Raj Patel', 12000, 'Asia'), (2, 'Hina Khan', 15000, 'Asia'), (3, 'Park Ji-Soo', 9000, 'Asia'), (4, 'Li Wen', 11000, 'Asia');
What are the top 3 contributors to language preservation in 'Asia'?
SELECT name, donation FROM language_donors WHERE location = 'Asia' ORDER BY donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, fiscal_year INT, budget DECIMAL(10, 2)); INSERT INTO peacekeeping_operations (id, fiscal_year, budget) VALUES (1, 2018, 50000), (2, 2019, 55000), (3, 2020, 60000), (4, 2021, 65000), (5, 2022, 70000);
Show the total peacekeeping operations budget by fiscal year
SELECT fiscal_year, SUM(budget) as total_budget FROM peacekeeping_operations GROUP BY fiscal_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Claim (ClaimId INT, PolicyId INT, ClaimDate DATE); CREATE TABLE Policy (PolicyId INT, PolicyholderGender VARCHAR(10), PolicyType VARCHAR(50), Premium DECIMAL(10,2), Region VARCHAR(50));
Show the number of policyholders and total premiums, by policy type and gender, for policyholders in Illinois who have filed at least one claim.
SELECT Policy.PolicyType, PolicyholderGender, COUNT(PolicyId) as PolicyholderCount, SUM(Premium) as TotalPremiums FROM Policy INNER JOIN Claim ON Policy.PolicyId = Claim.PolicyId WHERE Policy.Region = 'Illinois' GROUP BY Policy.PolicyType, PolicyholderGender HAVING COUNT(Claim.ClaimId) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Ratings (title VARCHAR(255), genre VARCHAR(255), rating DECIMAL(3,2)); INSERT INTO TV_Ratings (title, genre, rating) VALUES ('TVShow1', 'Comedy', 8.5), ('TVShow2', 'Drama', 9.0), ('TVShow3', 'Comedy', 9.2), ('TVShow4', 'Action', 7.8), ('TVShow5', 'Comedy', 8.7);
What is the highest-rated TV show in the comedy genre?
SELECT title FROM TV_Ratings WHERE genre = 'Comedy' AND rating = (SELECT MAX(rating) FROM TV_Ratings WHERE genre = 'Comedy');
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy_projects (project_id INT, institution_id INT, completion_date DATE);
What is the total number of open pedagogy projects completed per institution in the last year?
SELECT institution_id, COUNT(project_id) FROM open_pedagogy_projects WHERE completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY institution_id;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerCount (GameID int, GameName varchar(100), Genre varchar(50), PlayerCount int); INSERT INTO PlayerCount VALUES (1, 'GameA', 'Action', 100000), (2, 'GameB', 'RPG', 120000), (3, 'GameC', 'Action', 150000), (4, 'GameD', 'Simulation', 110000);
Find the number of players for each game genre.
SELECT Genre, SUM(PlayerCount) as TotalPlayers FROM PlayerCount GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates_sydney (year INT, recycling_rate DECIMAL(5, 2)); INSERT INTO recycling_rates_sydney (year, recycling_rate) VALUES (2017, 0.45), (2018, 0.48), (2019, 0.51), (2021, 0.57);
What was the recycling rate in Sydney from 2018 to 2020?
SELECT year, recycling_rate FROM recycling_rates_sydney WHERE year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureProjects (id INT, name TEXT, category TEXT, budget FLOAT); INSERT INTO InfrastructureProjects (id, name, category, budget) VALUES (1, 'Highway 12 Expansion', 'Transportation', 2000000); INSERT INTO InfrastructureProjects (id, name, category, budget) VALUES (2, 'Bridgewater Park Pedestrian Pat...
What is the total budget for 'Waste Management' projects?
SELECT SUM(budget) FROM InfrastructureProjects WHERE category = 'Waste Management';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT, name VARCHAR(100), primary_investigator VARCHAR(50), primary_investigator_gender VARCHAR(10));INSERT INTO genetics.research_projects (id, name, primary_investigator, primary_investigator_gender) VALUES (1, 'ProjectX', 'A...
What is the distribution of genetic research projects by primary investigator gender?
SELECT primary_investigator_gender, COUNT(*) as total_projects FROM genetics.research_projects GROUP BY primary_investigator_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistConcerts (ArtistID INT, ConcertID INT, AvgPrice DECIMAL(10,2));
Which Hip-Hop artist has the highest average concert ticket price?
SELECT A.Name, AVG(AC.AvgPrice) AS AvgPrice FROM ArtistConcerts AC INNER JOIN Artists A ON AC.ArtistID = A.ArtistID WHERE A.Genre = 'Hip-Hop' GROUP BY A.Name ORDER BY AvgPrice DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE stadiums (stadium_id INT, stadium_name VARCHAR(50), seating_capacity INT); INSERT INTO stadiums (stadium_id, stadium_name, seating_capacity) VALUES (1, 'Luzhniki Stadium', 81000), (2, 'Estadio do Maracanã', 78838); CREATE TABLE matches (match_id INT, stadium_id INT);
Find the number of FIFA World Cup matches played in each stadium with a seating capacity of over 60,000?
SELECT stadium_id, COUNT(*) FROM matches JOIN stadiums ON matches.stadium_id = stadiums.stadium_id WHERE seating_capacity > 60000 GROUP BY stadium_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category VARCHAR(50), billing_amount INT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Civil Litigation', 7000), (3, 'Personal Injury', 6000), (4, 'Civil Litigation', 8000);
Display the total billing amount for cases in the 'Personal Injury' category
SELECT SUM(billing_amount) FROM cases WHERE category = 'Personal Injury';
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (title VARCHAR(100), author_country VARCHAR(50), publication_year INT);
What is the number of autonomous driving research papers published each year since 2015 in the 'research_papers' table?
SELECT publication_year, COUNT(*) FROM research_papers WHERE publication_year >= 2015 GROUP BY publication_year;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, sector, funding) VALUES (1, 'Genetech', 'genetic research', 2000000), (2, 'BioVentures', 'bioprocess engineering', 1500000);
What is the total funding received by startups in the 'genetic research' sector?
SELECT SUM(funding) FROM startups WHERE sector = 'genetic research';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Age INT); CREATE TABLE VolunteerEvents (EventID INT, ProgramID INT, EventDate DATE, VolunteerID INT, ProgramFocus TEXT); CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, FocusArea TEXT);
How many volunteers engaged in mental health programs in the first quarter of this year?
SELECT COUNT(DISTINCT v.VolunteerID) FROM Volunteers v INNER JOIN VolunteerEvents ve ON v.VolunteerID = ve.VolunteerID INNER JOIN Programs p ON ve.ProgramID = p.ProgramID WHERE p.FocusArea = 'Mental Health' AND ve.EventDate >= DATEADD(year, DATEDIFF(year, 0, GETDATE()), 0) AND ve.EventDate < DATEADD(year, DATEDIFF(year...
gretelai_synthetic_text_to_sql
CREATE TABLE Districts (District VARCHAR(255)); INSERT INTO Districts (District) VALUES ('Downtown LA'), ('Hollywood'), ('West LA'), ('South LA'), ('San Fernando Valley'); CREATE TABLE PoliceOfficers (ID INT, District VARCHAR(255), Number INT); INSERT INTO PoliceOfficers (ID, District, Number) VALUES (1, 'Downtown LA',...
What is the total number of police officers in each district of Los Angeles County?
SELECT D.District, SUM(PO.Number) as TotalPoliceOfficers FROM PoliceOfficers PO INNER JOIN Districts D ON PO.District = D.District GROUP BY D.District;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, name VARCHAR(255), offense VARCHAR(255), created_at TIMESTAMP); INSERT INTO offenders (id, name, offense, created_at) VALUES (1, 'John Doe', 'Theft', '2021-01-01 10:00:00'), (2, 'Jane Smith', 'Assault', '2021-01-02 10:00:00'), (3, 'John Doe', 'Vandalism', '2021-01-03 10:00:00');
Who are the top 5 offenders with the highest number of offenses, including their names and total offense counts?
SELECT name, offense, COUNT(*) as total_offenses, RANK() OVER (ORDER BY COUNT(*) DESC) as offender_rank FROM offenders GROUP BY name, offense ORDER BY offender_rank;
gretelai_synthetic_text_to_sql
CREATE TABLE ratings (product_id INT, rating INT, natural_ingredients BOOLEAN); INSERT INTO ratings (product_id, rating, natural_ingredients) VALUES (1, 4, true), (2, 3, false), (3, 5, true), (4, 2, false);
What is the average rating for products containing natural ingredients?
SELECT AVG(rating) FROM ratings WHERE natural_ingredients = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, Title VARCHAR(50), Gallery VARCHAR(50), Size INT); INSERT INTO Artworks (ArtworkID, Title, Gallery, Size) VALUES (1, 'Untitled', 'ContemporaryArt', 100); INSERT INTO Artworks (ArtworkID, Title, Gallery, Size) VALUES (2, 'Untitled2', 'ContemporaryArt', 200);
What is the average size of artworks displayed in the 'ContemporaryArt' gallery?
SELECT AVG(Size) FROM Artworks WHERE Gallery = 'ContemporaryArt';
gretelai_synthetic_text_to_sql
CREATE TABLE VR_Games (id INT, name VARCHAR(50), release_year INT); INSERT INTO VR_Games (id, name, release_year) VALUES (1, 'Beat Saber', 2018), (2, 'Job Simulator', 2016), (3, 'Superhot VR', 2017);
List all virtual reality games and their respective release years
SELECT name, release_year FROM VR_Games;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_efforts (county_name VARCHAR(30), state VARCHAR(20), conservation_score FLOAT);
What are the average water conservation efforts by county in California?
SELECT county_name, AVG(conservation_score) FROM conservation_efforts WHERE state = 'California' GROUP BY county_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (FundingID int, FundingAmount decimal(10,2), FundingDate date, FundingSource varchar(50)); INSERT INTO Funding (FundingID, FundingAmount, FundingDate, FundingSource) VALUES (1, 10000.00, '2020-01-01', 'Government'), (2, 20000.00, '2019-01-01', 'Foundation'), (3, 15000.00, '2021-01-01', 'Government'...
What is the total amount of funding received from government sources in the year 2020?
SELECT SUM(FundingAmount) FROM Funding WHERE FundingDate BETWEEN '2020-01-01' AND '2020-12-31' AND FundingSource = 'Government';
gretelai_synthetic_text_to_sql
CREATE TABLE org_consumer (id INT, name VARCHAR(100), sector VARCHAR(50), ESG_score FLOAT); INSERT INTO org_consumer (id, name, sector, ESG_score) VALUES (1, 'Amazon', 'Consumer Discretionary', 75.0), (2, 'Starbucks', 'Consumer Discretionary', 77.5), (3, 'Home Depot', 'Consumer Discretionary', 72.5);
What is the average ESG score for organizations in the Consumer Discretionary sector?
SELECT AVG(ESG_score) FROM org_consumer WHERE sector = 'Consumer Discretionary';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, project_type VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, project_type, donation_amount, donation_date) VALUES (1, 'Community Development', 100.00, '2021-01-01'), (2, 'Disaster Response', 150.00, '2021-02-15'), (3, 'Community Development', 2...
What was the total amount of donations received by each project type in 2021?
SELECT project_type, SUM(donation_amount) as total_donations FROM donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, organic BOOLEAN); INSERT INTO suppliers (id, name, organic) VALUES (1, 'Green Earth Farms', true), (2, 'Smith Wholesale', false), (3, 'Health Food Inc.', true); CREATE TABLE purchases (supplier_id INT, weight FLOAT); INSERT INTO purchases (supplier_id, weight) VALUES (1, 100.5...
What is the total weight of organic ingredients in the supply chain from farm to table?
SELECT SUM(purchases.weight) FROM purchases JOIN suppliers ON purchases.supplier_id = suppliers.id WHERE suppliers.organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteOrbits (id INT, satellite_name VARCHAR(100), company VARCHAR(100), orbit_altitude FLOAT); INSERT INTO SatelliteOrbits (id, satellite_name, company, orbit_altitude) VALUES (1, 'ISS', 'NASA', 400); INSERT INTO SatelliteOrbits (id, satellite_name, company, orbit_altitude) VALUES (2, 'Hubble', 'NASA',...
What is the lowest orbit altitude for any satellite?
SELECT MIN(orbit_altitude) FROM SatelliteOrbits;
gretelai_synthetic_text_to_sql