context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Expenses (ExpenseID int, Department varchar(50), ExpenseAmount money, ExpenseDate date);
|
Calculate the total expenses for each department in the current year.
|
SELECT Department, SUM(ExpenseAmount) as TotalExpenses FROM Expenses WHERE DATEPART(YEAR, ExpenseDate) = DATEPART(YEAR, GETDATE()) GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Smart_Contracts (contract_name TEXT, transaction_value NUMERIC, num_transactions INTEGER); INSERT INTO Smart_Contracts (contract_name, transaction_value, num_transactions) VALUES ('Contract A', 50, 1), ('Contract A', 75, 2), ('Contract A', 100, 3), ('Contract B', 25, 1), ('Contract B', 30, 2), ('Contract C', 15, 101), ('Contract D', 10, 100);
|
What is the sum of all transaction values for Smart Contracts with more than 100 transactions?
|
SELECT SUM(transaction_value) FROM Smart_Contracts WHERE num_transactions > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, drill_year INT); INSERT INTO wells VALUES (1, 'Well A', 1000, 2016); INSERT INTO wells VALUES (2, 'Well B', 1500, 2017); INSERT INTO wells VALUES (3, 'Well C', 1200, 2018); INSERT INTO wells VALUES (4, 'Well D', 800, 2015);
|
List all the wells that were drilled between 2015 and 2018
|
SELECT well_name, drill_year FROM wells WHERE drill_year BETWEEN 2015 AND 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (id INT, policyholder_id INT, date DATE, amount FLOAT); INSERT INTO claims (id, policyholder_id, date, amount) VALUES (1, 1, '2021-01-01', 100), (2, 1, '2021-02-01', 200), (3, 2, '2021-03-01', 300), (4, 3, '2021-03-01', 500), (5, 3, '2021-04-01', 600);
|
Calculate the total claims processed in each quarter of the year
|
SELECT EXTRACT(QUARTER FROM date) as quarter, SUM(amount) as total_claims FROM claims GROUP BY quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Countries (id INT, name VARCHAR(50)); INSERT INTO Countries (id, name) VALUES (1, 'CountryA'), (2, 'CountryB'); CREATE TABLE SmartCities (id INT, country_id INT, initiative VARCHAR(50), budget FLOAT); INSERT INTO SmartCities (id, country_id, initiative, budget) VALUES (1, 1, 'InitiativeA', 100000), (2, 1, 'InitiativeB', 200000), (3, 2, 'InitiativeC', 300000);
|
What is the average smart city initiative budget per country?
|
SELECT Countries.name, AVG(SmartCities.budget) FROM Countries INNER JOIN SmartCities ON Countries.id = SmartCities.country_id GROUP BY Countries.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessel_cargo_weight (vessel_name VARCHAR(50), cargo_weight INT); INSERT INTO vessel_cargo_weight (vessel_name, cargo_weight) VALUES ('Sea Titan', 12000), ('Harbor Master', 15000), ('Marine Express', 10000), ('Ocean Express', 8000);
|
What is the total cargo weight handled by vessels with 'Express' in their name?
|
SELECT SUM(cargo_weight) FROM vessel_cargo_weight WHERE vessel_name LIKE '%Express%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE neighborhoods (name VARCHAR(255), crime_count INT); INSERT INTO neighborhoods (name, crime_count) VALUES ('Central Park', 25), ('Harlem', 75), ('Brooklyn', 120);
|
Find the top 3 neighborhoods with the highest crime rate?
|
SELECT name, crime_count, RANK() OVER (ORDER BY crime_count DESC) FROM neighborhoods WHERE RANK() <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(20), description TEXT); INSERT INTO vulnerabilities (id, sector, description) VALUES (1, 'financial', 'SQL injection vulnerability');
|
What are the total number of vulnerabilities found in the financial sector?
|
SELECT COUNT(*) FROM vulnerabilities WHERE sector = 'financial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DonationTransactions (TransactionID INT, Amount DECIMAL(10,2), TransactionDate DATE); INSERT INTO DonationTransactions (TransactionID, Amount, TransactionDate) VALUES (1, 5000.00, '2021-07-01'), (2, 1000.00, '2021-07-15');
|
What is the maximum donation amount received in a single transaction in the month of July 2021?
|
SELECT MAX(Amount) FROM DonationTransactions WHERE MONTH(TransactionDate) = 7 AND YEAR(TransactionDate) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE corals (id INT, common_name TEXT, scientific_name TEXT, conservation_status TEXT); INSERT INTO corals (id, common_name, scientific_name, conservation_status) VALUES (1, 'Brain Coral', 'Diploria labyrinthiformis', 'Least Concern'), (2, 'Staghorn Coral', 'Acropora cervicornis', 'Critically Endangered'); CREATE TABLE seagrasses (id INT, common_name TEXT, scientific_name TEXT, conservation_status TEXT); INSERT INTO seagrasses (id, common_name, scientific_name, conservation_status) VALUES (1, 'Turtle Grass', 'Thalassia testudinum', 'Least Concern'), (2, 'Manatee Grass', 'Syringodium filiforme', 'Least Concern');
|
What is the total number of marine species in the database?
|
SELECT COUNT(*) FROM (SELECT * FROM marine_species UNION ALL SELECT * FROM corals UNION ALL SELECT * FROM seagrasses) AS all_species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_patents (id INT, country TEXT, filing_date DATE); INSERT INTO military_patents (id, country, filing_date) VALUES (1, 'Canada', '2016-01-01');
|
What is the total number of military innovation patents filed by 'Canada' in the last 6 years?
|
SELECT COUNT(*) FROM military_patents WHERE country = 'Canada' AND filing_date >= DATE_SUB(CURDATE(), INTERVAL 6 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (id INT, source_country VARCHAR(20), destination_state VARCHAR(20), weight FLOAT, shipping_date DATE); INSERT INTO shipments (id, source_country, destination_state, weight, shipping_date) VALUES (1, 'India', 'New York', 12.6, '2022-02-01'), (2, 'India', 'New York', 19.2, '2022-02-04');
|
What is the total weight of packages shipped from India to New York in the last week?
|
SELECT SUM(weight) FROM shipments WHERE source_country = 'India' AND destination_state = 'New York' AND shipping_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier_sustainability (supplier_id INTEGER, rating NUMERIC(3,1), rating_date DATE); INSERT INTO supplier_sustainability (supplier_id, rating, rating_date) VALUES (1, 8.5, '2023-01-01'), (1, 8.3, '2023-01-02'), (2, 9.2, '2023-01-03');
|
Calculate the 30-day moving average of sustainable sourcing ratings for each supplier.
|
SELECT supplier_id, AVG(rating) OVER (PARTITION BY supplier_id ORDER BY rating_date ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) AS moving_average FROM supplier_sustainability;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE media_publication (publication_id INT, publication_date DATE, content_type VARCHAR(50), views INT); INSERT INTO media_publication (publication_id, publication_date, content_type, views) VALUES (1, '2021-01-01', 'News', 1000), (2, '2021-01-02', 'Entertainment', 2000), (3, '2021-02-01', 'Sports', 1500);
|
How many pieces of news media were published in each month of 2021 in the media_publication table?
|
SELECT EXTRACT(MONTH FROM publication_date) as month, COUNT(content_type) as news_count FROM media_publication WHERE publication_date BETWEEN '2021-01-01' AND '2021-12-31' AND content_type = 'News' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales (id INT, region VARCHAR(20), quarter VARCHAR(10), year INT, revenue FLOAT); INSERT INTO military_sales (id, region, quarter, year, revenue) VALUES (1, 'Asia-Pacific', 'Q1', 2022, 5000000);
|
What was the total revenue for military equipment sales in the Asia-Pacific region in Q1 2022?
|
SELECT SUM(revenue) FROM military_sales WHERE region = 'Asia-Pacific' AND quarter = 'Q1' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(20), price INT, year_built INT); INSERT INTO properties (id, city, price, year_built) VALUES (1, 'Portland', 400000, 1985), (2, 'Portland', 500000, 2000), (3, 'Eugene', 300000, 2010);
|
What is the minimum property price for buildings constructed before 1990 in Portland, OR?
|
SELECT MIN(price) FROM properties WHERE city = 'Portland' AND year_built < 1990;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cities (CityID INT, CityName VARCHAR(100)); INSERT INTO Cities (CityID, CityName) VALUES (1, 'City1'), (2, 'City2'); CREATE TABLE Shelters (ShelterID INT, ShelterName VARCHAR(100), CityID INT); INSERT INTO Shelters (ShelterID, ShelterName, CityID) VALUES (1, 'Shelter1', 1), (2, 'Shelter2', 1), (3, 'Shelter3', 2);
|
What is the number of shelters in each city, ordered by the number of shelters in descending order?
|
SELECT CityName, COUNT(*) as NumberOfShelters FROM Shelters JOIN Cities ON Shelters.CityID = Cities.CityID GROUP BY CityName ORDER BY NumberOfShelters DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artifact_ages (artifact_id INT, site_id INT, artifact_type TEXT, age INT); INSERT INTO artifact_ages (artifact_id, site_id, artifact_type, age) VALUES (1, 1, 'ceramic', 120), (2, 1, 'metal', 150), (3, 1, 'bone', 100), (4, 2, 'ceramic', 180), (5, 2, 'metal', 200), (6, 2, 'bone', 170), (7, 3, 'ceramic', 300), (8, 3, 'metal', 350), (9, 3, 'bone', 320), (10, 4, 'stone', 250), (11, 4, 'stone', 500), (12, 5, 'bone', 110), (13, 5, 'bone', 130), (14, 6, 'bone', 160), (15, 6, 'bone', 190);
|
What is the average age of bone artifacts at Site E and Site F?
|
SELECT AVG(age) FROM artifact_ages WHERE site_id IN (5, 6) AND artifact_type = 'bone';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(255), manufacturer VARCHAR(255)); INSERT INTO drugs (drug_id, drug_name, manufacturer) VALUES (1, 'DrugX', 'ManufacturerA'), (2, 'DrugY', 'ManufacturerB'); CREATE TABLE sales (sale_id INT, drug_id INT, sale_amount DECIMAL(10,2), sale_tax DECIMAL(10,2), country VARCHAR(255), year INT); INSERT INTO sales (sale_id, drug_id, sale_amount, sale_tax, country, year) VALUES (1, 1, 100.00, 15.00, 'Japan', 2022), (2, 1, 200.00, 30.00, 'Australia', 2022), (3, 2, 50.00, 7.50, 'China', 2022);
|
Calculate the total sales for each drug in the APAC region for the year 2022.
|
SELECT d.drug_name, SUM(s.sale_amount + s.sale_tax) as total_sales FROM drugs d JOIN sales s ON d.drug_id = s.drug_id WHERE s.country IN ('Japan', 'Australia', 'China', 'India') AND s.year = 2022 GROUP BY d.drug_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (name VARCHAR(50), department VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO projects (name, department, start_date, end_date) VALUES ('project1', 'research', '2022-01-01', '2022-12-31'), ('project2', 'engineering', '2022-06-01', '2022-11-30');
|
What are the 'start_date' and 'end_date' of 'projects' in the 'research' department?
|
SELECT start_date, end_date FROM projects WHERE department = 'research';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE flu_shots (shot_id INT, patient_name TEXT, shot_date DATE, location TEXT); INSERT INTO flu_shots (shot_id, patient_name, shot_date, location) VALUES (1, 'Jane Doe', '2022-02-15', 'California');
|
What is the number of flu shots administered in rural California this year?
|
SELECT COUNT(*) FROM flu_shots WHERE EXTRACT(YEAR FROM shot_date) = EXTRACT(YEAR FROM CURRENT_DATE) AND location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_followers (user_id INT, followers_count INT);
|
What is the maximum number of followers for any user in the 'user_followers' table?
|
SELECT MAX(followers_count) FROM user_followers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(100), city_name VARCHAR(50), installed_capacity FLOAT); CREATE TABLE cities (city_name VARCHAR(50), state VARCHAR(50), country VARCHAR(50));
|
List the top 5 cities with the highest renewable energy capacity installed.
|
SELECT r.city_name, SUM(r.installed_capacity) AS total_capacity FROM renewable_projects r INNER JOIN cities c ON r.city_name = c.city_name GROUP BY r.city_name ORDER BY total_capacity DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_innovation_metrics (id INT PRIMARY KEY, metric_name VARCHAR(50), value DECIMAL(10, 2), measurement_date DATE);
|
What was the minimum value of the agricultural innovation metrics for the first quarter, by metric name?
|
SELECT metric_name, MIN(value) as min_value FROM agricultural_innovation_metrics WHERE measurement_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND measurement_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY metric_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (id INT, name VARCHAR(50)); CREATE TABLE materials_used (id INT, brand_id INT, material VARCHAR(50), quantity INT); INSERT INTO brands (id, name) VALUES (1, 'Brand A'), (2, 'Brand B'); INSERT INTO materials_used (id, brand_id, material, quantity) VALUES (1, 1, 'Organic Cotton', 100), (2, 1, 'Recycled Polyester', 150), (3, 2, 'Organic Cotton', 200);
|
Insert a new sustainable material for a brand.
|
INSERT INTO materials_used (id, brand_id, material, quantity) VALUES (4, 1, 'Tencel', 125);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, user_id INT, datetime DATETIME, content VARCHAR(255)); INSERT INTO posts (id, user_id, datetime, content) VALUES (1, 123, '2022-01-01 12:00:00', 'Raising awareness for disability today!'), (2, 456, '2022-12-31 23:59:59', 'Sharing my experiences with disability.');
|
What was the daily average number of posts about disability awareness between January 1, 2022 and December 31, 2022?
|
SELECT AVG(count) as avg_daily_posts FROM (SELECT DATE(datetime) as date, COUNT(*) as count FROM posts WHERE content LIKE '%disability awareness%' AND datetime BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY date) as daily_posts;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE campaigns (id INT, campaign_name VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT, region VARCHAR(50)); INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, region) VALUES (17, 'EmpowerMinds', '2022-01-01', '2022-03-31', 25000, 'Asia'); INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, region) VALUES (18, 'MindfulLiving', '2022-04-01', '2022-06-30', 30000, 'Africa'); INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, region) VALUES (19, 'HarmonyHearts', '2022-07-01', '2022-09-30', 15000, 'Europe'); INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, region) VALUES (20, 'BraveSpirits', '2022-10-01', '2022-12-31', 28000, 'Americas');
|
What is the total budget spent on campaigns for each region, ranked by total budget?
|
SELECT region, SUM(budget) as total_budget, RANK() OVER (ORDER BY SUM(budget) DESC) as budget_rank FROM campaigns GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) VALUES (3, 'Sea Otter', 'Kelp Forest', 50.0);
|
How many marine species live at a depth greater than 1000 meters?
|
SELECT COUNT(*) FROM species WHERE depth > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing (id INT, year INT, cost FLOAT);CREATE TABLE SpacecraftComponents (id INT, country TEXT, quantity INT);
|
What is the correlation between spacecraft manufacturing costs and spacecraft component quantities?
|
SELECT CORR(SpacecraftManufacturing.cost, SpacecraftComponents.quantity) FROM SpacecraftManufacturing INNER JOIN SpacecraftComponents ON SpacecraftManufacturing.id = SpacecraftComponents.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE greenhouse_gas_emissions (country VARCHAR(255), co2_emissions DECIMAL(10,2), year INT); INSERT INTO greenhouse_gas_emissions (country, co2_emissions, year) VALUES ('China', 10435.3, 2019), ('USA', 5416.1, 2019), ('India', 2654.5, 2019), ('Indonesia', 643.2, 2019), ('Russia', 1530.6, 2019);
|
Find the top 3 countries with the highest CO2 emissions in the 'greenhouse_gas_emissions' table.
|
SELECT country, co2_emissions FROM (SELECT country, co2_emissions, ROW_NUMBER() OVER (ORDER BY co2_emissions DESC) as rank FROM greenhouse_gas_emissions WHERE year = 2019) AS subquery WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tours (tour_id INT, name TEXT, type TEXT, duration INT); INSERT INTO tours (tour_id, name, type, duration) VALUES (1, 'NZ Adventure', 'Adventure', 7), (2, 'NZ Sightseeing', 'Sightseeing', 5);
|
What is the maximum tour duration for adventure tours in New Zealand?
|
SELECT MAX(duration) FROM tours WHERE type = 'Adventure' AND country = 'New Zealand';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy(year INT, state VARCHAR(255), initiatives INT); INSERT INTO circular_economy VALUES (2021, 'California', 4), (2022, 'California', 0);
|
Insert new records of circular economy initiatives for 2022 in California.
|
INSERT INTO circular_economy (year, state, initiatives) VALUES (2022, 'California', 5);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AccessToJustice (case_id INT, case_type VARCHAR(10)); INSERT INTO AccessToJustice (case_id, case_type) VALUES (1, 'civil'), (2, 'criminal'), (3, 'family'), (4, 'constitutional'), (5, 'federal'), (6, 'state');
|
List the 'case_id' and 'case_type' for cases in the 'AccessToJustice' table where the 'case_type' starts with 'c' or 'f'
|
SELECT case_id, case_type FROM AccessToJustice WHERE case_type LIKE 'c%' OR case_type LIKE 'f%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production (year INT, country VARCHAR(255), region VARCHAR(255), volume FLOAT);
|
Find total timber production in Oceania by year
|
SELECT region, SUM(volume) FROM timber_production WHERE region = 'Oceania' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_water_consumption (id INT, city VARCHAR(50), yearly_consumption FLOAT, year INT); INSERT INTO city_water_consumption (id, city, yearly_consumption, year) VALUES (1, 'New York', 1440000000, 2020), (2, 'Los Angeles', 720000000, 2020), (3, 'Chicago', 960000000, 2020);
|
Identify the top 3 cities with the highest water consumption in the last 12 months.
|
SELECT city, yearly_consumption FROM (SELECT city, yearly_consumption, ROW_NUMBER() OVER (ORDER BY yearly_consumption DESC) as rn FROM city_water_consumption WHERE year = 2020) t WHERE rn <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies(id INT, name VARCHAR(50), industry VARCHAR(20), num_patents INT); INSERT INTO companies VALUES (1, 'Alpha', 'Healthcare', 5); INSERT INTO companies VALUES (2, 'Beta', 'Finance', 3); INSERT INTO companies VALUES (3, 'Gamma', 'Healthcare', 7);
|
What is the number of patents filed by companies in the healthcare industry?
|
SELECT COUNT(companies.num_patents) FROM companies WHERE companies.industry = 'Healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threats (threat_id INT, type VARCHAR(255), description VARCHAR(255), severity VARCHAR(255));
|
Delete a record with threat_id 1 from the threats table
|
DELETE FROM threats WHERE threat_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeartRate (user_id INT, heart_rate INT, measurement_date DATE); INSERT INTO HeartRate (user_id, heart_rate, measurement_date) VALUES (1, 75, '2021-04-01'), (2, 85, '2021-04-02'), (3, 95, '2021-04-03'), (4, 65, '2021-04-04'), (5, 55, '2021-04-05');
|
Find the average heart rate per user for the month of April 2021.
|
SELECT user_id, AVG(heart_rate) FROM HeartRate WHERE measurement_date BETWEEN '2021-04-01' AND '2021-04-30' GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(50), max_speed DECIMAL(5,2), current_speed DECIMAL(5,2)); INSERT INTO vessels (id, name, type, max_speed, current_speed) VALUES (1, 'VesselA', 'Cargo', 20.5, 15.2), (2, 'VesselB', 'Tanker', 25.3, 22.4), (3, 'VesselC', 'Passenger', 30.6, 28.1); CREATE TABLE voyages (id INT, vessel_id INT, region VARCHAR(50), distance DECIMAL(5,2), duration DECIMAL(5,2)); INSERT INTO voyages (id, vessel_id, region, distance, duration) VALUES (1, 1, 'Atlantic', 500, 100), (2, 1, 'Pacific', 700, 140), (3, 2, 'Atlantic', 600, 120), (4, 3, 'Pacific', 800, 160);
|
What is the average speed of vessels that traveled to the Pacific region?
|
SELECT AVG(distance/duration) as avg_speed FROM voyages WHERE region = 'Pacific' AND vessel_id IN (SELECT id FROM vessels);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_consumption (country VARCHAR(255), material VARCHAR(255), production_type VARCHAR(255), water_consumption INT); INSERT INTO water_consumption (country, material, production_type, water_consumption) VALUES ('United States', 'cotton', 'farming', 2500); INSERT INTO water_consumption (country, material, production_type, water_consumption) VALUES ('United States', 'cotton', 'processing', 3000);
|
What is the average water consumption for cotton farming in the United States?
|
SELECT AVG(water_consumption) FROM water_consumption WHERE country = 'United States' AND material = 'cotton' AND production_type = 'farming';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (country VARCHAR(50), year INT, budget INT); INSERT INTO military_innovation (country, year, budget) VALUES ('Nigeria', 2020, 7000000), ('South Africa', 2020, 6000000), ('Egypt', 2020, 5000000);
|
What was the minimum budget allocated for military innovation by African countries in 2020?
|
SELECT MIN(budget) FROM military_innovation WHERE country IN ('Nigeria', 'South Africa', 'Egypt') AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, initiative_name VARCHAR(50), budget FLOAT); INSERT INTO community_development (id, initiative_name, budget) VALUES (1, 'Youth Center', 300000.00), (2, 'Senior Center', 150000.00);
|
Find the names of community development initiatives with a budget greater than $200,000 in the 'community_development' table.
|
SELECT initiative_name FROM community_development WHERE budget > 200000.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), region VARCHAR(50), year_established INT); INSERT INTO marine_protected_areas (id, name, region, year_established) VALUES (1, 'Arctic Protected Area 1', 'Arctic', 2016), (2, 'Arctic Protected Area 2', 'Arctic', 2019), (3, 'Arctic Protected Area 3', 'Arctic', 2012);
|
What is the total number of marine protected areas in the Arctic region that have been established since 2015?
|
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Arctic' AND year_established >= 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Obesity (Country TEXT, Obese INT, Total INT); INSERT INTO Obesity (Country, Obese, Total) VALUES ('Mexico', 2500, 5000), ('Mexico', 3000, 5000);
|
What is the obesity rate in Mexico?
|
SELECT (Obese / Total) * 100 FROM Obesity WHERE Country = 'Mexico';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy_asia (country VARCHAR(50), year INT, events INT); INSERT INTO defense_diplomacy_asia (country, year, events) VALUES ('China', 2019, 7), ('India', 2019, 6), ('Japan', 2019, 5), ('South Korea', 2019, 4), ('Indonesia', 2019, 3), ('Vietnam', 2019, 2), ('Malaysia', 2019, 1);
|
How many defense diplomacy events occurred for Asian countries in 2019?
|
SELECT COUNT(events) total_events FROM defense_diplomacy_asia WHERE country IN ('China', 'India', 'Japan', 'South Korea', 'Indonesia', 'Vietnam', 'Malaysia') AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Region VARCHAR(50), TrainingDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Region, TrainingDate) VALUES (1, 'John', 'Doe', 'East', '2020-01-01'), (2, 'Jane', 'Doe', 'West', '2019-06-15'), (3, 'Mike', 'Johnson', 'North', '2021-03-20');
|
How many employees have participated in training programs in the last 3 years, broken down by region?
|
SELECT Region, COUNT(*) AS TrainingCount FROM Employees WHERE TrainingDate >= DATEADD(year, -3, GETDATE()) GROUP BY Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions_mwh (country VARCHAR(20), co2_emissions FLOAT, electricity_mwh FLOAT); INSERT INTO co2_emissions_mwh (country, co2_emissions, electricity_mwh) VALUES ('United States', 0.5, 4000), ('Japan', 0.3, 3000), ('United States', 0.6, 4500);
|
What is the average CO2 emissions per MWh for electricity production in each G20 country?
|
SELECT country, AVG(co2_emissions/electricity_mwh) FROM co2_emissions_mwh WHERE country IN (SELECT country FROM g20_countries) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW production_figures AS SELECT well_id, production_rate FROM wells WHERE region = 'Gulf of Mexico';
|
List all the production figures for the Gulf of Mexico
|
SELECT * FROM production_figures;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sensors (sensor_id INT, sensor_type VARCHAR(255), country VARCHAR(255)); INSERT INTO sensors (sensor_id, sensor_type, country) VALUES (1, 'temperature', 'US'), (2, 'humidity', 'Canada'), (3, 'moisture', 'UK'), (4, 'light', 'Australia');
|
Delete all records in the IoT sensor table with a country of 'UK'
|
DELETE FROM sensors WHERE sensors.country = 'UK';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (hospital_id INT, name VARCHAR(50), region VARCHAR(20), cultural_competency_score INT); INSERT INTO hospitals (hospital_id, name, region, cultural_competency_score) VALUES (1, 'Hospital A', 'Midwest', 85); INSERT INTO hospitals (hospital_id, name, region, cultural_competency_score) VALUES (2, 'Hospital B', 'Midwest', 92);
|
What is the cultural competency score for each hospital in the Midwest region?
|
SELECT region, AVG(cultural_competency_score) as avg_score FROM hospitals WHERE region = 'Midwest' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TreatmentOutcomes (TreatmentID int, ConditionID int, Gender varchar(10), Completed int); INSERT INTO TreatmentOutcomes (TreatmentID, ConditionID, Gender, Completed) VALUES (1, 1, 'Male', 1), (2, 1, 'Female', 0), (3, 2, 'Male', 1);
|
What is the percentage of male and female patients that have completed their treatment for each condition?
|
SELECT Conditions.Condition, Gender, SUM(TreatmentOutcomes.Completed)*100.0/COUNT(TreatmentOutcomes.TreatmentID) AS Percentage FROM TreatmentOutcomes JOIN Conditions ON TreatmentOutcomes.ConditionID = Conditions.ConditionID GROUP BY Conditions.Condition, Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite_Imagery (id INT, farm_id INT, date DATE, moisture INT, temperature INT); INSERT INTO Satellite_Imagery (id, farm_id, date, moisture, temperature) VALUES (1, 1, '2022-05-01', 60, 20); INSERT INTO Satellite_Imagery (id, farm_id, date, moisture, temperature) VALUES (2, 2, '2022-05-05', 70, 25); INSERT INTO Satellite_Imagery (id, farm_id, date, moisture, temperature) VALUES (3, 3, '2022-05-03', 75, 15);
|
What is the minimum temperature recorded for farms in Canada?
|
SELECT MIN(temperature) FROM Satellite_Imagery WHERE farm_id IN (SELECT id FROM Farmers WHERE country = 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_transportation_trips (city VARCHAR(30), country VARCHAR(30), trips INT, year INT); INSERT INTO public_transportation_trips VALUES ('London', 'UK', 15000000, 2018); INSERT INTO public_transportation_trips VALUES ('London', 'UK', 16000000, 2019); INSERT INTO public_transportation_trips VALUES ('London', 'UK', 12000000, 2020);
|
What is the total number of public transportation trips in London, UK between 2018 and 2020?
|
SELECT SUM(trips) FROM public_transportation_trips WHERE city = 'London' AND country = 'UK' AND year BETWEEN 2018 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (id INT, type TEXT, region TEXT); INSERT INTO subscribers (id, type, region) VALUES (1, 'mobile', 'urban'); INSERT INTO subscribers (id, type, region) VALUES (2, 'broadband', 'urban'); INSERT INTO subscribers (id, type, region) VALUES (3, 'mobile', 'rural');
|
How many mobile subscribers are there in the 'urban' region?
|
SELECT COUNT(*) FROM subscribers WHERE type = 'mobile' AND region = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tour_revenue_by_region(revenue_id INT, tour_type TEXT, region TEXT, revenue DECIMAL);
|
What is the total revenue for each tour type, broken down by region?
|
SELECT tour_type, region, SUM(revenue) FROM tour_revenue_by_region GROUP BY tour_type, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue(restaurant_id INT, revenue DECIMAL(10,2), revenue_date DATE);
|
What is the total revenue for the month of January 2022 across all restaurants?
|
SELECT SUM(revenue) FROM restaurant_revenue WHERE revenue_date BETWEEN '2022-01-01' AND '2022-01-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (song_id INT, release_date DATE, song_title TEXT, genre TEXT); INSERT INTO songs VALUES (1, '2012-01-01', 'Winter Song', 'Jazz'), (2, '2011-02-14', 'Rolling in the Deep', 'R&B'), (3, '2010-05-23', 'Empire State of Mind', 'Rap'), (4, '2012-12-31', 'Christmas Song', 'Jazz'), (5, '2011-06-20', 'Tears Always Win', 'R&B'); CREATE TABLE albums (album_id INT, album_title TEXT, release_date DATE); INSERT INTO albums VALUES (1, 'Winter Collection', '2012-01-01'), (2, 'Rolling in the Deep', '2011-02-14'), (3, 'Empire State of Mind', '2010-05-23'), (4, 'Jazz Christmas', '2012-12-01'), (5, 'Tears and Rain', '2011-06-20');
|
Show all Jazz songs released in 2012.
|
SELECT song_title FROM songs INNER JOIN albums ON songs.release_date = albums.release_date WHERE songs.genre = 'Jazz';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (project_id INT, project_name VARCHAR(100), state VARCHAR(100), project_type VARCHAR(100), installed_capacity FLOAT);
|
What is the maximum installed capacity (in MW) for a solar energy project in the state of Arizona?
|
SELECT MAX(installed_capacity) FROM Projects WHERE state = 'Arizona' AND project_type = 'Solar';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EmployeeData (EmployeeID int, Name varchar(30), Ethnicity varchar(20), JobTitle varchar(20), Department varchar(20), TrainingComplete int); INSERT INTO EmployeeData (EmployeeID, Name, Ethnicity, JobTitle, Department, TrainingComplete) VALUES (1, 'John Doe', 'Caucasian', 'Marketing Manager', 'Marketing', 1), (2, 'Jane Smith', 'African American', 'Marketing Coordinator', 'Marketing', 0), (3, 'Jim Brown', 'Hispanic', 'Software Engineer', 'IT', 0);
|
List the names, ethnicities, and job titles for employees in the IT department who have not completed diversity and inclusion training.
|
SELECT Name, Ethnicity, JobTitle FROM EmployeeData WHERE Department = 'IT' AND TrainingComplete = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (state VARCHAR(20), year INT, material VARCHAR(20), recycling_rate DECIMAL(3,2)); INSERT INTO recycling_rates (state, year, material, recycling_rate) VALUES ('New York', 2020, 'Glass', 0.25), ('New York', 2020, 'Paper', 0.50);
|
Update the recycling rate for glass in the state of New York in 2020.
|
UPDATE recycling_rates SET recycling_rate = 0.30 WHERE state = 'New York' AND year = 2020 AND material = 'Glass';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_projects (id INT, name VARCHAR(255), capacity FLOAT, location VARCHAR(255));
|
What's the total installed capacity of wind energy projects?
|
SELECT SUM(capacity) FROM wind_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, sector TEXT, ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'Tesla', 'Energy', 85.0), (2, 'Microsoft', 'Technology', 80.5), (3, 'IBM', 'Technology', 78.2), (4, 'Siemens Energy', 'Energy', 76.7), (5, 'Vestas Wind Systems', 'Energy', 82.1);
|
Who are the top 3 companies with the highest ESG scores in the energy sector?
|
SELECT name, ESG_score FROM companies WHERE sector = 'Energy' ORDER BY ESG_score DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Storm_Water_Management (project_id INT, project_name VARCHAR(50), location VARCHAR(50), total_cost FLOAT); INSERT INTO Storm_Water_Management (project_id, project_name, location, total_cost) VALUES (1, 'Detention Basin Construction', 'Floodplain', 3000000.00), (2, 'Wetlands Restoration', 'Coastal Area', 1500000.00), (3, 'Stream Bank Stabilization', 'Rural Area', 750000.00);
|
What is the minimum total cost of a project in the 'Storm_Water_Management' table?
|
SELECT MIN(total_cost) FROM Storm_Water_Management;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_sales (equipment_id INT, contractor_id INT, sale_value FLOAT); INSERT INTO equipment_sales (equipment_id, contractor_id, sale_value) VALUES (1, 1, 12000000), (2, 2, 15000000), (3, 3, 18000000), (4, 1, 10000000), (5, 2, 13000000), (6, 3, 16000000);
|
Who are the top 3 defense contractors by the number of military equipment sales?
|
SELECT d.contractor_name, COUNT(*) as sales_count FROM defense_contractors d INNER JOIN equipment_sales e ON d.contractor_id = e.contractor_id GROUP BY d.contractor_name ORDER BY sales_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (Name TEXT, Nationality TEXT);
|
Insert a new astronaut record for Han Xu from China
|
INSERT INTO Astronauts (Name, Nationality) VALUES ('Han Xu', 'China');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE football_matches (match_id INT, home_team VARCHAR(50), away_team VARCHAR(50), home_team_score INT, away_team_score INT, match_date DATE);
|
Insert new records for a football match in the 'football_matches' table between Barcelona and Real Madrid?
|
INSERT INTO football_matches (match_id, home_team, away_team, home_team_score, away_team_score, match_date) VALUES (1, 'Barcelona', 'Real Madrid', 3, 2, '2023-06-10');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Digital_Exhibitions_Visitors (visitor_id INT, country VARCHAR(20), num_exhibitions INT);
|
What is the average number of digital exhibitions visited per visitor in Spain?
|
SELECT AVG(num_exhibitions) FROM Digital_Exhibitions_Visitors WHERE country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_data (customer_id INT, age INT, income FLOAT, location_category VARCHAR(50)); INSERT INTO customer_data VALUES (1001, 30, 75000.00, 'Urban'), (1002, 40, 100000.00, 'Suburban'), (1003, 50, 125000.00, 'Rural'), (1004, 60, 150000.00, 'Urban');
|
What is the average income of customers in each location category?
|
SELECT location_category, AVG(income) AS avg_income FROM customer_data GROUP BY location_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, state VARCHAR(20), size INT, co_owned BOOLEAN); INSERT INTO properties (id, state, size, co_owned) VALUES (1, 'New York', 1200, TRUE), (2, 'New York', 1500, FALSE), (3, 'New York', 1800, TRUE);
|
What is the average square footage of co-owned properties in the state of New York?
|
SELECT AVG(size) FROM properties WHERE state = 'New York' AND co_owned = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_services (service_id INT, service TEXT, city TEXT); INSERT INTO public_services (service_id, service, city) VALUES (1, 'Police Station', 'Los Angeles'), (2, 'Fire Station', 'Los Angeles'), (3, 'Police Station', 'New York'), (4, 'Hospital', 'Los Angeles');
|
What is the total number of police stations in the city of Los Angeles?
|
SELECT COUNT(*) FROM public_services WHERE service = 'Police Station' AND city = 'Los Angeles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessel_types (id INT, type TEXT); INSERT INTO vessel_types (id, type) VALUES (1, 'Container'), (2, 'Tanker'), (3, 'Bulk Carrier');
|
Create a table for vessel types with corresponding IDs
|
SELECT * FROM vessel_types;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE luxury_properties (property_id INT, market_value INT); INSERT INTO luxury_properties VALUES (1, 1000000), (2, 1500000), (3, 800000)
|
Display property_ids and 'market_value' from the luxury_properties table where 'market_value' > 1000000.
|
SELECT property_id, market_value FROM luxury_properties WHERE market_value > 1000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE testing_results (id INT PRIMARY KEY, vehicle_id INT, safety_rating INT, crash_test_date DATE, is_electric BOOLEAN);
|
What is the minimum safety rating for electric vehicles in the 'testing_results' table?
|
SELECT MIN(safety_rating) FROM testing_results WHERE is_electric = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_records (id INT, company_id INT, funding_amount INT, funding_date DATE); INSERT INTO funding_records (id, company_id, funding_amount, funding_date) VALUES (1, 1, 500000, '2016-01-01'); INSERT INTO funding_records (id, company_id, funding_amount, funding_date) VALUES (2, 2, 300000, '2017-01-01');
|
What is the maximum funding amount for startups founded in 2018?
|
SELECT MAX(funding_amount) FROM funding_records JOIN companies ON funding_records.company_id = companies.id WHERE companies.founding_year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ad_stats(ad_id INT, ad_category TEXT, ad_spend DECIMAL(10,2));
|
What is the minimum ad spend for ads with the category 'solarpower' in the 'ad_stats' table and how many ads fall into this category?
|
SELECT MIN(ad_spend) AS min_ad_spend, COUNT(*) AS ad_count FROM ad_stats WHERE ad_category = 'solarpower';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gas_consumption (country VARCHAR(50), consumption_year INT, gas_consumption FLOAT); INSERT INTO gas_consumption (country, consumption_year, gas_consumption) VALUES ('India', 2020, 20000), ('India', 2019, 18000), ('China', 2020, 30000), ('China', 2019, 28000), ('Japan', 2020, 15000), ('Japan', 2019, 13000);
|
Calculate the total gas consumption for India in 2020
|
SELECT gas_consumption FROM gas_consumption WHERE country = 'India' AND consumption_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, region TEXT, donation_amount FLOAT); INSERT INTO donations (id, donor_id, region, donation_amount) VALUES (1, 1, 'Asia', 5000.00), (2, 2, 'Europe', 3000.00), (3, 3, 'Americas', 2000.00), (4, 4, 'Asia', 4000.00), (5, 5, 'Africa', 1000.00);
|
What's the average donation amount for each region?
|
SELECT region, AVG(donation_amount) FROM donations GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species VARCHAR(50), ocean VARCHAR(50), conservation_status VARCHAR(50)); INSERT INTO marine_species (id, species, ocean, conservation_status) VALUES (1, 'Orca', 'Pacific', 'Least Concern'), (2, 'Coral', 'Atlantic', 'Critically Endangered');
|
What is the total number of marine species found in the Pacific and Atlantic oceans, grouped by their conservation status (critically endangered, endangered, vulnerable, or least concern)?
|
SELECT ocean, conservation_status, COUNT(*) FROM marine_species WHERE ocean IN ('Pacific', 'Atlantic') GROUP BY ocean, conservation_status;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(50), Classification VARCHAR(50), AverageSpeed DECIMAL(5,2)); INSERT INTO Vessels (VesselID, VesselName, Classification, AverageSpeed) VALUES (1, 'SeaLion', 'HighSpeed', 30.5), (2, 'OceanRunner', 'MedSpeed', 25.2), (3, 'HarborMaster', 'LowSpeed', 12.4);
|
What is the average speed of vessels with the 'HighSpeed' classification?
|
SELECT AVG(AverageSpeed) FROM Vessels WHERE Classification = 'HighSpeed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data (year INT, company_name TEXT, element TEXT, quantity INT); INSERT INTO production_data (year, company_name, element, quantity) VALUES (2018, 'RST Mining', 'Samarium', 1200), (2019, 'STW Mining', 'Samarium', 1500), (2020, 'TUV Mining', 'Samarium', 1000);
|
Delete all records related to Samarium production from the production_data table?
|
DELETE FROM production_data WHERE element = 'Samarium';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerHours (PlayerID INT, Age INT, Hours DECIMAL(3, 2)); INSERT INTO PlayerHours (PlayerID, Age, Hours) VALUES (1, 35, 5.5);
|
What is the total number of hours played per day by players who are over 30 years old?
|
SELECT SUM(Hours) FROM PlayerHours WHERE Age > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE state_budget (state VARCHAR(20), sector VARCHAR(20), allocation INT); INSERT INTO state_budget (state, sector, allocation) VALUES ('New York', 'Education', 12000), ('New York', 'Healthcare', 15000), ('California', 'Education', 10000), ('California', 'Healthcare', 18000);
|
What is the maximum budget allocation for healthcare in the state of California?
|
SELECT MAX(allocation) FROM state_budget WHERE state = 'California' AND sector = 'Healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (policyholder_id INT, gender VARCHAR(10)); INSERT INTO policyholders (policyholder_id, gender) VALUES (1, 'Male'), (2, 'Female'); CREATE TABLE policies (policy_id INT, policyholder_id INT); INSERT INTO policies (policy_id, policyholder_id) VALUES (1001, 1), (1002, 2);
|
What is the total number of policies issued by gender?
|
SELECT p.gender, COUNT(DISTINCT pol.policy_id) as total_policies FROM policyholders p JOIN policies pol ON p.policyholder_id = pol.policyholder_id GROUP BY p.gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Mobile_Subscribers (Subscriber_ID INT, Subscription_Type VARCHAR(20), Data_Allowance FLOAT, Monthly_Charge FLOAT); INSERT INTO Mobile_Subscribers (Subscriber_ID, Subscription_Type, Data_Allowance, Monthly_Charge) VALUES (1, 'Postpaid', 5.0, 60.0), (2, 'Prepaid', 3.0, 40.0); CREATE TABLE Broadband_Subscribers (Subscriber_ID INT, Subscription_Type VARCHAR(20), Download_Speed FLOAT, Monthly_Charge FLOAT); INSERT INTO Broadband_Subscribers (Subscriber_ID, Subscription_Type, Download_Speed, Monthly_Charge) VALUES (1, 'Fiber', 500.0, 80.0), (2, 'Cable', 300.0, 60.0);
|
Generate a report on the total revenue for each subscription type, considering both mobile and broadband subscribers.
|
SELECT COALESCE(MS.Subscription_Type, BS.Subscription_Type) as Subscription_Type, SUM(COALESCE(MS.Monthly_Charge, BS.Monthly_Charge)) as Total_Revenue FROM Mobile_Subscribers MS FULL OUTER JOIN Broadband_Subscribers BS ON MS.Subscription_Type = BS.Subscription_Type GROUP BY MS.Subscription_Type, BS.Subscription_Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_facilities (name TEXT, state TEXT, category TEXT, budget_allocation INT); INSERT INTO public_facilities (name, state, category, budget_allocation) VALUES ('Facility A', 'Texas', 'City Park', 250000), ('Facility B', 'Texas', 'Community Center', 300000);
|
What is the total budget allocation for public facilities in the state of Texas, excluding city parks?
|
SELECT SUM(budget_allocation) FROM public_facilities WHERE state = 'Texas' AND category <> 'City Park';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (post_id INT, post_text TEXT, post_likes INT, post_date DATE);CREATE TABLE hashtags (hashtag_id INT, hashtag_name TEXT, post_id INT);
|
What are the top 10 most liked posts containing the hashtag #food, in the last week?
|
SELECT p.post_text, p.post_likes FROM posts p JOIN hashtags h ON p.post_id = h.post_id WHERE h.hashtag_name = '#food' AND p.post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) ORDER BY p.post_likes DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_incidents (incident_id INT, incident_type VARCHAR(50), report_date DATE, region VARCHAR(50));
|
What is the maximum number of threat intelligence incidents reported in the Middle East in the past year?
|
SELECT MAX(incident_id) FROM threat_incidents WHERE region = 'Middle East' AND report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, name VARCHAR(100), subscribed_date DATE); INSERT INTO mobile_subscribers (subscriber_id, name, subscribed_date) VALUES (1, 'John Doe', '2022-01-01'), (2, 'Jane Smith', '2022-03-15'), (3, 'Alice Johnson', '2022-06-30'), (4, 'Bob Brown', '2022-09-15'), (5, 'Charlie Davis', '2022-12-31'); CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(100), subscribed_date DATE); INSERT INTO broadband_subscribers (subscriber_id, name, subscribed_date) VALUES (1, 'John Doe', '2022-02-01'), (2, 'Jane Smith', '2022-04-15'), (3, 'Alice Johnson', '2022-07-30'), (4, 'Bob Brown', '2022-10-15'), (5, 'Charlie Davis', '2023-01-31');
|
What is the total number of mobile and broadband subscribers?
|
SELECT COUNT(*) FROM mobile_subscribers; SELECT COUNT(*) FROM broadband_subscribers; SELECT SUM(mobile_count + broadband_count) FROM (SELECT COUNT(*) AS mobile_count FROM mobile_subscribers) AS mobile_counts CROSS JOIN (SELECT COUNT(*) AS broadband_count FROM broadband_subscribers) AS broadband_counts;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fans (id INT, city VARCHAR(50), age INT, gender VARCHAR(10), event_id INT); INSERT INTO fans (id, city, age, gender, event_id) VALUES (1, 'New York', 25, 'Female', 1); INSERT INTO fans (id, city, age, gender, event_id) VALUES (2, 'Los Angeles', 30, 'Male', 2);
|
Find the number of female fans from each city who purchased tickets to any event.
|
SELECT city, gender, COUNT(DISTINCT event_id) AS num_events FROM fans WHERE gender = 'Female' GROUP BY city, gender;
|
gretelai_synthetic_text_to_sql
|
safety_inspections(inspection_id, vessel_id, inspection_date)
|
Add a new safety inspection for vessel MV-V001 on 2023-01-05
|
INSERT INTO safety_inspections (inspection_id, vessel_id, inspection_date) VALUES (1001, 'MV-V001', '2023-01-05');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MediaEthicsViolations (UserID INT, Violation VARCHAR(255), Age INT); CREATE TABLE AudienceDemographics (UserID INT, Age INT, Gender VARCHAR(255)); INSERT INTO MediaEthicsViolations (UserID, Violation, Age) VALUES (1, 'plagiarism', 35), (2, 'fabrication', 45), (3, 'conflict of interest', 50); INSERT INTO AudienceDemographics (UserID, Age, Gender) VALUES (1, 35, 'female'), (2, 45, 'non-binary'), (4, 25, 'male');
|
Identify the number of female and non-binary individuals who have committed media ethics violations and their respective age ranges in the "MediaEthics" and "AudienceDemographics" databases.
|
SELECT CASE WHEN AudienceDemographics.Gender = 'female' THEN 'Female' ELSE 'Non-binary' END AS Gender, FLOOR(MediaEthicsViolations.Age/10)*10 AS AgeRange, COUNT(DISTINCT MediaEthicsViolations.UserID) AS Count FROM MediaEthicsViolations INNER JOIN AudienceDemographics ON MediaEthicsViolations.UserID = AudienceDemographics.UserID WHERE AudienceDemographics.Gender IN ('female', 'non-binary') GROUP BY Gender, AgeRange;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA fitness; USE fitness; CREATE TABLE members (member_id INT PRIMARY KEY, name VARCHAR(50), age INT, membership VARCHAR(20)); INSERT INTO members (member_id, name, age, membership) VALUES (1, 'John Doe', 30, 'gold'), (2, 'Jane Smith', 40, 'silver'), (3, 'Mike Johnson', 50, 'platinum'), (4, 'Alice Davis', 35, NULL);
|
How many members have a membership?
|
SELECT COUNT(*) FROM members WHERE membership IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), manufacturer VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO military_equipment (id, name, type, manufacturer, year, country) VALUES (1, 'M1 Abrams', 'Tank', 'General Dynamics', 1980, 'USA'), (2, 'F-15 Eagle', 'Fighter', 'McDonnell Douglas', 1976, 'USA');
|
Count the number of military equipment items in 'military_equipment' table
|
SELECT COUNT(*) FROM military_equipment;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE travel_warnings (id INT, country VARCHAR(50), warnings VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO travel_warnings (id, country, warnings, start_date, end_date) VALUES (1, 'Brazil', 'Political instability', '2022-01-01', '2022-12-31'); INSERT INTO travel_warnings (id, country, warnings, start_date, end_date) VALUES (2, 'Argentina', 'Economic crisis', '2022-03-01', '2022-06-30');
|
Display the travel warnings for South America.
|
SELECT country, warnings FROM travel_warnings WHERE country IN ('Brazil', 'Argentina');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, attorney_name VARCHAR(255), win_status BOOLEAN, case_date DATE); INSERT INTO cases (case_id, attorney_name, win_status, case_date) VALUES (1, 'Smith', true, '2019-01-01'), (2, 'Jones', false, '2020-05-15'), (3, 'Jones', true, '2021-07-20');
|
How many cases were won by attorney Jones in the last 3 years?
|
SELECT COUNT(*) FROM cases WHERE attorney_name = 'Jones' AND win_status = true AND case_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HiringDates (EmployeeID INT, HireDate DATE); INSERT INTO HiringDates (EmployeeID, HireDate) VALUES (1, '2021-03-15'), (2, '2021-06-30'), (3, '2021-11-10'), (4, '2021-02-28'), (5, '2021-05-12'), (6, '2021-07-04'); CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10)); INSERT INTO Employees (EmployeeID, Gender) VALUES (1, 'Non-binary'), (2, 'Prefer not to say'), (3, 'Female'), (4, 'Male'), (5, 'Non-binary'), (6, 'Non-binary');
|
List the number of employees hired each month in 2021, for those who identify as non-binary or prefer not to say.
|
SELECT EXTRACT(MONTH FROM HireDate) AS Month, COUNT(*) AS HiredCount FROM HiringDates INNER JOIN Employees ON HiringDates.EmployeeID = Employees.EmployeeID WHERE Gender IN ('Non-binary', 'Prefer not to say') GROUP BY Month ORDER BY Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibits (id INT, name VARCHAR(50), event VARCHAR(50), area INT); INSERT INTO exhibits (id, name, event, area) VALUES (1, 'Japanese Woodblock Prints', 'Asian Art', 500), (2, 'Indian Miniature Paintings', 'Asian Art', 300);
|
Add a new exhibit 'Chinese Calligraphy' to the 'Asian Art' event.
|
INSERT INTO exhibits (id, name, event, area) VALUES (3, 'Chinese Calligraphy', 'Asian Art', 400);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation (region VARCHAR(255), project_status VARCHAR(255)); INSERT INTO climate_mitigation VALUES ('South America', 'completed');
|
How many climate mitigation projects were completed in South America?
|
SELECT COUNT(*) FROM climate_mitigation WHERE region = 'South America' AND project_status = 'completed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget (budget_id INT, budget_amount DECIMAL(10,2), budget_date DATE);
|
What is the total budget for the year 2022?
|
SELECT SUM(budget_amount) FROM budget WHERE YEAR(budget_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, Name TEXT, Budget FLOAT); INSERT INTO Programs (ProgramID, Name, Budget) VALUES (1, 'Education', 15000.00), (2, 'Health', 20000.00); CREATE TABLE ProgramVolunteers (ProgramID INT, VolunteerID INT); INSERT INTO ProgramVolunteers (ProgramID, VolunteerID) VALUES (1, 1), (1, 2), (2, 3);
|
Delete the 'Health' program and all associated volunteer records.
|
DELETE FROM ProgramVolunteers WHERE ProgramID = (SELECT ProgramID FROM Programs WHERE Name = 'Health'); DELETE FROM Programs WHERE Name = 'Health';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.