context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_rating FLOAT)
|
What is the average ESG rating for companies in the 'technology' sector?
|
SELECT AVG(ESG_rating) FROM companies WHERE sector = 'technology'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE parties (party_name VARCHAR(255), party_abbreviation VARCHAR(255)); INSERT INTO parties VALUES ('Democratic Party', 'DP'); INSERT INTO parties VALUES ('Republican Party', 'RP'); CREATE TABLE voters (voter_name VARCHAR(255), voter_party VARCHAR(255), state VARCHAR(255));
|
What is the total number of registered voters in the state of Texas, and what is the percentage of those voters who are registered as Democrats?
|
SELECT (COUNT(*) FILTER (WHERE voter_party = 'DP')::float / COUNT(*) * 100) AS democratic_percentage FROM voters JOIN states ON voters.state = states.state_abbreviation WHERE states.state_name = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE alternative_sentencing_programs (program_id INT, year INT, state VARCHAR(20)); INSERT INTO alternative_sentencing_programs (program_id, year, state) VALUES (1, 2022, 'Illinois'), (2, 2021, 'Illinois'), (3, 2020, 'Illinois'), (4, 2019, 'Illinois'), (5, 2018, 'Illinois'), (6, 2017, 'Illinois');
|
What is the total number of alternative sentencing programs implemented in Illinois since 2017?
|
SELECT COUNT(*) FROM alternative_sentencing_programs WHERE year >= 2017 AND state = 'Illinois';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dye_usage (id INT, batch_number INT, dye_type VARCHAR(20), quantity INT); INSERT INTO dye_usage (id, batch_number, dye_type, quantity) VALUES (1, 101, 'eco_friendly', 200); INSERT INTO dye_usage (id, batch_number, dye_type, quantity) VALUES (2, 102, 'regular', 300);
|
What is the maximum quantity of eco-friendly dye used in a single batch?
|
SELECT MAX(quantity) FROM dye_usage WHERE dye_type = 'eco_friendly';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation_trend_caribbean (region VARCHAR(50), year INT, waste_amount FLOAT); INSERT INTO waste_generation_trend_caribbean (region, year, waste_amount) VALUES ('Caribbean', 2017, 120000.0), ('Caribbean', 2018, 130000.0), ('Caribbean', 2019, 140000.0), ('Caribbean', 2020, 150000.0), ('Caribbean', 2021, 160000.0);
|
What is the total waste generation trend in metric tons per year for the Caribbean region from 2017 to 2021?
|
SELECT year, SUM(waste_amount) FROM waste_generation_trend_caribbean WHERE region = 'Caribbean' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, Gender TEXT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, Gender) VALUES (1, 'John Doe', 500.00, 'Male'), (2, 'Jane Smith', 350.00, 'Female'), (3, 'Alice Johnson', 700.00, 'Female');
|
What is the percentage of donation amount by gender, with cross join?
|
SELECT D1.Gender, SUM(D1.DonationAmount) as TotalDonation, (SUM(D1.DonationAmount)/SUM(D2.DonationAmount))*100 as Percentage FROM Donors D1 CROSS JOIN Donors D2 GROUP BY D1.Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE silk_shirts (id INT PRIMARY KEY, price DECIMAL(5,2), sale_date DATE); INSERT INTO silk_shirts (id, price, sale_date) VALUES (1, 59.99, '2021-06-15'), (2, 69.99, '2021-07-10'), (3, 49.99, '2021-08-05');
|
What is the average price of silk shirts sold in the past year, grouped by month?
|
SELECT AVG(price), EXTRACT(MONTH FROM sale_date) FROM silk_shirts WHERE sale_date >= DATE '2020-01-01' AND sale_date < DATE '2021-01-01' AND shirt_type = 'silk' GROUP BY EXTRACT(MONTH FROM sale_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CompletedProjects (project_id INT, sustainability VARCHAR(255), state VARCHAR(255)); INSERT INTO CompletedProjects (project_id, sustainability, state) VALUES (1, 'sustainable', 'Texas'), (2, 'not sustainable', 'California');
|
How many sustainable construction projects were completed in Texas?
|
SELECT COUNT(*) FROM CompletedProjects WHERE sustainability = 'sustainable' AND state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forwarders(id INT, name VARCHAR(255), address VARCHAR(255)); INSERT INTO forwarders VALUES(1, 'ABC Logistics', '123 Main St'), (2, 'DEF Freight', '456 Elm St');
|
Update freight forwarder addresses
|
UPDATE forwarders SET address = '789 Oak St' WHERE name = 'ABC Logistics'; UPDATE forwarders SET address = '321 Maple St' WHERE name = 'DEF Freight';
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW micro_mobility AS SELECT 'ebike' AS vehicle_type, COUNT(*) AS quantity UNION ALL SELECT 'escooter', COUNT(*);
|
Display the number of electric bicycles and electric scooters in the micro_mobility view.
|
SELECT vehicle_type, quantity FROM micro_mobility;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists bioprocess; CREATE TABLE if not exists bioprocess.projects (id INT, name VARCHAR(100), duration INT); INSERT INTO bioprocess.projects (id, name, duration) VALUES (1, 'Protein Production', 18), (2, 'Cell Culture', 15), (3, 'Fermentation', 9), (4, 'Bioprocess Optimization', 24);
|
Display bioprocess engineering information for projects with a duration greater than 12 months and order the results by duration in ascending order.
|
SELECT * FROM bioprocess.projects WHERE duration > 12 ORDER BY duration ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_control_initiatives (initiative_id INT, initiative_name TEXT, country TEXT, region TEXT); INSERT INTO pollution_control_initiatives (initiative_id, initiative_name, country, region) VALUES (1, 'Initiative X', 'India', 'Indian Ocean'), (2, 'Initiative Y', 'Australia', 'Indian Ocean'), (3, 'Initiative Z', 'Indonesia', 'Indian Ocean');
|
Identify the number of pollution control initiatives in the Indian Ocean by country.
|
SELECT country, COUNT(*) FROM pollution_control_initiatives WHERE region = 'Indian Ocean' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing (id INT PRIMARY KEY, program_name VARCHAR(50), start_date DATE, end_date DATE);
|
How many community policing programs were active between 2015 and 2017?
|
SELECT COUNT(*) as active_programs FROM community_policing WHERE start_date BETWEEN '2015-01-01' AND '2017-12-31' AND end_date BETWEEN '2015-01-01' AND '2017-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hotels (id INT, name TEXT, country TEXT, type TEXT, co2_emission INT); INSERT INTO Hotels (id, name, country, type, co2_emission) VALUES (1, 'Eco Hotel', 'Spain', 'Eco', 50);
|
What is the total CO2 emission from all hotels in Spain?
|
SELECT SUM(co2_emission) FROM Hotels WHERE country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, product_id INT, supplier_id INT, cost DECIMAL(10,2)); CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT, is_sustainable BOOLEAN); CREATE TABLE products (product_id INT, product_name TEXT, product_category TEXT);
|
What is the total cost of ingredients sourced from sustainable suppliers for each product category?
|
SELECT products.product_category, SUM(ingredients.cost) as total_cost FROM ingredients INNER JOIN suppliers ON ingredients.supplier_id = suppliers.supplier_id INNER JOIN products ON ingredients.product_id = products.product_id WHERE suppliers.is_sustainable = TRUE GROUP BY products.product_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (state_name VARCHAR(255), state_id INT); INSERT INTO states (state_name, state_id) VALUES ('New York', 2); CREATE TABLE schools (school_name VARCHAR(255), state_id INT, PRIMARY KEY (school_name, state_id)); CREATE TABLE teachers (teacher_id INT, teacher_age INT, school_name VARCHAR(255), state_id INT, PRIMARY KEY (teacher_id), FOREIGN KEY (school_name, state_id) REFERENCES schools(school_name, state_id)); CREATE TABLE professional_development (pd_id INT, teacher_id INT, pd_date DATE, pd_type VARCHAR(255), PRIMARY KEY (pd_id), FOREIGN KEY (teacher_id) REFERENCES teachers(teacher_id));
|
What is the average age of teachers who have completed cross-cultural training in the last 2 years, in New York state?
|
SELECT AVG(teachers.teacher_age) FROM teachers INNER JOIN professional_development ON teachers.teacher_id = professional_development.teacher_id INNER JOIN schools ON teachers.school_name = schools.school_name WHERE schools.state_id = 2 AND professional_development.pd_type = 'cross-cultural training' AND professional_development.pd_date >= DATEADD(year, -2, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name TEXT, type TEXT);
|
List all types of renewable energy projects in the database
|
SELECT DISTINCT type FROM projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AccessibleTech (project_id INT, launch_date DATE); INSERT INTO AccessibleTech (project_id, launch_date) VALUES (1, '2005-02-17'), (2, '2007-11-09'), (3, '2009-06-23'), (4, '2011-08-04'), (5, '2013-01-15');
|
Which accessible technology projects were launched before 2010?
|
SELECT project_id, launch_date FROM AccessibleTech WHERE launch_date < '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE department_data (dept_name TEXT, column_name TEXT, data_type TEXT); INSERT INTO department_data (dept_name, column_name, data_type) VALUES ('Human Services Department', 'age', 'INTEGER'), ('Human Services Department', 'gender', 'TEXT'), ('Human Services Department', 'income', 'FLOAT'), ('Education Department', 'school_name', 'TEXT'), ('Education Department', 'student_count', 'INTEGER');
|
List all departments and their associated data types.
|
SELECT dept_name, column_name, data_type FROM department_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), region VARCHAR(50), ethical_labor_practices BOOLEAN); INSERT INTO suppliers (supplier_id, name, region, ethical_labor_practices) VALUES (1, 'Fair Trade Fabrics', 'Southeast Asia', TRUE), (2, 'Eco-Friendly Packaging', 'North America', FALSE);
|
List suppliers from Southeast Asia who use ethical labor practices.
|
SELECT * FROM suppliers WHERE region = 'Southeast Asia' AND ethical_labor_practices = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (1, 'Shape of You', 2017, 'Pop', 2000000000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (2, 'Sicko Mode', 2018, 'Hip Hop', 1500000000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (3, 'Black Panther', 2018, 'Soundtrack', 1200000000); CREATE TABLE artists (id INT, name VARCHAR(100), age INT, genre VARCHAR(50)); INSERT INTO artists (id, name, age, genre) VALUES (1, 'Ed Sheeran', 30, 'Pop'); INSERT INTO artists (id, name, age, genre) VALUES (2, 'Travis Scott', 31, 'Hip Hop'); INSERT INTO artists (id, name, age, genre) VALUES (3, 'Kendrick Lamar', 34, 'Soundtrack'); INSERT INTO artists (id, name, age, genre) VALUES (4, 'Queen', 50, 'Rock');
|
How many unique artists have released songs in the 'Rock' genre?
|
SELECT COUNT(DISTINCT artists.name) FROM songs JOIN artists ON songs.genre = artists.genre WHERE artists.genre = 'Rock';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attack_timeline(id INT, start_time TIMESTAMP, end_time TIMESTAMP);
|
What is the total number of hours that the network was under attack in the past month?
|
SELECT SUM(TIMESTAMPDIFF(HOUR, start_time, end_time)) as total_hours FROM attack_timeline WHERE start_time >= NOW() - INTERVAL 1 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gulf_of_mexico_fields (field_id INT, field_name VARCHAR(50), gas_production FLOAT, datetime DATETIME); INSERT INTO gulf_of_mexico_fields (field_id, field_name, gas_production, datetime) VALUES (1, 'Gulf of Mexico Field A', 2000000, '2019-01-01 00:00:00'), (2, 'Gulf of Mexico Field B', 2500000, '2019-01-01 00:00:00');
|
List the production figures of gas for all fields in the Gulf of Mexico in Q1 2019.
|
SELECT field_name, SUM(gas_production) FROM gulf_of_mexico_fields WHERE QUARTER(datetime) = 1 AND YEAR(datetime) = 2019 GROUP BY field_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arts_images (id INT, image_url VARCHAR(255), image_type VARCHAR(50), model_used VARCHAR(50));
|
Which models were trained on the 'arts_images' table?
|
SELECT model_used FROM arts_images;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses(id INT, location VARCHAR(50), capacity INT); INSERT INTO Warehouses(id, location, capacity) VALUES (1, 'India', 1500); CREATE TABLE Inventory(id INT, warehouse_id INT, quantity INT); INSERT INTO Inventory(id, warehouse_id, quantity) VALUES (1, 1, 750);
|
List the names and capacities of all warehouses in India and the total quantity of items stored in each.
|
SELECT Warehouses.location, SUM(Inventory.quantity), Warehouses.capacity FROM Warehouses INNER JOIN Inventory ON Warehouses.id = Inventory.warehouse_id WHERE Warehouses.location = 'India' GROUP BY Warehouses.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50)); INSERT INTO animal_population (animal_id, animal_name, program) VALUES (1, 'Grizzly Bear', 'habitat_preservation'), (2, 'Gray Wolf', 'community_education');
|
Check if the 'habitat_preservation' program exists
|
SELECT EXISTS(SELECT 1 FROM animal_population WHERE program = 'habitat_preservation');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary FLOAT);
|
What is the average salary for male employees in the IT department?
|
SELECT AVG(Salary) FROM Employees WHERE Gender = 'Male' AND Department = 'IT';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE traditional_arts (id INT, art_form VARCHAR(255), region VARCHAR(255), country VARCHAR(255)); INSERT INTO traditional_arts (id, art_form, region, country) VALUES (1, 'Uzbek Suzani', 'Central Asia', 'Uzbekistan'), (2, 'Kilim Weaving', 'Middle East', 'Turkey');
|
What is the distribution of traditional art forms by region?
|
SELECT region, COUNT(*) as art_forms_count FROM traditional_arts GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(50), type VARCHAR(20), location VARCHAR(50));
|
Add a new restorative justice program to the "programs" table
|
INSERT INTO programs (id, name, type, location) VALUES (3002, 'Neighborhood Healing', 'Restorative Justice', 'San Francisco');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geothermal_plants (id INT, plant_name VARCHAR(255), state VARCHAR(255), plant_status VARCHAR(255), num_units INT);
|
What is the total number of geothermal power plants in the state of Nevada, grouped by plant status?
|
SELECT plant_status, COUNT(plant_name) FROM geothermal_plants WHERE state = 'Nevada' GROUP BY plant_status;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteData (SiteName VARCHAR(50), WasteQuantity INT, WasteDate DATE); INSERT INTO WasteData (SiteName, WasteQuantity, WasteDate) VALUES ('Site A', 2000, '2022-02-15');
|
What is the total amount of waste produced by each site in the past year?
|
SELECT SiteName, SUM(WasteQuantity) FROM WasteData WHERE WasteDate >= CURRENT_DATE - INTERVAL '1 year' GROUP BY SiteName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), num_workers INT, wage DECIMAL(5,2)); CREATE TABLE Products (product_id INT, name VARCHAR(100), factory_id INT); INSERT INTO Factories VALUES (1,'Factory X','Los Angeles',100,15.00),(2,'Factory Y','Jakarta',250,5.00),(3,'Factory Z','Rome',300,12.00),(4,'Factory W','Berlin',150,18.00); INSERT INTO Products VALUES (1,'Eco Leggings',1),(2,'Fair Trade Tank Top',2),(3,'Sustainable Sports Bra',3),(4,'Organic Cotton Shirt',3);
|
What is the minimum number of workers in factories that produce the most ethical activewear?
|
SELECT MIN(Factories.num_workers) FROM Factories JOIN Products ON Factories.factory_id = Products.factory_id WHERE Products.name LIKE '%activewear%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_records (id INT, location TEXT, pollution_level INT, record_date DATE); INSERT INTO pollution_records (id, location, pollution_level, record_date) VALUES (1, 'Mediterranean Sea', 8, '2018-01-01'), (2, 'Mediterranean Sea', 9, '2019-01-01'), (3, 'Baltic Sea', 7, '2020-01-01');
|
What is the maximum pollution level recorded in the Mediterranean Sea in the last 5 years?
|
SELECT MAX(pollution_level) FROM pollution_records WHERE location = 'Mediterranean Sea' AND record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_treatment_plants (name VARCHAR(50), state VARCHAR(2), built INT); INSERT INTO water_treatment_plants (name, state, built) VALUES ('Plant A', 'CA', 2017), ('Plant B', 'CA', 2019), ('Plant C', 'CA', 2013);
|
Count the number of water treatment plants in California that were built after 2015?
|
SELECT COUNT(*) FROM water_treatment_plants WHERE state = 'CA' AND built > 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_revenue (hotel_name TEXT, quarter TEXT, revenue INT); INSERT INTO hotel_revenue (hotel_name, quarter, revenue) VALUES ('Barcelona Eco Hotel', 'Q1', 8000), ('Madrid Green Hotel', 'Q1', 10000);
|
What was the revenue generated by each hotel in Spain in the last quarter?
|
SELECT hotel_name, revenue FROM hotel_revenue WHERE quarter = 'Q1' AND hotel_name LIKE '%Spain%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(30), donation_amount DECIMAL(5,2)); INSERT INTO donors (donor_id, donor_name, donation_amount) VALUES (1, 'Jane Doe', 300), (2, 'Mary Smith', 400), (3, 'Bob Johnson', 200), (5, 'Sophia Lee', 700);
|
What is the total donation amount for donor 'Bob Johnson'?
|
SELECT SUM(donation_amount) FROM donors WHERE donor_name = 'Bob Johnson';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityEngagement (id INT, name VARCHAR(255), region VARCHAR(255), start_year INT, end_year INT); INSERT INTO CommunityEngagement (id, name, region, start_year, end_year) VALUES (1, 'Cape Town Jazz Festival', 'Africa', 2000, 2005);
|
Identify community engagement events in 'Africa' between 2000 and 2005.
|
SELECT * FROM CommunityEngagement WHERE region = 'Africa' AND start_year BETWEEN 2000 AND 2005;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_virtual_tours (user_id INT, city VARCHAR(20), tour_count INT); INSERT INTO user_virtual_tours (user_id, city, tour_count) VALUES (1, 'Tokyo', 5), (2, 'Tokyo', 3), (3, 'Osaka', 4), (4, 'Osaka', 2);
|
Find the average virtual tour bookings per user in Tokyo and Osaka.
|
SELECT AVG(tour_count) FROM user_virtual_tours WHERE city IN ('Tokyo', 'Osaka');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations_environment_us (id INT, donor_name TEXT, country TEXT, cause TEXT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations_environment_us (id, donor_name, country, cause, donation_amount, donation_date) VALUES (1, 'John Smith', 'USA', 'Environment', 100.00, '2021-05-10'); INSERT INTO donations_environment_us (id, donor_name, country, cause, donation_amount, donation_date) VALUES (2, 'Emily Johnson', 'USA', 'Environment', 200.00, '2021-03-25');
|
What is the average donation amount made to environmental causes in the US in 2021?
|
SELECT AVG(donation_amount) FROM donations_environment_us WHERE country = 'USA' AND cause = 'Environment' AND YEAR(donation_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_control (id INT, name TEXT, region TEXT); INSERT INTO pollution_control (id, name, region) VALUES (1, 'Initiative A', 'Indian Ocean'); INSERT INTO pollution_control (id, name, region) VALUES (2, 'Initiative B', 'Atlantic Ocean');
|
How many pollution control initiatives are registered in the Atlantic ocean in the pollution_control table?
|
SELECT COUNT(*) FROM pollution_control WHERE region = 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Crops (id INT PRIMARY KEY, name VARCHAR(50), planting_date DATE, harvest_date DATE, yield INT, farmer_id INT, FOREIGN KEY (farmer_id) REFERENCES Farmers(id)); INSERT INTO Crops (id, name, planting_date, harvest_date, yield, farmer_id) VALUES (1, 'Corn', '2022-05-01', '2022-08-01', 100, 1); INSERT INTO Crops (id, name, planting_date, harvest_date, yield, farmer_id) VALUES (2, 'Soybeans', '2022-06-15', '2022-09-15', 50, 2); INSERT INTO Crops (id, name, planting_date, harvest_date, yield, farmer_id) VALUES (3, 'Rice', '2021-03-01', '2021-06-01', 80, 3);
|
Which crops were planted in '2022'?
|
SELECT * FROM Crops WHERE YEAR(planting_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, software_app VARCHAR(50), severity INT);
|
Identify the top 3 most vulnerable software applications and their associated vulnerabilities
|
SELECT software_app, severity, COUNT(*) as num_vulnerabilities FROM vulnerabilities WHERE severity >= 5 GROUP BY software_app ORDER BY num_vulnerabilities DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_projects (id INT PRIMARY KEY, project_name VARCHAR(50), budget FLOAT); INSERT INTO safety_projects (id, project_name, budget) VALUES (1, 'Secure AI', 150000.0), (2, 'Robust AI', 125000.0), (3, 'Privacy-Preserving AI', 170000.0), (4, 'Verification & Validation', 200000.0), (5, 'Ethical AI', 225000.0);
|
Total budget for AI safety projects.
|
SELECT SUM(budget) FROM safety_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PollutionTrend (ID INT, Location VARCHAR(50), Pollutant VARCHAR(50), Level INT, MeasurementDate DATE); INSERT INTO PollutionTrend (ID, Location, Pollutant, Level, MeasurementDate) VALUES (1, 'NewYork', 'Mercury', 5, '2020-01-01'), (2, 'California', 'Lead', 10, '2020-01-02'), (3, 'Texas', 'CarbonMonoxide', 15, '2020-01-03'), (4, 'NewYork', 'Mercury', 10, '2020-01-04');
|
List pollution levels with a sudden increase.
|
SELECT Location, Pollutant, Level, LEAD(Level) OVER (PARTITION BY Location ORDER BY MeasurementDate) as NextLevel FROM PollutionTrend;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, Name VARCHAR(50), Genre VARCHAR(20), ReleaseDate DATETIME, Publisher VARCHAR(50)); INSERT INTO Games (GameID, Name, Genre, ReleaseDate, Publisher) VALUES (2, 'Grand Theft Auto III', 'Action', '2001-10-22', 'Rockstar Games');
|
Which games were released before 2010 and have a genre of 'Action'?
|
SELECT Name FROM Games WHERE ReleaseDate < '2010-01-01' AND Genre = 'Action';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Consumer_Complaints (ComplaintID INT, ProductID INT, ComplaintDate DATE); INSERT INTO Consumer_Complaints (ComplaintID, ProductID, ComplaintDate) VALUES (7, 101, '2022-01-01'), (8, 102, '2022-02-01'), (9, 101, '2022-03-01'), (10, 103, '2022-04-01'), (11, 102, '2022-05-01'), (12, 101, '2022-06-01');
|
How many consumer complaints were there for each cosmetic product in 2022?
|
SELECT ProductID, COUNT(*) as Complaints FROM Consumer_Complaints WHERE EXTRACT(YEAR FROM ComplaintDate) = 2022 GROUP BY ProductID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farms (country VARCHAR(255), organic BOOLEAN); INSERT INTO farms (country, organic) VALUES ('Canada', TRUE), ('Canada', TRUE), ('Canada', FALSE), ('Canada', TRUE);
|
What is the total number of organic farms in Canada?
|
SELECT COUNT(*) FROM farms WHERE country = 'Canada' AND organic = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_customers (customer_id INT, data_usage FLOAT, state VARCHAR(50)); INSERT INTO broadband_customers (customer_id, data_usage, state) VALUES (1, 3.5, 'New York'), (2, 4.2, 'California'), (3, 5.1, 'New York'); CREATE VIEW data_usage_view AS SELECT state, SUM(data_usage) as total_data_usage FROM broadband_customers GROUP BY state;
|
What is the data usage distribution for broadband customers in a specific state?
|
SELECT state, total_data_usage, total_data_usage/SUM(total_data_usage) OVER (PARTITION BY state) as data_usage_percentage FROM data_usage_view;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE age_demographics (visitor_id INT, age INT); INSERT INTO age_demographics (visitor_id, age) VALUES (100, 28);
|
What is the number of visitors who attended the "African Art" exhibition and are under 30 years old?
|
SELECT COUNT(*) FROM visitor_presence JOIN exhibitions ON visitor_presence.exhibition_id = exhibitions.exhibition_id JOIN age_demographics ON visitor_presence.visitor_id = age_demographics.visitor_id WHERE exhibitions.exhibition_name = 'African Art' AND age_demographics.age < 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ReverseLogistics (id INT, route VARCHAR(50), metric INT); INSERT INTO ReverseLogistics (id, route, metric) VALUES (1, 'Route 2', 200), (2, 'Route 3', 300);
|
Find all reverse logistics metrics for Route 2 and Route 3
|
SELECT route, metric FROM ReverseLogistics WHERE route IN ('Route 2', 'Route 3');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attractions (id INT, name VARCHAR(50), city VARCHAR(20), rating FLOAT); INSERT INTO attractions (id, name, city, rating) VALUES (1, 'Palace', 'Tokyo', 4.5), (2, 'Castle', 'Osaka', 4.2), (3, 'Shrine', 'Kyoto', 4.7);
|
What is the average rating of attractions in Tokyo?
|
SELECT AVG(rating) FROM attractions WHERE city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (item_type VARCHAR(10), quarter VARCHAR(2), year INT, units_sold INT); INSERT INTO inventory (item_type, quarter, year, units_sold) VALUES ('women_tops', 'Q3', 2020, 1200), ('women_tops', 'Q3', 2020, 1500), ('women_tops', 'Q3', 2020, 1300);
|
How many units of women's tops were sold in Q3 2020?
|
SELECT SUM(units_sold) FROM inventory WHERE item_type = 'women_tops' AND quarter = 'Q3' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT, size INT, city VARCHAR(20), inclusive_housing_policy BOOLEAN);
|
Find the average size, in square feet, of properties with inclusive housing policies in the city of Denver.
|
SELECT AVG(size) FROM property WHERE city = 'Denver' AND inclusive_housing_policy = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm ( FarmID INT, FarmName VARCHAR(255) ); CREATE TABLE Stock ( StockID INT, FarmID INT, FishSpecies VARCHAR(255), Weight DECIMAL(10,2), StockDate DATE ); INSERT INTO Farm (FarmID, FarmName) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'), (4, 'Farm D'); INSERT INTO Stock (StockID, FarmID, FishSpecies, Weight, StockDate) VALUES (1, 1, 'Tilapia', 5.5, '2022-01-01'), (2, 1, 'Salmon', 12.3, '2022-01-02'), (3, 2, 'Tilapia', 6.0, '2022-01-03'), (4, 2, 'Catfish', 8.2, '2022-01-04'), (5, 3, 'Tilapia', 9.0, '2022-01-05'), (6, 3, 'Salmon', 11.0, '2022-01-06'), (7, 4, 'Tilapia', 10.0, '2022-01-07'), (8, 4, 'Salmon', 12.0, '2022-01-08');
|
Identify the farm with the lowest biomass of fish for a given species in a given year?
|
SELECT FarmName, FishSpecies, MIN(Weight) OVER (PARTITION BY FishSpecies) as MinBiomass FROM Stock JOIN Farm ON Stock.FarmID = Farm.FarmID WHERE DATE_TRUNC('year', StockDate) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE views (viewer_id INT, movie_title VARCHAR(255), views INT); INSERT INTO views (viewer_id, movie_title, views) VALUES (1, 'Movie1', 1000000), (2, 'Movie2', 2000000), (3, 'Movie1', 1500000), (4, 'Movie3', 500000);
|
Find the number of unique viewers for each movie and the total number of views for each movie
|
SELECT movie_title, COUNT(DISTINCT viewer_id) as unique_viewers, SUM(views) as total_views FROM views GROUP BY movie_title;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50), num_doctors INT);
|
What is the minimum number of doctors working in rural hospitals in India?
|
SELECT MIN(num_doctors) FROM hospitals WHERE location LIKE '%India%' AND location LIKE '%rural%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle_types (vehicle_type_id INT, vehicle_type VARCHAR(255)); CREATE TABLE trips (trip_id INT, vehicle_type_id INT, fare_amount DECIMAL(5,2), trip_date DATE);
|
What are the total fare collections for each vehicle type in the past month?
|
SELECT vt.vehicle_type, SUM(t.fare_amount) as total_fare FROM vehicle_types vt INNER JOIN trips t ON vt.vehicle_type_id = t.vehicle_type_id WHERE t.trip_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY vt.vehicle_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name TEXT, region TEXT); INSERT INTO vessels (id, name, region) VALUES (1, 'VesselA', 'Atlantic'); INSERT INTO vessels (id, name, region) VALUES (2, 'VesselB', 'Arctic'); INSERT INTO vessels (id, name, region) VALUES (3, 'VesselC', 'Atlantic');
|
How many vessels are there in the 'Atlantic' and 'Arctic' regions combined?
|
SELECT COUNT(*) FROM vessels WHERE region IN ('Atlantic', 'Arctic')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE xai_models (id INT, name VARCHAR(255), type VARCHAR(255), method VARCHAR(255)); INSERT INTO xai_models (id, name, type, method) VALUES (1, 'SHAP', 'Explainable AI', 'TreeExplainer'), (2, 'DeepLIFT', 'Explainable AI', 'Backpropagation');
|
Update the 'Explainable AI' model named 'SHAP' with a new method
|
UPDATE xai_models SET method = 'KernelExplainer' WHERE name = 'SHAP';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (item_id INT, item_name TEXT); INSERT INTO menu (item_id, item_name) VALUES (1, 'Spicy Quinoa'), (2, 'Tofu Stir Fry'), (3, 'Chickpea Curry'), (4, 'Beef Burrito'), (5, 'Chicken Alfredo'), (6, 'Fish and Chips'), (7, 'Veggie Pizza'), (8, 'Spicy Beef Burrito'), (9, 'Spicy Fish and Chips'), (10, 'Spicy Veggie Pizza');
|
How many items are there in the menu that have 'Spicy' in their name?
|
SELECT COUNT(*) FROM menu WHERE item_name LIKE '%Spicy%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, location VARCHAR(50), investment_type VARCHAR(50), investment_amount DECIMAL(10,2), investment_date DATE);
|
Remove a record from the network_investments table
|
DELETE FROM network_investments WHERE investment_id = 67890;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (id INT, name TEXT, region TEXT, founder_underrepresented BOOLEAN); INSERT INTO Companies (id, name, region, founder_underrepresented) VALUES (1, 'Solar Power LLC', 'North America', TRUE); INSERT INTO Companies (id, name, region, founder_underrepresented) VALUES (2, 'Wind Energy GmbH', 'Europe', FALSE);
|
Which regions have the most companies founded by individuals from underrepresented racial or ethnic groups?
|
SELECT region, COUNT(*) FROM Companies WHERE founder_underrepresented = TRUE GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicles (id INT, make VARCHAR(50), model VARCHAR(50), year INT, safety_rating FLOAT, manufacturer_country VARCHAR(50)); INSERT INTO vehicles (id, make, model, year, safety_rating, manufacturer_country) VALUES (1, 'Tesla', 'Model S', 2020, 5.3, 'USA'); INSERT INTO vehicles (id, make, model, year, safety_rating, manufacturer_country) VALUES (2, 'Toyota', 'Camry', 2021, 5.1, 'Japan'); INSERT INTO vehicles (id, make, model, year, safety_rating, manufacturer_country) VALUES (3, 'Ford', 'F-150', 2022, 5.0, 'USA');
|
What is the average safety_rating for vehicles manufactured in the US?
|
SELECT AVG(safety_rating) FROM vehicles WHERE manufacturer_country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title TEXT, runtime INT, director TEXT); INSERT INTO movies (id, title, runtime, director) VALUES (1, 'Movie1', 120, 'Director1'), (2, 'Movie2', 90, 'Director2'), (3, 'Movie3', 105, 'Director1');
|
What is the total runtime of movies directed by 'Director1'?
|
SELECT SUM(runtime) FROM movies WHERE director = 'Director1';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, model VARCHAR(255), manufacturer VARCHAR(255), production_year INT); INSERT INTO aircraft_manufacturing (id, model, manufacturer, production_year) VALUES (1, 'A320neo', 'Boeing', 2016);
|
Delete the aircraft with id 1 from the manufacturing table
|
DELETE FROM aircraft_manufacturing WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DispensarySales(id INT, dispensary VARCHAR(255), state VARCHAR(255), strain_type VARCHAR(255), sale_date DATE);
|
Find the number of days between the first and last sale for each strain type in Oregon dispensaries.
|
SELECT strain_type, MAX(sale_date) - MIN(sale_date) as days_between_sales FROM DispensarySales WHERE state = 'Oregon' GROUP BY strain_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BuildingPermits (PermitID INT, PermitDate DATE, State TEXT); INSERT INTO BuildingPermits VALUES (1, '2022-04-01', 'Florida'), (2, '2022-06-15', 'Florida'), (3, '2022-05-05', 'Florida');
|
How many building permits were issued in Florida in Q2 2022?
|
SELECT COUNT(*) FROM BuildingPermits WHERE State = 'Florida' AND YEAR(PermitDate) = 2022 AND QUARTER(PermitDate) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, founder_race TEXT, industry TEXT, total_funding INT); INSERT INTO company (id, name, founder_race, industry, total_funding) VALUES (1, 'Acme Inc', 'Hispanic', 'Biotech', 500000); INSERT INTO company (id, name, founder_race, industry, total_funding) VALUES (2, 'Beta Inc', 'Black', 'Biotech', 1000000);
|
What is the total funding amount for startups founded by people from underrepresented racial or ethnic backgrounds and are in the biotech industry?
|
SELECT SUM(total_funding) FROM company WHERE founder_race IN ('Hispanic', 'Black', 'Native American', 'Pacific Islander') AND industry = 'Biotech';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salaries (id INT, employee_id INT, job_title VARCHAR(50), annual_salary DECIMAL(10,2)); INSERT INTO salaries (id, employee_id, job_title, annual_salary) VALUES (1, 1, 'Engineer', 75000.00), (2, 2, 'Manager', 85000.00), (3, 3, 'Operator', 60000.00);
|
Show the top 3 roles with the highest average salary in the 'salaries' table.
|
SELECT job_title, AVG(annual_salary) as avg_salary FROM salaries GROUP BY job_title ORDER BY avg_salary DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditure (expenditure_id INT, drug_name TEXT, disease_area TEXT, year INT, amount DECIMAL); INSERT INTO rd_expenditure (expenditure_id, drug_name, disease_area, year, amount) VALUES (1, 'DrugC', 'Oncology', 2020, 5000000), (2, 'DrugD', 'Cardiovascular', 2019, 6000000);
|
Total R&D expenditure for Oncology drugs in 2020
|
SELECT SUM(amount) FROM rd_expenditure WHERE disease_area = 'Oncology' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (investment_id INT, strategy VARCHAR(255), esg_factors TEXT); INSERT INTO investment (investment_id, strategy, esg_factors) VALUES (1, 'Sustainable Agriculture', 'Water Management,Fair Trade,Biodiversity');
|
Which ESG factors are most commonly considered in sustainable agriculture investments?
|
SELECT strategy, REGEXP_SPLIT_TO_TABLE(esg_factors, ',') as esg_factor FROM investment WHERE strategy = 'Sustainable Agriculture' GROUP BY strategy, esg_factor;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE musicians (id INT PRIMARY KEY, name VARCHAR(100), genre VARCHAR(50), country VARCHAR(50), birth_date DATE); CREATE TABLE albums (id INT PRIMARY KEY, title VARCHAR(100), release_date DATE, musician_id INT, FOREIGN KEY (musician_id) REFERENCES musicians(id));
|
Insert a new album for the musician with id 3 with a title 'Eternal Sunshine' and a release date of '2024-05-15'
|
INSERT INTO albums (title, release_date, musician_id) VALUES ('Eternal Sunshine', '2024-05-15', 3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ev_adoption_stats (id INT, city VARCHAR, state VARCHAR, num_evs INT, population INT);
|
Identify the top 5 cities with the highest percentage of electric vehicle adoption in the 'ev_adoption_stats' table.
|
SELECT city, state, (num_evs * 100.0 / population)::DECIMAL(5,2) AS ev_adoption_percentage, RANK() OVER (ORDER BY (num_evs * 100.0 / population) DESC) AS rank FROM ev_adoption_stats WHERE rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_stock (species VARCHAR(255), pH FLOAT); CREATE TABLE ocean_health (species VARCHAR(255), pH FLOAT); INSERT INTO fish_stock (species, pH) VALUES ('Cod', 7.8), ('Haddock', 7.6); INSERT INTO ocean_health (species, pH) VALUES ('Cod', 7.6), ('Haddock', 7.5);
|
What is the minimum water pH level for each species, grouped by species, from the 'fish_stock' and 'ocean_health' tables?
|
SELECT f.species, MIN(f.pH) FROM fish_stock f INNER JOIN ocean_health o ON f.species = o.species GROUP BY f.species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CityInitiatives (City VARCHAR(255), Initiative VARCHAR(255), CO2EmissionReduction FLOAT); INSERT INTO CityInitiatives (City, Initiative, CO2EmissionReduction) VALUES ('NYC', 'SmartGrid', 15000), ('LA', 'SmartTransit', 20000), ('Chicago', 'SmartBuildings', 10000);
|
What is the CO2 emission reduction for each smart city initiative, ranked by the reduction?
|
SELECT Initiative, SUM(CO2EmissionReduction) AS Total_Reduction FROM CityInitiatives GROUP BY Initiative ORDER BY Total_Reduction DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, product VARCHAR(255), vulnerability_severity VARCHAR(255)); INSERT INTO vulnerabilities (id, timestamp, product, vulnerability_severity) VALUES (1, '2020-07-01 14:00:00', 'Product A', 'High'), (2, '2020-08-05 09:30:00', 'Product B', 'Medium');
|
How many vulnerabilities were found in the last 6 months for each product?
|
SELECT product, COUNT(*) as num_vulnerabilities FROM vulnerabilities WHERE timestamp >= NOW() - INTERVAL 6 MONTH GROUP BY product;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attacks (id INT, type VARCHAR(255), result VARCHAR(255), date DATE); INSERT INTO attacks (id, type, result, date) VALUES (1, 'phishing', 'successful', '2021-01-01'); INSERT INTO attacks (id, type, result, date) VALUES (2, 'malware', 'unsuccessful', '2021-01-02');
|
Calculate the percentage of successful phishing attacks in the healthcare sector in the first half of 2021
|
SELECT 100.0 * SUM(CASE WHEN type = 'phishing' AND result = 'successful' THEN 1 ELSE 0 END) / COUNT(*) as percentage FROM attacks WHERE sector = 'healthcare' AND date >= '2021-01-01' AND date < '2021-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project_energy_efficiency (project_name TEXT, state TEXT); INSERT INTO project_energy_efficiency (project_name, state) VALUES ('Project A', 'State A'), ('Project B', 'State A'), ('Project C', 'State B'), ('Project D', 'State B'), ('Project E', 'State C');
|
How many energy efficiency projects are there in each state in the United States?
|
SELECT state, COUNT(*) FROM project_energy_efficiency GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plan_info (plan_name VARCHAR(50), plan_type VARCHAR(20), monthly_fee FLOAT, average_data_usage FLOAT); CREATE TABLE subscriber_data (customer_id INT, service_type VARCHAR(20), plan_name VARCHAR(50));
|
List the top 5 mobile and broadband plans with the highest monthly revenue, including the plan name, plan type, monthly fee, and average data usage, and the total number of subscribers for each plan.
|
SELECT plan_info.plan_name, plan_info.plan_type, plan_info.monthly_fee, plan_info.average_data_usage, SUM(subscriber_data.customer_id) as total_subscribers FROM plan_info JOIN subscriber_data ON plan_info.plan_name = subscriber_data.plan_name WHERE plan_info.plan_name IN (SELECT plan_name FROM (SELECT plan_name, ROW_NUMBER() OVER (ORDER BY monthly_fee * average_data_usage DESC) as rank FROM plan_info) as subquery WHERE rank <= 5) GROUP BY plan_info.plan_name, plan_info.plan_type, plan_info.monthly_fee, plan_info.average_data_usage ORDER BY total_subscribers DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LaborHours (project_id INT, hours FLOAT, sustainability VARCHAR(255)); INSERT INTO LaborHours (project_id, hours, sustainability) VALUES (1, 500.5, 'sustainable'), (2, 300.2, 'not sustainable'), (3, 400, 'not sustainable');
|
How many labor hours were reported for not sustainable construction projects?
|
SELECT SUM(hours) FROM LaborHours WHERE sustainability = 'not sustainable';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations_2 (country VARCHAR(50), continent VARCHAR(50), operation_name VARCHAR(50), year INT); INSERT INTO peacekeeping_operations_2 (country, continent, operation_name, year) VALUES ('Egypt', 'Africa', 'UNOGIL', 1958), ('South Africa', 'Africa', 'UNAVEM', 1991), ('Nigeria', 'Africa', 'UNAMIR', 1993), ('Kenya', 'Africa', 'ONUSAL', 1991), ('Algeria', 'Africa', 'MINURSO', 1991);
|
How many peacekeeping operations have been conducted by each country in Africa?
|
SELECT country, COUNT(*) as total_operations FROM peacekeeping_operations_2 WHERE continent = 'Africa' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE voyage_log (id INT, vessel_type VARCHAR(50), voyage_duration INT);
|
Display the average voyage duration for each vessel type in the 'voyage_log' table
|
SELECT vessel_type, AVG(voyage_duration) FROM voyage_log GROUP BY vessel_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_production (site_name VARCHAR(50), quarter INT, year INT, waste_amount FLOAT); INSERT INTO waste_production (site_name, quarter, year, waste_amount) VALUES ('Site A', 1, 2021, 150.5), ('Site A', 2, 2021, 160.7), ('Site B', 1, 2021, 125.7), ('Site B', 2, 2021, 130.5), ('Site C', 1, 2021, 200.3), ('Site C', 2, 2021, 210.9), ('Site D', 1, 2021, 75.9), ('Site D', 2, 2021, 80.1);
|
Calculate the percentage change in chemical waste production per site, quarter over quarter.
|
SELECT site_name, ((waste_amount - LAG(waste_amount) OVER (PARTITION BY site_name ORDER BY year, quarter))/ABS(LAG(waste_amount) OVER (PARTITION BY site_name ORDER BY year, quarter))) * 100 as pct_change FROM waste_production;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug VARCHAR(20), approval_date DATE); INSERT INTO drug_approval (drug, approval_date) VALUES ('DrugA', '2022-01-01'), ('DrugB', '2022-02-01'), ('DrugC', '2021-03-01');
|
Delete records of drugs that were not approved in 2022 from the drug_approval table.
|
DELETE FROM drug_approval WHERE drug NOT IN (SELECT drug FROM drug_approval WHERE approval_date BETWEEN '2022-01-01' AND '2022-12-31');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors(id INT, name TEXT, state TEXT, donations_total INT); INSERT INTO donors VALUES (1, 'Donor A', 'New York', 50000); INSERT INTO donors VALUES (2, 'Donor B', 'New York', 30000); INSERT INTO donors VALUES (3, 'Donor C', 'California', 70000); INSERT INTO donors VALUES (4, 'Donor D', 'New York', 60000); INSERT INTO donors VALUES (5, 'Donor E', 'Texas', 40000);
|
Who are the top 5 donors contributing to political campaigns in the state of New York, including their donation amounts?
|
SELECT name, SUM(donations_total) as total_donations FROM donors WHERE state = 'New York' GROUP BY name ORDER BY total_donations DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (id INT, item VARCHAR(50), quantity INT, purchase_price DECIMAL(10, 2)); INSERT INTO Inventory (id, item, quantity, purchase_price) VALUES (1, 'Thingamajig', 100, 25.50), (2, 'Doohickey', 75, 18.35);
|
Which warehouse has the highest inventory value for item 'Thingamajig'?
|
SELECT item, MAX(quantity * purchase_price) FROM Inventory WHERE item = 'Thingamajig' GROUP BY item;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (state VARCHAR(20), year INT, num_projects INT); INSERT INTO renewable_projects (state, year, num_projects) VALUES ('California', 2020, 150), ('California', 2019, 140), ('California', 2018, 130), ('Texas', 2020, 120), ('Texas', 2019, 110);
|
How many renewable energy projects were initiated in California in 2020?
|
SELECT num_projects FROM renewable_projects WHERE state = 'California' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production (country VARCHAR(255), volume INT); INSERT INTO timber_production (country, volume) VALUES ('Canada', 1200), ('USA', 2000), ('France', 500), ('Germany', 700);
|
What is the total volume of timber produced by countries in Europe?
|
SELECT SUM(volume) FROM timber_production WHERE country IN ('France', 'Germany');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Product (product_id INT PRIMARY KEY, product_name VARCHAR(50), price DECIMAL(5,2), is_ethically_sourced BOOLEAN);
|
Find the average price of products that are not ethically sourced in the 'Product' table
|
SELECT AVG(price) FROM Product WHERE is_ethically_sourced = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_vehicles (vehicle_id INT, vehicle_type VARCHAR(20)); INSERT INTO autonomous_vehicles (vehicle_id, vehicle_type) VALUES (1, 'Car'), (2, 'Truck'), (3, 'Car'), (4, 'Bus'), (5, 'Car');
|
What is the total number of autonomous vehicles in operation in Oslo?
|
SELECT COUNT(*) as num_vehicles FROM autonomous_vehicles WHERE vehicle_type IN ('Car', 'Truck', 'Bus');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (8, 'Brazil', 'Switzerland', '2023-03-07', 45), (9, 'Argentina', 'Switzerland', '2023-07-20', 29);
|
What is the total number of tourists visiting Switzerland in 2023?
|
SELECT COUNT(*) FROM tourism_data WHERE destination = 'Switzerland' AND YEAR(arrival_date) = 2023;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists engineering; USE engineering; CREATE TABLE if not exists costs (id INT, date DATE, amount DECIMAL(10,2)); INSERT INTO costs (id, date, amount) VALUES (1, '2021-01-01', 15000.00), (2, '2021-01-15', 7000.00), (3, '2021-02-01', 12000.00), (4, '2021-03-01', 10000.00);
|
Find the total bioprocess engineering cost for each month in 2021.
|
SELECT MONTH(date) AS month, SUM(amount) AS total_cost FROM costs WHERE YEAR(date) = 2021 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets_canada (id INT, name TEXT, country TEXT, co2_reduction INT); INSERT INTO carbon_offsets_canada (id, name, country, co2_reduction) VALUES (1, 'The Gold Standard', 'Canada', 50000), (2, 'Verified Carbon Standard', 'Canada', 75000);
|
What is the total CO2 emissions reduction from all carbon offset programs in Canada?
|
SELECT SUM(co2_reduction) FROM carbon_offsets_canada WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY, name VARCHAR, description VARCHAR); CREATE TABLE Facilities (facility_id INT PRIMARY KEY, name VARCHAR, location VARCHAR, capacity INT, waste_type_id INT, FOREIGN KEY (waste_type_id) REFERENCES WasteTypes(waste_type_id)); CREATE TABLE RecyclingRates (rate_id INT PRIMARY KEY, facility_id INT, year INT, rate DECIMAL, FOREIGN KEY (facility_id) REFERENCES Facilities(facility_id)); INSERT INTO RecyclingRates (rate_id, facility_id, year, rate) VALUES (1, 1, 2018, 0.75), (2, 1, 2019, 0.78), (3, 1, 2020, 0.81);
|
List the recycling rates for facility ID 1
|
SELECT year, rate FROM RecyclingRates WHERE facility_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RenewableEnergyProjects (id INT, project_type VARCHAR(50), project_location VARCHAR(50), installed_capacity FLOAT); INSERT INTO RenewableEnergyProjects (id, project_type, project_location, installed_capacity) VALUES (1, 'Solar', 'NYC', 1000.0), (2, 'Wind', 'LA', 1500.0), (3, 'Solar', 'SF', 1200.0);
|
What is the total installed capacity of solar energy projects, grouped by project location?
|
SELECT project_location, SUM(installed_capacity) FROM RenewableEnergyProjects WHERE project_type = 'Solar' GROUP BY project_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, category VARCHAR(20), revenue DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, category, revenue) VALUES (1, 1, 'footwear', 200.00), (2, 2, 'footwear', 150.00), (3, 3, 'footwear', 250.00);
|
What is the maximum revenue generated from a single sale in the 'footwear' category?
|
SELECT MAX(revenue) FROM sales WHERE category = 'footwear';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO Volunteers (id, name, country) VALUES (1, 'Alice', 'United States'), (2, 'Bob', 'United States');
|
Update the country for volunteer 'Bob' to Canada.
|
UPDATE Volunteers SET country = 'Canada' WHERE name = 'Bob';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), rank VARCHAR(10));
|
Add a new faculty member to the faculty table
|
INSERT INTO faculty (id, name, department, rank) VALUES (101, 'Jane Smith', 'Mathematics', 'Assistant Professor');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_projects (id INT, name VARCHAR(50), budget FLOAT); INSERT INTO research_projects VALUES (1, 'ProjectM', 1000000); INSERT INTO research_projects VALUES (2, 'ProjectN', 1200000); INSERT INTO research_projects VALUES (3, 'ProjectO', 1500000);
|
What is the maximum budget for any genetic research project?
|
SELECT MAX(budget) FROM research_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_records (id INT, date DATE, temperature FLOAT);
|
What is the minimum water temperature in each month in 2021?
|
SELECT EXTRACT(MONTH FROM date) AS month, MIN(temperature) FROM temperature_records WHERE date LIKE '2021-%' GROUP BY month;
|
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.