context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE facilities (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO facilities (id, name, location, capacity) VALUES (1, 'Rural Family Health Center', 'Florida', 50), (2, 'Rural General Hospital', 'Florida', 200), (3, 'Rural Community Clinic', 'Georgia', 25);
|
What is the combined capacity of all rural healthcare facilities in Florida?
|
SELECT SUM(capacity) FROM facilities WHERE location = 'Florida';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Operations (OperationID INT, MineName VARCHAR(50), OperationType VARCHAR(50), StartDate DATE, EndDate DATE, TotalTonnes DECIMAL(10,2)); INSERT INTO Operations (OperationID, MineName, OperationType, StartDate, EndDate, TotalTonnes) VALUES (1, 'ABC Mine', 'Coal Mining', '2020-01-01', '2020-12-31', 150000.00); INSERT INTO Operations (OperationID, MineName, OperationType, StartDate, EndDate, TotalTonnes) VALUES (2, 'DEF Mine', 'Gold Mining', '2020-01-01', '2020-12-31', 5000.00);
|
What is the total tonnes extracted by each mining operation, ordered by the most to least?
|
SELECT OperationID, MineName, OperationType, TotalTonnes, ROW_NUMBER() OVER (ORDER BY TotalTonnes DESC) as 'Rank' FROM Operations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication (project_id INTEGER, project_name TEXT, location TEXT); INSERT INTO climate_communication (project_id, project_name, location) VALUES (1, 'Project I', 'North America'), (2, 'Project J', 'Europe');
|
Which climate communication projects are not in 'North America'?
|
SELECT project_name FROM climate_communication WHERE location != 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (movie_id INT, title TEXT, genre TEXT, release_date DATE, platform TEXT); INSERT INTO movies (movie_id, title, genre, release_date, platform) VALUES (1, 'Movie 10', 'Comedy', '2018-01-01', 'Disney+'), (2, 'Movie 11', 'Drama', '2019-06-15', 'Apple TV'), (3, 'Movie 12', 'Action', '2020-12-25', 'HBO Max');
|
List all movies and their genres that have been released on streaming services, ordered by the release date in ascending order.
|
SELECT movies.title, movies.genre, movies.release_date FROM movies ORDER BY movies.release_date ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists metro; CREATE TABLE if not exists metro.emergency_responses (id INT, response_time TIME); INSERT INTO metro.emergency_responses (id, response_time) VALUES (1, '01:34:00'), (2, '02:15:00'), (3, '01:52:00');
|
What is the maximum response time for emergency calls in the 'metro' schema?
|
SELECT MAX(TIME_TO_SEC(response_time)) FROM metro.emergency_responses;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (state VARCHAR(50), program_id INT); INSERT INTO carbon_offsets (state, program_id) VALUES ('CA', 123), ('NY', 456), ('OR', 789);
|
How many carbon offset programs exist in each state?
|
SELECT state, COUNT(program_id) as num_programs FROM carbon_offsets GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellites (ID INT, Name VARCHAR(50), LaunchYear INT, SatelliteType VARCHAR(50));
|
What are the names and types of military satellites launched since 2010?
|
SELECT Name, SatelliteType FROM Satellites WHERE LaunchYear >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Disability_Accessibility_Modifications (Building VARCHAR(50), Budget NUMERIC(10,2), Modification_Date DATE); INSERT INTO Disability_Accessibility_Modifications VALUES ('Building A', 100000, '2021-01-01'), ('Building B', 120000, '2021-02-01'), ('Building C', 90000, '2021-03-01'), ('Building A', 110000, '2021-04-01'), ('Building B', 130000, '2021-05-01');
|
What is the total budget allocated for disability accessibility modifications for each building in the past year, ordered by the building with the highest budget?
|
SELECT Building, SUM(Budget) as Total_Budget FROM Disability_Accessibility_Modifications WHERE Modification_Date >= DATEADD(year, -1, GETDATE()) GROUP BY Building ORDER BY Total_Budget DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, region VARCHAR(50), amount INT, investment_date DATE); INSERT INTO network_investments (investment_id, region, amount, investment_date) VALUES (1, 'North', 1000000, '2021-01-01');
|
What is the distribution of network infrastructure investments across regions in the year 2021?
|
SELECT region, EXTRACT(MONTH FROM investment_date) AS month, SUM(amount) FROM network_investments WHERE EXTRACT(YEAR FROM investment_date) = 2021 GROUP BY region, EXTRACT(MONTH FROM investment_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE atlantic_ocean_monitoring_station (date DATE, temperature FLOAT);
|
What was the minimum water temperature in the Atlantic Ocean Monitoring Station in June 2020?
|
SELECT MIN(temperature) AS min_temperature FROM atlantic_ocean_monitoring_station WHERE date BETWEEN '2020-06-01' AND '2020-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_facilities (facility_id INT, location TEXT, score INT); INSERT INTO mental_health_facilities (facility_id, location, score) VALUES (1, 'Urban', 80), (2, 'Rural', 75), (3, 'Suburban', 85);
|
What is the minimum health equity metric score for mental health facilities in rural areas?
|
SELECT MIN(score) FROM mental_health_facilities WHERE location = 'Rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Equipment_Maintenance (ID INT, Equipment_Type VARCHAR(255), Maintenance_Date DATE); INSERT INTO Equipment_Maintenance (ID, Equipment_Type, Maintenance_Date) VALUES (1, 'Aircraft', '2020-01-01'), (2, 'Vehicles', '2020-02-15'), (3, 'Naval', '2020-03-01'), (4, 'Aircraft', '2020-04-10'), (5, 'Weaponry', '2020-05-01');
|
What is the average time between equipment maintenance for each type of military equipment?
|
SELECT Equipment_Type, AVG(DATEDIFF(day, LAG(Maintenance_Date) OVER (PARTITION BY Equipment_Type ORDER BY Maintenance_Date), Maintenance_Date)) as Avg_Maintenance_Interval FROM Equipment_Maintenance GROUP BY Equipment_Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(100), country VARCHAR(50), donation DECIMAL(10,2)); INSERT INTO donors (id, name, country, donation) VALUES (1, 'John Doe', 'USA', 50.00), (2, 'Jane Smith', 'USA', 100.00), (3, 'Alice Johnson', 'Canada', 75.00), (4, 'Bob Brown', 'Africa', 25.00), (5, 'Charlie Green', 'Africa', 100.00), (6, 'Oliver White', 'England', 30.00), (7, 'Sophia Black', 'France', 20.00);
|
What is the minimum donation amount given by a donor from Europe?
|
SELECT MIN(donation) FROM donors WHERE country = 'England' OR country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_data (user_id INT, join_date DATE, country VARCHAR(50)); INSERT INTO user_data (user_id, join_date, country) VALUES (1, '2021-01-01', 'India'), (2, '2022-01-02', 'USA'), (3, '2021-06-03', 'India');
|
How many users joined Twitter from India in the last year?
|
SELECT COUNT(*) FROM user_data WHERE country = 'India' AND join_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT, license_date DATE, first_sale_date DATE); INSERT INTO dispensaries (id, name, state, license_date, first_sale_date) VALUES (1, 'Green Shelter', 'Washington', '2016-01-01', '2016-02-01'), (2, 'Purple Leaf', 'Washington', '2015-12-31', '2015-12-31'), (3, 'Bud Haven', 'Washington', '2017-06-15', '2017-07-01');
|
Identify the number of dispensaries that have been licensed in Washington State since 2015, but haven't reported any sales by the end of 2021.
|
SELECT COUNT(*) FROM (SELECT * FROM dispensaries WHERE state = 'Washington' AND license_date <= '2015-12-31' AND first_sale_date > '2021-12-31' EXCEPT SELECT * FROM (SELECT DISTINCT * FROM dispensaries)) tmp;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TheaterPerformances (id INT, performance_name VARCHAR(50), audience_member_name VARCHAR(50), country VARCHAR(50), performance_date DATE, age INT); INSERT INTO TheaterPerformances (id, performance_name, audience_member_name, country, performance_date, age) VALUES (1, 'Shakespeare Play', 'John', 'UK', '2022-08-01', 35), (2, 'Comedy Show', 'Jane', 'Spain', '2022-08-05', 28), (3, 'Drama Performance', 'Mark', 'UK', '2022-08-03', 42), (4, 'Musical', 'Natalie', 'Spain', '2022-08-07', 31);
|
What was the average age of audience members at theater performances in the UK and Spain?
|
SELECT AVG(age) FROM TheaterPerformances WHERE country IN ('UK', 'Spain');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, region VARCHAR(50), budget DECIMAL(10,2), rating INT); INSERT INTO programs (id, region, budget, rating) VALUES (1, 'Midwest', 8000, 8), (2, 'Northeast', 12000, 9), (3, 'West Coast', 7000, 7), (4, 'Southeast', 15000, 10), (5, 'Eastern', 11000, 6);
|
What is the average rating of art programs in the Eastern region with a budget over $10,000?
|
SELECT AVG(rating) FROM programs WHERE region = 'Eastern' AND budget > 10000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ota_revenue (revenue_id INT, ota_platform VARCHAR(50), region VARCHAR(20), revenue_date DATE, revenue FLOAT);
|
Which OTA platforms generated the most revenue in Europe in the last year?
|
SELECT ota_platform, region, SUM(revenue) as total_revenue FROM ota_revenue WHERE region = 'Europe' AND revenue_date >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY ota_platform ORDER BY total_revenue DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE education_programs (id INT, name VARCHAR(50), description TEXT, target_audience VARCHAR(50), duration INT);
|
Delete the 'Nature Nurturers' education program record from the 'education_programs' table
|
DELETE FROM education_programs WHERE name = 'Nature Nurturers';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id INT, crop_name VARCHAR(20), country VARCHAR(20), production INT, year INT); INSERT INTO crops (id, crop_name, country, production, year) VALUES (1, 'corn', 'Africa', 20000, 2019), (2, 'cassava', 'Africa', 30000, 2019), (3, 'sorghum', 'Africa', 15000, 2019);
|
List all the unique types of crops grown in 'Africa' in 2019 and the number of times they appear?
|
SELECT DISTINCT crop_name, COUNT(crop_name) as crop_count FROM crops WHERE country = 'Africa' AND year = 2019 GROUP BY crop_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethereum_dapps (id INT, name VARCHAR(255), network VARCHAR(255), launch_date DATE); INSERT INTO ethereum_dapps (id, name, network, launch_date) VALUES (1, 'Dapp1', 'ethereum', '2022-07-01'), (2, 'Dapp2', 'ethereum', '2022-05-01');
|
List all decentralized applications in the 'Ethereum' network that were launched after 2022-06-01.
|
SELECT * FROM ethereum_dapps WHERE network = 'ethereum' AND launch_date > '2022-06-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255), sustainability_score INT, local BOOLEAN, organic BOOLEAN);
|
Insert a new record for a local, organic vegetable supplier in the suppliers table.
|
INSERT INTO suppliers (id, name, country, sustainability_score, local, organic) VALUES (1, 'Local Organic Veggies', 'USA', 95, true, true);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE astrobiology_data (record_id INT, name VARCHAR(255), discovery_date DATE); INSERT INTO astrobiology_data (record_id, name, discovery_date) VALUES (1, 'Discovery 1', '2000-12-25'), (2, 'Discovery 2', '2007-06-18'), (3, 'Discovery 3', '2003-11-05');
|
Delete all astrobiology records with a discovery_date before 2005-01-01 from the astrobiology_data table
|
DELETE FROM astrobiology_data WHERE discovery_date < '2005-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ferries (id INT, city VARCHAR(50), fare DECIMAL(5,2)); INSERT INTO ferries (id, city, fare) VALUES (1, 'San Francisco', 6.50), (2, 'San Francisco', 7.00), (3, 'New York', 4.00);
|
What is the minimum fare for ferries in San Francisco?
|
SELECT MIN(fare) FROM ferries WHERE city = 'San Francisco';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Contractors (ContractorID INT, ContractorName VARCHAR(50), City VARCHAR(50), State VARCHAR(2), Country VARCHAR(50)); CREATE TABLE BuildingPermits (PermitID INT, ContractorID INT, PermitDate DATE, PermitType VARCHAR(50), Cost FLOAT); CREATE TABLE SustainablePractices (PracticeID INT, ContractorID INT, PracticeType VARCHAR(50), ImplementationDate DATE); INSERT INTO Contractors (ContractorID, ContractorName, City, State, Country) VALUES (3, 'JKL Construction', 'Chicago', 'IL', 'USA'); INSERT INTO BuildingPermits (PermitID, ContractorID, PermitDate, PermitType, Cost) VALUES (1, 3, '2022-01-01', 'Residential', 60000); INSERT INTO SustainablePractices (PracticeID, ContractorID, PracticeType, ImplementationDate) VALUES (1, 3, 'Green Roofs', '2022-02-01');
|
What is the total cost of building permits for contractors implementing sustainable practices?
|
SELECT ContractorID FROM SustainablePractices; SELECT SUM(Cost) FROM BuildingPermits WHERE ContractorID IN (SELECT ContractorID FROM SustainablePractices);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), industry VARCHAR(50), funding FLOAT, year INT);
|
Calculate the average funding for biotech startups in a specific year.
|
SELECT AVG(funding) FROM startups WHERE industry = 'biotech' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subway_ridership (user_id INT, trip_date DATE, trip_subway_line VARCHAR(20)); INSERT INTO subway_ridership (user_id, trip_date, trip_subway_line) VALUES (1, '2022-01-01', '4'), (2, '2022-01-01', '6');
|
Identify the number of public transit users in New York City by subway line.
|
SELECT trip_subway_line, COUNT(DISTINCT user_id) AS unique_users FROM subway_ridership GROUP BY trip_subway_line;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameType VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (1, 'John Doe', 'FPS'); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (2, 'Jane Smith', 'RPG'); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (3, 'Mike Johnson', 'FPS');
|
Determine the percentage of players who play FPS games
|
SELECT (COUNT(*) FILTER (WHERE GameType = 'FPS') * 100.0 / COUNT(*)) FROM Players;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (contract_id INT, address VARCHAR(42), name VARCHAR(255));
|
List all smart contracts associated with a given address?
|
SELECT contract_id, name FROM smart_contracts WHERE address = '0x1234567890abcdef1234567890abcdef';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE org_ai_ethics_budget (org_name VARCHAR(255), budget NUMERIC(10,2)); INSERT INTO org_ai_ethics_budget (org_name, budget) VALUES ('OrgA', 50000), ('OrgB', 75000), ('OrgC', 60000);
|
What is the average AI ethics budget per organization in North America?
|
SELECT AVG(budget) OVER (PARTITION BY CASE WHEN org_name LIKE 'North%' THEN 1 ELSE 0 END) as avg_budget FROM org_ai_ethics_budget;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MusicStreaming(Genre VARCHAR(20), Revenue DECIMAL(10,2), Date DATE); INSERT INTO MusicStreaming(Genre, Revenue, Date) VALUES ('Pop', 5000, '2022-01-01'), ('Rock', 6000, '2022-01-01'), ('Jazz', 3000, '2022-01-01'), ('Pop', 5500, '2022-02-01'), ('Rock', 6500, '2022-02-01'), ('Jazz', 3200, '2022-02-01'), ('Pop', 6000, '2022-03-01'), ('Rock', 7000, '2022-03-01'), ('Jazz', 3500, '2022-03-01');
|
What is the total revenue for each music genre in Q1 2022?
|
SELECT Genre, SUM(Revenue) as Total_Revenue FROM MusicStreaming WHERE Date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY Genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shallow_protected_areas (area_name TEXT, max_depth REAL); INSERT INTO shallow_protected_areas (area_name, max_depth) VALUES ('Bermuda Triangle', 750.0), ('Belize Barrier Reef', 914.0), ('Seychelles Bank', 1000.0);
|
Which marine protected areas have a maximum depth of 1000 meters?
|
SELECT area_name FROM shallow_protected_areas WHERE max_depth <= 1000.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attendees (attendee_id INT, event_id INT, age_group VARCHAR(50), attendee_date DATE); INSERT INTO Attendees (attendee_id, event_id, age_group, attendee_date) VALUES (4, 4, '18-24', '2021-01-01'), (5, 5, '25-34', '2021-02-01'), (6, 6, '35-44', '2021-03-01');
|
What was the distribution of attendees by age group for each event in '2021'?
|
SELECT event_id, age_group, COUNT(*) AS num_attendees FROM Attendees WHERE YEAR(attendee_date) = 2021 GROUP BY event_id, age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR, manager_id INT); CREATE TABLE volunteers (id INT, name VARCHAR, program_id INT);
|
List all programs and their respective volunteer managers.
|
SELECT programs.name as program_name, managers.name as manager_name FROM programs INNER JOIN volunteers ON programs.id = volunteers.program_id INNER JOIN donors d ON d.id = volunteers.manager_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GeneralDynamicsSales (country TEXT, quantity INT, year INT); INSERT INTO GeneralDynamicsSales VALUES ('India', 10, 2020); CREATE TABLE BoeingSales (country TEXT, quantity INT, year INT); INSERT INTO BoeingSales VALUES ('India', 20, 2020); CREATE TABLE LockheedMartinSales (country TEXT, quantity INT, year INT); INSERT INTO LockheedMartinSales VALUES ('India', 30, 2020);
|
Determine the total number of military equipment sold by all defense contractors to India?
|
SELECT SUM(GeneralDynamicsSales.quantity + BoeingSales.quantity + LockheedMartinSales.quantity) AS TotalQuantity
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Student (StudentID INT, StudentName VARCHAR(50)); INSERT INTO Student (StudentID, StudentName) VALUES (1, 'John Doe'); INSERT INTO Student (StudentID, StudentName) VALUES (2, 'Jane Smith'); INSERT INTO Student (StudentID, StudentName) VALUES (3, 'Michael Lee'); CREATE TABLE SupportProgram (ProgramID INT, ProgramName VARCHAR(50), StudentID INT, ProgramCompletion DATE); INSERT INTO SupportProgram (ProgramID, ProgramName, StudentID, ProgramCompletion) VALUES (1, 'Tutoring', 1, '2021-01-01'); INSERT INTO SupportProgram (ProgramID, ProgramName, StudentID, ProgramCompletion) VALUES (2, 'Mentoring', 1, '2021-03-01'); INSERT INTO SupportProgram (ProgramID, ProgramName, StudentID, ProgramCompletion) VALUES (3, 'Disability Support', 2, NULL);
|
Calculate the percentage of students who have completed a support program, grouped by the program type.
|
SELECT ProgramName, (COUNT(*) * 100.0 / NULLIF(SUM(CASE WHEN ProgramCompletion IS NOT NULL THEN 1 END) OVER (PARTITION BY NULL), 0)) AS Percentage FROM SupportProgram JOIN Student ON SupportProgram.StudentID = Student.StudentID GROUP BY ProgramName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle_sales (id INT, vehicle_type VARCHAR(255), sale_year INT, price FLOAT);
|
Delete records in the 'vehicle_sales' table where the 'sale_year' is before 2018
|
DELETE FROM vehicle_sales WHERE sale_year < 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(255), page_name VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, page_name VARCHAR(255), content TEXT); CREATE TABLE likes (id INT, user_id INT, post_id INT); CREATE TABLE hashtags (id INT, post_id INT, tag VARCHAR(255));
|
List posts with hashtags related to 'food' and 'restaurants' in descending order of likes, excluding posts with less than 10 likes.
|
SELECT DISTINCT posts.id, posts.content FROM posts JOIN hashtags ON posts.id = hashtags.post_id JOIN likes ON posts.id = likes.post_id WHERE hashtags.tag IN ('food', 'restaurants') GROUP BY posts.id HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(255), price DECIMAL(5,2));
|
Delete records of menu items without a price
|
DELETE FROM menu_items WHERE price IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Military_Expenditure (year INT, country VARCHAR(50), amount FLOAT, gdp FLOAT); CREATE TABLE Countries (id INT, name VARCHAR(50), region VARCHAR(50));
|
What is the average military expenditure as a percentage of GDP for each region in the past decade?
|
SELECT co.region, AVG(me.amount/me.gdp*100) as avg_military_expenditure FROM Military_Expenditure me INNER JOIN Countries co ON me.country = co.name WHERE me.year BETWEEN (YEAR(CURRENT_DATE) - 10) AND YEAR(CURRENT_DATE) GROUP BY co.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE the_miami_herald (category TEXT, publication_date DATE);CREATE TABLE the_atlanta_journal (category TEXT, publication_date DATE);
|
What are the unique categories of articles published by 'The Miami Herald' and 'The Atlanta Journal' in the last year, excluding any duplicate categories?
|
SELECT DISTINCT category FROM (SELECT category FROM the_miami_herald WHERE publication_date > DATE('now','-1 year') UNION SELECT category FROM the_atlanta_journal WHERE publication_date > DATE('now','-1 year'))
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title TEXT, publication TEXT, topic TEXT, year INT); INSERT INTO articles (id, title, publication, topic, year) VALUES (1, 'Article 1', 'CNN', 'Investigative Journalism', 2019); INSERT INTO articles (id, title, publication, topic, year) VALUES (2, 'Article 2', 'MSNBC', 'Investigative Journalism', 2019); INSERT INTO articles (id, title, publication, topic, year) VALUES (3, 'Article 3', 'CNN', 'News', 2019);
|
What is the total number of investigative journalism articles published by "CNN" and "MSNBC" in 2019?
|
SELECT SUM(cnt) FROM (SELECT publication, COUNT(*) as cnt FROM articles WHERE topic = 'Investigative Journalism' AND year = 2019 AND (publication = 'CNN' OR publication = 'MSNBC') GROUP BY publication) as t;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, resolved BOOLEAN, resolved_time TIMESTAMP, SLA_deadline TIMESTAMP);
|
What is the percentage of security incidents resolved within the SLA in the past month?
|
SELECT ROUND(AVG(CASE WHEN resolved THEN 1.0 ELSE 0.0 END * (resolved_time <= SLA_deadline)) * 100, 2) as percentage_within_SLA FROM security_incidents WHERE resolved_time >= NOW() - INTERVAL '1 month';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT, investor VARCHAR(255), amount FLOAT, date DATE); INSERT INTO investments (id, investor, amount, date) VALUES (3, 'Sustainable Future', 60000, '2021-04-01'); INSERT INTO investments (id, investor, amount, date) VALUES (4, 'Sustainable Future', 90000, '2021-04-15');
|
List all investments made by 'Sustainable Future' in Q2 2021.
|
SELECT * FROM investments WHERE investor = 'Sustainable Future' AND date BETWEEN '2021-04-01' AND '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(255), country VARCHAR(255));CREATE TABLE donations (id INT, donor_id INT, cause_id INT, amount DECIMAL(10, 2), donation_date DATE);
|
How many donations were made in total for each year?
|
SELECT YEAR(donation_date), COUNT(*) FROM donations GROUP BY YEAR(donation_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE activity (id INT, subscriber_id INT, data_usage INT, last_activity_date DATE); INSERT INTO activity (id, subscriber_id, data_usage, last_activity_date) VALUES (1, 1001, 3000, '2022-01-01'), (2, 1002, 1500, '2022-02-15'), (3, 1003, 2500, '2022-03-01'), (4, 1004, 1000, '2022-04-10');
|
Identify mobile subscribers who have used more than 2GB of data in the last 30 days.
|
SELECT subscriber_id FROM activity WHERE last_activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) AND data_usage > 2000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salaries (id INT PRIMARY KEY, employee_id INT, salary DECIMAL(10,2), last_update DATE);
|
Update the salary for employee "Clara Rodriguez" in the "salaries" table
|
UPDATE salaries SET salary = 50000.00 WHERE employee_id = 5678;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), last_ordered_date DATE); INSERT INTO dishes (dish_id, dish_name, last_ordered_date) VALUES (1, 'Vegan Tacos', '2022-05-15'), (2, 'Chickpea Curry', '2022-05-18'), (3, 'Cheese Quesadilla', '2022-01-01');
|
Delete dishes that have not been ordered in the past 30 days
|
DELETE FROM dishes WHERE last_ordered_date < NOW() - INTERVAL 30 DAY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tropical_production (id INT, facility_name VARCHAR(255), biome VARCHAR(255), violation_flag BOOLEAN, violation_date DATE);
|
How many timber production facilities are there in the tropical biome that have recorded violations in the past year?
|
SELECT COUNT(*) FROM tropical_production WHERE biome = 'tropical' AND violation_flag = TRUE AND violation_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonorID INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations (DonorID, DonationDate, Amount) VALUES (1, '2020-01-01', 50.00), (2, '2020-02-01', 100.00), (3, '2020-12-31', 250.00), (1, '2020-06-01', 100.00), (3, '2020-09-01', 150.00);
|
Who were the top 3 donors in 2020, based on total donation amount?
|
SELECT DonorID, SUM(Amount) as TotalDonated FROM Donations WHERE YEAR(DonationDate) = 2020 GROUP BY DonorID ORDER BY TotalDonated DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (warehouse_id INT, location TEXT); INSERT INTO warehouses (warehouse_id, location) VALUES (1, 'Tokyo'), (2, 'Osaka'), (3, 'Kyoto'); CREATE TABLE inventory (product TEXT, warehouse_id INT, quantity INT); INSERT INTO inventory (product, warehouse_id, quantity) VALUES ('Product B', 1, 150), ('Product B', 2, 250), ('Product B', 3, 350);
|
How many units of product B are stored in each warehouse?
|
SELECT i.product, w.location, SUM(i.quantity) as total_quantity FROM inventory i JOIN warehouses w ON i.warehouse_id = w.warehouse_id WHERE i.product = 'Product B' GROUP BY w.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CategoryFeedback (Id INT, CityId INT, Category VARCHAR(50), Feedback VARCHAR(255)); INSERT INTO CategoryFeedback (Id, CityId, Category, Feedback) VALUES (1, 1, 'Transportation', 'Great public transportation!'), (2, 1, 'Infrastructure', 'Good infrastructure...'), (3, 2, 'Transportation', 'Poor public transportation...'), (4, 2, 'Education', 'Excellent schools...'), (5, 3, 'Transportation', 'Average public transportation...'), (6, 3, 'Infrastructure', 'Excellent infrastructure...');
|
What is the number of feedback entries for each category, and what is the percentage of feedback entries for each category in cities with a population over 10 million?
|
SELECT Category, COUNT(*) AS FeedbackCount, (COUNT(*) * 100.0 / SUM(COUNT(*)) OVER ()) AS CategoryPercentage FROM (SELECT Category FROM CategoryFeedback JOIN City ON CategoryFeedback.CityId = City.Id WHERE Population > 1000000 GROUP BY Category, CityId) AS Subquery GROUP BY Category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_brands (brand_id INT, brand_name TEXT, total_organic_cotton_kg FLOAT);
|
What is the total quantity of organic cotton used by brands in the 'ethical_brands' table?
|
SELECT SUM(total_organic_cotton_kg) FROM ethical_brands;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cybersecurity_Strategies (Year INT, Strategy VARCHAR(255)); INSERT INTO Cybersecurity_Strategies (Year, Strategy) VALUES (2005, 'Cybersecurity Initiative'), (2010, 'Comprehensive National Cybersecurity Initiative'), (2015, 'Cybersecurity National Action Plan');
|
What are the names of the cybersecurity strategies implemented before 2015?
|
SELECT Strategy FROM Cybersecurity_Strategies WHERE Year < 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'); CREATE TABLE schools (school_id INT, school_name VARCHAR(255), region_id INT, build_year INT); INSERT INTO schools (school_id, school_name, region_id, build_year) VALUES (1, 'School A', 1, 2020), (2, 'School B', 1, 2019), (3, 'School C', 2, 2020), (4, 'School D', 3, 2018);
|
How many primary schools were built in 2020, separated by region?
|
SELECT r.region_name, COUNT(s.school_id) as num_of_schools FROM regions r INNER JOIN schools s ON r.region_id = s.region_id WHERE s.build_year = 2020 GROUP BY r.region_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_patients (patient_id INT, age INT, treatment VARCHAR(255), country VARCHAR(255)); INSERT INTO mental_health_patients (patient_id, age, treatment, country) VALUES (1, 30, 'CBT', 'Canada'); INSERT INTO mental_health_patients (patient_id, age, treatment, country) VALUES (2, 35, 'DBT', 'Canada');
|
What is the average age of patients who received CBT treatment in Canada?
|
SELECT AVG(age) FROM mental_health_patients WHERE treatment = 'CBT' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name VARCHAR(255)); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Westside'), (4, 'Eastside'); CREATE TABLE education_budget (district_id INT, year INT, amount INT); INSERT INTO education_budget (district_id, year, amount) VALUES (1, 2022, 3000000), (2, 2022, 3500000), (3, 2022, 4000000), (4, 2022, 4200000);
|
What is the total budget allocated for education in each district?
|
SELECT district_name, SUM(amount) AS total_budget FROM education_budget JOIN districts ON education_budget.district_id = districts.district_id GROUP BY district_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (id INT, species VARCHAR(50), population INT, location VARCHAR(50));
|
What is the average population of capybaras and jaguars in the Amazon Rainforest?
|
SELECT species, AVG(population) FROM animal_population WHERE species IN ('capybara', 'jaguar') AND location = 'Amazon Rainforest' GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (id INT, animal_name VARCHAR(255), habitat_type VARCHAR(255), weight DECIMAL(5,2)); INSERT INTO animals (id, animal_name, habitat_type, weight) VALUES (1, 'Lion', 'Savannah', 190.0), (2, 'Elephant', 'Forest', 6000.0), (3, 'Hippo', 'Wetlands', 3300.0), (4, 'Giraffe', 'Savannah', 1600.0), (5, 'Duck', 'Wetlands', 15.0), (6, 'Bear', 'Mountains', 300.0);
|
For each habitat, what is the average weight of the animals in that habitat?
|
SELECT habitat_type, AVG(weight) AS avg_weight FROM animals GROUP BY habitat_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_sourcing (id INT PRIMARY KEY, restaurant_id INT, ingredient VARCHAR(50), sourcing_percentage DECIMAL(5, 2));
|
Update the sustainable_sourcing table to set the sourcing_percentage to 85 for ingredient 'Chia Seeds'
|
UPDATE sustainable_sourcing SET sourcing_percentage = 85 WHERE ingredient = 'Chia Seeds';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Routes (route VARCHAR(20), intersect VARCHAR(20)); INSERT INTO Routes (route, intersect) VALUES ('1', '73'), ('39', '73');
|
Which routes intersect with the 73 bus in Boston?
|
SELECT intersect FROM Routes WHERE route = '73';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_patents (patent_id INT, company_name VARCHAR(30), country VARCHAR(20)); INSERT INTO ai_patents (patent_id, company_name, country) VALUES (1, 'TCS', 'India'), (2, 'Infosys', 'India'), (3, 'Google', 'USA');
|
What is the total number of AI patents filed by companies based in India?
|
SELECT COUNT(*) FROM ai_patents WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE iss_missions (id INT, mission_name VARCHAR(255), spacecraft_mass INT); INSERT INTO iss_missions (id, mission_name, spacecraft_mass) VALUES (1, 'STS-88', 125835); INSERT INTO iss_missions (id, mission_name, spacecraft_mass) VALUES (2, 'Soyuz TMA-1', 7200);
|
What is the total mass of all spacecraft sent to the International Space Station?
|
SELECT SUM(spacecraft_mass) FROM iss_missions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fairness (model_id INT, country VARCHAR(255), issue_description VARCHAR(255)); INSERT INTO fairness (model_id, country, issue_description) VALUES (1, 'Germany', 'Fairness issue 1'), (2, 'Germany', 'Fairness issue 2'), (3, 'France', 'Fairness issue 3'), (4, 'Germany', 'Fairness issue 4'), (5, 'Germany', 'Fairness issue 5');
|
Delete fairness issues for models from Germany with an id greater than 5.
|
DELETE FROM fairness WHERE model_id > 5 AND country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(50));CREATE TABLE CargoLoads (LoadID INT, VesselID INT, LoadLocation VARCHAR(50), LoadDate DATE); INSERT INTO Vessels (VesselID, VesselName) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'), (4, 'VesselD'); INSERT INTO CargoLoads (LoadID, VesselID, LoadLocation, LoadDate) VALUES (1, 1, 'South Africa', '2021-01-01'), (2, 1, 'Australia', '2021-02-01'), (3, 2, 'New Zealand', '2021-03-01'), (4, 3, 'Madagascar', '2021-04-01'), (5, 4, 'Papua New Guinea', '2021-05-01');
|
Which vessels have loaded cargo in both Africa and Oceania?
|
SELECT VesselName FROM Vessels WHERE VesselID IN (SELECT VesselID FROM CargoLoads WHERE LoadLocation LIKE 'Africa%') INTERSECT SELECT VesselName FROM Vessels WHERE VesselID IN (SELECT VesselID FROM CargoLoads WHERE LoadLocation LIKE 'Oceania%');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (id INT, country VARCHAR(255), items_quantity INT); INSERT INTO Warehouse (id, country, items_quantity) VALUES (1, 'Canada', 200), (2, 'USA', 400), (3, 'Mexico', 500);
|
How many items are there in total in the warehouse in Canada?
|
SELECT SUM(items_quantity) FROM Warehouse WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Field1 (id INT, sensor_id INT, temperature DECIMAL(5,2), location VARCHAR(255)); INSERT INTO Field1 (id, sensor_id, temperature, location) VALUES (1, 101, 22.5, 'US-NY');
|
What is the average temperature reading for all IoT sensors in the "Field1" located in "US-NY"?
|
SELECT AVG(temperature) FROM Field1 WHERE location = 'US-NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population (animal_id, animal_name, population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 5000), (3, 'Lion', 3000);
|
What is the minimum population of animals in the 'animal_population' table?
|
SELECT MIN(population) FROM animal_population;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_procedures (procedure_id INT, patient_id INT, hospital_id INT, procedure_date DATE, procedure_name TEXT); INSERT INTO medical_procedures (procedure_id, patient_id, hospital_id, procedure_date, procedure_name) VALUES (1, 1, 1, '2022-01-01', 'Dental Checkup'); CREATE TABLE patient (patient_id INT, patient_name TEXT, age INT, gender TEXT, diagnosis TEXT, location TEXT); INSERT INTO patient (patient_id, patient_name, age, gender, diagnosis, location) VALUES (1, 'Jimmy Brown', 15, 'Male', 'Healthy', 'California'); CREATE TABLE hospital (hospital_id INT, hospital_name TEXT, location TEXT); INSERT INTO hospital (hospital_id, hospital_name, location) VALUES (1, 'Rural Hospital A', 'California');
|
What is the total number of dental procedures performed on patients under 18 years old in rural hospitals of California?
|
SELECT SUM(procedures) FROM (SELECT patient_id, COUNT(*) as procedures FROM medical_procedures WHERE patient.age < 18 GROUP BY patient_id) as subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Contract_Negotiations (country VARCHAR(50), contract_value INT, negotiation_date DATE);
|
Insert a new record into the Contract_Negotiations table for 'Australia' with a contract value of 10000000 and a negotiation date of 2023-03-15.
|
INSERT INTO Contract_Negotiations (country, contract_value, negotiation_date) VALUES ('Australia', 10000000, '2023-03-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (id INT, name VARCHAR(255), location VARCHAR(255), capacity FLOAT, PRIMARY KEY (id)); INSERT INTO Projects (id, name, location, capacity) VALUES (1, 'Wind Farm A', 'USA', 180.0), (2, 'Solar Farm B', 'California', 100.5); CREATE TABLE Offsets (id INT, project_id INT, amount INT, PRIMARY KEY (id), FOREIGN KEY (project_id) REFERENCES Projects(id)); INSERT INTO Offsets (id, project_id, amount) VALUES (1, 1, 25000), (2, 2, 30000);
|
What are the carbon offset programs and their corresponding project capacities for renewable energy projects located in the US?
|
SELECT P.name, P.capacity, O.amount FROM Projects P INNER JOIN Offsets O ON P.id = O.project_id WHERE P.location = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects_Phase (id INT, state VARCHAR(2), project_phase VARCHAR(10), project_manager VARCHAR(10), construction_cost INT); INSERT INTO Projects_Phase (id, state, project_phase, project_manager, construction_cost) VALUES (1, 'TX', 'Design', 'Alice', 500000), (2, 'TX', 'Construction', 'Bob', 800000), (3, 'TX', 'Maintenance', 'Charlie', 300000);
|
What is the maximum construction cost for public works projects in Texas, categorized by project phase and project manager?
|
SELECT project_phase, project_manager, MAX(construction_cost) FROM Projects_Phase WHERE state = 'TX' GROUP BY project_phase, project_manager;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE explainable_ai (id INT, method VARCHAR(20), technique VARCHAR(30), description TEXT); INSERT INTO explainable_ai (id, method, technique, description) VALUES (1, 'SHAP', 'Model Explanation', 'SHapley Additive exPlanations'), (2, 'SHAP', 'Feature Importance', 'SHapley Feature Importance');
|
Update the 'explainable_ai' table, changing 'description' to 'SHAP: Local Explanations' for records where 'method' is 'SHAP' and 'technique' is 'Model Explanation'
|
UPDATE explainable_ai SET description = 'SHAP: Local Explanations' WHERE method = 'SHAP' AND technique = 'Model Explanation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai (id INT, principle VARCHAR(50), region VARCHAR(50));INSERT INTO ethical_ai (id, principle, region) VALUES (1, 'Fairness', 'Asia'), (2, 'Accountability', 'Europe'), (3, 'Transparency', 'Americas');
|
What is the distribution of ethical AI principles across different regions?
|
SELECT region, COUNT(*) as principle_count FROM ethical_ai GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DigitalAssets (name VARCHAR(64), symbol VARCHAR(8), total_supply DECIMAL(20, 8), platform VARCHAR(64), project_url VARCHAR(128));
|
Insert a new digital asset with the name 'CryptoPet', symbol 'CPT', and total supply of 1,000,000,000 into the 'DigitalAssets' table
|
INSERT INTO DigitalAssets (name, symbol, total_supply) VALUES ('CryptoPet', 'CPT', 1000000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), join_date DATE); INSERT INTO users (id, name, age, gender, join_date) VALUES (1, 'Bob', 30, 'Male', '2022-01-02');
|
How many users are there in the social_media database who joined after '2021-12-31'?
|
SELECT COUNT(*) as num_users FROM users WHERE join_date > '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT PRIMARY KEY, name TEXT, location TEXT, sustainability_rating REAL);
|
Update the location of the supplier with id 1 to 'California, USA'
|
UPDATE suppliers SET location = 'California, USA' WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers(id INT, name TEXT, department TEXT, country TEXT); INSERT INTO volunteers(id, name, department, country) VALUES (1, 'John Doe', 'Education', 'USA'), (2, 'Jane Smith', 'Health', 'Canada'), (3, 'Alice Johnson', 'Education', 'Nigeria');
|
How many volunteers signed up in the Education department from countries with a population over 100 million?
|
SELECT COUNT(*) FROM volunteers WHERE department = 'Education' AND country IN (SELECT country FROM (SELECT * FROM world_population) AS wp WHERE wp.population > 100000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE machines (id INT PRIMARY KEY, model TEXT, year INT, manufacturer TEXT, circular_economy BOOLEAN); CREATE TABLE maintenance (id INT PRIMARY KEY, machine_id INT, date DATE, FOREIGN KEY (machine_id) REFERENCES machines(id));
|
Show machines that were produced using circular economy principles.
|
SELECT machines.model, machines.year, machines.manufacturer FROM machines WHERE machines.circular_economy = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerGames (PlayerID int, PlayerName varchar(50), Game varchar(50), Category varchar(50));
|
What is the number of games played by each player in the "Platformer" genre?
|
SELECT PlayerName, COUNT(DISTINCT Game) OVER(PARTITION BY PlayerID) as GamesCount FROM PlayerGames WHERE Category = 'Platformer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Art (ArtID INT, Type VARCHAR(255), Region VARCHAR(255), Quantity INT); INSERT INTO Art (ArtID, Type, Region, Quantity) VALUES (1, 'Painting', 'Asia', 25), (2, 'Sculpture', 'Africa', 18), (3, 'Textile', 'South America', 30), (4, 'Pottery', 'Europe', 20), (5, 'Jewelry', 'North America', 12);
|
Which regions have more than 30 traditional art pieces?
|
SELECT Region, SUM(Quantity) as Total_Quantity FROM Art GROUP BY Region HAVING SUM(Quantity) > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EventParticipation (EventID INT, PlayerID INT, EventCountry VARCHAR(50)); INSERT INTO EventParticipation (EventID, PlayerID, EventCountry) VALUES (1, 1, 'USA'), (2, 2, 'USA'), (3, 3, 'Canada');
|
Find the number of players who joined esports events in the US and their total games played, partitioned by event country.
|
SELECT EventCountry, COUNT(PlayerID) AS PlayersJoined, SUM(TotalGames) AS TotalGamesPlayed FROM Players P JOIN EventParticipation EP ON P.PlayerID = EP.PlayerID GROUP BY EventCountry
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE NewsTopics (TopicID INT, Topic VARCHAR(255)); CREATE TABLE Articles (ArticleID INT, TopicID INT, PublishDate DATE); INSERT INTO NewsTopics (TopicID, Topic) VALUES (1, 'corruption'), (2, 'environment'), (3, 'human rights'); INSERT INTO Articles (ArticleID, TopicID, PublishDate) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-02-01'), (3, 3, '2022-03-01'), (4, 1, '2022-06-01');
|
Find the total number of articles published in each news topic in the last 6 months, sorted by the total number of articles in descending order in the "InvestigativeJournalism" and "NewsReporting" databases.
|
SELECT NewsTopics.Topic, COUNT(Articles.ArticleID) AS ArticleCount FROM NewsTopics INNER JOIN Articles ON NewsTopics.TopicID = Articles.TopicID WHERE Articles.PublishDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY NewsTopics.Topic ORDER BY ArticleCount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species VARCHAR(255)); INSERT INTO marine_species (id, species) VALUES (1, 'Dolphin'), (2, 'Shark'); CREATE TABLE pollution_control (id INT, initiative VARCHAR(255)); INSERT INTO pollution_control (id, initiative) VALUES (1, 'Beach Cleanup'), (2, 'Ocean Floor Mapping');
|
Find the total number of marine species and total number of pollution control initiatives in the database.
|
SELECT COUNT(*) FROM marine_species UNION ALL SELECT COUNT(*) FROM pollution_control;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (facility_id INT, name VARCHAR(50), capacity INT, location VARCHAR(50), surface VARCHAR(20));
|
List all facilities in the 'facilities' table that have a capacity greater than 15000.
|
SELECT facility_id, name, capacity, location FROM facilities WHERE capacity > 15000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects(id INT, province TEXT, project_name TEXT, completion_status TEXT); INSERT INTO infrastructure_projects (id, province, project_name, completion_status) VALUES (1, 'Quebec', 'Wind Turbine Project', 'in progress'); INSERT INTO infrastructure_projects (id, province, project_name, completion_status) VALUES (2, 'Ontario', 'Smart Grid Implementation', 'in progress');
|
Update the status of the rural infrastructure project with ID 1 to 'completed' in the 'infrastructure_projects' table.
|
UPDATE infrastructure_projects SET completion_status = 'completed' WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_consumption_by_user (id INT, user_id INT, event_date DATE, water_consumption FLOAT); INSERT INTO water_consumption_by_user (id, user_id, event_date, water_consumption) VALUES (1, 1, '2021-08-01', 120), (2, 2, '2021-08-02', 150), (3, 3, '2021-08-03', 180);
|
What was the maximum water consumption by a single user in a day in the month of August?
|
SELECT user_id, MAX(water_consumption) as max_water_consumption_by_user FROM water_consumption_by_user WHERE MONTH(event_date) = 8 GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City (id INT, name VARCHAR(255), population INT, renewable_energy_projects INT); INSERT INTO City (id, name, population, renewable_energy_projects) VALUES (1, 'Rio de Janeiro', 6500000, 500); INSERT INTO City (id, name, population, renewable_energy_projects) VALUES (2, 'Sydney', 5000000, 120); CREATE TABLE GreenBuilding (id INT, name VARCHAR(255), city_id INT, size INT, is_certified BOOLEAN); INSERT INTO GreenBuilding (id, name, city_id, size, is_certified) VALUES (1, 'Eco Tower', 1, 15000, true); INSERT INTO GreenBuilding (id, name, city_id, size, is_certified) VALUES (2, 'Green Heights', 2, 20000, false);
|
Which cities have more than 100 certified green buildings?
|
SELECT c.name FROM City c JOIN GreenBuilding gb ON c.id = gb.city_id WHERE is_certified = true GROUP BY c.name HAVING COUNT(gb.id) > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE american_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO american_teams (team_id, team_name) VALUES (1, 'LA Galaxy'), (2, 'Seattle Sounders'), (3, 'Atlanta United'); CREATE TABLE american_matches (match_id INT, home_team_id INT, away_team_id INT, home_team_player_assists INT, away_team_player_assists INT); INSERT INTO american_matches (match_id, home_team_id, away_team_id, home_team_player_assists, away_team_player_assists) VALUES (1, 1, 2, 2, 1), (2, 2, 3, 1, 2), (3, 3, 1, 3, 1);
|
What is the total number of assists by players in the MLS?
|
SELECT COUNT(home_team_player_assists + away_team_player_assists) AS total_assists FROM american_matches;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wildlife_habitat (country_code CHAR(3), year INT, habitat_area INT); INSERT INTO wildlife_habitat (country_code, year, habitat_area) VALUES ('COL', 2022, 70000), ('COL', 2021, 65000);
|
Insert new record of wildlife habitat data for Colombia in 2023
|
INSERT INTO wildlife_habitat (country_code, year, habitat_area) VALUES ('COL', 2023, 75000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE excavation_sites_metalwork (site_id INT, artifact_count INT); INSERT INTO excavation_sites_metalwork (site_id, artifact_count) VALUES (1, 10), (2, 8), (3, 12); CREATE TABLE artifacts_categories_count (site_id INT, category VARCHAR(255), artifact_count INT); INSERT INTO artifacts_categories_count (site_id, category, artifact_count) VALUES (1, 'Ceramics', 20), (1, 'Metalwork', 10), (2, 'Ceramics', 15), (2, 'Metalwork', 8), (3, 'Ceramics', 12), (3, 'Metalwork', 12);
|
Which excavation sites have more than 5 'Metalwork' artifacts and their corresponding category percentages?
|
SELECT a.site_id, a.artifact_count, 100.0 * a.artifact_count / SUM(b.artifact_count) OVER (PARTITION BY a.site_id) AS category_percentage FROM excavation_sites_metalwork a JOIN artifacts_categories_count b ON a.site_id = b.site_id WHERE b.category = 'Metalwork' AND a.artifact_count > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceanographic_data (sea_name VARCHAR(50), avg_depth DECIMAL(5,2));
|
What is the average depth of the seas in the 'oceanographic_data' table, excluding the Mediterranean Sea?"
|
SELECT AVG(avg_depth) FROM oceanographic_data WHERE sea_name != 'Mediterranean Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, price) VALUES (1, 1, 20.99), (2, 2, 50.00), (3, 3, 75.00), (4, 4, 10.00), (5, 5, 30.00), (6, 6, 40.00); CREATE TABLE products (product_id INT, category TEXT); INSERT INTO products (product_id, category) VALUES (1, 'Electronics'), (2, 'Clothing'), (3, 'Furniture'), (4, 'Electronics'), (5, 'Clothing'), (6, 'Furniture');
|
What is the revenue for each product category in descending order?
|
SELECT products.category, SUM(sales.price) FROM products INNER JOIN sales ON products.product_id = sales.product_id GROUP BY products.category ORDER BY SUM(sales.price) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (state VARCHAR(50), race_ethnicity VARCHAR(50), workers INT); INSERT INTO community_health_workers (state, race_ethnicity, workers) VALUES ('California', 'Hispanic', 200), ('California', 'White', 150), ('Texas', 'Hispanic', 250), ('Texas', 'White', 100), ('New York', 'Black', 180), ('New York', 'White', 120);
|
List the top 3 states with the most community health workers by race/ethnicity?
|
SELECT state, race_ethnicity, SUM(workers) as total_workers FROM community_health_workers GROUP BY state, race_ethnicity ORDER BY total_workers DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
species_observations
|
List all unique species observed
|
SELECT DISTINCT species FROM species_observations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_funding (company_id INT, founding_year INT, amount FLOAT); INSERT INTO company_funding (company_id, founding_year, amount) VALUES (1, 2010, 1500000.0), (2, 2012, 2000000.0), (3, 2010, 500000.0), (4, 2012, 1000000.0), (5, 2011, 1200000.0);
|
What is the total funding amount for companies founded in 2012?
|
SELECT SUM(amount) FROM company_funding WHERE founding_year = 2012;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_initiatives (region VARCHAR(50), date DATE, initiative VARCHAR(50)); INSERT INTO conservation_initiatives (region, date, initiative) VALUES ('Cape Town', '2017-01-01', 'Rainwater harvesting'), ('Cape Town', '2018-01-01', 'Greywater reuse'), ('Cape Town', '2019-01-01', 'Smart irrigation');
|
List all water conservation initiatives implemented in 'Cape Town' from 2017 to 2019
|
SELECT * FROM conservation_initiatives WHERE region = 'Cape Town' AND date BETWEEN '2017-01-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eco_hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); INSERT INTO eco_hotels (hotel_id, hotel_name, country, rating) VALUES (1, 'Eco-Friendly Hotel 1', 'Germany', 4.2), (2, 'Eco-Friendly Hotel 2', 'Germany', 4.7);
|
What is the minimum rating of eco-friendly hotels in Germany?
|
SELECT MIN(rating) FROM eco_hotels WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inspections (id INT, date DATE, score FLOAT); INSERT INTO inspections (id, date, score) VALUES (1, '2022-01-01', 90.0), (2, '2022-04-01', 85.0), (3, '2022-07-01', 95.0);
|
What is the average food safety inspection score for each quarter of the year?
|
SELECT DATE_FORMAT(date, '%Y-%m') as quarter, AVG(score) as avg_score FROM inspections GROUP BY quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nonprofits (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip_code VARCHAR(10));
|
Update the address of a nonprofit in the nonprofits table
|
UPDATE nonprofits SET city = 'Los Angeles', state = 'CA', zip_code = '90001' WHERE id = 3;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.