context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE cities (city_id INT, city_name VARCHAR(255));CREATE TABLE properties (property_id INT, city_id INT, price DECIMAL(10,2)); INSERT INTO cities (city_id, city_name) VALUES (1, 'CityA'), (2, 'CityB'); INSERT INTO properties (property_id, city_id, price) VALUES (1, 1, 500000.00), (2, 1, 700000.00), (3, 2, 300000.00), (4, 2, 400000.00);
What is the difference in property prices between the most expensive and least expensive property in each city?
SELECT city_id, MAX(price) - MIN(price) as price_difference FROM properties GROUP BY city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Workout (user_id INT, workout_duration INT, country VARCHAR(50)); INSERT INTO Workout (user_id, workout_duration, country) VALUES (1, 30, 'Germany'), (2, 40, 'USA'), (3, 50, 'Germany');
How many users are from Germany in the Workout table?
SELECT COUNT(*) FROM Workout WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE aus_rj_cases(id INT, state VARCHAR(255), plea_bargain VARCHAR(255));
What is the percentage of cases in which plea bargains were offered in restorative justice programs in Australia, and how does it differ between states?
SELECT state, 100.0*SUM(CASE WHEN plea_bargain = 'Yes' THEN 1 ELSE 0 END)/COUNT(*) AS percentage FROM aus_rj_cases GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE test_flights (id INT, company VARCHAR(50), launch_year INT, test_flight BOOLEAN);
How many test flights did SpaceX perform in 2019?
SELECT COUNT(*) FROM test_flights WHERE company = 'SpaceX' AND launch_year = 2019 AND test_flight = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerCountry VARCHAR(20), Game VARCHAR(20), Playtime INT); INSERT INTO Players (PlayerID, PlayerCountry, Game, Playtime) VALUES (1, 'Japan', 'PUBG', 50), (2, 'Japan', 'Fortnite', 60);
What is the total playtime of players who played PUBG in Japan?
SELECT SUM(Playtime) FROM Players WHERE Game = 'PUBG' AND PlayerCountry = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE PRODUCT ( id INT PRIMARY KEY, name TEXT, material TEXT, quantity INT, country TEXT ); INSERT INTO PRODUCT (id, name, material, quantity, country) VALUES (1, 'Organic Cotton Shirt', 'Organic Cotton', 30, 'USA'); INSERT INTO PRODUCT (id, name, material, quantity, country) VALUES (2, 'Recycled Poly Shoes', 'Recycled Polyester', 25, 'Germany'); INSERT INTO PRODUCT (id, name, material, quantity, country) VALUES (3, 'Bamboo T-Shirt', 'Bamboo', 15, 'China');
Which countries have the highest and lowest average product quantities for sustainable materials?
SELECT country, AVG(quantity) as avg_quantity FROM PRODUCT WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Bamboo') GROUP BY country ORDER BY avg_quantity DESC, country ASC LIMIT 1; SELECT country, AVG(quantity) as avg_quantity FROM PRODUCT WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Bamboo') GROUP BY country ORDER BY avg_quantity ASC, country ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE staff_demographics (id INT, name VARCHAR(50), gender VARCHAR(50), ethnicity VARCHAR(50)); INSERT INTO staff_demographics (id, name, gender, ethnicity) VALUES (1, 'John Doe', 'Male', 'Caucasian'), (2, 'Jane Smith', 'Female', 'African American'); CREATE TABLE staff_details (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO staff_details (id, name, department) VALUES (1, 'John Doe', 'Mining Engineering'), (2, 'Jane Smith', 'Human Resources');
List unique workforce demographics and their respective departments in the 'staff_demographics' and 'staff_details' tables.
SELECT staff_demographics.gender, staff_demographics.ethnicity, staff_details.department FROM staff_demographics INNER JOIN staff_details ON staff_demographics.name = staff_details.name;
gretelai_synthetic_text_to_sql
CREATE TABLE DrugApprovals (DrugName varchar(50), ApprovalDate date); INSERT INTO DrugApprovals (DrugName, ApprovalDate) VALUES ('DrugM', '2022-01-05'), ('DrugN', '2022-02-12'), ('DrugO', '2022-03-19'), ('DrugP', '2022-04-23');
What is the average drug approval time for drugs approved in each month, ranked by average approval time?
SELECT YEAR(ApprovalDate) as ApprovalYear, MONTH(ApprovalDate) as ApprovalMonth, AVG(DATEDIFF(day, ApprovalDate, LEAD(ApprovalDate, 1, GETDATE()) OVER (PARTITION BY YEAR(ApprovalDate), MONTH(ApprovalDate) ORDER BY ApprovalDate))), ROW_NUMBER() OVER (ORDER BY AVG(DATEDIFF(day, ApprovalDate, LEAD(ApprovalDate, 1, GETDATE()) OVER (PARTITION BY YEAR(ApprovalDate), MONTH(ApprovalDate) ORDER BY ApprovalDate))) DESC) as ApprovalRank FROM DrugApprovals GROUP BY YEAR(ApprovalDate), MONTH(ApprovalDate);
gretelai_synthetic_text_to_sql
CREATE TABLE police_officers (id INT, name VARCHAR(255), joined_date DATE, state VARCHAR(255)); INSERT INTO police_officers (id, name, joined_date, state) VALUES (1, 'John Doe', '2021-01-02', 'Arizona');
What is the percentage of police officers in Arizona who joined in 2021?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM police_officers WHERE state = 'Arizona')) as percentage FROM police_officers WHERE state = 'Arizona' AND joined_date >= '2021-01-01' AND joined_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_violations (id INT, state VARCHAR(50), violation_date DATE); INSERT INTO mental_health_parity_violations (id, state, violation_date) VALUES (1, 'California', '2022-01-15'), (2, 'Texas', '2022-02-20'), (3, 'New York', '2022-03-05');
List the number of mental health parity violations by state in Q1 2022.
SELECT state, COUNT(*) as num_violations FROM mental_health_parity_violations WHERE violation_date >= '2022-01-01' AND violation_date < '2022-04-01' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Purchases (purchase_id INT, consumer_id INT, supplier_id INT, purchase_date DATE); INSERT INTO Purchases (purchase_id, consumer_id, supplier_id, purchase_date) VALUES (1, 100, 1, '2022-01-01'), (2, 101, 2, '2022-02-15'), (3, 102, 3, '2022-03-05'), (4, 103, 1, '2022-04-10'), (5, 104, 4, '2022-05-22'); CREATE TABLE Suppliers (supplier_id INT, ethical_practices BOOLEAN); INSERT INTO Suppliers (supplier_id, ethical_practices) VALUES (1, true), (2, false), (3, true), (4, false);
Determine the number of unique consumers who have purchased products from suppliers with ethical labor practices.
SELECT COUNT(DISTINCT consumer_id) as unique_ethical_consumers FROM Purchases INNER JOIN Suppliers ON Purchases.supplier_id = Suppliers.supplier_id WHERE Suppliers.ethical_practices = true;
gretelai_synthetic_text_to_sql
CREATE TABLE FlightSafety(id INT, aircraft_id INT, manufacturer VARCHAR(255), flight_hours INT); INSERT INTO FlightSafety(id, aircraft_id, manufacturer, flight_hours) VALUES (1, 1001, 'Boeing', 12000), (2, 1002, 'Airbus', 15500), (3, 1003, 'Boeing', 18000), (4, 1004, 'Airbus', 16000), (5, 1005, 'Airbus', 15200);
What is the average number of flight hours for aircrafts manufactured by Airbus that have more than 15000 flight hours?
SELECT AVG(flight_hours) FROM FlightSafety WHERE manufacturer = 'Airbus' AND flight_hours > 15000;
gretelai_synthetic_text_to_sql
CREATE TABLE UnionMembership (id INT, sector VARCHAR(255), membership DECIMAL(5,2)); INSERT INTO UnionMembership (id, sector, membership) VALUES (1, 'Retail', 0.25);
What is the average Union membership rate in the Retail sector?
SELECT AVG(membership) FROM UnionMembership WHERE sector = 'Retail';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT, birth_rate DECIMAL(4,2), death_rate DECIMAL(4,2));
What is the net change in the population of each animal in the animal_population table?
SELECT animal_name, net_change FROM animal_population_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, publication_date DATE, topic TEXT); INSERT INTO articles VALUES (1, '2022-01-01', 'Media Literacy'), (2, '2022-01-15', 'Content Diversity'), (3, '2022-02-01', 'Media Representation'), (4, '2022-02-15', 'Disinformation Detection'), (5, '2022-03-01', 'Media Literacy'), (6, '2022-03-15', 'Content Diversity'), (7, '2022-04-01', 'Media Literacy'), (8, '2022-04-15', 'Content Diversity'), (9, '2022-05-01', 'Media Representation'), (10, '2022-05-15', 'Disinformation Detection'), (11, '2022-06-01', 'Media Literacy'), (12, '2022-06-15', 'Content Diversity'), (13, '2022-07-01', 'Media Representation'), (14, '2022-07-15', 'Disinformation Detection'), (15, '2022-08-01', 'Media Literacy'), (16, '2022-08-15', 'Content Diversity'), (17, '2022-09-01', 'Media Representation'), (18, '2022-09-15', 'Disinformation Detection'), (19, '2022-10-01', 'Media Literacy'), (20, '2022-10-15', 'Content Diversity'), (21, '2022-11-01', 'Media Representation'), (22, '2022-11-15', 'Disinformation Detection'), (23, '2022-12-01', 'Media Literacy'), (24, '2022-12-15', 'Content Diversity');
What is the total number of articles published in each quarter?
SELECT EXTRACT(QUARTER FROM publication_date) as quarter, COUNT(*) as article_count FROM articles GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS disaster_recovery; CREATE TABLE disaster_recovery.projects (id INT, name VARCHAR(100), co2_emissions FLOAT); INSERT INTO disaster_recovery.projects (id, name, co2_emissions) VALUES (1, 'Hurricane Resilience', 100), (2, 'Flood Mitigation', 80), (3, 'Earthquake Preparedness', 50);
List the names and CO2 emissions for projects in the 'disaster_recovery' schema, ordered by CO2 emissions in descending order
SELECT name, co2_emissions FROM disaster_recovery.projects ORDER BY co2_emissions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE FishPopulation (id INT, species VARCHAR(255), population INT); INSERT INTO FishPopulation (id, species, population) VALUES (1, 'Salmon', 50000); INSERT INTO FishPopulation (id, species, population) VALUES (2, 'Trout', 25000); INSERT INTO FishPopulation (id, species, population) VALUES (3, 'Carp', 40000); INSERT INTO FishPopulation (id, species, population) VALUES (4, 'Tuna', 30000); INSERT INTO FishPopulation (id, species, population) VALUES (5, 'Shrimp', 10000);
Display the species and total population of fish in the 'FishPopulation' table with a population greater than 50000
SELECT species, SUM(population) FROM FishPopulation WHERE population > 50000 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (id INT, name VARCHAR(50), articles_published INT); INSERT INTO journalists (id, name, articles_published) VALUES (1, 'Sasha Petrova', 25), (2, 'Chen Wei', 18), (3, 'Mariana Santos', 22), (4, 'Alessandro Alviani', 15), (5, 'Sana Saeed', 30);
Identify the top 5 most active contributors in the investigative journalism projects, based on the number of articles they have published.
SELECT name, articles_published FROM journalists ORDER BY articles_published DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT PRIMARY KEY, source VARCHAR(50), actionable_report BOOLEAN, report_time TIMESTAMP, organization_size VARCHAR(50)); INSERT INTO threat_intelligence (id, source, actionable_report, report_time, organization_size) VALUES (1, 'FireEye', TRUE, '2022-07-01 10:00:00', 'Large'), (2, 'CrowdStrike', FALSE, '2022-07-02 12:30:00', 'Small'), (3, 'Mandiant', TRUE, '2022-07-03 08:15:00', 'Medium');
List the top 3 sources of threat intelligence that provided the most actionable intelligence in the past month, along with the number of actionable intelligence reports, broken down by organization size.
SELECT source, COUNT(*) as actionable_reports, organization_size FROM threat_intelligence WHERE actionable_report = TRUE AND report_time >= NOW() - INTERVAL '1 month' GROUP BY source, organization_size ORDER BY actionable_reports DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Social_Good_Tech (Program VARCHAR(255), Region VARCHAR(255)); INSERT INTO Social_Good_Tech (Program, Region) VALUES ('EduTech', 'Africa'), ('HealthTech', 'Asia'), ('AgriTech', 'Africa'), ('FinTech', 'Europe');
List all the social good technology programs in Africa.
SELECT Program FROM Social_Good_Tech WHERE Region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE art_styles (id INT, style VARCHAR(255), movement VARCHAR(255)); CREATE TABLE artworks (id INT, title VARCHAR(255), year INT, style_id INT);
Update the year of an artwork with the title 'The Persistence of Memory' to 1931, associated with the style 'Surrealism'.
UPDATE artworks SET year = 1931 WHERE title = 'The Persistence of Memory' AND style_id = (SELECT s.id FROM art_styles s WHERE s.style = 'Surrealism');
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name TEXT, size_km2 FLOAT); INSERT INTO habitats (id, name, size_km2) VALUES (1, 'Forest', 50.3), (2, 'Wetlands', 32.1), (3, 'Grasslands', 87.6);
What is the size of the largest protected habitat in square kilometers?
SELECT MAX(size_km2) as max_size FROM habitats;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (id INT, name VARCHAR(100), model VARCHAR(100), launch_date DATE); INSERT INTO Satellites (id, name, model, launch_date) VALUES (6, 'Sat6', 'Model1', '2021-05-01'); INSERT INTO Satellites (id, name, model, launch_date) VALUES (7, 'Sat7', 'Model2', '2022-03-18'); INSERT INTO Satellites (id, name, model, launch_date) VALUES (8, 'Sat8', 'Model1', '2020-09-25');
What is the latest launch date for each satellite model?
SELECT model, MAX(launch_date) OVER (PARTITION BY model) as max_launch_date FROM Satellites;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (product_name TEXT, ingredient TEXT, sourcing_country TEXT, sustainability_rating FLOAT); INSERT INTO ingredients (product_name, ingredient, sourcing_country, sustainability_rating) VALUES ('ProductA', 'IngredientX', 'USA', 4.2), ('ProductB', 'IngredientY', 'Canada', 3.5), ('ProductC', 'IngredientX', 'USA', 4.8);
Top 5 ingredients sourced from sustainable farms in the USA?
SELECT ingredient, AVG(sustainability_rating) as avg_sustainability_rating FROM ingredients WHERE sourcing_country = 'USA' GROUP BY ingredient ORDER BY avg_sustainability_rating DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE aisafety_research (area VARCHAR(255), lead_researcher VARCHAR(255)); INSERT INTO aisafety_research (area, lead_researcher) VALUES ('Robustness and Generalization', 'Gary Marcus'), ('Interpretability', 'Cynthia Rudin'), ('Value Alignment', 'Stuart Russell');
List all unique AI safety research areas and corresponding lead researchers.
SELECT DISTINCT area, lead_researcher FROM aisafety_research
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT PRIMARY KEY, year INT, threat_level VARCHAR(10), description TEXT);INSERT INTO threat_intelligence (id, year, threat_level, description) VALUES (1, 2018, 'High', 'Cyber attack on defense networks'), (2, 2018, 'Medium', 'Espionage activities'), (3, 2018, 'Low', 'Propaganda campaigns'), (4, 2019, 'High', 'Physical attack on military bases'), (5, 2019, 'Medium', 'Cyber attack on defense networks'), (6, 2019, 'Low', 'Propaganda campaigns');
Generate a view 'threat_trends' to display the number of high, medium, and low threat intelligence metrics by year
CREATE VIEW threat_trends AS SELECT year, SUM(CASE WHEN threat_level = 'High' THEN 1 ELSE 0 END) as high_threats, SUM(CASE WHEN threat_level = 'Medium' THEN 1 ELSE 0 END) as medium_threats, SUM(CASE WHEN threat_level = 'Low' THEN 1 ELSE 0 END) as low_threats FROM threat_intelligence GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE TheaterAttendees (attendeeID INT, visitDate DATE, gender VARCHAR(10)); INSERT INTO TheaterAttendees (attendeeID, visitDate, gender) VALUES (1, '2022-02-05', 'Female'), (2, '2022-02-09', 'Male'), (3, '2022-02-14', 'Female');
How many female attendees visited the theater in the past week?
SELECT COUNT(*) FROM TheaterAttendees WHERE visitDate >= '2022-02-01' AND visitDate <= '2022-02-07' AND gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME); INSERT INTO Artifacts (ArtifactID, Name, CreationDate) VALUES (1, 'Ancient Dagger', '1500-01-01'), (2, 'Modern Artifact', '2020-01-01'), (3, 'Bronze Age Axe', '3500-01-01'), (4, 'Iron Age Helmet', '2500-01-01');
What is the name and creation date of the artifact with the third earliest creation date?
SELECT Name, CreationDate FROM (SELECT Name, CreationDate, ROW_NUMBER() OVER (ORDER BY CreationDate) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houston'), (5, 'Phoenix'); CREATE TABLE mayor (id INT, city_id INT, name VARCHAR(255), gender VARCHAR(10), start_year INT, end_year INT); INSERT INTO mayor (id, city_id, name, gender, start_year, end_year) VALUES (1, 1, 'John Smith', 'Male', 2018, 2021), (2, 1, 'Maria Rodriguez', 'Female', 2005, 2017), (3, 2, 'James Johnson', 'Male', 2015, 2020), (4, 3, 'William Lee', 'Male', 2000, 2005), (5, 3, 'Sarah Lee', 'Female', 2006, 2019), (6, 4, 'Robert Brown', 'Male', 2010, 2019), (7, 5, 'David Garcia', 'Male', 2005, 2011), (8, 5, 'Grace Kim', 'Female', 2012, 2021);
Which cities have had a female mayor for the longest continuous period?
SELECT c.name, MAX(m.end_year - m.start_year) as max_tenure FROM city c JOIN mayor m ON c.id = m.city_id WHERE m.gender = 'Female' GROUP BY c.name HAVING MAX(m.end_year - m.start_year) >= ALL (SELECT MAX(m2.end_year - m2.start_year) FROM mayor m2 WHERE m2.gender = 'Female')
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(50), product_type VARCHAR(50));
What is the total sales for each product type in Q3 of 2022?
SELECT p.product_type, SUM(s.revenue) as q3_sales FROM sales s JOIN products p ON s.product_id = p.product_id WHERE s.sale_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY p.product_type;
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyEfficiency (Country TEXT, Year INT, Score NUMBER); INSERT INTO EnergyEfficiency (Country, Year, Score) VALUES ('South Africa', 2021, 60), ('Egypt', 2021, 65), ('Nigeria', 2021, 70), ('Kenya', 2021, 75), ('Morocco', 2021, 80);
What are the top 3 energy-efficient countries in Africa in 2021?
SELECT Country, Score FROM EnergyEfficiency WHERE Year = 2021 ORDER BY Score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE project_timeline (timeline_id INT, project_id INT, building_type VARCHAR(20), city VARCHAR(20), days INT); INSERT INTO project_timeline (timeline_id, project_id, building_type, city, days) VALUES (1, 301, 'Commercial', 'Chicago', 90), (2, 302, 'Residential', 'Chicago', 60), (3, 303, 'Commercial', 'New York', 120);
What is the average project timeline for commercial buildings in Chicago?
SELECT AVG(days) FROM project_timeline WHERE building_type = 'Commercial' AND city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(50), followers INT); INSERT INTO users (id, country, followers) VALUES (1, 'Brazil', 1000), (2, 'Brazil', 2000), (3, 'Brazil', 1500), (4, 'Canada', 2500), (5, 'Canada', 3000);
Who are the top 5 users with the most followers from Brazil?
SELECT * FROM (SELECT users.id, users.country, users.followers, ROW_NUMBER() OVER (ORDER BY users.followers DESC) as row_num FROM users WHERE users.country = 'Brazil') sub WHERE row_num <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_sourcing_practices(cuisine VARCHAR(255), is_sustainable BOOLEAN); INSERT INTO sustainable_sourcing_practices VALUES ('Italian', true), ('Mexican', false), ('Chinese', true);
What is the percentage of sustainable sourcing practices for each cuisine type?
SELECT cuisine, 100.0 * AVG(CAST(is_sustainable AS DECIMAL)) AS percentage FROM sustainable_sourcing_practices GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (HospitalID INT, Name VARCHAR(50), State VARCHAR(20), FreeTesting BOOLEAN); INSERT INTO Hospitals (HospitalID, Name, State, FreeTesting) VALUES (1, 'Mount Sinai', 'New York', TRUE); INSERT INTO Hospitals (HospitalID, Name, State, FreeTesting) VALUES (2, 'NYU Langone', 'New York', TRUE);
What is the number of hospitals in New York state that offer free COVID-19 testing?
SELECT COUNT(*) FROM Hospitals WHERE State = 'New York' AND FreeTesting = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue_by_month (month VARCHAR(10), category VARCHAR(25), sales DECIMAL(10,2)); INSERT INTO revenue_by_month (month, category, sales) VALUES ('January', 'Italian', 1500.00), ('January', 'Vegan', 1200.00); CREATE VIEW monthly_revenue_by_category AS SELECT month, category, SUM(sales) as total_sales FROM revenue_by_month GROUP BY month, category;
What is the total revenue of each category of dishes in January?
SELECT total_sales FROM monthly_revenue_by_category WHERE month = 'January';
gretelai_synthetic_text_to_sql
CREATE TABLE art_sales (id INT, year INT, art_name VARCHAR(50), art_type VARCHAR(50), sale_price INT);
Which art pieces were sold for the highest and lowest prices in the last 10 years?
SELECT art_name, year, sale_price FROM (SELECT art_name, year, sale_price, DENSE_RANK() OVER (ORDER BY sale_price DESC) as rank FROM art_sales WHERE year >= 2012) a WHERE rank <= 1 OR rank >= 11;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (assistance_id INT, provider TEXT, recipient TEXT, amount FLOAT, year INT); INSERT INTO humanitarian_assistance (assistance_id, provider, recipient, amount, year) VALUES (1, 'Japan', 'Syria', 1000000, 2020), (2, 'Japan', 'Afghanistan', 500000, 2020);
What is the total humanitarian assistance provided by Japan in 2020?
SELECT SUM(amount) FROM humanitarian_assistance WHERE provider = 'Japan' AND year = 2020
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (Spacecraft_ID INT, Name VARCHAR(100), Manufacturer VARCHAR(100), Mass FLOAT, Operational BOOLEAN); INSERT INTO Spacecrafts (Spacecraft_ID, Name, Manufacturer, Mass, Operational) VALUES (1, 'Crew Dragon', 'SpaceX', 14000.0, TRUE);
What is the average mass of operational spacecraft in the 'Spacecrafts' table?
SELECT AVG(Mass) FROM Spacecrafts WHERE Operational = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_programs (id INT, location VARCHAR(20), min_stay INT); INSERT INTO volunteer_programs (id, location, min_stay) VALUES (1, 'Nepal', 14), (2, 'Nepal', 21), (3, 'Nepal', 10);
What is the minimum stay required for volunteer tourism in Nepal?
SELECT MIN(min_stay) FROM volunteer_programs WHERE location = 'Nepal';
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (id INT, name TEXT, issue_date DATE, material TEXT); INSERT INTO Permits (id, name, issue_date, material) VALUES (1, 'High-Rise Construction', '2023-02-01', 'Concrete'), (2, 'Townhome Construction', '2023-03-15', 'Wood');
List the name and material of all the building permits issued in the last 3 months, with the most recent permits first.
SELECT name, material FROM Permits WHERE issue_date > (CURRENT_DATE - INTERVAL '3 months') ORDER BY issue_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Launches (LaunchID INT, LaunchDate DATE, SatelliteName VARCHAR(50), Country VARCHAR(50), Success VARCHAR(50)); INSERT INTO Launches (LaunchID, LaunchDate, SatelliteName, Country, Success) VALUES (1, '2020-01-01', 'Sat1', 'USA', 'Success'); INSERT INTO Launches (LaunchID, LaunchDate, SatelliteName, Country, Success) VALUES (2, '2020-02-10', 'Sat2', 'China', 'Failure');
Count the number of successful satellite launches per country
SELECT Country, COUNT(*) FROM Launches WHERE Success = 'Success' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE artist (id INT, name VARCHAR(100)); CREATE TABLE album (id INT, title VARCHAR(100), artist_id INT, release_year INT); CREATE TABLE song (id INT, title VARCHAR(100), album_id INT, track_number INT); INSERT INTO artist (id, name) VALUES (1, 'Taylor Swift'); INSERT INTO album (id, title, artist_id, release_year) VALUES (1, 'Album1', 1, 2010); INSERT INTO song (id, title, album_id, track_number) VALUES (1, 'Song1', 1, 1);
What's the total number of songs and albums released by a specific artist, such as 'Taylor Swift'?
SELECT COUNT(*), (SELECT COUNT(*) FROM album WHERE artist_id = artist.id) as album_count FROM song WHERE artist_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_audits (id INT, model_id INT, safety_score INT, created_at DATETIME); INSERT INTO safety_audits (id, model_id, safety_score, created_at) VALUES (1, 1, 8, '2021-01-01'); INSERT INTO safety_audits (id, model_id, safety_score, created_at) VALUES (2, 2, 9, '2021-01-02'); INSERT INTO safety_audits (id, model_id, safety_score, created_at) VALUES (3, 3, 6, '2021-01-03');
What is the average safety score for models that have at least one safety score greater than 7?
SELECT model_id, AVG(safety_score) as avg_safety_score FROM safety_audits WHERE model_id IN (SELECT model_id FROM safety_audits WHERE safety_score > 7 GROUP BY model_id HAVING COUNT(*) > 1) GROUP BY model_id;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (id INT, technique VARCHAR(255), application VARCHAR(255)); INSERT INTO explainable_ai (id, technique, application) VALUES (1, 'SHAP', 'Image generation'), (2, 'LIME', 'Music composition'), (3, 'TreeExplainer', 'Text summarization'), (4, 'DeepLIFT', 'Painting style transfer');
List all explainable AI techniques and their applications, if any, in the creative AI domain.
SELECT technique, application FROM explainable_ai WHERE application IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE students(id INT, program VARCHAR(255), gpa DECIMAL(3,2)); INSERT INTO students VALUES (1, 'traditional learning', 2.8), (2, 'traditional learning', 3.5), (3, 'traditional learning', 3.9);
What is the minimum GPA for students in the traditional learning program?
SELECT MIN(gpa) FROM students WHERE program = 'traditional learning';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50), capacity INT); INSERT INTO hospitals (id, name, location, capacity) VALUES (1, 'Mumbai Hospital', 'Mumbai', 600); CREATE TABLE infections (id INT, patient_id INT, infection VARCHAR(50), date DATE, hospital_id INT); INSERT INTO infections (id, patient_id, infection, date, hospital_id) VALUES (1, 1, 'Covid-19', '2022-01-01', 1);
Which hospitals in Mumbai have a capacity greater than 500 and have reported COVID-19 cases?
SELECT hospitals.name, hospitals.capacity FROM hospitals INNER JOIN infections ON hospitals.id = infections.hospital_id WHERE hospitals.location = 'Mumbai' AND hospitals.capacity > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE market_share (id INT, year INT, country VARCHAR(255), vehicle_type VARCHAR(255), market_share DECIMAL(5,2)); INSERT INTO market_share (id, year, country, vehicle_type, market_share) VALUES (1, 2022, 'China', 'Hybrid Vehicle', 0.15), (2, 2021, 'China', 'Hybrid Vehicle', 0.13);
What is the total number of hybrid vehicles in the Chinese market as of 2022?
SELECT SUM(market_share*1000000) FROM market_share WHERE year = 2022 AND country = 'China' AND vehicle_type = 'Hybrid Vehicle';
gretelai_synthetic_text_to_sql
CREATE TABLE patient_diabetes (patient_id INT, age INT, diagnosis VARCHAR(50), location VARCHAR(20)); INSERT INTO patient_diabetes (patient_id, age, diagnosis, location) VALUES (1, 55, 'Diabetes', 'Rural Montana'); INSERT INTO patient_diabetes (patient_id, age, diagnosis, location) VALUES (2, 60, 'Diabetes', 'Rural Montana'); INSERT INTO patient_diabetes (patient_id, age, diagnosis, location) VALUES (3, 45, 'Pre-diabetes', 'Urban Montana');
What is the average age of patients diagnosed with diabetes in rural areas of Montana?
SELECT AVG(age) FROM patient_diabetes WHERE diagnosis = 'Diabetes' AND location = 'Rural Montana';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Age INT, Country VARCHAR(20)); INSERT INTO Customers (CustomerID, FirstName, LastName, Age, Country) VALUES (1, 'Sanaa', 'Ali', 32, 'Morocco'); INSERT INTO Customers (CustomerID, FirstName, LastName, Age, Country) VALUES (2, 'Javier', 'Gonzalez', 47, 'Mexico'); INSERT INTO Customers (CustomerID, FirstName, LastName, Age, Country) VALUES (3, 'Xueyan', 'Wang', 51, 'China'); INSERT INTO Customers (CustomerID, FirstName, LastName, Age, Country) VALUES (4, 'Rajesh', 'Patel', 45, 'India'); INSERT INTO Customers (CustomerID, FirstName, LastName, Age, Country) VALUES (5, 'Ana', 'Santos', 50, 'Brazil');
Count the number of customers from India and Brazil who are above 40 years old.
SELECT COUNT(*) FROM Customers WHERE Age > 40 AND Country IN ('India', 'Brazil');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (region VARCHAR(20), revenue INT, sale_date DATE); INSERT INTO sales (region, revenue, sale_date) VALUES ('East Coast', 500, '2021-01-01'), ('West Coast', 300, '2021-01-01'), ('Midwest', 400, '2021-01-01'), ('East Coast', 600, '2021-01-02'), ('West Coast', 400, '2021-01-02'), ('Midwest', 500, '2021-01-02');
What is the average revenue per day for each region?
SELECT region, AVG(revenue) FROM sales GROUP BY region, EXTRACT(DAY FROM sale_date);
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, employee_name TEXT, department TEXT); CREATE TABLE transactions (transaction_id INT, employee_id INT, transaction_status TEXT);
Calculate the percentage of transactions completed by each employee in the Human Resources department.
SELECT e.employee_name, 100.0 * COUNT(t.transaction_id) / SUM(COUNT(t.transaction_id)) OVER (PARTITION BY NULL) AS transaction_percentage FROM transactions t JOIN employees e ON t.employee_id = e.employee_id WHERE e.department = 'Human Resources' GROUP BY e.employee_id, e.employee_name;
gretelai_synthetic_text_to_sql
CREATE TABLE north_american_conservation_areas (id INT, name VARCHAR(255), state VARCHAR(255)); CREATE TABLE community_education_programs (id INT, conservation_area_id INT, program_type VARCHAR(255), date DATE, attendees INT);
How many community education programs were conducted in the North American conservation areas, broken down by state and program type?
SELECT na.state, pe.program_type, COUNT(pe.id) as program_count FROM north_american_conservation_areas na JOIN community_education_programs pe ON na.id = pe.conservation_area_id GROUP BY na.state, pe.program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE tool (category VARCHAR(20), tool VARCHAR(20), score INT); INSERT INTO tool (category, tool, score) VALUES ('AI', 'Chatbot', 85), ('AI', 'Image Recognition', 90), ('Data', 'Data Visualization', 80);
What is the tool with the lowest score?
SELECT tool, score FROM tool WHERE score = (SELECT MIN(score) FROM tool);
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INTEGER, fan_state TEXT);
How many fans are from NY in the fan_demographics table?
SELECT COUNT(*) FROM fan_demographics WHERE fan_state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE programs(id INT, name VARCHAR(255), year INT, budget FLOAT); INSERT INTO programs (id, name, year, budget) VALUES (1, 'Heritage Preservation', 2021, 1000000.00), (2, 'Arts Education', 2022, 750000.00), (3, 'Heritage Preservation', 2022, 1200000.00);
What was the total budget for the 'Heritage Preservation' program in 2021?
SELECT budget FROM programs WHERE name = 'Heritage Preservation' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatIntelligence (ID INT, Year INT, ThreatLevel TEXT); INSERT INTO ThreatIntelligence (ID, Year, ThreatLevel) VALUES (1, 2017, 'High'), (2, 2018, 'Low'), (3, 2019, 'Medium');
Delete all threat intelligence records from 2018
DELETE FROM ThreatIntelligence WHERE Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset (id INT, project_type VARCHAR(50), country VARCHAR(50), offset_amount INT);
What is the total carbon offset by renewable energy projects in Brazil?
SELECT SUM(offset_amount) FROM carbon_offset WHERE country = 'Brazil' AND project_type = 'renewable';
gretelai_synthetic_text_to_sql
CREATE TABLE Tuberculosis (Country TEXT, Age TEXT, Cases INT); INSERT INTO Tuberculosis (Country, Age, Cases) VALUES ('India', '0-4', 100), ('India', '5-9', 200), ('India', '10-14', 300);
What is the most common age group for Tuberculosis cases in India?
SELECT Age, MAX(Cases) FROM Tuberculosis WHERE Country = 'India' GROUP BY Age;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, ArtworkName VARCHAR(50), Genre VARCHAR(20)); INSERT INTO Artworks (ArtworkID, ArtworkName, Genre) VALUES (1, 'The Joy of Life', 'Fauvism'); CREATE TABLE ExhibitionsArtworks (ExhibitionID INT, ArtworkID INT, Location VARCHAR(20)); INSERT INTO ExhibitionsArtworks (ExhibitionID, ArtworkID) VALUES (1, 1); CREATE TABLE Sales (SaleID INT, ArtworkID INT, Genre VARCHAR(20), Revenue FLOAT, Location VARCHAR(20)); INSERT INTO Sales (SaleID, ArtworkID, Genre, Revenue, Location) VALUES (1, 1, 'Fauvism', NULL, 'Japan'), (2, 1, NULL, 2000.00, 'Germany');
Find the number of exhibitions in Asia featuring artworks from the 'Fauvism' genre and the total revenue generated from sales of 'Impressionism' genre artworks in Germany.
SELECT COUNT(DISTINCT ExhibitionsArtworks.ExhibitionID), SUM(Sales.Revenue) FROM ExhibitionsArtworks INNER JOIN Sales ON ExhibitionsArtworks.ArtworkID = Sales.ArtworkID WHERE ExhibitionsArtworks.Location = 'Asia' AND Sales.Genre = 'Impressionism' AND Sales.Location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (tx_id INT, contract_name VARCHAR(255), tx_value DECIMAL(10,2)); INSERT INTO Transactions (tx_id, contract_name, tx_value) VALUES (1, 'SmartContractF', 150.50); INSERT INTO Transactions (tx_id, contract_name, tx_value) VALUES (2, 'SmartContractF', 250.75);
What is the average transaction value for 'SmartContractF'?
SELECT AVG(tx_value) FROM Transactions WHERE contract_name = 'SmartContractF';
gretelai_synthetic_text_to_sql
CREATE TABLE multimodal_mobility (station_name VARCHAR(255), city VARCHAR(255), mode VARCHAR(255));
Insert a new record into the 'multimodal_mobility' table with 'station_name'='Capitol Hill', 'city'='Seattle', 'mode'='Scooter Share'
INSERT INTO multimodal_mobility (station_name, city, mode) VALUES ('Capitol Hill', 'Seattle', 'Scooter Share');
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, location, state) VALUES (5, 'Diablo Canyon Power Plant', 'Power Plant', 'San Luis Obispo', 'California');
Display the number of power plants in California
SELECT COUNT(*) FROM Infrastructure WHERE type = 'Power Plant' AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE petitions (id INT PRIMARY KEY, department_id INT, title VARCHAR(255));
Update the petition titles in the 'petitions' table to uppercase for petitions related to the 'Education' department.
UPDATE petitions SET title = UPPER(title) WHERE department_id IN (SELECT id FROM departments WHERE name = 'Education');
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (application_name TEXT, application_type TEXT); INSERT INTO creative_ai (application_name, application_type) VALUES ('App7', 'Image Generation'), ('App8', 'Text Generation'), ('App9', 'Image Generation');
What is the most common application type in creative AI?
SELECT application_type, COUNT(*) FROM creative_ai GROUP BY application_type ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_projects_world (project_name VARCHAR(50), budget DECIMAL(10,2), year INT); INSERT INTO autonomous_projects_world (project_name, budget, year) VALUES ('Project Pegasus', 9000000, 2022), ('Project Quantum', 11000000, 2022), ('Project Orion', 8500000, 2022), ('Project Titan', 10000000, 2022), ('Project Neo', 12000000, 2022);
List all autonomous driving research projects with a budget over $8 million in 2022.
SELECT * FROM autonomous_projects_world WHERE budget > 8000000 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Buildings (Project_ID INT, Project_Name VARCHAR(255), State VARCHAR(255), Labor_Cost DECIMAL(10,2)); INSERT INTO Green_Buildings (Project_ID, Project_Name, State, Labor_Cost) VALUES (1, 'Solar Farm', 'Texas', 200000.00), (2, 'Wind Turbine Park', 'Oklahoma', 180000.00);
What is the total labor cost for green building projects in Texas and Oklahoma?
SELECT State, SUM(Labor_Cost) FROM Green_Buildings WHERE State IN ('Texas', 'Oklahoma') GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE TrafficViolations (ID INT, Precinct VARCHAR(20), Fine FLOAT); INSERT INTO TrafficViolations (ID, Precinct, Fine) VALUES (1, 'Precinct1', 150.0), (2, 'Precinct2', 200.0), (3, 'Precinct3', 125.0);
What is the average fine issued for traffic violations in each police precinct?
SELECT Precinct, AVG(Fine) OVER (PARTITION BY Precinct) AS AvgFine FROM TrafficViolations;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_database.bridges (bridge_id INT, name VARCHAR(255)); CREATE TABLE infrastructure_database.dams (dam_id INT, name VARCHAR(255)); CREATE TABLE infrastructure_database.roads (road_id INT, name VARCHAR(255)); INSERT INTO infrastructure_database.bridges (bridge_id, name) VALUES (1, 'Brooklyn Bridge'), (2, 'Tower Bridge'); INSERT INTO infrastructure_database.dams (dam_id, name) VALUES (1, 'Hoover Dam'), (2, 'Grand Coulee Dam'); INSERT INTO infrastructure_database.roads (road_id, name) VALUES (1, 'Autobahn'), (2, 'I-95');
What is the total number of bridges, dams, and roads in the 'infrastructure_database' schema?
SELECT COUNT(*) FROM (SELECT * FROM infrastructure_database.bridges UNION ALL SELECT * FROM infrastructure_database.dams UNION ALL SELECT * FROM infrastructure_database.roads);
gretelai_synthetic_text_to_sql
CREATE TABLE Staff (StaffID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50)); INSERT INTO Staff (StaffID, FirstName, LastName, Position) VALUES (1, 'John', 'Doe', 'Manager'), (2, 'Jane', 'Doe', 'Assistant Manager'), (3, 'Bob', 'Smith', 'Coordinator');
Insert a new record for a staff member 'Jamal Jackson' in the 'Staff' table.
INSERT INTO Staff (StaffID, FirstName, LastName, Position) VALUES (5, 'Jamal', 'Jackson', 'Specialist');
gretelai_synthetic_text_to_sql
CREATE TABLE concert_sales (sale_id INT, concert_name VARCHAR(100), total_tickets_sold INT); INSERT INTO concert_sales (sale_id, concert_name, total_tickets_sold) VALUES (1, 'Stadium Tour', 1000000); INSERT INTO concert_sales (sale_id, concert_name, total_tickets_sold) VALUES (2, 'Arena Tour', 750000);
How many concert tickets were sold for the 'Stadium Tour'?
SELECT total_tickets_sold FROM concert_sales WHERE concert_name = 'Stadium Tour';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, assessment_date DATE, assessment_score INT);
Update all mental health assessment scores below 70 for students in the past month in the 'student_mental_health' table to 70.
UPDATE student_mental_health SET assessment_score = 70 WHERE assessment_score < 70 AND assessment_date >= DATE(NOW()) - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE genre_songs (genre VARCHAR(50), song_length FLOAT); INSERT INTO genre_songs (genre, song_length) VALUES ('Pop', 225.0), ('Rock', 275.0), ('Pop', 195.0), ('Rock', 260.0);
What is the difference between the average song length of 'Pop' and 'Rock' genres?
SELECT AVG(gs1.song_length) - AVG(gs2.song_length) FROM genre_songs gs1 JOIN genre_songs gs2 ON gs1.genre = 'Pop' AND gs2.genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Heights (Building_ID INT, Building_Type VARCHAR(50), Stories INT, Location VARCHAR(50));
What is the maximum number of stories in high-rise residential buildings in Singapore?
SELECT MAX(Stories) FROM Building_Heights WHERE Building_Type = 'Residential' AND Location = 'Singapore';
gretelai_synthetic_text_to_sql
CREATE TABLE nba_games (game_id INT, home_team_id INT, away_team_id INT); CREATE TABLE nba_game_scores (game_id INT, team_id INT, player_name VARCHAR(255), rebounds INT);
Identify the players with the most rebounds in a single game in the 'nba_games' table.
SELECT game_id, home_team_id AS team_id, player_name, rebounds FROM nba_game_scores WHERE rebounds = (SELECT MAX(rebounds) FROM nba_game_scores) UNION ALL SELECT game_id, away_team_id, player_name, rebounds FROM nba_game_scores WHERE rebounds = (SELECT MAX(rebounds) FROM nba_game_scores);
gretelai_synthetic_text_to_sql
CREATE TABLE theater_events (event_id INT, event_type VARCHAR(255), num_attendees INT); INSERT INTO theater_events (event_id, event_type, num_attendees) VALUES (1, 'Musical', 100), (2, 'Play', 120), (3, 'Opera', 150);
What is the average attendance at the "theater_events" table for musicals?
SELECT AVG(num_attendees) FROM theater_events WHERE event_type = 'Musical';
gretelai_synthetic_text_to_sql
CREATE TABLE community_centers (id INT, name VARCHAR(255)); INSERT INTO community_centers (id, name) VALUES (1, 'Community Center A'), (2, 'Community Center B'), (3, 'Community Center C'), (4, 'Community Center D'); CREATE TABLE treatments (id INT, community_center_id INT, patient_id INT, type VARCHAR(255)); INSERT INTO treatments (id, community_center_id, patient_id, type) VALUES (1, 1, 1, 'therapy'), (2, 1, 2, 'counseling'), (3, 2, 3, 'meditation'), (4, 4, 4, 'therapy'), (5, 4, 5, 'counseling'); CREATE TABLE patients (id INT, age INT); INSERT INTO patients (id, age) VALUES (1, 35), (2, 45), (3, 50), (4, 30), (5, 40);
Find the number of unique patients who received therapy, counseling, or meditation sessions in Community Center D.
SELECT COUNT(DISTINCT patient_id) FROM treatments t WHERE t.community_center_id = 4 AND t.type IN ('therapy', 'counseling', 'meditation');
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO organizations (id, name, budget) VALUES (1, 'ABC Corp', 5000000.00), (2, 'XYZ Inc', 8000000.00), (3, 'DEF Org', 9000000.00), (4, 'GHI Co', 6000000.00);
What is the name of the organization that has the maximum budget allocated for digital divide research?
SELECT name FROM organizations WHERE budget = (SELECT MAX(budget) FROM organizations);
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, name TEXT, country TEXT, position TEXT); INSERT INTO military_personnel (id, name, country, position) VALUES (1, 'John Doe', 'USA', 'Army Officer'); INSERT INTO military_personnel (id, name, country, position) VALUES (2, 'Jane Smith', 'USA', 'Intelligence Agent'); INSERT INTO military_personnel (id, name, country, position) VALUES (3, 'Li Yang', 'China', 'Army General'); INSERT INTO military_personnel (id, name, country, position) VALUES (4, 'Zhang Wei', 'China', 'Intelligence Officer');
What is the total number of military personnel and intelligence agents from the US and China, grouped by their respective countries?
SELECT m.country, COUNT(*) as total FROM military_personnel m JOIN (SELECT * FROM military_personnel WHERE position LIKE '%Intelligence%') i ON m.country = i.country GROUP BY m.country;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_speeds (id INT, location VARCHAR(50), download_speed FLOAT); INSERT INTO broadband_speeds (id, location, download_speed) VALUES (1, 'Illinois', 60.5), (2, 'Texas', 45.7), (3, 'Illinois', 52.9);
What is the total number of broadband customers in the state of Illinois who have a download speed greater than 50 Mbps?
SELECT COUNT(*) FROM broadband_speeds WHERE location = 'Illinois' AND download_speed > 50;
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, 'United Auto Workers', 'Automobiles, Aerospace', 400000);
What is the total number of members in unions that focus on 'Aerospace'?
SELECT SUM(members) FROM unions WHERE domain LIKE '%Aerospace%';
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicSales (product_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO OrganicSales (product_id, sale_date, revenue) VALUES (1, '2021-01-01', 50.00), (2, '2021-01-15', 120.00);
What is the total revenue of organic products sold in the last quarter?
SELECT SUM(revenue) FROM OrganicSales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE AND product_id IN (SELECT product_id FROM OrganicProducts);
gretelai_synthetic_text_to_sql
CREATE TABLE Orders (OrderID INT, CustomerID INT, OrderDate DATETIME); CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50), LoyaltyTier VARCHAR(50), MembershipDate DATETIME);
What is the average time between orders for each customer, grouped by loyalty tier?
SELECT Customers.LoyaltyTier, AVG(DATEDIFF('day', LAG(Orders.OrderDate) OVER (PARTITION BY Customers.CustomerID ORDER BY Orders.OrderDate), Orders.OrderDate)) as AverageTimeBetweenOrders FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID GROUP BY Customers.LoyaltyTier;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, department VARCHAR(255), incident_time TIMESTAMP); INSERT INTO security_incidents (id, department, incident_time) VALUES (1, 'HR', '2022-02-07 15:45:00'), (2, 'IT', '2022-02-15 11:00:00'), (3, 'Finance', '2022-02-12 08:30:00');
What are the security incidents that involved the finance department in the past week?
SELECT * FROM security_incidents WHERE department = 'Finance' AND incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE tour_revenue(id INT, country TEXT, booking_date DATE, revenue INT); INSERT INTO tour_revenue (id, country, booking_date, revenue) VALUES (1, 'Canada', '2022-01-01', 2000), (2, 'Canada', '2022-02-01', 3000), (3, 'Canada', '2022-03-01', 4000);
What is the total revenue of virtual tours in Canada in the last quarter?
SELECT SUM(revenue) FROM tour_revenue WHERE country = 'Canada' AND booking_date >= DATEADD(quarter, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(50)); CREATE TABLE engagements (user_id INT, content_id INT, engagement_type VARCHAR(50), timestamp DATETIME);
How many unique users from the USA engaged with LGBTQ+ related content in the past week?
SELECT COUNT(DISTINCT users.id) FROM users JOIN engagements ON users.id = engagements.user_id WHERE users.country = 'USA' AND engagements.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW() AND engagements.content_id IN (SELECT id FROM content WHERE content.topic = 'LGBTQ+');
gretelai_synthetic_text_to_sql
CREATE TABLE Stadiums (StadiumID INT, StadiumName VARCHAR(255));CREATE TABLE Games (GameID INT, StadiumID INT, GameName VARCHAR(255), TicketPrice DECIMAL(5,2));
Find the top 3 most expensive games per stadium, displaying only the stadium name, game name, and ticket price.
SELECT StadiumName, GameName, TicketPrice FROM (SELECT StadiumName, GameName, TicketPrice, ROW_NUMBER() OVER (PARTITION BY StadiumName ORDER BY TicketPrice DESC) AS Rank FROM Stadiums JOIN Games ON Stadiums.StadiumID = Games.StadiumID) AS Subquery WHERE Subquery.Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT, author_name VARCHAR(50), title VARCHAR(100), published_date DATE);
Count the number of articles published per day in the 'news_articles' table
SELECT published_date, COUNT(article_id) as articles_per_day FROM news_articles GROUP BY published_date;
gretelai_synthetic_text_to_sql
CREATE TABLE last_month_drought(state VARCHAR(20), severity INT); INSERT INTO last_month_drought(state, severity) VALUES ('California', 6), ('Texas', 4), ('Florida', 3);
Find the states with moderate drought severity in the last month.
SELECT state FROM last_month_drought WHERE severity = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (initiative_id INT, initiative_name VARCHAR(255), launch_date DATE, region VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO initiative (initiative_id, initiative_name, launch_date, region, budget) VALUES (1, 'Accessible Software Development', '2018-04-01', 'North America', 500000), (2, 'Adaptive Hardware Prototyping', '2019-12-15', 'Europe', 750000), (3, 'Digital Inclusion Program', '2020-08-03', 'Asia', 800000), (4, 'Diverse Tech Talent Network', '2021-02-22', 'Africa', 600000), (5, 'Global Accessibility Campaign', '2022-01-01', 'Latin America', 900000);
What is the maximum budget for an accessible technology initiative in Latin America?
SELECT MAX(budget) as max_budget FROM initiative WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id serial, contract_name varchar(20), regulatory_framework varchar(20)); INSERT INTO smart_contracts (contract_id, contract_name, regulatory_framework) VALUES (1, 'ContractA', 'GDPR'), (2, 'ContractB', 'HIPAA'), (3, 'ContractC', 'GDPR');
List all smart contracts associated with the regulatory framework 'GDPR'.
SELECT contract_name FROM smart_contracts WHERE regulatory_framework = 'GDPR';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (id INT, name VARCHAR(50), sustainable_purchase_date DATE); INSERT INTO Customers (id, name, sustainable_purchase_date) VALUES (1, 'Alice', '2022-01-01'), (2, 'Bob', '2022-02-15'), (3, 'Charlie', '2022-03-05'), (4, 'David', '2022-04-10'), (5, 'Eve', '2022-05-25'), (6, 'Frank', '2022-06-12');
How many unique customers purchased sustainable clothing in the last 6 months?
SELECT COUNT(DISTINCT id) FROM Customers WHERE sustainable_purchase_date >= DATEADD(MONTH, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (name TEXT, start_year INT, end_year INT, location TEXT);
Which projects were started before 1990 and completed after 2010?
SELECT name FROM Projects WHERE start_year < 1990 AND end_year > 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE MappingData (Location VARCHAR(255), Depth INT, Coordinates VARCHAR(255)); INSERT INTO MappingData (Location, Depth, Coordinates) VALUES ('Mariana Trench', 36000, '14.5851, 145.7154');
What is the depth and coordinate of the Mariana Trench?
SELECT Depth, Coordinates FROM MappingData WHERE Location = 'Mariana Trench';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, type TEXT); CREATE TABLE materials (id INT, name TEXT, supplier_id INT, organic BOOLEAN); INSERT INTO suppliers (id, name, type) VALUES (1, 'Supplier 1', 'Type A'), (2, 'Supplier 2', 'Type B'), (3, 'Supplier 3', 'Type A'), (4, 'Supplier 4', 'Type B'), (5, 'Supplier 5', 'Type A'); INSERT INTO materials (id, name, supplier_id, organic) VALUES (1, 'Material 1', 1, true), (2, 'Material 2', 2, false), (3, 'Material 3', 3, true), (4, 'Material 4', 4, true), (5, 'Material 5', 5, false);
Who are the top 3 suppliers of organic cotton?
SELECT suppliers.name FROM suppliers INNER JOIN materials ON suppliers.id = materials.supplier_id WHERE materials.organic = true GROUP BY suppliers.name ORDER BY COUNT(*) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(project VARCHAR(50), country VARCHAR(20), amount DECIMAL(10,2));INSERT INTO investments(project, country, amount) VALUES('ProjectX', 'Japan', 2000000.00), ('ProjectY', 'US', 3000000.00), ('ProjectZ', 'Japan', 4000000.00);
What is the total investment in biosensor technology development in Japan?
SELECT SUM(amount) FROM investments WHERE country = 'Japan' AND project = 'Biosensor';
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, state TEXT, policy_type TEXT, premium FLOAT); INSERT INTO policyholders (id, name, state, policy_type, premium) VALUES (1, 'John Doe', 'FL', 'Auto', 1200.00), (2, 'Jane Smith', 'FL', 'Auto', 1200.00), (3, 'Jim Brown', 'CA', 'Home', 2500.00);
Find policy types with more than one policyholder living in 'FL'.
SELECT policy_type, COUNT(DISTINCT name) as num_policyholders FROM policyholders WHERE state = 'FL' GROUP BY policy_type HAVING num_policyholders > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE hiring (id INT, employee_id INT, hire_date DATE);
Find the number of employees hired in each month of 2021 from the "hiring" table
SELECT EXTRACT(MONTH FROM hire_date) AS month, COUNT(*) AS num_hires FROM hiring WHERE hire_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists smart_contracts (contract_id INT, contract_address VARCHAR(255), network VARCHAR(255)); INSERT INTO smart_contracts (contract_id, contract_address, network) VALUES (1, '0x123...', 'Ethereum'), (2, '0x456...', 'Binance Smart Chain'), (3, '0x789...', 'Tron'), (4, '0xabc...', 'Cardano'), (5, '0xdef...', 'Polkadot'), (6, '0xghi...', 'Solana');
What is the total number of smart contracts deployed on each blockchain network?
SELECT network, COUNT(*) as contract_count FROM smart_contracts GROUP BY network;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels(VesselID INT, VesselName TEXT, Speed FLOAT, Timestamp DATETIME); INSERT INTO Vessels(VesselID, VesselName, Speed, Timestamp) VALUES (1, 'Vessel1', 15.2, '2022-01-01 10:00:00'), (2, 'Vessel2', 18.5, '2022-01-01 11:00:00');
What is the average speed of all vessels near the Port of Los Angeles in the past week?
SELECT AVG(Speed) FROM Vessels WHERE Timestamp BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE AND VesselName IN (SELECT VesselName FROM Vessels WHERE Timestamp BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE AND ABS(X() - LOCATION_X) < 50 AND ABS(Y() - LOCATION_Y) < 50);
gretelai_synthetic_text_to_sql