context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE workouts (id INT, member_id INT, workout_type VARCHAR(50), heart_rate INT); INSERT INTO workouts (id, member_id, workout_type, heart_rate) VALUES (1, 1, 'Cycling', 120), (2, 1, 'Yoga', 90), (3, 2, 'Yoga', 85), (4, 3, 'Cycling', 130), (5, 4, 'Zumba', 110); CREATE TABLE members (id INT, name VARCHAR(50), age INT); INSERT INTO members (id, name, age) VALUES (1, 'John Doe', 30), (2, 'Jane Smith', 40), (3, 'Mike Johnson', 50), (4, 'Nancy Adams', 60);
|
How many members have a heart rate over 100 while doing Yoga?
|
SELECT COUNT(*) FROM workouts JOIN members ON workouts.member_id = members.id WHERE workout_type = 'Yoga' AND heart_rate > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patents(company varchar(20), region varchar(20), year int, num_patents int);INSERT INTO patents VALUES ('CompanyD', 'RegionE', 2016, 20);INSERT INTO patents VALUES ('CompanyD', 'RegionE', 2017, 25);INSERT INTO patents VALUES ('CompanyD', 'RegionE', 2018, 30);INSERT INTO patents VALUES ('CompanyD', 'RegionE', 2019, 35);
|
How many patents were filed by 'CompanyD' in 'RegionE' between 2016 and 2019?
|
SELECT SUM(num_patents) FROM patents WHERE company = 'CompanyD' AND region = 'RegionE' AND year BETWEEN 2016 AND 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_by_region_type (region TEXT, drug_name TEXT, drug_type TEXT, sales_q1 INT, sales_q2 INT, sales_q3 INT, sales_q4 INT); CREATE TABLE drug_types (drug_name TEXT, drug_type TEXT); INSERT INTO sales_by_region_type (region, drug_name, drug_type, sales_q1, sales_q2, sales_q3, sales_q4) VALUES ('North', 'DrugR', 'Biosimilar', 400, 500, 600, 800), ('South', 'DrugR', 'Biosimilar', 300, 350, 400, 500), ('East', 'DrugR', 'Biosimilar', 500, 600, 700, 900), ('West', 'DrugR', 'Biosimilar', 600, 700, 800, 1000), ('North', 'DrugS', 'Vaccine', 500, 600, 700, 800), ('South', 'DrugS', 'Vaccine', 400, 450, 500, 600), ('East', 'DrugS', 'Vaccine', 600, 700, 800, 900), ('West', 'DrugS', 'Vaccine', 700, 800, 900, 1000); INSERT INTO drug_types (drug_name, drug_type) VALUES ('DrugR', 'Biosimilar'), ('DrugS', 'Vaccine');
|
Which drug types have the highest and lowest sales in the 'sales_by_region_type' and 'drug_types' tables?
|
SELECT drug_type, SUM(sales_q1 + sales_q2 + sales_q3 + sales_q4) as total_sales FROM sales_by_region_type sbrt JOIN drug_types dt ON sbrt.drug_name = dt.drug_name GROUP BY drug_type ORDER BY total_sales DESC, drug_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE UNESCO_Intangible_Heritage (id INT, year INT, art_form VARCHAR(100)); INSERT INTO UNESCO_Intangible_Heritage (id, year, art_form) VALUES (1, 2001, 'Argentine Tango'), (2, 2003, 'Kilim weaving in Turkey'), (3, 2005, 'Falconry, a living human heritage');
|
Identify the traditional arts that were first inscribed in the Representative List of the Intangible Cultural Heritage of Humanity in 2003.
|
SELECT art_form FROM UNESCO_Intangible_Heritage WHERE year = 2003;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sf_rideshares (id INT, ride_id VARCHAR(20), start_time TIMESTAMP, end_time TIMESTAMP, trip_distance FLOAT);
|
List the 5 most recent rideshare trips in San Francisco.
|
SELECT * FROM sf_rideshares ORDER BY end_time DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name VARCHAR(50), position VARCHAR(50), height FLOAT, weight INT, team_id INT, league VARCHAR(50)); INSERT INTO players (player_id, name, position, height, weight, team_id, league) VALUES (3, 'Carol', 'Forward', 1.68, 65, 301, 'Premier League');
|
What is the minimum height of soccer players in the 'Premier League'?
|
SELECT MIN(height) FROM players WHERE league = 'Premier League';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceDebris (id INT, object_name VARCHAR(255), source_country VARCHAR(255), launch_year INT); INSERT INTO SpaceDebris (id, object_name, source_country, launch_year) VALUES (1, 'Fengyun 1C', 'China', 1999); INSERT INTO SpaceDebris (id, object_name, source_country, launch_year) VALUES (2, 'Cosmos 2251', 'Russia', 1993); INSERT INTO SpaceDebris (id, object_name, source_country, launch_year) VALUES (3, 'Mir', 'Russia', 1986); INSERT INTO SpaceDebris (id, object_name, source_country, launch_year) VALUES (4, 'Skylab', 'United States', 1973);
|
Display the number of space debris objects from the USA and Russia launched before 2000
|
SELECT source_country, COUNT(*) as 'Number of Objects' FROM SpaceDebris WHERE launch_year < 2000 AND source_country IN ('United States', 'Russia') GROUP BY source_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite_Launches (launch_date DATE, country VARCHAR(255), success BOOLEAN); INSERT INTO Satellite_Launches (launch_date, country, success) VALUES ('2020-01-01', 'Israel', FALSE), ('2020-02-01', 'India', TRUE), ('2020-03-01', 'Israel', FALSE), ('2020-04-01', 'India', TRUE), ('2020-05-01', 'Israel', FALSE);
|
What is the total number of failed satellite launches by Israeli and Indian space programs?
|
SELECT SUM(success) AS total_failed_launches FROM (SELECT success FROM Satellite_Launches WHERE country IN ('Israel', 'India')) AS subquery WHERE success = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id VARCHAR(20), name VARCHAR(20), region VARCHAR(20)); CREATE TABLE incidents (id INT, country_id VARCHAR(20), type VARCHAR(20)); INSERT INTO countries (id, name, region) VALUES ('1', 'USA', 'North America'), ('2', 'Canada', 'North America'), ('3', 'Mexico', 'Central America'); INSERT INTO incidents (id, country_id, type) VALUES (1, '1', 'Safety'), (2, '1', 'Environment'), (3, '2', 'Safety'), (4, '3', 'Environment');
|
How many regulatory compliance incidents were reported for each country?
|
SELECT c.region, COUNT(*) FROM countries co JOIN incidents i ON co.id = i.country_id GROUP BY co.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(50), type VARCHAR(20), location VARCHAR(50));
|
Delete a restorative justice program from the "programs" table
|
DELETE FROM programs WHERE id = 3001 AND type = 'Restorative Justice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AgriculturalInnovations (id INT, country VARCHAR(50), project VARCHAR(50), budget FLOAT, year INT); INSERT INTO AgriculturalInnovations (id, country, project, budget, year) VALUES (1, 'Kenya', 'AgriTech App Development', 250000, 2020), (2, 'Kenya', 'Modern Irrigation Systems', 500000, 2020), (3, 'Uganda', 'Solar Powered Pumps', 300000, 2019);
|
What was the total budget for all agricultural innovation projects in Kenya in 2020?
|
SELECT SUM(budget) FROM AgriculturalInnovations WHERE country = 'Kenya' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farms (id INT, name TEXT, location TEXT, size FLOAT); INSERT INTO farms (id, name, location, size) VALUES (1, 'Sustainable Grove', 'India', 180.0); CREATE TABLE crops (id INT, farm_id INT, crop TEXT, yield INT, year INT); INSERT INTO crops (id, farm_id, crop, yield, year) VALUES (1, 1, 'moringa', 100, 2023);
|
Increase the yield of crop 'moringa' in farm 'Sustainable Grove' by 30 in 2023
|
UPDATE crops SET yield = yield + 30 WHERE farm_id = (SELECT id FROM farms WHERE name = 'Sustainable Grove') AND crop = 'moringa' AND year = 2023;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_city_projects (project_id INT, project_name VARCHAR(100), city VARCHAR(100), implementation_date DATE, energy_savings FLOAT); INSERT INTO smart_city_projects (project_id, project_name, city, implementation_date, energy_savings) VALUES (1, 'Smart Lighting', 'New York', '2022-01-01', 20.0), (2, 'Smart Grid', 'New York', '2021-07-01', 30.0);
|
What is the average energy savings of smart city projects implemented in the last 3 years in the city of New York?
|
SELECT AVG(energy_savings) FROM smart_city_projects WHERE city = 'New York' AND implementation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountryParticipation (id INT, country VARCHAR(50), num_operations INT);
|
What is the minimum number of peacekeeping operations participated in by each country?
|
SELECT country, MIN(num_operations) FROM CountryParticipation GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, mine_name VARCHAR(50), community_type VARCHAR(50), employees INT); CREATE VIEW underrepresented_communities AS SELECT * FROM (VALUES ('Indigenous'), ('Rural'), ('Minority')) AS underrepresented(community_type);
|
How many employees work in mining operations located in underrepresented communities?
|
SELECT COUNT(*) FROM mining_operations JOIN underrepresented_communities ON mining_operations.community_type = underrepresented_communities.community_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bioprocess (id INT, bioreactor VARCHAR(50), parameter VARCHAR(50), value FLOAT); INSERT INTO bioprocess (id, bioreactor, parameter, value) VALUES (3, 'Bioreactor3', 'Temperature', 40);
|
List all bioprocess engineering information for a specific bioreactor with a temperature of 40 degrees Celsius?
|
SELECT * FROM bioprocess WHERE value = 40 AND parameter = 'Temperature';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE unesco_world_heritage_sites (site_id INT, name VARCHAR(50), country_id INT, is_protected BOOLEAN); INSERT INTO unesco_world_heritage_sites (site_id, name, country_id, is_protected) VALUES (9, 'Great Wall of China', 12, true); INSERT INTO unesco_world_heritage_sites (site_id, name, country_id, is_protected) VALUES (10, 'Angkor Wat', 13, true);
|
What is the total number of visitors to each UNESCO World Heritage Site in Asia?
|
SELECT u.name, SUM(i.num_visitors) as total_visitors FROM unesco_world_heritage_sites u INNER JOIN destinations d ON u.site_id = d.destination_id INNER JOIN international_visitors i ON d.destination_id = i.destination_id WHERE u.country_id IN (SELECT country_id FROM countries WHERE continent = 'Asia') GROUP BY u.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE iocs (ioc_id INT, ioc_value TEXT, attack_type TEXT, occurrence_count INT, last_updated DATETIME);INSERT INTO iocs (ioc_id, ioc_value, attack_type, occurrence_count, last_updated) VALUES (1, 'IOC Value 1', 'Ransomware', 120, '2022-01-01 10:00:00'),(2, 'IOC Value 2', 'Ransomware', 75, '2022-01-02 11:00:00'),(3, 'IOC Value 3', 'Ransomware', 200, '2022-01-03 12:00:00'),(4, 'IOC Value 4', 'Ransomware', 90, '2022-01-04 13:00:00'),(5, 'IOC Value 5', 'Ransomware', 110, '2022-01-05 14:00:00');
|
List the unique indicators of compromise (IOCs) associated with ransomware attacks in the last month, excluding any IOCs seen more than 100 times.
|
SELECT DISTINCT ioc_value FROM iocs WHERE attack_type = 'Ransomware' AND last_updated >= DATEADD(month, -1, GETDATE()) AND occurrence_count <= 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_tourism (initiative_id INT, name TEXT, continent TEXT); INSERT INTO sustainable_tourism (initiative_id, name, continent) VALUES (1, 'Green Coast Project', 'Europe'), (2, 'EcoVillage Borneo', 'Asia'), (3, 'Sustainable Safari Tours', 'Africa');
|
How many sustainable tourism initiatives are in Asia and Africa?
|
SELECT SUM(continent = 'Asia') as asia_count, SUM(continent = 'Africa') as africa_count FROM sustainable_tourism;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ManufacturerProducts (manufacturer_id INT, manufacturer_name VARCHAR(255), product_type VARCHAR(255), is_fair_trade BOOLEAN); INSERT INTO ManufacturerProducts (manufacturer_id, manufacturer_name, product_type, is_fair_trade) VALUES (1, 'EcoPure', 'Clothing', true), (2, 'GreenYarn', 'Yarn', false), (3, 'SustainableTimber', 'Furniture', true), (4, 'EthicalMinerals', 'Electronics', true), (5, 'FairTradeFabrics', 'Textiles', true), (6, 'EcoDyes', 'Dyes', false), (7, 'EcoPaints', 'Paint', true), (8, 'GreenBuilding', 'Building Materials', false);
|
What is the percentage of fair trade products by manufacturer?
|
SELECT manufacturer_name, ROUND(COUNT(*) FILTER (WHERE is_fair_trade = true) * 100.0 / COUNT(*), 2) as fair_trade_percentage FROM ManufacturerProducts GROUP BY manufacturer_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE intelligence_agency (agency VARCHAR(50), operation_name VARCHAR(50), operation_year INT); INSERT INTO intelligence_agency (agency, operation_name, operation_year) VALUES ('CIA', 'Operation Bluebird', 1950), ('CIA', 'Operation Mockingbird', 1960), ('MI6', 'Operation Gold', 1956), ('MI6', 'Operation Silver', 1962), ('NSA', 'Operation Shamrock', 1945);
|
Which intelligence operations were conducted before the year 2000 in the 'intelligence_agency' table?
|
SELECT agency, operation_name FROM intelligence_agency WHERE operation_year < 2000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if NOT EXISTS animal_region (animal_id INT, animal_name VARCHAR(50), region VARCHAR(10), conservation_status VARCHAR(20)); INSERT INTO animal_region (animal_id, animal_name, region, conservation_status) VALUES (1, 'Grizzly Bear', 'North America', 'Threatened'); INSERT INTO animal_region (animal_id, animal_name, region, conservation_status) VALUES (2, 'Bald Eagle', 'North America', 'Least Concern');
|
Identify the conservation status of animals living in the North American region.
|
SELECT animal_name, conservation_status FROM animal_region WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(255), LastName VARCHAR(255), Position VARCHAR(255), Department VARCHAR(255), Gender VARCHAR(255), Country VARCHAR(255));
|
How many employees in each department have underrepresented genders in US mining operations?
|
SELECT Department, COUNT(*) as Total FROM Employees WHERE Gender IN ('Non-binary', 'Female') AND Country = 'USA' GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Highways (id INT, name VARCHAR(100), location VARCHAR(100), lanes INT, speed_limit INT, state VARCHAR(50)); CREATE TABLE Engineering_Standards (id INT, standard VARCHAR(100), highway_id INT); INSERT INTO Highways (id, name, location, lanes, speed_limit, state) VALUES (1, 'Interstate 90', 'Buffalo to Albany', 4, 70, 'New York'); INSERT INTO Engineering_Standards (id, standard, highway_id) VALUES (1, 'AASHTO Standard 1A', 1);
|
What is the name, location, and number of lanes for all highways in the state of New York with a speed limit greater than 60 miles per hour, along with their corresponding engineering design standards?
|
SELECT Highways.name, Highways.location, Highways.lanes, Engineering_Standards.standard FROM Highways INNER JOIN Engineering_Standards ON Highways.id = Engineering_Standards.highway_id WHERE Highways.state = 'New York' AND Highways.speed_limit > 60;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerTeam (PlayerID INT, TeamID INT); INSERT INTO PlayerTeam (PlayerID, TeamID) VALUES (101, 1), (102, 1), (103, 2), (104, 3); CREATE TABLE PlayerScore (PlayerID INT, GameID INT, Score INT); INSERT INTO PlayerScore (PlayerID, GameID, Score) VALUES (101, 1001, 70), (102, 1001, 80), (103, 1002, 85), (104, 1002, 90);
|
Which team has the highest average score?
|
SELECT TeamID, AVG(Score) FROM PlayerScore JOIN PlayerTeam ON PlayerScore.PlayerID = PlayerTeam.PlayerID GROUP BY TeamID ORDER BY AVG(Score) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipments (id INT, weight INT, delay_reason VARCHAR(50), delivery_date DATE); INSERT INTO Shipments (id, weight, delay_reason, delivery_date) VALUES (1, 100, 'Weather', '2021-01-05'), (2, 150, 'Mechanical', '2021-01-07'), (3, 200, 'Weather', '2021-02-12'); CREATE TABLE DelayReasons (id INT, reason VARCHAR(50)); INSERT INTO DelayReasons (id, reason) VALUES (1, 'Weather'), (2, 'Mechanical');
|
What are the total weights of shipments that were delayed due to weather conditions for each month in 2021?
|
SELECT DATE_FORMAT(delivery_date, '%Y-%m') AS month, SUM(weight) AS total_weight FROM Shipments INNER JOIN DelayReasons ON Shipments.delay_reason = DelayReasons.reason WHERE DelayReasons.reason = 'Weather' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members (id INT, name VARCHAR(50), email VARCHAR(50));
|
Add a new record for a user with id 20, name 'John Doe' and email 'johndoe@example.com' to the members table
|
INSERT INTO members (id, name, email) VALUES (20, 'John Doe', 'johndoe@example.com');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_virtual_tours (hotel TEXT, region TEXT, has_virtual_tour BOOLEAN); INSERT INTO hotel_virtual_tours (hotel, region, has_virtual_tour) VALUES ('Hotel Marrakech', 'Africa', true), ('Hotel Cairo', 'Africa', false), ('Hotel Capetown', 'Africa', true), ('Hotel Alexandria', 'Africa', false), ('Hotel Tunis', 'Africa', true);
|
What is the percentage of hotels in 'Africa' that offer virtual tours?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM hotel_virtual_tours WHERE region = 'Africa')) AS percentage FROM hotel_virtual_tours WHERE region = 'Africa' AND has_virtual_tour = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sourcing (item VARCHAR(20), material VARCHAR(20), country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO sourcing (item, material, country, price) VALUES ('T-Shirt', 'Linen', 'Egypt', 18.50), ('Skirt', 'Linen', 'Egypt', 20.00);
|
What is the average price of linen textiles sourced from Egypt?
|
SELECT AVG(price) FROM sourcing WHERE material = 'Linen' AND country = 'Egypt';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id int, product_id int, sale_date date, revenue decimal(5,2)); CREATE TABLE products (product_id int, product_name varchar(255), is_organic boolean, country varchar(50)); INSERT INTO sales (sale_id, product_id, sale_date, revenue) VALUES (1, 1, '2022-01-01', 75.00); INSERT INTO products (product_id, product_name, is_organic, country) VALUES (1, 'Organic Spices', true, 'India');
|
What is the daily sales revenue of organic products in India?
|
SELECT sale_date, SUM(revenue) AS daily_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE is_organic = true AND country = 'India' GROUP BY sale_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contractors (id INT, contractor_name VARCHAR(255)); INSERT INTO contractors (id, contractor_name) VALUES (1, 'Contractor A'), (2, 'Contractor B'), (3, 'Contractor C'), (4, 'Contractor D'), (5, 'Contractor E'); CREATE TABLE contracts (id INT, contractor_id INT, contract_date DATE); INSERT INTO contracts (id, contractor_id, contract_date) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-02-05'), (3, 3, '2021-03-12'), (4, 4, '2021-04-20'), (5, 5, '2021-05-01'), (6, 1, '2021-06-15'), (7, 2, '2021-07-01'), (8, 3, '2021-08-10'), (9, 4, '2021-09-20'), (10, 5, '2021-10-01');
|
Who are the top 2 defense contractors by the number of contracts signed in 2021?
|
SELECT contractor_name, COUNT(*) AS num_contracts FROM contracts INNER JOIN contractors ON contracts.contractor_id = contractors.id WHERE YEAR(contract_date) = 2021 GROUP BY contractor_name ORDER BY num_contracts DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ingredients (IngredientID INT, ProductID INT, Vegan BOOLEAN); INSERT INTO Ingredients (IngredientID, ProductID, Vegan) VALUES (1, 1, TRUE), (2, 1, FALSE), (3, 2, FALSE), (4, 2, TRUE), (5, 3, FALSE); CREATE TABLE Products (ProductID INT, ConsumerPreferenceScore INT); INSERT INTO Products (ProductID, ConsumerPreferenceScore) VALUES (1, 75), (2, 80), (3, 60);
|
List the non-vegan ingredients for products with a preference score above 70.
|
SELECT Ingredients.IngredientID, Products.ProductID, Ingredients.Vegan FROM Ingredients INNER JOIN Products ON Ingredients.ProductID = Products.ProductID WHERE Products.ConsumerPreferenceScore > 70 AND Ingredients.Vegan = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (id INT, region TEXT, rd_expenditure FLOAT); INSERT INTO clinical_trials (id, region, rd_expenditure) VALUES (1, 'North America', 800000), (2, 'Asia-Pacific', 900000), (3, 'Europe', 700000), (4, 'North America', 850000), (5, 'Asia-Pacific', 950000), (6, 'Europe', 750000);
|
What is the average R&D expenditure per clinical trial for the Asia-Pacific region?
|
SELECT AVG(rd_expenditure) as avg_rd_expenditure FROM clinical_trials WHERE region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE north_wells (well_name TEXT, production_quantity INT); INSERT INTO north_wells (well_name, production_quantity) VALUES ('Well A', 4000), ('Well B', 5000), ('Well C', 6000);
|
What is the total production quantity for wells in the 'north' region?
|
SELECT SUM(production_quantity) FROM north_wells WHERE region = 'north';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, location VARCHAR(20), volume INT); INSERT INTO production (id, location, volume) VALUES (1, 'Middle East', 100000); INSERT INTO production (id, location, volume) VALUES (2, 'Middle East', 110000); INSERT INTO production (id, location, volume) VALUES (3, 'Europe', 70000);
|
What is the average production volume in the Middle East?
|
SELECT AVG(volume) FROM production WHERE location = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT, company_id INT, year INT, gender_distribution TEXT, racial_distribution TEXT); INSERT INTO diversity_metrics (id, company_id, year, gender_distribution, racial_distribution) VALUES (1, 1, 2020, '...', '...'); CREATE TABLE company (id INT, name TEXT, industry TEXT); INSERT INTO company (id, name, industry) VALUES (1, 'SunPower', 'Green Energy');
|
Update records of diversity metrics for companies in the green energy sector with accurate and complete data.
|
UPDATE diversity_metrics SET gender_distribution = '...', racial_distribution = '...' WHERE company_id IN (SELECT id FROM company WHERE industry = 'Green Energy');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RiskAssessments (AssessmentID INT, AssessmentName VARCHAR(50), RiskLevel INT); INSERT INTO RiskAssessments (AssessmentID, AssessmentName, RiskLevel) VALUES (1, 'Assessment A', 5), (2, 'Assessment B', 3), (3, 'Assessment C', 4), (4, 'Assessment D', 2);
|
Rank the geopolitical risk assessments by risk level in descending order, and display the assessment name, risk level, and rank?
|
SELECT AssessmentName, RiskLevel, ROW_NUMBER() OVER (ORDER BY RiskLevel DESC) AS Rank FROM RiskAssessments;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_species (species_id INT PRIMARY KEY, species_name VARCHAR(50), conservation_status VARCHAR(20))
|
What is the total number of fish species?
|
SELECT COUNT(*) FROM fish_species
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), ocean VARCHAR(255), depth INT); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (1, 'Narwhal', 'Arctic', 1500); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (2, 'Beluga Whale', 'Arctic', 500);
|
Delete all records of marine species from the Arctic ocean that are deeper than 1000 meters.
|
DELETE FROM marine_species WHERE ocean = 'Arctic' AND depth > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, state TEXT, therapy TEXT); INSERT INTO patients (patient_id, age, gender, state, therapy) VALUES (1, 30, 'Female', 'California', 'Yes'); INSERT INTO patients (patient_id, age, gender, state, therapy) VALUES (2, 45, 'Male', 'Texas', 'No'); INSERT INTO patients (patient_id, age, gender, state, therapy) VALUES (3, 50, 'Non-binary', 'California', 'Yes');
|
What is the percentage of female patients who received therapy in California?
|
SELECT (COUNT(*) FILTER (WHERE gender = 'Female' AND therapy = 'Yes')) * 100.0 / (SELECT COUNT(*) FROM patients WHERE state = 'California') AS percentage FROM patients WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT); INSERT INTO factories (factory_id, name, location) VALUES (1, 'GreenTech', 'Seattle'), (2, 'EcoPlants', 'Chicago'), (3, 'BlueFactory', 'Miami'); CREATE TABLE waste_data (factory_id INT, waste_tons INT, month TEXT); INSERT INTO waste_data (factory_id, waste_tons, month) VALUES (1, 120, 'January'), (1, 110, 'February'), (2, 80, 'January'), (2, 90, 'February'), (3, 150, 'January'), (3, 160, 'February');
|
What are the names and locations of all factories with an average waste production of over 100 tons per month?
|
SELECT f.name, f.location FROM factories f INNER JOIN waste_data w ON f.factory_id = w.factory_ID GROUP BY f.factory_id HAVING AVG(waste_tons) > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, city VARCHAR(20), price DECIMAL(5,2)); INSERT INTO events (id, city, price) VALUES (1, 'Tokyo', 30.99), (2, 'Seoul', 25.50);
|
What is the average ticket price for events in Tokyo and Seoul?
|
SELECT AVG(price) FROM events WHERE city IN ('Tokyo', 'Seoul');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spring2023 (garment_id INT, garment_name VARCHAR(50), material VARCHAR(50), sustainable BOOLEAN); INSERT INTO Spring2023 (garment_id, garment_name, material, sustainable) VALUES (1, 'Linen Blend Dress', 'Linen-Hemp Blend', true), (2, 'Silk Top', 'Silk', false), (3, 'Recycled Polyester Skirt', 'Recycled Polyester', true);
|
List all garments in the "Spring 2023" collection that use sustainable materials.
|
SELECT garment_name FROM Spring2023 WHERE sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT); CREATE TABLE research_grants (grant_id INT, student_id INT, amount DECIMAL(10,2), date DATE);
|
List the departments that have never received a research grant.
|
SELECT gs.department FROM graduate_students gs LEFT JOIN research_grants rg ON gs.student_id = rg.student_id WHERE rg.grant_id IS NULL GROUP BY gs.department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT, name TEXT); CREATE TABLE cases (case_id INT, attorney_id INT);
|
List all attorneys who have not handled any cases.
|
SELECT a.attorney_id, a.name FROM attorneys a WHERE a.attorney_id NOT IN (SELECT c.attorney_id FROM cases c);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_sequestration_by_region (id INT, region VARCHAR(255), year INT, metric_tons FLOAT); INSERT INTO carbon_sequestration_by_region (id, region, year, metric_tons) VALUES (1, 'North America', 2018, 1234567.12), (2, 'South America', 2018, 2345678.12), (3, 'Europe', 2018, 3456789.12);
|
List the top 3 regions with the lowest total carbon sequestration, in metric tons, for the year 2018.
|
SELECT region, SUM(metric_tons) as total_metric_tons FROM carbon_sequestration_by_region WHERE year = 2018 GROUP BY region ORDER BY total_metric_tons ASC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WeatherData (Station VARCHAR(255), Date DATE, Temperature FLOAT); INSERT INTO WeatherData (Station, Date, Temperature) VALUES ('StationA', '2020-01-01', -10.5), ('StationB', '2020-01-01', -12.3);
|
What is the highest temperature recorded at each Arctic research station in 2020?
|
SELECT Station, MAX(Temperature) FROM WeatherData WHERE YEAR(Date) = 2020 GROUP BY Station;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethics_projects (project_id INT, budget FLOAT, initiative TEXT); INSERT INTO ethics_projects (project_id, budget, initiative) VALUES (1, 60000, 'ethical AI'), (2, 80000, 'digital divide'), (3, 90000, 'ethical AI');
|
What is the total budget for ethical AI projects in Asia?
|
SELECT SUM(budget) FROM ethics_projects WHERE initiative = 'ethical AI';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feed_additives (id INT, name VARCHAR(255), manufacturer_id INT, usage_volume FLOAT); INSERT INTO feed_additives (id, name, manufacturer_id, usage_volume) VALUES (1, 'Aquaculture', 1, 3500.0), (2, 'Aquafeed Colorant', 2, 2800.0), (3, 'Aquafeed Preservative', 3, 4200.0), (4, 'Aquafeed Attractant', 1, 3000.0), (5, 'Aquafeed Binder', 2, 4500.0);
|
What is the percentage of the total usage volume for each feed additive?
|
SELECT name, usage_volume, usage_volume * 100.0 / (SELECT SUM(usage_volume) FROM feed_additives) AS percentage FROM feed_additives;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, Name TEXT, Region TEXT); INSERT INTO Programs (ProgramID, Name, Region) VALUES (1, 'Reading Club', 'Northeast'), (2, 'Garden Club', 'Midwest'); CREATE TABLE Regions (RegionID INT, Name TEXT); INSERT INTO Regions (RegionID, Name) VALUES (1, 'Northeast'), (2, 'Midwest'), (3, 'South');
|
How many unique programs were run in each region?
|
SELECT r.Name as Region, COUNT(DISTINCT p.ProgramID) as ProgramCount FROM Programs p INNER JOIN Regions r ON p.Region = r.Name GROUP BY r.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DailyOilProduction (FieldName TEXT, OilProduction INT, Date DATE); INSERT INTO DailyOilProduction (FieldName, OilProduction, Date) VALUES ('FieldA', 100, '2019-01-01'), ('FieldB', 150, '2019-02-01'), ('FieldC', 200, '2019-03-01');
|
What is the maximum daily oil production in the Niger Delta in 2019?
|
SELECT MAX(OilProduction) AS MaxDailyOilProduction FROM DailyOilProduction WHERE FieldName IN ('FieldA', 'FieldB', 'FieldC') AND Date BETWEEN '2019-01-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (organization_id INT, name VARCHAR(50), sector VARCHAR(50), headquarters_country VARCHAR(50)); INSERT INTO organizations (organization_id, name, sector, headquarters_country) VALUES (1, 'OrgA', 'technology for social good', 'India'), (2, 'OrgB', 'healthcare', 'USA'), (3, 'OrgC', 'technology for social good', 'China'), (4, 'OrgD', 'finance', 'Canada');
|
How many organizations in the technology for social good sector have their headquarters in India, China, and Brazil?
|
SELECT COUNT(*) FROM organizations WHERE sector = 'technology for social good' AND headquarters_country IN ('India', 'China', 'Brazil');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Visitors (id INT, country VARCHAR(50), destination VARCHAR(50), trip_duration INT); INSERT INTO Visitors (id, country, destination, trip_duration) VALUES (1, 'UK', 'New Zealand', 20);
|
What is the maximum trip duration for visitors who traveled to New Zealand from the United Kingdom in 2022?
|
SELECT MAX(trip_duration) FROM Visitors WHERE country = 'UK' AND destination = 'New Zealand' AND YEAR(visit_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Bookings (booking_date DATE, bookings INT); INSERT INTO Bookings (booking_date, bookings) VALUES ('2022-01-01', 500), ('2022-02-01', 600), ('2022-03-01', 700);
|
What is the total number of bookings for each month in the 'Bookings' table?
|
SELECT EXTRACT(MONTH FROM booking_date) AS month, SUM(bookings) FROM Bookings GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE program_volunteers (id INT, program_id INT, volunteer_id INT, signup_date DATE); INSERT INTO program_volunteers (id, program_id, volunteer_id, signup_date) VALUES (1, 1, 1, '2021-01-01'), (2, 2, 2, '2021-01-01'), (3, 1, 3, '2021-02-01'); CREATE TABLE program_donations (id INT, program_id INT, donor_id INT, donation_date DATE, amount FLOAT); INSERT INTO program_donations (id, program_id, donor_id, donation_date, amount) VALUES (1, 1, 1, '2021-01-01', 500.00), (2, 2, 2, '2021-02-01', 300.00), (3, 1, 4, '2022-03-01', 600.00); CREATE TABLE programs (id INT, program_name TEXT); INSERT INTO programs (id, program_name) VALUES (1, 'Education'), (2, 'Health');
|
What is the total number of volunteers and total amount donated for each program?
|
SELECT p.program_name, COUNT(DISTINCT program_volunteers.volunteer_id) AS total_volunteers, SUM(program_donations.amount) AS total_donations FROM programs LEFT JOIN program_volunteers ON programs.id = program_volunteers.program_id LEFT JOIN program_donations ON programs.id = program_donations.program_id GROUP BY p.program_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2), emissions_reduced DECIMAL(10,2)); INSERT INTO projects (id, name, location, start_date, end_date, budget, emissions_reduced) VALUES (1, 'Wind Turbine Park', 'UK', '2015-01-01', '2020-12-31', 10000000.00, 5000000.00);
|
What is the total emission reduction for projects in the United Kingdom between 2015 and 2020?
|
SELECT location AS region, SUM(emissions_reduced) as total_reduction FROM projects WHERE start_date >= '2015-01-01' AND end_date <= '2020-12-31' GROUP BY region;
|
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');
|
List all departments and the number of employees in each department.
|
SELECT department, COUNT(*) FROM Employees GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing (id INT, officer_id INT, event_type VARCHAR(255), event_date DATE); INSERT INTO community_policing (id, officer_id, event_type, event_date) VALUES (1, 40, 'Neighborhood Watch', '2021-01-03'); INSERT INTO community_policing (id, officer_id, event_type, event_date) VALUES (2, 41, 'Community Meeting', '2021-01-04');
|
List the community policing officers with the highest and lowest number of events attended?
|
SELECT officer_id, MIN(COUNT(event_type)) OVER(PARTITION BY officer_id ORDER BY event_date) as lowest, MAX(COUNT(event_type)) OVER(PARTITION BY officer_id ORDER BY event_date DESC) as highest FROM community_policing GROUP BY officer_id, event_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DigitalAssets (id INT, name VARCHAR(50), category VARCHAR(20), quantity INT);
|
How many digital assets are there for each category in the 'DigitalAssets' table?
|
SELECT category, COUNT(*) FROM DigitalAssets GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE boroughs (borough_name VARCHAR(255)); INSERT INTO boroughs (borough_name) VALUES ('Bronx'), ('Brooklyn'), ('Manhattan'), ('Queens'), ('Staten Island'); CREATE TABLE community_policing_events (event_date DATE, borough_name VARCHAR(255), event_count INT);
|
How many community policing events were held in each borough in the past year?
|
SELECT b.borough_name, COUNT(cpe.event_count) as total_events FROM boroughs b JOIN community_policing_events cpe ON b.borough_name = cpe.borough_name WHERE cpe.event_date >= CURDATE() - INTERVAL 1 YEAR GROUP BY b.borough_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(10));CREATE TABLE Events (EventID INT, EventName VARCHAR(20), EventCategory VARCHAR(20));CREATE TABLE VisitorSpending (VisitorID INT, EventID INT, Spending INT);
|
How many unique visitors attended events in the 'Theater' category and what was their total spending?
|
SELECT COUNT(DISTINCT V.VisitorID) AS Num_Unique_Visitors, SUM(VS.Spending) AS Total_Spending FROM Visitors V INNER JOIN VisitorSpending VS ON V.VisitorID = VS.VisitorID INNER JOIN Events E ON VS.EventID = E.EventID WHERE E.EventCategory = 'Theater';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Maintenance_Requests (request_id INT, equipment_type TEXT, state TEXT, request_date DATE); INSERT INTO Maintenance_Requests (request_id, equipment_type, state, request_date) VALUES (1, 'Helicopter', 'California', '2019-01-01'), (2, 'Tank', 'California', '2019-02-01');
|
How many military equipment maintenance requests were submitted in California in 2019?
|
SELECT COUNT(*) FROM Maintenance_Requests WHERE state = 'California' AND YEAR(request_date) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_stock (harvest_date DATE, species VARCHAR(255), quantity INT);
|
What is the total quantity of fish harvested per month in 2022, partitioned by species?
|
SELECT EXTRACT(MONTH FROM harvest_date) AS month, species, SUM(quantity) AS total_quantity FROM fish_stock WHERE harvest_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM harvest_date), species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, program_name VARCHAR(50), launch_year INT, budget DECIMAL(10,2)); INSERT INTO community_development (id, program_name, launch_year, budget) VALUES (1, 'Youth Skills Training', 2013, 15000.00), (2, 'Women Empowerment', 2016, 20000.00);
|
Which community development programs were launched before 2015 and their budgets in the 'community_development' table?
|
SELECT program_name, budget FROM community_development WHERE launch_year < 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE epl_cards (team_id INT, team VARCHAR(50), yellow_cards INT, red_cards INT); INSERT INTO epl_cards (team_id, team, yellow_cards, red_cards) VALUES (1, 'Manchester City', 50, 3); INSERT INTO epl_cards (team_id, team, yellow_cards, red_cards) VALUES (2, 'Liverpool', 45, 5);
|
What is the average number of yellow cards received by each soccer team in the EPL?
|
SELECT team, AVG(yellow_cards) FROM epl_cards GROUP BY team;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm_regions (farm_id INT, biomass FLOAT, region VARCHAR(50)); INSERT INTO farm_regions (farm_id, biomass, region) VALUES (1, 250.3, 'Asia-Pacific'), (2, 320.5, 'Asia-Pacific'), (3, 180.7, 'Asia-Pacific'), (4, 450.9, 'Asia-Pacific'), (5, 220.1, 'Asia-Pacific'), (6, 370.2, 'Asia-Pacific'); CREATE TABLE species_farms (farm_id INT, species VARCHAR(50)); INSERT INTO species_farms (farm_id, species) VALUES (1, 'Salmon'), (2, 'Tilapia'), (3, 'Carp'), (4, 'Salmon'), (5, 'Tuna'), (6, 'Cod');
|
What is the total biomass of fish in farms in the Asia-Pacific region for each species?
|
SELECT species, SUM(biomass) FROM farm_regions JOIN species_farms ON farm_regions.farm_id = species_farms.farm_id WHERE region = 'Asia-Pacific' GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, founded_year INT, industry TEXT, founder_gender TEXT, founder_race TEXT, veteran BOOLEAN, funding FLOAT);
|
What is the total funding raised by startups founded by veterans?
|
SELECT SUM(funding) FROM startups WHERE veteran = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, province VARCHAR(50), initiative VARCHAR(50), status VARCHAR(50)); INSERT INTO community_development (id, province, initiative, status) VALUES (1, 'Ontario', 'Community Center', 'Completed'), (2, 'Quebec', 'Park', 'In Progress'), (3, 'British Columbia', 'Community Garden', 'Completed'), (4, 'Alberta', 'Library', 'Completed');
|
How many community development initiatives have been completed in each province of Canada?
|
SELECT province, COUNT(*) as completed_initiatives FROM community_development WHERE status = 'Completed' GROUP BY province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinics (id INT, state VARCHAR(20), rural BOOLEAN); INSERT INTO clinics (id, state, rural) VALUES (1, 'Colorado', true), (2, 'Colorado', false), (3, 'Wyoming', true);
|
How many rural clinics are in each state?
|
SELECT state, COUNT(*) FROM clinics WHERE rural = true GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodation (id INT, name TEXT, country TEXT, sustainable INT); INSERT INTO accommodation (id, name, country, sustainable) VALUES (1, 'Sustainable Inn', 'Canada', 1); INSERT INTO accommodation (id, name, country, sustainable) VALUES (2, 'Eco Lodge', 'Mexico', 1); INSERT INTO accommodation (id, name, country, sustainable) VALUES (3, 'Green Retreat', 'USA', 1);
|
What is the maximum number of sustainable accommodations in each country?
|
SELECT country, MAX(sustainable) as max_sustainable FROM accommodation GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ethical_AI_Patents (year INT, patent VARCHAR(50)); INSERT INTO Ethical_AI_Patents (year, patent) VALUES (2018, 'AI Ethics Framework'), (2019, 'Ethical AI Algorithm'), (2018, 'Ethical AI Guidelines'), (2019, 'Ethical AI Toolkit'), (2018, 'AI Ethics Charter');
|
What is the trend of ethical AI patents filed over time?
|
SELECT year, COUNT(patent) as num_patents FROM Ethical_AI_Patents GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Tunnels (Name VARCHAR(255), Length_miles DECIMAL(5,2), State VARCHAR(255)); INSERT INTO Tunnels (Name, Length_miles, State) VALUES ('Port Miami Tunnel', 1.2, 'Florida');
|
What are the tunnels in Florida that are over 1 mile long?
|
SELECT Name FROM Tunnels WHERE Length_miles > 1 AND State = 'Florida';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INTEGER, name TEXT, age INTEGER, expertise TEXT); INSERT INTO volunteers (volunteer_id, name, age, expertise) VALUES (1, 'Alice', 25, 'Medical'), (2, 'Bob', 30, 'Engineering'), (3, 'Charlie', 35, 'Medical'), (4, 'David', 40, 'Logistics'), (5, 'Eve', 45, 'Communications');
|
What is the total number of volunteers with each expertise?
|
SELECT v.expertise, COUNT(v.expertise) FROM volunteers v GROUP BY v.expertise;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_tech (hotel_id INT, hotel_name TEXT, country TEXT, chatbot BOOLEAN, year_adopted INT);
|
How many hotels in Canada adopted AI-powered chatbots in each year?
|
SELECT year_adopted, COUNT(*) FROM hotel_tech WHERE country = 'Canada' AND chatbot = TRUE GROUP BY year_adopted;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cases (CaseID int, Outcome varchar(50), AttorneyID int, Gender varchar(50)); INSERT INTO Cases VALUES (1, 'Won', 1, 'Female'), (2, 'Lost', 2, 'Male'), (3, 'Won', 3, 'Female'), (4, 'Lost', 1, 'Female'), (5, 'Won', 2, 'Male'), (6, 'Lost', 3, 'Female');
|
What is the success rate of cases handled by female attorneys compared to male attorneys?
|
SELECT SUM(CASE WHEN Gender = 'Female' AND Outcome = 'Won' THEN 1 ELSE 0 END)/COUNT(*) AS FemaleSuccessRate, SUM(CASE WHEN Gender = 'Male' AND Outcome = 'Won' THEN 1 ELSE 0 END)/COUNT(*) AS MaleSuccessRate FROM Cases;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Instructors (id INT, name VARCHAR(30), region VARCHAR(20)); CREATE TABLE Courses (instructor_id INT, location VARCHAR(20));
|
Who are the top 5 traditional art instructors in Asia by total courses taught?
|
SELECT I.name, COUNT(C.instructor_id) as total_courses_taught FROM Instructors I JOIN Courses C ON I.id = C.instructor_id WHERE I.region = 'Asia' GROUP BY I.name ORDER BY total_courses_taught DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), attendance INT); INSERT INTO events (id, name, date, category, attendance) VALUES (1, 'Ballet', '2022-06-01', 'dance', 500), (2, 'Flamenco', '2022-06-02', 'dance', 200);
|
List the events that have attendance greater than the average attendance for all events.
|
SELECT name, attendance FROM events WHERE attendance > (SELECT AVG(attendance) FROM events);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, city VARCHAR(20), country VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id, city, country) VALUES (1, 'Vancouver', 'Canada'), (2, 'Toronto', 'Canada'), (3, 'Montreal', 'Canada'); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO Visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 30), (2, 1, 35), (3, 2, 25), (4, 2, 28), (5, 3, 40), (6, 3, 45);
|
What is the total age of visitors who attended exhibitions in Canada?
|
SELECT SUM(age) FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), organization VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO projects (id, name, type, location, organization, start_date, end_date) VALUES (1, 'Project X', 'Emergency Response', 'Asia', 'UN Aid', '2008-01-01', '2008-12-31');
|
How many 'Emergency Response' projects were conducted by 'UN Aid' in 'Asia' before 2010?
|
SELECT COUNT(*) FROM projects WHERE location = 'Asia' AND organization = 'UN Aid' AND type = 'Emergency Response' AND start_date < '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Organizations (OrgID INT, OrgName TEXT); INSERT INTO Organizations (OrgID, OrgName) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'), (3, 'Doctors Without Borders'); CREATE TABLE Donations (DonID INT, DonationAmount DECIMAL(5,2), OrgID INT); INSERT INTO Donations (DonID, DonationAmount, OrgID) VALUES (1, 50.00, 1), (2, 100.00, 1), (3, 25.00, 2), (4, 150.00, 3), (5, 75.00, 3);
|
Which organization has the highest average donation amount?
|
SELECT OrgName, AVG(DonationAmount) as AvgDonation FROM Donations INNER JOIN Organizations ON Donations.OrgID = Organizations.OrgID GROUP BY OrgID ORDER BY AvgDonation DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asia_temperature (year INT, avg_temp FLOAT); INSERT INTO asia_temperature (year, avg_temp) VALUES (2015, 20.1), (2016, 20.5), (2017, 21.2), (2018, 20.8), (2019, 21.0), (2020, 21.5); CREATE TABLE oceania_temperature (year INT, avg_temp FLOAT); INSERT INTO oceania_temperature (year, avg_temp) VALUES (2015, 15.1), (2016, 15.5), (2017, 16.2), (2018, 15.8), (2019, 16.0), (2020, 16.5);
|
What is the average temperature change in Asia and Oceania from 2015 to 2020?
|
SELECT AVG(asia_temperature.avg_temp) AS asia_avg_temp, AVG(oceania_temperature.avg_temp) AS oceania_avg_temp FROM asia_temperature, oceania_temperature WHERE asia_temperature.year = oceania_temperature.year AND asia_temperature.year BETWEEN 2015 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Venues (VenueID INT, VenueName VARCHAR(255), Capacity INT, Country VARCHAR(255)); INSERT INTO Venues (VenueID, VenueName, Capacity, Country) VALUES (1, 'VenueX', 5000, 'USA'), (2, 'VenueY', 7000, 'Canada'), (3, 'VenueZ', 6000, 'Mexico'); CREATE TABLE Concerts (ConcertID INT, VenueID INT, GenreID INT, TicketPrice DECIMAL(5,2), Sold INT); INSERT INTO Concerts (ConcertID, VenueID, GenreID, TicketPrice, Sold) VALUES (1, 1, 1, 50.00, 4000), (2, 2, 2, 60.00, 5000), (3, 3, 3, 45.00, 6500);
|
List the top 3 countries with the highest concert ticket revenue.
|
SELECT V.Country, SUM(C.TicketPrice * C.Sold) as TotalRevenue FROM Venues V JOIN Concerts C ON V.VenueID = C.VenueID GROUP BY V.Country ORDER BY TotalRevenue DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Courses (ID INT, Faculty VARCHAR(50), Course VARCHAR(50), Semester VARCHAR(10), Year INT); INSERT INTO Courses (ID, Faculty, Course, Semester, Year) VALUES ('Alice', 'Data Science', 'Fall', 2021), ('Bob', 'Machine Learning', 'Spring', 2022);
|
Which faculty member has the highest number of 'Data Science' courses taught?
|
SELECT Faculty, COUNT(*) AS CourseCount FROM Courses WHERE Course LIKE '%Data Science%' GROUP BY Faculty ORDER BY CourseCount DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, user_id INT, timestamp TIMESTAMP);
|
What is the most popular day of the week for virtual tours of hotels in the UK?
|
SELECT DATE_PART('dow', timestamp) AS day_of_week, COUNT(*) FROM virtual_tours WHERE country = 'UK' GROUP BY day_of_week ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); INSERT INTO restaurants (restaurant_id, name) VALUES (8, 'Middle Eastern Delights'); CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), restaurant_id INT); INSERT INTO menu_items (menu_item_id, name, price, restaurant_id) VALUES (10, 'Chicken Shawarma', 12.99, 8); CREATE TABLE orders (order_id INT, menu_item_id INT, quantity INT, order_date DATE, restaurant_id INT); INSERT INTO orders (order_id, menu_item_id, quantity, order_date, restaurant_id) VALUES (6, 10, 2, '2022-01-03', 8);
|
What percentage of revenue came from 'Chicken Shawarma' at 'Middle Eastern Delights'?
|
SELECT 100.0 * SUM(price * quantity) / (SELECT SUM(price * quantity) FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.restaurant_id = 8) AS revenue_percentage FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.name = 'Chicken Shawarma' AND mi.restaurant_id = 8;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), created_at TIMESTAMP); INSERT INTO user (id, name, age, gender, created_at) VALUES (1, 'John Doe', 25, 'Male', '2021-01-01 10:00:00'); CREATE TABLE post (id INT, user_id INT, content TEXT, posted_at TIMESTAMP); INSERT INTO post (id, user_id, content, posted_at) VALUES (1, 1, 'Hello World!', '2021-01-01 10:10:00');
|
What is the total number of posts for users over the age of 30 in the 'social_media' schema?
|
SELECT COUNT(*) FROM post JOIN user ON post.user_id = user.id WHERE user.age > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autoshow (vehicle_type VARCHAR(10), safety_rating DECIMAL(3,2)); INSERT INTO autoshow VALUES ('electric', 4.3), ('electric', 4.5), ('gasoline', 3.9), ('gasoline', 4.2), ('hybrid', 4.6);
|
What is the minimum safety rating for gasoline vehicles in the 'autoshow' table?
|
SELECT MIN(safety_rating) FROM autoshow WHERE vehicle_type = 'gasoline';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Infrastructure_Projects (Project_ID INT, Project_Name VARCHAR(255), Resilience_Score FLOAT, Year INT, Location VARCHAR(255));
|
What is the maximum resilience score for infrastructure projects in the Southern region of the US for the year 2020?
|
SELECT Year, MAX(Resilience_Score) FROM Infrastructure_Projects WHERE Location LIKE '%Southern%' AND Year = 2020 GROUP BY Year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, name VARCHAR(255), habitat_type VARCHAR(255), average_depth FLOAT); INSERT INTO marine_species (id, name, habitat_type, average_depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO marine_species (id, name, habitat_type, average_depth) VALUES (2, 'Blue Whale', 'Open Ocean', 200.0); CREATE TABLE ocean_depths (location VARCHAR(255), depth FLOAT); INSERT INTO ocean_depths (location, depth) VALUES ('Mariana Trench', 10994.0); INSERT INTO ocean_depths (location, depth) VALUES ('Sierra Leone Rise', 5791.0);
|
What is the maximum recorded depth for a marine species habitat?
|
SELECT MAX(od.depth) as max_depth FROM marine_species ms JOIN ocean_depths od ON ms.habitat_type = od.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, state VARCHAR(20), year INT, crime_type VARCHAR(20), number_of_crimes INT);
|
What is the total number of crimes committed in the state of Texas in the year 2019, grouped by crime type?
|
SELECT crime_type, SUM(number_of_crimes) FROM crimes WHERE state = 'Texas' AND year = 2019 GROUP BY crime_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, ingredient_name VARCHAR(50)); CREATE TABLE product_ingredients (product_id INT, ingredient_id INT);
|
For each ingredient, list the number of cosmetic products that source it, ranked in descending order.
|
SELECT i.ingredient_name, COUNT(pi.product_id) as product_count FROM ingredients i JOIN product_ingredients pi ON i.ingredient_id = pi.ingredient_id GROUP BY i.ingredient_name ORDER BY product_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_incident_repair_times (incident_id INT, incident_date DATE, repair_time INT, region VARCHAR(255)); INSERT INTO equipment_incident_repair_times (incident_id, incident_date, repair_time, region) VALUES (1, '2021-01-01', 5, 'Atlantic'), (2, '2021-01-15', 10, 'Pacific'), (3, '2021-03-20', 7, 'Atlantic');
|
What is the average repair time for equipment incidents in the Atlantic region in 2021?
|
SELECT AVG(repair_time) FROM equipment_incident_repair_times WHERE region = 'Atlantic' AND incident_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SUSTAINABLE_BRANDS (brand_id INT PRIMARY KEY, brand_name VARCHAR(50), country VARCHAR(50), sustainable_practices TEXT);
|
Insert a new sustainable brand from Brazil using organic materials.
|
INSERT INTO SUSTAINABLE_BRANDS (brand_id, brand_name, country, sustainable_practices) VALUES (4, 'BrandD', 'Brazil', 'Organic materials, fair trade');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates_southeast_asia (district VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates_southeast_asia (district, year, recycling_rate) VALUES ('Bangkok', 2020, 30.0), ('Ho_Chi_Minh_City', 2020, 25.0), ('Jakarta', 2020, 22.0), ('Kuala_Lumpur', 2020, 35.0), ('Singapore', 2020, 45.0);
|
What are the average recycling rates in percentage for each district in Southeast Asia in 2020?
|
SELECT district, AVG(recycling_rate) FROM recycling_rates_southeast_asia WHERE year = 2020 GROUP BY district;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete_wellbeing (athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (2, 'Jane Smith', 28, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (3, 'Jim Brown', 30, 'Football');
|
What is the average age of athletes in the 'athlete_wellbeing' table who play 'Basketball'?
|
SELECT AVG(age) FROM athlete_wellbeing WHERE sport = 'Basketball';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vulnerabilities (vuln_id INT, vuln_severity INT, vuln_date DATE, vuln_sector VARCHAR(50));
|
What is the average severity score of vulnerabilities in the finance sector for the last year?
|
SELECT AVG(vuln_severity) FROM Vulnerabilities WHERE vuln_sector = 'finance' AND vuln_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_productivity (mine_id INT, amount_extracted INT, num_employees INT, operational_costs INT); INSERT INTO labor_productivity (mine_id, amount_extracted, num_employees, operational_costs) VALUES (5, 1500, 75, 300000), (5, 1800, 90, 360000), (6, 1000, 50, 200000), (6, 1200, 60, 250000); CREATE TABLE mines (mine_id INT, mine_name TEXT); INSERT INTO mines (mine_id, mine_name) VALUES (5, 'MineN'), (6, 'MineO');
|
List the labor productivity metrics for each mine, including the total amount of minerals extracted, the number of employees, and the total operational costs. Calculate the productivity metric for each mine.
|
SELECT m.mine_name, AVG(lp.amount_extracted / lp.num_employees) AS productivity_metric FROM labor_productivity lp JOIN mines m ON lp.mine_id = m.mine_id GROUP BY m.mine_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indian_ocean (name VARCHAR(255), depth FLOAT); INSERT INTO indian_ocean VALUES ('Java', 7725);
|
What is the maximum depth of all trenches in the Indian Ocean?
|
SELECT MAX(depth) FROM indian_ocean WHERE name = 'Java';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (org_id INT, org_name TEXT, focus_topic TEXT); INSERT INTO organizations (org_id, org_name, focus_topic) VALUES (1, 'Org 1', 'Climate Change'), (2, 'Org 2', 'Social Impact'), (3, 'Org 3', 'Climate Change');
|
Delete all records from organizations focused on climate change.
|
DELETE FROM organizations WHERE focus_topic = 'Climate Change';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), oil_production FLOAT, gas_production FLOAT, location VARCHAR(50), timestamp TIMESTAMP); INSERT INTO wells (well_id, well_name, oil_production, gas_production, location, timestamp) VALUES (1, 'Well C', 1500, 2500, 'Gulf of Mexico', '2019-01-01 00:00:00'), (2, 'Well D', 1800, 2200, 'Gulf of Mexico', '2019-01-02 00:00:00');
|
Find the top 3 gas-producing wells in the Gulf of Mexico in H1 2019, ordered by average daily gas production.
|
SELECT well_id, well_name, AVG(gas_production) FROM wells WHERE location = 'Gulf of Mexico' AND EXTRACT(MONTH FROM timestamp) BETWEEN 1 AND 6 AND EXTRACT(YEAR FROM timestamp) = 2019 GROUP BY well_id, well_name ORDER BY AVG(gas_production) DESC LIMIT 3;
|
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.