context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE SCHEMA Space;CREATE TABLE Space.SpaceExplorationResearch (country VARCHAR(50), mission_result VARCHAR(10));INSERT INTO Space.SpaceExplorationResearch (country, mission_result) VALUES ('USA', 'Success'), ('USA', 'Success'), ('China', 'Success'), ('Russia', 'Failure'), ('Russia', 'Success'), ('India', 'Success'), ('India', 'Failure'), ('Brazil', 'Success'), ('Brazil', 'Success');
|
What is the total number of space missions and the percentage of successful missions by country?
|
SELECT country, COUNT(*) AS total_missions, 100.0 * SUM(CASE WHEN mission_result = 'Success' THEN 1 ELSE 0 END) / COUNT(*) AS success_percentage FROM Space.SpaceExplorationResearch GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_members (id INT, date DATE, industry VARCHAR(255), member_count INT); INSERT INTO union_members (id, date, industry, member_count) VALUES (1, '2021-01-01', 'healthcare', 500), (2, '2021-02-01', 'healthcare', 550), (3, '2021-03-01', 'healthcare', 600);
|
What is the maximum number of union members in the 'healthcare' schema for any given month in '2021'?
|
SELECT MAX(member_count) FROM union_members WHERE industry = 'healthcare' AND date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VolumeCategory (VolumeCategoryID INT, VolumeRange VARCHAR(50), LowerLimit INT, UpperLimit INT); INSERT INTO VolumeCategory (VolumeCategoryID, VolumeRange, LowerLimit, UpperLimit) VALUES (1, 'up to 10000', 0, 10000); INSERT INTO VolumeCategory (VolumeCategoryID, VolumeRange, LowerLimit, UpperLimit) VALUES (2, '10000-50000', 10000, 50000);
|
What is the rank of each cargo by volume category?
|
SELECT CargoName, Weight, RANK() OVER (PARTITION BY vc.VolumeCategoryID ORDER BY Weight DESC) as Rank FROM Cargo c JOIN VolumeCategory vc ON c.Weight BETWEEN vc.LowerLimit AND vc.UpperLimit;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (site_id INT, site_name TEXT, country TEXT); INSERT INTO heritage_sites (site_id, site_name, country) VALUES (1, 'Brandenburg Gate', 'Germany'), (2, 'Schönbrunn Palace', 'Austria'), (3, 'Jungfrau-Aletsch', 'Switzerland');
|
How many cultural heritage sites are there in Germany, Austria, and Switzerland?
|
SELECT COUNT(*) FROM heritage_sites WHERE country IN ('Germany', 'Austria', 'Switzerland');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon (forest_id INT, year INT, sequestration FLOAT);
|
Find the total carbon sequestration in 2020 in the 'carbon' table.
|
SELECT SUM(sequestration) FROM carbon WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT PRIMARY KEY, event_name VARCHAR(100), event_type VARCHAR(50), num_tickets_sold INT);
|
How many total tickets were sold for each type of event in the 'events' table?
|
SELECT event_type, SUM(num_tickets_sold) AS total_tickets_sold FROM events GROUP BY event_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_observations (id INTEGER, species TEXT, location TEXT); INSERT INTO marine_species_observations (id, species, location) VALUES (1, 'Clownfish', 'Coral Triangle'), (2, 'Sea Turtle', 'Coral Triangle'), (3, 'Dolphin', 'Coral Triangle');
|
What is the total number of marine species observed in the Coral Triangle?
|
SELECT COUNT(*) FROM marine_species_observations WHERE location = 'Coral Triangle';
|
gretelai_synthetic_text_to_sql
|
diversity_metrics
|
Show the total number of employees by ethnicity
|
SELECT ethnicity, COUNT(*) as total_employees FROM diversity_metrics GROUP BY ethnicity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contributors (id INT, name VARCHAR(50), donation INT, location VARCHAR(50)); INSERT INTO contributors (id, name, donation, location) VALUES (1, 'Anne Smith', 15000, 'Europe'), (2, 'Bob Johnson', 12000, 'Europe'), (3, 'Charlotte Lee', 10000, 'Europe');
|
Who are the top 3 contributors to heritage site conservation efforts in 'Europe'?
|
SELECT name, donation FROM contributors WHERE location = 'Europe' ORDER BY donation DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_initiatives(region VARCHAR(10), year INT, initiative VARCHAR(20)); INSERT INTO circular_initiatives VALUES('Africa', 2015, 'Waste-to-Energy'), ('Asia', 2016, 'Recycling program'), ('Africa', 2016, 'Composting program'), ('Europe', 2017, 'Product reuse'), ('Africa', 2018, 'Plastic reduction campaign');
|
How many circular economy initiatives were launched in 'Africa' since 2015?
|
SELECT COUNT(*) FROM circular_initiatives WHERE region = 'Africa' AND year >= 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, type VARCHAR(255), imo INT); CREATE TABLE speeds (id INT, vessel_id INT, speed FLOAT);
|
What is the minimum speed for each vessel type?
|
SELECT v.type, MIN(s.speed) as min_speed FROM speeds s JOIN vessels v ON s.vessel_id = v.id GROUP BY v.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Articles (id INT, title VARCHAR(255), publisher VARCHAR(100), publication_year INT, topic VARCHAR(50)); INSERT INTO Articles (id, title, publisher, publication_year, topic) VALUES (1, 'Article1', 'The New York Times', 2019, 'climate'), (2, 'Article2', 'The Washington Post', 2018, 'politics'), (3, 'Article3', 'The New York Times', 2017, 'sports');
|
How many articles were published by "The New York Times" in 2019 having the word 'climate' in the title?
|
SELECT COUNT(*) FROM Articles WHERE publisher = 'The New York Times' AND publication_year = 2019 AND topic = 'climate';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE reaction (id INT, chemical_1 VARCHAR(255), chemical_2 VARCHAR(255), reaction_type VARCHAR(255)); INSERT INTO reaction (id, chemical_1, chemical_2, reaction_type) VALUES (1, 'Sodium Hydroxide', 'Hydrochloric Acid', 'Neutralization'), (2, 'Sodium Hydroxide', 'Acetic Acid', 'Neutralization'), (3, 'Hydrochloric Acid', 'Sodium Carbonate', 'Acid-Base Reaction'); INSERT INTO reaction_record (id, reaction_id, record_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-01-02'), (3, 2, '2022-01-03'), (4, 3, '2022-01-04'), (5, 1, '2022-01-05');
|
List all chemical reactions involving 'Sodium Hydroxide' and 'Hydrochloric Acid', along with their reaction types, and the number of times they have been performed.
|
SELECT r.reaction_type, r.chemical_1, r.chemical_2, COUNT(rr.id) as num_reactions FROM reaction r INNER JOIN reaction_record rr ON r.id = rr.reaction_id WHERE (r.chemical_1 = 'Sodium Hydroxide' AND r.chemical_2 = 'Hydrochloric Acid') OR (r.chemical_1 = 'Hydrochloric Acid' AND r.chemical_2 = 'Sodium Hydroxide') GROUP BY r.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramName VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Programs (ProgramName, Budget) VALUES ('Education', 15000.00), ('Healthcare', 22000.00), ('Arts', 10000.00);
|
What are the names of the programs that have a budget greater than the average program budget?
|
SELECT ProgramName FROM Programs WHERE Budget > (SELECT AVG(Budget) FROM Programs);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_mammals (name VARCHAR(255), species VARCHAR(255), location VARCHAR(255)); INSERT INTO marine_mammals (name, species, location) VALUES ('Beluga Whale', 'Whale', 'Arctic'), ('Polar Bear', 'Bear', 'Arctic');
|
List the names and locations of all marine mammal species in the Arctic.
|
SELECT name, location FROM marine_mammals WHERE location = 'Arctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garments (id INT PRIMARY KEY, category VARCHAR(255)); CREATE TABLE sales (id INT PRIMARY KEY, garment_id INT, date DATE, quantity INT, price DECIMAL(5,2)); ALTER TABLE sales ADD FOREIGN KEY (garment_id) REFERENCES garments(id);
|
What is the average price of garments, grouped by category, for those categories that have a total revenue greater than $100,000?
|
SELECT garments.category, AVG(sales.price) as avg_price FROM garments INNER JOIN sales ON garments.id = sales.garment_id GROUP BY garments.category HAVING SUM(sales.quantity*sales.price) > 100000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tech_for_social_good (project_name VARCHAR(255), budget_remaining FLOAT, start_date DATE);
|
For the tech_for_social_good table, return the project_name and budget_remaining for the row with the latest start_date, in descending order.
|
SELECT project_name, budget_remaining FROM tech_for_social_good WHERE start_date = (SELECT MAX(start_date) FROM tech_for_social_good);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (city_id INT, city_name VARCHAR(255)); INSERT INTO cities VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR(255), city_id INT); INSERT INTO hospitals VALUES (1, 'Hospital1', 1), (2, 'Hospital2', 2); CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(255), city_id INT); INSERT INTO clinics VALUES (1, 'Clinic1', 1), (2, 'Clinic2', 2);
|
What is the number of hospitals and clinics in each city?
|
SELECT cities.city_name, COUNT(hospitals.hospital_id) AS hospitals, COUNT(clinics.clinic_id) AS clinics FROM cities LEFT JOIN hospitals ON cities.city_id = hospitals.city_id LEFT JOIN clinics ON cities.city_id = clinics.city_id GROUP BY cities.city_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ports (PortID INT, PortName VARCHAR(50)); CREATE TABLE Visits (VisitID INT, PortID INT, VisitDate DATE); INSERT INTO Ports (PortID, PortName) VALUES (1, 'PortA'), (2, 'PortB'), (3, 'PortC'); INSERT INTO Visits (VisitID, PortID, VisitDate) VALUES (1, 1, '2022-01-05'), (2, 1, '2022-01-10'), (3, 2, '2022-01-15'), (4, 3, '2022-01-20');
|
List the ports and the number of vessels that visited each port in the last month
|
SELECT PortName, COUNT(*) FROM Ports INNER JOIN Visits ON Ports.PortID = Visits.PortID WHERE VisitDate >= DATEADD(month, -1, GETDATE()) GROUP BY PortName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT); INSERT INTO farmers (id, name, age) VALUES (1, 'James Brown', 45); INSERT INTO farmers (id, name, age) VALUES (2, 'Sara Johnson', 50); INSERT INTO farmers (id, name, age) VALUES (3, 'Maria Garcia', 55); INSERT INTO farmers (id, name, age) VALUES (4, 'David White', 60); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT, farmer_id INT, PRIMARY KEY (id), FOREIGN KEY (farmer_id) REFERENCES farmers(id)); INSERT INTO crops (id, name, yield, farmer_id) VALUES (1, 'Corn', 200, 1); INSERT INTO crops (id, name, yield, farmer_id) VALUES (2, 'Wheat', 150, 2); INSERT INTO crops (id, name, yield, farmer_id) VALUES (3, 'Rice', 100, 1); INSERT INTO crops (id, name, yield, farmer_id) VALUES (4, 'Soybean', 120, 3); INSERT INTO crops (id, name, yield, farmer_id) VALUES (5, 'Cotton', 80, 3); INSERT INTO crops (id, name, yield, farmer_id) VALUES (6, 'Barley', 180, 4);
|
Who are the top 3 farmers in terms of total crop yield?
|
SELECT farmers.name, SUM(crops.yield) as total_yield FROM farmers INNER JOIN crops ON farmers.id = crops.farmer_id GROUP BY farmers.name ORDER BY total_yield DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workouts (id INT, user_location VARCHAR(50), workout_date DATE, avg_heart_rate INT); INSERT INTO workouts (id, user_location, workout_date, avg_heart_rate) VALUES (1, 'Tokyo', '2022-04-01', 130), (2, 'Tokyo', '2022-04-02', 110);
|
How many users in Tokyo have a heart rate over 120 during their workouts in April 2022?
|
SELECT COUNT(*) FROM workouts WHERE user_location = 'Tokyo' AND avg_heart_rate > 120 AND workout_date BETWEEN '2022-04-01' AND '2022-04-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transparency_initiatives (initiative_date DATE, initiative_type VARCHAR(20)); INSERT INTO transparency_initiatives (initiative_date, initiative_type) VALUES ('2021-01-01', 'Fiscal Transparency'), ('2021-02-01', 'Open Data'), ('2021-03-01', 'Public Participation');
|
What is the total number of government transparency initiatives in the last 2 years?
|
SELECT COUNT(*) FROM transparency_initiatives WHERE initiative_date >= DATEADD(year, -2, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Player (Player_ID INT, Name VARCHAR(50), Date_Joined DATE); INSERT INTO Player (Player_ID, Name, Date_Joined) VALUES (1, 'John Doe', '2019-06-15'), (2, 'Jane Smith', '2020-03-08'), (3, 'Alice Johnson', '2021-02-22');
|
Add a new column 'Age' to the 'Player' table and calculate it based on the 'Date_Joined' column
|
ALTER TABLE Player ADD Age INT; UPDATE Player SET Age = DATEDIFF(year, Date_Joined, GETDATE()) FROM Player;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50), event VARCHAR(50)); INSERT INTO athletes (id, name, age, sport, event) VALUES (1, 'John Doe', 25, 'Athletics', 'Olympics'), (2, 'Jane Smith', 30, 'Swimming', 'Commonwealth Games'), (3, 'Richard Roe', 28, 'Athletics', 'Commonwealth Games');
|
Find the average age of athletes participating in the Olympics and Commonwealth Games.
|
SELECT AVG(age) FROM athletes WHERE event IN ('Olympics', 'Commonwealth Games');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE refugee_support(id INT, age INT, location VARCHAR(255)); INSERT INTO refugee_support(id, age, location) VALUES (1, 10, 'Syria'), (2, 25, 'Iraq'), (3, 12, 'Syria');
|
How many refugee children are there in the 'refugee_support' table for 'Syria'?
|
SELECT COUNT(*) FROM refugee_support WHERE location = 'Syria' AND age < 18;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE returns (id INT, date DATE, store VARCHAR(50), days_to_process INT);
|
What is the average number of days it takes to process a return, for each store, in the past month?
|
SELECT store, AVG(days_to_process) as avg_days_to_process FROM returns WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY store;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE device_vulnerabilities (id INT, device_id INT, device_type VARCHAR(255), vulnerability_type VARCHAR(255), year INT); INSERT INTO device_vulnerabilities (id, device_id, device_type, vulnerability_type, year) VALUES (1, 1, 'Laptop', 'SQL Injection', 2021), (2, 1, 'Laptop', 'Cross-site Scripting', 2021), (3, 2, 'Desktop', 'SQL Injection', 2021), (4, 3, 'Laptop', 'Phishing', 2021), (5, 3, 'Server', 'SQL Injection', 2021), (6, 4, 'Mobile', 'Phishing', 2021), (7, 4, 'Tablet', 'Cross-site Scripting', 2021), (8, 5, 'Server', 'SQL Injection', 2021);
|
What is the number of unique devices affected by each vulnerability type in the last year?
|
SELECT vulnerability_type, COUNT(DISTINCT device_id) as unique_devices FROM device_vulnerabilities WHERE year = 2021 GROUP BY vulnerability_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_power_projects (id INT, name TEXT, country TEXT, investment_usd FLOAT); INSERT INTO wind_power_projects (id, name, country, investment_usd) VALUES (1, 'São Vitor Wind Farm', 'Brazil', 250.0);
|
Find the number of wind power projects in India, Brazil, and South Africa with an investment over 200 million dollars.
|
SELECT COUNT(*) FROM wind_power_projects WHERE country IN ('India', 'Brazil', 'South Africa') AND investment_usd > 200000000.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT, brand_name TEXT, is_cruelty_free BOOLEAN, country TEXT); INSERT INTO brands (brand_id, brand_name, is_cruelty_free, country) VALUES (1, 'Lush', TRUE, 'USA'), (2, 'The Body Shop', TRUE, 'UK'), (3, 'Estee Lauder', FALSE, 'USA');
|
What are the top 3 cruelty-free cosmetic brands by total sales in the USA?
|
SELECT brand_name, SUM(sales) as total_sales FROM brands JOIN sales_data ON brands.brand_id = sales_data.brand_id WHERE country = 'USA' AND is_cruelty_free = TRUE GROUP BY brand_name ORDER BY total_sales DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Freight (id INT, item VARCHAR(50), weight FLOAT, country VARCHAR(50)); INSERT INTO Freight (id, item, weight, country) VALUES (1, 'Gizmo', 15.3, 'Canada'), (2, 'Gadget', 22.8, 'Australia');
|
What is the total weight of freight forwarded from Canada to Australia?
|
SELECT SUM(weight) FROM Freight f1 INNER JOIN Freight f2 ON f1.item = f2.item WHERE f1.country = 'Canada' AND f2.country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (ID INT, MissionName VARCHAR(50), Success BOOLEAN); INSERT INTO SpaceMissions VALUES (1, 'Apollo 11', true), (2, 'Apollo 13', false);
|
List all space missions that failed
|
SELECT * FROM SpaceMissions WHERE Success = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_sentiment (date DATE, sentiment INT); INSERT INTO consumer_sentiment (date, sentiment) VALUES ('2022-01-01', 75), ('2022-01-02', 78), ('2022-01-03', 82), ('2022-02-01', 80), ('2022-02-02', 85), ('2022-02-03', 88), ('2022-03-01', 90), ('2022-03-02', 92), ('2022-03-03', 95);
|
Identify the consumer sentiment trend for ethical fashion in the last 3 months.
|
SELECT date, sentiment, LAG(sentiment, 2) OVER (ORDER BY date) as lagged_sentiment FROM consumer_sentiment;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE humanitarian_assistance (id INT, quarter INT, year INT, amount FLOAT); INSERT INTO humanitarian_assistance (id, quarter, year, amount) VALUES (1, 1, 2018, 125000), (2, 1, 2019, 137500), (3, 1, 2020, 150000), (4, 2, 2020, 162500), (5, 3, 2020, 175000), (6, 4, 2020, 187500);
|
What is the average amount of humanitarian assistance provided per quarter in 2020?
|
SELECT AVG(amount) FROM humanitarian_assistance WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pharmacotherapy (pharmacotherapy_id INT, patient_id INT, condition VARCHAR(50), country VARCHAR(50), num_sessions INT); INSERT INTO pharmacotherapy (pharmacotherapy_id, patient_id, condition, country, num_sessions) VALUES (1, 15, 'Depression', 'France', 4), (2, 16, 'Depression', 'France', 6), (3, 17, 'Depression', 'France', 5);
|
What is the minimum number of pharmacotherapy sessions attended by patients with depression in France?
|
SELECT MIN(num_sessions) FROM pharmacotherapy WHERE country = 'France' AND condition = 'Depression';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE permit_delay_north (delay_id INT, region VARCHAR(50), project_type VARCHAR(50), delay INT); INSERT INTO permit_delay_north (delay_id, region, project_type, delay) VALUES (1, 'North', 'Residential', 5);
|
What is the minimum permit issuance delay in the North region for residential projects?
|
SELECT MIN(delay) FROM permit_delay_north WHERE region = 'North' AND project_type = 'Residential';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50), capacity INT); INSERT INTO hospitals (id, name, location, capacity) VALUES (7, 'Nairobi Hospital', 'Nairobi', 600); CREATE TABLE patient_vaccinations (id INT, hospital_id INT, patient_id INT, date DATE); INSERT INTO patient_vaccinations (id, hospital_id, patient_id, date) VALUES (7, 7, 7, '2022-03-01');
|
List hospitals in Nairobi with their capacity and the number of patients vaccinated at each.
|
SELECT hospitals.name, hospitals.capacity, COUNT(patient_vaccinations.patient_id) FROM hospitals LEFT JOIN patient_vaccinations ON hospitals.id = patient_vaccinations.hospital_id WHERE hospitals.location = 'Nairobi' GROUP BY hospitals.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE auto_sales (id INT, manufacturer VARCHAR(20), sale_type VARCHAR(10), vehicle_type VARCHAR(10)); INSERT INTO auto_sales (id, manufacturer, sale_type, vehicle_type) VALUES (1, 'Tesla', 'Sold', 'EV'), (2, 'Toyota', 'Leased', 'Hybrid'), (3, 'Tesla', 'Sold', 'EV'), (4, 'Nissan', 'Leased', 'EV');
|
Find the number of electric cars sold, leased, and total for each manufacturer in the 'auto_sales' table.
|
SELECT manufacturer, COUNT(*) FILTER (WHERE sale_type = 'Sold' AND vehicle_type = 'EV') AS sold, COUNT(*) FILTER (WHERE sale_type = 'Leased' AND vehicle_type = 'EV') AS leased, COUNT(*) AS total FROM auto_sales GROUP BY manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE reporters (id INT, name VARCHAR(255), gender VARCHAR(10), age INT, country VARCHAR(100)); CREATE TABLE investigative_projects (id INT, title VARCHAR(255), reporter_id INT, status VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO reporters (id, name, gender, age, country) VALUES (3, 'Alex Garcia', 'Male', 32, 'Mexico'); INSERT INTO investigative_projects (id, title, reporter_id, status, start_date, end_date) VALUES (3, 'The Hidden Truth', 3, 'In Progress', '2022-02-01', '2023-01-31');
|
Which male reporters aged 30 or above are assigned to investigative projects?
|
SELECT reporters.name, reporters.gender, reporters.age FROM reporters INNER JOIN investigative_projects ON reporters.id = investigative_projects.reporter_id WHERE reporters.gender = 'Male' AND reporters.age >= 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Projects (id, name, type, budget) VALUES (1, 'Seawall', 'Resilience', 5000000.00), (2, 'Floodgate', 'Resilience', 3000000.00), (3, 'Bridge', 'Transportation', 8000000.00), (4, 'Highway', 'Transportation', 12000000.00);
|
What is the maximum budget for all projects in the infrastructure development database?
|
SELECT MAX(budget) FROM Projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, year INT, country VARCHAR(50), equipment VARCHAR(50), value FLOAT); INSERT INTO MilitaryEquipmentSales (id, year, country, equipment, value) VALUES (1, 2022, 'USA', 'Ships', 50000000);
|
What is the maximum value of military equipment sold in a single transaction?
|
SELECT MAX(value) FROM MilitaryEquipmentSales;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, student_name VARCHAR(50), school_id INT); INSERT INTO students (student_id, student_name, school_id) VALUES (1, 'John Doe', 1001), (2, 'Jane Smith', 1001), (3, 'Mike Johnson', 1002); CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), school_id INT); INSERT INTO teachers (teacher_id, teacher_name, school_id) VALUES (1, 'Alice Brown', 1001), (2, 'David Lee', 1001), (3, 'Emily White', 1002);
|
What is the number of students and teachers in each school?
|
SELECT school_id, COUNT(DISTINCT s.student_id) as student_count, COUNT(DISTINCT t.teacher_id) as teacher_count FROM students s FULL OUTER JOIN teachers t ON s.school_id = t.school_id GROUP BY school_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE South_LS (statistic VARCHAR(30), frequency INT); INSERT INTO South_LS VALUES ('Hourly wage', 5000), ('Overtime hours', 3000), ('Safety incidents', 1500);
|
Rank the top 3 construction labor statistics by frequency in the South?
|
SELECT statistic, ROW_NUMBER() OVER (ORDER BY frequency DESC) as rank FROM South_LS WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmTemperature (farm_id INT, date DATE, temperature DECIMAL(5,2)); INSERT INTO FarmTemperature (farm_id, date, temperature) VALUES (1, '2022-03-01', 26.2), (1, '2022-03-02', 26.3);
|
What is the average water temperature for the Tilapia farm in the last 7 days?
|
SELECT AVG(temperature) avg_temp FROM FarmTemperature WHERE farm_id = 1 AND date >= (SELECT DATEADD(day, -7, GETDATE()));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (id INT, student_id INT, issue VARCHAR(50), severity VARCHAR(50));
|
What is the most common severity of mental health issues reported in the student_mental_health table?
|
SELECT severity, COUNT(*) FROM student_mental_health GROUP BY severity ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE enrollment (id INT, student_id INT, department VARCHAR(50)); INSERT INTO enrollment (id, student_id, department) VALUES (1, 1, 'Computer Science'), (2, 2, 'Computer Science'), (3, 3, 'Mathematics'), (4, 4, 'Physics');
|
How many students are enrolled in each department?
|
SELECT department, COUNT(DISTINCT student_id) FROM enrollment GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE visitors (id INT, country VARCHAR(255), exhibition_id INT); INSERT INTO visitors (id, country, exhibition_id) VALUES (1, 'United States', 1), (2, 'Canada', 1), (3, 'Mexico', 1), (4, 'United States', 2), (5, 'Canada', 2), (6, 'Brazil', 2), (7, 'United States', 3), (8, 'Canada', 3); CREATE TABLE exhibitions (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO exhibitions (id, name, type) VALUES (1, 'Impressionism', 'Classic'), (2, 'Surrealism', 'Modern'), (3, 'Renaissance', 'Classic');
|
What is the total number of visitors from the 'United States' and 'Canada'?
|
SELECT COUNT(*) FROM visitors WHERE country IN ('United States', 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ROTTERDAM_PORT_CALLS (ID INT, PORT_CALL_ID INT, CARGO_TYPE VARCHAR(50), ARRIVAL DATETIME); INSERT INTO ROTTERDAM_PORT_CALLS VALUES (1, 1, 'Crude Oil', '2021-12-01 12:00:00'); INSERT INTO ROTTERDAM_PORT_CALLS VALUES (2, 2, 'Gasoline', '2021-12-03 06:00:00');
|
Present the earliest and latest arrival times for tanker cargo types in the Port of Rotterdam.
|
SELECT CARGO_TYPE, MIN(ARRIVAL) AS EARLIEST_ARRIVAL, MAX(ARRIVAL) AS LATEST_ARRIVAL FROM ROTTERDAM_PORT_CALLS JOIN PORT_CALLS ON ROTTERDAM_PORT_CALLS.PORT_CALL_ID = PORT_CALLS.ID WHERE PORT = 'Port of Rotterdam' AND CARGO_TYPE LIKE 'Tanker%' GROUP BY CARGO_TYPE
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE StudentPrograms (student_id INT, program_name VARCHAR(255)); INSERT INTO StudentPrograms (student_id, program_name) VALUES (1, 'AssistiveTechnology'), (2, 'SignLanguageInterpreter'), (3, 'ExtendedTestingTime'), (4, 'AssistiveTechnology'), (5, 'ExtendedTestingTime');
|
How many students are enrolled in the 'AssistiveTechnology' and 'SignLanguageInterpreter' programs in the 'StudentPrograms' table?
|
SELECT COUNT(*) FROM StudentPrograms WHERE program_name IN ('AssistiveTechnology', 'SignLanguageInterpreter');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE machine_data (machine_type VARCHAR(50), industry VARCHAR(50), production_rate FLOAT); INSERT INTO machine_data (machine_type, industry, production_rate) VALUES ('Automated Cutting Machine', 'Textile', 120), ('Sewing Machine', 'Textile', 90), ('Knitting Machine', 'Textile', 80), ('Automated Folding Machine', 'Textile', 70), ('Material Handling Robot', 'Textile', 60);
|
Show production rates for machines in the textile manufacturing industry, ordered from highest to lowest.
|
SELECT machine_type, production_rate FROM machine_data WHERE industry = 'Textile' ORDER BY production_rate DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donation_date DATE, donation_amount DECIMAL(10, 2)); INSERT INTO donors VALUES (11, '2023-01-02', 200.00), (12, '2023-03-10', 300.00), (13, '2023-01-15', 100.00);
|
What was the total donation amount by new donors in Q1 2023?
|
SELECT SUM(donation_amount) FROM donors WHERE donor_id IN (SELECT donor_id FROM donors WHERE donation_date BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY donor_id HAVING COUNT(*) = 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT, name TEXT, location TEXT, investment_amount INT, year INT); INSERT INTO project (id, name, location, investment_amount, year) VALUES (1, 'Northern Highway', 'India', 2000000, 2020), (2, 'Southern Railway', 'Vietnam', 1500000, 2019), (3, 'Central Dam', 'Indonesia', 2500000, 2018), (4, 'Eastern Irrigation', 'Nepal', 1000000, 2017);
|
What is the total investment in rural infrastructure in Southeast Asia?
|
SELECT SUM(investment_amount) FROM project WHERE location LIKE 'Southeast%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE service_union_members (member_id INT, gender VARCHAR(10), union VARCHAR(20), age INT); INSERT INTO service_union_members (member_id, gender, union, age) VALUES (1, 'Male', 'Service', 25); INSERT INTO service_union_members (member_id, gender, union, age) VALUES (2, 'Female', 'Service', 30);
|
What is the minimum age of male 'service' union members?
|
SELECT MIN(age) FROM service_union_members WHERE gender = 'Male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, region_id INT, join_date DATE); INSERT INTO mobile_subscribers (subscriber_id, region_id, join_date) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-03-01'), (3, 3, '2021-02-01'), (4, 4, '2021-04-01'); CREATE TABLE broadband_subscribers (subscriber_id INT, region_id INT, join_date DATE); INSERT INTO broadband_subscribers (subscriber_id, region_id, join_date) VALUES (5, 1, '2021-01-15'), (6, 2, '2021-03-15'), (7, 3, '2021-02-15'), (8, 4, '2021-04-15');
|
List the number of mobile and broadband subscribers in each region for the most recent month.
|
SELECT r.region_name, COUNT(m.subscriber_id) AS mobile_count, COUNT(b.subscriber_id) AS broadband_count FROM regions r LEFT JOIN mobile_subscribers m ON r.region_id = m.region_id LEFT JOIN broadband_subscribers b ON r.region_id = b.region_id WHERE MONTH(m.join_date) = MONTH(CURRENT_DATE()) AND YEAR(m.join_date) = YEAR(CURRENT_DATE()) GROUP BY r.region_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE support_programs (program_name VARCHAR(50), department VARCHAR(50)); INSERT INTO support_programs VALUES ('Tutoring', 'Science'), ('Writing Center', 'English'), ('Tutoring', 'Science'), ('Accessibility Services', 'General');
|
List the number of support programs offered by each department, excluding any duplicate program names.
|
SELECT department, COUNT(DISTINCT program_name) FROM support_programs GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, system VARCHAR(255), timestamp DATETIME); CREATE TABLE vulnerabilities (id INT, system VARCHAR(255), timestamp DATETIME);
|
What is the total number of security incidents and vulnerabilities for each system in the last month?
|
SELECT system, COUNT(security_incidents.id) + COUNT(vulnerabilities.id) as total_issues FROM security_incidents RIGHT JOIN vulnerabilities ON security_incidents.system = vulnerabilities.system WHERE security_incidents.timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) OR vulnerabilities.timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY system;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), location VARCHAR(255), sustainability_rating FLOAT); INSERT INTO suppliers (supplier_id, name, location, sustainability_rating) VALUES (1, 'Blue Manufacturing', 'USA', 4.2), (2, 'Green Assembly', 'Canada', 4.8), (3, 'Fair Tech', 'Mexico', 4.5), (4, 'Eco Supplies', 'USA', 4.7), (5, 'Sustainable Logistics', 'USA', 4.3), (6, 'Green Materials', 'Canada', 4.6);
|
List all suppliers located in the USA with a sustainability rating above 4.0.
|
SELECT s.name, s.sustainability_rating FROM suppliers s WHERE s.location = 'USA' AND s.sustainability_rating > 4.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sector_vulnerabilities (id INT, cve_id VARCHAR(255), sector VARCHAR(255), severity VARCHAR(255), publish_date DATE, description TEXT); INSERT INTO sector_vulnerabilities (id, cve_id, sector, severity, publish_date, description) VALUES (1, 'CVE-2022-1234', 'Education', 'CRITICAL', '2022-02-20', 'Description of CVE-2022-1234');
|
What are the details of the top 2 most critical vulnerabilities in software products used in the education sector?
|
SELECT * FROM sector_vulnerabilities WHERE sector = 'Education' AND severity = 'CRITICAL' LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacex_satellites (satellite_id INT, company VARCHAR(20)); INSERT INTO spacex_satellites (satellite_id, company) VALUES (1, 'SpaceX'), (2, 'SpaceX'), (3, 'SpaceX'); CREATE TABLE rocket_lab_satellites (satellite_id INT, company VARCHAR(20)); INSERT INTO rocket_lab_satellites (satellite_id, company) VALUES (4, 'Rocket Lab'), (5, 'Rocket Lab');
|
What is the total number of satellites deployed by SpaceX and Rocket Lab?
|
SELECT COUNT(*) FROM spacex_satellites JOIN rocket_lab_satellites ON FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oil_spills_data(spill_name VARCHAR(255), location VARCHAR(255), year INT, volume INT);INSERT INTO oil_spills_data(spill_name, location, year, volume) VALUES('Santa Barbara Oil Spill','Pacific Ocean',1969,80000),('Deepwater Horizon Oil Spill','Gulf of Mexico',2010,4000000),('Ixtoc I Oil Spill','Gulf of Mexico',1979,3000000),('Montara Oil Spill','Timor Sea',2009,30000),('Kursk Oil Spill','Barents Sea',2000,10000),('Niger Delta Oil Spill','Niger Delta',2011,50000);
|
Determine the number of oil spills that have occurred in the Niger Delta and the Caspian Sea.
|
SELECT location, COUNT(*) AS number_of_spills FROM oil_spills_data WHERE location IN ('Niger Delta', 'Caspian Sea') GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_weather (date DATE, temperature FLOAT, region VARCHAR(255)); INSERT INTO arctic_weather (date, temperature, region) VALUES ('2020-01-01', -15.0, 'North'), ('2020-01-02', -16.5, 'North');
|
What is the average temperature recorded in the 'arctic_weather' table for each month in 2020, grouped by month and region?
|
SELECT m.month, r.region, AVG(a.temperature) FROM (SELECT EXTRACT(MONTH FROM date) AS month, region FROM arctic_weather WHERE date BETWEEN '2020-01-01' AND '2020-12-31') m INNER JOIN arctic_weather a ON m.month = EXTRACT(MONTH FROM a.date) AND m.region = a.region GROUP BY m.month, r.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255));
|
Update the conservation_status of a specific marine species in the marine_species table.
|
UPDATE marine_species SET conservation_status = 'endangered' WHERE id = 1 AND name = 'Blue Whale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT);
|
Create a table named "hotels" with columns "hotel_id", "name", "location", and "stars".
|
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat_projects (project_id INT, project_name VARCHAR(50));CREATE TABLE budget_allocations (allocation_id INT, project_id INT, allocation_amount DECIMAL(10, 2)); INSERT INTO habitat_projects (project_id, project_name) VALUES (1, 'Habitat Project A'), (2, 'Habitat Project B'), (3, 'Habitat Project C'); INSERT INTO budget_allocations (allocation_id, project_id, allocation_amount) VALUES (101, 1, 5000.00), (102, 2, 7500.00), (103, 3, 10000.00);
|
What is the total budget allocated to each habitat preservation project?
|
SELECT p.project_name, SUM(ba.allocation_amount) AS total_budget FROM habitat_projects p JOIN budget_allocations ba ON p.project_id = ba.project_id GROUP BY p.project_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Athletes (Team VARCHAR(50), Athlete VARCHAR(50), Performance DECIMAL(5,2)); INSERT INTO Athletes (Team, Athlete, Performance) VALUES ('Team A', 'Athlete 1', 85.25), ('Team A', 'Athlete 2', 88.75), ('Team A', 'Athlete 3', 90.00), ('Team B', 'Athlete 4', 82.50), ('Team B', 'Athlete 5', 86.25), ('Team B', 'Athlete 6', 92.50), ('Team C', 'Athlete 7', 78.00), ('Team C', 'Athlete 8', 89.25), ('Team C', 'Athlete 9', 91.50), ('Team D', 'Athlete 10', 87.50), ('Team D', 'Athlete 11', 93.75), ('Team D', 'Athlete 12', 84.00);
|
Identify the top 5 athletes in terms of their performance in the wellbeing program across all teams.
|
SELECT Athlete, Performance FROM (SELECT Athlete, Performance, ROW_NUMBER() OVER (ORDER BY Performance DESC) AS Rank FROM Athletes) WHERE Rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CreativeAI (id INT, application VARCHAR(255), safety_score DECIMAL(5,2), region VARCHAR(255)); INSERT INTO CreativeAI (id, application, safety_score, region) VALUES (1, 'Artistic Image Generation', 85.67, 'North America'), (2, 'Automated Journalism', 91.23, 'Europe'), (3, 'Music Composition', 88.98, 'Asia');
|
What is the safety score for each creative AI application in North America?
|
SELECT application, safety_score FROM CreativeAI WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_founding(id INT PRIMARY KEY, company_name VARCHAR(100), founder_gender VARCHAR(10)); CREATE TABLE investment_rounds(id INT PRIMARY KEY, company_id INT, funding_amount INT); INSERT INTO company_founding VALUES (1, 'Acme Inc', 'Female'); INSERT INTO company_founding VALUES (2, 'Beta Corp', 'Male'); INSERT INTO company_founding VALUES (3, 'Charlie LLC', 'Female'); INSERT INTO investment_rounds VALUES (1, 1, 1000000); INSERT INTO investment_rounds VALUES (2, 1, 2000000); INSERT INTO investment_rounds VALUES (3, 3, 500000);
|
Calculate the average funding amount for each company founded by women
|
SELECT cf.company_name, AVG(ir.funding_amount) FROM company_founding cf INNER JOIN investment_rounds ir ON cf.id = ir.company_id WHERE cf.founder_gender = 'Female' GROUP BY cf.company_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE case_outcomes (case_id INT, attorney_name VARCHAR(50), case_won BOOLEAN); INSERT INTO case_outcomes (case_id, attorney_name, case_won) VALUES (1, 'Lisa Kim', true), (2, 'Mike Johnson', false), (3, 'Lisa Kim', true);
|
What is the percentage of cases won by attorney 'Lisa Kim'?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM case_outcomes WHERE attorney_name = 'Lisa Kim')) AS percentage_won FROM case_outcomes WHERE case_won = true AND attorney_name = 'Lisa Kim';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artist_productivity (id INT, artist_name VARCHAR(50), year INT, num_pieces INT);
|
Which artists are the most and least productive in terms of art pieces created?
|
SELECT artist_name, year, num_pieces FROM (SELECT artist_name, year, num_pieces, DENSE_RANK() OVER (ORDER BY num_pieces DESC) as rank FROM artist_productivity) a WHERE rank <= 1 OR rank >= 11;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE productivity (id INT, mine_id INT, year INT, tons_per_employee INT); INSERT INTO productivity (id, mine_id, year, tons_per_employee) VALUES (9, 9, 2022, 180); INSERT INTO productivity (id, mine_id, year, tons_per_employee) VALUES (10, 10, 2022, 200);
|
What is the minimum and maximum production volume for each mine in Canada?
|
SELECT m.name, MIN(p.tons_per_employee) AS min_production, MAX(p.tons_per_employee) AS max_production FROM mines m JOIN productivity p ON m.id = p.mine_id WHERE m.location = 'Canada' GROUP BY m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fleet_management(ship_id INT, ship_name VARCHAR(50), age INT); CREATE TABLE government_registry(ship_id INT, ship_name VARCHAR(50), age INT);
|
Find the names and ages of all ships in the fleet_management table that do not appear in the government_registry table.
|
SELECT FM.ship_name, FM.age FROM fleet_management FM WHERE FM.ship_id NOT IN (SELECT GR.ship_id FROM government_registry GR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE areas (area_id INT, area_name VARCHAR(255), poverty_level DECIMAL(5,2));CREATE TABLE emergency_calls (id INT, area_id INT, call_type VARCHAR(255), call_date DATE);CREATE TABLE crimes (id INT, area_id INT, crime_type VARCHAR(255), crime_date DATE);
|
Find the total number of emergency calls and crimes committed in areas with high poverty levels.
|
SELECT 'Total emergency calls' AS metric, COUNT(ec.id) AS count FROM emergency_calls ec JOIN areas a ON ec.area_id = a.area_id WHERE a.poverty_level >= 0.2 UNION ALL SELECT 'Total crimes' AS metric, COUNT(c.id) AS count FROM crimes c JOIN areas a ON c.area_id = a.area_id WHERE a.poverty_level >= 0.2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Infrastructure (type TEXT, state TEXT, design_code TEXT); INSERT INTO Infrastructure (type, state, design_code) VALUES ('Bridges', 'Nevada', 'AASHTO LRFD'); INSERT INTO Infrastructure (type, state, design_code) VALUES ('Dams', 'Arizona', 'USBR Design Standards');
|
What are the unique types of infrastructure and their respective standard design codes in 'Nevada' and 'Arizona'?
|
SELECT DISTINCT type, design_code FROM Infrastructure WHERE state IN ('Nevada', 'Arizona');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE donors (id INT, country VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 500.00, '2018-10-20'); INSERT INTO donors (id, country) VALUES (1, 'United Kingdom');
|
What is the maximum donation amount received from a single donor in the United Kingdom in the year 2018?
|
SELECT MAX(donation_amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.country = 'United Kingdom' AND YEAR(donation_date) = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, product_id INT, material VARCHAR(50), sale_date DATE, quantity INT);
|
Which sustainable material has the highest sales in the last quarter?
|
SELECT material, SUM(quantity) AS total_sales FROM sales WHERE material IN ('organic_cotton', 'recycled_polyester', 'tencel') AND sale_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY material ORDER BY total_sales DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID INT, AttorneyName TEXT, ProBonoCases INT, CaseResolutionDate DATE, State TEXT); INSERT INTO Attorneys (AttorneyID, AttorneyName, ProBonoCases, CaseResolutionDate, State) VALUES (1, 'John Smith', 25, '2022-01-15', 'Colorado');
|
Who are the top 3 attorneys with the highest number of successful pro-bono cases in Colorado in the last 2 years?
|
SELECT AttorneyName, SUM(ProBonoCases) as TotalProBonoCases FROM Attorneys WHERE State = 'Colorado' AND CaseResolutionDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) AND CURRENT_DATE GROUP BY AttorneyName ORDER BY TotalProBonoCases DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat (id INT, name VARCHAR(255), carbon_sequestration FLOAT); INSERT INTO habitat (id, name, carbon_sequestration) VALUES (1, 'Habitat1', 123.45); INSERT INTO habitat (id, name, carbon_sequestration) VALUES (2, 'Habitat2', 234.56); CREATE TABLE wildlife (id INT, name VARCHAR(255), habitat_id INT); INSERT INTO wildlife (id, name, habitat_id) VALUES (1, 'Wildlife1', 1); INSERT INTO wildlife (id, name, habitat_id) VALUES (2, 'Wildlife2', 2);
|
What is the maximum carbon sequestration value for each wildlife habitat?
|
SELECT w.name, MAX(h.carbon_sequestration) FROM habitat h JOIN wildlife w ON h.id = w.habitat_id GROUP BY w.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LipstickSales (sale_id INT, product_id INT, sale_price DECIMAL(5,2), sale_date DATE, brand TEXT, country TEXT); INSERT INTO LipstickSales (sale_id, product_id, sale_price, sale_date, brand, country) VALUES (1, 301, 12.99, '2021-04-21', 'Maybelline', 'Canada');
|
How many units of each brand's lipstick were sold in Canada in 2021?
|
SELECT brand, product_id, SUM(1) AS units_sold FROM LipstickSales WHERE country = 'Canada' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY brand, product_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wastewater_plants (plant_id INT, plant_name VARCHAR(255), state VARCHAR(255), capacity FLOAT); INSERT INTO wastewater_plants (plant_id, plant_name, state, capacity) VALUES (1, 'LA WWTP', 'California', 5000000), (2, 'NY WWTP', 'New York', 3000000);
|
List all wastewater treatment plants in California with their capacity.
|
SELECT plant_name, capacity FROM wastewater_plants WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (country VARCHAR(50), budget INT); INSERT INTO military_innovation (country, budget) VALUES ('Algeria', 1200000), ('Angola', 800000), ('Egypt', 3000000);
|
What is the average budget allocated for military innovation by each country in Africa?
|
SELECT AVG(budget) avg_budget, country FROM military_innovation WHERE country IN ('Algeria', 'Angola', 'Egypt') GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Patients (PatientID INT, Age INT, Gender TEXT, Diagnosis TEXT, State TEXT); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, State) VALUES (1, 45, 'Male', 'Diabetes', 'Texas');
|
How many patients with diabetes live in each state?
|
SELECT State, COUNT(*) FROM Patients WHERE Diagnosis = 'Diabetes' GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (id INT, transaction_date DATE, country VARCHAR(255), amount DECIMAL(10,2)); INSERT INTO transactions (id, transaction_date, country, amount) VALUES (1, '2022-01-01', 'USA', 100.00), (2, '2022-01-02', 'Canada', 200.00), (3, '2022-01-03', 'USA', 300.00), (4, '2022-01-04', 'Mexico', 400.00);
|
What is the total transaction amount for each day in January 2022, for transactions that occurred in the United States or Canada?
|
SELECT transaction_date, SUM(amount) FROM transactions WHERE (country = 'USA' OR country = 'Canada') AND transaction_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY transaction_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_incidents (mine_name VARCHAR(255), incident_date DATE, incident_type VARCHAR(255)); INSERT INTO mining_incidents (mine_name, incident_date, incident_type) VALUES ('Green Valley', '2017-06-05', 'Water Contamination'); CREATE TABLE geology_survey (mine_name VARCHAR(255), survey_date DATE, mineral_deposits INT); INSERT INTO geology_survey (mine_name, survey_date, mineral_deposits) VALUES ('Green Valley', '2018-02-15', 8000); INSERT INTO geology_survey (mine_name, survey_date, mineral_deposits) VALUES ('Blue Hills', '2019-01-01', 9000);
|
Which mines have both water contamination incidents and geology survey data?
|
SELECT mine_name FROM mining_incidents WHERE incident_type = 'Water Contamination' INTERSECT SELECT mine_name FROM geology_survey;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles (article_id INT PRIMARY KEY, title TEXT, topic TEXT, author_id INT, publication_date DATE); CREATE TABLE authors (author_id INT PRIMARY KEY, author_name TEXT);
|
What is the number of articles published by each author in the "Ethics" topic, with an inner join to the authors table?
|
SELECT a.author_name, COUNT(*) FROM news_articles n INNER JOIN authors a ON n.author_id = a.author_id WHERE n.topic = 'Ethics' GROUP BY a.author_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT, size FLOAT, city VARCHAR(20)); INSERT INTO property (id, size, city) VALUES (1, 1500, 'Denver'), (2, 2000, 'Portland'), (3, 1000, 'NYC'), (4, 2500, 'Austin');
|
What is the maximum and minimum property size for each city?
|
SELECT city, MAX(size) as max_size, MIN(size) as min_size FROM property GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumers (consumer_id INT, total_spent DECIMAL(10,2)); CREATE TABLE purchases (purchase_id INT, consumer_id INT, product_id INT, is_circular_supply BOOLEAN); INSERT INTO consumers (consumer_id, total_spent) VALUES (1, 500), (2, 700), (3, 600), (4, 800), (5, 900); INSERT INTO purchases (purchase_id, consumer_id, product_id, is_circular_supply) VALUES (1, 1, 1, TRUE), (2, 1, 2, FALSE), (3, 2, 3, TRUE), (4, 3, 4, TRUE), (5, 4, 5, TRUE);
|
Who are the top 5 consumers by total spent on circular supply chain products?
|
SELECT consumers.consumer_id, SUM(purchases.total_spent) AS total_spent FROM consumers INNER JOIN purchases ON consumers.consumer_id = purchases.consumer_id WHERE purchases.is_circular_supply = TRUE GROUP BY consumers.consumer_id ORDER BY total_spent DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarineSpecies (SpeciesID INT PRIMARY KEY, SpeciesName TEXT, KnownDepth FLOAT);
|
List all marine species with a known depth in the 'MarineSpecies' table.
|
SELECT SpeciesName FROM MarineSpecies WHERE KnownDepth IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50));CREATE TABLE coal_mine (mine_id INT, amount INT);CREATE TABLE iron_mine (mine_id INT, amount INT);
|
Show the names and locations of mines where the total amount of coal mined is equal to the total amount of iron mined.
|
SELECT m.name, m.location FROM mine m INNER JOIN coal_mine c ON m.id = c.mine_id INNER JOIN iron_mine i ON m.id = i.mine_id GROUP BY m.id, m.name, m.location HAVING SUM(c.amount) = SUM(i.amount);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students (StudentID INT PRIMARY KEY, Name VARCHAR(50), Disability VARCHAR(20));
|
Update the disability type for student with ID 123 to 'Mental Health'
|
UPDATE Students SET Disability = 'Mental Health' WHERE StudentID = 123;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grants (id INT, pi_gender VARCHAR(6), amount DECIMAL(10,2)); INSERT INTO grants (id, pi_gender, amount) VALUES (1, 'Female', 50000), (2, 'Male', 75000), (3, 'Female', 100000), (4, 'Non-binary', 80000);
|
What is the average number of research grants per female Principal Investigator (PI)?
|
SELECT AVG(total_grants) FROM (SELECT pi_gender, COUNT(*) as total_grants FROM grants WHERE pi_gender = 'Female' GROUP BY pi_gender) as subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (service varchar(20), location varchar(20), date date); INSERT INTO feedback (service, location, date) VALUES ('Education', 'Urban', '2021-01-01'), ('Healthcare', 'Urban', '2021-02-01'), ('Education', 'Rural', '2020-12-01'), ('Healthcare', 'Rural', '2020-11-01');
|
How many citizen feedback records were received in total for each service?
|
SELECT service, COUNT(*) FROM feedback GROUP BY service;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage(customer_id INT, usage FLOAT, month DATE); INSERT INTO water_usage(customer_id, usage, month) VALUES (1, 500, '2022-07-01'), (2, 350, '2022-07-01'), (3, 700, '2022-07-01');
|
What is the total water usage by all agricultural customers in the month of July?
|
SELECT SUM(usage) FROM water_usage WHERE month = '2022-07-01' AND customer_type = 'agricultural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, investment_type VARCHAR(50), cost DECIMAL(5,2), investment_date DATE);
|
What is the total revenue for each type of network infrastructure investment, for the year 2022?
|
SELECT investment_type, SUM(cost) AS total_cost FROM network_investments WHERE YEAR(investment_date) = 2022 GROUP BY investment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE schools (school_id INT, school_name TEXT); CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, school_id INT);
|
Add a new teacher with a unique teacher_id, teacher_name, and assignment to a school, updating the corresponding school record accordingly.
|
INSERT INTO teachers (teacher_id, teacher_name, school_id) VALUES (98765, 'Mx. Lopez', 4321); UPDATE schools s SET s.teacher_id = 98765 WHERE EXISTS (SELECT * FROM teachers t WHERE t.school_id = s.school_id AND s.teacher_id != 98765);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerInfo (CustomerID INT, Country VARCHAR(255), PreferredSize INT); INSERT INTO CustomerInfo (CustomerID, Country, PreferredSize) VALUES (1, 'US', 18), (2, 'CA', 14), (3, 'US', 16), (4, 'MX', 12);
|
How many customers from the US prefer size 16 and above in women's clothing?
|
SELECT COUNT(*) FROM CustomerInfo WHERE Country = 'US' AND PreferredSize >= 16;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (artist_id INT, name VARCHAR(50), gender VARCHAR(50), country VARCHAR(50)); INSERT INTO artists (artist_id, name, gender, country) VALUES (1, 'Georgia O''Keeffe', 'Female', 'USA'); CREATE TABLE art_pieces (art_piece_id INT, title VARCHAR(50), value INT, artist_id INT); INSERT INTO art_pieces (art_piece_id, title, value, artist_id) VALUES (1, 'Black Iris III', 14000000, 1);
|
What is the total value of artworks from female artists in the USA?
|
SELECT SUM(ap.value) FROM art_pieces ap INNER JOIN artists a ON ap.artist_id = a.artist_id WHERE a.gender = 'Female' AND a.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai_projects (id INT, region VARCHAR(255), year INT, projects INT, budget DECIMAL(10,2)); INSERT INTO ethical_ai_projects (id, region, year, projects, budget) VALUES (1, 'Middle East', 2021, 50, 450000.00); INSERT INTO ethical_ai_projects (id, region, year, projects, budget) VALUES (2, 'Europe', 2021, 60, 600000.00);
|
What is the total number of ethical AI projects in the Middle East and their budgets in 2021?
|
SELECT region, SUM(budget) FROM ethical_ai_projects WHERE year = 2021 AND region = 'Middle East' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO hotels (id, name, city, rating) VALUES (1, 'Eco Hotel', 'Barcelona', 4.6), (2, 'Green Lodge', 'Barcelona', 4.7), (3, 'Sustainable Suites', 'Barcelona', 4.5);
|
Who is the top-rated eco-friendly hotel in Barcelona?
|
SELECT name FROM hotels WHERE city = 'Barcelona' AND rating = (SELECT MAX(rating) FROM hotels WHERE city = 'Barcelona' AND name IN ('Eco Hotel', 'Green Lodge', 'Sustainable Suites'));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (year INT, sector TEXT, amount INT); INSERT INTO waste_generation (year, sector, amount) VALUES (NULL, 'commercial', 1200), (2018, 'residential', 800), (2019, 'commercial', 1500), (2019, 'residential', 900), (2020, 'commercial', NULL), (2020, 'residential', 1100);
|
How many waste generation records are missing a year value?
|
SELECT COUNT(*) FROM waste_generation WHERE year IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels(hotel_id INT, hotel_name TEXT, category TEXT); INSERT INTO hotels(hotel_id, hotel_name, category) VALUES (1, 'Green Haven Hotel', 'Eco-friendly'); CREATE TABLE bookings(booking_id INT, hotel_id INT, booking_status TEXT, booking_revenue DECIMAL, booking_date DATE); CREATE TABLE users(user_id INT, user_country TEXT);
|
What is the total revenue from bookings in hotels under the 'Eco-friendly' category, for users from Australia, in 2022, considering both completed and cancelled bookings?
|
SELECT SUM(booking_revenue) FROM hotels INNER JOIN bookings ON hotels.hotel_id = bookings.hotel_id INNER JOIN users ON bookings.user_id = users.user_id WHERE hotels.category = 'Eco-friendly' AND users.user_country = 'Australia' AND YEAR(booking_date) = 2022 AND (booking_status = 'completed' OR booking_status = 'cancelled');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TB_By_State (id INT, state VARCHAR(50), type VARCHAR(50)); INSERT INTO TB_By_State (id, state, type) VALUES (1, 'California', 'Tunnel'), (2, 'California', 'Bridge'), (3, 'Texas', 'Bridge');
|
Display the number of tunnels and bridges in each state
|
SELECT state, type, COUNT(*) FROM TB_By_State GROUP BY state, type;
|
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.