context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE neighborhoods (id INT, name TEXT);CREATE TABLE accidents (id INT, neighborhood_id INT, date DATE);
How many traffic accidents were there in each neighborhood in the last 3 months, grouped by day?
SELECT n.name, DATEADD(day, DATEDIFF(day, 0, a.date), 0) AS truncated_date, COUNT(a.id) FROM neighborhoods n JOIN accidents a ON n.id = a.neighborhood_id WHERE a.date >= DATEADD(month, -3, GETDATE()) GROUP BY n.id, truncated_date ORDER BY truncated_date;
gretelai_synthetic_text_to_sql
CREATE TABLE cs_students (id INT, student_type VARCHAR(10), gre_score INT); INSERT INTO cs_students (id, student_type, gre_score) VALUES (1, 'domestic', 320), (2, 'international', 330);
What is the average GRE score for domestic graduate students in the Computer Science department?
SELECT AVG(gre_score) FROM cs_students WHERE student_type = 'domestic';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, age INT, region TEXT); INSERT INTO clients (id, name, age, region) VALUES (1, 'John Doe', 35, 'California');
What is the minimum age of clients in the 'California' region?
SELECT MIN(age) FROM clients WHERE region = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Audience (id INT, name TEXT, age INT, gender TEXT, city TEXT, attendance INT); INSERT INTO Audience (id, name, age, gender, city, attendance) VALUES (1, 'John Doe', 25, 'Male', 'New York', 200), (2, 'Jane Smith', 35, 'Female', 'Los Angeles', 300), (3, 'Bob Johnson', 45, 'Male', 'Chicago', 400);
Show all audience demographics and their corresponding attendance
SELECT * FROM Audience;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, age INT, country TEXT, assets FLOAT); INSERT INTO customers (id, name, age, country, assets) VALUES (1, 'John Doe', 45, 'USA', 250000.00); INSERT INTO customers (id, name, age, country, assets) VALUES (2, 'Jane Smith', 34, 'Canada', 320000.00); INSERT INTO customers (id, name,...
How many customers are there from each country?
SELECT country, COUNT(*) FROM customers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, country TEXT, amount DECIMAL(10,2)); INSERT INTO donations (id, country, amount) VALUES (1, 'Country A', 500.00), (2, 'Country A', 750.00), (3, 'Country B', 300.00), (4, 'Country C', 1000.00);
What is the average donation amount per country, for countries that have received donations?
SELECT country, AVG(amount) FROM donations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT PRIMARY KEY, investor_id INT, nonprofit_id INT, amount DECIMAL(10,2), investment_date DATE); INSERT INTO investments (id, investor_id, nonprofit_id, amount, investment_date) VALUES (1, 1, 2, 1500.00, '2020-03-01'), (2, 2, 4, 2000.00, '2020-05-01'), (3, 3, 5, 1000.00, '2020-09-01'); CREA...
Who are the investors who have not made any investments in the healthcare sector?
SELECT i.id, i.name FROM investors i LEFT JOIN (SELECT investor_id FROM investments WHERE nonprofit_id IN (SELECT id FROM nonprofits WHERE sector = 'Healthcare')) sub ON i.id = sub.investor_id WHERE sub.investor_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE nz_population (id INT, age INT, location VARCHAR(50), ethnicity VARCHAR(50), vaccinated BOOLEAN); INSERT INTO nz_population (id, age, location, ethnicity, vaccinated) VALUES (1, 20, 'Rural', 'Maori', true);
What is the percentage of the population that is vaccinated by ethnicity in rural areas of New Zealand?
SELECT ethnicity, (SUM(vaccinated_count) * 100.0 / SUM(total_count)) as vaccination_percentage FROM (SELECT ethnicity, SUM(vaccinated) as vaccinated_count, COUNT(*) as total_count FROM nz_population WHERE location = 'Rural' GROUP BY ethnicity) as subquery GROUP BY ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT PRIMARY KEY, seller VARCHAR(255), buyer VARCHAR(255), equipment_type VARCHAR(255), quantity INT);
What is the total number of military equipment of each type sold and the total quantity sold, ordered by the total quantity sold in descending order?
SELECT equipment_type, SUM(quantity) FROM military_sales GROUP BY equipment_type ORDER BY SUM(quantity) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE AnimalPopulation (AnimalID int, AnimalName varchar(50), Population int); INSERT INTO AnimalPopulation (AnimalID, AnimalName, Population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 500), (3, 'Giraffe', 1200);
Delete records with a Population less than 1000 from the 'AnimalPopulation' table.
DELETE FROM AnimalPopulation WHERE Population < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE ExtractionData (ExtractionDataID INT, MineID INT, Date DATE, Mineral TEXT, Quantity INT);
What is the total quantity of mineral extracted for each mine in the first quarter of a specific year?
SELECT MineID, SUM(Quantity) FROM ExtractionData WHERE Date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY MineID;
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, country VARCHAR(255), num_personnel INT); INSERT INTO military_personnel (id, country, num_personnel) VALUES (1, 'Indonesia', 400000); INSERT INTO military_personnel (id, country, num_personnel) VALUES (2, 'Vietnam', 350000);
What is the total number of military personnel in Southeast Asia?
SELECT SUM(num_personnel) AS total_personnel FROM military_personnel WHERE country IN ('Indonesia', 'Vietnam', 'Philippines', 'Myanmar', 'Thailand');
gretelai_synthetic_text_to_sql
CREATE TABLE military_operations (id INT, operation_name VARCHAR(50), country VARCHAR(50), start_date DATE, end_date DATE);
What are the details of military operations in the Middle East since 2010?
SELECT * FROM military_operations WHERE country = 'Middle East' AND start_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_gender (case_id INT, attorney_gender VARCHAR(50)); INSERT INTO attorney_gender (case_id, attorney_gender) VALUES (1, 'female'), (2, 'male'), (3, 'female');
What is the total number of cases handled by female attorneys?
SELECT COUNT(*) FROM attorney_gender WHERE attorney_gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_management (vessel_id INT, vessel_name VARCHAR(50), launch_date DATE); INSERT INTO fleet_management (vessel_id, vessel_name, launch_date) VALUES (1, 'Vessel_A', '2015-01-01'), (2, 'Vessel_B', '2016-01-01'), (3, 'Vessel_C', '2017-01-01');
What is the average age of vessels in the fleet_management table?
SELECT AVG(DATEDIFF(CURDATE(), launch_date) / 365.25) FROM fleet_management;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, country VARCHAR(255)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, country) VALUES (1, 5.5, 'USA'), (2, 3.2, 'Canada'), (3, 6.1, 'Mexico');
What is the average data usage for each country's mobile subscribers, ordered from highest to lowest?
SELECT country, AVG(data_usage) as avg_data_usage FROM mobile_subscribers GROUP BY country ORDER BY avg_data_usage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE canada_cybersecurity_incidents (id INT, year INT, incidents INT); INSERT INTO canada_cybersecurity_incidents (id, year, incidents) VALUES (1, 2018, 300), (2, 2019, 450), (3, 2020, 520);
What was the average number of cybersecurity incidents reported in Canada between 2018 and 2020?
SELECT AVG(incidents) FROM canada_cybersecurity_incidents WHERE year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ytterbium_suppliers (supplier VARCHAR(50), shipments INT); CREATE TABLE ytterbium_shipments (supplier VARCHAR(50), year INT);
List all Ytterbium suppliers and their respective number of shipments in 2020.
SELECT s.supplier, COUNT(*) FROM ytterbium_shipments sh INNER JOIN ytterbium_suppliers s ON sh.supplier = s.supplier WHERE sh.year = 2020 GROUP BY s.supplier;
gretelai_synthetic_text_to_sql
CREATE TABLE dolphin_sightings (year INT, location TEXT, sightings INT); INSERT INTO dolphin_sightings (year, location, sightings) VALUES (2017, 'Mediterranean Sea', 120), (2018, 'Mediterranean Sea', 150), (2019, 'Mediterranean Sea', 170);
How many dolphin sightings were reported in the Mediterranean Sea in 2019?
SELECT sightings FROM dolphin_sightings WHERE year = 2019 AND location = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (id INT, category VARCHAR(20)); INSERT INTO ArtPieces (id, category) VALUES (1, 'Impressionism'), (2, 'Cubism'), (3, 'Impressionism');
How many art pieces are there in the 'Impressionism' category?
SELECT COUNT(*) FROM ArtPieces WHERE category = 'Impressionism';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(255)); INSERT INTO donors (id, name) VALUES (101, 'Alice'), (102, 'Bob'), (103, 'Charlie'), (104, 'David'), (105, 'Eve'); CREATE TABLE donations (id INT, donor_id INT, program_id INT, donation_amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, program_id, donation_amou...
Who are the top 3 donors by total donation amount for the 'Health' program?
SELECT d.donor_id, d.name, SUM(d.donation_amount) as total_donation_amount FROM donations d JOIN donors don ON d.donor_id = don.id WHERE d.program_id = 2 GROUP BY d.donor_id ORDER BY total_donation_amount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (spacecraft_id INT, manufacturer VARCHAR(255), flight_test_result VARCHAR(10)); INSERT INTO Spacecraft (spacecraft_id, manufacturer, flight_test_result) VALUES (1, 'AstroSpace', 'successful'), (2, 'Galactic Enterprise', 'failed'), (3, 'AstroSpace', 'successful'), (4, 'Galactic Enterprise', 'succ...
What is the total number of successful and failed flight tests for each spacecraft manufacturer?
SELECT manufacturer, COUNT(*) as total_tests, SUM(flight_test_result = 'successful') as successful_tests, SUM(flight_test_result = 'failed') as failed_tests FROM Spacecraft GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE maintenance_expenses (id INT, equipment_type VARCHAR(50), maintenance_date DATE, expense DECIMAL(10,2)); INSERT INTO maintenance_expenses (id, equipment_type, maintenance_date, expense) VALUES (1, 'Excavator', '2021-03-15', 1000.00), (2, 'Drill', '2021-03-17', 750.00), (3, 'Excavator', '2021-03-20', 1200.0...
What is the total amount spent on equipment maintenance, by type, in the 'maintenance_expenses' table?
SELECT equipment_type, SUM(expense) as total_expense FROM maintenance_expenses GROUP BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE civil_cases (case_id INT, case_name VARCHAR(255), case_status VARCHAR(255)); INSERT INTO civil_cases VALUES (1, 'Case A', 'Open'), (2, 'Case B', 'Closed'); CREATE TABLE criminal_cases (case_id INT, case_name VARCHAR(255), case_status VARCHAR(255)); INSERT INTO criminal_cases VALUES (3, 'Case C', 'In Progre...
What is the total number of cases in the 'civil_cases' and 'criminal_cases' tables?
SELECT COUNT(*) FROM civil_cases UNION SELECT COUNT(*) FROM criminal_cases;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), country VARCHAR(255), cost FLOAT); INSERT INTO space_missions (id, mission_name, country, cost) VALUES (1, 'Apollo 11', 'USA', 25500000), (2, 'Mars Orbiter Mission', 'India', 73000000), (3, 'Chandrayaan-1', 'India', 79000000), (4, 'Grail', 'USA', 496000000...
What is the average cost of space missions for each country?
SELECT country, AVG(cost) as avg_cost FROM space_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (id INT, tail_number VARCHAR(20), model VARCHAR(100), airline VARCHAR(100), flight_hours DECIMAL(10,2)); INSERT INTO Aircraft (id, tail_number, model, airline, flight_hours) VALUES (5, 'N56789', '737-800', 'GreenAirlines', 12000.00); INSERT INTO Aircraft (id, tail_number, model, airline, flight_ho...
Find the number of aircraft with more than 10000 flight hours for each airline?
SELECT airline, COUNT(*) OVER (PARTITION BY airline) as count FROM Aircraft WHERE flight_hours > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INTEGER, species_name VARCHAR(255), population_trend VARCHAR(255));
List all marine species with observed population declines.
SELECT species_name FROM marine_species WHERE population_trend = 'decline';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, title VARCHAR(20), release_year INT, revenue INT); INSERT INTO games (id, title, release_year, revenue) VALUES (1, 'Galactic Gold', 2021, 50000000), (2, 'Mystic Mayhem', 2020, 40000000), (3, 'Quantum Quandary', 2021, 60000000), (4, 'Retro Rampage', 2019, 30000000), (5, 'Solar System Siege', ...
What is the average revenue of games released in 2021, excluding those that have not been released yet?
SELECT AVG(games.revenue) FROM games WHERE games.release_year = 2021 AND games.revenue IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Producers(producer VARCHAR(50), year INT, revenue INT); INSERT INTO Producers(producer, year, revenue) VALUES ('Producer A', 2018, 100000), ('Producer A', 2019, 120000), ('Producer B', 2018, 110000), ('Producer B', 2019, 130000), ('Producer C', 2018, 90000), ('Producer C', 2019, 100000);
What are the total annual revenues of the top 2 rare earth element producers?
SELECT producer, SUM(revenue) FROM Producers WHERE year = 2019 AND revenue IN (SELECT MAX(revenue) FROM Producers WHERE year = 2019) OR year = 2018 AND revenue IN (SELECT MAX(revenue) FROM Producers WHERE year = 2018) GROUP BY producer;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (id INT, type VARCHAR(50), country VARCHAR(50), purchase_date DATE); INSERT INTO equipment (id, type, country, purchase_date) VALUES (1, 'drill', 'China', '2017-01-01'), (2, 'truck', 'China', '2020-01-01');
Delete records in the "equipment" table where the "country" is "China" and the "type" is "drill" that were purchased before 2018
DELETE FROM equipment WHERE country = 'China' AND type = 'drill' AND purchase_date < '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Workout (id INT, member_id INT, session_start TIMESTAMP, session_end TIMESTAMP); INSERT INTO Workout (id, member_id, session_start, session_end) VALUES (1, 1001, '2022-01-01 08:00:00', '2022-01-01 09:00:00');
List the total duration of each type of workout for members who have used a wearable device for more than 270 days.
SELECT wt.workout_name, SUM(DATEDIFF('second', session_start, session_end)) as total_duration FROM Workout w JOIN WorkoutSession ws ON w.id = ws.id JOIN Member m ON w.member_id = m.id JOIN WearableDevice wd ON m.id = wd.member_id WHERE DATEDIFF('day', device_start_date, device_end_date) > 270 GROUP BY wt.workout_name;
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, Spend DECIMAL(10,2));CREATE VIEW Revenue AS SELECT g.Genre, c.Country, SUM(p.Spend) as TotalRevenue FROM Games g JOIN Players p ON g.GameID = p.GameID JOIN (SELECT PlayerID...
What are the top 3 countries with the highest total revenue for the "AdventureGames" genre?
SELECT Genre, Country, TotalRevenue FROM Revenue WHERE Genre = 'AdventureGames' ORDER BY TotalRevenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE product_labels (product VARCHAR(255), paraben_free BOOLEAN, fragrance_free BOOLEAN, customer_rating DECIMAL(2,1)); INSERT INTO product_labels (product, paraben_free, fragrance_free, customer_rating) VALUES ('Cleanser', TRUE, TRUE, 4.2), ('Toner', FALSE, TRUE, 3.8);
Show the customer ratings for products with paraben-free and fragrance-free labels
SELECT product, customer_rating FROM product_labels WHERE paraben_free = TRUE AND fragrance_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification_monitoring_stations (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO ocean_acidification_monitoring_stations (id, name, location) VALUES (1, 'Hans Island Station', 'Arctic'); INSERT INTO ocean_acidification_monitoring_stations (id, name, location) VALUES (2, 'Rothera Stat...
How many ocean acidification monitoring stations are there in the Arctic and Antarctic regions?
SELECT COUNT(*) FROM ocean_acidification_monitoring_stations WHERE location IN ('Arctic', 'Antarctic');
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), ManufacturerCountry VARCHAR(50), LaunchDate DATE, SolarPanel BOOLEAN); INSERT INTO Spacecraft (SpacecraftID, Name, ManufacturerCountry, LaunchDate, SolarPanel) VALUES (1, 'Voyager 1', 'USA', '1977-09-05', TRUE); INSERT INTO Spacecraft (SpacecraftID, Name, Man...
Which countries have manufactured spacecraft using solar panel technology?
SELECT DISTINCT ManufacturerCountry FROM Spacecraft WHERE SolarPanel = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectFunds (FundID int, ProjectID int, FundsAllocated money, FundDate date);
Show the total funds allocated to each project in the current year.
SELECT ProjectID, SUM(FundsAllocated) as TotalFundsAllocated FROM ProjectFunds WHERE DATEPART(YEAR, FundDate) = DATEPART(YEAR, GETDATE()) GROUP BY ProjectID;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT); INSERT INTO donors VALUES (1, 'USAID', 'USA'); INSERT INTO donors VALUES (2, 'DFID', 'UK'); CREATE TABLE donations (id INT, donor_id INT, sector TEXT, amount INT, donation_date YEAR); INSERT INTO donations VALUES (1, 1, 'disaster response', 3000, 2018);
What are the top 5 donors for 'disaster response' sector in Bangladesh in 2018 and the total amount donated by each?
SELECT d.name, SUM(donations.amount) FROM donations INNER JOIN donors ON donations.donor_id = donors.id WHERE donations.sector = 'disaster response' AND donations.donation_date = 2018 AND donors.country = 'Bangladesh' GROUP BY donations.donor_id ORDER BY SUM(donations.amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Genre (Genre VARCHAR(50)); CREATE TABLE GenreRevenue (Genre VARCHAR(50), ReleaseDate DATE, Revenue DECIMAL(10, 2)); INSERT INTO Genre (Genre) VALUES ('Pop'); INSERT INTO GenreRevenue (Genre, ReleaseDate, Revenue) VALUES ('Rock', '2020-01-01', 5000);
List the genres that have no associated revenue.
SELECT Genre FROM Genre WHERE Genre NOT IN (SELECT Genre FROM GenreRevenue);
gretelai_synthetic_text_to_sql
CREATE TABLE monorail_routes (route_id INT PRIMARY KEY, start_location TEXT, end_location TEXT);
Delete all 'Monorail' routes
DELETE FROM monorail_routes;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (reader_id INT PRIMARY KEY, age INT, gender VARCHAR(10), location VARCHAR(100));
Delete the 'readers' table
DROP TABLE readers;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchVessels (id INT, name VARCHAR(50), type VARCHAR(50), length INT, year INT); INSERT INTO ResearchVessels (id, name, type, length, year) VALUES (1, 'Ocean Explorer', 'Research', 100, 2010), (2, 'Marine Discoverer', 'Exploration', 120, 2015), (3, 'Sea Surveyor', 'Survey', 90, 2005);
Insert new records for a new research vessel into the 'ResearchVessels' table
INSERT INTO ResearchVessels (id, name, type, length, year) VALUES (4, 'Ocean Odyssey', 'Research', 110, 2018);
gretelai_synthetic_text_to_sql
CREATE TABLE launches (launch_id INT, launch_date DATE); INSERT INTO launches (launch_id, launch_date) VALUES (1, '2020-01-01'), (2, '2019-12-15'), (3, '2021-03-03'); CREATE TABLE satellites (satellite_id INT, launch_id INT, launch_date DATE); INSERT INTO satellites (satellite_id, launch_id, launch_date) VALUES (1, 1, ...
How many satellites were launched in 2020?
SELECT COUNT(*) FROM satellites WHERE YEAR(launch_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE SCHEMA PrecisionFarming; CREATE TABLE IoT_Sensors (sensor_id INT, sensor_name VARCHAR(50), measurement VARCHAR(50)); INSERT INTO PrecisionFarming.IoT_Sensors (sensor_id, sensor_name, measurement) VALUES (1, 'Sensor1', 'temperature'), (2, 'Sensor2', 'humidity'), (4, 'Sensor4', 'moisture'), (5, 'Sensor5', 'moistur...
List the names and measurement types of IoT sensors in the 'PrecisionFarming' schema that have a 'moisture' measurement.
SELECT sensor_name, measurement FROM PrecisionFarming.IoT_Sensors WHERE measurement = 'moisture';
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, Name VARCHAR(100), Genre VARCHAR(50), VRPossible BOOLEAN); INSERT INTO Games (GameID, Name, Genre, VRPossible) VALUES (1, 'Game1', 'Action', true), (2, 'Game2', 'Adventure', true), (3, 'Game3', 'Simulation', false), (4, 'Game4', 'Strategy', false), (5, 'Game5', 'Puzzle', false);
List the unique game genres for games designed for non-VR platforms.
SELECT DISTINCT Genre FROM Games WHERE VRPossible = false;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, user_name VARCHAR(50), join_date DATE, follower_count INT);CREATE TABLE posts (post_id INT, user_id INT, post_content TEXT, post_date DATE);INSERT INTO users (user_id, user_name, join_date, follower_count) VALUES (1, 'user1', '2021-01-01', 15000), (2, 'user2', '2021-02-01', 12000), (3, ...
Who are the top 5 users with the most followers who have posted about vegan food in the past month?
SELECT u.user_name, u.follower_count FROM users u JOIN posts p ON u.user_id = p.user_id WHERE p.post_content LIKE '%vegan food%' AND p.post_date >= DATEADD(month, -1, GETDATE()) ORDER BY u.follower_count DESC, u.user_name DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (model_name TEXT, dataset TEXT, safety_score INTEGER); INSERT INTO creative_ai (model_name, dataset, safety_score) VALUES ('model1', 'creative_ai', 85), ('model2', 'creative_ai', 92);
What is the maximum safety score for models trained on the 'creative_ai' dataset?
SELECT MAX(safety_score) FROM creative_ai WHERE dataset = 'creative_ai';
gretelai_synthetic_text_to_sql
CREATE TABLE AerospaceWorkers (WorkerID INT, Country VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO AerospaceWorkers (WorkerID, Country, Salary) VALUES (1, 'USA', 12000), (2, 'Canada', 13000), (3, 'UK', 14000);
What is the minimum salary of workers in the aerospace industry by country?
SELECT Country, MIN(Salary) as MinSalary FROM AerospaceWorkers GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (network VARCHAR(255), transaction_count INT); INSERT INTO transactions (network, transaction_count) VALUES ('Ripple', 200000); INSERT INTO transactions (network, transaction_count) VALUES ('Stellar', 150000);
Find the total number of transactions processed by Ripple and Stellar networks.
SELECT SUM(transaction_count) FROM transactions WHERE network IN ('Ripple', 'Stellar');
gretelai_synthetic_text_to_sql
CREATE TABLE mediators (mediator_id INT, name TEXT); INSERT INTO mediators (mediator_id, name) VALUES (1, 'John'), (2, 'Jane'), (3, 'Mike'); CREATE TABLE cases (case_id INT, mediator_id INT, date TEXT); INSERT INTO cases (case_id, mediator_id, date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-02-01'), (3, 2, '2022-03-01'...
What is the total number of cases handled by each mediator?
SELECT mediators.name, COUNT(cases.case_id) as total_cases FROM mediators INNER JOIN cases ON mediators.mediator_id = cases.mediator_id GROUP BY mediators.name;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, region TEXT, incident_date DATE); INSERT INTO security_incidents (id, region, incident_date) VALUES (1, 'Asia-Pacific', '2021-03-01'); INSERT INTO security_incidents (id, region, incident_date) VALUES (2, 'Europe', '2021-05-15'); INSERT INTO security_incidents (id, region, incid...
How many security incidents were recorded in the Asia-Pacific region in the past year?
SELECT COUNT(*) FROM security_incidents WHERE region = 'Asia-Pacific' AND incident_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_year INT); INSERT INTO donors (donor_id, donation_amount, donation_year) VALUES (1, 5000.00, 2020), (2, 3000.00, 2019), (3, 7000.00, 2020);
Update the donation amount to $6000 for donor_id 2 in 2020.
UPDATE donors SET donation_amount = 6000 WHERE donor_id = 2 AND donation_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE billing (attorney_id INT, client_id INT, hours_billed INT, billing_rate DECIMAL(5,2));
Find the minimum billing rate for attorneys in 'billing' table
SELECT MIN(billing_rate) FROM billing;
gretelai_synthetic_text_to_sql
CREATE TABLE RouteFares (RouteID int, RouteName varchar(50), FareType varchar(50)); INSERT INTO RouteFares VALUES (1, 'Route A1', 'Standard'); INSERT INTO RouteFares VALUES (1, 'Route A1', 'Discounted'); INSERT INTO RouteFares VALUES (2, 'Route A2', 'Standard'); INSERT INTO RouteFares VALUES (3, 'Route B1', 'Standard')...
List the fare types that are not offered on any route starting with 'A'.
SELECT FareType FROM RouteFares WHERE RouteName NOT LIKE 'A%' EXCEPT SELECT FareType FROM RouteFares WHERE RouteName LIKE 'A%';
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_sales (product_id INT, product_name VARCHAR(255), sale_quantity INT, is_vegan BOOLEAN, country VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO skincare_sales (product_id, product_name, sale_quantity, is_vegan, country) VALUES (1,...
What is the total quantity of vegan skincare products sold in France and Germany?
SELECT SUM(skincare_sales.sale_quantity) FROM skincare_sales INNER JOIN products ON skincare_sales.product_id = products.product_id WHERE skincare_sales.is_vegan = true AND (skincare_sales.country = 'France' OR skincare_sales.country = 'Germany') AND products.category = 'Skincare';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_water_usage (compound_name VARCHAR(50), water_usage FLOAT, liter_of_chemical FLOAT); INSERT INTO chemical_water_usage (compound_name, water_usage, liter_of_chemical) VALUES ('Compound A', 15, 10), ('Compound B', 18, 10), ('Compound C', 12, 10), ('Compound D', 14, 10), ('Compound E', 19, 10), ('Com...
Identify the three chemical compounds with the highest water usage per liter of chemical produced and their corresponding ranks.
SELECT compound_name, water_usage, RANK() OVER (ORDER BY water_usage/liter_of_chemical DESC) as water_usage_rank FROM chemical_water_usage WHERE water_usage_rank <= 3;
gretelai_synthetic_text_to_sql
CREATE VIEW marine_protected_areas_view AS SELECT * FROM marine_protected_areas;
Create a view named 'marine_protected_areas_view' that includes all records from the 'marine_protected_areas' table.
CREATE VIEW marine_protected_areas_view AS SELECT * FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_incidents (incident_id INT, incident_date DATE, region TEXT); INSERT INTO fairness_incidents (incident_id, incident_date, region) VALUES (1, '2022-06-15', 'Oceania'), (2, '2022-07-11', 'Oceania'), (3, '2022-08-01', 'Oceania');
How many algorithmic fairness incidents were reported in Oceania in the last month?
SELECT COUNT(*) FROM fairness_incidents WHERE region = 'Oceania' AND incident_date >= '2022-07-01' AND incident_date < '2022-08-01';
gretelai_synthetic_text_to_sql
CREATE TABLE SolarIrradiance ( Country VARCHAR(255), AnnualIrradiance FLOAT );
Find the top 3 countries with the highest solar irradiance?
SELECT Country, AnnualIrradiance FROM (SELECT Country, AnnualIrradiance, ROW_NUMBER() OVER(ORDER BY AnnualIrradiance DESC) as rank FROM SolarIrradiance) AS subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name TEXT, country TEXT); INSERT INTO cities (city_id, city_name, country) VALUES (1, 'Paris', 'France'); CREATE TABLE tourism_impact (impact_id INT, city_id INT, economic_impact FLOAT); INSERT INTO tourism_impact (impact_id, city_id, economic_impact) VALUES (1, 1, 1000.0), (2, 1,...
What is the local economic impact of tourism in Paris?
SELECT SUM(economic_impact) FROM tourism_impact WHERE city_id = (SELECT city_id FROM cities WHERE city_name = 'Paris');
gretelai_synthetic_text_to_sql
CREATE TABLE Memberships (MemberID INT, MembershipType VARCHAR(20), StartDate DATE, EndDate DATE, MonthlyFee DECIMAL(5,2)); INSERT INTO Memberships (MemberID, MembershipType, StartDate, EndDate, MonthlyFee) VALUES (1, 'Platinum', '2021-12-01', '2022-11-30', 50.00), (2, 'Gold', '2022-01-01', '2022-12-31', 30.00);
What is the total revenue generated from Platinum memberships in the month of January 2022?
SELECT SUM(MonthlyFee) FROM Memberships WHERE MembershipType = 'Platinum' AND StartDate <= '2022-01-31' AND EndDate >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE market_access_3(strategy_name TEXT, drug_name TEXT, approval_year INT, rd_expenditure FLOAT); INSERT INTO market_access_3(strategy_name, drug_name, approval_year, rd_expenditure) VALUES('Strategy1', 'Drug1', 2018, 8000000), ('Strategy2', 'Drug2', 2019, 9000000), ('Strategy3', 'Drug3', 2020, 7000000), ('Str...
How many market access strategies were implemented for drugs approved in each year, and what was the average R&D expenditure for those drugs?
SELECT approval_year, AVG(rd_expenditure) AS avg_rd_expenditure, COUNT(DISTINCT drug_name) AS strategy_count FROM market_access_3 GROUP BY approval_year;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (id INT PRIMARY KEY, species VARCHAR(255), population INT, habitat VARCHAR(255));
How many marine species have a population of less than 1000 in the Pacific Ocean?
SELECT COUNT(*) FROM marine_life WHERE population < 1000 AND habitat LIKE '%Pacific%';
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityPolicies (id INT, policy_name VARCHAR(255), last_updated DATE);
Which policies have been updated in the last month?
SELECT policy_name FROM CybersecurityPolicies WHERE last_updated >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableItems (id INT, item VARCHAR(255), country VARCHAR(255), price DECIMAL(5,2)); INSERT INTO SustainableItems (id, item, country, price) VALUES (1, 'Organic Cotton T-Shirt', 'US', 30.00), (2, 'Recycled Polyester Hoodie', 'Mexico', 60.00), (3, 'Bamboo Viscose Pants', 'US', 50.00), (4, 'Fair Trade Soc...
What is the total number of sustainable fashion items produced in the US and Mexico?
SELECT COUNT(*) FROM SustainableItems WHERE country IN ('US', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), City VARCHAR(50), MaxVisitors INT); INSERT INTO Exhibitions (ExhibitionID, Title, City, MaxVisitors) VALUES (1, 'Art of the 20th Century', 'Paris', 100); INSERT INTO Exhibitions (ExhibitionID, Title, City, MaxVisitors) VALUES (2, 'Impressionist Masters', 'R...
What is the maximum number of visitors for an exhibition in Paris and Rome?
SELECT MAX(Exhibitions.MaxVisitors) FROM Exhibitions WHERE Exhibitions.City IN ('Paris', 'Rome');
gretelai_synthetic_text_to_sql
CREATE TABLE lockout_policies (department VARCHAR(255), max_attempts INT); INSERT INTO lockout_policies (department, max_attempts) VALUES ('IT', 5), ('marketing', 3), ('HR', 7);
What is the maximum number of attempts before a lockout for the marketing department?
SELECT MAX(max_attempts) FROM lockout_policies WHERE department = 'marketing';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (id INT, category VARCHAR(20), year INT); INSERT INTO ArtPieces (id, category, year) VALUES (1, 'Pop Art', 2005), (2, 'Cubism', 1920), (3, 'Pop Art', 2015);
What is the total number of art pieces in the 'Pop Art' category that were created in the 21st century?
SELECT COUNT(*) FROM ArtPieces WHERE category = 'Pop Art' AND year >= 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatActors (id INT, actor_name VARCHAR(255), last_seen DATE); INSERT INTO ThreatActors (id, actor_name, last_seen) VALUES (1, 'APT29', '2022-03-10'), (2, 'Lazarus Group', '2022-03-05'), (3, 'Cozy Bear', '2022-03-01'), (4, 'Fancy Bear', '2022-02-25'), (5, 'WannaCry', '2022-02-20'), (6, 'Carbanak', '2022-0...
List the threat actors that have been active in the last 60 days, ordered by their latest activity.
SELECT actor_name, last_seen, ROW_NUMBER() OVER (ORDER BY last_seen DESC) AS rank FROM ThreatActors WHERE last_seen >= DATEADD(day, -60, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE donor_type (id INT, donor_type VARCHAR(20), total_donation DECIMAL(10,2)); INSERT INTO donor_type (id, donor_type, total_donation) VALUES (1, 'Individual', 15000.00), (2, 'Corporation', 35000.00), (3, 'Foundation', 50000.00);
What was the total amount donated by each donor type in the year 2020?
SELECT donor_type, SUM(total_donation) as total_donation FROM donor_type WHERE YEAR(donation_date) = 2020 GROUP BY donor_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Category TEXT, OutcomeScore INT, StartYear INT, Country TEXT); INSERT INTO Programs (ProgramID, Category, OutcomeScore, StartYear, Country) VALUES (1, 'Arts and Culture', 85, 2018, 'USA'), (2, 'Healthcare', 90, 2019, 'Canada'), (3, 'Arts and Culture', 80, 2018, 'Mexico');
What was the average program outcome score for programs in the Arts and Culture category in 2018, grouped by country?
SELECT Country, AVG(OutcomeScore) as 'Average Outcome Score' FROM Programs WHERE Category = 'Arts and Culture' AND StartYear = 2018 GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, category TEXT, revenue FLOAT); INSERT INTO restaurants (id, name, category, revenue) VALUES (1, 'Restaurant A', 'organic', 50000.00), (2, 'Restaurant B', 'conventional', 45000.00), (3, 'Restaurant C', 'organic', 60000.00);
What is the total revenue generated by restaurants in the "organic" category?
SELECT SUM(revenue) FROM restaurants WHERE category = 'organic';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name TEXT); CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program_id INT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); INSERT INTO volunteers (volunteer_id, volunteer_name, program_id) VALUES...
What is the total number of volunteers for each program in the 'programs' and 'volunteers' tables?
SELECT p.program_name, COUNT(v.volunteer_id) as num_volunteers FROM programs p JOIN volunteers v ON p.program_id = v.program_id GROUP BY p.program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (name VARCHAR(255), country VARCHAR(255), continent VARCHAR(255), sustainable_certification BOOLEAN); INSERT INTO destinations (name, country, continent, sustainable_certification) VALUES ('City A', 'Country A', 'Europe', TRUE), ('City B', 'Country B', 'Europe', FALSE), ('City C', 'Country C',...
Find the number of destinations with sustainable tourism certifications in the European Union
SELECT COUNT(*) FROM destinations WHERE continent = 'Europe' AND sustainable_certification = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT, well_being_score INT); INSERT INTO teams (team_id, team_name) VALUES (1, 'Atlanta Hawks'), (2, 'Boston Celtics'); INSERT INTO athletes (athlete_id, athlete_name, team_id, well_being_scor...
What is the average well-being score for athletes in each team?
SELECT t.team_name, AVG(a.well_being_score) FROM teams t JOIN athletes a ON t.team_id = a.team_id GROUP BY t.team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (project_id INT, region VARCHAR(50), project_cost DECIMAL(10, 2)); INSERT INTO DefenseProjects (project_id, region, project_cost) VALUES (1, 'Y', 1000000.00); INSERT INTO DefenseProjects (project_id, region, project_cost) VALUES (2, 'Y', 2000000.00);
What is the total number of defense projects and their total cost for region Y?
SELECT region, COUNT(*) as total_projects, SUM(project_cost) as total_cost FROM DefenseProjects WHERE region = 'Y' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT, name VARCHAR(255), sustainability_rating FLOAT); INSERT INTO fabrics (id, name, sustainability_rating) VALUES (1, 'Organic Cotton', 4.3), (2, 'Recycled Polyester', 3.8), (3, 'Hemp', 4.5), (4, 'Bamboo', 4.7), (5, 'Linen', 4.4);
Delete the fabric with id 3 from the fabrics table.
DELETE FROM fabrics WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE InvestmentRounds (id INT, founder_id INT, funding_amount INT); INSERT INTO InvestmentRounds VALUES (1, 2, 5000000);
What is the maximum funding amount received by Asian founders in the SaaS sector?
SELECT MAX(InvestmentRounds.funding_amount) FROM InvestmentRounds JOIN Founders ON InvestmentRounds.founder_id = Founders.id WHERE Founders.ethnicity = 'Asian' AND Founders.industry = 'SaaS';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (project_name VARCHAR(50), location VARCHAR(50), start_year INT, budget INT, sector VARCHAR(50)); INSERT INTO climate_projects (project_name, location, start_year, budget, sector) VALUES ('Solar Farm A', 'Australia', 2018, 1000000, 'Solar'), ('Wind Farm B', 'New Zealand', 2019, 1500000, 'W...
What is the average budget for climate projects in Oceania that were started after 2016?
SELECT AVG(budget) FROM climate_projects WHERE location IN ('Oceania') AND start_year > 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Debris (id INT, object_id INT, location VARCHAR(50), detection_date DATE); INSERT INTO Debris (id, object_id, location, detection_date) VALUES (1, 234, 'LEO', '2022-01-01');
How many debris objects were detected in the last 3 months?
SELECT COUNT(object_id) FROM Debris WHERE detection_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (provider_id INT, cultural_competency_score INT); INSERT INTO healthcare_providers (provider_id, cultural_competency_score) VALUES (1, 80), (2, 90), (3, 70), (4, 85), (5, 95);
What is the cultural competency score distribution among health care providers?
SELECT cultural_competency_score, COUNT(provider_id) as num_providers FROM healthcare_providers GROUP BY cultural_competency_score;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_installations (name TEXT, country TEXT, capacity_mw REAL); INSERT INTO solar_installations (name, country, capacity_mw) VALUES ('Solar Farm A', 'Australia', 120), ('Solar Farm B', 'Australia', 150);
How many solar power installations are there in Australia that have a capacity of at least 100 MW?
SELECT COUNT(*) FROM solar_installations WHERE country = 'Australia' AND capacity_mw >= 100;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicSales (SaleID INT, ArtistGender VARCHAR(6), Genre VARCHAR(10), SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID, ArtistGender, Genre, SalesAmount) VALUES (1, 'Female', 'Jazz', 12.99), (2, 'Male', 'Rock', 15.00), (3, 'Female', 'Pop', 19.45);
What is the total revenue generated from digital music sales by female artists?
SELECT SUM(SalesAmount) FROM MusicSales WHERE ArtistGender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists employment (id INT, industry VARCHAR, number_of_employees INT); INSERT INTO employment (id, industry, number_of_employees) VALUES (1, 'manufacturing', 5000), (2, 'technology', 8000), (3, 'healthcare', 7000), (4, 'retail', 6000), (5, 'education', 9000), (6, 'finance', 10000), (7, 'government',...
What is the number of employees in the 'construction' industry?
SELECT SUM(number_of_employees) FROM employment WHERE industry = 'construction';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name VARCHAR(20), assessment_id INT, mental_health_score INT); INSERT INTO students (student_id, name, assessment_id, mental_health_score) VALUES (1, 'James', 1, 75), (1, 'James', 2, 85), (2, 'Emily', 1, 80), (2, 'Emily', 2, 80), (3, 'Michael', 1, 70), (3, 'Michael', 2, 80), (4, '...
How many students have achieved a mental health score improvement of at least 10 points?
SELECT COUNT(*) as students_with_improvement FROM (SELECT student_id, assessment_id, mental_health_score, LAG(mental_health_score) OVER (PARTITION BY student_id ORDER BY assessment_id) as previous_mental_health_score FROM students) as subquery WHERE mental_health_score - previous_mental_health_score >= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Region (region_id INT PRIMARY KEY, region_name VARCHAR(255)); INSERT INTO Region (region_id, region_name) VALUES (1, 'Mediterranean'); CREATE TABLE Vessel (vessel_id INT PRIMARY KEY, vessel_name VARCHAR(255), region_id INT, build_date DATE); CREATE TABLE Safety_Incident (incident_id INT PRIMARY KEY, vessel...
What is the average age of vessels that have had safety incidents in the Mediterranean in 2021?
SELECT AVG(DATEDIFF('day', V.build_date, GETDATE())) FROM Vessel V JOIN Safety_Incident SI ON V.vessel_id = SI.vessel_id WHERE SI.incident_date >= '2021-01-01' AND SI.incident_date < '2022-01-01' AND V.region_id = (SELECT region_id FROM Region WHERE region_name = 'Mediterranean');
gretelai_synthetic_text_to_sql
CREATE TABLE Raw_Materials (raw_material_code TEXT, raw_material_name TEXT, quantity INTEGER); INSERT INTO Raw_Materials (raw_material_code, raw_material_name, quantity) VALUES ('M123', 'Hydrochloric Acid', 500), ('M234', 'Sodium Hydroxide', 800), ('M345', 'Acetic Acid', 300), ('M456', 'B302', 1000);
What are the names and quantities of raw materials used in the production of product 'B302'?
SELECT rm.raw_material_name, rm.quantity FROM Raw_Materials rm WHERE rm.raw_material_code = (SELECT p.raw_material_code FROM Products p WHERE p.product_name = 'B302');
gretelai_synthetic_text_to_sql
CREATE TABLE daily_water_consumption (operation TEXT, date DATE, consumption FLOAT); INSERT INTO daily_water_consumption (operation, date, consumption) VALUES ('Operation A', '2021-01-01', 5000), ('Operation B', '2021-01-01', 6000), ('Operation A', '2021-01-02', 5500), ('Operation B', '2021-01-02', 6500);
What is the daily water consumption of the mining operation with the highest daily water consumption?
SELECT operation, MAX(consumption) FROM daily_water_consumption GROUP BY operation;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty_diversity (id INT, name TEXT, gender TEXT); INSERT INTO faculty_diversity (id, name, gender) VALUES (1, 'Alice', 'Female'), (2, 'Bob', 'Male'), (3, 'Charlie', 'Non-binary');
Update the faculty_diversity table to change the gender of the faculty member with ID 1
UPDATE faculty_diversity SET gender = 'Non-binary' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sessions (session_id INT, type VARCHAR(20), therapist_id INT, patient_id INT, sessions INT); INSERT INTO sessions (session_id, type, therapist_id, patient_id, sessions) VALUES (1, 'CBT', 1, 1, 5); INSERT INTO sessions (session_id, type, therapist_id, patient_id, sessions) VALUES (2, 'CBT', 1, 2, 4); INSERT...
What is the total number of sessions for each type of therapy?
SELECT type, SUM(sessions) FROM sessions GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT PRIMARY KEY, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE nonprofits (id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(50), mission VARCHAR(200)); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 500, '2022-01-01'); IN...
Calculate the total donation amount for each nonprofit
SELECT donations.nonprofit_id, SUM(donation_amount) as total_donations FROM donations GROUP BY donations.nonprofit_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Wastewater_Treatment (id INT, treatment_date DATE, treatment_volume FLOAT); INSERT INTO Wastewater_Treatment (id, treatment_date, treatment_volume) VALUES (1, '2022-01-01', 1500.0), (2, '2022-02-01', 1600.0), (3, '2022-03-01', 1700.0), (4, '2022-04-01', 1800.0), (5, '2022-05-01', 1900.0);
Insert a new record into the Wastewater_Treatment table with the wastewater treatment plant ID 5, a treatment date of '2022-06-01', and a treatment volume of 1800.
INSERT INTO Wastewater_Treatment (id, treatment_date, treatment_volume) VALUES (6, '2022-06-01', 1800.0);
gretelai_synthetic_text_to_sql
CREATE TABLE SocialGoodBudget (Country VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO SocialGoodBudget (Country, Budget) VALUES ('Australia', 1200000.00), ('New Zealand', 1500000.00); CREATE TABLE Countries (Country VARCHAR(50), Continent VARCHAR(50)); INSERT INTO Countries (Country, Continent) VALUES ('Australia', 'O...
What is the minimum budget allocated for technology for social good projects in Oceania countries?
SELECT MIN(SocialGoodBudget.Budget) AS MinBudget FROM SocialGoodBudget INNER JOIN Countries ON SocialGoodBudget.Country = Countries.Country WHERE Countries.Continent = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item_name VARCHAR(50), item_size VARCHAR(10)); INSERT INTO inventory (id, item_name, item_size) VALUES (1, 'T-Shirt', 'XL'); INSERT INTO inventory (id, item_name, item_size) VALUES (2, 'Jeans', '2XL'); INSERT INTO inventory (id, item_name, item_size) VALUES (3, 'Sweater', 'M');
How many unique clothing items are available in size 2XL?
SELECT COUNT(DISTINCT item_name) FROM inventory WHERE item_size = '2XL';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name TEXT); CREATE TABLE sales (sale_id INT, customer_id INT, sale_date DATE, revenue FLOAT);
Calculate the average daily revenue for the top 10 customers in Q1 2022.
SELECT c.customer_name, AVG(s.revenue) AS avg_daily_revenue FROM sales s JOIN customers c ON s.customer_id = c.customer_id WHERE s.sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY c.customer_id, c.customer_name ORDER BY avg_daily_revenue DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE community_initiatives (id INT, name VARCHAR(50), completion_date DATE); INSERT INTO community_initiatives (id, name, completion_date) VALUES (1, 'Community Center Project', '2016-08-15');
Which community development initiatives were completed in the 'rural_infrastructure' schema between 2015 and 2017, inclusive?
SELECT name FROM rural_infrastructure.community_initiatives WHERE completion_date BETWEEN '2015-01-01' AND '2017-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (sensor_id INT, water_level FLOAT, timestamp TIMESTAMP);
List the names of all sensors and their respective last recorded timestamps from the 'sensor_data' table
SELECT sensor_id, MAX(timestamp) as last_recorded_timestamp FROM sensor_data;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id INT, org_name TEXT, region TEXT, avg_donation FLOAT); INSERT INTO organizations (org_id, org_name, region, avg_donation) VALUES (1, 'Habitat for Humanity', 'West', 100.00), (2, 'Red Cross', 'West', 115.00), (3, 'UNICEF', 'East', 200.00);
Which organizations have the lowest average donation amount in the West?
SELECT org_name, AVG(avg_donation) as avg_donation FROM organizations WHERE region = 'West' GROUP BY org_name ORDER BY avg_donation ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSales (SaleID INT, Contractor VARCHAR(255), EquipmentType VARCHAR(255), Quantity INT, SalePrice DECIMAL(5, 2), Country VARCHAR(255), Quarter VARCHAR(10), Year INT); INSERT INTO EquipmentSales (SaleID, Contractor, EquipmentType, Quantity, SalePrice, Country, Quarter, Year) VALUES (1, 'Contractor Q'...
Display all military equipment sales that occurred between Contractor Q and Country E in Q4 of 2018.
SELECT * FROM EquipmentSales WHERE Contractor = 'Contractor Q' AND Country = 'Country E' AND Quarter = 'Q4' AND Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_2020_2(country varchar(20), expenditure int); INSERT INTO rd_2020_2(country, expenditure) VALUES('US', 12000), ('Canada', 9000);
Which countries spent the most on R&D in '2020', excluding the US?
SELECT country, MAX(expenditure) FROM rd_2020_2 WHERE country != 'US' GROUP BY country
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftProductionCost ( id INT, model VARCHAR(255), quantity INT, unit_cost DECIMAL(5,2)); INSERT INTO AircraftProductionCost (id, model, quantity, unit_cost) VALUES (1, 'F-15', 100, 120.50), (2, 'F-16', 200, 145.20), (3, 'F-35', 300, 189.90);
What is the total production cost for each aircraft model?
SELECT model, SUM(quantity * unit_cost) AS total_cost FROM AircraftProductionCost GROUP BY model;
gretelai_synthetic_text_to_sql