context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE dissolved_oxygen (ocean TEXT, level FLOAT); INSERT INTO dissolved_oxygen (ocean, level) VALUES ('Atlantic', 4.5), ('Pacific', 4.3), ('Indian', 4.7);
|
What is the minimum dissolved oxygen level in each ocean?
|
SELECT ocean, MIN(level) FROM dissolved_oxygen;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_calls (id INT, call_date DATE, response_time FLOAT); INSERT INTO emergency_calls VALUES (1, '2021-01-01', 6.5), (2, '2021-02-01', 7.3);
|
What is the total number of emergency calls in each month?
|
SELECT DATE_FORMAT(call_date, '%Y-%m') AS month, COUNT(*) FROM emergency_calls GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (1, 30, 'Female', 'CBT', 'Texas'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (2, 45, 'Male', 'DBT', 'California'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (3, 25, 'Non-binary', 'Therapy', 'Washington');
|
What is the number of patients who identified as non-binary and received therapy in Washington?
|
SELECT COUNT(*) FROM patients WHERE gender = 'Non-binary' AND state = 'Washington';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_courts (id INT, name VARCHAR(50), state VARCHAR(20), cases_heard INT, year INT); INSERT INTO community_courts (id, name, state, cases_heard, year) VALUES (1, 'Court 1', 'Texas', 500, 2019); INSERT INTO community_courts (id, name, state, cases_heard, year) VALUES (2, 'Court 2', 'Texas', 600, 2020); INSERT INTO community_courts (id, name, state, cases_heard, year) VALUES (3, 'Court 3', 'California', 700, 2018);
|
What is the total number of cases heard in community courts in Texas in 2021?
|
SELECT SUM(cases_heard) FROM community_courts WHERE state = 'Texas' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_events (event_id INT, event_name TEXT, city TEXT, year INT); INSERT INTO community_events (event_id, event_name, city, year) VALUES (1, 'Cultural Festival', 'New York', 2020), (2, 'Traditional Music Concert', 'Los Angeles', 2019);
|
Identify community engagement events that were held in the year 2020, and their respective cities.
|
SELECT city, event_name FROM community_events WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (id INT, factory_name VARCHAR(50), ethical_manufacturing BOOLEAN); INSERT INTO Factories (id, factory_name, ethical_manufacturing) VALUES (1, 'Ethical Factory A', TRUE); INSERT INTO Factories (id, factory_name, ethical_manufacturing) VALUES (2, 'Unethical Factory B', FALSE); CREATE TABLE Workers (id INT, factory_id INT, name VARCHAR(50), salary FLOAT, ethnicity VARCHAR(50), industry VARCHAR(50)); INSERT INTO Workers (id, factory_id, name, salary, ethnicity, industry) VALUES (1, 1, 'John Doe', 50000, 'Hispanic', 'renewable energy'); INSERT INTO Workers (id, factory_id, name, salary, ethnicity, industry) VALUES (2, 1, 'Jane Smith', 55000, 'African American', 'renewable energy'); INSERT INTO Workers (id, factory_id, name, salary, ethnicity, industry) VALUES (3, 2, 'Mike Johnson', 60000, 'Caucasian', 'renewable energy'); INSERT INTO Workers (id, factory_id, name, salary, ethnicity, industry) VALUES (4, 2, 'Emily Brown', 65000, 'Asian', 'renewable energy');
|
What is the average salary of workers in the 'renewable energy' industry, grouped by their ethnicity, in factories that have implemented ethical manufacturing practices?
|
SELECT Workers.ethnicity, AVG(Workers.salary) FROM Workers INNER JOIN Factories ON Workers.factory_id = Factories.id WHERE Workers.industry = 'renewable energy' AND Factories.ethical_manufacturing = TRUE GROUP BY Workers.ethnicity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteer_hours (id INT, volunteer_id INT, volunteer_date DATE, hours_volunteered DECIMAL(10, 2)); INSERT INTO volunteer_hours (id, volunteer_id, volunteer_date, hours_volunteered) VALUES (1, 1, '2021-01-01', 2.0), (2, 2, '2021-01-02', 3.0);
|
How many volunteers joined each month in 2021, and what was their total volunteering time?
|
SELECT DATE_TRUNC('month', volunteer_date) AS month, COUNT(DISTINCT volunteer_id) AS volunteers_joined, SUM(hours_volunteered) AS total_volunteering_time FROM volunteer_hours WHERE volunteer_date >= '2021-01-01' AND volunteer_date < '2022-01-01' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_personnel (personnel_id INT, country VARCHAR(255), role VARCHAR(255), start_date DATE); INSERT INTO military_personnel (personnel_id, country, role, start_date) VALUES (1, 'Country A', 'Peacekeeper', '2015-01-01'), (2, 'Country B', 'Peacekeeper', '2016-01-01'), (3, 'Country C', 'Commander', '2017-01-01'); CREATE TABLE countries (country VARCHAR(255)); CREATE TABLE roles (role VARCHAR(255));
|
What is the total number of military personnel from Latin America involved in peacekeeping operations since 2015?
|
SELECT COUNT(*) FROM military_personnel INNER JOIN countries ON military_personnel.country = countries.country INNER JOIN roles ON military_personnel.role = roles.role WHERE countries.country LIKE '%Latin America%' AND role = 'Peacekeeper' AND start_date >= '2015-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ports (PortID INT, Name VARCHAR(255), Country VARCHAR(255)); CREATE TABLE Cargo (CargoID INT, PortID INT, Weight INT); INSERT INTO Ports (PortID, Name, Country) VALUES (1, 'New York', 'USA'); INSERT INTO Cargo (CargoID, PortID, Weight) VALUES (1, 1, 5000), (2, 1, 3000);
|
What is the total cargo weight handled by each vessel that visited the port of 'New York'?
|
SELECT Vessels.Name, SUM(Cargo.Weight) FROM Vessels INNER JOIN PortVisits ON Vessels.VesselID = PortVisits.VesselID INNER JOIN Cargo ON PortVisits.PortID = Cargo.PortID WHERE Ports.Name = 'New York' GROUP BY Vessels.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE, risk_score INT); CREATE VIEW customer_region AS SELECT customer_id, region FROM customers;
|
List all transactions with potential fraud risk in the last quarter.
|
SELECT t.transaction_id, t.customer_id, t.amount, t.transaction_date, t.risk_score FROM transactions t INNER JOIN customer_region cr ON t.customer_id = cr.customer_id WHERE t.risk_score > 80 AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, region_id INT, workshop_attendance BOOLEAN); INSERT INTO teachers (teacher_id, region_id, workshop_attendance) VALUES (1, 5, TRUE), (2, 5, FALSE), (3, 6, TRUE), (4, 6, TRUE); CREATE TABLE regions (region_id INT, region_name VARCHAR(20)); INSERT INTO regions (region_id, region_name) VALUES (5, 'Northeast'), (6, 'Southeast');
|
What is the percentage of teachers who attended professional development workshops in each region?
|
SELECT r.region_name, (COUNT(t.teacher_id) * 100.0 / (SELECT COUNT(*) FROM teachers)) as percentage_attended FROM teachers t JOIN regions r ON t.region_id = r.region_id WHERE workshop_attendance = TRUE GROUP BY r.region_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE JobApplications (ApplicationID INT, ApplicationDate DATE, ApplicationSource VARCHAR(20)); INSERT INTO JobApplications (ApplicationID, ApplicationDate, ApplicationSource) VALUES (1, '2022-01-01', 'LinkedIn'), (2, '2022-01-15', 'Glassdoor'), (3, '2022-02-01', 'Indeed');
|
How many job applicants were there in the last 3 months, broken down by source?
|
SELECT ApplicationSource, COUNT(*) FROM JobApplications WHERE ApplicationDate >= DATEADD(month, -3, GETDATE()) GROUP BY ApplicationSource;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (id INT, name VARCHAR(255), regulatory_status VARCHAR(50)); INSERT INTO digital_assets (id, name, regulatory_status) VALUES (1, 'AssetA', 'Regulated'), (2, 'AssetB', 'Unregulated'), (3, 'AssetC', 'Regulated');
|
What is the total market capitalization of digital assets with a regulatory framework in place?
|
SELECT SUM(market_cap) FROM digital_assets WHERE regulatory_status = 'Regulated';
|
gretelai_synthetic_text_to_sql
|
create table fish_species (id integer, name text, family text, region text); insert into fish_species (id, name, family, region) values (1, 'Salmon', 'Salmonidae', 'North Atlantic');
|
Create a table named "fish_species" with columns "id", "name", "family", "region" and add a row with the following details: id=1, name="Salmon", family="Salmonidae", region="North Atlantic"
|
create table fish_species (id integer, name text, family text, region text); insert into fish_species (id, name, family, region) values (1, 'Salmon', 'Salmonidae', 'North Atlantic');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Boston Warehouse', 'east'), (2, 'Atlanta Warehouse', 'east'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, state TEXT); INSERT INTO packages (id, warehouse_id, weight, state) VALUES (1, 1, 15.5, 'Massachusetts'), (2, 1, 20.3, 'New York'), (3, 2, 12.8, 'Florida');
|
What is the total weight of packages shipped to each state from the 'east' region?
|
SELECT state, SUM(weight) FROM packages p JOIN warehouses w ON p.warehouse_id = w.id WHERE w.region = 'east' GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE legal_aid_waiting_times (id INT, clinic_name VARCHAR(50), location VARCHAR(10), waiting_time INT); CREATE TABLE rural_areas (id INT, location VARCHAR(10));
|
What is the average waiting time for legal aid in rural areas?
|
SELECT AVG(waiting_time) FROM legal_aid_waiting_times lat INNER JOIN rural_areas ra ON lat.location = ra.location WHERE ra.id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE campaigns (id INT, name TEXT, target_region TEXT, start_date DATETIME, end_date DATETIME, ad_spend DECIMAL(10,2));
|
What is the total ad spend for all campaigns targeting users in the 'Europe' region, in the past month?
|
SELECT SUM(ad_spend) FROM campaigns WHERE target_region = 'Europe' AND start_date <= NOW() AND end_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups_funding (id INT, name VARCHAR(50), location VARCHAR(50), industry VARCHAR(50), funding DECIMAL(10, 2), funded_year INT); INSERT INTO biotech.startups_funding (id, name, location, industry, funding, funded_year) VALUES (1, 'StartupA', 'USA', 'Genetic Research', 6000000, 2019), (2, 'StartupB', 'Canada', 'Bioprocess Engineering', 4500000, 2018), (3, 'StartupC', 'USA', 'Synthetic Biology', 5000000, 2018), (4, 'StartupD', 'USA', 'Genetic Research', 8000000, 2020), (5, 'StartupE', 'Germany', 'Genetic Research', 7000000, 2019), (6, 'StartupF', 'USA', 'Genetic Research', 9000000, 2018);
|
What is the change in genetic research funding from the previous year, for each startup?
|
SELECT name, (funding - LAG(funding) OVER (PARTITION BY name ORDER BY funded_year)) as funding_change FROM biotech.startups_funding WHERE industry = 'Genetic Research';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sectors (sector_id INT, sector VARCHAR(20)); INSERT INTO sectors (sector_id, sector) VALUES (1, 'Technology'); CREATE TABLE investments (investment_id INT, client_id INT, sector_id INT); INSERT INTO investments (investment_id, client_id, sector_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 1);
|
List the clients and their total investments in the technology sector.
|
SELECT clients.client_id, SUM(value) AS total_investment FROM clients JOIN assets ON clients.client_id = assets.client_id JOIN investments ON clients.client_id = investments.client_id JOIN sectors ON investments.sector_id = sectors.sector_id WHERE sectors.sector = 'Technology' GROUP BY clients.client_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cerium_production (year INT, production_volume INT); INSERT INTO cerium_production VALUES (2015, 75), (2016, 80), (2017, 85), (2018, 90), (2019, 95);
|
What was the total production volume of Cerium in 2016?
|
SELECT SUM(production_volume) FROM cerium_production WHERE year = 2016;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, start_date DATE);CREATE TABLE game_sessions (id INT, player_id INT, session_duration INT);
|
What is the total number of hours spent playing games by players, grouped by the month they started playing?
|
SELECT DATE_FORMAT(p.start_date, '%Y-%m') AS month, SUM(gs.session_duration) AS total_hours_played FROM players p INNER JOIN game_sessions gs ON p.id = gs.player_id GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_agency (id INT, name TEXT); CREATE TABLE research_grants (id INT, funding_agency_id INT, amount INT, faculty_member_gender TEXT);
|
What is the total number of research grants awarded by funding agency and gender of the faculty member who received the grant?
|
SELECT f.name, r.faculty_member_gender, SUM(r.amount) FROM funding_agency f JOIN research_grants r ON f.id = r.funding_agency_id GROUP BY f.name, r.faculty_member_gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Military_Equipment_Sales(sale_id INT, sale_date DATE, equipment_type VARCHAR(50), country VARCHAR(50), sale_value DECIMAL(10,2));
|
What is the average sale value of military equipment sold to Europe in Q3 of 2021?
|
SELECT AVG(sale_value) FROM Military_Equipment_Sales WHERE country IN (SELECT country FROM World_Countries WHERE continent = 'Europe') AND sale_date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CasesByYear (CaseID INT, Age INT, Gender VARCHAR(10), City VARCHAR(20), Disease VARCHAR(20), Year INT); INSERT INTO CasesByYear (CaseID, Age, Gender, City, Disease, Year) VALUES (1, 35, 'Male', 'Chicago', 'Tuberculosis', 2020);
|
What is the total number of Tuberculosis cases reported in Chicago in 2020?
|
SELECT COUNT(*) FROM CasesByYear WHERE City = 'Chicago' AND Year = 2020 AND Disease = 'Tuberculosis';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_inventory (item_id INT, item_name TEXT, price INT); INSERT INTO player_inventory (item_id, item_name, price) VALUES (1, 'Gaming Mouse', 50), (2, 'Mechanical Keyboard', 150), (3, 'Gaming Monitor', 1200);
|
Update the 'player_inventory' table to mark items as 'sold' where the item's price is greater than 1000
|
WITH expensive_items AS (UPDATE player_inventory SET sold = 'true' WHERE price > 1000) SELECT * FROM expensive_items;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10));CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventType VARCHAR(20));
|
Delete the records of players who have not participated in any esports events.
|
DELETE FROM Players WHERE PlayerID NOT IN (SELECT EsportsEvents.PlayerID FROM EsportsEvents);
|
gretelai_synthetic_text_to_sql
|
create table vulnerabilities (id int, organization varchar(255), severity int, date date); insert into vulnerabilities values (1, 'Google', 7, '2022-01-01'); insert into vulnerabilities values (2, 'Google', 5, '2022-01-05'); insert into vulnerabilities values (3, 'Apple', 8, '2022-01-10'); insert into vulnerabilities values (4, 'Microsoft', 2, '2022-04-15'); insert into vulnerabilities values (5, 'Microsoft', 9, '2022-07-01');
|
What is the minimum severity score of vulnerabilities for each organization in the last 6 months that have at least one vulnerability with a severity score of 9?
|
SELECT organization, MIN(severity) FROM vulnerabilities WHERE severity = 9 AND date >= '2022-01-01' GROUP BY organization;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts(astronaut_id INT, name VARCHAR(50), country VARCHAR(50), missions INT);
|
number of missions for each astronaut
|
SELECT a.name, COUNT(m.astronaut_id) AS missions FROM Astronauts a JOIN Missions m ON a.astronaut_id = m.astronaut_id GROUP BY a.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mitigation_projects_canada (id INT, project VARCHAR(50), province VARCHAR(50), power_type VARCHAR(50), size INT); INSERT INTO mitigation_projects_canada (id, project, province, power_type, size) VALUES (1, 'Wind Power Project', 'Ontario', 'Wind', 3000); INSERT INTO mitigation_projects_canada (id, project, province, power_type, size) VALUES (2, 'Solar Power Project', 'Quebec', 'Solar', 4000); INSERT INTO mitigation_projects_canada (id, project, province, power_type, size) VALUES (3, 'Hydro Power Project', 'British Columbia', 'Hydro', 5000); INSERT INTO mitigation_projects_canada (id, project, province, power_type, size) VALUES (4, 'Geothermal Power Project', 'Alberta', 'Geothermal', 6000);
|
What is the average size of climate mitigation projects in each province of Canada?
|
SELECT province, AVG(size) FROM mitigation_projects_canada WHERE power_type != 'Geothermal' GROUP BY province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE astronauts (id INT, name VARCHAR(50), nationality VARCHAR(50)); CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, return_date DATE, astronaut_id INT);
|
List all astronauts who have been in space more than once and their missions.
|
SELECT astronauts.name, space_missions.mission_name FROM astronauts INNER JOIN space_missions ON astronauts.id = space_missions.astronaut_id GROUP BY astronauts.name HAVING COUNT(*) > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft_Repairs (id INT, spacecraft_id INT, repair_date DATE, description VARCHAR(100), cost DECIMAL(10,2)); CREATE TABLE Spacecraft (id INT, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE);
|
How many days between each repair was required for each spacecraft, ordered by manufacturer?
|
SELECT s.name, s.manufacturer, r.repair_date, LEAD(r.repair_date) OVER (PARTITION BY s.name ORDER BY r.repair_date) - r.repair_date as days_between_repairs FROM Spacecraft_Repairs r JOIN Spacecraft s ON r.spacecraft_id = s.id ORDER BY s.manufacturer, r.repair_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cuisine (cuisine_id INT, cuisine_name VARCHAR(255)); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), cuisine_id INT, price DECIMAL(5,2)); CREATE TABLE orders (order_id INT, dish_id INT, order_date DATE, quantity INT); INSERT INTO cuisine VALUES (1, 'Chinese'); INSERT INTO dishes VALUES (1, 'Kung Pao Chicken', 1, 13.99); INSERT INTO orders VALUES (1, 1, '2022-04-01', 2);
|
What is the total number of orders and revenue generated for each cuisine, including only orders placed within the past week?
|
SELECT cuisine_name, COUNT(o.order_id) as total_orders, SUM(d.price * o.quantity) as total_revenue FROM cuisine c JOIN dishes d ON c.cuisine_id = d.cuisine_id JOIN orders o ON d.dish_id = o.dish_id WHERE order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY cuisine_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE urban_agriculture (project_id INT, project_name TEXT, country TEXT, area_ha FLOAT); INSERT INTO urban_agriculture (project_id, project_name, country, area_ha) VALUES (1, 'Greenroof Energy Park', 'Canada', 1.2), (2, 'Brooklyn Grange', 'USA', 2.4);
|
What is the total area (in hectares) of all urban agriculture projects in Canada and the United States, grouped by country?
|
SELECT country, SUM(area_ha) FROM urban_agriculture WHERE country IN ('Canada', 'USA') GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (equipment_id INT, name VARCHAR(50), type VARCHAR(50), manufacturing_date DATE);
|
Delete records in the military_equipment table that have a manufacturing_date older than 20 years from today's date
|
DELETE FROM military_equipment WHERE manufacturing_date < DATE_SUB(CURRENT_DATE, INTERVAL 20 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE state_data (state VARCHAR(2), worker_count INT, violations INT); INSERT INTO state_data (state, worker_count, violations) VALUES ('CA', 150, 25), ('NY', 200, 30), ('TX', 120, 15), ('FL', 180, 20), ('IL', 160, 18);
|
Summarize the total number of community health workers and mental health parity violations by state
|
SELECT state, SUM(worker_count) as total_workers, SUM(violations) as total_violations FROM state_data GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dams (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE dam_construction_dates (dam_id INT, year INT);
|
What are the names and ages (in years) of the dams in 'California' from the 'dams' and 'dam_construction_dates' tables?
|
SELECT d.name, YEAR(CURRENT_DATE) - dcd.year as age_in_years FROM dams d INNER JOIN dam_construction_dates dcd ON d.id = dcd.dam_id WHERE d.location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity_sa (landfill VARCHAR(50), year INT, capacity INT); INSERT INTO landfill_capacity_sa (landfill, year, capacity) VALUES ('Cape Town', 2021, 9000000), ('Johannesburg', 2021, 11000000), ('Durban', 2021, 10000000), ('Pretoria', 2021, 12000000);
|
Landfill capacity of the 'Cape Town' and 'Johannesburg' landfills in 2021.
|
SELECT landfill, capacity FROM landfill_capacity_sa WHERE landfill IN ('Cape Town', 'Johannesburg') AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (1, 'Vostok 1', 'Roscosmos', '1961-04-12'), (2, 'Mercury-Redstone 3', 'NASA', '1961-05-05'), (3, 'SpaceShipOne', 'Scaled Composites', '2004-06-21');
|
What are the names of all spacecraft that were launched after the first manned spaceflight by a non-US agency but before the first manned spaceflight by a private company?
|
SELECT s.name FROM Spacecraft s WHERE s.launch_date > (SELECT launch_date FROM Spacecraft WHERE name = 'Vostok 1') AND s.launch_date < (SELECT launch_date FROM Spacecraft WHERE name = 'SpaceShipOne');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Garments (garment_id INT, garment_name VARCHAR(50), retail_price DECIMAL(5,2), material VARCHAR(50)); INSERT INTO Garments (garment_id, garment_name, retail_price, material) VALUES (1, 'Silk Blouse', 120.00, 'Silk'), (2, 'Wool Coat', 250.00, 'Wool'), (3, 'Cotton Trousers', 80.00, 'Cotton');
|
Update the retail price of all garments made of silk to 15% higher than the current price.
|
UPDATE Garments SET retail_price = retail_price * 1.15 WHERE material = 'Silk';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Port (port_id INT PRIMARY KEY, port_name VARCHAR(255)); INSERT INTO Port (port_id, port_name) VALUES (1, 'Hong Kong'); CREATE TABLE Vessel (vessel_id INT PRIMARY KEY, vessel_name VARCHAR(255)); CREATE TABLE Cargo (cargo_id INT, vessel_id INT, cargo_weight INT, PRIMARY KEY (cargo_id, vessel_id)); CREATE TABLE Vessel_Movement (vessel_id INT, movement_date DATE, port_id INT, PRIMARY KEY (vessel_id, movement_date));
|
What is the total cargo weight for each vessel that docked in Hong Kong in the last 6 months?
|
SELECT V.vessel_name, SUM(C.cargo_weight) FROM Vessel V JOIN Cargo C ON V.vessel_id = C.vessel_id JOIN Vessel_Movement VM ON V.vessel_id = VM.vessel_id WHERE VM.movement_date >= DATEADD(month, -6, GETDATE()) AND VM.port_id = (SELECT port_id FROM Port WHERE port_name = 'Hong Kong') GROUP BY V.vessel_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (id INT, years_of_experience INT); CREATE TABLE cases (id INT, attorney_id INT, case_outcome VARCHAR(10));
|
How many cases were won by attorneys with more than 5 years of experience?
|
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.years_of_experience > 5 AND case_outcome = 'won';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, Sold DATE);
|
How many properties have been sold in the last 12 months in each neighborhood?
|
SELECT NeighborhoodName, COUNT(*) AS PropertiesSoldCount FROM Properties JOIN Neighborhoods ON Properties.NeighborhoodID = Neighborhoods.NeighborhoodID WHERE Sold >= DATEADD(year, -1, CURRENT_TIMESTAMP) GROUP BY NeighborhoodName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_companies (id INT, name VARCHAR(20), location VARCHAR(20), sector VARCHAR(20), employees INT, ethical_ai BOOLEAN); INSERT INTO ai_companies (id, name, location, sector, employees, ethical_ai) VALUES (2, 'XYZ Tech', 'USA', 'Data Science', 30, true);
|
What is the average number of employees for companies in the 'Data Science' sector with ethical AI?
|
SELECT sector, AVG(employees) as avg_employees FROM ai_companies WHERE ethical_ai = true AND sector = 'Data Science' GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production (id INT, year INT, species VARCHAR(255), volume FLOAT); INSERT INTO timber_production (id, year, species, volume) VALUES (1, 2000, 'Pine', 1200), (2, 2000, 'Oak', 1500), (3, 2001, 'Spruce', 1800);
|
Show the total volume of timber production for each species in the 'timber_production' table, in descending order by total volume.
|
SELECT species, SUM(volume) FROM timber_production GROUP BY species ORDER BY SUM(volume) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Adoption (Country varchar(20), AdoptionPercentage float); INSERT INTO Adoption (Country, AdoptionPercentage) VALUES ('USA', 12.5), ('China', 25.6), ('Germany', 18.2), ('Norway', 65.7), ('Japan', 10.2);
|
What are the electric vehicle adoption statistics for each country?
|
SELECT Country, AdoptionPercentage FROM Adoption WHERE Country = 'USA' OR Country = 'China' OR Country = 'Germany' OR Country = 'Norway' OR Country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE individuals (individual_id INT, country VARCHAR(50), financial_capability_score DECIMAL(5, 2)); INSERT INTO individuals (individual_id, country, financial_capability_score) VALUES (1, 'India', 75.50), (2, 'Brazil', 80.25), (3, 'China', 68.75), (4, 'USA', 90.00), (5, 'India', 72.25), (6, 'Brazil', 85.00), (7, 'China', 65.00), (8, 'USA', 92.50);
|
Calculate the percentage of financially capable individuals in each country and display the country and percentage.
|
SELECT country, AVG(financial_capability_score) OVER (PARTITION BY country) * 100.0 AS percentage FROM individuals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmE (species VARCHAR(20), country VARCHAR(20), farming_method VARCHAR(20)); INSERT INTO FarmE (species, country, farming_method) VALUES ('Salmon', 'Chile', 'Non-organic'); INSERT INTO FarmE (species, country, farming_method) VALUES ('Trout', 'Chile', 'Organic'); INSERT INTO FarmE (species, country, farming_method) VALUES ('Tuna', 'Indonesia', 'Non-organic'); INSERT INTO FarmE (species, country, farming_method) VALUES ('Pangasius', 'Indonesia', 'Non-organic');
|
Identify the number of fish species farmed in Chile and Indonesia using non-organic methods.
|
SELECT COUNT(DISTINCT species) FROM FarmE WHERE country IN ('Chile', 'Indonesia') AND farming_method != 'Organic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_scores_v2 (player_id INT, game_name VARCHAR(50), score INT); INSERT INTO player_scores_v2 (player_id, game_name, score) VALUES (4, 'GameD', 450), (4, 'GameE', 400), (5, 'GameD', 550), (5, 'GameE', 500), (6, 'GameD', 650), (6, 'GameE', 600);
|
Which players have a higher score in GameD than in GameE?
|
SELECT a.player_id FROM player_scores_v2 a INNER JOIN player_scores_v2 b ON a.player_id = b.player_id WHERE a.game_name = 'GameD' AND b.game_name = 'GameE' AND a.score > b.score;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_investments (customer_id INT, investment FLOAT, investment_type VARCHAR(10), region VARCHAR(10)); INSERT INTO energy_investments (customer_id, investment, investment_type, region) VALUES (1, 5000, 'renewable', 'west'), (2, 3000, 'non-renewable', 'east'), (3, 7000, 'renewable', 'west');
|
What is the total investment in renewable energy for customers in the western region?
|
SELECT SUM(investment) FROM energy_investments WHERE investment_type = 'renewable' AND region = 'west';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CanadianBasketballTeams (TeamID INT, TeamName VARCHAR(50), Country VARCHAR(50), Wins INT, Losses INT); INSERT INTO CanadianBasketballTeams (TeamID, TeamName, Country, Wins, Losses) VALUES (1, 'Toronto Raptors', 'Canada', 48, 24); INSERT INTO CanadianBasketballTeams (TeamID, TeamName, Country, Wins, Losses) VALUES (2, 'Vancouver Grizzlies', 'Canada', 35, 47);
|
What is the win-loss record and ranking of basketball teams from Canada?
|
SELECT TeamID, TeamName, Country, Wins, Losses, RANK() OVER (ORDER BY Wins DESC, Losses ASC) AS WinLossRank FROM CanadianBasketballTeams;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(50), age INT, team VARCHAR(50));
|
Delete athlete records from the "athletes" table for athletes who are not part of any team
|
DELETE FROM athletes WHERE team IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attendees (id INT, event_id INT, no_attendees INT, online BOOLEAN); CREATE TABLE events (id INT, name VARCHAR(255), type VARCHAR(255), date DATE, country VARCHAR(255), online BOOLEAN);
|
How many total attendees were there for online events in Africa?
|
SELECT SUM(a.no_attendees) FROM attendees a INNER JOIN events e ON a.event_id = e.id WHERE e.country LIKE '%Africa%' AND e.online = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Visitor_Demographics (Visitor_ID INT, Age INT, Gender VARCHAR(255)); INSERT INTO Visitor_Demographics (Visitor_ID, Age, Gender) VALUES (1001, 25, 'Female'), (1002, 35, 'Male'), (1003, 45, 'Female'), (1004, 55, 'Male'); CREATE TABLE Digital_Exhibit_Interactions (Visitor_ID INT, Interaction_Date DATE); INSERT INTO Digital_Exhibit_Interactions (Visitor_ID, Interaction_Date) VALUES (1001, '2022-01-01'), (1002, '2022-01-02'), (1003, '2022-01-03'), (1004, '2022-01-04'), (1001, '2022-01-05'); CREATE VIEW Interacted_Digital_Exhibits AS SELECT Visitor_ID FROM Digital_Exhibit_Interactions GROUP BY Visitor_ID HAVING COUNT(DISTINCT Interaction_Date) > 0;
|
What is the total number of visitors who have interacted with digital exhibits, broken down by age group?
|
SELECT FLOOR(Age/10)*10 AS Age_Group, COUNT(DISTINCT Visitor_ID) FROM Visitor_Demographics INNER JOIN Interacted_Digital_Exhibits ON Visitor_Demographics.Visitor_ID = Interacted_Digital_Exhibits.Visitor_ID GROUP BY Age_Group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (species VARCHAR(50), population INT, status VARCHAR(20));
|
Update the animals table and set the status to 'Endangered' for any records where the population is below 100
|
UPDATE animals SET status = 'Endangered' WHERE population < 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists blockchain_domain.block_producers (producer_id INT PRIMARY KEY, name VARCHAR(255), jurisdiction VARCHAR(255), is_active BOOLEAN); CREATE TABLE if not exists blockchain_domain.blocks (block_id INT PRIMARY KEY, block_producer_id INT, FOREIGN KEY (block_producer_id) REFERENCES blockchain_domain.block_producers(producer_id));
|
Which block producers are active in the South Korean jurisdiction?
|
SELECT name FROM blockchain_domain.block_producers WHERE jurisdiction = 'South Korea' AND is_active = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE); INSERT INTO space_missions (id, mission_name, launch_country, launch_date) VALUES (1, 'Sputnik 1', 'Russia', '1957-10-04'); INSERT INTO space_missions (id, mission_name, launch_country, launch_date) VALUES (2, 'Explorer 1', 'USA', '1958-01-31');
|
List the names of all countries that have launched space missions before 1965.
|
SELECT launch_country FROM space_missions WHERE launch_date < '1965-01-01' GROUP BY launch_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bus_sales (id INT, year INT, city VARCHAR(50), bus_type VARCHAR(50), sales INT); INSERT INTO bus_sales (id, year, city, bus_type, sales) VALUES (1, 2020, 'Beijing', 'Electric', 20000), (2, 2020, 'Beijing', 'Diesel', 10000), (3, 2020, 'Shanghai', 'Electric', 15000);
|
What is the market share of electric buses in Beijing?
|
SELECT (SUM(CASE WHEN bus_type = 'Electric' THEN sales ELSE 0 END) * 100.0 / SUM(sales)) FROM bus_sales WHERE city = 'Beijing' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT); INSERT INTO companies (id, name, industry) VALUES (1, 'EcoInnovate', 'Eco-friendly'); INSERT INTO companies (id, name, industry) VALUES (2, 'SmartHome', 'Smart Home'); CREATE TABLE funds (company_id INT, funding_amount INT); INSERT INTO funds (company_id, funding_amount) VALUES (1, 500000); INSERT INTO funds (company_id, funding_amount) VALUES (2, 750000);
|
What is the total funding received by companies in the eco-friendly sector?
|
SELECT SUM(funds.funding_amount) FROM companies JOIN funds ON companies.id = funds.company_id WHERE companies.industry = 'Eco-friendly';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (id INT, product_id INT, sale_date DATE, sale_price DECIMAL(5,2)); CREATE TABLE Products (id INT, category TEXT, is_fair_trade BOOLEAN, price DECIMAL(5,2)); INSERT INTO Sales (id, product_id, sale_date, sale_price) VALUES (1, 1, '2021-11-01', 24.99), (2, 2, '2022-03-10', 15.99); INSERT INTO Products (id, category, is_fair_trade, price) VALUES (1, 'Skincare', true, 19.99), (2, 'Hair Care', false, 9.99);
|
What is the total revenue of fair-trade skincare products in the last year?
|
SELECT SUM(sale_price) FROM Sales JOIN Products ON Sales.product_id = Products.id WHERE is_fair_trade = true AND category = 'Skincare' AND sale_date >= '2021-01-01' AND sale_date <= '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty_publications (id INT, name VARCHAR(50), department VARCHAR(50), papers_published INT, publication_year INT);
|
What is the average number of academic papers published by faculty members in the Art department in the past 2 years?
|
SELECT AVG(papers_published) FROM faculty_publications WHERE department = 'Art' AND publication_year BETWEEN YEAR(CURRENT_DATE) - 2 AND YEAR(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE managers (manager_id INT, manager_name TEXT, manager_start_date DATE); CREATE TABLE programs (program_id INT, program_name TEXT, manager_id INT, start_date DATE, end_date DATE);
|
Display all managers and their respective programs from 'managers' and 'programs' tables
|
SELECT managers.manager_name, programs.program_name FROM managers INNER JOIN programs ON managers.manager_id = programs.manager_id AND managers.manager_start_date <= programs.start_date AND (programs.end_date IS NULL OR programs.end_date >= managers.manager_start_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50));
|
What is the total number of male and female readers?
|
SELECT gender, COUNT(*) as count FROM readers GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClimateChangeWordCount (id INT, word_count INT, category VARCHAR(20), newspaper VARCHAR(20)); INSERT INTO ClimateChangeWordCount (id, word_count, category, newspaper) VALUES (1, 600, 'climate change', 'Guardian'), (2, 700, 'climate change', 'Guardian'), (3, 550, 'politics', 'Guardian');
|
What is the average word count of articles about climate change in the "Guardian"?
|
SELECT AVG(word_count) FROM ClimateChangeWordCount WHERE category = 'climate change' AND newspaper = 'Guardian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IF NOT EXISTS public.example_table (id SERIAL PRIMARY KEY, name TEXT, created_at TIMESTAMP);
|
What is the name of the most recently created table in the "public" schema?
|
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY create_time DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (tour_id INT, location VARCHAR(50), tour_date DATE);
|
Insert a new virtual tour for the city of Istanbul on July 4, 2022 with ID 5.
|
INSERT INTO virtual_tours (tour_id, location, tour_date) VALUES (5, 'Istanbul', '2022-07-04');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_test (vehicle_manufacturer VARCHAR(10), vehicle_type VARCHAR(10), safety_rating INT);
|
Find the difference in average safety ratings for electric and hybrid vehicles in the 'safety_test' table, for each manufacturer.
|
SELECT vehicle_manufacturer, AVG(safety_rating) FILTER (WHERE vehicle_type = 'Electric') - AVG(safety_rating) FILTER (WHERE vehicle_type = 'Hybrid') AS safety_diff FROM safety_test GROUP BY vehicle_manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accessibility_data (id INT PRIMARY KEY, initiative_name VARCHAR(50), type VARCHAR(50), region VARCHAR(50));
|
Show a pivot table of the number of accessible technology initiatives by type and region in the 'accessibility_data' table
|
SELECT type, region, COUNT(*) as num_initiatives FROM accessibility_data GROUP BY type, region ORDER BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category_id INT, price DECIMAL(5,2));
|
Calculate the difference between the 'price' of a product and the average 'price' of all products in the same 'category_id' for the 'products' table
|
SELECT product_id, product_name, category_id, price, price - AVG(price) OVER (PARTITION BY category_id) AS price_difference FROM products;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (field_name VARCHAR(50), year INT, production_qty INT); INSERT INTO production (field_name, year, production_qty) VALUES ('MC652', 2015, 50000), ('MC652', 2016, 60000), ('MC973', 2015, 70000), ('MC973', 2016, 80000);
|
Determine the total production in the Gulf of Mexico for the years 2015 and 2016
|
SELECT SUM(production_qty) FROM production WHERE field_name IN ('MC652', 'MC973') AND year IN (2015, 2016);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MiningSites (site_id INT, site_name VARCHAR(50), location VARCHAR(50), accidents_reported INT); INSERT INTO MiningSites (site_id, site_name, location, accidents_reported) VALUES (1, 'Site A', 'California', 5), (2, 'Site B', 'Nevada', 3);
|
What is the total number of accidents reported at each mining site?
|
SELECT site_name, accidents_reported FROM MiningSites;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (location VARCHAR(50), waste_type VARCHAR(50), generation INT);
|
Update records in waste_generation table where waste generation is less than 100 tons
|
UPDATE waste_generation SET waste_type = 'organic' WHERE generation < 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (Project_ID INT, Project_Name VARCHAR(100), City VARCHAR(50), State CHAR(2), Zipcode INT, Start_Date DATE, End_Date DATE, Cost FLOAT);
|
List the top three cities with the highest number of construction projects in Canada.
|
SELECT City, COUNT(*) as Project_Count FROM Projects WHERE State = 'CA' GROUP BY City ORDER BY Project_Count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_centers_3 (id INT, name TEXT, state TEXT, location TEXT); INSERT INTO community_health_centers_3 (id, name, state, location) VALUES (1, 'Center A', 'California', 'suburban'), (2, 'Center B', 'New York', 'rural'), (3, 'Center C', 'Texas', 'suburban');
|
What is the average number of community health centers per state, in suburban areas?
|
SELECT state, AVG(COUNT(*)) FROM community_health_centers_3 WHERE location = 'suburban' GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerGenres (PlayerID INT, GenreID INT); INSERT INTO PlayerGenres (PlayerID, GenreID) VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 1), (2, 2), (2, 3), (2, 5), (3, 1), (3, 3), (3, 4), (3, 6), (4, 2), (4, 4), (4, 5), (4, 6), (5, 1), (5, 3), (5, 5), (5, 6), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6); CREATE TABLE Genres (GenreID INT); INSERT INTO Genres (GenreID) VALUES (1), (2), (3), (4), (5), (6);
|
Determine the number of unique players who have played games in all available genres.
|
SELECT COUNT(DISTINCT PlayerID) FROM (SELECT PlayerID FROM PlayerGenres GROUP BY PlayerID HAVING COUNT(DISTINCT GenreID) = (SELECT COUNT(*) FROM Genres)) AS AllGenresPlayers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Warehouses (WarehouseID, WarehouseName, Country) VALUES (1, 'India Warehouse', 'India'); CREATE TABLE Shipments (ShipmentID INT, WarehouseID INT, DeliveryTime INT);
|
What is the earliest delivery time for shipments from India?
|
SELECT MIN(DeliveryTime) FROM Shipments WHERE WarehouseID = (SELECT WarehouseID FROM Warehouses WHERE Country = 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OrganicCotton (id INT, purchase_date DATE, material_cost DECIMAL(5,2)); INSERT INTO OrganicCotton (id, purchase_date, material_cost) VALUES (1, '2021-07-01', 1000.00), (2, '2021-08-01', 2000.00), (3, '2021-09-01', 1500.00), (4, '2021-10-01', 2500.00); CREATE TABLE OrganicCertifications (id INT, certification_date DATE); INSERT INTO OrganicCertifications (id, certification_date) VALUES (1, '2021-06-01'), (2, '2021-07-01'), (3, '2021-08-01'), (4, '2021-09-01');
|
What is the total cost of materials sourced from certified organic cotton farms in the last quarter?
|
SELECT SUM(material_cost) FROM OrganicCotton JOIN OrganicCertifications ON OrganicCotton.id = OrganicCertifications.id WHERE OrganicCotton.purchase_date >= '2021-07-01' AND OrganicCotton.purchase_date <= '2021-10-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organization (id INT, name VARCHAR(255)); CREATE TABLE volunteer (id INT, name VARCHAR(255), organization_id INT, volunteer_date DATE); CREATE TABLE donation (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE);
|
What is the total number of volunteers and total donation amount for each organization in a given year?
|
SELECT o.name, COUNT(v.id) as total_volunteers, SUM(d.amount) as total_donations FROM volunteer v JOIN organization o ON v.organization_id = o.id JOIN donation d ON o.id = d.organization_id WHERE YEAR(v.volunteer_date) = 2022 AND YEAR(d.donation_date) = 2022 GROUP BY o.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soccer_teams (team_id INT, name VARCHAR(50)); CREATE TABLE soccer_games (game_id INT, home_team INT, away_team INT, home_team_score INT, away_team_score INT); INSERT INTO soccer_teams (team_id, name) VALUES (1, 'Manchester United'), (2, 'Liverpool'), (3, 'Arsenal'); INSERT INTO soccer_games (game_id, home_team, away_team, home_team_score, away_team_score) VALUES (1, 1, 2, 2, 1), (2, 2, 3, 3, 1), (3, 3, 1, 0, 3);
|
What is the total number of points scored by each team in the 'soccer_games' table?
|
SELECT name AS team, SUM(home_team_score) AS total_home_points, SUM(away_team_score) AS total_away_points, SUM(home_team_score + away_team_score) AS total_points FROM soccer_games JOIN soccer_teams ON soccer_games.home_team = soccer_teams.team_id OR soccer_games.away_team = soccer_teams.team_id GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, category VARCHAR(20), risk_score INT, last_observed DATE); INSERT INTO vulnerabilities (id, category, risk_score, last_observed) VALUES (1, 'network', 8, '2021-01-01'); INSERT INTO vulnerabilities (id, category, risk_score, last_observed) VALUES (2, 'network', 6, '2021-01-02');
|
What is the average risk score for vulnerabilities in the 'network' category, partitioned by the 'last observed' date?
|
SELECT last_observed, AVG(risk_score) OVER (PARTITION BY category ORDER BY last_observed) FROM vulnerabilities WHERE category = 'network';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_floor (ocean TEXT, depth INT); INSERT INTO ocean_floor (ocean, depth) VALUES ('Atlantic', 8000), ('Pacific', 10000);
|
What are the maximum and minimum depths of the ocean floor in the Atlantic Ocean?
|
SELECT MAX(depth) FROM ocean_floor WHERE ocean = 'Atlantic' UNION SELECT MIN(depth) FROM ocean_floor WHERE ocean = 'Atlantic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Local_Economic_Impact (region TEXT, impact NUMERIC); INSERT INTO Local_Economic_Impact (region, impact) VALUES ('North', 15000), ('South', 12000), ('East', 18000), ('West', 10000);
|
What is the distribution of local economic impact by region?
|
SELECT region, AVG(impact) FROM Local_Economic_Impact GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ceo (company_id INT, CEO TEXT); INSERT INTO ceo (company_id, CEO) VALUES (1, 'male'), (2, 'non-binary'), (3, 'female'), (4, 'male'), (5, 'female');
|
How many companies in the "fintech" sector have a female CEO and have raised more than 5 million dollars in funding?
|
SELECT COUNT(*) FROM company JOIN ceo ON company.id = ceo.company_id WHERE company.industry = 'fintech' AND ceo.CEO = 'female' AND company.id IN (SELECT company_id FROM funding WHERE amount > 5000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_visits (id INT, visit_date DATE, state CHAR(2), rural BOOLEAN); INSERT INTO medical_visits (id, visit_date, state, rural) VALUES (1, '2023-01-01', 'GA', true), (2, '2023-01-15', 'GA', true);
|
Identify the top 3 states with the highest number of medical visits in rural areas in the last month.
|
SELECT state, COUNT(*) as visits FROM medical_visits WHERE rural = true AND visit_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY state ORDER BY visits DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE violations (id INT, country VARCHAR(255), year INT, violation_count INT); INSERT INTO violations (id, country, year, violation_count) VALUES (1, 'USA', 2020, 350), (2, 'Canada', 2020, 200), (3, 'USA', 2019, 300);
|
How many food safety violations were recorded in the USA in 2020?
|
SELECT SUM(violation_count) FROM violations WHERE country = 'USA' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exit (id INT, company_id INT, exit_type VARCHAR(50), exit_value INT, exit_date DATE); INSERT INTO exit (id, company_id, exit_type, exit_value, exit_date) VALUES (4, 4, 'IPO', 30000000, '2019-01-02'); INSERT INTO exit (id, company_id, exit_type, exit_value, exit_date) VALUES (5, 4, 'Acquisition', 35000000, '2020-07-10');
|
What is the difference in the previous and current exit values for companies that had multiple exit events in 'Singapore'?
|
SELECT e.company_id, LAG(exit_value, 1) OVER (PARTITION BY company_id ORDER BY exit_date) as previous_exit_value, exit_value, exit_date FROM exit e WHERE company_id IN (SELECT company_id FROM exit GROUP BY company_id HAVING COUNT(*) > 1) AND (SELECT country FROM company WHERE id = e.company_id) = 'Singapore';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE new_cause (cause_id INT, cause_name VARCHAR(50), donation_amount DECIMAL(10, 2));
|
Insert a new cause 'Research' with donation amount 22000.00.
|
INSERT INTO new_cause (cause_id, cause_name, donation_amount) VALUES (4, 'Research', 22000.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT, player_id INT, score INT);
|
Delete 'games' records where the 'score' is above 150
|
DELETE FROM games WHERE score > 150;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetic_brands (brand_id INT, brand_name VARCHAR(100), region VARCHAR(50), cruelty_free BOOLEAN); INSERT INTO cosmetic_brands (brand_id, brand_name, region, cruelty_free) VALUES (1, 'Clinique', 'North America', false), (2, 'The Body Shop', 'Europe', true), (3, 'Lush', 'North America', true), (4, 'Estee Lauder', 'Europe', false), (5, 'Natio', 'Australia', true);
|
Which cruelty-free cosmetic brands are available in the 'North America' and 'Europe' regions?
|
SELECT brand_name FROM cosmetic_brands WHERE region IN ('North America', 'Europe') AND cruelty_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grants (id INT, amount INT, faculty_name VARCHAR(50), rank VARCHAR(20));
|
Calculate the average grant amount awarded to faculty members in the 'grants' table by their 'rank'.
|
SELECT rank, AVG(amount) FROM grants GROUP BY rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Fans (fan_id INT, fan_name VARCHAR(255), city VARCHAR(255), team VARCHAR(255)); INSERT INTO Fans VALUES (1, 'John Doe', 'New York', 'MLS'), (2, 'Jane Doe', 'Los Angeles', 'MLS');
|
What is the total number of 'MLS' fans from 'New York' and 'Los Angeles'?
|
SELECT COUNT(fan_id) FROM Fans WHERE (city = 'New York' OR city = 'Los Angeles') AND team = 'MLS';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE unions (id INT, name VARCHAR(255), industry VARCHAR(255), member_age INT); INSERT INTO unions (id, name, industry, member_age) VALUES (1, 'Union A', 'construction', 35), (2, 'Union B', 'technology', 28);
|
What is the average age of male members in the 'construction' union?
|
SELECT AVG(member_age) FROM unions WHERE name = 'Union A' AND gender = 'male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy (id INT, event VARCHAR(50), country VARCHAR(50), num_participating_countries INT, year INT); INSERT INTO defense_diplomacy (id, event, country, num_participating_countries, year) VALUES (1, 'Joint Military Exercise', 'India', 15, 2022); INSERT INTO defense_diplomacy (id, event, country, num_participating_countries, year) VALUES (2, 'Military Attaché Visit', 'Japan', 5, 2022); INSERT INTO defense_diplomacy (id, event, country, num_participating_countries, year) VALUES (3, 'Defense Minister Summit', 'Australia', 10, 2022);
|
What are the defense diplomacy events in 2022 with the highest number of participating countries?
|
SELECT event, country, num_participating_countries FROM defense_diplomacy WHERE year = 2022 ORDER BY num_participating_countries DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, name TEXT, signup_date DATE, program TEXT); INSERT INTO volunteers (id, name, signup_date, program) VALUES (1, 'Bob Brown', '2022-01-15', 'Education'), (2, 'Charlie Davis', '2022-03-30', 'Arts'), (3, 'Eva Thompson', '2021-12-31', 'Education'), (4, 'Grace Wilson', '2021-10-01', 'Arts'), (5, 'Harry Moore', '2021-08-01', 'Education');
|
How many volunteers signed up in Q3 2021 for each program?
|
SELECT program, COUNT(*) AS num_volunteers FROM volunteers WHERE signup_date >= '2021-07-01' AND signup_date < '2021-10-01' GROUP BY program;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_stats (permit_id INT, fine INT);
|
Add a new labor violation with a fine of $7000 for permit ID 789
|
INSERT INTO labor_stats (permit_id, fine) VALUES (789, 7000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE miami_fire_responses (id INT, response_time INT, location VARCHAR(20)); INSERT INTO miami_fire_responses (id, response_time, location) VALUES (1, 120, 'Miami'), (2, 90, 'Miami');
|
What is the average response time for fire stations in Miami?
|
SELECT AVG(response_time) FROM miami_fire_responses WHERE location = 'Miami';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Department (id INT, name VARCHAR(50), initiatives INT); INSERT INTO Department (id, name, initiatives) VALUES (1, 'Transportation', 30); INSERT INTO Department (id, name, initiatives) VALUES (2, 'Education', 50);
|
Find the total number of open data initiatives by department
|
SELECT Department.name, SUM(Department.initiatives) AS total_initiatives FROM Department WHERE Department.initiatives IS NOT NULL GROUP BY Department.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, museum_name VARCHAR(255), artist_id INT, artwork_id INT); INSERT INTO Exhibitions (exhibition_id, museum_name, artist_id, artwork_id) VALUES (1, 'Museum X', 101, 201), (2, 'Museum Y', 101, 202), (3, 'Museum Z', 101, 203);
|
Which artworks were exhibited by artist '101'?
|
SELECT artwork_id FROM Exhibitions WHERE artist_id = 101;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EquipmentTypes (EquipmentTypeID INT, EquipmentType VARCHAR(50)); CREATE TABLE MaintenanceCosts (CostID INT, EquipmentTypeID INT, Cost DECIMAL(10,2), MaintenanceDate DATE); INSERT INTO EquipmentTypes (EquipmentTypeID, EquipmentType) VALUES (1, 'Tank'), (2, 'Fighter Jet'), (3, 'Helicopter'); INSERT INTO MaintenanceCosts (CostID, EquipmentTypeID, Cost, MaintenanceDate) VALUES (1, 1, 500000, '2021-01-01'), (2, 1, 750000, '2022-02-03'), (3, 2, 1000000, '2021-06-15'), (4, 3, 250000, '2022-07-20');
|
What is the average maintenance cost for military equipment by type for the past year?
|
SELECT E.EquipmentType, AVG(M.Cost) as AvgMaintenanceCost FROM EquipmentTypes E INNER JOIN MaintenanceCosts M ON E.EquipmentTypeID = M.EquipmentTypeID WHERE M.MaintenanceDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY E.EquipmentType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage (id INT, name TEXT, capacity FLOAT, region TEXT); INSERT INTO energy_storage (id, name, capacity, region) VALUES (1, 'ABC Battery', 2500, 'North'), (2, 'XYZ Battery', 3000, 'South'), (3, 'DEF Battery', 3500, 'West'), (4, 'JKL Battery', 1500, 'North'), (5, 'MNO Battery', 2000, 'South');
|
Find the energy storage systems and their capacities by region, ordered by capacity and region.
|
SELECT region, name, capacity FROM energy_storage ORDER BY region, capacity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine_operators (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), gender VARCHAR(10), years_of_experience INT); INSERT INTO mine_operators (id, name, role, gender, years_of_experience) VALUES (1, 'John Doe', 'Mining Engineer', 'Male', 7);
|
Insert a new record for a mining engineer with ID 2, named Maria, role Mining Engineer, gender Female, and 5 years of experience.
|
INSERT INTO mine_operators (id, name, role, gender, years_of_experience) VALUES (2, 'Maria', 'Mining Engineer', 'Female', 5);
|
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.