context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE dives (dive_id INT, diver_id INT, location VARCHAR(50), depth FLOAT, duration INT); INSERT INTO dives (dive_id, diver_id, location, depth, duration) VALUES (1, 1001, 'Great Barrier Reef', 35.4, 60);
|
What is the maximum depth (in meters) reached by a dive in the 'dives' table?
|
SELECT MAX(depth) FROM dives;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_investment (country VARCHAR(50), region VARCHAR(50), investment_type VARCHAR(50), year INT, investment_amount INT); INSERT INTO climate_investment (country, region, investment_type, year, investment_amount) VALUES ('Country A', 'Caribbean SIDS', 'Adaptation', 2017, 1000000); INSERT INTO climate_investment (country, region, investment_type, year, investment_amount) VALUES ('Country B', 'Caribbean SIDS', 'Mitigation', 2017, 1200000); INSERT INTO climate_investment (country, region, investment_type, year, investment_amount) VALUES ('Country C', 'Caribbean SIDS', 'Adaptation', 2018, 1100000); INSERT INTO climate_investment (country, region, investment_type, year, investment_amount) VALUES ('Country D', 'Caribbean SIDS', 'Mitigation', 2018, 1300000); INSERT INTO climate_investment (country, region, investment_type, year, investment_amount) VALUES ('Country E', 'Caribbean SIDS', 'Adaptation', 2019, 1400000);
|
What is the average annual investment in climate adaptation for small island developing states (SIDS) in the Caribbean region between 2017 and 2021?
|
SELECT AVG(investment_amount) FROM climate_investment WHERE region = 'Caribbean SIDS' AND investment_type = 'Adaptation' AND year BETWEEN 2017 AND 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_cities (city_id INT, city_name VARCHAR(255), state VARCHAR(255), country VARCHAR(255), focus VARCHAR(255));
|
Insert a new record of a smart city initiative in the city of Berlin with a focus on energy efficiency.
|
INSERT INTO smart_cities (city_id, city_name, state, country, focus) VALUES (1, 'Smart City 1', 'Berlin', 'Germany', 'Energy Efficiency');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE NYCPublicTransportation (id INT, date DATE, mode VARCHAR(20), ridership INT);
|
What is the daily ridership of public transportation in New York City by mode?
|
SELECT mode, SUM(ridership) FROM NYCPublicTransportation WHERE date = '2022-03-01' GROUP BY mode;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE audience_demographics (user_id INT, age INT); INSERT INTO audience_demographics (user_id, age) VALUES (1, 25), (2, 45), (3, 35), (4, 19), (5, 60);
|
What is the distribution of audience demographics by age group in 'audience_demographics' table?
|
SELECT CASE WHEN age < 30 THEN '18-29' WHEN age < 45 THEN '30-44' WHEN age < 60 THEN '45-59' ELSE '60+' END AS age_group, COUNT(*) FROM audience_demographics GROUP BY age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_initiatives (id INT, initiative VARCHAR(255), species VARCHAR(255), region VARCHAR(255)); INSERT INTO conservation_initiatives (id, initiative, species, region) VALUES (1, 'Ice Cap Mapping', 'Polar Bear', 'Arctic'), (2, 'Beach Cleanup', 'Dolphin', 'Pacific'), (3, 'Coral Restoration', 'Clownfish', 'Indian'), (4, 'Fish Population Study', 'Cod', 'Atlantic'), (5, 'Ocean Floor Mapping', 'Seal', 'Arctic');
|
List all regions and their corresponding conservation initiatives.
|
SELECT region, initiative FROM conservation_initiatives;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (equipment_type VARCHAR(255), quantity INT);
|
What is the total number of military equipment records for each type in the military_equipment table?
|
SELECT equipment_type, SUM(quantity) FROM military_equipment GROUP BY equipment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diseases (disease_id INT, disease_name VARCHAR(50)); INSERT INTO diseases (disease_id, disease_name) VALUES (1, 'Disease A'), (2, 'Disease B'); CREATE TABLE counties (county_id INT, county_name VARCHAR(50), state_abbr CHAR(2), rural BOOLEAN); INSERT INTO counties (county_id, county_name, state_abbr, rural) VALUES (1, 'Rural County A', 'AK', true), (2, 'Urban County B', 'AL', false); CREATE TABLE disease_prevalence (disease_id INT, county_id INT, year INT, q1 FLOAT, q2 FLOAT, q3 FLOAT, q4 FLOAT);
|
Add new disease prevalence records for 2022 Q1-Q4 for a rural county.
|
INSERT INTO disease_prevalence (disease_id, county_id, year, q1, q2, q3, q4) VALUES (1, 1, 2022, 10.5, 11.3, 12.1, 12.9), (2, 1, 2022, 15.2, 16.1, 17.3, 18.2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TerbiumProduction (country VARCHAR(20), year INT, quantity INT); INSERT INTO TerbiumProduction (country, year, quantity) VALUES ('China', 2018, 120), ('China', 2019, 150);
|
What is the total production quantity of terbium in China for the year 2018?
|
SELECT SUM(quantity) FROM TerbiumProduction WHERE country = 'China' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics_sales (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN, country TEXT);
|
What are the most commonly purchased cruelty-free cosmetic products by consumers in the United States?
|
SELECT product_name FROM cosmetics_sales WHERE is_cruelty_free = TRUE AND country = 'United States' GROUP BY product_name ORDER BY COUNT(*) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lithium_mines (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO lithium_mines (id, name, location, depth) VALUES (1, 'Salar de Uyuni', 'Potosi, Bolivia', 360), (2, 'Salar de Coipasa', 'Oruro, Bolivia', 340), (3, 'Pozuelos', 'Oruro, Bolivia', 320);
|
What is the maximum depth of lithium mines in Bolivia?
|
SELECT MAX(depth) FROM lithium_mines WHERE location LIKE '%Bolivia%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (game_id INT, date DATE, team1 TEXT, team2 TEXT, points1 INT, points2 INT);
|
What is the average number of points scored by a team in a single NBA game?
|
SELECT AVG(points1 + points2) FROM games;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Mission_Table (id INT, mission_name VARCHAR(100), mission_success BOOLEAN);
|
What are the names of all the successful space missions?
|
SELECT MISSION_NAME FROM Space_Mission_Table WHERE MISSION_SUCCESS = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, donation_date DATE, donation_amount DECIMAL); INSERT INTO donations (id, donor_id, donation_date, donation_amount) VALUES (1, 1, '2019-01-01', 50.00), (2, 2, '2018-01-01', 100.00), (3, 3, '2019-12-31', 25.00);
|
What is the total amount of donations made in the year 2019?
|
SELECT SUM(donation_amount) FROM donations WHERE YEAR(donation_date) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), organic BOOLEAN, weight FLOAT, supplier_id INT);
|
Find the number of suppliers that supply organic products and their average weight.
|
SELECT s.name, COUNT(p.id) as num_suppliers, AVG(p.weight) as avg_weight FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id WHERE p.organic = 't' GROUP BY s.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE StreamingRevenue (id INT, year INT, quarter INT, genre VARCHAR(50), revenue FLOAT);
|
What is the total revenue generated by streaming platforms for Jazz music in Q1 2021?
|
SELECT SUM(revenue) FROM StreamingRevenue WHERE year = 2021 AND quarter = 1 AND genre = 'Jazz';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if NOT EXISTS animal_population (animal_id INT, animal_name VARCHAR(50), conservation_status VARCHAR(20)); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (1, 'Giant Panda', 'Vulnerable'); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (2, 'Tiger', 'Endangered'); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (3, 'Elephant', 'Vulnerable'); CREATE TABLE if NOT EXISTS animal_region (animal_id INT, habitat_id INT); INSERT INTO animal_region (animal_id, habitat_id) VALUES (1, 1); INSERT INTO animal_region (animal_id, habitat_id) VALUES (2, 2); INSERT INTO animal_region (animal_id, habitat_id) VALUES (3, 3);
|
What is the total number of animals in the animal_population table and the total number of habitats?
|
SELECT COUNT(*) FROM animal_population UNION ALL SELECT COUNT(DISTINCT habitat_id) FROM animal_region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE field3 (id INT, image_date DATE); INSERT INTO field3 (id, image_date) VALUES (1, '2021-10-20'), (2, '2021-10-22'), (3, '2021-10-25');
|
List all satellite images for 'field3' taken in the last week.
|
SELECT * FROM field3 WHERE image_date >= (CURRENT_DATE - INTERVAL '7 days');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE skincare_products (product VARCHAR(255), country VARCHAR(255), cruelty_free BOOLEAN); INSERT INTO skincare_products (product, country, cruelty_free) VALUES ('Cleanser', 'France', true), ('Moisturizer', 'USA', true), ('Exfoliant', 'Canada', false), ('Toner', 'Australia', true);
|
Which countries do our cruelty-free skincare products come from?
|
SELECT country FROM skincare_products WHERE cruelty_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy (id INT, type TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_energy (id, type, country, capacity) VALUES (1, 'Wind Turbine', 'Germany', 2.2), (2, 'Solar Panel', 'Spain', 3.2), (3, 'Hydroelectric Power Plant', 'Brazil', 4.5);
|
Delete all hydroelectric power plants in Brazil.
|
DELETE FROM renewable_energy WHERE type = 'Hydroelectric Power Plant' AND country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indigenous_communities (id INT PRIMARY KEY, community_name TEXT, members INT, year INT); CREATE VIEW community_members_max AS SELECT community_name, MAX(members) AS max_members FROM indigenous_communities WHERE year = 2030 GROUP BY community_name;
|
Find communities with member count higher than the maximum in 2030
|
SELECT community_name FROM indigenous_communities WHERE year = 2030 AND members > (SELECT max_members FROM community_members_max WHERE community_name = 'Sami');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Product (id INT, name VARCHAR(255), category VARCHAR(255), water_usage FLOAT, sale_date DATE);
|
What is the total water usage for each product category in the last year?
|
SELECT category, SUM(water_usage) as total_water_usage FROM Product WHERE sale_date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerFinancials (CustomerID INT, AccountType VARCHAR(20), Balance DECIMAL(10, 2)); INSERT INTO CustomerFinancials (CustomerID, AccountType, Balance) VALUES (1, 'Asset', 4000.00), (1, 'Liability', 1000.00), (2, 'Asset', 7000.00), (2, 'Liability', 2000.00);
|
What are the total assets and liabilities for each customer?
|
SELECT CustomerID, SUM(CASE WHEN AccountType = 'Asset' THEN Balance ELSE -Balance END) AS NetBalance FROM CustomerFinancials GROUP BY CustomerID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(100), word_count INT, publication_date DATE, category VARCHAR(50));
|
What is the maximum number of words in an article from the "investigative" category?
|
SELECT MAX(word_count) FROM articles WHERE category = 'investigative';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft (id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE, max_speed FLOAT);
|
What is the average speed of the fastest spacecraft launched each year?
|
SELECT EXTRACT(YEAR FROM launch_date) as launch_year, AVG(max_speed) as avg_speed FROM spacecraft WHERE max_speed = (SELECT MAX(max_speed) FROM spacecraft AS s WHERE spacecraft.launch_year = s.launch_year) GROUP BY launch_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonorID INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations (DonorID, DonationDate, Amount) VALUES (1, '2021-01-01', 500), (2, '2021-02-01', 300), (1, '2021-12-31', 700), (3, '2021-05-15', 400), (3, '2021-07-20', 200);
|
What is the average donation amount for each donor in 2021?
|
SELECT DonorID, AVG(Amount) as AvgDonation FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_pharmacy (id INT, name VARCHAR(50), location VARCHAR(100), satisfaction_score INT); INSERT INTO rural_pharmacy (id, name, location, satisfaction_score) VALUES (1, 'Pharmacy A', 'Rural Area 1', 95), (2, 'Pharmacy B', 'Rural Area 2', 88), (3, 'Pharmacy C', 'Rural Area 3', 98), (4, 'Pharmacy D', 'Rural Area 4', 82);
|
What is the name and location of the pharmacy with the highest patient satisfaction score in the 'rural_pharmacy' table?
|
SELECT name, location FROM rural_pharmacy WHERE satisfaction_score = (SELECT MAX(satisfaction_score) FROM rural_pharmacy);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_papers (id INT, author VARCHAR(50), country VARCHAR(50), title VARCHAR(100), publication_date DATE); INSERT INTO research_papers (id, author, country, title, publication_date) VALUES (1, 'John Doe', 'USA', 'AI Safety and Ethics', '2021-06-01'), (2, 'Jane Smith', 'Canada', 'Explainable AI for Safety-Critical Systems', '2020-12-15');
|
What's the total number of AI safety research papers published by US and Canadian authors?
|
SELECT COUNT(*) FROM research_papers WHERE country IN ('USA', 'Canada') AND (title LIKE '%AI safety%' OR title LIKE '%safe%critical%');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genetic_research (id INT, title VARCHAR(100), focus VARCHAR(50)); INSERT INTO genetic_research (id, title, focus) VALUES (1, 'Genetic Markers in Alzheimer''s Disease', 'neurodegenerative'); INSERT INTO genetic_research (id, title, focus) VALUES (2, 'Genomic Analysis of Parkinson''s Disease', 'neurodegenerative'); INSERT INTO genetic_research (id, title, focus) VALUES (3, 'Genetic Basis of Inherited Cancers', 'cancer');
|
Find genetic research data with a primary focus on neurodegenerative diseases.
|
SELECT * FROM genetic_research WHERE focus = 'neurodegenerative';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(50), price FLOAT, cruelty_free BOOLEAN); CREATE TABLE suppliers (id INT PRIMARY KEY, product_id INT, supplier_name VARCHAR(255), country VARCHAR(50), sustainability_score FLOAT);
|
How many cruelty-free products are supplied by countries with a sustainability score greater than 80?
|
SELECT COUNT(DISTINCT products.id) FROM products INNER JOIN suppliers ON products.id = suppliers.product_id WHERE products.cruelty_free = TRUE AND suppliers.sustainability_score > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_seoul (id INT, city VARCHAR(20), country VARCHAR(20), year INT, energy_consumption FLOAT); INSERT INTO energy_seoul (id, city, country, year, energy_consumption) VALUES (1, 'Seoul', 'South Korea', 2019, 12000), (2, 'Seoul', 'South Korea', 2020, 15000), (3, 'Seoul', 'South Korea', 2021, 16000);
|
What is the total energy consumption for smart city initiatives in Seoul, South Korea, per year?
|
SELECT year, SUM(energy_consumption) FROM energy_seoul WHERE city = 'Seoul' AND country = 'South Korea' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteManagement (District text, CollectionRating int, CollectionDate date); INSERT INTO WasteManagement (District, CollectionRating, CollectionDate) VALUES ('DistrictE', 90, '2022-06-15');
|
Insert a new record into the waste_management table with a collection rating of 90 for 'DistrictE' on '2022-06-15'?
|
INSERT INTO WasteManagement (District, CollectionRating, CollectionDate) VALUES ('DistrictE', 90, '2022-06-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE canada_provinces (province TEXT); INSERT INTO canada_provinces (province) VALUES ('Alberta'), ('British Columbia'), ('Ontario'); CREATE TABLE indigenous_communities (name TEXT, province TEXT); INSERT INTO indigenous_communities (name, province) VALUES ('Community1', 'Alberta'), ('Community2', 'British Columbia'), ('Community3', 'Ontario'); CREATE TABLE dental_clinics (name TEXT, community TEXT, province TEXT); INSERT INTO dental_clinics (name, community, province) VALUES ('Clinic1', 'Community1', 'Alberta'), ('Clinic2', 'Community2', 'British Columbia'), ('Clinic3', 'Community3', 'Ontario'), ('Clinic4', 'Community4', 'Alberta');
|
How many dental clinics serve indigenous communities in Canada?
|
SELECT COUNT(dc.name) AS num_dental_clinics FROM dental_clinics dc INNER JOIN indigenous_communities ic ON dc.community = ic.name INNER JOIN canada_provinces cp ON dc.province = cp.province WHERE ic.province = cp.province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_workers (id INT, name TEXT, salary REAL, is_rural BOOLEAN); INSERT INTO healthcare_workers (id, name, salary, is_rural) VALUES (1, 'John Doe', 60000, false), (2, 'Jane Smith', 45000, true); CREATE TABLE salary_adjustments (worker_id INT, adjustment REAL); INSERT INTO salary_adjustments (worker_id, adjustment) VALUES (1, 5000), (2, 0);
|
List the names and salaries of healthcare workers earning more than $50,000 in urban areas?
|
SELECT hw.name, (hw.salary + sa.adjustment) AS salary FROM healthcare_workers hw INNER JOIN salary_adjustments sa ON hw.id = sa.worker_id WHERE hw.is_rural = false AND (hw.salary + sa.adjustment) > 50000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BCFacilities (service VARCHAR(30), count INT, year INT); INSERT INTO BCFacilities (service, count, year) VALUES ('Public Schools', 800, 2022), ('Healthcare Facilities', 120, 2022);
|
How many public schools and healthcare facilities are there in British Columbia as of 2022?
|
SELECT service, count FROM BCFacilities WHERE year = 2022 AND service IN ('Public Schools', 'Healthcare Facilities');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, city VARCHAR(20), capacity INT); INSERT INTO warehouse (id, city, capacity) VALUES (1, 'Chicago', 1000), (2, 'Houston', 1500), (3, 'Miami', 800), (4, 'Los Angeles', 1200), (5, 'San Francisco', 1800); CREATE TABLE state (id INT, name VARCHAR(20)); INSERT INTO state (id, name) VALUES (1, 'California'), (2, 'Texas'), (3, 'Florida'); CREATE VIEW warehouse_state AS SELECT * FROM warehouse INNER JOIN state ON warehouse.id = state.id;
|
Update the capacities of all warehouses located in California
|
UPDATE warehouse_state SET capacity = 1500 WHERE name IN ('California');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, org_id INT); CREATE TABLE organizations (org_id INT, org_name TEXT);
|
Show the number of donors and total donation amount for each organization in the 'organizations' table.
|
SELECT organizations.org_name, COUNT(donors.donor_id) as num_donors, SUM(donors.donation_amount) as total_donations FROM donors INNER JOIN organizations ON donors.org_id = organizations.org_id GROUP BY organizations.org_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (project_name VARCHAR(255), project_type VARCHAR(255), completion_year INT); INSERT INTO rural_infrastructure (project_name, project_type, completion_year) VALUES ('Greenhouse Project', 'Agricultural Innovation', 2018), ('Drip Irrigation System', 'Agricultural Innovation', 2019), ('Rural Road Construction', 'Infrastructure', 2020);
|
How many rural infrastructure projects were completed per year in the 'rural_infrastructure' table?
|
SELECT completion_year, COUNT(*) FROM rural_infrastructure GROUP BY completion_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_tests (id INT PRIMARY KEY, company VARCHAR(255), brand VARCHAR(255), test_location VARCHAR(255), test_date DATE, safety_rating INT);
|
Show the average safety rating for each brand
|
SELECT brand, AVG(safety_rating) as avg_rating FROM safety_tests GROUP BY brand;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (country VARCHAR(255), capacity FLOAT); INSERT INTO landfill_capacity (country, capacity) VALUES ('Brazil', 6.8), ('Argentina', 2.1), ('Colombia', 1.7);
|
What is the total landfill capacity in South America?
|
SELECT SUM(capacity) FROM landfill_capacity WHERE country IN ('Brazil', 'Argentina', 'Colombia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE academic_publications (id INT, title VARCHAR(100), journal VARCHAR(50), publication_year INT); INSERT INTO academic_publications VALUES (1, 'Artificial Intelligence for Autonomous Systems', 'Journal of Machine Learning', 2018), (2, 'Deep Learning Techniques for Image Recognition', 'Journal of Machine Learning', 2019), (3, 'Reinforcement Learning in Robotics', 'IEEE Transactions on Robotics', 2018);
|
Delete all academic publications with a 'Journal of Machine Learning' that have a publication year of 2018.
|
DELETE FROM academic_publications WHERE journal = 'Journal of Machine Learning' AND publication_year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE strategies (id INT, investment_id INT, strategy VARCHAR(50)); INSERT INTO strategies (id, investment_id, strategy) VALUES (1, 1, 'Microfinance'), (2, 1, 'Sustainable Agriculture'), (3, 2, 'Green Energy'), (4, 3, 'Affordable Housing'); CREATE TABLE investment_scores (investment_id INT, esg_score FLOAT); INSERT INTO investment_scores (investment_id, esg_score) VALUES (1, 86.2), (2, 72.3), (3, 89.5);
|
List all unique investment strategies that have an ESG score greater than 85.
|
SELECT DISTINCT strategy FROM strategies JOIN investment_scores ON strategies.investment_id = investment_scores.investment_id WHERE investment_scores.esg_score > 85;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patents_granted_cardiovascular (patent_id INT, drug_name VARCHAR(255), therapeutic_area VARCHAR(255), patent_status VARCHAR(255)); INSERT INTO patents_granted_cardiovascular (patent_id, drug_name, therapeutic_area, patent_status) VALUES (1, 'DrugJ', 'Cardiovascular', 'Granted'), (2, 'DrugK', 'Cardiovascular', 'Pending'), (3, 'DrugJ', 'Cardiovascular', 'Granted'), (4, 'DrugL', 'Cardiovascular', 'Granted'), (5, 'DrugK', 'Cardiovascular', 'Pending'), (6, 'DrugL', 'Cardiovascular', 'Granted'), (7, 'DrugJ', 'Cardiovascular', 'Granted'), (8, 'DrugK', 'Cardiovascular', 'Granted');
|
Find the number of patents granted for each drug, ranked from the most patents to the least, in the cardiovascular therapeutic area?
|
SELECT drug_name, COUNT(*) as num_of_patents FROM patents_granted_cardiovascular WHERE therapeutic_area = 'Cardiovascular' AND patent_status = 'Granted' GROUP BY drug_name ORDER BY num_of_patents DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destinations (destination_id INT, name TEXT, type TEXT); INSERT INTO destinations (destination_id, name, type) VALUES (1, 'Parksville', 'Eco-friendly'), (2, 'Tofino', 'Eco-friendly'), (3, 'Vancouver', 'Urban'), (4, 'Whistler', 'Ski'), (5, 'Banff', 'Sustainable'), (6, 'Jasper', 'Sustainable');
|
How many destinations are there for each type of tourism?
|
SELECT type, COUNT(*) FROM destinations GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(20)); CREATE TABLE research_grants (faculty_id INT, grant_amount DECIMAL(10,2), department VARCHAR(20)); INSERT INTO faculty (id, name, department) VALUES (1, 'John Doe', 'Physics'), (2, 'Jane Smith', 'Mathematics'), (3, 'Mary Johnson', 'Physics'); INSERT INTO research_grants (faculty_id, grant_amount, department) VALUES (1, 15000.00, 'Physics'), (2, 20000.00, 'Mathematics'), (1, 10000.00, 'Mathematics');
|
Identify faculty members who have received research grants in both the 'Physics' and 'Mathematics' departments.
|
SELECT f.name FROM faculty f JOIN research_grants rg ON f.id = rg.faculty_id WHERE f.department = 'Physics' AND rg.department = 'Mathematics' GROUP BY f.name HAVING COUNT(DISTINCT rg.department) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameType VARCHAR(50), Age INT); INSERT INTO Players (PlayerID, PlayerName, GameType, Age) VALUES (1, 'John Doe', 'FPS', 25); INSERT INTO Players (PlayerID, PlayerName, GameType, Age) VALUES (2, 'Jane Smith', 'RPG', 30);
|
Calculate the average age of players who play FPS games
|
SELECT AVG(Age) FROM Players WHERE GameType = 'FPS';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hair_care_launches (id INT, product VARCHAR(50), launch_date DATE, country VARCHAR(50), vegan BOOLEAN); INSERT INTO hair_care_launches (id, product, launch_date, country, vegan) VALUES (1, 'Vegan Shampoo', '2021-02-15', 'Canada', TRUE);
|
Show the number of vegan hair care products launched in Canada each year.
|
SELECT EXTRACT(YEAR FROM launch_date) AS year, COUNT(*) FROM hair_care_launches WHERE country = 'Canada' AND vegan = TRUE GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accounts (id INT, customer_id INT, investment_risk VARCHAR(255), account_open_date DATE); INSERT INTO accounts (id, customer_id, investment_risk, account_open_date) VALUES (1, 1, 'high', '2022-01-01'), (2, 2, 'medium', '2022-01-15'), (3, 3, 'low', '2022-01-05'), (4, 4, 'high', '2022-01-30'), (5, 5, 'high', '2021-10-01');
|
What is the number of high-risk investment accounts opened in the last quarter?
|
SELECT COUNT(a.id) FROM accounts a WHERE a.investment_risk = 'high' AND a.account_open_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Satellites (Satellite_ID INT, Satellite_Name VARCHAR(100), Launch_Date DATE, Country_Name VARCHAR(50), Agency_Name VARCHAR(50)); INSERT INTO Space_Satellites (Satellite_ID, Satellite_Name, Launch_Date, Country_Name, Agency_Name) VALUES (1, 'Sat1', '2000-01-01', 'USA', 'NASA'), (2, 'Sat2', '2001-01-01', 'Russia', 'Roscosmos'), (3, 'Sat3', '2002-01-01', 'China', 'CNSA');
|
What is the total number of satellites launched by country in the Space_Satellites table?
|
SELECT Country_Name, COUNT(*) as Total_Satellites FROM Space_Satellites GROUP BY Country_Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vegan_sales(product_name TEXT, sales_volume INT, is_vegan BOOLEAN, country TEXT); INSERT INTO vegan_sales VALUES ('Lipstick', 500, true, 'Canada'); INSERT INTO vegan_sales VALUES ('Mascara', 300, true, 'Canada'); INSERT INTO vegan_sales VALUES ('Eyeshadow', 700, false, 'Canada');
|
What is the total sales volume of vegan makeup products sold in Canada?
|
SELECT SUM(sales_volume) FROM vegan_sales WHERE is_vegan = true AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount decimal(10,2), Country varchar(50)); INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (1, 'John Doe', 7000, 'USA'), (2, 'Jane Smith', 3000, 'Canada'), (3, 'Mike Johnson', 4000, 'USA'), (4, 'Emma Wilson', 8000, 'Canada');
|
update Donors set Donation_Amount = Donation_Amount * 1.10 where Donation_Amount > 5000
|
UPDATE Donors SET Donation_Amount = Donation_Amount * 1.10 WHERE Donation_Amount > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, name TEXT, city TEXT, is_eco_friendly BOOLEAN); INSERT INTO hotels (id, name, city, is_eco_friendly) VALUES (1, 'Eco Hotel Amsterdam', 'Amsterdam', TRUE), (2, 'Green Hotel Amsterdam', 'Amsterdam', TRUE);
|
How many eco-friendly hotels are there in Amsterdam?
|
SELECT COUNT(*) FROM hotels WHERE city = 'Amsterdam' AND is_eco_friendly = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WellExplorationCosts (well_id INT, drill_year INT, exploration_cost REAL); INSERT INTO WellExplorationCosts (well_id, drill_year, exploration_cost) VALUES (1, 2008, 2000000), (2, 2012, 3000000), (3, 2015, 1500000);
|
What is the highest exploration cost in the 'NorthSea' for wells drilled after 2010?
|
SELECT MAX(exploration_cost) FROM WellExplorationCosts WHERE region = 'NorthSea' AND drill_year > 2010
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Recycling_Centers_All (country VARCHAR(20), center_type VARCHAR(20)); INSERT INTO Recycling_Centers_All (country, center_type) VALUES ('US', 'Glass'), ('US', 'Paper'), ('Canada', 'Glass'), ('Mexico', 'Plastic'), ('US', 'Plastic'), ('Canada', 'Paper');
|
How many recycling centers are there in total for each center type?
|
SELECT center_type, COUNT(*) FROM Recycling_Centers_All GROUP BY center_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT, day VARCHAR(255), week INT, year INT); INSERT INTO production (id, country, element, quantity, day, week, year) VALUES (1, 'China', 'Samarium', 500, 'Monday', 1, 2021), (2, 'China', 'Samarium', 550, 'Tuesday', 1, 2021), (3, 'USA', 'Samarium', 400, 'Monday', 1, 2021), (4, 'USA', 'Samarium', 450, 'Tuesday', 1, 2021);
|
Determine the production quantity of Samarium for each day in the week, starting from Monday.
|
SELECT country, element, day, quantity FROM production WHERE element = 'Samarium' AND week = 1 AND day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') ORDER BY day;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, total_assets DECIMAL(10,2)); INSERT INTO customers (customer_id, total_assets) VALUES (1, 50000), (2, 75000), (3, 30000); CREATE TABLE investments (customer_id INT, stock_symbol VARCHAR(5), investment_amount DECIMAL(10,2)); INSERT INTO investments (customer_id, stock_symbol, investment_amount) VALUES (1, 'AAPL', 25000), (2, 'GOOG', 50000), (3, 'AAPL', 10000);
|
Find the total assets of all customers who have invested in stock 'AAPL'
|
SELECT SUM(total_assets) FROM customers INNER JOIN investments ON customers.customer_id = investments.customer_id WHERE investments.stock_symbol = 'AAPL';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, therapy TEXT, therapy_year INT); INSERT INTO patients (id, name, age, therapy, therapy_year) VALUES (1, 'Alice', 30, 'CBT', 2022), (2, 'Bob', 45, 'DBT', 2021), (3, 'Charlie', 63, 'CBT', 2018), (4, 'David', 50, 'CBT', 2022), (5, 'Eve', 55, 'DBT', 2019);
|
Update the therapy type to 'ACT' for patients who are over 60 years old.
|
UPDATE patients SET therapy = 'ACT' WHERE age > 60;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE emission (mine_id INT, year INT, co2_emission INT);
|
What is the total CO2 emission for each mine by year?
|
SELECT mine.name, emission.year, SUM(emission.co2_emission) FROM emission JOIN mine ON emission.mine_id = mine.id GROUP BY mine.name, emission.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mlb_2021 (player TEXT, team TEXT, home_run_distance FLOAT);
|
Find the top 5 longest home runs in the MLB in the 2021 season.
|
SELECT player, team, home_run_distance FROM mlb_2021 ORDER BY home_run_distance DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Leung Li', 'China'), (4, 'Kim Jae', 'South Korea');
|
How many unique donors are there from Asian countries?
|
SELECT COUNT(DISTINCT DonorID) FROM Donors WHERE Country IN ('China', 'South Korea', 'India', 'Japan', 'Indonesia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_ocean (species TEXT, ocean TEXT);
|
How many marine species are found in each ocean?
|
SELECT ocean, COUNT(species) FROM marine_species_ocean GROUP BY ocean;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, location VARCHAR(100)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'Marie Dubois', 42, 'France'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Pedro Gomez', 60, 'Spain'); CREATE TABLE Plots (id INT PRIMARY KEY, farmer_id INT, size FLOAT, crop VARCHAR(50)); INSERT INTO Plots (id, farmer_id, size, crop) VALUES (1, 1, 0.75, 'Grapes'); INSERT INTO Plots (id, farmer_id, size, crop) VALUES (2, 2, 1.5, 'Olives'); CREATE TABLE ClimateTypes (id INT PRIMARY KEY, country VARCHAR(50), climate_type VARCHAR(50)); INSERT INTO ClimateTypes (id, country, climate_type) VALUES (1, 'France', 'Mediterranean'); INSERT INTO ClimateTypes (id, country, climate_type) VALUES (2, 'Spain', 'Mediterranean');
|
List the names and crops of farmers who grow crops in regions with a Mediterranean climate?
|
SELECT f.name, p.crop FROM Farmers f INNER JOIN Plots p ON f.id = p.farmer_id INNER JOIN ClimateTypes c ON f.location = c.country WHERE c.climate_type = 'Mediterranean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), AmountDonated numeric(10,2)); INSERT INTO Donors VALUES (1, 'John Doe', 'USA', 500.00), (2, 'Jane Smith', 'Canada', 300.00);
|
What is the total amount donated by individual donors from the United States in 2021?
|
SELECT SUM(AmountDonated) FROM Donors WHERE Country = 'USA' AND YEAR(DonationDate) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_grants (id INT, faculty_id INT, grant_amount DECIMAL(10,2), department VARCHAR(50), grant_date DATE);
|
Calculate the total research grant funding awarded to the Physics department in the current fiscal year.
|
SET @fy_start := DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL MONTH(CURDATE()) - 7 MONTH), '%Y-%m-01'); SET @fy_end := DATE_FORMAT(LAST_DAY(CURDATE()), '%Y-%m-%d'); WITH phys_grants AS (SELECT * FROM research_grants WHERE department = 'Physics' AND grant_date BETWEEN @fy_start AND @fy_end) SELECT SUM(grant_amount) FROM phys_grants;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Platforms (platform_id INT, platform_name TEXT); CREATE TABLE AlbumSales (sale_id INT, platform_id INT, sales INT);
|
What is the average album sales per platform?
|
SELECT platform_name, AVG(sales) as avg_sales FROM Platforms JOIN AlbumSales ON Platforms.platform_id = AlbumSales.platform_id GROUP BY platform_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE individuals (id INT, country VARCHAR(255), age INT, financial_wellbeing_score INT);
|
What is the total financial wellbeing score for individuals in South America, aged 20-30?
|
SELECT SUM(financial_wellbeing_score) FROM individuals WHERE country = 'South America' AND age BETWEEN 20 AND 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_release (game VARCHAR(10), release_date DATE); CREATE TABLE player_join (player_id INT, join_date DATE, game VARCHAR(10)); INSERT INTO game_release (game, release_date) VALUES ('Game1', '2020-01-01'), ('Game2', '2019-01-01'); INSERT INTO player_join (player_id, join_date, game) VALUES (1, '2020-01-02', 'Game1'), (2, '2019-01-01', 'Game2'), (3, '2020-01-03', 'Game1');
|
What is the number of players who joined after a game was released, for each game?
|
SELECT game, COUNT(*) as num_players FROM player_join p JOIN game_release r ON p.game = r.game WHERE p.join_date > r.release_date GROUP BY game;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists(id INT, name VARCHAR(255), birthplace VARCHAR(255), art_style VARCHAR(255)); INSERT INTO Artists(id, name, birthplace, art_style) VALUES (1, 'Pablo Picasso', 'Málaga, Spain', 'Cubism'); INSERT INTO Artists(id, name, birthplace, art_style) VALUES (2, 'Salvador Dalí', 'Figueres, Spain', 'Surrealism'); CREATE TABLE Artworks(id INT, title VARCHAR(255), artist_id INT); INSERT INTO Artworks(id, title, artist_id) VALUES (1, 'Guernica', 1); INSERT INTO Artworks(id, title, artist_id) VALUES (2, 'The Persistence of Memory', 2);
|
What are the names and art styles of all artworks created by artists born in Spain?
|
SELECT Artworks.title, Artists.art_style FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.id WHERE Artists.birthplace = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities_2 (name VARCHAR(255), state VARCHAR(255), population DECIMAL(10,2), recycling_rate DECIMAL(5,2)); INSERT INTO cities_2 (name, state, population, recycling_rate) VALUES ('City1', 'California', 50000, 15), ('City2', 'Texas', 75000, 8), ('City3', 'Florida', 90000, 25);
|
Identify cities with a population under 100,000 and a recycling rate below 10%.
|
SELECT name FROM cities_2 WHERE population < 100000 AND recycling_rate < 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (id INT, name VARCHAR(100), city VARCHAR(50), state VARCHAR(20)); INSERT INTO policyholders (id, name, city, state) VALUES (1, 'John Doe', 'Seattle', 'WA'); CREATE TABLE claims (id INT, policyholder_id INT, amount DECIMAL(10, 2)); INSERT INTO claims (id, policyholder_id, amount) VALUES (1, 1, 500.00), (2, 1, 750.00);
|
What is the average claim amount for policyholders in the city of Seattle?
|
SELECT AVG(claims.amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.city = 'Seattle';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender) VALUES (1, 35, 'Female'), (2, 42, 'Male'), (3, 48, 'Non-binary');
|
What is the average age of community health workers by gender?
|
SELECT AVG(Age) as AvgAge, Gender FROM CommunityHealthWorkers GROUP BY Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE support_groups (id INT, name TEXT, location TEXT, facilitator_id INT, members INT, success_rate DECIMAL(3,2)); INSERT INTO support_groups (id, name, location, facilitator_id, members, success_rate) VALUES (1, 'Hopeful Minds', 'Los Angeles', 3, 12, 0.85); INSERT INTO support_groups (id, name, location, facilitator_id, members, success_rate) VALUES (2, 'Brave Hearts', 'San Francisco', 4, 8, 0.95); INSERT INTO support_groups (id, name, location, facilitator_id, members, success_rate) VALUES (3, 'Stronger Together', 'San Diego', 2, 10, 0.75);
|
What is the success rate of support groups in Los Angeles?
|
SELECT AVG(success_rate) FROM support_groups WHERE location = 'Los Angeles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ships (ship_id INT, ship_name VARCHAR(255), registration_date DATE); INSERT INTO ships VALUES (1, 'Sea Giant', '2010-03-23'), (2, 'Poseidon', '2012-09-08');
|
Update the registration date of the ship 'Poseidon' to '2015-01-01'
|
UPDATE ships SET registration_date = '2015-01-01' WHERE ship_name = 'Poseidon';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vehicles (Id INT, Name TEXT, Type TEXT, SafetyRating INT, ReleaseDate DATE); INSERT INTO Vehicles (Id, Name, Type, SafetyRating, ReleaseDate) VALUES (1, 'Model S', 'Electric', 5, '2016-06-22'), (2, 'Model 3', 'Electric', 5, '2017-07-28'), (3, 'Tesla Roadster', 'Electric', 4, '2008-03-16'), (4, 'Corvette', 'Gasoline', 2, '2014-09-18'), (5, 'F150', 'Gasoline', 3, '2015-03-31');
|
Delete all records of vehicles that have a safety rating below 3.
|
DELETE FROM Vehicles WHERE SafetyRating < 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (city VARCHAR(20), year INT, recycling_rate FLOAT);INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('San Francisco', 2019, 0.65), ('San Francisco', 2020, 0.7), ('San Francisco', 2021, 0.75), ('Oakland', 2019, 0.55), ('Oakland', 2020, 0.6), ('Oakland', 2021, 0.65);
|
Find the recycling rate for the city of Oakland in 2021
|
SELECT recycling_rate FROM recycling_rates WHERE city = 'Oakland' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Schools (region_id INT, meets_standard BOOLEAN); INSERT INTO Schools (region_id, meets_standard) VALUES (1, true), (1, false), (2, true), (2, true), (3, false), (3, true), (4, true), (4, true); CREATE TABLE Regions (id INT, name VARCHAR(50)); INSERT INTO Regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West');
|
What is the percentage of schools meeting environmental standards in each region?
|
SELECT R.name, (COUNT(S.id) * 100.0 / (SELECT COUNT(*) FROM Schools WHERE region_id = R.id)) as Percentage_Meeting_Standards FROM Schools S JOIN Regions R ON S.region_id = R.id WHERE S.meets_standard = true GROUP BY R.name;
|
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'); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10, 2)); INSERT INTO transactions (id, customer_id, amount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 300.00);
|
What is the average transaction amount for all customers from the United States?
|
SELECT AVG(t.amount) FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE c.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodations (id INT, name TEXT, country TEXT, rating FLOAT); INSERT INTO accommodations (id, name, country, rating) VALUES (1, 'Hotel Fasano Rio de Janeiro', 'Brazil', 4.7), (2, 'Belmond Copacabana Palace', 'Brazil', 4.6), (3, 'Hotel Emiliano Rio', 'Brazil', 4.5);
|
What is the minimum rating of accommodations in Brazil?
|
SELECT MIN(rating) FROM accommodations WHERE country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE charging_stations (station_id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO charging_stations (station_id, type, city) VALUES (1, 'Car', 'Madrid'), (2, 'Bike', 'Madrid'), (3, 'Bike', 'Madrid');
|
Add a new charging station in Madrid for electric cars.
|
INSERT INTO charging_stations (station_id, type, city) VALUES (4, 'Car', 'Madrid');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA gov_data;CREATE TABLE gov_data.budget_allocation (city VARCHAR(20), service VARCHAR(20), budget INT); INSERT INTO gov_data.budget_allocation (city, service, budget) VALUES ('Oakland', 'Education', 3000000), ('Oakland', 'Healthcare', 4000000);
|
What is the total budget allocated for education and healthcare services in the city of Oakland?
|
SELECT SUM(budget) FROM gov_data.budget_allocation WHERE city = 'Oakland' AND service IN ('Education', 'Healthcare');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE algorithmic_fairness_researchers (researcher_id INTEGER, researcher_name TEXT, research_count INTEGER);
|
Who are the algorithmic_fairness researchers and their respective research_counts?
|
SELECT researcher_name, research_count FROM algorithmic_fairness_researchers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Chicago Warehouse', 'north'), (2, 'Dallas Warehouse', 'south'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, state TEXT); INSERT INTO packages (id, warehouse_id, weight, state) VALUES (1, 1, 30.5, 'Illinois'), (2, 1, 22.3, 'Indiana'), (3, 2, 12.8, 'Texas');
|
Find the top 3 heaviest packages shipped from the 'north' region to any state.
|
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY weight DESC) as row_num FROM packages p JOIN warehouses w ON p.warehouse_id = w.id WHERE w.region = 'north') sub WHERE row_num <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (id INT, policy_id INT, claim_amount INT); INSERT INTO claims (id, policy_id, claim_amount) VALUES (1, 1, 1500), (2, 2, 2500), (3, 3, 3000); CREATE TABLE policies (id INT, state VARCHAR(2)); INSERT INTO policies (id, state) VALUES (1, 'NY'), (2, 'TX'), (3, 'CA');
|
What is the maximum claim amount for policies in 'NY'?
|
SELECT MAX(claim_amount) FROM claims JOIN policies ON claims.policy_id = policies.id WHERE policies.state = 'NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, name TEXT, price DECIMAL, country TEXT, product_type TEXT);
|
Decrease the price of all skincare products from the United Kingdom by 10%.
|
UPDATE products SET price = price * 0.9 WHERE country = 'United Kingdom' AND product_type = 'skincare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 78.3), (2, 'finance', 65.2), (3, 'technology', 81.5), (4, 'healthcare', 72.1);
|
Find companies in the 'technology' sector with an ESG score above 80.
|
SELECT * FROM companies WHERE sector = 'technology' AND ESG_score > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cyber_incidents (id INT, region VARCHAR(50), incident_type VARCHAR(50)); INSERT INTO cyber_incidents (id, region, incident_type) VALUES (1, 'North America', 'Data Breach'); INSERT INTO cyber_incidents (id, region, incident_type) VALUES (2, 'Europe', 'Phishing');
|
Find the total number of cybersecurity incidents in the North America region.
|
SELECT COUNT(*) FROM cyber_incidents WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name TEXT, country TEXT, founder_race TEXT, funding FLOAT); INSERT INTO startups(id, name, country, founder_race, funding) VALUES (1, 'StartupA', 'USA', 'African American', 500000), (2, 'StartupB', 'USA', 'Asian', 750000), (3, 'StartupC', 'USA', 'Hispanic', 250000), (4, 'StartupD', 'USA', 'White', 300000), (5, 'StartupE', 'USA', 'Native American', 150000);
|
What is the average funding received by startups founded by underrepresented racial groups in the USA?
|
SELECT founder_race, AVG(funding) FROM startups WHERE country = 'USA' GROUP BY founder_race;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, port_name VARCHAR(50), country VARCHAR(50), region VARCHAR(50), cargo_handling_violations INT); INSERT INTO ports (id, port_name, country, region, cargo_handling_violations) VALUES (1, 'Valencia', 'Spain', 'Mediterranean', 20), (2, 'Barcelona', 'Spain', 'Mediterranean', 15), (3, 'Piraeus', 'Greece', 'Mediterranean', 10);
|
What is the total number of cargo handling violations in the Mediterranean region?
|
SELECT SUM(cargo_handling_violations) FROM ports WHERE region = 'Mediterranean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RuralHealthFacility2 (patient_id INT, patient_name VARCHAR(50), age INT, diagnosis VARCHAR(20));
|
Insert a new patient 'Alice' with age 30 and diagnosis 'hypertension' into 'RuralHealthFacility2' table.
|
INSERT INTO RuralHealthFacility2 (patient_id, patient_name, age, diagnosis) VALUES (4, 'Alice', 30, 'hypertension');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (property_id INT, city VARCHAR(20), region VARCHAR(20), inclusive_policy BOOLEAN); INSERT INTO properties (property_id, city, region, inclusive_policy) VALUES (1, 'Nairobi', 'Africa', true), (2, 'Cape Town', 'Africa', false), (3, 'Nairobi', 'Africa', true);
|
How many properties are there in each city with inclusive housing policies in Africa?
|
SELECT city, COUNT(*) as count_of_properties FROM properties WHERE inclusive_policy = true AND region = 'Africa' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ratings_by_genre (title VARCHAR(255), rating FLOAT, genre VARCHAR(255)); INSERT INTO ratings_by_genre (title, rating, genre) VALUES ('The Sopranos', 9.2, 'Crime'), ('The Big Bang Theory', 6.8, 'Comedy');
|
Which genres have the highest and lowest average ratings?
|
SELECT genre, AVG(rating) AS avg_rating FROM ratings_by_genre GROUP BY genre ORDER BY avg_rating DESC, genre ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE billing (id INT, case_id INT, attorney_id INT, hours_worked INT, billable_rate DECIMAL(10,2)); INSERT INTO billing (id, case_id, attorney_id, hours_worked, billable_rate) VALUES (1, 1, 1, 15, 200.00); INSERT INTO billing (id, case_id, attorney_id, hours_worked, billable_rate) VALUES (2, 2, 2, 20, 250.00); CREATE TABLE attorneys (id INT, name VARCHAR(50), cases_handled INT, region VARCHAR(50), billable_rate DECIMAL(10,2)); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (1, 'John Lee', 40, 'Northeast', 200.00); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (2, 'Jane Doe', 50, 'Southwest', 250.00);
|
Get the total billing for each attorney by region
|
SELECT a.region, SUM(b.hours_worked * b.billable_rate) as total_billing FROM attorneys a JOIN billing b ON a.id = b.attorney_id GROUP BY a.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibition_statistics (exhibit_id INT, attendance INT); CREATE TABLE visitor_demographics (age INT, gender VARCHAR(10));
|
list all tables and their columns
|
SELECT table_name, column_name FROM information_schema.columns;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists us_east (region varchar(10), technology varchar(10), capacity numeric); INSERT INTO us_east (region, technology, capacity) VALUES ('us_east', 'wind', 8000), ('us_east', 'solar', 9000), ('us_east', 'hydro', 12000);
|
List the energy sources and their capacities for the us_east region.
|
SELECT technology, capacity FROM us_east;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MuseumOperations (id INT, revenue DECIMAL(10,2), expense DECIMAL(10,2));
|
What are the total revenues and expenses for museum operations in the 'MuseumOperations' table?
|
SELECT SUM(revenue) as total_revenue, SUM(expense) as total_expense FROM MuseumOperations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fertilizer_application (application_id INT, application_timestamp TIMESTAMP, fertilizer_type TEXT, application_rate FLOAT);
|
Update the "application_rate" in the "fertilizer_application" table where the "application_id" is 2 to 3.5
|
UPDATE fertilizer_application SET application_rate = 3.5 WHERE application_id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (country VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (country, year, recycling_rate) VALUES ('India', 2018, 0.25), ('India', 2019, 0.30);
|
What is the recycling rate for country 'India' in 2018?
|
SELECT recycling_rate FROM recycling_rates WHERE country = 'India' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TicketRevenue (id INT, visitor_id INT, community_id INT, revenue FLOAT); INSERT INTO TicketRevenue (id, visitor_id, community_id, revenue) VALUES (1, 101, 1, 15.5), (2, 102, 1, 12.3), (3, 103, 2, 21.0);
|
What was the total revenue from exhibition tickets for underrepresented communities in 2020?
|
SELECT SUM(TicketRevenue.revenue) FROM TicketRevenue INNER JOIN Communities ON TicketRevenue.community_id = Communities.id WHERE Communities.community_type = 'Underrepresented' AND TicketRevenue.id IN (SELECT visitor_id FROM Visitors WHERE year = 2020);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tour_stats (hotel_id INT, num_unique_users INT);
|
Add new records to virtual_tour_stats_table for hotel_id 1001, 1002, and 1003, with 50, 30, and 70 unique users respectively
|
INSERT INTO virtual_tour_stats (hotel_id, num_unique_users) VALUES (1001, 50), (1002, 30), (1003, 70);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_records (record_id INT, product_id INT, incident_location TEXT, incident_date DATE); INSERT INTO safety_records (record_id, product_id, incident_location, incident_date) VALUES (1, 1, 'Germany', '2021-05-01'), (2, 3, 'France', '2021-03-15'), (3, 2, 'UK', '2021-07-20');
|
Count the number of product safety incidents in the European Union.
|
SELECT COUNT(*) FROM safety_records WHERE incident_location IN ('Germany', 'France', 'UK');
|
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.