context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE military_equipment_maintenance (equipment_id INT, maintenance_company VARCHAR(255), cost FLOAT); INSERT INTO military_equipment_maintenance (equipment_id, maintenance_company, cost) VALUES (1, 'Global Maintainers', 5000.00), (2, 'Tactical Technologies', 7000.00);
|
Get the average maintenance cost for military equipment
|
SELECT AVG(cost) FROM military_equipment_maintenance;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_weather (date DATE, temperature FLOAT);
|
What is the minimum temperature recorded in the 'arctic_weather' table for each month?
|
SELECT EXTRACT(MONTH FROM date) AS month, MIN(temperature) AS min_temperature FROM arctic_weather GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_land_trusts (id INT, property_price FLOAT, num_owners INT); INSERT INTO community_land_trusts (id, property_price, num_owners) VALUES (1, 600000, 2), (2, 700000, 3), (3, 800000, 2);
|
Find the number of co-owned properties in the community_land_trusts table.
|
SELECT COUNT(*) FROM community_land_trusts WHERE num_owners > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Climate_Data ( id INT PRIMARY KEY, location VARCHAR(50), temperature FLOAT, precipitation FLOAT, date DATE ); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (1, 'Longyearbyen', -10.5, 50.0, '2022-01-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (2, 'Tromsø', -5.0, 70.0, '2022-01-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (3, 'Arctic Circle', -15.0, 30.0, '2022-01-01');
|
What are the temperature and precipitation data for the Arctic Circle in 2022?
|
SELECT location, temperature, precipitation FROM Climate_Data WHERE location = 'Arctic Circle' AND date BETWEEN '2022-01-01' AND '2022-12-31'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SupportAsia (Id INT, SupportType VARCHAR(50), Quantity INT); INSERT INTO SupportAsia (Id, SupportType, Quantity) VALUES (1, 'Food', 100), (2, 'Shelter', 200), (3, 'Medical', 150), (4, 'Water', 200);
|
What is the average quantity of each type of support provided in Asia?
|
SELECT SupportType, AVG(Quantity) FROM SupportAsia GROUP BY SupportType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Nonprofits (NonprofitID INT, Name VARCHAR(50), City VARCHAR(50), State VARCHAR(2), Zip VARCHAR(10), MissionStatement TEXT); CREATE TABLE Grants (GrantID INT, DonorID INT, NonprofitID INT, GrantAmount DECIMAL(10,2), Date DATE); CREATE TABLE Donors (DonorID INT, Name VARCHAR(50), City VARCHAR(50), State VARCHAR(2), Zip VARCHAR(10), DonationAmount DECIMAL(10,2));
|
What is the mission statement for the nonprofit with the highest average donation amount?
|
SELECT MissionStatement FROM Nonprofits N WHERE N.NonprofitID = (SELECT G.NonprofitID FROM Grants G INNER JOIN Donors D ON G.DonorID = D.DonorID GROUP BY G.NonprofitID ORDER BY AVG(DonationAmount) DESC LIMIT 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Department (id INT, name VARCHAR(50), personnel INT); INSERT INTO Department (id, name, personnel) VALUES (1, 'Infantry', 500); INSERT INTO Department (id, name, personnel) VALUES (2, 'Artillery', 250);
|
What is the average number of military personnel in each department in the 'Department' table?
|
SELECT name, AVG(personnel) FROM Department GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients(id INT, name TEXT, organic BOOLEAN, source_country TEXT, price DECIMAL); INSERT INTO ingredients(id, name, organic, source_country, price) VALUES (1, 'aloe vera', true, 'US', 2.50), (2, 'lavender', true, 'France', 7.00), (3, 'jojoba oil', true, 'Argentina', 9.50), (4, 'coconut oil', true, 'Philippines', 4.25);
|
What is the average price of organic ingredients sourced from the US?
|
SELECT AVG(price) FROM ingredients WHERE organic = true AND source_country = 'US';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attendees (id INT PRIMARY KEY, name VARCHAR(50), age INT, event_id INT); CREATE VIEW dance_workshops AS SELECT * FROM events WHERE event_type = 'Dance Workshop';
|
What is the minimum age of attendees for dance workshops in the 'attendees' table?
|
SELECT MIN(age) AS min_age_dance_workshop FROM attendees INNER JOIN dance_workshops ON attendees.event_id = dance_workshops.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE devices (id INT, name VARCHAR(50), accessibility_rating INT);CREATE TABLE people (id INT, disability BOOLEAN, device_id INT);
|
What is the total number of accessible devices for people with disabilities?
|
SELECT COUNT(*) FROM devices d INNER JOIN people p ON d.id = p.device_id WHERE p.disability = true AND d.accessibility_rating > 6;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (id INT, name VARCHAR(255)); CREATE TABLE medical_supplies (id INT, region_id INT, sent_date DATE, quantity INT);
|
How many medical supplies were sent to each region in Syria in the last 12 months?
|
SELECT regions.name, SUM(medical_supplies.quantity) FROM medical_supplies JOIN regions ON medical_supplies.region_id = regions.id WHERE regions.name = 'Syria' AND medical_supplies.sent_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND CURRENT_DATE GROUP BY medical_supplies.region_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MathAccommodations (AccommodationID INT, Department VARCHAR(20)); INSERT INTO MathAccommodations (AccommodationID, Department) VALUES (1, 'Mathematics'), (2, 'Mathematics'), (3, 'Mathematics'); CREATE TABLE HistoryAccommodations (AccommodationID INT, Department VARCHAR(20)); INSERT INTO HistoryAccommodations (AccommodationID, Department) VALUES (4, 'History'), (5, 'History');
|
How many unique types of accommodations are provided in the Mathematics department, and how many unique types of accommodations are provided in the History department?
|
SELECT COUNT(DISTINCT AccommodationID) FROM MathAccommodations WHERE Department = 'Mathematics' INTERSECT SELECT COUNT(DISTINCT AccommodationID) FROM HistoryAccommodations WHERE Department = 'History';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_habitats (id INT PRIMARY KEY, habitat_name VARCHAR, num_animals INT); INSERT INTO animal_habitats (id, habitat_name, num_animals) VALUES (1, 'Rainforest', 600), (2, 'Savannah', 300), (3, 'Mountains', 200);
|
What is the total number of animals in the 'animal_habitats' table?
|
SELECT SUM(num_animals) FROM animal_habitats;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); CREATE TABLE games (game_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT);
|
What is the highest scored game for each team in the NBA?
|
SELECT home_team_id, MAX(home_team_score) AS high_score FROM games GROUP BY home_team_id; SELECT away_team_id, MAX(away_team_score) AS high_score FROM games GROUP BY away_team_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, client_name TEXT, country TEXT, financial_capability_score FLOAT); INSERT INTO clients (client_id, client_name, country, financial_capability_score) VALUES (1, 'John Doe', 'China', 7), (2, 'Jane Smith', 'Japan', 8), (3, 'Alice Johnson', 'India', 6), (4, 'Bob Brown', 'United States', 9);
|
Find the average financial capability score for clients in Asia.
|
SELECT AVG(financial_capability_score) FROM clients WHERE country IN ('China', 'Japan', 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (supplier_id VARCHAR(50), supplier_name VARCHAR(50), supplier_country VARCHAR(50));
|
Add new supplier 'Fair Trade Co.' with id 'FTC123' and country 'Canada'
|
INSERT INTO suppliers (supplier_id, supplier_name, supplier_country) VALUES ('FTC123', 'Fair Trade Co.', 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tech_for_social_good (id INT, name VARCHAR(50), release_date DATE); INSERT INTO tech_for_social_good (id, name, release_date) VALUES (1, 'Tech1', '2021-01-01'); INSERT INTO tech_for_social_good (id, name, release_date) VALUES (2, 'Tech2', '2021-04-20');
|
What is the name and release date of the most recent technology for social good?
|
SELECT name, release_date, ROW_NUMBER() OVER (ORDER BY release_date DESC) AS rank FROM tech_for_social_good;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teacher_trainings (training_id INT, teacher_id INT, training_date DATE, course_completed INT, level VARCHAR(20)); INSERT INTO teacher_trainings (training_id, teacher_id, training_date, course_completed, level) VALUES (1, 1, '2022-01-01', 1, 'Beginner'), (2, 1, '2022-02-01', 2, 'Intermediate'), (3, 2, '2022-01-01', 3, 'Advanced'), (4, 2, '2022-02-01', 1, 'Beginner'); CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), department VARCHAR(20)); INSERT INTO teachers (teacher_id, teacher_name, department) VALUES (1, 'Ms. Lopez', 'Science'), (2, 'Mr. Johnson', 'English');
|
What is the distribution of professional development courses completed by teachers by department and level?
|
SELECT department, level, COUNT(*) FROM teacher_trainings JOIN teachers ON teacher_trainings.teacher_id = teachers.teacher_id GROUP BY department, level;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MusicianFunding (id INT, musician_name VARCHAR(30), musician_community VARCHAR(30), funding_amount INT, funding_year INT); INSERT INTO MusicianFunding (id, musician_name, musician_community, funding_amount, funding_year) VALUES (1, 'Taylor Raincloud', 'BIPOC', 5000, 2021), (2, 'Jamal Sunshine', 'BIPOC', 4000, 2021), (3, 'Grace Moon', 'BIPOC', 6000, 2021);
|
What was the total funding received by BIPOC musicians in 2021?
|
SELECT SUM(funding_amount) as total_funding FROM MusicianFunding WHERE musician_community = 'BIPOC' AND funding_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE australia_europium (id INT, year INT, units INT); INSERT INTO australia_europium (id, year, units) VALUES (1, 2014, 350), (2, 2015, 400), (3, 2016, 450), (4, 2017, 500), (5, 2018, 550);
|
How many europium units were extracted in Australia after 2016?
|
SELECT COUNT(*) FROM australia_europium WHERE year > 2016;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donor_type (donor_id INT, recurring BOOLEAN, donation_year INT); INSERT INTO donor_type (donor_id, recurring, donation_year) VALUES (1, TRUE, 2020), (2, FALSE, 2020), (3, TRUE, 2021), (4, FALSE, 2021), (5, TRUE, 2022);
|
What is the percentage of total donations coming from recurring donors in the last 3 years?
|
SELECT 100.0 * SUM(CASE WHEN recurring THEN 1 ELSE 0 END) / COUNT(*) AS percentage_recurring FROM donor_type WHERE donation_year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (id INT, name VARCHAR(50)); CREATE TABLE visitor_stats (region_id INT, year INT, visitors INT); INSERT INTO regions (id, name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); INSERT INTO visitor_stats (region_id, year, visitors) VALUES (1, 2021, 10000), (1, 2020, 8000), (2, 2021, 12000), (2, 2020, 9000), (3, 2021, 7000), (3, 2020, 6000);
|
How many tourists visited each region last year?
|
SELECT r.name, SUM(vs.visitors) as total_visitors FROM regions r JOIN visitor_stats vs ON r.id = vs.region_id WHERE vs.year = 2021 GROUP BY r.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, region VARCHAR, date DATE); INSERT INTO security_incidents (id, region, date) VALUES (1, 'North America', '2021-01-01'), (2, 'Europe', '2021-02-01'), (3, 'Asia', '2021-03-01'), (4, 'South America', '2021-04-01'), (5, 'Africa', '2021-05-01');
|
How many security incidents were reported in each region in the past year?
|
SELECT region, COUNT(*) FROM security_incidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Gender VARCHAR(10), Department VARCHAR(50), Age INT); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (1, 'John Doe', 'Male', 'Mining Operations', 35); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (2, 'Jane Smith', 'Female', 'Human Resources', 40); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (3, 'David Johnson', 'Male', 'Finance', 30);
|
What is the percentage of female employees in the mining company?
|
SELECT (COUNT(*) FILTER (WHERE Gender = 'Female')) * 100.0 / COUNT(*) FROM Employees;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA Compliance;CREATE TABLE PollutionViolations (id INT, country TEXT, region TEXT, year INT, violations INT); INSERT INTO PollutionViolations (id, country, region, year, violations) VALUES (1, 'Bahamas', 'Caribbean', 2019, 3), (2, 'Jamaica', 'Caribbean', 2020, 5), (3, 'Puerto Rico', 'Caribbean', 2019, 2), (4, 'Cuba', 'Caribbean', 2020, 4), (5, 'Haiti', 'Caribbean', 2019, 6), (6, 'Dominican Republic', 'Caribbean', 2020, 7);
|
Identify the number of pollution violations in the Caribbean region in the 'Compliance' schema.
|
SELECT region, SUM(violations) AS total_violations FROM Compliance.PollutionViolations WHERE region = 'Caribbean' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (id, name, country, amount, donation_date) VALUES (1, 'John Doe', 'USA', 500.00, '2022-01-05'), (2, 'Jane Smith', 'USA', 300.00, '2022-03-15'); CREATE TABLE organizations (id INT, name TEXT, country TEXT); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); CREATE VIEW individual_donations AS SELECT donors.id, donors.name, donations.amount, donations.donation_date FROM donors INNER JOIN donations ON donors.id = donations.donor_id WHERE donors.id NOT IN (SELECT organizations.id FROM organizations);
|
What was the total amount donated by individuals in the United States in Q1 2022?
|
SELECT SUM(amount) FROM individual_donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE securities (security_id INT PRIMARY KEY, security_symbol VARCHAR(10), security_name VARCHAR(100));
|
Insert a new row into the 'securities' table with a security ID of 123, a security symbol of 'ABC', and a security name of 'ABC Corporation'
|
INSERT INTO securities (security_id, security_symbol, security_name) VALUES (123, 'ABC', 'ABC Corporation');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forest_plot (id INT PRIMARY KEY, size FLOAT, species_id INT, FOREIGN KEY (species_id) REFERENCES species(id)); CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(50), population INT);
|
Delete any forest plots that are larger than 50 hectares and have a population of less than 500 for the associated species.
|
DELETE FROM forest_plot fp USING species s WHERE fp.size > 50 AND fp.species_id = s.id AND s.population < 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Faculty(FacultyID INT, Department VARCHAR(255), LastGrantDate DATE); INSERT INTO Faculty VALUES (1, 'Mathematics', '2021-01-01');
|
Identify faculty members in the Mathematics department who have not received any research grants in the last year.
|
SELECT FacultyID FROM Faculty WHERE Faculty.Department = 'Mathematics' AND Faculty.LastGrantDate < DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodations (id INT, name TEXT, country TEXT, rating FLOAT, eco_friendly BOOLEAN); INSERT INTO accommodations (id, name, country, rating, eco_friendly) VALUES (1, 'Eco Lodge', 'Brazil', 4.5, true), (2, 'Green Hotel', 'Brazil', 4.2, true), (3, 'Standard Hotel', 'Brazil', 3.8, false);
|
What is the average rating of eco-friendly accommodations in Brazil?
|
SELECT AVG(rating) FROM accommodations WHERE eco_friendly = true AND country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Gender VARCHAR(255)); INSERT INTO Employees (EmployeeID, Department, Gender) VALUES (1, 'Mining Operations', 'Female'), (2, 'Mining Operations', 'Male'), (3, 'Mining Operations', 'Female');
|
What is the percentage of female employees in the Mining Operations department?
|
SELECT Department, Gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE Department = 'Mining Operations') AS Percentage FROM Employees WHERE Department = 'Mining Operations' GROUP BY Department, Gender HAVING Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hr.job_applications (id INT, job_id INT, applicant_id INT, applied_date DATE, job_location VARCHAR(50));
|
List the number of job applications in the 'hr' schema's 'job_applications' table by job location
|
SELECT job_location, COUNT(*) FROM hr.job_applications GROUP BY job_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sensor_costs (cost_date DATE, sensor_type VARCHAR(20), cost FLOAT); INSERT INTO sensor_costs (cost_date, sensor_type, cost) VALUES ('2022-06-01', 'Temperature', 250.00), ('2022-06-01', 'Humidity', 150.00), ('2022-06-03', 'Temperature', 260.00), ('2022-06-05', 'Humidity', 160.00), ('2022-06-07', 'Temperature', 270.00);
|
List the total costs associated with IoT sensors for the past month
|
SELECT sensor_type, SUM(cost) FROM sensor_costs WHERE cost_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY sensor_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aircraft (id INT, model VARCHAR(255), manufacturer VARCHAR(255)); INSERT INTO aircraft (id, model, manufacturer) VALUES (1, '737', 'Boeing'), (2, '747', 'Boeing'), (3, 'A320', 'Airbus'), (4, 'A330', 'Airbus'), (5, 'ATR-72', 'Airbus India');
|
List the total number of aircraft manufactured by each company, including 'Boeing' and 'Airbus India'.
|
SELECT manufacturer, COUNT(*) FROM aircraft GROUP BY manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE music_concerts (id INT, location VARCHAR(20), year INT, genre VARCHAR(20), price DECIMAL(5,2)); INSERT INTO music_concerts (id, location, year, genre, price) VALUES (1, 'India', 2017, 'traditional music', 15.00), (2, 'India', 2018, 'traditional music', 20.00), (3, 'India', 2019, 'traditional music', 25.00), (4, 'Nepal', 2018, 'traditional music', 18.00), (5, 'Bhutan', 2018, 'traditional music', 16.50);
|
What is the maximum ticket price for traditional music concerts in India in 2018?
|
SELECT MAX(price) FROM music_concerts WHERE location = 'India' AND genre = 'traditional music' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE construction_workers (worker_id INT, occupation VARCHAR(50), state VARCHAR(50), salary INT); INSERT INTO construction_workers (worker_id, occupation, state, salary) VALUES (1, 'Carpenter', 'Florida', 60000); INSERT INTO construction_workers (worker_id, occupation, state, salary) VALUES (2, 'Electrician', 'Florida', 70000);
|
What is the total number of construction workers in the state of Florida, grouped by occupation?
|
SELECT occupation, COUNT(*) FROM construction_workers WHERE state = 'Florida' GROUP BY occupation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_control_initiatives (initiative_id INT, initiative_name TEXT, region TEXT); INSERT INTO pollution_control_initiatives (initiative_id, initiative_name, region) VALUES (1, 'Initiative X', 'North Atlantic'), (2, 'Initiative Y', 'South Pacific'), (3, 'Initiative Z', 'Indian Ocean');
|
List the total number of pollution control initiatives by region
|
SELECT COUNT(*) FROM pollution_control_initiatives GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DonorContributions (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, region VARCHAR(50), donor_type VARCHAR(50)); INSERT INTO DonorContributions (donor_id, donation_amount, donation_date, region, donor_type) VALUES (10, 500, '2022-01-01', 'Pacific', 'Recurring'), (11, 600, '2022-02-01', 'Pacific', 'One-time'), (12, 400, '2022-03-01', 'Atlantic', 'Recurring');
|
Find the average donation amount from recurring donors in the Pacific region in 2022.
|
SELECT AVG(donation_amount) FROM DonorContributions WHERE region = 'Pacific' AND donation_date BETWEEN '2022-01-01' AND '2022-12-31' AND donor_type = 'Recurring';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipment (id INT PRIMARY KEY, warehouse_id INT, carrier_id INT, package_count INT, shipped_date DATE);
|
Insert a new shipment record with ID 124, warehouse ID 1, carrier ID 3, package count 600, and shipped date '2022-01-15'.
|
INSERT INTO shipment (id, warehouse_id, carrier_id, package_count, shipped_date) VALUES (124, 1, 3, 600, '2022-01-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE unesco_sites (id INT, country VARCHAR(50), site_name VARCHAR(100)); INSERT INTO unesco_sites (id, country, site_name) VALUES (1, 'Brazil', 'Iguazu National Park'), (2, 'India', 'Taj Mahal');
|
Identify countries with no UNESCO heritage sites.
|
SELECT country FROM unesco_sites GROUP BY country HAVING COUNT(site_name) = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SensorData (ID INT, SensorID INT, Timestamp DATETIME, Temperature FLOAT); CREATE VIEW LastWeekSensorData AS SELECT * FROM SensorData WHERE Timestamp BETWEEN DATEADD(day, -7, GETDATE()) AND GETDATE(); CREATE VIEW Field1Sensors AS SELECT * FROM SensorData WHERE FieldID = 1; CREATE VIEW Field1LastWeekSensorData AS SELECT * FROM LastWeekSensorData WHERE SensorData.SensorID = Field1Sensors.SensorID;
|
What is the average temperature trend in the past week for all IoT sensors in the 'Field1'?
|
SELECT AVG(Temperature) OVER (PARTITION BY SensorID ORDER BY Timestamp ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS AvgTemperatureTrend FROM Field1LastWeekSensorData;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (1, 'Eastside'), (2, 'Westside'), (3, 'Greenhills'); CREATE TABLE emergency_incidents (id INT, district_id INT, incident_type VARCHAR(50), response_time INT); INSERT INTO emergency_incidents (id, district_id, incident_type, response_time) VALUES (1, 1, 'fire', 8), (2, 1, 'medical', 7), (3, 2, 'fire', 6);
|
What is the total number of emergency incidents reported in each district, grouped by incident type?
|
SELECT districts.name, emergency_incidents.incident_type, COUNT(*) AS total_incidents FROM districts JOIN emergency_incidents ON districts.id = emergency_incidents.district_id GROUP BY districts.name, emergency_incidents.incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (id INT, name VARCHAR(100), department VARCHAR(50), country VARCHAR(50)); INSERT INTO Employees (id, name, department, country) VALUES (1, 'John Doe', 'IT', 'United States'), (2, 'Jane Smith', 'Marketing', 'Canada'), (3, 'Mike Johnson', 'IT', 'France'), (4, 'Sara Connor', 'HR', 'United States'), (5, 'David Brown', 'Finance', 'Canada');
|
Show the number of employees in each department, excluding the IT department.
|
SELECT department, COUNT(*) FROM Employees WHERE department != 'IT' GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TourTypes (TypeID INT, TourName VARCHAR(255)); INSERT INTO TourTypes (TypeID, TourName) VALUES (1, 'Eco-Friendly Tour'), (2, 'Cultural Tour'); CREATE TABLE Bookings (BookingID INT, TourTypeID INT, Country VARCHAR(255), Revenue DECIMAL(10,2)); INSERT INTO Bookings (BookingID, TourTypeID, Country, Revenue) VALUES (1, 1, 'France', 800.00), (2, 1, 'France', 1200.00), (3, 2, 'Spain', 1500.00), (4, 2, 'Spain', 2000.00);
|
What is the total revenue generated from cultural tours in Spain and France?
|
SELECT SUM(Bookings.Revenue) FROM Bookings INNER JOIN TourTypes ON Bookings.TourTypeID = TourTypes.TypeID WHERE TourTypes.TourName = 'Cultural Tour' AND Bookings.Country IN ('Spain', 'France');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditures (country VARCHAR(255), drug VARCHAR(255), year INT, amount FLOAT); INSERT INTO rd_expenditures (country, drug, year, amount) VALUES ('USA', 'DrugA', 2022, 60000), ('Germany', 'DrugB', 2022, 32000), ('Japan', 'DrugC', 2022, 45000), ('France', 'DrugD', 2022, 28000);
|
Increase the R&D expenditure for 'DrugD' in 'France' in 2022 by 10%.
|
UPDATE rd_expenditures SET amount = amount * 1.10 WHERE country = 'France' AND drug = 'DrugD' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryTechProjects (ProjectName VARCHAR(100), CompletionDate DATE, Budget INT); INSERT INTO MilitaryTechProjects (ProjectName, CompletionDate, Budget) VALUES ('Project A', '2021-04-01', 5000000), ('Project B', '2021-03-15', 7000000), ('Project C', '2021-02-20', 3000000), ('Project D', '2021-01-05', 8000000);
|
How many military technology projects were completed in the last quarter, and what was their average budget?
|
SELECT COUNT(*) AS ProjectCount, AVG(Budget) AS AverageBudget FROM MilitaryTechProjects WHERE CompletionDate >= DATEADD(quarter, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (id INT, name VARCHAR(255), sector VARCHAR(255), liabilities DECIMAL(10, 2)); INSERT INTO clients (id, name, sector, liabilities) VALUES (1, 'Emma White', 'Healthcare', 120000.00), (2, 'Liam Black', 'Healthcare', 180000.00), (3, 'Noah Gray', 'Banking', 220000.00), (4, 'Olivia Brown', 'Banking', 280000.00), (5, 'Ethan Green', 'Technology', 50000.00), (6, 'Harper Blue', 'Retail', 90000.00);
|
What is the sector with the highest total liabilities value?
|
SELECT sector, SUM(liabilities) AS total_liabilities FROM clients GROUP BY sector ORDER BY total_liabilities DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_usage (subscriber_id INT, technology VARCHAR(20), data_usage FLOAT, last_usage_date DATE); INSERT INTO broadband_usage (subscriber_id, technology, data_usage, last_usage_date) VALUES (1, 'Cable', 15.5, '2022-01-01'), (2, 'Fiber', 20.0, '2022-02-15'), (3, 'Cable', NULL, '2022-03-01');
|
Identify broadband subscribers who have not had any data usage in the past 30 days, for each technology type, ordered by technology type and subscriber count?
|
SELECT technology, COUNT(subscriber_id) as subscriber_count FROM broadband_usage WHERE last_usage_date <= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) GROUP BY technology ORDER BY technology, subscriber_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HearingDates (ID INT, CaseType VARCHAR(20), Year INT, HearingDate DATE); INSERT INTO HearingDates (ID, CaseType, Year, HearingDate) VALUES (1, 'Civil', 2022, '2022-01-01'), (2, 'Criminal', 2022, '2022-02-01'), (3, 'Civil', 2022, '2022-03-01'), (4, 'Criminal', 2022, '2022-04-01'), (5, 'Civil', 2021, '2021-01-01'), (6, 'Criminal', 2021, '2021-02-01');
|
What is the earliest and latest date of hearings for each case type in the current year?
|
SELECT CaseType, MIN(HearingDate) OVER (PARTITION BY CaseType) AS EarliestHearingDate, MAX(HearingDate) OVER (PARTITION BY CaseType) AS LatestHearingDate FROM HearingDates WHERE Year = EXTRACT(YEAR FROM CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Raw_Materials (raw_material_code TEXT, raw_material_name TEXT, quantity INTEGER); INSERT INTO Raw_Materials (raw_material_code, raw_material_name, quantity) VALUES ('M123', 'Hydrochloric Acid', 500), ('M234', 'Sodium Hydroxide', 800), ('M345', 'Acetic Acid', 300), ('M456', 'B302', 1000); CREATE TABLE Products (product_code TEXT, raw_material_code TEXT); INSERT INTO Products (product_code, raw_material_code) VALUES ('A101', 'M123'), ('B203', 'M234'), ('C405', 'M345'), ('A101', 'M456');
|
What are the product codes and names for products that use raw materials with a quantity greater than 700?
|
SELECT p.product_code, p.product_name FROM Products p JOIN Raw_Materials rm ON p.raw_material_code = rm.raw_material_code WHERE rm.quantity > 700;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_hospitals (name TEXT, state TEXT, num_beds INTEGER); INSERT INTO rural_hospitals (name, state, num_beds) VALUES ('Hospital A', 'CA', 50), ('Clinic B', 'TX', 25), ('Clinic C', 'OR', 30); CREATE TABLE rural_clinics (name TEXT, state TEXT); INSERT INTO rural_clinics (name, state) VALUES ('Clinic D', 'TX'), ('Clinic E', 'WA');
|
List the states where there are no rural hospitals or clinics.
|
(SELECT state FROM rural_hospitals UNION SELECT state FROM rural_clinics) EXCEPT (SELECT state FROM rural_hospitals INTERSECT SELECT state FROM rural_clinics);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_contracts (contract_id INT, contract_date DATE, contract_value DECIMAL(10,2), contractor TEXT);
|
What is the total number of defense contracts awarded to company X in the last 5 years?
|
SELECT COUNT(*) FROM defense_contracts WHERE contractor = 'company X' AND contract_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (post_id INT, user_id INT, post_date DATE, hashtags VARCHAR(255)); CREATE TABLE users (user_id INT, name VARCHAR(255), followers INT); INSERT INTO posts (post_id, user_id, post_date, hashtags) VALUES (1, 1, '2021-01-01', '#mentalhealth #selfcare'); INSERT INTO users (user_id, name, followers) VALUES (1, 'Amy', 2000);
|
What was the average number of followers for users who made posts with the hashtags '#mentalhealth' and '#selfcare'?
|
SELECT AVG(followers) FROM posts JOIN users ON posts.user_id = users.user_id WHERE hashtags LIKE '%#mentalhealth%' AND hashtags LIKE '%#selfcare%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai (id INT, industry VARCHAR(20), budget INT); INSERT INTO ethical_ai (id, industry, budget) VALUES (1, 'technology', 10000), (2, 'finance', 12000), (3, 'healthcare', 15000);
|
What is the minimum budget allocated for ethical AI projects in the technology industry?
|
SELECT MIN(budget) FROM ethical_ai WHERE industry = 'technology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT);
|
How many mining operations are there in total?
|
SELECT COUNT(*) FROM mining_operations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_orbits (satellite_name VARCHAR(255), orbit_type VARCHAR(255)); INSERT INTO satellite_orbits (satellite_name, orbit_type) VALUES ('Sat-1', 'LEO'); INSERT INTO satellite_orbits (satellite_name, orbit_type) VALUES ('Sat-2', 'GEO'); INSERT INTO satellite_orbits (satellite_name, orbit_type) VALUES ('Sat-3', 'MEO');
|
Identify the number of satellites in LEO, GEO, and MEO orbits
|
SELECT orbit_type, COUNT(*) FROM satellite_orbits GROUP BY orbit_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, sale_price DECIMAL(5,2), is_sustainable BOOLEAN);
|
What is the total revenue generated from sustainable cosmetics sales in the 'sales' table?
|
SELECT SUM(sale_price) FROM sales WHERE is_sustainable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE orders (id INT, supplier_id INT, quantity INT); INSERT INTO suppliers (id, name, country) VALUES (1, 'Spices of South America', 'South America'), (2, 'Tasty Imports', 'USA'), (3, 'Fruits of Brazil', 'South America'); INSERT INTO orders (id, supplier_id, quantity) VALUES (1, 1, 10), (2, 1, 20), (3, 2, 5), (4, 3, 15);
|
List all suppliers from South America with an order count greater than 5.
|
SELECT suppliers.name FROM suppliers JOIN orders ON suppliers.id = orders.supplier_id GROUP BY suppliers.name HAVING COUNT(orders.id) > 5 AND suppliers.country LIKE 'South America%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ota_revenue (ota_id INT, ota_name TEXT, region TEXT, revenue FLOAT); INSERT INTO ota_revenue (ota_id, ota_name, region, revenue) VALUES (1, 'OTA A', 'Americas', 25000000), (2, 'OTA B', 'Americas', 30000000), (3, 'OTA C', 'Americas', 32000000);
|
What is the maximum revenue of an OTA in 'Americas'?
|
SELECT MAX(revenue) FROM ota_revenue WHERE region = 'Americas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE services (service_id INT, patient_id INT, service_date DATE, service_cost INT, state TEXT); INSERT INTO services (service_id, patient_id, service_date, service_cost, state) VALUES (3, 6, '2022-03-15', 100, 'Colorado');
|
What is the number of medical services provided to patients with hypertension in rural Colorado this year?
|
SELECT COUNT(*) FROM services JOIN patients ON services.patient_id = patients.patient_id WHERE patients.diagnosis = 'Hypertension' AND EXTRACT(YEAR FROM service_date) = EXTRACT(YEAR FROM CURRENT_DATE) AND patients.state = 'Colorado';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_stats (building_id INT, building_type VARCHAR(50), energy_efficiency_rating FLOAT); INSERT INTO building_stats (building_id, building_type, energy_efficiency_rating) VALUES (1, 'Residential', 80.5), (2, 'Commercial', 65.3), (3, 'Industrial', 72.9), (4, 'Residential', 86.7), (5, 'Residential', 90.1);
|
How many residential buildings in the 'building_stats' table have an energy efficiency rating above 85?
|
SELECT COUNT(*) FROM building_stats WHERE building_type = 'Residential' AND energy_efficiency_rating > 85;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceanography_data (id INT PRIMARY KEY, location VARCHAR(255), temperature DECIMAL(5,2), salinity DECIMAL(5,2), depth DECIMAL(5,2));
|
Update the temperature data for the location with ID 1 in the oceanography_data table
|
WITH updated_data AS (UPDATE oceanography_data SET temperature = 23.1 WHERE id = 1 RETURNING *) SELECT * FROM updated_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE returns (client_id INT, return_date DATE, investment_return FLOAT); INSERT INTO returns (client_id, return_date, investment_return) VALUES (1, '2022-01-01', 0.07), (1, '2022-02-01', 0.06), (2, '2022-01-01', 0.05), (2, '2022-02-01', 0.06);
|
What is the maximum and minimum investment return for each client?
|
SELECT client_id, MIN(investment_return) as min_return, MAX(investment_return) as max_return FROM returns GROUP BY client_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, district_id INT, mental_health_score INT); INSERT INTO student_mental_health (student_id, district_id, mental_health_score) VALUES (1, 101, 75), (2, 101, 80), (3, 102, 65), (4, 102, 70), (5, 103, 85);
|
What is the average mental health score of students per school district?
|
SELECT district_id, AVG(mental_health_score) FROM student_mental_health GROUP BY district_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospital (hospital_id INT, name VARCHAR(50), state VARCHAR(20), num_of_beds INT); INSERT INTO hospital (hospital_id, name, state, num_of_beds) VALUES (1, 'Rural Hospital A', 'Texas', 40); INSERT INTO hospital (hospital_id, name, state, num_of_beds) VALUES (2, 'Rural Hospital B', 'California', 60);
|
How many hospitals are there in each state that have less than 50 beds?
|
SELECT state, COUNT(*) FROM hospital WHERE num_of_beds < 50 GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE disability_programs (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, website VARCHAR(255));
|
Update the description of a disability support program
|
WITH program AS (UPDATE disability_programs SET description = 'A mentorship program for students with disabilities with a focus on STEM fields' WHERE name = 'Disability Mentorship Program' RETURNING id) SELECT id FROM program;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage (id INT, name TEXT, state TEXT, capacity FLOAT);
|
What is the maximum energy storage capacity in Texas?
|
SELECT MAX(capacity) FROM energy_storage WHERE state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO biotech.startups (id, name, country, funding) VALUES (1, 'StartupA', 'USA', 1500000.00), (2, 'StartupB', 'USA', 2000000.00), (3, 'StartupC', 'Canada', 1200000.00);
|
Which countries have biotech startups with funding greater than 2,500,000?
|
SELECT DISTINCT country FROM biotech.startups WHERE funding > 2500000.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PeacekeepingMissions(Year INT, Location NVARCHAR(50), Mission VARCHAR(50), Casualties INT);INSERT INTO PeacekeepingMissions(Year, Location, Mission, Casualties) VALUES (2016, 'Africa', 'MONUSCO', 150), (2017, 'Africa', 'MINUSMA', 200), (2017, 'Middle East', 'UNTSO', 50), (2018, 'Africa', 'UNAMID', 100);
|
What is the rank of peacekeeping missions by the UN based on the number of casualties since 2016?
|
SELECT Mission, RANK() OVER(ORDER BY SUM(Casualties) DESC) AS Mission_Rank FROM PeacekeepingMissions WHERE Year >= 2016 GROUP BY Mission;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chemicals (name VARCHAR(255), origin_country VARCHAR(255), inventory INT); INSERT INTO Chemicals (name, origin_country, inventory) VALUES ('Acetone', 'USA', 2500), ('Ammonia', 'Canada', 1800), ('Chloroform', 'Mexico', 1200), ('Ethanol', 'USA', 3000);
|
What are the total inventories for chemicals produced in the US?
|
SELECT SUM(inventory) FROM Chemicals WHERE origin_country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE refugee_support.organizations (id INT, name VARCHAR(50), people_supported INT);
|
What is the maximum number of people supported by an organization?
|
SELECT MAX(people_supported) FROM refugee_support.organizations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, EmployeeName TEXT, Department TEXT, Gender TEXT, Salary FLOAT);
|
What is the percentage of employees who are female and work in the HR department?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees)) AS Percentage FROM Employees WHERE Department = 'HR' AND Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50), Diet VARCHAR(20)); INSERT INTO Customers (CustomerID, Name, Diet) VALUES (1, 'John Doe', 'Vegan'); INSERT INTO Customers (CustomerID, Name, Diet) VALUES (2, 'Jane Smith', 'Vegan'); CREATE TABLE Meals (MealID INT, CustomerID INT, Calories INT); INSERT INTO Meals (MealID, CustomerID, Calories) VALUES (1, 1, 400); INSERT INTO Meals (MealID, CustomerID, Calories) VALUES (2, 1, 500); INSERT INTO Meals (MealID, CustomerID, Calories) VALUES (3, 2, 450); INSERT INTO Meals (MealID, CustomerID, Calories) VALUES (4, 2, 550);
|
What is the average caloric intake per meal for vegan customers?
|
SELECT AVG(m.Calories) FROM Meals m JOIN Customers c ON m.CustomerID = c.CustomerID WHERE c.Diet = 'Vegan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name TEXT, budget DECIMAL(10,2)); INSERT INTO programs (id, name, budget) VALUES (1, 'Education', 15000.00), (2, 'Healthcare', 20000.00); CREATE TABLE expenses (id INT, program_id INT, amount DECIMAL(10,2)); INSERT INTO expenses (id, program_id, amount) VALUES (1, 1, 5000.00), (2, 1, 3000.00), (3, 2, 18000.00), (4, 2, 2000.00);
|
List all programs with their budget and actual expenses, sorted by total expenses in descending order.
|
SELECT programs.name, programs.budget, SUM(expenses.amount) as total_expenses FROM programs INNER JOIN expenses ON programs.id = expenses.program_id GROUP BY programs.name, programs.budget ORDER BY total_expenses DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthcareAccessData (Country VARCHAR(50), Population INT, AccessToHealthcare INT); INSERT INTO HealthcareAccessData (Country, Population, AccessToHealthcare) VALUES ('Canada', 38000000, 36500000), ('USA', 331000000, 312000000);
|
What is the percentage of the population that has access to healthcare in each country?
|
SELECT Country, (AccessToHealthcare / Population) * 100 AS AccessPercentage FROM HealthcareAccessData;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE power_plants (name TEXT, country TEXT, technology TEXT, capacity INTEGER, year_built INTEGER); INSERT INTO power_plants (name, country, technology, capacity, year_built) VALUES ('Solana', 'United States', 'Solar', 280, 2013); INSERT INTO power_plants (name, country, technology, capacity, year_built) VALUES ('Desert Sunlight', 'United States', 'Solar', 550, 2015);
|
Which renewable energy power plants were built after 2015 and have a higher installed capacity than any power plant in the United Kingdom?
|
SELECT * FROM power_plants WHERE country != 'United Kingdom' AND year_built > 2015 AND capacity > (SELECT MAX(capacity) FROM power_plants WHERE country = 'United Kingdom');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Country VARCHAR(50), AverageScore DECIMAL(5,2), TotalGames INT); INSERT INTO Players (PlayerID, PlayerName, Country, AverageScore, TotalGames) VALUES (1, 'John Doe', 'USA', 150.50, 200), (2, 'Jane Smith', 'Canada', 160.00, 250), (3, 'Peter Lee', 'South Korea', 200.25, 300);
|
Find the top 3 countries with the highest average scores and the total number of players from those countries.
|
SELECT Country, AVG(AverageScore) AS AvgScore, COUNT(*) AS TotalPlayers FROM Players GROUP BY Country ORDER BY AvgScore DESC, TotalPlayers DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE polar_bear_sightings (id INT, date DATE, sighted BOOLEAN, region VARCHAR(50));
|
How many polar bears were sighted in the 'polar_bear_sightings' table during the summer months (June, July, August) in the year 2019, broken down by region ('region' column in the 'polar_bear_sightings' table)?
|
SELECT MONTH(date) AS month, region, COUNT(*) FROM polar_bear_sightings WHERE MONTH(date) IN (6, 7, 8) AND sighted = TRUE AND YEAR(date) = 2019 GROUP BY month, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE News (news_id INT, title TEXT, update_count INT); INSERT INTO News (news_id, title, update_count) VALUES (1, 'Article1', 3), (2, 'Article2', 1), (3, 'Article3', 2);
|
Which news articles have been updated the most?
|
SELECT title, update_count FROM News ORDER BY update_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_production (production_date DATE, chemical_code VARCHAR(10), quantity INT); INSERT INTO chemical_production (production_date, chemical_code, quantity) VALUES ('2021-01-03', 'A123', 450), ('2021-01-07', 'A123', 620), ('2021-01-12', 'A123', 390), ('2021-02-15', 'B456', 550), ('2021-02-19', 'B456', 700);
|
Find the total production quantity for each month of 2021
|
SELECT DATE_FORMAT(production_date, '%Y-%m') AS Month, SUM(quantity) FROM chemical_production GROUP BY Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE support_programs (id INT, program_name VARCHAR(50), budget INT, department VARCHAR(50)); INSERT INTO support_programs (id, program_name, budget, department) VALUES (1, 'Mentorship Program', 10000, 'Education'), (2, 'Tutoring Program', 15000, 'Education'), (3, 'Accessibility Improvements', 20000, 'IT');
|
What is the average budget for support programs in the education department?
|
SELECT AVG(support_programs.budget) AS average_budget FROM support_programs WHERE support_programs.department = 'Education';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (name VARCHAR(255), country VARCHAR(100)); INSERT INTO company (name, country) VALUES ('CompanyA', 'USA'), ('CompanyB', 'Canada'), ('CompanyC', 'USA'), ('CompanyD', 'Mexico'), ('CompanyE', 'USA'), ('CompanyF', 'Canada');
|
What is the number of startups founded by people from each country?
|
SELECT country, COUNT(*) as num_startups FROM company GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, order_date DATE, order_value DECIMAL(10,2), country VARCHAR(50), shipping_method VARCHAR(50)); INSERT INTO orders (order_id, order_date, order_value, country, shipping_method) VALUES (1, '2021-01-01', 150.00, 'USA', 'ground'), (2, '2021-01-02', 200.00, 'Canada', 'air'), (3, '2021-01-03', 120.00, 'USA', 'ground');
|
What is the average order value for orders placed in the United States and shipped via ground shipping?
|
SELECT AVG(order_value) FROM orders WHERE country = 'USA' AND shipping_method = 'ground';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FOOD_ITEMS (id INT, name VARCHAR(50), category VARCHAR(50), is_organic BOOLEAN, weight FLOAT); INSERT INTO FOOD_ITEMS (id, name, category, is_organic, weight) VALUES (1, 'Chicken Breast', 'Meat', false, 0.4), (2, 'Ground Beef', 'Meat', false, 0.8);
|
What is the total weight of non-organic meat products in the FOOD_ITEMS table?
|
SELECT SUM(weight) FROM FOOD_ITEMS WHERE is_organic = false AND category = 'Meat';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteer_program (id INT, name VARCHAR(50), age INT, location VARCHAR(30)); INSERT INTO volunteer_program (id, name, age, location) VALUES (1, 'John Doe', 25, 'New York'), (2, 'Jane Smith', 32, 'California'), (3, 'Alice Johnson', 22, 'Texas');
|
What is the average age of volunteers in the 'volunteer_program' table, grouped by location?
|
SELECT location, AVG(age) FROM volunteer_program GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (id INT, policyholder_id INT, claim_amount DECIMAL(10,2), policyholder_region VARCHAR(20)); INSERT INTO claims (id, policyholder_id, claim_amount, policyholder_region) VALUES (1, 1, 1500.00, 'North'), (2, 2, 3000.00, 'West'), (3, 3, 500.00, 'North'), (4, 4, 4500.00, 'East'), (5, 1, 2000.00, 'North');
|
What is the total claim amount by policyholder's region?
|
SELECT policyholder_region, SUM(claim_amount) as total_claim_amount FROM claims GROUP BY policyholder_region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (id INT, order_date DATE, customer_id INT, special_requests TEXT);
|
How many customers have requested gluten-free options in the last month?
|
SELECT COUNT(DISTINCT customer_id) FROM orders WHERE special_requests LIKE '%gluten-free%' AND order_date >= DATE(NOW()) - INTERVAL 1 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT);
|
Delete all records with safety_rating below 6 from the 'chemical_compounds' table
|
DELETE FROM chemical_compounds WHERE safety_rating < 6;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health_country (student_id INT, country VARCHAR(255), mental_health_score INT); INSERT INTO student_mental_health_country (student_id, country, mental_health_score) VALUES (1, 'USA', 70), (2, 'Canada', 80), (3, 'Mexico', 75), (4, 'Brazil', 85);
|
What is the average mental health score by country?
|
SELECT country, AVG(mental_health_score) as avg_mental_health_score FROM student_mental_health_country GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (drug_name TEXT, trial_id TEXT, region TEXT); INSERT INTO clinical_trials (drug_name, trial_id, region) VALUES ('Vaxo', 'CT001', 'United States'), ('Curely', 'CT002', 'Germany');
|
List all clinical trials for the drug 'Curely' in Europe.
|
SELECT * FROM clinical_trials WHERE drug_name = 'Curely' AND region = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diplomacy_staff (staff_id INT, name VARCHAR(255), position VARCHAR(255), salary INT); INSERT INTO diplomacy_staff (staff_id, name, position, salary) VALUES (1, 'John Doe', 'Ambassador', 75000), (2, 'Jane Smith', 'Consul', 50000), (3, 'Michael Johnson', 'Diplomatic Attaché', 60000), (4, 'Sarah Brown', 'Ambassador', 90000), (5, 'David Williams', 'Consul', 80000);
|
Who are the diplomats with the highest salaries?
|
SELECT name, position, salary FROM diplomacy_staff ORDER BY salary DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_animals (name TEXT, species TEXT, location TEXT);
|
List the names and species of all animals in the 'arctic_animals' table that were observed in 'Alaska' or 'Sweden'.
|
SELECT name, species FROM arctic_animals WHERE location IN ('Alaska', 'Sweden')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property_type (property_id INT, city VARCHAR(50), type VARCHAR(50)); INSERT INTO property_type VALUES (1, 'Atlanta', 'co-ownership'), (2, 'Atlanta', 'rental'), (3, 'Miami', 'co-ownership');
|
What is the total number of properties with a co-ownership model in Atlanta?
|
SELECT COUNT(*) FROM property_type WHERE city = 'Atlanta' AND type = 'co-ownership';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sources (id INT, name VARCHAR(50), popularity INT); CREATE TABLE reader_source_preferences (id INT, reader_id INT, source_id INT);
|
What is the most common news source among readers in the UK?
|
SELECT sources.name, AVG(sources.popularity) as avg_popularity FROM sources JOIN reader_source_preferences ON sources.id = reader_source_preferences.source_id JOIN readers ON readers.id = reader_source_preferences.reader_id WHERE readers.country = 'UK' GROUP BY sources.name ORDER BY avg_popularity DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE residential (customer_id INT, water_usage FLOAT, usage_date DATE); INSERT INTO residential (customer_id, water_usage, usage_date) VALUES (1, 150.5, '2022-04-01'), (2, 250.7, '2022-04-02'), (3, 100.4, '2022-04-03');
|
Find the average water usage in the residential table for all customers except the one with the lowest water usage in the month of April 2022.
|
SELECT AVG(water_usage) FROM residential WHERE customer_id != (SELECT customer_id FROM residential WHERE usage_date BETWEEN '2022-04-01' AND '2022-04-30' ORDER BY water_usage ASC LIMIT 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE disaster_events (id INT, region VARCHAR(50), event_type VARCHAR(50), date DATE); INSERT INTO disaster_events (id, region, event_type, date) VALUES (1, 'Pacific', 'earthquake', '2019-01-01');
|
How many disaster response events were there in the Pacific region in the last 3 years?
|
SELECT region, COUNT(*) as event_count FROM disaster_events WHERE region = 'Pacific' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vaccinations (state VARCHAR(2), doses INT);
|
What is the number of vaccinations administered per state?
|
SELECT state, SUM(doses) FROM vaccinations GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name TEXT, harmful_ingredient BOOLEAN);
|
Delete all products that contain a harmful ingredient.
|
DELETE FROM products WHERE products.harmful_ingredient = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (id INT, first_name VARCHAR, last_name VARCHAR, email VARCHAR, phone_number VARCHAR, date_joined DATE); INSERT INTO Volunteers (id, first_name, last_name, email, phone_number, date_joined) VALUES (1, 'John', 'Doe', 'john.doe@email.com', '555-123-4567', '2021-05-01'), (2, 'Jane', 'Doe', 'jane.doe@email.com', '555-987-6543', '2021-06-01');
|
Remove a volunteer from the database
|
DELETE FROM Volunteers WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_disability TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_disability) VALUES (1, 'TelecomTech', 'Telecommunications', 2018, 'Yes'); INSERT INTO companies (id, name, industry, founding_year, founder_disability) VALUES (2, 'NetworkSolutions', 'Telecommunications', 2019, 'No');
|
What is the total number of companies founded by persons with disabilities in the telecommunications industry?
|
SELECT COUNT(*) FROM companies WHERE founder_disability = 'Yes' AND industry = 'Telecommunications';
|
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.