context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE WeatherData (province VARCHAR(50), temperature FLOAT, measurement_date DATE); INSERT INTO WeatherData (province, temperature, measurement_date) VALUES ('Alberta', 10, '2022-01-01'), ('British Columbia', 5, '2022-01-01'), ('Ontario', 15, '2022-01-01'), ('Quebec', 20, '2022-01-01');
|
What is the average monthly temperature in each province, ranked in ascending order?
|
SELECT province, AVG(temperature) AS avg_temperature FROM WeatherData GROUP BY province ORDER BY avg_temperature ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wearable_tech (user_id INT, heart_rate INT, country VARCHAR(50)); INSERT INTO wearable_tech (user_id, heart_rate, country) VALUES (1, 70, 'India'), (2, 75, 'Canada'), (3, 80, 'India'), (4, 65, 'India');
|
What is the minimum heart rate of users from India?
|
SELECT MIN(heart_rate) FROM wearable_tech WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE social_media_users_latam (user_id INT, signup_date DATE, country VARCHAR(50));
|
Display the daily new user signups for the social_media_users_latam table in a bar chart format for the last month.
|
SELECT signup_date, COUNT(*) as new_users FROM social_media_users_latam WHERE signup_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY signup_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_camps (id INT PRIMARY KEY, location VARCHAR(50), year INT, number INT); INSERT INTO medical_camps (id, location, year, number) VALUES (1, 'Africa', 2018, 10), (2, 'Asia', 2018, 15), (3, 'Africa', 2019, 12), (4, 'Asia', 2019, 20), (5, 'Africa', 2020, 14), (6, 'Asia', 2020, 25);
|
How many medical camps were organized in total in 2019 and 2020?
|
SELECT SUM(number) FROM medical_camps WHERE year IN (2019, 2020);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WaterSources (ID INT, SourceID INT, Status VARCHAR(10), LastOnline DATE); INSERT INTO WaterSources (ID, SourceID, Status, LastOnline) VALUES (1, 1, 'Online', '2022-01-01'); INSERT INTO WaterSources (ID, SourceID, Status, LastOnline) VALUES (2, 2, 'Offline', '2022-06-15');
|
Which water sources have been offline for more than a month and their last online date in the 'WaterSources' table?
|
SELECT SourceID, LastOnline FROM WaterSources WHERE Status = 'Offline' AND DATEDIFF(day, LastOnline, GETDATE()) > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Clinics (ClinicID INT, Name VARCHAR(50), Specialty VARCHAR(30), Area VARCHAR(20)); INSERT INTO Clinics (ClinicID, Name, Specialty, Area) VALUES (1, 'Rural Clinic A', 'Primary Care', 'Rural Colorado'); INSERT INTO Clinics (ClinicID, Name, Specialty, Area) VALUES (2, 'Rural Clinic B', 'Dental', 'Rural Utah');
|
What is the total number of clinics in the rural areas of "Colorado" and "Utah"?
|
SELECT COUNT(*) FROM Clinics WHERE Area IN ('Rural Colorado', 'Rural Utah');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_statistics (id INT PRIMARY KEY, project_id INT, workers_count INT, FOREIGN KEY (project_id) REFERENCES project(id)); INSERT INTO labor_statistics (id, project_id, workers_count) VALUES (1, 1, 50);
|
Find the average number of workers per sustainable material used in projects
|
SELECT sm.material_name, AVG(l.workers_count) AS avg_workers_count FROM labor_statistics l INNER JOIN project p ON l.project_id = p.id INNER JOIN building_permit bp ON p.id = bp.project_id INNER JOIN sustainable_material sm ON bp.id = sm.permit_id WHERE sm.material_name IN ('Reclaimed Wood', 'Straw Bale') GROUP BY sm.material_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT PRIMARY KEY, volunteer_name TEXT); INSERT INTO volunteers (volunteer_id, volunteer_name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); CREATE TABLE volunteer_hours (hour_id INT PRIMARY KEY, volunteer_id INT, program_id INT, hours_served DECIMAL); INSERT INTO volunteer_hours (hour_id, volunteer_id, program_id, hours_served) VALUES (1, 1, 1, 5.00), (2, 1, 2, 3.00), (3, 2, 1, 4.00);
|
Delete volunteers with no hours served
|
WITH no_hours_served AS (DELETE FROM volunteer_hours WHERE hours_served = 0 RETURNING volunteer_id) DELETE FROM volunteers WHERE volunteer_id IN (SELECT * FROM no_hours_served);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hr.employee_salaries (id INT, employee_id INT, salary DECIMAL(10, 2), gender VARCHAR(10), department VARCHAR(50));
|
Calculate the average salary of employees in the 'hr' schema's 'employee_salaries' table by department
|
SELECT department, AVG(salary) FROM hr.employee_salaries GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Material_Prices (Type VARCHAR(255), Year INT, Price FLOAT); INSERT INTO Material_Prices (Type, Year, Price) VALUES ('Organic Cotton', 2020, 3.5), ('Organic Cotton', 2021, 3.7), ('Recycled Polyester', 2020, 4.2), ('Recycled Polyester', 2021, 4.4), ('Hemp', 2020, 2.8), ('Hemp', 2021, 3.0);
|
Find the top 2 sustainable material types with the greatest price increase compared to the previous year.
|
SELECT Type, (Price - LAG(Price) OVER (PARTITION BY Type ORDER BY Year)) / LAG(Price) OVER (PARTITION BY Type ORDER BY Year) * 100.0 as Price_Increase_Percentage FROM Material_Prices WHERE Type IN ('Organic Cotton', 'Recycled Polyester', 'Hemp') ORDER BY Price_Increase_Percentage DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), gender VARCHAR(50), balance DECIMAL(10,2)); INSERT INTO customers (id, name, gender, balance) VALUES (1, 'John Doe', 'Male', 5000.00), (2, 'Jane Smith', 'Female', 7000.00), (3, 'Bob Johnson', 'Male', 4000.00);
|
What is the average account balance for customers in each gender?
|
SELECT gender, AVG(balance) FROM customers GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE materials (id INT, country VARCHAR(255), type VARCHAR(255), sales FLOAT, profits FLOAT); INSERT INTO materials (id, country, type, sales, profits) VALUES (1, 'France', 'Organic Cotton', 500, 250), (2, 'Germany', 'Hemp', 600, 360), (3, 'France', 'Recycled Polyester', 700, 350), (4, 'Germany', 'Organic Cotton', 800, 400);
|
List the ethical material types and their sales in France and Germany.
|
SELECT type, SUM(sales) as total_sales FROM materials WHERE country IN ('France', 'Germany') GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_conservation (species TEXT, conservation_status TEXT);
|
List all marine species with their conservation status, ordered alphabetically by species name.
|
SELECT species, conservation_status FROM marine_species_conservation ORDER BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TemperatureData (location VARCHAR(50), year INT, temperature FLOAT); INSERT INTO TemperatureData (location, year, temperature) VALUES ('Greenland', 2000, 15.6), ('Greenland', 2001, 18.2), ('Greenland', 2002, 12.9);
|
What is the maximum temperature recorded per year in Greenland?
|
SELECT location, MAX(temperature) FROM TemperatureData GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (saleID INT, garmentID INT, year INT, revenue DECIMAL(5,2)); INSERT INTO Sales (saleID, garmentID, year, revenue) VALUES (1, 1, 2020, 25000.00), (2, 2, 2020, 30000.00), (3, 3, 2019, 22000.00), (4, 4, 2020, 15000.00), (5, 5, 2019, 10000.00);
|
What are the annual sales figures for garments made with sustainable materials, excluding organic cotton?
|
SELECT SUM(revenue) FROM Sales WHERE garmentID IN (SELECT garmentID FROM GarmentProduction WHERE material NOT LIKE '%Organic Cotton%');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MinCarbonOffsetProjects (project TEXT, carbon_offset FLOAT); INSERT INTO MinCarbonOffsetProjects (project, carbon_offset) VALUES ('Project1', 1200), ('Project2', 1000), ('Project3', 800);
|
What is the minimum carbon offset of projects in the 'CarbonOffsetProjects' table?
|
SELECT carbon_offset FROM MinCarbonOffsetProjects ORDER BY carbon_offset LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing_plants (id INT, name VARCHAR(50));CREATE TABLE waste_generation (plant_id INT, date DATE, amount INT); INSERT INTO manufacturing_plants (id, name) VALUES (1, 'Plant A'), (2, 'Plant B'); INSERT INTO waste_generation (plant_id, date, amount) VALUES (1, '2022-02-01', 100), (1, '2022-02-03', 150), (1, '2022-02-05', 50), (2, '2022-02-02', 200), (2, '2022-02-04', 300), (2, '2022-02-06', 100);
|
Calculate the average waste generation rate per day for each manufacturing plant in the month of February 2022.
|
SELECT m.name, AVG(w.amount / 31.0) AS avg_daily_amount FROM manufacturing_plants m INNER JOIN waste_generation w ON m.id = w.plant_id WHERE w.date >= '2022-02-01' AND w.date <= '2022-02-28' GROUP BY m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (policyholder_id INT, name VARCHAR(50)); INSERT INTO policyholders (policyholder_id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE policies (policy_id INT, policyholder_id INT, category VARCHAR(10)); INSERT INTO policies (policy_id, policyholder_id, category) VALUES (1, 1, 'auto'), (2, 1, 'auto'), (3, 2, 'home'), (4, 2, 'auto');
|
Identify policyholders with more than one auto policy
|
SELECT policyholders.name FROM policyholders INNER JOIN policies ON policyholders.policyholder_id = policies.policyholder_id WHERE policies.category = 'auto' GROUP BY policyholders.name HAVING COUNT(policies.policy_id) > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT PRIMARY KEY, name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE);
|
What was the average donation amount from individual donors in 2021?
|
SELECT AVG(donation_amount) FROM donors WHERE EXTRACT(YEAR FROM donation_date) = 2021 AND id NOT IN (SELECT donor_id FROM organization_donations);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (route_id INT, name VARCHAR(255), type VARCHAR(255));
|
Add a new route to the 'routes' table
|
INSERT INTO routes (route_id, name, type) VALUES (1, 'Red Line', 'Subway');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Buildings (id INT, sector VARCHAR(20), CO2_emission FLOAT); INSERT INTO Buildings (id, sector, CO2_emission) VALUES (1, 'Renewable', 34.5), (2, 'Non-renewable', 78.3);
|
What is the minimum CO2 emission of a building in the renewable energy sector?
|
SELECT MIN(CO2_emission) FROM Buildings WHERE sector = 'Renewable';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE therapies (id INT, patient_id INT, type TEXT); CREATE TABLE conditions (id INT, name TEXT); INSERT INTO conditions (id, name) VALUES (1, 'Anxiety Disorder');
|
What is the most common type of therapy for patients with anxiety disorders?
|
SELECT type, COUNT(*) as count FROM therapies JOIN conditions ON therapies.type = conditions.name WHERE conditions.id = 1 GROUP BY type ORDER BY count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meal_plan (meal_name TEXT, vegan BOOLEAN, servings_per_day INTEGER); INSERT INTO meal_plan (meal_name, vegan, servings_per_day) VALUES ('Tofu Stir Fry', true, 100), ('Chicken Caesar Salad', false, 150), ('Veggie Burger', true, 120);
|
How many vegan dishes are served in the university_cafeteria per day according to the meal_plan table?
|
SELECT SUM(servings_per_day) FROM meal_plan WHERE vegan = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO customers (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Marie Lee', 'France'); CREATE TABLE accounts (id INT, customer_id INT, balance DECIMAL(10, 2)); INSERT INTO accounts (id, customer_id, balance) VALUES (1, 1, 12000.00), (2, 1, 18000.00), (3, 2, 6000.00), (4, 3, 1500.00);
|
How many customers from each country have an account balance greater than 10000?
|
SELECT customers.country, COUNT(DISTINCT customers.id) FROM customers INNER JOIN accounts ON customers.id = accounts.customer_id WHERE accounts.balance > 10000 GROUP BY customers.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, is_investigative BOOLEAN, word_count INT, year INT); INSERT INTO articles (id, is_investigative, word_count, year) VALUES (1, TRUE, 1000, 2019), (2, FALSE, 500, 2019), (3, TRUE, 1500, 2019);
|
What was the average word count of investigative journalism articles in 2019?
|
SELECT AVG(word_count) FROM articles WHERE is_investigative = TRUE AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation_france(year INT, material VARCHAR(20), amount INT); INSERT INTO waste_generation_france VALUES (2019, 'Plastic', 1000), (2019, 'Glass', 2000), (2019, 'Metal', 3000);
|
What is the average waste generation by material type in France in 2019?
|
SELECT material, AVG(amount) as avg_amount FROM waste_generation_france WHERE year = 2019 GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EcoFriendlyTextileSuppliers (supplier TEXT, item_id INTEGER); INSERT INTO EcoFriendlyTextileSuppliers (supplier, item_id) VALUES ('Supplier1', 111), ('Supplier2', 222), ('Supplier3', 333), ('Supplier1', 444), ('Supplier4', 555), ('Supplier4', 666), ('Supplier5', 777), ('Supplier5', 888);
|
What is the total number of eco-friendly items produced by each textile supplier, and show only those suppliers with more than 200 eco-friendly items produced?
|
SELECT supplier, COUNT(*) as eco_friendly_total FROM EcoFriendlyTextileSuppliers GROUP BY supplier HAVING COUNT(*) > 200;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soil_data (soil_type VARCHAR(20), ph FLOAT, region VARCHAR(20)); INSERT INTO soil_data (soil_type, ph, region) VALUES ('Loamy', 7.2, 'Midwest');
|
List all the unique soil types and their corresponding pH values in the 'Midwest' region.
|
SELECT DISTINCT soil_type, ph FROM soil_data WHERE region = 'Midwest'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CrimeRates (district_name TEXT, crime_rate FLOAT); INSERT INTO CrimeRates (district_name, crime_rate) VALUES ('Downtown', 0.4), ('Uptown', 0.3), ('Central', 0.25), ('Westside', 0.2), ('North', 0.15);
|
List the bottom 2 districts with the lowest crime rate, excluding the North district.
|
SELECT district_name, crime_rate FROM CrimeRates WHERE district_name != 'North' ORDER BY crime_rate LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indigenous_communities (id INT, community_name VARCHAR, country VARCHAR);
|
List the names of all indigenous communities in Greenland.
|
SELECT community_name FROM indigenous_communities WHERE country = 'Greenland';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mitigation_projects (project_name TEXT, funding INTEGER);INSERT INTO mitigation_projects (project_name, funding) VALUES ('Reforestation', 1500000), ('Carbon Capture', 2000000);
|
List the funding allocated for each climate mitigation project in South America.
|
SELECT project_name, funding FROM mitigation_projects WHERE region = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, name VARCHAR(100), visitor_count INT); INSERT INTO Exhibitions (exhibition_id, name, visitor_count) VALUES (1, 'Ancient Egypt', 750);
|
Update the visitor count for 'Ancient Egypt' exhibition by 250.
|
UPDATE Exhibitions SET visitor_count = visitor_count + 250 WHERE name = 'Ancient Egypt';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name TEXT, location TEXT, mineral TEXT, productivity INT); INSERT INTO mine (id, name, location, mineral, productivity) VALUES (1, 'Freeport', 'Indonesia', 'Tin', 1300), (2, 'Amman', 'Indonesia', 'Tin', 1100);
|
How many tin mines are there in Indonesia with productivity above 1200?
|
SELECT COUNT(*) FROM mine WHERE mineral = 'Tin' AND location = 'Indonesia' AND productivity > 1200;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_shuttles (id INT PRIMARY KEY, shuttle_name VARCHAR(255), city VARCHAR(255), num_shuttles INT, capacity INT);
|
Add a new self-driving shuttle service in the city of Austin
|
INSERT INTO autonomous_shuttles (id, shuttle_name, city, num_shuttles, capacity) VALUES (301, 'Capital Metro Shuttle', 'Austin', 20, 12);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite (Id INT, Name VARCHAR(100), LaunchDate DATETIME, Country VARCHAR(50), Function VARCHAR(50)); INSERT INTO Satellite (Id, Name, LaunchDate, Country, Function) VALUES (3, 'Lomonosov', '2016-04-28', 'Russia', 'Scientific Research');
|
List the names and launch dates of all satellites launched by Russia for scientific purposes.
|
SELECT Name, LaunchDate FROM Satellite WHERE Country = 'Russia' AND Function = 'Scientific Research';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE researchers (researcher_id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), experience INT);
|
Update the "experience" field in the "researchers" table for the researcher with "researcher_id" 205 to 7.
|
UPDATE researchers SET experience = 7 WHERE researcher_id = 205;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_projects(project_id INT, project_name VARCHAR(50), duration INT, cost FLOAT); INSERT INTO defense_projects VALUES (1, 'Project A', 36, 5000000), (2, 'Project B', 24, 4000000), (3, 'Project C', 18, 3000000);
|
What is the maximum duration of defense projects?
|
SELECT MAX(duration) FROM defense_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, player_name VARCHAR(50), team_id INT);CREATE TABLE games (game_id INT, team_id INT, date DATE, points INT); INSERT INTO players VALUES (1, 'James Harden', 1); INSERT INTO players VALUES (2, 'Kevin Durant', 1); INSERT INTO games VALUES (1, 1, '2022-03-01', 25); INSERT INTO games VALUES (2, 1, '2022-03-03', 30); INSERT INTO games VALUES (3, 1, '2022-03-05', 20);
|
What is the average number of points scored per game for each player, ordered by the highest average points scored?
|
SELECT player_id, AVG(points) as avg_points FROM games GROUP BY player_id ORDER BY avg_points DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CybersecurityStrategies (Country VARCHAR(50), Strategy VARCHAR(100)); INSERT INTO CybersecurityStrategies (Country, Strategy) VALUES ('USA', 'Zero Trust Architecture'), ('UK', 'Active Cyber Defence'), ('France', 'National Cybersecurity Strategy 2018-2023'), ('Germany', 'Cybersecurity Strategy for the Federal Government 2021'), ('Canada', 'National Cyber Security Strategy');
|
What cybersecurity strategies are used by NATO members?
|
SELECT Strategy FROM CybersecurityStrategies WHERE Country IN ('USA', 'UK', 'France', 'Germany', 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE portfolio_managers (manager_name VARCHAR(20), id INT); CREATE TABLE investments (manager_id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO portfolio_managers (manager_name, id) VALUES ('Portfolio Manager 1', 1), ('Portfolio Manager 2', 2), ('Portfolio Manager 3', 3); INSERT INTO investments (manager_id, sector, ESG_rating) VALUES (1, 'renewable_energy', 8.1), (1, 'technology', 7.5), (2, 'renewable_energy', 6.5), (2, 'technology', 9.0), (3, 'finance', 6.8), (3, 'renewable_energy', 9.2);
|
How many investments has 'Portfolio Manager 2' made in total, and what's their average ESG rating?
|
SELECT COUNT(*), AVG(investments.ESG_rating) FROM investments INNER JOIN portfolio_managers ON investments.manager_id = portfolio_managers.id WHERE portfolio_managers.manager_name = 'Portfolio Manager 2';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contract_developers (developer_id INT PRIMARY KEY, developer_name TEXT, contract_name TEXT); INSERT INTO smart_contract_developers (developer_id, developer_name, contract_name) VALUES (1, 'Vitalik Buterin', 'Uniswap'), (2, 'Hayden Adams', 'Uniswap');
|
Who are the developers of the smart contract 'Uniswap'?
|
SELECT developer_name FROM smart_contract_developers WHERE contract_name = 'Uniswap';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete_injury (athlete_id INT, injury_date DATE);
|
Show the percentage of athletes who suffered from an injury in the last season
|
SELECT ((SUM(CASE WHEN injury_date >= (SELECT MIN(gs.game_date) FROM game_schedule gs WHERE gs.season = (SELECT MAX(gs2.season) FROM game_schedule gs2)) THEN 1 ELSE 0 END) / COUNT(*)) * 100) AS percentage FROM athlete_injury;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_categories (building_id INT, category VARCHAR(50), num_units INT); INSERT INTO building_categories (building_id, category, num_units) VALUES (1, 'Apartment', 30), (2, 'Condo', 40), (3, 'Townhouse', 20), (4, 'Apartment', 50), (5, 'Condo', 60);
|
How many units are there in each building category?
|
SELECT category, COUNT(*) FROM building_categories GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT, investor VARCHAR(255), amount FLOAT, date DATE, impact BOOLEAN); INSERT INTO investments (id, investor, amount, date, impact) VALUES (17, 'Eco Innovators', 150000, '2022-05-01', TRUE); INSERT INTO investments (id, investor, amount, date, impact) VALUES (18, 'Eco Innovators', 170000, '2022-11-30', TRUE);
|
How many impact investments were made by 'Eco Innovators' in 2022?
|
SELECT COUNT(*) FROM investments WHERE investor = 'Eco Innovators' AND impact = TRUE AND year(date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'StartupA', 'UK', 5000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'StartupB', 'UK', 7000000); INSERT INTO startups (id, name, location, funding) VALUES (3, 'StartupC', 'UK', 9000000);
|
What is the average funding for biotech startups in the UK?
|
SELECT AVG(funding) FROM startups WHERE location = 'UK';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drought_prone_regions (region VARCHAR(20), water_usage FLOAT); INSERT INTO drought_prone_regions (region, water_usage) VALUES ('Central Valley', 12000), ('Los Angeles', 9000), ('San Diego', 8000), ('Silicon Valley', 11000);
|
Identify the top 3 drought-prone regions in California with the highest water consumption?
|
SELECT region, water_usage FROM drought_prone_regions ORDER BY water_usage DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (id INT, name TEXT, category TEXT); CREATE TABLE investments (id INT, client_id INT, product_code TEXT); INSERT INTO clients (id, name, category) VALUES (1, 'John Doe', 'Medium-Risk'), (2, 'Jane Smith', 'Low-Risk'), (3, 'Alice Johnson', 'High-Risk'), (4, 'Bob Brown', 'Medium-Risk'); INSERT INTO investments (id, client_id, product_code) VALUES (1, 1, 'AAPL'), (2, 1, 'GOOG'), (3, 2, 'MSFT'), (4, 4, 'FB');
|
What is the number of investment products owned by clients in the 'Medium-Risk' category?
|
SELECT COUNT(*) FROM clients c JOIN investments i ON c.id = i.client_id WHERE c.category = 'Medium-Risk';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_towers (id INT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), status VARCHAR(255));CREATE VIEW network_outages AS SELECT tower_id, date FROM network_issues WHERE issue_type = 'outage';
|
List all mobile towers that have experienced network outages in the past year, including their geographical coordinates.
|
SELECT mt.id, mt.latitude, mt.longitude FROM mobile_towers mt INNER JOIN network_outages no ON mt.id = no.tower_id WHERE no.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_agencies (agency_id INT, agency_name VARCHAR(50), city VARCHAR(20), year INT, requests_open INT); INSERT INTO city_agencies (agency_id, agency_name, city, year, requests_open) VALUES (1, 'New York City Police Department', 'New York', 2019, 250);
|
List the names and number of open records requests for each agency in the city of New York for the year 2019
|
SELECT agency_name, requests_open FROM city_agencies WHERE city = 'New York' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity (policy_id INT, policy_name VARCHAR(50), policy_description VARCHAR(100)); INSERT INTO mental_health_parity (policy_id, policy_name, policy_description) VALUES (1, 'Parity Act 2008', 'Federal law requiring insurers to cover mental health conditions the same as physical health conditions'), (2, 'MHPAEA 2010', 'Expansion of Parity Act to cover additional mental health conditions'), (3, 'California MHP 2014', 'California state law for mental health parity');
|
List all unique mental health parity policies in the database.
|
SELECT DISTINCT policy_name FROM mental_health_parity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FoodSources (source_id INT, food_type VARCHAR(255), origin VARCHAR(255), is_organic BOOLEAN); INSERT INTO FoodSources (source_id, food_type, origin, is_organic) VALUES (1, 'Avocado', 'Latin America', true), (2, 'Banana', 'Latin America', false), (3, 'Carrot', 'Europe', true);
|
What is the total weight of fruits and vegetables sourced from Latin America that are organic?
|
SELECT SUM(weight) FROM FoodSources WHERE food_type IN ('Fruit', 'Vegetable') AND origin = 'Latin America' AND is_organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investors (investor_id INT, investor_name TEXT, gender TEXT); CREATE TABLE investments (investment_id INT, investor_id INT, invested_amount INT);
|
What is the percentage of investments made by female-led investing firms in the social impact space?
|
SELECT (COUNT(*) FILTER (WHERE gender = 'female')) * 100.0 / COUNT(*) AS percentage FROM investors i JOIN investments j ON i.investor_id = j.investor_id WHERE j.investment_type = 'social impact';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_expeditions (expedition_id INT, name TEXT, organization TEXT, year INT);
|
Count how many deep-sea expeditions have been conducted by the "Ocean Explorers" organization?
|
SELECT COUNT(*) FROM deep_sea_expeditions WHERE organization = 'Ocean Explorers';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE Organic_Produce (id INT, name VARCHAR(50), Supplier_id INT, calories INT); INSERT INTO Suppliers (id, name, country) VALUES (1, 'Nutty Acres', 'USA'), (2, 'Peanut Paradise', 'Canada'); INSERT INTO Organic_Produce (id, name, Supplier_id, calories) VALUES (1, 'Almonds', 1, 150), (2, 'Cashews', 1, 200), (3, 'Peanuts', 2, 250), (4, 'Walnuts', 2, 300);
|
How many items in the Organic_Produce table are supplied by each sustainable farmer, grouped by the supplier's country of origin?
|
SELECT s.country, COUNT(o.id) AS item_count FROM Sustainable_Farmers s LEFT JOIN Organic_Produce o ON s.id = o.Supplier_id GROUP BY s.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions(id INT, company VARCHAR(255), mission VARCHAR(255), year INT, success BOOLEAN); INSERT INTO SpaceMissions(id, company, mission, year, success) VALUES (1, 'SpaceX', 'Mission 1', 2021, true), (2, 'Blue Origin', 'Mission 2', 2021, true), (3, 'SpaceX', 'Mission 3', 2022, false), (4, 'Virgin Galactic', 'Mission 4', 2021, true);
|
How many space missions were carried out by private companies in 2021?
|
SELECT COUNT(*) FROM SpaceMissions WHERE company IN ('SpaceX', 'Blue Origin', 'Virgin Galactic') AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contract_language (language VARCHAR(255), smart_contract_count INT); INSERT INTO smart_contract_language (language, smart_contract_count) VALUES ('Solidity', 8000), ('Vyper', 2000), ('Rust', 1000);
|
What is the percentage of smart contracts written in Rust compared to the total number of smart contracts?
|
SELECT language, 100.0 * smart_contract_count / SUM(smart_contract_count) OVER () as percentage FROM smart_contract_language WHERE language = 'Rust';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE adaptation_activities (org VARCHAR(50), year INT, activity VARCHAR(50)); INSERT INTO adaptation_activities VALUES ('OrgA', 2010, 'ActivityA');
|
Which organizations have not reported any climate adaptation activities since 2010?
|
SELECT DISTINCT org FROM adaptation_activities WHERE org NOT IN (SELECT org FROM adaptation_activities WHERE year >= 2010 AND activity != 'N/A')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, type VARCHAR(50));
|
Show the total number of vehicles and the number of electric vehicles in the 'green_vehicles' table
|
SELECT COUNT(*) AS total_vehicles, SUM(CASE WHEN type = 'Electric' THEN 1 ELSE 0 END) AS electric_vehicles FROM green_vehicles;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (restaurant_id INT, cuisine_type VARCHAR(255), revenue DECIMAL(10,2), transaction_date DATE); INSERT INTO restaurant_revenue (restaurant_id, cuisine_type, revenue, transaction_date) VALUES (1, 'Italian', 5000, '2022-01-01'), (2, 'Mexican', 7000, '2022-01-02');
|
What was the total revenue for each cuisine type in January 2022?
|
SELECT cuisine_type, SUM(revenue) as total_revenue FROM restaurant_revenue WHERE transaction_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY cuisine_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE airlines (flight_id INT, airline_id INT, flight_start_time TIMESTAMP, flight_end_time TIMESTAMP, origin TEXT, destination TEXT, city TEXT, avg_passengers DECIMAL);
|
What is the average number of passengers per flight for airlines in New Delhi, India?
|
SELECT AVG(avg_passengers) FROM airlines WHERE city = 'New Delhi';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hockey_players (player_id INT, name VARCHAR(50), position VARCHAR(50), salary DECIMAL(5,2)); INSERT INTO hockey_players (player_id, name, position, salary) VALUES (1, 'James Lee', 'Goalie', 50000.00), (2, 'Jasmine White', 'Forward', 75000.00);
|
Find the names of athletes in the hockey_players table who earn more than the average salary.
|
SELECT name FROM hockey_players WHERE salary > (SELECT AVG(salary) FROM hockey_players);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthParity (IncidentID INT, IncidentDate DATE, City VARCHAR(255)); INSERT INTO MentalHealthParity (IncidentID, IncidentDate, City) VALUES (1, '2022-06-01', 'New York'); INSERT INTO MentalHealthParity (IncidentID, IncidentDate, City) VALUES (2, '2022-06-15', 'Los Angeles'); INSERT INTO MentalHealthParity (IncidentID, IncidentDate, City) VALUES (3, '2022-06-05', 'Chicago'); INSERT INTO MentalHealthParity (IncidentID, IncidentDate, City) VALUES (4, '2022-06-10', 'Houston');
|
List the number of mental health parity incidents in each city for the last month.
|
SELECT City, COUNT(*) FROM MentalHealthParity WHERE IncidentDate >= DATEADD(month, -1, GETDATE()) GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (id INT, name VARCHAR, location VARCHAR); INSERT INTO heritage_sites (id, name, location) VALUES (1, 'Heritage Site A', 'City A'), (2, 'Heritage Site B', 'City B'); CREATE TABLE workshops (id INT, type VARCHAR, site_id INT); INSERT INTO workshops (id, type, site_id) VALUES (1, 'Craft', 1), (2, 'Performance', 2);
|
What is the name and location of all heritage sites that have craft workshops?
|
SELECT heritage_sites.name, heritage_sites.location FROM heritage_sites INNER JOIN workshops ON heritage_sites.id = workshops.site_id WHERE workshops.type = 'Craft';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE high_speed_rail_routes (id INT PRIMARY KEY, route_name VARCHAR(255), departure_city VARCHAR(255), destination_city VARCHAR(255), distance INT, avg_speed INT);
|
Add a new high-speed train route from Beijing to Shanghai
|
INSERT INTO high_speed_rail_routes (id, route_name, departure_city, destination_city, distance, avg_speed) VALUES (101, 'Beijing-Shanghai Express', 'Beijing', 'Shanghai', 1268, 305);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecrafts (id INT, name VARCHAR(255), launch_date DATE, manufacturing_cost FLOAT);
|
Insert a new spacecraft with ID 4 named "Voyager 1" launched on 1977-09-05 with a manufacturing cost of 250000.
|
INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (4, 'Voyager 1', '1977-09-05', 250000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AircraftModels (model_id INT, name VARCHAR(50), manufacturer VARCHAR(50), country VARCHAR(50)); INSERT INTO AircraftModels (model_id, name, manufacturer, country) VALUES (1, 'Air1', 'AvionicCorp', 'USA'), (2, 'Air2', 'AeroCanada', 'Canada'), (3, 'Air3', 'EuroJet', 'France'), (4, 'Air4', 'AvionicCorp', 'Mexico'), (5, 'Air5', 'AeroCanada', 'USA');
|
Which manufacturers have manufactured aircraft in both the USA and Canada?
|
SELECT manufacturer FROM AircraftModels WHERE country IN ('USA', 'Canada') GROUP BY manufacturer HAVING COUNT(DISTINCT country) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (id INT, name TEXT, safety_record TEXT, flag_country TEXT, incident_year INT); INSERT INTO Vessels (id, name, safety_record, flag_country, incident_year) VALUES (1, 'Vessel1', 'Safe', 'Panama', 2019); INSERT INTO Vessels (id, name, safety_record, flag_country, incident_year) VALUES (2, 'Vessel2', 'Incident', 'Panama', 2020);
|
List the names and safety records of Panamanian-flagged vessels that had safety incidents in 2020.
|
SELECT name, safety_record FROM Vessels WHERE flag_country = 'Panama' AND incident_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE prepaid_plans (id INT, plan_name VARCHAR(20), region VARCHAR(10), monthly_bill INT); INSERT INTO prepaid_plans (id, plan_name, region, monthly_bill) VALUES (1, 'Basic', 'tropical', 30), (2, 'Plus', 'tropical', 40), (3, 'Premium', 'tropical', 50);
|
What is the maximum monthly bill for prepaid mobile customers in the "tropical" region?
|
SELECT MAX(monthly_bill) FROM prepaid_plans WHERE region = 'tropical';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50)); INSERT INTO Vessels (ID, Name, Type) VALUES (1, 'MV Pacific', 'Cargo Ship'), (2, 'MV Persian Gulf', 'Tanker');
|
What are the names of all vessels that are either cargo ships or tankers?
|
SELECT Name FROM Vessels WHERE Type IN ('Cargo Ship', 'Tanker');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_gender_distribution (id INT, union_name TEXT, state TEXT, total_male INT, total_female INT); INSERT INTO union_gender_distribution (id, union_name, state, total_male, total_female) VALUES (1, 'Union G', 'California', 250, 300), (2, 'Union H', 'California', 400, 450), (3, 'Union I', 'California', 350, 300);
|
What are the names of unions that have a higher number of female members than male members in California?
|
SELECT union_name FROM union_gender_distribution WHERE total_female > total_male AND state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (subscriber_id INT, connection_speed FLOAT, state VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, connection_speed, state) VALUES (1, 150, 'California'), (2, 75, 'New York'), (3, 120, 'California');
|
How many broadband customers have a connection speed greater than 100 Mbps in the state of California?
|
SELECT COUNT(*) FROM broadband_subscribers WHERE state = 'California' AND connection_speed > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (facility_id INT, facility_name TEXT, num_beds INT, location TEXT); INSERT INTO facilities (facility_id, facility_name, num_beds, location) VALUES (3, 'Montana Rural Clinic', 12, 'Montana');
|
What is the maximum number of beds in healthcare facilities in rural Montana?
|
SELECT MAX(num_beds) FROM facilities WHERE location = 'Montana';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CBAs (UnionName TEXT, ExpirationDate DATE); INSERT INTO CBAs (UnionName, ExpirationDate) VALUES ('UnionA', '2023-01-01'), ('UnionB', '2024-01-01'), ('UnionX', '2025-01-01'), ('UnionY', '2022-01-01');
|
What are the collective bargaining agreement expiration dates for unions with more than 4000 members?
|
SELECT UnionName, ExpirationDate FROM CBAs WHERE MemberCount > 4000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (id INT, initial_orbit VARCHAR(255), current_orbit VARCHAR(255), distance FLOAT);
|
What is the average distance (in kilometers) that space debris travels from its initial orbit?
|
SELECT AVG(distance) FROM space_debris WHERE initial_orbit IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vr_games (game VARCHAR(20), release_year INT, region VARCHAR(10)); INSERT INTO vr_games (game, release_year, region) VALUES ('Game1', 2020, 'Europe'); INSERT INTO vr_games (game, release_year, region) VALUES ('Game2', 2019, 'Asia'); INSERT INTO vr_games (game, release_year, region) VALUES ('Game3', 2018, 'America');
|
Identify virtual reality games that were released after 2018 and their respective regions
|
SELECT game, region FROM vr_games WHERE release_year > 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_conservation (id INT PRIMARY KEY, location VARCHAR(50), water_savings FLOAT);
|
Calculate the average water savings
|
SELECT AVG(water_savings) FROM water_conservation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArts (ProjectID INT PRIMARY KEY, ProjectName VARCHAR(50), Location VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO TraditionalArts (ProjectID, ProjectName, Location, Budget) VALUES (1, 'Batik Workshops', 'Jamaica', 200000.00), (2, 'Steelpan Preservation', 'Trinidad and Tobago', 300000.00);
|
What is the total budget allocated for all traditional arts preservation projects in 'Caribbean'?
|
SELECT SUM(Budget) FROM TraditionalArts WHERE Location LIKE '%Caribbean%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO Employees (id, name, department) VALUES (1, 'John Doe', 'Editorial'); INSERT INTO Employees (id, name, department) VALUES (2, 'Jane Smith', 'Marketing');
|
find the number of employees who work in 'Editorial' department
|
SELECT COUNT(*) FROM Employees WHERE department = 'Editorial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID int, Gender varchar(20), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, Gender, Salary) VALUES (1, 'Non-binary', 70000.00), (2, 'Male', 75000.00), (3, 'Non-binary', 65000.00);
|
What is the minimum salary for employees who identify as non-binary?
|
SELECT MIN(Salary) FROM Employees WHERE Gender = 'Non-binary';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT, owner VARCHAR(255), area VARCHAR(255)); INSERT INTO property (id, owner, area) VALUES (1, 'Jamal', 'rural'), (2, 'Alex', 'rural'), (3, 'Sofia', 'urban'), (4, 'Tom', 'urban');
|
What is the total number of properties owned by people from historically underrepresented communities in rural areas?
|
SELECT COUNT(*) FROM property WHERE (owner = 'Jamal' OR owner = 'Sofia') AND area = 'rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (project_id INT, project_name TEXT, funding_year INT, amount FLOAT); INSERT INTO green_buildings (project_id, project_name, funding_year, amount) VALUES (1, 'Green Buildings 1', 2021, 1000000.00), (2, 'Green Buildings 2', 2022, 2000000.00);
|
What is the total climate finance committed for Green Buildings projects?
|
SELECT SUM(amount) FROM green_buildings;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE financial_transactions (id INT, transaction_date DATE, program_id INT);
|
What is the total number of financial transactions for each program?
|
SELECT p.name, SUM(ft.amount) as total_financial_transactions FROM programs p JOIN financial_transactions ft ON p.id = ft.program_id GROUP BY p.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment_manufacturers (id INT, name VARCHAR(100), country VARCHAR(50), uses_recycled_materials BOOLEAN); INSERT INTO garment_manufacturers (id, name, country, uses_recycled_materials) VALUES (1, 'Manufacturer A', 'Canada', true), (2, 'Manufacturer B', 'Canada', false);
|
Count the number of garment manufacturers that use recycled materials in Canada.
|
SELECT COUNT(*) FROM garment_manufacturers WHERE country = 'Canada' AND uses_recycled_materials = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (ClaimID int, ClaimDate date, ClaimAmount decimal(10, 2), PolicyType varchar(50)); INSERT INTO Claims (ClaimID, ClaimDate, ClaimAmount, PolicyType) VALUES (1, '2022-01-15', 4500.00, 'Auto'), (2, '2022-02-03', 3200.00, 'Home'), (3, '2022-03-17', 5700.00, 'Auto'), (4, '2022-04-01', 6100.00, 'Life'), (5, '2022-05-12', 4200.00, 'Auto'), (6, '2022-06-20', 3800.00, 'Home');
|
What is the moving average of claim amounts for the last 3 months, grouped by policy type?
|
SELECT PolicyType, AVG(ClaimAmount) OVER (PARTITION BY PolicyType ORDER BY ClaimDate ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS MovingAverage FROM Claims WHERE ClaimDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(20), size INT, co_owned BOOLEAN); INSERT INTO properties (id, city, size, co_owned) VALUES (1, 'Denver', 1000, TRUE), (2, 'Denver', 1500, FALSE), (3, 'Denver', 2000, TRUE);
|
What is the maximum square footage of a co-owned property in the city of Denver?
|
SELECT MAX(size) FROM properties WHERE city = 'Denver' AND co_owned = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, quantity INT, price DECIMAL(10,2), is_cruelty_free BOOLEAN); INSERT INTO sales (sale_id, product_id, sale_date, quantity, price, is_cruelty_free) VALUES (1, 1, '2022-01-01', 3, 25.99, true), (2, 2, '2022-01-02', 1, 39.99, false), (3, 3, '2022-01-03', 2, 9.99, true);
|
What is the sum of cruelty-free product sales in the US and Canada?
|
SELECT SUM(quantity * price) FROM sales WHERE is_cruelty_free = true AND (sale_date BETWEEN '2022-01-01' AND '2022-12-31') AND (country IN ('US', 'Canada'));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HospitalLocations (hospital_id INT, hospital_name VARCHAR(50), state VARCHAR(20)); INSERT INTO HospitalLocations (hospital_id, hospital_name, state) VALUES (1, 'RuralHospitalTX', 'Texas'), (2, 'RuralHospitalCA', 'California');
|
How many rural hospitals are located in Texas and California?
|
SELECT COUNT(*) FROM HospitalLocations WHERE state IN ('Texas', 'California');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing (ID INT, Manufacturer VARCHAR(255), Spacecraft VARCHAR(255)); CREATE TABLE Missions (ID INT, Name VARCHAR(255), Asteroid INT); INSERT INTO SpacecraftManufacturing (ID, Manufacturer, Spacecraft) VALUES (1, 'SpaceCorp', 'Spacecraft1'), (2, 'SpaceCorp', 'Spacecraft2'); INSERT INTO Missions (ID, Name, Asteroid) VALUES (1, 'Mission1', 1234), (2, 'Mission2', 5678);
|
Which spacecraft were used in missions that encountered asteroid 1234?
|
SELECT SpacecraftManufacturing.Spacecraft FROM SpacecraftManufacturing INNER JOIN Missions ON SpacecraftManufacturing.ID = Missions.ID WHERE Missions.Asteroid = 1234;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (item_id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO menu_items (item_id, name, category) VALUES (1, 'Burger', 'Main Course'), (2, 'Salad', 'Side Dish'), (3, 'Pizza', 'Main Course'); CREATE TABLE sales (sale_id INT, item_id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO sales (sale_id, item_id, date, revenue) VALUES (1, 1, '2022-03-01', 500), (2, 2, '2022-03-02', 300), (3, 3, '2022-03-03', 700), (4, 1, '2022-04-01', 400), (5, 2, '2022-04-02', 600), (6, 3, '2022-04-03', 800);
|
Find the total revenue per category in the last month.
|
SELECT mi.category, SUM(s.revenue) as total_revenue FROM sales s JOIN menu_items mi ON s.item_id = mi.item_id WHERE s.date >= DATE(NOW()) - INTERVAL 30 DAY GROUP BY mi.category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, Game VARCHAR(100), Rank VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Game, Rank) VALUES (1, 'John Doe', 25, 'Overwatch', 'Master'); INSERT INTO Players (PlayerID, Name, Age, Game, Rank) VALUES (2, 'Jane Smith', 30, 'Overwatch', 'Grandmaster');
|
What is the average age of players who have achieved a rank of Master or higher in the game 'Overwatch'?
|
SELECT AVG(Age) FROM Players WHERE Game = 'Overwatch' AND Rank IN ('Master', 'Grandmaster');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA research;CREATE TABLE grants(faculty_name TEXT,department TEXT,amount INTEGER);INSERT INTO grants(faculty_name,department,amount)VALUES('Karen','Mathematics',150000),('Larry','Physics',200000),('Melissa','Physics',50000);
|
What are the total research grant funds awarded to faculty members in the Mathematics and Physics departments?
|
SELECT department,SUM(amount) FROM research.grants WHERE department='Mathematics' OR department='Physics' GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_seasons (season_year INT, total_revenue FLOAT);
|
What was the total revenue for the 2020 NBA season?
|
SELECT total_revenue FROM nba_seasons WHERE season_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies(id INT, name VARCHAR(50), founding_year INT, diversity_score INT); INSERT INTO companies VALUES (1, 'Alpha', 2010, 70); INSERT INTO companies VALUES (2, 'Beta', 2015, 80); CREATE TABLE founders(id INT, company_id INT, is_immigrant BOOLEAN); INSERT INTO founders VALUES (1, 1, true); INSERT INTO founders VALUES (2, 1, false); INSERT INTO founders VALUES (3, 2, true); CREATE TABLE funding(id INT, company_id INT, amount INT); INSERT INTO funding VALUES (1, 1, 500000); INSERT INTO funding VALUES (2, 1, 750000); INSERT INTO funding VALUES (3, 2, 1000000);
|
What is the total funding received by companies founded by immigrants?
|
SELECT SUM(funding.amount) FROM companies INNER JOIN (funding INNER JOIN founders ON funding.company_id = founders.company_id) ON companies.id = funding.company_id WHERE founders.is_immigrant = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Loans (LoanID INT, Type VARCHAR(255), Amount DECIMAL(18,2), Date DATE, Gender VARCHAR(255)); INSERT INTO Loans (LoanID, Type, Amount, Date, Gender) VALUES (1, 'Socially Responsible', 10000, '2022-04-01', 'Female'); INSERT INTO Loans (LoanID, Type, Amount, Date, Gender) VALUES (2, 'Conventional', 20000, '2022-04-01', 'Male');
|
What is the total amount of socially responsible loans issued to female entrepreneurs in Q2?
|
SELECT SUM(Amount) FROM Loans WHERE Type = 'Socially Responsible' AND Date >= '2022-04-01' AND Date < '2022-07-01' AND Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MaritimeLaw (LawID INT, LawName VARCHAR(255), Year INT, Content TEXT);
|
Delete all records from the 'MaritimeLaw' table where the 'LawName' starts with 'I'
|
DELETE FROM MaritimeLaw WHERE LawName LIKE 'I%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE StrategyGame (playerID INT, region VARCHAR(5), playtime INT); INSERT INTO StrategyGame (playerID, region, playtime) VALUES (1, 'EU', 200), (2, 'EU', 100), (3, 'EU', 75), (4, 'ASIA', 80);
|
What is the minimum playtime for 'StrategyGame' in 'EU' region?
|
SELECT MIN(playtime) FROM StrategyGame WHERE region = 'EU' AND game = 'StrategyGame';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (claim_id INT, policyholder_id INT); CREATE TABLE policyholders (policyholder_id INT, gender VARCHAR(10));
|
List all claims and their corresponding policyholder's gender from the claims and policyholders tables.
|
SELECT claims.claim_id, policyholders.gender FROM claims INNER JOIN policyholders ON claims.policyholder_id = policyholders.policyholder_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarsRovers (name TEXT, launch_date DATE, cost INTEGER);INSERT INTO MarsRovers (name, launch_date, cost) VALUES ('Sojourner', '1996-12-04', 250000000); INSERT INTO MarsRovers (name, launch_date, cost) VALUES ('Spirit', '2003-06-10', 400000000);
|
What is the average cost of Mars rovers?
|
SELECT AVG(cost) FROM MarsRovers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, region VARCHAR(20)); INSERT INTO clients (client_id, region) VALUES (1, 'South East'), (2, 'North West'); CREATE TABLE assets (asset_id INT, client_id INT, value DECIMAL(10,2)); INSERT INTO assets (asset_id, client_id, value) VALUES (1, 1, 5000.00), (2, 1, 3000.00), (3, 2, 7000.00);
|
What is the total assets value for clients in region 'South East'?
|
SELECT SUM(a.value) FROM assets a INNER JOIN clients c ON a.client_id = c.client_id WHERE c.region = 'South East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Site (SiteID INT, SiteName VARCHAR(50), Region VARCHAR(50)); INSERT INTO Site (SiteID, SiteName, Region) VALUES (1, 'Great Wall', 'Asia'), (2, 'Machu Picchu', 'South America'), (3, 'Easter Island', 'Polynesia'); CREATE TABLE Artifact (ArtifactID INT, ArtifactName VARCHAR(50), SiteID INT); INSERT INTO Artifact (ArtifactID, ArtifactName, SiteID) VALUES (1, 'Watchtower', 1), (2, 'Temple of the Sun', 1), (3, 'Temple of the Moon', 1), (4, 'Llama Figurine', 2), (5, 'Moai', 3);
|
What are the top 3 regions with the most diverse set of heritage sites and associated artifacts?
|
SELECT r.Region, COUNT(s.SiteName) as SiteCount, COUNT(a.ArtifactID) as ArtifactCount FROM Site s JOIN Artifact a ON s.SiteID = a.SiteID JOIN Site s2 ON s.SiteID = s2.SiteID JOIN (SELECT DISTINCT Region FROM Site) r ON s2.Region = r.Region GROUP BY r.Region ORDER BY SiteCount DESC, ArtifactCount DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.