context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE japan_offset_programs (name TEXT, co2_reduction_tons INT); INSERT INTO japan_offset_programs (name, co2_reduction_tons) VALUES ('Program A', 12000), ('Program B', 9000);
What is the minimum CO2 emissions reduction (in metric tons) achieved by carbon offset programs in Japan, and how many of them achieved a reduction of over 10000 metric tons?
SELECT MIN(co2_reduction_tons) AS min_reduction, COUNT(*) FILTER (WHERE co2_reduction_tons > 10000) AS num_programs_over_10000 FROM japan_offset_programs;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athletes (id, name, age, sport) VALUES (1, 'John Doe', 30, 'Basketball'), (2, 'Jane Smith', 28, 'Soccer'); CREATE TABLE medals (medal_id INT, athlete_id INT, medal_type VARCHAR(50)); INSERT INTO medals (medal_id, athlete_id, medal_type) VALUES (101, 1, 'Gold'), (102, 1, 'Silver'), (103, 2, 'Bronze');
Delete records of athletes who have not won any medals
DELETE FROM athletes WHERE id NOT IN (SELECT athlete_id FROM medals);
gretelai_synthetic_text_to_sql
CREATE TABLE salesperson_quarter (salesperson_id INT, quarter INT, num_orders INT);
What is the salesperson performance by the number of orders, in each quarter of the year 2021?'
INSERT INTO salesperson_quarter (salesperson_id, quarter, num_orders) SELECT salesperson_id, QUARTER(sale_date) AS quarter, COUNT(DISTINCT id) AS num_orders FROM sales JOIN salesperson ON sales.salesperson_id = salesperson.id WHERE YEAR(sale_date) = 2021 GROUP BY salesperson_id, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT, name VARCHAR(50), type VARCHAR(50), sustainability_score INT); INSERT INTO fabrics (id, name, type, sustainability_score) VALUES (1, 'Organic Cotton', 'Natural', 85); INSERT INTO fabrics (id, name, type, sustainability_score) VALUES (2, 'Recycled Polyester', 'Synthetic', 65);
What are the names of all garments made from sustainable fabrics with a sustainability score greater than 60?
SELECT garments.name FROM garments JOIN fabrics ON garments.fabric_id = fabrics.id WHERE fabrics.sustainability_score > 60;
gretelai_synthetic_text_to_sql
CREATE TABLE Routes (RouteID int, RouteName varchar(255), Region varchar(255)); INSERT INTO Routes (RouteID, RouteName, Region) VALUES (1, 'North', 'East'), (2, 'South', 'Central'), (3, 'West', 'West'), (4, 'Red Line', 'East'), (5, 'Green Line', 'North'), (6, 'Blue Line', 'West'); CREATE TABLE Trips (TripID int, RouteID int, Passengers int, TripDateTime datetime); CREATE TABLE PeakHours (PeakHourID int, StartTime time, EndTime time); INSERT INTO PeakHours (PeakHourID, StartTime, EndTime) VALUES (1, '06:00', '09:00'), (2, '16:00', '19:00');
What is the average number of passengers per trip on the 'Blue Line' route during non-peak hours?
SELECT AVG(Passengers) FROM Routes JOIN Trips ON Routes.RouteID = Trips.RouteID JOIN PeakHours ON Trips.TripDateTime BETWEEN PeakHours.StartTime AND PeakHours.EndTime WHERE Routes.RouteName = 'Blue Line' AND NOT (PeakHours.StartTime BETWEEN '06:00' AND '09:00' OR PeakHours.StartTime BETWEEN '16:00' AND '19:00');
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, region VARCHAR(20), year INT, rate DECIMAL(5,2));
Update records in recycling_rates table where region is 'Asia' and year is 2019
WITH data_to_update AS (UPDATE recycling_rates SET rate = rate * 1.10 WHERE region = 'Asia' AND year = 2019 RETURNING *) UPDATE recycling_rates SET rate = (SELECT rate FROM data_to_update) WHERE id IN (SELECT id FROM data_to_update);
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, Neodymium_monthly_production FLOAT); INSERT INTO mine (id, name, location, Neodymium_monthly_production) VALUES (1, 'Australian Mine', 'Australia', 120.5), (2, 'Californian Mine', 'USA', 150.3), (3, 'Brazilian Mine', 'Brazil', 80.0);
What is the average monthly production of Neodymium in 2020 from the Australian mine?
SELECT AVG(Neodymium_monthly_production) FROM mine WHERE name = 'Australian Mine' AND EXTRACT(YEAR FROM timestamp) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, name VARCHAR(255), department VARCHAR(255), safety_training_hours INT);
Update the 'workforce' table and set the 'safety_training_hours' to 24 for all workers in the 'electronics' department
UPDATE workforce SET safety_training_hours = 24 WHERE department = 'electronics';
gretelai_synthetic_text_to_sql
CREATE TABLE seasons (season_id INT, team TEXT, goalkeeper TEXT, saves INT);
What is the maximum number of saves made by a goalkeeper in a single soccer season in the English Premier League, and who was the goalkeeper?
SELECT goalkeeper, MAX(saves) FROM seasons WHERE team IN ('Liverpool', 'Manchester United', 'Arsenal', 'Chelsea', 'Manchester City');
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS green_spaces; CREATE TABLE green_spaces.parks (id INT, name VARCHAR(100), area FLOAT, elevation FLOAT); INSERT INTO green_spaces.parks (id, name, area, elevation) VALUES (1, 'Central Park', 341, 41), (2, 'Prospect Park', 266, 45), (3, 'Washington Square Park', 9.75, 30);
Calculate the total area and average elevation of parks in the 'green_spaces' schema
SELECT SUM(area), AVG(elevation) FROM green_spaces.parks;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_biodiversity (id INTEGER, species VARCHAR(255), population INTEGER, region VARCHAR(255));
How many different species are present in the 'arctic_biodiversity' table for each region?
SELECT region, COUNT(DISTINCT species) AS species_count FROM arctic_biodiversity GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(255), Genre VARCHAR(255));CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(255), GameID INT);CREATE VIEW PlayerCount AS SELECT g.Genre, c.Country, COUNT(p.PlayerID) as PlayerCount FROM Games g JOIN Players p ON g.GameID = p.GameID JOIN (SELECT PlayerID, Country FROM PlayerProfile GROUP BY PlayerID) c ON p.PlayerID = c.PlayerID GROUP BY g.Genre, c.Country;
What are the top 3 countries with the highest number of players for the "SportsGames" genre?
SELECT Genre, Country, PlayerCount FROM PlayerCount WHERE Genre = 'SportsGames' ORDER BY PlayerCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, name TEXT, country TEXT, capacity_mw FLOAT); INSERT INTO wind_farms (id, name, country, capacity_mw) VALUES (1, 'Big Spring Wind Farm', 'United States', 251.0), (2, 'Desert Sky Wind Farm', 'United States', 300.0);
What is the total installed capacity (in MW) of wind farms in the country 'United States'?
SELECT SUM(capacity_mw) FROM wind_farms WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE astronaut_medical_2 (id INT, astronaut_name VARCHAR(30), mission VARCHAR(20), medical_condition VARCHAR(30));INSERT INTO astronaut_medical_2 (id, astronaut_name, mission, medical_condition) VALUES (1, 'John Doe', 'Mars-1', 'Anemia'), (2, 'Jane Smith', 'Moon-1', 'Motion Sickness'), (3, 'Alice Johnson', 'Moon-1', 'Back Pain');
What are the medical conditions of astronauts who have flown missions to the Moon?
SELECT astronaut_name, medical_condition FROM astronaut_medical_2 WHERE mission = 'Moon-1';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant (id INT, name VARCHAR(255)); INSERT INTO restaurant (id, name) VALUES (1, 'fine_dining'); CREATE TABLE menu (id INT, item VARCHAR(255), price DECIMAL(5,2), daily_sales INT, restaurant_id INT);
Find the top 3 menu items contributing to daily revenue in 'fine_dining' restaurant
SELECT i.item, SUM(m.price * m.daily_sales) as revenue FROM menu m JOIN restaurant r ON m.restaurant_id = r.id WHERE r.name = 'fine_dining' GROUP BY i.item ORDER BY revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE hiv_cases (case_id INT, date DATE, age_group_id INT, gender VARCHAR(10), cases_count INT);
What is the trend of HIV cases over time by age group and gender?
SELECT ag.age_group, g.gender, EXTRACT(YEAR FROM hc.date) AS year, EXTRACT(MONTH FROM hc.date) AS month, AVG(hc.cases_count) AS avg_cases FROM hiv_cases hc JOIN age_groups ag ON hc.age_group_id = ag.age_group_id JOIN (VALUES ('Male'), ('Female')) AS g(gender) ON hc.gender = g.gender GROUP BY ag.age_group, g.gender, EXTRACT(YEAR FROM hc.date), EXTRACT(MONTH FROM hc.date) ORDER BY ag.age_group, g.gender, EXTRACT(YEAR FROM hc.date), EXTRACT(MONTH FROM hc.date);
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policy_name VARCHAR(50), region VARCHAR(50), policy_cost FLOAT, policy_start_date DATE); INSERT INTO policies (policy_id, policy_name, region, policy_cost, policy_start_date) VALUES (1, 'Renewable Portfolio Standard', 'California', 2000000, '2010-01-01'), (2, 'Solar Energy Tax Incentive', 'Texas', 5000000, '2018-01-01'), (3, 'Wind Energy Subsidy', 'Iowa', 3000000, '2015-01-01');
What is the total cost of policies for each region?
SELECT region, SUM(policy_cost) as total_policy_cost FROM policies GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Country varchar(50)); INSERT INTO Artists (ArtistID, ArtistName, Country) VALUES (1, 'Tame Impala', 'Australia'), (2, 'Iggy Azalea', 'Australia'), (3, 'Eminem', 'United States'); CREATE TABLE StreamingData (StreamDate date, ArtistID int, Streams int); INSERT INTO StreamingData (StreamDate, ArtistID, Streams) VALUES ('2022-01-01', 1, 10000), ('2022-01-02', 2, 8000), ('2022-01-03', 3, 9000);
What is the average number of streams for artists from Australia in 2022?
SELECT AVG(Streams) as AverageStreams FROM Artists JOIN StreamingData ON Artists.ArtistID = StreamingData.ArtistID WHERE Artists.Country = 'Australia' AND StreamingData.StreamDate >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE SiteL (site_id INT, artifact_name VARCHAR(50), description TEXT); INSERT INTO SiteL (site_id, artifact_name, description) VALUES (201, 'Bronze Axe', 'A bronze axe used for woodworking'), (202, 'Bronze Chisel', 'A bronze chisel used for carving stone'), (203, 'Bronze Spearhead', 'A bronze spearhead used for hunting');
Which sites have 'Bronze Tools'?
SELECT site_id FROM SiteL WHERE artifact_name LIKE '%Bronze Tool%';
gretelai_synthetic_text_to_sql
CREATE TABLE museum_visitors (visitor_id INT, name VARCHAR(50), museum_id INT, visit_count INT); CREATE TABLE museums (museum_id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO museums (museum_id, name, city) VALUES (1, 'Tokyo National Museum', 'Tokyo'); INSERT INTO museum_visitors (visitor_id, name, museum_id, visit_count) VALUES (1, 'Alice', 1, 6), (2, 'Bob', 1, 3), (3, 'Charlie', 1, 4);
Delete records of attendees who visited a museum in Tokyo more than 5 times.
DELETE FROM museum_visitors WHERE museum_id = 1 AND visit_count > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, product_name VARCHAR(20), last_updated DATE); CREATE TABLE Safety_Protocols (protocol_id INT, product_id INT, protocol_description VARCHAR(100));
List all the products and their safety protocols that were last updated before 2019-01-01.
SELECT Products.product_name, Safety_Protocols.protocol_description FROM Products INNER JOIN Safety_Protocols ON Products.product_id = Safety_Protocols.product_id WHERE Products.last_updated < '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID INT, Name VARCHAR(50), OpenDate DATETIME); CREATE TABLE Inventory (InventoryID INT, RestaurantID INT, Item VARCHAR(50), Quantity INT, Cost DECIMAL(5,2), Waste INT);
What is the total cost of food waste for each restaurant, grouped by month?
SELECT Restaurants.Name, DATE_PART('month', Inventory.InventoryDate) as Month, SUM(Inventory.Cost * Inventory.Waste) as TotalFoodWasteCost FROM Restaurants JOIN Inventory ON Restaurants.RestaurantID = Inventory.RestaurantID WHERE Inventory.Waste > 0 GROUP BY Restaurants.Name, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, total_funding FLOAT, founder TEXT); INSERT INTO startups VALUES(1, 'StartupA', 'Tech', 15000000, 'Asian'); INSERT INTO startups VALUES(2, 'StartupB', 'Tech', 20000000, 'White'); INSERT INTO startups VALUES(3, 'StartupC', 'Healthcare', 12000000, 'Hispanic'); INSERT INTO startups VALUES(4, 'StartupD', 'Finance', 30000000, 'Black'); INSERT INTO startups VALUES(5, 'StartupE', 'Tech', 8000000, 'Underrepresented Minority');
What is the average total funding for startups founded by underrepresented minorities in the Tech sector?
SELECT AVG(total_funding) FROM startups WHERE industry = 'Tech' AND founder IN ('Underrepresented Minority', 'African American', 'Hispanic', 'Native American');
gretelai_synthetic_text_to_sql
CREATE TABLE RestaurantRevenue (RevenueID INT, RestaurantID INT, Revenue DECIMAL(10,2), Month INT); INSERT INTO RestaurantRevenue (RevenueID, RestaurantID, Revenue, Month) VALUES (1, 1, 5000.00, 1), (2, 1, 6000.00, 2), (3, 2, 8000.00, 1), (4, 2, 7000.00, 2), (5, 3, 9000.00, 1), (6, 3, 9500.00, 2);
What is the total revenue for each restaurant by month?
SELECT RestaurantID, Month, SUM(Revenue) as TotalRevenue FROM RestaurantRevenue GROUP BY RestaurantID, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founder_gender) VALUES (1, 'InnoHealth', 'Healthcare', 'Female'); CREATE TABLE funding (company_id INT, amount INT); INSERT INTO funding (company_id, amount) VALUES (1, 500000);
What is the total funding received by companies founded by women in the healthcare sector?
SELECT SUM(funding.amount) FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.founder_gender = 'Female' AND companies.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name TEXT, region TEXT);INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Great White Shark', 'Pacific'), (2, 'Blue Whale', 'Atlantic'), (3, 'Giant Pacific Octopus', 'Pacific'), (4, 'Green Sea Turtle', 'Atlantic'), (5, 'Indian Ocean Humpback Dolphin', 'Indian');
What is the total number of marine species in the 'Indian' and 'Atlantic' regions?
SELECT COUNT(*) FROM marine_species WHERE region IN ('Indian', 'Atlantic');
gretelai_synthetic_text_to_sql
CREATE TABLE highway (id INT, name TEXT, state TEXT, length FLOAT, sustainable_materials BOOLEAN); INSERT INTO highway (id, name, state, length, sustainable_materials) VALUES (1, 'Highway A', 'New York', 100.5, 1); INSERT INTO highway (id, name, state, length, sustainable_materials) VALUES (2, 'Highway B', 'New York', 120.3, 0);
What is the total length of all highways in the state of New York that have been constructed using sustainable materials?
SELECT SUM(length) FROM highway WHERE state = 'New York' AND sustainable_materials = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE philanthropic_trends (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO philanthropic_trends VALUES (1, 100000, '2020-01-01'), (2, 80000, '2020-02-01'), (3, 60000, '2020-03-01'), (4, 50000, '2020-04-01'), (5, 40000, '2020-05-01'), (6, 30000, '2020-06-01');
Display the top 5 donors who have made the largest total donations in the philanthropic trends sector.
SELECT donor_id, SUM(donation_amount) as total_donation FROM philanthropic_trends GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (name VARCHAR(50), city VARCHAR(20), rating INT); INSERT INTO Hospitals (name, city, rating) VALUES ('HospitalA', 'Chicago', 8), ('HospitalB', 'Chicago', 9), ('HospitalC', 'New York', 7);
Find the number of hospitals in the city of Chicago and New York, excluding any hospitals with a rating below 8.
SELECT COUNT(*) FROM Hospitals WHERE city IN ('Chicago', 'New York') AND rating >= 8;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ID INT, Name TEXT, Category TEXT, Budget FLOAT); INSERT INTO Programs (ID, Name, Category, Budget) VALUES (1, 'Assistive Technology', 'Disability Support', 50000.00), (2, 'Mental Health Services', 'Health Care', 100000.00);
What is the average budget allocated per program in the 'Disability Support' category?
SELECT AVG(Budget) FROM Programs WHERE Category = 'Disability Support';
gretelai_synthetic_text_to_sql
CREATE TABLE Sites (SiteID int, SiteName varchar(50)); INSERT INTO Sites VALUES (1, 'Site A'), (2, 'Site B'); CREATE TABLE Artifacts (ArtifactID int, SiteID int, ArtifactType varchar(50), Quantity int); INSERT INTO Artifacts VALUES (1, 1, 'Lithic', 120), (2, 1, 'Ceramic', 30), (3, 2, 'Lithic', 150), (4, 2, 'Ceramic', 50);
Which excavation sites have produced the most lithic artifacts, and how many were found at each?
SELECT Sites.SiteName, SUM(Artifacts.Quantity) as TotalLithics FROM Artifacts INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID WHERE ArtifactType = 'Lithic' GROUP BY Sites.SiteName ORDER BY TotalLithics DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE spacex_satellites (satellite_id INT, name VARCHAR(100), type VARCHAR(50), launch_date DATE, speed FLOAT);
What is the average speed of satellites in the SpaceX fleet?
SELECT AVG(speed) FROM spacex_satellites WHERE type = 'Satellite';
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (StreamID INT, UserID INT, SongID INT, StreamDate TIMESTAMP, Country VARCHAR(50)); CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), ArtistID INT, Genre VARCHAR(50)); INSERT INTO Streams VALUES (1, 1, 1, '2023-01-01 10:00:00', 'South Korea'), (2, 1, 2, '2023-01-01 11:00:00', 'South Korea'), (3, 2, 1, '2023-01-02 12:00:00', 'South Korea'); INSERT INTO Songs VALUES (1, 'K-pop Song', 1, 'K-pop'), (2, 'Rock Out', 2, 'Rock');
What is the total number of streams for K-pop songs in South Korea in the past month?
SELECT SUM(*) FROM Streams JOIN Songs ON Streams.SongID = Songs.SongID WHERE Songs.Genre = 'K-pop' AND Streams.Country = 'South Korea' AND Streams.StreamDate BETWEEN (CURRENT_DATE - INTERVAL '1 month') AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE budget (id INT, dept VARCHAR(50), program VARCHAR(50), amount INT); INSERT INTO budget (id, dept, program, amount) VALUES (1, 'Disability Services', 'Accessible Technology', 50000), (2, 'Disability Services', 'Sign Language Interpretation', 75000), (3, 'Human Resources', 'Diversity Training', 30000), (4, 'Disability Services', 'Assistive Listening Devices', 60000);
Calculate the average budget for each department.
SELECT dept, AVG(amount) as avg_budget FROM budget GROUP BY dept;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (member_id INT, member_name VARCHAR(255), gender VARCHAR(255), union_id INT); CREATE TABLE unions (union_id INT, union_name VARCHAR(255)); INSERT INTO unions (union_id, union_name) VALUES (123, 'Service Employees Union'); INSERT INTO unions (union_id, union_name) VALUES (456, 'Teachers Union'); INSERT INTO union_members (member_id, member_name, gender, union_id) VALUES (1, 'John Doe', 'Male', 123); INSERT INTO union_members (member_id, member_name, gender, union_id) VALUES (2, 'Jane Doe', 'Non-binary', 123);
What is the percentage of non-binary workers in the 'Service Employees Union'?
SELECT ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM union_members WHERE union_id = 123) , 2) FROM union_members WHERE union_id = 123 AND gender = 'Non-binary';
gretelai_synthetic_text_to_sql
CREATE TABLE Tunnels(id INT, name TEXT, location TEXT, length FLOAT); INSERT INTO Tunnels(id, name, location, length) VALUES (1, 'Holland Tunnel', 'New York', 8564.0);
Show the tunnels in New York with a length greater than 5 miles.
SELECT name FROM Tunnels WHERE location = 'New York' AND length > 5 * 5280;
gretelai_synthetic_text_to_sql
CREATE TABLE collective_bargaining (union_name VARCHAR(20), company_name VARCHAR(20), start_date DATE);
Insert a new record into the "collective_bargaining" table with the following values: "Union B", "Company ABC", "2022-07-01"
INSERT INTO collective_bargaining (union_name, company_name, start_date) VALUES ('Union B', 'Company ABC', '2022-07-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Policy_Info (Policy_ID INT, Policy_Limit INT, Driver_Risk VARCHAR(10)); INSERT INTO Policy_Info (Policy_ID, Policy_Limit, Driver_Risk) VALUES (1, 2000000, 'High'), (2, 1500000, 'Medium'), (3, 500000, 'Low'), (4, 3000000, 'High'), (5, 750000, 'Medium');
List all policies with a policy limit higher than $1,000,000 for high-risk drivers.
SELECT * FROM Policy_Info WHERE Policy_Limit > 1000000 AND Driver_Risk = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug varchar(255), quarter varchar(255), revenue int); INSERT INTO sales (drug, quarter, revenue) VALUES ('DrugA', 'Q2 2020', 600000), ('DrugB', 'Q2 2020', 500000);
What is the minimum sales revenue for each drug in Q2 2020?
SELECT drug, MIN(revenue) FROM sales WHERE quarter = 'Q2 2020' GROUP BY drug;
gretelai_synthetic_text_to_sql
CREATE TABLE contractors (contractor_id INT, name VARCHAR(50), state VARCHAR(2)); INSERT INTO contractors (contractor_id, name, state) VALUES (1, 'ABC Construction', 'CA'), (2, 'DEF Construction', 'TX'), (3, 'GHI Construction', 'CA'), (4, 'JKL Construction', 'TX'); CREATE TABLE projects (project_id INT, contractor_id INT, state VARCHAR(2)); INSERT INTO projects (project_id, contractor_id, state) VALUES (101, 1, 'CA'), (102, 2, 'TX'), (103, 3, 'CA'), (104, 4, 'TX');
List all contractors who have completed projects in both 'California' and 'Texas'
SELECT c.name FROM contractors c JOIN projects p ON c.contractor_id = p.contractor_id WHERE c.state IN ('CA', 'TX') GROUP BY c.name HAVING COUNT(DISTINCT c.state) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_efforts (id INT PRIMARY KEY, effort VARCHAR(255), start_date DATE, end_date DATE, location VARCHAR(255));
Which marine conservation efforts in the Indian Ocean have been ongoing for more than 5 years?
SELECT effort, start_date FROM conservation_efforts WHERE end_date IS NULL AND start_date <= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) AND location LIKE '%Indian%';
gretelai_synthetic_text_to_sql
CREATE TABLE fans (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), team VARCHAR(50));
Add a new 'fan' record for 'Jessica White' and her favorite team 'Seattle Yellow'
INSERT INTO fans (id, first_name, last_name, team) VALUES (345, 'Jessica', 'White', 'Seattle Yellow');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, value FLOAT, sign_date DATE); INSERT INTO defense_contracts (contract_id, value, sign_date) VALUES (1, 400000, '2021-07-01'), (2, 500000, '2021-10-01');
What was the average defense contract value in Q3 2021?
SELECT AVG(value) FROM defense_contracts WHERE sign_date BETWEEN '2021-07-01' AND '2021-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE DispensaryStrains (dispensary VARCHAR(255), state VARCHAR(255), strain VARCHAR(255)); INSERT INTO DispensaryStrains (dispensary, state, strain) VALUES ('Dispensary A', 'CA', 'Blue Dream'), ('Dispensary A', 'CO', 'Sour Diesel'), ('Dispensary B', 'CA', 'Blue Dream'), ('Dispensary B', 'CO', 'Durban Poison');
What is the percentage of dispensaries in each state that sell a particular strain, such as Blue Dream?
SELECT state, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM DispensaryStrains WHERE strain = 'Blue Dream') as percentage FROM DispensaryStrains WHERE strain = 'Blue Dream' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, city TEXT, score INT);
What is the average food safety score for restaurants located in each city, excluding cities with no restaurants?
SELECT city, AVG(score) FROM restaurants WHERE city IS NOT NULL GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, size FLOAT, certification VARCHAR(255), PRIMARY KEY (id)); INSERT INTO green_buildings (id, size, certification) VALUES (1, 1200.0, 'LEED'), (2, 800.0, 'BREEAM'), (3, 1500.0, 'WELL');
What is the total size of green buildings in the 'green_buildings' table?
SELECT SUM(size) FROM green_buildings WHERE certification IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE BuildingPermits (PermitID INT, PermitType TEXT, DateIssued DATE);
Identify the number of building permits issued per month, for the past year, separated by permit type.
SELECT DatePart(month, DateIssued) AS Month, PermitType, Count(PermitID) AS Count FROM BuildingPermits WHERE DateIssued >= DATEADD(year, -1, GETDATE()) GROUP BY DatePart(month, DateIssued), PermitType;
gretelai_synthetic_text_to_sql
CREATE TABLE Viewership (country VARCHAR(20), show_id INT, viewers INT); INSERT INTO Viewership (country, show_id, viewers) VALUES ('Canada', 1, 1000000), ('Canada', 2, 800000), ('Canada', 3, 1200000), ('US', 1, 2000000), ('US', 2, 1500000), ('US', 3, 1800000);
How many viewers in Canada watched the top 3 TV shows?
SELECT COUNT(*) FROM (SELECT * FROM Viewership WHERE country = 'Canada' AND show_id IN (1, 2, 3)) AS top_3_shows;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (id INT, name VARCHAR(255), last_inspection DATE);
Which vendors have not been inspected in the last six months?
SELECT name FROM Vendors WHERE last_inspection < (CURRENT_DATE - INTERVAL '6 months');
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name VARCHAR(255), region VARCHAR(255), water_salinity FLOAT); INSERT INTO fish_farms (id, name, region, water_salinity) VALUES (1, 'Farm A', 'Europe', 32.5), (2, 'Farm B', 'Europe', 28.2), (3, 'Farm C', 'Asia Pacific', 15.9);
What is the maximum water salinity (in ppt) in fish farms located in Europe?
SELECT MAX(water_salinity) FROM fish_farms WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE academic_publications (id INT, author_name TEXT, author_gender TEXT, department TEXT, publication_date DATE); INSERT INTO academic_publications (id, author_name, author_gender, department, publication_date) VALUES (1, 'Charlie', 'M', 'Physics', '2021-01-01'); INSERT INTO academic_publications (id, author_name, author_gender, department, publication_date) VALUES (2, 'Dana', 'F', 'Physics', '2022-04-01');
What is the number of academic publications by gender and department in the last 2 years?
SELECT author_gender, department, COUNT(*) FROM academic_publications WHERE publication_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) AND CURRENT_DATE GROUP BY author_gender, department
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, category VARCHAR(255), severity INT); INSERT INTO vulnerabilities (id, category, severity) VALUES (1, 'network', 8), (2, 'malware', 5);
What is the average severity rating of all vulnerabilities in the 'network' category?
SELECT AVG(severity) FROM vulnerabilities WHERE category = 'network';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (customer_id, transaction_amount, transaction_date) VALUES (1, 150.00, '2022-01-01'), (2, 200.00, '2022-01-05'), (3, 120.00, '2022-01-10');
What is the total transaction value for all customers from the United States and Canada in the first quarter of 2022?
SELECT SUM(transaction_amount) FROM transactions WHERE transaction_date BETWEEN '2022-01-01' AND '2022-03-31' AND (country_code = 'US' OR country_code = 'CA');
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock (id INT PRIMARY KEY, species VARCHAR(255), quantity INT, location VARCHAR(255));
Update the quantity for Salmon in the fish_stock table
UPDATE fish_stock SET quantity = 350 WHERE species = 'Salmon';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_capacity (country VARCHAR(255), source_type VARCHAR(255), capacity INT); INSERT INTO energy_capacity (country, source_type, capacity) VALUES ('Germany', 'Solar', 50000), ('Germany', 'Wind', 60000), ('Germany', 'Hydro', 30000);
What is the total solar power capacity in Germany?
SELECT SUM(capacity) FROM energy_capacity WHERE country = 'Germany' AND source_type = 'Solar';
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (id INT, title TEXT, medium TEXT, donor_id INT, donor_type TEXT);CREATE TABLE donors (id INT, name TEXT, city TEXT, country TEXT);
Which art pieces were donated by local philanthropists?
SELECT ap.title, d.name, d.city FROM art_pieces ap JOIN donors d ON ap.donor_id = d.id WHERE d.city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE tourist_sites (id INT PRIMARY KEY, name TEXT, country TEXT, visitor_count INT);
Add a new record to the "tourist_sites" table for "India" called "Taj Mahal" with a visitor count of 8000000
INSERT INTO tourist_sites (id, name, country, visitor_count) VALUES (1, 'Taj Mahal', 'India', 8000000);
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 average population of animals in the 'animal_population' table?
SELECT AVG(population) FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_name VARCHAR(20), item_name VARCHAR(30), price DECIMAL(5,2)); INSERT INTO Menu (menu_name, item_name, price) VALUES ('Lunch', 'Chicken Sandwich', 9.99), ('Lunch', 'Steak Wrap', 12.49), ('Lunch', 'Quinoa Salad', 14.50);
Update the name of the 'Quinoa Salad' on the 'Lunch' menu to 'Quinoa Bowl'
UPDATE Menu SET item_name = 'Quinoa Bowl' WHERE menu_name = 'Lunch' AND item_name = 'Quinoa Salad';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR(50), listing_price DECIMAL(10, 2), co_owned BOOLEAN); INSERT INTO properties (id, city, listing_price, co_owned) VALUES (1, 'New York', 400000.00, TRUE), (2, 'New York', 500000.00, FALSE), (3, 'New York', 350000.00, TRUE);
What is the minimum listing price for properties in New York that are co-owned?
SELECT MIN(listing_price) FROM properties WHERE city = 'New York' AND co_owned = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (DishID INT, DishName VARCHAR(50), Cuisine VARCHAR(50), Calories INT); INSERT INTO Dishes (DishID, DishName, Cuisine, Calories) VALUES (1, 'Hummus', 'Mediterranean', 250), (2, 'Falafel', 'Mediterranean', 350), (3, 'Pizza', 'Italian', 800), (4, 'Pasta', 'Italian', 700);
Identify the dishes that have a lower calorie content than the average calorie content for all dishes?
SELECT DishName FROM Dishes WHERE Calories < (SELECT AVG(Calories) FROM Dishes);
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), state VARCHAR(20));
What is the number of hospitals in each state in the US?
SELECT state, COUNT(*) FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, continent TEXT, confirmed_cases INT, deaths INT); INSERT INTO countries (id, name, continent, confirmed_cases, deaths) VALUES (1, 'Country A', 'Europe', 500000, 20000), (2, 'Country B', 'Asia', 300000, 15000), (3, 'Country C', 'Europe', 800000, 30000), (4, 'Country D', 'Africa', 200000, 10000);
What is the number of confirmed COVID-19 cases and deaths in each country, ordered by the case-fatality ratio, descending?
SELECT name, confirmed_cases, deaths, (deaths * 100.0 / confirmed_cases) as case_fatality_ratio FROM countries ORDER BY case_fatality_ratio DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (donor_id, donation_amount, donation_date) VALUES (1, 100, '2022-01-05'), (2, 250, '2022-03-20'), (3, 50, '2021-12-31'), (4, 75, '2022-11-28'); CREATE TABLE countries (country_id INT, country_name VARCHAR(50)); INSERT INTO countries (country_id, country_name) VALUES (1, 'Canada'), (2, 'United States'), (3, 'Mexico');
How many visitors from Canada supported our organization through donations in 2022?
SELECT COUNT(*) FROM donors JOIN countries ON donors.donation_date >= '2022-01-01' AND donors.donation_date < '2023-01-01' AND countries.country_name = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT PRIMARY KEY, program_name TEXT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Feeding the Hungry'), (2, 'Tutoring Kids');
Delete program with ID 1
WITH program_to_delete AS (DELETE FROM programs WHERE program_id = 1 RETURNING program_id) DELETE FROM program_to_delete;
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture (id INT PRIMARY KEY, farm_id INT, moisture INT, date DATE);
Insert a new record into the "soil_moisture" table with the following data: farm_id: 4, moisture: 70, date: '2023-01-05'
INSERT INTO soil_moisture (farm_id, moisture, date) VALUES (4, 70, '2023-01-05');
gretelai_synthetic_text_to_sql
CREATE TABLE products_ingredients(product_id INT, ingredient_id INT, natural_ingredient BOOLEAN, price DECIMAL, source_country TEXT); INSERT INTO products_ingredients(product_id, ingredient_id, natural_ingredient, price, source_country) VALUES (1, 1, true, 1.25, 'US'), (2, 2, true, 3.00, 'France'), (3, 3, false, 1.50, 'Argentina'), (4, 4, true, 2.00, 'Canada'), (5, 5, true, 2.50, 'US');
What is the average price of natural ingredients for products sourced from the US?
SELECT AVG(price) FROM products_ingredients WHERE natural_ingredient = true AND source_country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (id INT, brand VARCHAR(255), is_cruelty_free BOOLEAN, price DECIMAL(10, 2)); INSERT INTO cosmetics (id, brand, is_cruelty_free, price) VALUES (1, 'Lush', true, 25.99), (2, 'NYX', false, 12.99), (3, 'Lush', true, 34.99), (4, 'Burt’s Bees', true, 15.99);
Identify the number of cruelty-free cosmetic products and their average price, grouped by brand.
SELECT brand, COUNT(*), AVG(price) FROM cosmetics WHERE is_cruelty_free = true GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE tourists (id INT, continent VARCHAR(50), country VARCHAR(50), visitors INT, year INT); INSERT INTO tourists (id, continent, country, visitors, year) VALUES (1, 'Asia', 'Japan', 2500, 2019), (2, 'Asia', 'China', 3000, 2019), (3, 'North America', 'USA', 1500, 2019), (4, 'North America', 'Canada', 1000, 2019);
How many tourists visited Asian countries from North America in 2019?
SELECT SUM(visitors) FROM tourists WHERE continent = 'Asia' AND year = 2019 AND country IN (SELECT country FROM tourists WHERE continent = 'North America');
gretelai_synthetic_text_to_sql
CREATE TABLE DeptServiceBudget (Department TEXT, Budget INTEGER); INSERT INTO DeptServiceBudget (Department, Budget) VALUES ('DepartmentA', 1000000), ('DepartmentB', 1200000), ('DepartmentC', 1100000);
What is the average budget allocated for public service delivery in each department?
SELECT Department, AVG(Budget) FROM DeptServiceBudget GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255)); INSERT INTO farmers (farmer_id, name, age, location) VALUES (1, 'John Doe', 35, 'Springfield');
Create a view 'young_farmers' with farmers under 30 years old
CREATE VIEW young_farmers AS SELECT * FROM farmers WHERE age < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Sales (equipment_id INT, equipment_type VARCHAR(50), equipment_region VARCHAR(50), sale_date DATE, sale_value FLOAT);
What is the trend of military equipment sales by type, in the North American region over the last 2 years?
SELECT equipment_type, equipment_region, DATEPART(year, sale_date) as sale_year, AVG(sale_value) as avg_sale_value FROM Equipment_Sales WHERE equipment_region = 'North American region' AND sale_date >= DATEADD(year, -2, GETDATE()) GROUP BY equipment_type, equipment_region, sale_year;
gretelai_synthetic_text_to_sql
CREATE TABLE inspections (id INT, restaurant_name TEXT, grade TEXT, inspection_date DATE);
Add a new record to the 'inspections' table for '2023-02-15' with a grade of 'B'
INSERT INTO inspections (restaurant_name, grade, inspection_date) VALUES ('ABC Restaurant', 'B', '2023-02-15');
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), destination VARCHAR(50)); INSERT INTO space_missions (id, name, destination) VALUES (1, 'Europa One', 'Europa');
Insert a new record for a space mission to Jupiter's moon Europa.
INSERT INTO space_missions (id, name, destination) VALUES (2, 'Jupiter II', 'Europa');
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturing (id INT, spacecraft_name VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO spacecraft_manufacturing (id, spacecraft_name, manufacturer) VALUES (1, 'Apollo CSM', 'North American Rockwell'), (2, 'Apollo LM', 'Grumman'), (3, 'Space Shuttle Orbiter', 'Rockwell International');
How many spacecrafts have been manufactured in total, considering the 'spacecraft_manufacturing' table?
SELECT COUNT(DISTINCT spacecraft_name) FROM spacecraft_manufacturing;
gretelai_synthetic_text_to_sql
CREATE TABLE flights (id INT, pilot_name VARCHAR(50), flight_hours DECIMAL(10,2), flight_date DATE);
Show the total number of flight hours for pilot Jane Doe
SELECT SUM(flight_hours) FROM flights WHERE pilot_name = 'Jane Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT);
Show the maximum quantity of all items in the Inventory table
SELECT MAX(quantity) FROM Inventory;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (forest_type VARCHAR(30), country VARCHAR(20), sequestration_rate FLOAT); INSERT INTO carbon_sequestration (forest_type, country, sequestration_rate) VALUES ('Boreal Forest', 'Canada', 1.23), ('Boreal Forest', 'Russia', 2.34);
What is the average carbon sequestration rate, in metric tons per hectare per year, for boreal forests in Canada and Russia?
SELECT AVG(sequestration_rate) FROM carbon_sequestration WHERE forest_type = 'Boreal Forest' AND country IN ('Canada', 'Russia');
gretelai_synthetic_text_to_sql
CREATE TABLE construction_workers (id INT, name VARCHAR(50), salary DECIMAL(10, 2), state VARCHAR(10)); INSERT INTO construction_workers (id, name, salary, state) VALUES (1, 'John Doe', 60000, 'Washington'); INSERT INTO construction_workers (id, name, salary, state) VALUES (2, 'Jane Smith', 55000, 'Washington');
Who are the construction workers in Washington with a salary higher than the average salary?
SELECT * FROM construction_workers WHERE state = 'Washington' AND salary > (SELECT AVG(salary) FROM construction_workers WHERE state = 'Washington');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_name VARCHAR(100), donation_amount DECIMAL(10,2), donation_date DATE, event_id INT);
What is the average donation amount per day, for the month of December, in the year 2021?
SELECT DATE_TRUNC('day', donation_date) as donation_day, AVG(donation_amount) as avg_donation FROM Donations WHERE DATE_TRUNC('month', donation_date) = DATE_TRUNC('month', '2021-12-01') AND DATE_TRUNC('year', donation_date) = DATE_TRUNC('year', '2021-12-01') GROUP BY donation_day;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (date DATE, threat_level INT, incident_count INT); INSERT INTO threat_intelligence (date, threat_level, incident_count) VALUES ('2021-01-01', 5, 200), ('2021-02-01', 4, 150), ('2021-03-01', 6, 220), ('2021-04-01', 3, 100), ('2021-05-01', 7, 250), ('2021-06-01', 4, 180), ('2021-07-01', 5, 200), ('2021-08-01', 6, 220), ('2021-09-01', 3, 100), ('2021-10-01', 7, 250), ('2021-11-01', 4, 180), ('2021-12-01', 5, 200);
What are the average threat intelligence metrics for the past year?
SELECT AVG(threat_level), AVG(incident_count) FROM threat_intelligence WHERE date >= '2021-01-01' AND date <= '2021-12-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID int, Title varchar(50), YearCreated int, AverageRating decimal(3,2)); CREATE TABLE Artists (ArtistID int, Name varchar(50), Nationality varchar(50));
What is the average rating of Indigenous artworks?
SELECT AVG(Artworks.AverageRating) AS AverageIndigenousArtworksRating FROM Artworks INNER JOIN Artists ON Artworks.ArtistID = Artists.ArtistID WHERE Artists.Nationality LIKE 'Indigenous%';
gretelai_synthetic_text_to_sql
CREATE TABLE genres (id INT, genre TEXT);
Delete all records from the 'genres' table
DELETE FROM genres;
gretelai_synthetic_text_to_sql
CREATE TABLE patents (patent_id INT, year INT, team_leader VARCHAR(10), technology VARCHAR(20)); INSERT INTO patents (patent_id, year, team_leader, technology) VALUES (1, 2012, 'Aisha', 'Legal Tech'), (2, 2015, 'Brian', 'Legal Tech');
How many legal technology patents were granted to women-led teams in the past decade?
SELECT COUNT(*) FROM patents WHERE technology = 'Legal Tech' AND YEAR(year) >= 2011 AND team_leader IN ('Aisha', 'Brian', 'Candace', 'Dana', 'Eva');
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_smart_contracts (id INT, gas_fees DECIMAL(10, 2), gaming_involvement BOOLEAN); INSERT INTO ethereum_smart_contracts (id, gas_fees, gaming_involvement) VALUES (1, 25, TRUE);
What are the average gas fees for Ethereum smart contracts involved in gaming?
SELECT AVG(gas_fees) FROM ethereum_smart_contracts WHERE gaming_involvement = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, mineral TEXT, productivity INT); INSERT INTO mine (id, name, location, mineral, productivity) VALUES (1, 'Fresnillo', 'Mexico', 'Silver', 2000), (2, 'Penasquito', 'Mexico', 'Silver', 1800);
How many silver mines are there in Mexico with productivity above 1500?
SELECT COUNT(*) FROM mine WHERE mineral = 'Silver' AND location = 'Mexico' AND productivity > 1500;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthClinics (ClinicID INT, Location VARCHAR(50), Type VARCHAR(20), ParityCompliance DATE); INSERT INTO MentalHealthClinics (ClinicID, Location, Type, ParityCompliance) VALUES (1, '123 Main St', 'Psychiatric', '2022-01-01'); INSERT INTO MentalHealthClinics (ClinicID, Location, Type, ParityCompliance) VALUES (2, '456 Elm St', 'Counseling', NULL);
What is the number of mental health clinics that are not in compliance with mental health parity regulations?
SELECT COUNT(ClinicID) FROM MentalHealthClinics WHERE ParityCompliance IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE support_programs (program_id INT, program_name VARCHAR(30), budget DECIMAL(10,2), region VARCHAR(20)); INSERT INTO support_programs (program_id, program_name, budget, region) VALUES (1, 'Mobility Support', 25000, 'North'), (2, 'Assistive Technology', 30000, 'South'), (3, 'Note Taking', 15000, 'East'), (4, 'Diversity Training', 40000, 'West');
Calculate the average budget for support programs in each region
SELECT region, AVG(budget) FROM support_programs GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE education_initiatives (id INT, region VARCHAR(255), completion_date DATE, budget FLOAT); INSERT INTO education_initiatives (id, region, completion_date, budget) VALUES (1, 'Southeast', '2020-01-01', 80000.00), (2, 'Northwest', '2021-12-31', 55000.00), (3, 'Southeast', '2022-02-14', 100000.00);
What is the average number of education initiatives in the southeastern region, that were completed in the last 2 years and had a budget over $70,000?
SELECT AVG(budget) FROM education_initiatives WHERE region = 'Southeast' AND completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) AND budget > 70000;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT PRIMARY KEY, product VARCHAR(100), quantity INT); INSERT INTO inventory (id, product, quantity) VALUES (1, 'Fresh Mozzarella', 50), (2, 'Tomato Sauce', 100), (3, 'Romaine Lettuce', 30), (4, 'Free-Range Eggs', 60);
What is the total quantity of 'Free-Range Eggs' in inventory?
SELECT SUM(quantity) FROM inventory WHERE product = 'Free-Range Eggs';
gretelai_synthetic_text_to_sql
CREATE TABLE stories (id INT, title VARCHAR(100), country VARCHAR(50), story_type VARCHAR(50)); INSERT INTO stories (id, title, country, story_type) VALUES (1, 'Celebrity interview', 'USA', 'Entertainment'), (2, 'Movie review', 'India', 'Entertainment'), (3, 'Music album release', 'South Korea', 'Entertainment');
Rank the top 3 countries by the number of entertainment stories published, in descending order.
SELECT country, RANK() OVER (ORDER BY COUNT(*) DESC) ranking FROM stories WHERE story_type = 'Entertainment' GROUP BY country HAVING ranking <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tunnels (tunnel_name TEXT, tunnel_width INT, tunnel_state TEXT); INSERT INTO tunnels (tunnel_name, tunnel_width, tunnel_state) VALUES ('T1', 25, 'New Jersey'), ('T2', 30, 'New Jersey'), ('T3', 35, 'New Jersey'), ('T4', 20, 'New Jersey');
What is the average width of tunnels in New Jersey?
SELECT AVG(tunnel_width) FROM tunnels WHERE tunnel_state = 'New Jersey';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount int, Country varchar(50)); INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (1, 'John Doe', 7000, 'USA'), (2, 'Jane Smith', 3000, 'Canada'), (3, 'Mike Johnson', 4000, 'USA'), (4, 'Emma Wilson', 8000, 'Kenya'), (5, 'Aisha Ahmed', 6000, 'USA');
Update the donation amount to 9000 for any donor from Kenya
UPDATE Donors SET Donation_Amount = 9000 WHERE Country = 'Kenya';
gretelai_synthetic_text_to_sql
CREATE TABLE athletes_table (athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(20)); INSERT INTO athletes_table (athlete_id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athletes_table (athlete_id, name, age, sport) VALUES (2, 'Jane Smith', 30, 'Soccer');
Find the average age of athletes in 'athletes_table'
SELECT AVG(age) FROM athletes_table;
gretelai_synthetic_text_to_sql
CREATE TABLE detentions (id INT, region VARCHAR(50), year INT, num_vessels INT); INSERT INTO detentions (id, region, year, num_vessels) VALUES (1, 'Mediterranean Sea', 2018, 12), (2, 'Mediterranean Sea', 2019, 15), (3, 'Mediterranean Sea', 2020, 18);
How many vessels were detained for maritime safety violations in the Mediterranean Sea in 2018?
SELECT num_vessels FROM detentions WHERE region = 'Mediterranean Sea' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE treatment_summary (patient_id INT, region TEXT, treatment_type TEXT); INSERT INTO treatment_summary (patient_id, region, treatment_type) VALUES (5, 'Southern', 'Medication'); INSERT INTO treatment_summary (patient_id, region, treatment_type) VALUES (6, 'Northern', 'Therapy');
How many patients have been treated using medication in the Southern region?
SELECT COUNT(*) FROM treatment_summary WHERE region = 'Southern' AND treatment_type = 'Medication';
gretelai_synthetic_text_to_sql
CREATE TABLE Student_Accommodations (student_id INT, accommodation_type TEXT, cost DECIMAL(5,2), academic_year INT); CREATE VIEW Visual_Impairment_Accommodations AS SELECT * FROM Student_Accommodations WHERE accommodation_type LIKE '%visual impairment%'; CREATE VIEW Total_Visual_Impairment_Accommodations_Cost AS SELECT SUM(cost) FROM Visual_Impairment_Accommodations WHERE academic_year = YEAR(CURRENT_DATE)-1;
What is the total cost of accommodations provided to students with visual impairments in the last academic year?
SELECT Total_Visual_Impairment_Accommodations_Cost.SUM(cost) FROM Visual_Impairment_Accommodations INNER JOIN Total_Visual_Impairment_Accommodations_Cost ON Visual_Impairment_Accommodations.accommodation_type = Total_Visual_Impairment_Accommodations_Cost.accommodation_type WHERE Visual_Impairment_Accommodations.academic_year = YEAR(CURRENT_DATE)-1;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_contacts (id INT, name TEXT, phone_number TEXT); INSERT INTO emergency_contacts (id, name, phone_number) VALUES (1, 'John Doe', '1234567890'), (2, 'Jane Smith', '0987654321');
Insert data into 'emergency_contacts' table
INSERT INTO emergency_contacts (id, name, phone_number) VALUES (1, 'John Doe', '1234567890'), (2, 'Jane Smith', '0987654321');
gretelai_synthetic_text_to_sql
CREATE TABLE audience (id INT, gender VARCHAR(10), age INT, location VARCHAR(50), interests VARCHAR(100)); INSERT INTO audience (id, gender, age, location, interests) VALUES (1, 'Male', 25, 'New York', 'Sports'); INSERT INTO audience (id, gender, age, location, interests) VALUES (2, 'Female', 35, 'California', 'Entertainment'); INSERT INTO audience (id, gender, age, location, interests) VALUES (3, 'Male', 45, 'Texas', 'Politics');
What is the sum of all audience demographics in the 'audience' table?
SELECT SUM(age) FROM audience;
gretelai_synthetic_text_to_sql
CREATE TABLE public.biosensors (id SERIAL PRIMARY KEY, name VARCHAR(255), type TEXT, accuracy FLOAT); INSERT INTO public.biosensors (name, type, accuracy) VALUES ('BioSen-1', 'Biosensor', 92.5), ('BioSen-2', 'Glucose', 96.0), ('BioSen-3', 'Genetic', 94.5);
What are the names and types of biosensors that have an accuracy of at least 95%?
SELECT b.name, b.type FROM public.biosensors b WHERE b.accuracy >= 95.0;
gretelai_synthetic_text_to_sql