context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE financial_institutions (institution_name TEXT, shariah_compliant BOOLEAN, region TEXT); INSERT INTO financial_institutions (institution_name, shariah_compliant, region) VALUES ('Bank Islam Brunei Darussalam', TRUE, 'Southeast Asia'); INSERT INTO financial_institutions (institution_name, shariah_compliant, region) VALUES ('Maybank Islamic Berhad', TRUE, 'Southeast Asia');
What is the number of Shariah-compliant financial institutions in Southeast Asia?
SELECT COUNT(institution_name) FROM financial_institutions WHERE shariah_compliant = TRUE AND region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, has_smartwatch BOOLEAN, country VARCHAR(50)); INSERT INTO Users (user_id, has_smartwatch, country) VALUES (1, true, 'Canada'); INSERT INTO Users (user_id, has_smartwatch, country) VALUES (2, false, 'USA');
How many users have a smartwatch and live in Canada?
SELECT COUNT(*) FROM Users WHERE has_smartwatch = true AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE IceHockeyPlayers (PlayerID INT, Name VARCHAR(50)); CREATE TABLE IceHockeyPenalties (PlayerID INT, MatchID INT, PenaltyMinutes INT);
What is the total number of penalty minutes served by players in the IceHockeyPlayers and IceHockeyPenalties tables, for players who have served more than 500 penalty minutes in total?
SELECT SUM(PenaltyMinutes) FROM IceHockeyPenalties INNER JOIN (SELECT PlayerID, SUM(PenaltyMinutes) as TotalPenaltyMinutes FROM IceHockeyPenalties GROUP BY PlayerID HAVING SUM(PenaltyMinutes) > 500) as Subquery ON IceHockeyPenalties.PlayerID = Subquery.PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_id INT, is_return BOOLEAN); INSERT INTO warehouse VALUES (1, 'LA'), (2, 'NY'), (3, 'TX'); INSERT INTO shipment VALUES (1, 1, FALSE), (2, 2, TRUE), (3, 3, FALSE), (4, 1, TRUE);
What are the names of all warehouses that have had a return shipment?
SELECT DISTINCT warehouse.name FROM warehouse INNER JOIN shipment ON warehouse.id = shipment.warehouse_id WHERE shipment.is_return = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), city VARCHAR(255), certification_level VARCHAR(255)); INSERT INTO green_buildings (building_id, building_name, city, certification_level) VALUES (1, 'EcoTower', 'New York', 'LEED Gold'), (2, 'GreenHeights', 'Chicago', 'LEED Platinum'), (3, 'SustainableCentral', 'Los Angeles', 'LEED Silver');
How many green buildings are there in each city?
SELECT city, COUNT(*) as num_buildings FROM green_buildings GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE platform_production_figures (platform_id INT, production_date DATE, oil_production FLOAT);
Find the average daily production of oil for each platform in Q4 2020
SELECT platform_id, AVG(oil_production) as avg_oil_production FROM platform_production_figures WHERE production_date BETWEEN '2020-10-01' AND '2020-12-31' GROUP BY platform_id;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturers (manufacturer_id INT, name VARCHAR(100)); CREATE TABLE spacecrafts (spacecraft_id INT, manufacturer_id INT, mass DECIMAL(10,2)); INSERT INTO spacecraft_manufacturers (manufacturer_id, name) VALUES (1, 'SpaceX'), (2, 'NASA'), (3, 'Blue Origin'); INSERT INTO spacecrafts (spacecraft_id, manufacturer_id, mass) VALUES (1, 1, 12000.00), (2, 1, 9000.00), (3, 2, 15000.00), (4, 3, 8000.00);
What is the total mass of all spacecraft built by each manufacturer?
SELECT sm.name, SUM(s.mass) as total_mass FROM spacecraft_manufacturers sm INNER JOIN spacecrafts s ON sm.manufacturer_id = s.manufacturer_id GROUP BY sm.name;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_rigs (rig_id INT, location VARCHAR(20), years_active INT); INSERT INTO oil_rigs (rig_id, location, years_active) VALUES (1, 'North Sea', 6), (2, 'North Sea', 3), (3, 'Gulf of Mexico', 8);
Identify the number of oil rigs in the 'North Sea' that have been active for more than 5 years.
SELECT COUNT(*) FROM oil_rigs WHERE location = 'North Sea' AND years_active > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels(hotel_id INT, hotel_name TEXT, category TEXT); INSERT INTO hotels(hotel_id, hotel_name, category) VALUES (1, 'Boutique Chateau', 'Boutique'); CREATE TABLE bookings(booking_id INT, hotel_id INT, booking_revenue DECIMAL, booking_date DATE); CREATE TABLE users(user_id INT, user_country TEXT);
Identify the number of bookings and their total revenue for hotels in the 'Boutique' category, for users from Canada, in 2022.
SELECT COUNT(b.booking_id) AS num_bookings, SUM(b.booking_revenue) AS total_revenue FROM hotels h INNER JOIN bookings b ON h.hotel_id = b.hotel_id INNER JOIN users u ON u.user_id = b.user_id WHERE h.category = 'Boutique' AND u.user_country = 'Canada' AND YEAR(b.booking_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, year INT, country VARCHAR(50), expenditure FLOAT); INSERT INTO Visitors (id, year, country, expenditure) VALUES (1, 2022, 'Canada', 1500), (2, 2022, 'Canada', 1600), (3, 2022, 'Canada', 1700); CREATE TABLE Countries (id INT, name VARCHAR(50)); INSERT INTO Countries (id, name) VALUES (1, 'Canada'), (2, 'USA');
What is the average expenditure of tourists from the USA visiting Canada in 2022?
SELECT AVG(Visitors.expenditure) FROM Visitors INNER JOIN Countries ON Visitors.country = Countries.name WHERE Visitors.year = 2022 AND Countries.name = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name TEXT, age INT, city TEXT, interest TEXT); INSERT INTO readers (id, name, age, city, interest) VALUES (1, 'John Doe', 35, 'New York', 'sports');
What is the average age of readers who prefer sports news in the city of New York or Chicago?
SELECT AVG(age) FROM readers WHERE city IN ('New York', 'Chicago') AND interest = 'sports';
gretelai_synthetic_text_to_sql
CREATE TABLE Instructor_Accommodations (instructor_id INT, accommodation_id INT, cost FLOAT);
Identify instructors who provide accommodations with a cost above the average.
SELECT i.name as instructor_name, AVG(ia.cost) as avg_cost FROM Instructors i JOIN Instructor_Accommodations ia ON i.id = ia.instructor_id GROUP BY i.name HAVING MAX(ia.cost) > (SELECT AVG(cost) FROM Instructor_Accommodations);
gretelai_synthetic_text_to_sql
CREATE TABLE CircularEconomy (Region VARCHAR(50), Initiative VARCHAR(50), ImplementationYear INT); INSERT INTO CircularEconomy (Region, Initiative, ImplementationYear) VALUES ('RegionA', 'Initiative1', 2018), ('RegionB', 'Initiative2', 2019), ('RegionA', 'Initiative3', 2020);
How many circular economy initiatives were implemented in each region between 2018 and 2020?
SELECT Region, COUNT(*) FROM CircularEconomy WHERE ImplementationYear BETWEEN 2018 AND 2020 GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (program_id INT, program_category VARCHAR(50)); INSERT INTO Programs (program_id, program_category) VALUES (1, 'Theater'), (2, 'Dance'), (3, 'Visual Arts'); CREATE TABLE Funding (funding_id INT, program_id INT, funding_amount INT); INSERT INTO Funding (funding_id, program_id, funding_amount) VALUES (1, 1, 10000), (2, 1, 15000), (3, 2, 20000), (4, 3, 25000);
What is the total amount of funding received by programs in the 'Theater' category?
SELECT p.program_category, SUM(f.funding_amount) AS total_funding FROM Programs p JOIN Funding f ON p.program_id = f.program_id WHERE p.program_category = 'Theater' GROUP BY p.program_category;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT);CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, tour_date DATE, engaged BOOLEAN); INSERT INTO hotels VALUES (5, 'Hotel F', 'Australia'); INSERT INTO virtual_tours VALUES (3, 5, '2022-03-17', true);
What is the total number of virtual tours engaged in the last month, grouped by hotel for hotels in Australia that have adopted AI chatbots?
SELECT hotels.hotel_name, COUNT(*) FROM hotels INNER JOIN virtual_tours ON hotels.hotel_id = virtual_tours.hotel_id WHERE hotels.country = 'Australia' AND virtual_tours.engaged = true AND virtual_tours.tour_date >= DATEADD(month, -1, GETDATE()) GROUP BY hotels.hotel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, population INT); CREATE TABLE medals (id INT, country INT, medal TEXT);
Display the number of medals won by each country, along with the total population.
SELECT c.name, COUNT(m.id), c.population FROM countries c LEFT JOIN medals m ON c.id = m.country GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE union_profiles (union_name VARCHAR(30), safety_rating INT, num_offices INT); INSERT INTO union_profiles (union_name, safety_rating, num_offices) VALUES ('UnionX', 90, 7), ('UnionY', 75, 3), ('UnionZ', 88, 5);
Calculate the average number of offices for unions with a safety rating above 85.
SELECT AVG(num_offices) FROM union_profiles WHERE safety_rating > 85;
gretelai_synthetic_text_to_sql
CREATE TABLE Ingredients (id INT, item_name VARCHAR(50), cost DECIMAL(5,2)); INSERT INTO Ingredients VALUES (1, 'Lettuce', 0.25), (2, 'Tomato', 0.30), (3, 'Cucumber', 0.20), (4, 'Avocado', 0.50), (5, 'Bread', 0.75);
What is the total cost of ingredients for the 'Veggie Delight' sandwich?
SELECT SUM(cost) FROM Ingredients WHERE item_name = 'Veggie Delight';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(50), program_category VARCHAR(50), funding_amount INT); INSERT INTO programs (program_id, program_name, program_category, funding_amount) VALUES (1, 'Theater Workshop', 'Arts Education', 10000), (2, 'Music Appreciation', 'Arts Education', 15000), (3, 'Dance Class', 'Performance', 8000), (4, 'Writing Workshop', 'Arts Education', 5000), (5, 'Film Class', 'Media Arts', 12000);
Find the number of programs in each program category with a funding_amount greater than $10,000.
SELECT program_category, COUNT(*) FROM programs WHERE funding_amount > 10000 GROUP BY program_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Hair_Care_Products (ProductID int, ProductName varchar(100), Country varchar(50), SustainabilityRating int); INSERT INTO Hair_Care_Products (ProductID, ProductName, Country, SustainabilityRating) VALUES (1, 'Eco-friendly Shampoo', 'France', 9); INSERT INTO Hair_Care_Products (ProductID, ProductName, Country, SustainabilityRating) VALUES (2, 'Natural Hair Conditioner', 'Germany', 8);
Which country has the most eco-friendly hair care products?
SELECT Country, COUNT(*) as NumberOfProducts, SUM(SustainabilityRating) as TotalSustainabilityRating FROM Hair_Care_Products GROUP BY Country HAVING COUNT(*) > 10 ORDER BY TotalSustainabilityRating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name TEXT, budget INT, category TEXT, completion_date DATE); INSERT INTO rural_infrastructure (id, project_name, budget, category, completion_date) VALUES (1, 'Road Construction', 50000, 'Roads', '2018-05-01'), (2, 'Clean Water Supply', 75000, 'Water', '2019-08-15'), (3, 'Electricity Grid Expansion', 80000, 'Energy', '2020-12-31');
What is the average budget for rural infrastructure projects, categorized by type, for each year since 2017?
SELECT category, YEAR(completion_date) AS completion_year, AVG(budget) FROM rural_infrastructure WHERE completion_date >= '2017-01-01' GROUP BY category, YEAR(completion_date);
gretelai_synthetic_text_to_sql
CREATE TABLE polar_bear_sightings (year INT, num_sighted INT);
How many polar bears were sighted each year?
SELECT year, COUNT(*) FROM polar_bear_sightings GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide (region VARCHAR(255), issues INT);
Which regions have no digital divide issues, based on the digital_divide table?
SELECT region FROM digital_divide WHERE issues = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Exhibitions (artist_id INT, museum VARCHAR(30)); INSERT INTO Artists (id, name) VALUES (1, 'Artist A'), (2, 'Artist B'), (3, 'Artist C'); INSERT INTO Exhibitions (artist_id, museum) VALUES (1, 'Guggenheim Museum'), (1, 'Metropolitan Museum of Art'), (2, 'Guggenheim Museum'), (3, 'Metropolitan Museum of Art');
Which artists have exhibited in both the Guggenheim Museum and the Metropolitan Museum of Art?
SELECT a.name FROM Artists a INNER JOIN Exhibitions e1 ON a.id = e1.artist_id INNER JOIN Exhibitions e2 ON a.id = e2.artist_id WHERE e1.museum = 'Guggenheim Museum' AND e2.museum = 'Metropolitan Museum of Art';
gretelai_synthetic_text_to_sql
CREATE TABLE TrainTrips (TripID INT, TripDate DATE);
How many train trips have been taken in the last month?
SELECT COUNT(TripID) FROM TrainTrips WHERE TripDate >= DATEADD(MONTH, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Ridership (RouteID int, AnnualPassengers int); INSERT INTO Ridership (RouteID, AnnualPassengers) VALUES (1, 120000), (2, 80000), (3, 150000); CREATE TABLE RouteFares (RouteID int, AvgFare decimal(5,2)); INSERT INTO RouteFares (RouteID, AvgFare) VALUES (1, 4.00), (2, 3.25), (3, 2.75);
What is the average fare for routes that have more than 100,000 annual passengers?
SELECT AVG(AvgFare) FROM RouteFares INNER JOIN Ridership ON RouteFares.RouteID = Ridership.RouteID GROUP BY RouteFares.RouteID HAVING SUM(Ridership.AnnualPassengers) > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_development (sensor_id INT, gene_id INT, development_stage VARCHAR(255)); INSERT INTO biosensor_development (sensor_id, gene_id, development_stage) VALUES (1, 1, 'Research'), (2, 2, 'Development'), (3, 3, 'Testing'); CREATE TABLE gene_expression (gene_id INT, expression FLOAT); INSERT INTO gene_expression (gene_id, expression) VALUES (1, 3.5), (2, 2.8), (3, 4.2);
What are the biosensor development stages for sensors using genes with an expression level above 4.0?
SELECT sensor_id, development_stage FROM biosensor_development WHERE gene_id IN (SELECT gene_id FROM gene_expression WHERE expression > 4.0);
gretelai_synthetic_text_to_sql
CREATE TABLE user (user_id INT, username VARCHAR(20), posts INT, country VARCHAR(20)); INSERT INTO user (user_id, username, posts, country) VALUES (1, 'user1', 10, 'United States'), (2, 'user2', 20, 'Canada'), (3, 'user3', 30, 'United States'), (4, 'user4', 40, 'Mexico'), (5, 'user5', 50, 'Canada');
What is the total number of posts in the social_media database for users from the United States?
SELECT SUM(posts) FROM user WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE beijing_transit (trip_id INT, mode VARCHAR(20), start_time TIMESTAMP, end_time TIMESTAMP); CREATE TABLE shanghai_transit (journey_id INT, mode VARCHAR(20), start_time TIMESTAMP, end_time TIMESTAMP);
What is the average trip duration for public transportation in Beijing and Shanghai?
SELECT AVG(TIMESTAMPDIFF(MINUTE, start_time, end_time)) AS avg_duration FROM beijing_transit WHERE mode = 'Public Transport' UNION ALL SELECT AVG(TIMESTAMPDIFF(MINUTE, start_time, end_time)) AS avg_duration FROM shanghai_transit WHERE mode = 'Public Transport';
gretelai_synthetic_text_to_sql
CREATE TABLE Satisfaction(service VARCHAR(20), region VARCHAR(20), score INT); INSERT INTO Satisfaction VALUES ('ServiceA', 'RegionC', 85), ('ServiceA', 'RegionC', 87), ('ServiceA', 'RegionD', 83), ('ServiceB', 'RegionC', 88), ('ServiceB', 'RegionD', 86);
What is the average citizen satisfaction score for 'ServiceA' in 'RegionC'?
SELECT AVG(score) FROM Satisfaction WHERE service = 'ServiceA' AND region = 'RegionC';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, name VARCHAR(50), event_id INT, hours_worked INT); CREATE TABLE events (event_id INT, name VARCHAR(50), city VARCHAR(50), event_type VARCHAR(50)); INSERT INTO events (event_id, name, city, event_type) VALUES (1, 'Visual Arts Exhibition', 'New York', 'Visual Arts');
Insert a new record of a volunteer who worked at a visual arts exhibition in New York.
INSERT INTO volunteers (volunteer_id, name, event_id, hours_worked) VALUES (1, 'Karen Brown', 1, 8);
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), ethnicity VARCHAR(50), is_vaccinated BOOLEAN); INSERT INTO patients (id, name, age, gender, ethnicity, is_vaccinated) VALUES (1, 'John Doe', 45, 'Male', 'Asian', true), (2, 'Jane Smith', 35, 'Female', 'African American', false), (3, 'Alice Johnson', 50, 'Female', 'Hispanic', true), (4, 'Bob Lee', 60, 'Male', 'Asian', true);
What is the total number of patients by ethnicity and vaccination status?
SELECT ethnicity, is_vaccinated, COUNT(*) FROM patients GROUP BY ethnicity, is_vaccinated;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO rural_infrastructure (id, project_name, start_date, end_date) VALUES (1, 'Road', '2017-01-01', '2018-12-31'); INSERT INTO rural_infrastructure (id, project_name, start_date, end_date) VALUES (2, 'Bridge', '2018-01-01', '2019-12-31');
Which rural infrastructure projects were completed before 2019?
SELECT project_name FROM rural_infrastructure WHERE YEAR(end_date) < 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, age INT, donation_date DATE, amount DECIMAL(10,2)); INSERT INTO donors (id, age, donation_date, amount) VALUES (1, 30, '2022-01-05', 100); INSERT INTO donors (id, age, donation_date, amount) VALUES (2, 45, '2022-02-10', 200);
What was the average donation amount by age group of donors in 2022?
SELECT FLOOR(age/10)*10 as age_group, AVG(amount) as avg_donation FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives_tokyo (city varchar(255), initiative varchar(255)); INSERT INTO circular_economy_initiatives_tokyo (city, initiative) VALUES ('Tokyo', 'Food Waste Reduction Program'); INSERT INTO circular_economy_initiatives_tokyo (city, initiative) VALUES ('Tokyo', 'E-waste Recycling Program');
What are the circular economy initiatives in the city of Tokyo?
SELECT initiative FROM circular_economy_initiatives_tokyo WHERE city = 'Tokyo'
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (customer_id INT, customer_name VARCHAR(50), customer_type VARCHAR(50), country VARCHAR(50)); INSERT INTO Customers (customer_id, customer_name, customer_type, country) VALUES (1, 'John Doe', 'New', 'USA'), (2, 'Jane Smith', 'Returning', 'Canada'), (3, 'Jim Brown', 'New', 'USA'), (4, 'Jake White', 'Returning', 'Mexico');
Show the number of new and returning customers in H1 of 2023, grouped by country.
SELECT country, COUNT(CASE WHEN customer_type = 'New' THEN 1 END) AS new_customers, COUNT(CASE WHEN customer_type = 'Returning' THEN 1 END) AS returning_customers FROM Customers WHERE customer_date BETWEEN '2023-01-01' AND '2023-06-30' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS defense_security;CREATE TABLE IF NOT EXISTS defense_security.Military_Cyber_Commands (id INT PRIMARY KEY, command_name VARCHAR(255), type VARCHAR(255));INSERT INTO defense_security.Military_Cyber_Commands (id, command_name, type) VALUES (1, 'USCYBERCOM', 'Defensive Cyber Operations'), (2, 'JTF-CND', 'Offensive Cyber Operations'), (3, '10th Fleet', 'Network Warfare');
Show the name and type of military cyber commands in the 'Military_Cyber_Commands' table.
SELECT command_name, type FROM defense_security.Military_Cyber_Commands;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, cause VARCHAR(255), cost INT, date DATE); INSERT INTO incidents (id, cause, cost, date) VALUES (1, 'insider threat', 10000, '2022-01-01'); INSERT INTO incidents (id, cause, cost, date) VALUES (2, 'phishing', 5000, '2022-01-02');
Find the total cost of all security incidents caused by insider threats in the last 6 months
SELECT SUM(cost) FROM incidents WHERE cause = 'insider threat' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE libraries (name VARCHAR(255), state VARCHAR(255), population DECIMAL(10,2), libraries DECIMAL(5,2)); INSERT INTO libraries (name, state, population, libraries) VALUES ('Library1', 'California', 39512223, 3154), ('Library2', 'Texas', 29528404, 2212), ('Library3', 'Florida', 21644287, 1835);
Show the top 3 states with the most public libraries per capita.
SELECT state, (libraries / population) AS libraries_per_capita FROM libraries ORDER BY libraries_per_capita DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, location VARCHAR(50)); CREATE TABLE posts (id INT, user_id INT, created_at DATETIME);
What is the total number of posts made by users located in Australia, in the last month?
SELECT COUNT(posts.id) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.location = 'Australia' AND posts.created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE WindFarms (FarmID INT, FarmName VARCHAR(255), Capacity DECIMAL(5,2), Country VARCHAR(255)); INSERT INTO WindFarms (FarmID, FarmName, Capacity, Country) VALUES (1, 'WindFarm1', 150, 'USA'), (2, 'WindFarm2', 200, 'Canada'), (3, 'WindFarm3', 120, 'Mexico');
List the total installed capacity of wind farms in the WindEnergy schema for each country?
SELECT Country, SUM(Capacity) as TotalCapacity FROM WindFarms GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_temperatures (location VARCHAR(50), year INTEGER, temperature FLOAT); INSERT INTO arctic_temperatures (location, year, temperature) VALUES ('Arctic', 2016, -23.4), ('Arctic', 2017, -23.2), ('Arctic', 2018, -23.0), ('Arctic', 2019, -22.8), ('Arctic', 2020, -22.6), ('Arctic', 2021, -22.4);
What is the average annual temperature change in the last 5 years for the Arctic region?
SELECT AVG(temperature - LAG(temperature) OVER (ORDER BY year)) AS avg_annual_temp_change FROM arctic_temperatures WHERE location = 'Arctic' AND year BETWEEN 2016 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (id INT, name VARCHAR(50), inspection_date DATE); INSERT INTO Bridges (id, name, inspection_date) VALUES (1, 'Golden Gate', '2020-05-01'), (2, 'Brooklyn', '2019-12-20'), (3, 'Tower', '2021-03-05');
What was the earliest inspection date across all bridges?
SELECT MIN(inspection_date) FROM Bridges;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_size INTEGER, region VARCHAR(255));
What is the total area covered by marine protected areas in the 'indian_ocean'?
SELECT SUM(area_size) FROM marine_protected_areas WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement_heritage (id INT, name VARCHAR(255), description TEXT); INSERT INTO community_engagement_heritage (id, name, description) VALUES (1, 'Heritage Education Program', 'A community engagement initiative aimed at educating the public about local heritage sites'), (2, 'Historical Site Clean-up', 'A community event organized to clean and maintain local historical sites');
What are the details of community engagement initiatives in the 'community_engagement' schema focused on heritage sites?
SELECT * FROM community_engagement.community_engagement_heritage;
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (id INT, name TEXT, principal_investigator TEXT, country TEXT); INSERT INTO research_projects (id, name, principal_investigator, country) VALUES (1, 'Project X', 'Dr. Smith', 'USA'); INSERT INTO research_projects (id, name, principal_investigator, country) VALUES (2, 'Project Y', 'Dr. Johnson', 'Canada');
Provide the number of genetic research projects for each principal investigator, grouped by the country they are located in.
SELECT country, principal_investigator, COUNT(name) FROM research_projects GROUP BY country, principal_investigator;
gretelai_synthetic_text_to_sql
CREATE TABLE operatives (region TEXT, operative_count INT); INSERT INTO operatives (region, operative_count) VALUES ('Europe', 500); INSERT INTO operatives (region, operative_count) VALUES ('Africa', 300);
What is the average number of intelligence operatives in the 'Europe' region?
SELECT AVG(operative_count) FROM operatives WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, city VARCHAR(20), operator VARCHAR(20), num_chargers INT, open_date DATE);
Delete all records from the 'charging_stations' table where the 'city' is 'Chicago'
DELETE FROM charging_stations WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, category VARCHAR(50));
How many unique ingredients are used in each product category?
SELECT category, COUNT(DISTINCT ingredient_id) FROM Products p JOIN Product_Ingredients pi ON p.product_id = pi.product_id GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_rights_advocacy (la_id SERIAL PRIMARY KEY, union_id VARCHAR(5), issue TEXT, action TEXT, date DATE);
Insert records for the labor_rights_advocacy table for the union_id 003 with the following details: issue = 'Health and Safety', action = 'Protest', date = '2022-02-15'
INSERT INTO labor_rights_advocacy (union_id, issue, action, date) VALUES ('003', 'Health and Safety', 'Protest', '2022-02-15');
gretelai_synthetic_text_to_sql
CREATE TABLE extractions (id INT, month INT, extraction_amount INT); INSERT INTO extractions (id, month, extraction_amount) VALUES (1, 1, 1000), (2, 2, 1200), (3, 3, 1400), (4, 4, 1600), (5, 5, 1800), (6, 6, 2000), (7, 7, 2200), (8, 8, 2400), (9, 9, 2600), (10, 10, 2800), (11, 11, 3000), (12, 12, 3200);
What is the total amount of mineral extractions per month, in the last 12 months?
SELECT month, SUM(extraction_amount) AS total_extraction FROM extractions WHERE month BETWEEN 1 AND 12 GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, model VARCHAR(255), manufacturer VARCHAR(255), production_year INT);
Create a table for storing aircraft manufacturing data
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, model VARCHAR(255), manufacturer VARCHAR(255), production_year INT);
gretelai_synthetic_text_to_sql
CREATE TABLE well_information (well_id INT, country VARCHAR(50));
Insert new records into the 'well_information' table for wells 101 and 102 with the country 'Canada' and 'USA' respectively
INSERT INTO well_information (well_id, country) VALUES (101, 'Canada'), (102, 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE employee_gender (employee_id INT, gender VARCHAR(10)); INSERT INTO employee_gender (employee_id, gender) VALUES (1, 'Male'), (2, 'Female'), (3, 'Non-binary'), (4, 'Male'), (5, 'Female'), (6, 'Non-binary'); CREATE TABLE employee_hours_2 (employee_id INT, hours_worked INT, work_date DATE); INSERT INTO employee_hours_2 (employee_id, hours_worked, work_date) VALUES (1, 8, '2022-02-15'), (2, 7, '2022-02-20'), (3, 9, '2022-03-01'), (4, 6, '2022-02-14'), (5, 10, '2022-03-15'), (6, 8, '2022-03-20');
Display the number of employees and total hours worked by gender for the current month.
SELECT e.gender, COUNT(eh.employee_id) AS employees, SUM(eh.hours_worked) AS total_hours_worked FROM employee_gender e JOIN employee_hours_2 eh ON e.employee_id = eh.employee_id WHERE MONTH(work_date) = MONTH(CURRENT_DATE) GROUP BY e.gender
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT PRIMARY KEY, name VARCHAR(100), birth_date DATE, death_date DATE, country VARCHAR(50), medium VARCHAR(100));
Insert a new record into the "artists" table for artist "Frida Kahlo" with the medium "Oil painting"
INSERT INTO artists (artist_id, name, birth_date, death_date, country, medium) VALUES ((SELECT MAX(artist_id) FROM artists) + 1, 'Frida Kahlo', '1907-07-06', '1954-07-13', 'Mexico', 'Oil painting');
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(50), firm VARCHAR(50)); INSERT INTO attorneys (attorney_id, attorney_name, firm) VALUES (1, 'James Davis', 'Davis'), (2, 'Jennifer Thompson', 'Thompson'), (3, 'James Davis', 'Davis'); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 1), (3, 2);
How many cases were handled by attorneys in the 'Davis' firm?
SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.firm = 'Davis';
gretelai_synthetic_text_to_sql
CREATE TABLE PreservationProjects (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, donation_amount FLOAT);
What is the total donation amount for each preservation project?
SELECT name, SUM(donation_amount) FROM PreservationProjects GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (id INT, name VARCHAR(30), location VARCHAR(20), flu_vaccine INT); CREATE VIEW urban_areas AS SELECT area_id FROM areas WHERE population_density > 2000;
What is the number of healthcare providers who have not administered the flu vaccine in urban areas?
SELECT COUNT(*) FROM healthcare_providers JOIN urban_areas ON healthcare_providers.location = urban_areas.area_id WHERE flu_vaccine = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE ForeignMilitaryAid (Year INT, Country VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO ForeignMilitaryAid (Year, Country, Amount) VALUES (2005, 'Afghanistan', 5000000), (2006, 'Iraq', 7000000);
Update the Amount for Iraq in the 'ForeignMilitaryAid' table to 8000000 for the year 2006.
UPDATE ForeignMilitaryAid SET Amount = 8000000 WHERE Year = 2006 AND Country = 'Iraq';
gretelai_synthetic_text_to_sql
CREATE TABLE aquaculture_sites_count (site_id INT, country VARCHAR(50), total_sites INT); INSERT INTO aquaculture_sites_count VALUES (1, 'China', 200), (2, 'Indonesia', 150), (3, 'India', 120), (4, 'Vietnam', 100), (5, 'Norway', 80);
What is the total number of aquaculture sites per country, ranked in descending order?
SELECT country, SUM(total_sites) AS total_sites_sum, RANK() OVER (ORDER BY SUM(total_sites) DESC) AS total_sites_rank FROM aquaculture_sites_count GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerPreferences (PlayerID INT, Preference VARCHAR(50)); INSERT INTO PlayerPreferences (PlayerID, Preference) VALUES (1, 'VR'), (2, 'Non-VR'), (3, 'VR'), (4, 'VR'), (5, 'Non-VR'); CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Li Kim', 'China'), (4, 'Park Chan', 'Korea'), (5, 'Ravi Verma', 'India');
What is the total number of players who prefer using VR technology for gaming, and how many of them are from Asia?
(SELECT COUNT(*) FROM PlayerPreferences WHERE Preference = 'VR' INTERSECT SELECT COUNT(*) FROM Players JOIN PlayerPreferences ON Players.PlayerID = PlayerPreferences.PlayerID WHERE Players.Country = 'Asia')
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, state VARCHAR(20), investment_amount FLOAT); INSERT INTO network_investments (investment_id, state, investment_amount) VALUES (1, 'NY', 500000), (2, 'CA', 700000), (3, 'TX', 600000);
What is the total investment in network infrastructure for each state?
SELECT state, SUM(investment_amount) FROM network_investments GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_taxis (taxi_id INT, trip_distance INT, trip_date DATE); INSERT INTO electric_taxis (taxi_id, trip_distance, trip_date) VALUES (1, 15, '2022-01-01'), (2, 20, '2022-01-02'); CREATE TABLE city_coordinates (city VARCHAR(50), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO city_coordinates (city, latitude, longitude) VALUES ('Berlin', 52.5200, 13.4050);
What is the total distance traveled by electric taxis in Berlin?
SELECT SUM(trip_distance) FROM electric_taxis, city_coordinates WHERE city_coordinates.city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives_ny (city varchar(255), initiative varchar(255)); INSERT INTO circular_economy_initiatives_ny (city, initiative) VALUES ('New York', 'Composting Program'); INSERT INTO circular_economy_initiatives_ny (city, initiative) VALUES ('New York', 'Recycling Education Campaign');
What are the circular economy initiatives in the city of New York?
SELECT initiative FROM circular_economy_initiatives_ny WHERE city = 'New York'
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (weather_id INT, temperature FLOAT, humidity FLOAT, timestamp TIMESTAMP);
Delete records in the 'weather_data' table where the 'temperature' is greater than 35
DELETE FROM weather_data WHERE temperature > 35;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists fundraising_us;CREATE TABLE if not exists fundraising_us.startups (id INT, name VARCHAR(100), quarter INT, year INT, funds DECIMAL(10,2));INSERT INTO fundraising_us.startups (id, name, quarter, year, funds) VALUES (1, 'StartupA', 1, 2022, 1500000.00), (2, 'StartupB', 2, 2022, 2000000.00), (3, 'StartupC', 1, 2022, 1000000.00), (4, 'StartupD', 2, 2022, 2500000.00);
What is the total funding raised by biotech startups in the United States, categorized by the quarter and year?
SELECT year, quarter, SUM(funds) FROM fundraising_us.startups GROUP BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID int, DonorID int, Amount decimal(10,2), DonationDate date, Country varchar(50)); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate, Country) VALUES (1, 1, 100.00, '2022-07-01', 'United States'), (2, 2, 200.00, '2022-08-15', 'Canada'), (3, 1, 50.00, '2022-09-30', 'United States');
What is the average donation amount per month for donations made in the United States?
SELECT AVG(Amount) as AverageDonation, DATE_FORMAT(DonationDate, '%Y-%m') as Month FROM Donations WHERE Country = 'United States' GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, category VARCHAR(20)); INSERT INTO project (id, name, location, start_date, end_date, category) VALUES (5, 'Seismic Retrofit', 'City A', '2020-01-01', '2020-12-31', 'Seismic'); CREATE TABLE material (id INT, name VARCHAR(50), project_id INT, standard_id INT, cost DECIMAL(10,2)); INSERT INTO material (id, name, project_id, standard_id, cost) VALUES (3, 'Steel', 1, 1, 10000.00), (4, 'Concrete', 1, 2, 20000.00), (5, 'Steel', 5, 1, 15000.00);
What is the total cost of all materials used in projects in 'City A'?
SELECT SUM(m.cost) FROM material m WHERE m.project_id IN (SELECT p.id FROM project p WHERE p.location = 'City A');
gretelai_synthetic_text_to_sql
CREATE TABLE EconomicDiversification (id INT, name VARCHAR(50), region VARCHAR(20), initiative_type VARCHAR(30), budget FLOAT, start_date DATE, end_date DATE);
Insert new records into the 'EconomicDiversification' table, representing initiatives in the 'Oceania' region
INSERT INTO EconomicDiversification (id, name, region, initiative_type, budget, start_date, end_date) VALUES (1, 'Sustainable Fishing', 'Oceania', 'Fisheries', 80000, '2023-01-01', '2025-12-31'), (2, 'Eco-Tourism', 'Oceania', 'Tourism', 100000, '2024-04-01', '2026-03-31'), (3, 'Renewable Energy', 'Oceania', 'Energy', 120000, '2023-07-01', '2027-06-30');
gretelai_synthetic_text_to_sql
CREATE TABLE daily_conservation (day DATE, score INT); INSERT INTO daily_conservation (day, score) VALUES ('2022-01-01', 80), ('2022-01-02', 85), ('2022-01-03', 90), ('2022-02-01', 75), ('2022-02-02', 80), ('2022-02-03', 85);
What is the average water conservation score for each month?
SELECT DATE_FORMAT(day, '%Y-%m') as month, AVG(score) FROM daily_conservation GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Races (RaceID INT, TrackName VARCHAR(50), AverageSpeed DECIMAL(5,2)); INSERT INTO Races (RaceID, TrackName, AverageSpeed) VALUES (1, 'Monza', 242.60), (2, 'Spa-Francorchamps', 212.44);
Which F1 tracks have an average speed above 220 mph?
SELECT TrackName FROM Races WHERE AverageSpeed > 220.00
gretelai_synthetic_text_to_sql
CREATE TABLE marine_pollution (id INT, type TEXT, location TEXT, year INT); INSERT INTO marine_pollution (id, type, location, year) VALUES (1, 'Oil spill', 'Southern Ocean', 2018), (2, 'Plastic waste', 'Pacific Ocean', 2020), (3, 'Chemical spill', 'Atlantic Ocean', 2019);
What is the total number of marine pollution incidents in the Southern Ocean?
SELECT COUNT(*) FROM marine_pollution WHERE location = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE donors(id INT, name TEXT, art_donated INT); INSERT INTO donors VALUES (1, 'John Doe', 3), (2, 'Jane Smith', 2), (3, 'ABC Org', 5);
What's the total number of traditional art pieces donated by individuals and organizations?
SELECT SUM(art_donated) FROM donors;
gretelai_synthetic_text_to_sql
CREATE TABLE impact (impact_id INT, hotel_name VARCHAR(255), region VARCHAR(255), impact INT); INSERT INTO impact (impact_id, hotel_name, region, impact) VALUES (1, 'The Grand Hotel', 'America', 1000000);
Identify the hotels in the American region with the highest local economic impact.
SELECT hotel_name, impact FROM impact WHERE region = 'America' ORDER BY impact DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE country_production (country VARCHAR(50), element VARCHAR(10), year INT, quantity INT); INSERT INTO country_production (country, element, year, quantity) VALUES ('Australia', 'Dy', 2016, 750), ('China', 'Tm', 2016, 500), ('United States', 'Y', 2016, 900), ('Canada', 'Gd', 2016, 850), ('Norway', 'Nd', 2016, 1100), ('Brazil', 'Pr', 2016, 700);
What is the total production quantity for each country in 2016?
SELECT cp.country, cp.element, SUM(cp.quantity) as total_quantity FROM country_production cp WHERE cp.year = 2016 GROUP BY cp.country, cp.element;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (id INT, service VARCHAR(10), year INT, country VARCHAR(50)); INSERT INTO missions (id, service, year, country) VALUES (1, 'Navy', 2018, 'Mexico'); INSERT INTO missions (id, service, year, country) VALUES (2, 'Air Force', 2018, 'Haiti');
What is the total number of humanitarian assistance missions conducted by the Navy and Air Force?
SELECT SUM(missions.id) FROM missions WHERE missions.service IN ('Navy', 'Air Force') AND missions.year = 2018 AND missions.country LIKE '%assistance%';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, species VARCHAR(255), population INT); INSERT INTO animal_population (id, species, population) VALUES (1, 'Tiger', 500), (2, 'Elephant', 2000), (3, 'Lion', 800);
Insert a new record into the 'animal_population' table with id 4, species 'Giraffe', and population 1500.
INSERT INTO animal_population (id, species, population) VALUES (4, 'Giraffe', 1500);
gretelai_synthetic_text_to_sql
CREATE TABLE authors (author_id INT, first_name VARCHAR(255), last_name VARCHAR(255), email VARCHAR(255), total_pageviews INT);
Insert a new view "top_authors_this_month" that shows the top authors by pageviews this month in the "authors" table
CREATE VIEW top_authors_this_month AS SELECT author_id, first_name, last_name, email, SUM(pageviews) AS total_pageviews FROM authors JOIN articles ON authors.author_id = articles.author_id WHERE publication_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY author_id ORDER BY total_pageviews DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Pollution (id INT PRIMARY KEY, location VARCHAR(255), pollutant VARCHAR(255), concentration FLOAT);
What is the total amount of pollution for each pollutant, and the average concentration for each pollutant?
SELECT p.pollutant, COUNT(*) as total_pollution, AVG(concentration) as avg_concentration FROM Pollution p GROUP BY p.pollutant;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(50), launch_date DATE, return_date DATE, mission_company VARCHAR(50));
What is the maximum duration of a space mission for AstroTech Corp?
SELECT 100.0 * DATEDIFF('9999-12-31', MAX(launch_date)) / DATEDIFF('9999-12-31', '1970-01-01') AS mission_duration FROM space_missions WHERE mission_company = 'AstroTech Corp';
gretelai_synthetic_text_to_sql
CREATE TABLE vaccine_records (patient_id INT, vaccine_name VARCHAR(20), age INT, state VARCHAR(20)); INSERT INTO vaccine_records VALUES (1, 'Pfizer', 35, 'Texas'), (2, 'Pfizer', 42, 'Texas'), (3, 'Moderna', 50, 'California');
What is the average age of patients who received the Pfizer vaccine in Texas?
SELECT AVG(age) FROM vaccine_records WHERE vaccine_name = 'Pfizer' AND state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (Platform VARCHAR(20), Genre VARCHAR(10), Revenue INT); INSERT INTO Revenue (Platform, Genre, Revenue) VALUES ('Spotify', 'Pop', 3500000), ('Spotify', 'Rock', 2800000), ('Deezer', 'Pop', 1600000), ('Deezer', 'Rock', 1100000), ('AppleMusic', 'Pop', 2900000), ('AppleMusic', 'Rock', 2400000);
What is the total revenue for the pop genre on Spotify and Deezer in 2020?
SELECT Platform, SUM(Revenue) as TotalRevenue FROM Revenue WHERE Genre = 'Pop' AND (Platform = 'Spotify' OR Platform = 'Deezer') AND YEAR(EventDate) = 2020 GROUP BY Platform;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy ( id INT PRIMARY KEY, location VARCHAR(255), project_name VARCHAR(255), installed_capacity INT ); INSERT INTO renewable_energy (id, location, project_name, installed_capacity) VALUES (1, 'Germany', 'Solarpark Finow Tower', 45000); INSERT INTO renewable_energy (id, location, project_name, installed_capacity) VALUES (2, 'France', 'La Plaine Wind Farm', 60000);
Show the total installed capacity of renewable energy projects for each location
SELECT location, SUM(installed_capacity) FROM renewable_energy GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE communication_initiatives (id INT, region VARCHAR(255), year INT, type VARCHAR(255), cost FLOAT); INSERT INTO communication_initiatives (id, region, year, type, cost) VALUES (1, 'Oceania', 2010, 'climate change communication', 150000);
What is the average number of climate change communication initiatives per year in Oceania from 2010 to 2020?
SELECT AVG(cost) FROM communication_initiatives WHERE region = 'Oceania' AND type = 'climate change communication' AND year BETWEEN 2010 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_streams (week INT, streams_in_week INT); INSERT INTO justice_streams (week, streams_in_week) VALUES (1, 200000), (2, 180000), (3, 170000);
How many streams did the 2021 album release 'Justice' by Justin Bieber receive in its first week?
SELECT streams_in_week FROM justice_streams WHERE week = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, price FLOAT, community VARCHAR(255)); CREATE TABLE inclusive_communities (community VARCHAR(255), has_inclusive_policy BOOLEAN); INSERT INTO properties (property_id, price, community) VALUES (1, 500000, 'CommunityA'), (2, 600000, 'CommunityB'); INSERT INTO inclusive_communities (community, has_inclusive_policy) VALUES ('CommunityA', true), ('CommunityB', false);
What is the total property value in communities with inclusive housing policies?
SELECT SUM(properties.price) FROM properties INNER JOIN inclusive_communities ON properties.community = inclusive_communities.community WHERE inclusive_communities.has_inclusive_policy = true;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_preparedness (disaster_type VARCHAR(255), preparedness_level VARCHAR(255)); INSERT INTO disaster_preparedness (disaster_type, preparedness_level) VALUES ('Tornado', 'High'), ('Flood', 'Medium'), ('Hurricane', 'Low'), ('Earthquake', 'High');
Delete all records from the disaster_preparedness table for the 'Hurricane' disaster type
DELETE FROM disaster_preparedness WHERE disaster_type = 'Hurricane';
gretelai_synthetic_text_to_sql
CREATE TABLE pacific_floor (location TEXT, depth INT); INSERT INTO pacific_floor (location, depth) VALUES ('North Pacific - A', 3500), ('North Pacific - B', 2000), ('North Pacific - C', 4500), ('South Pacific - A', 5000), ('South Pacific - B', 3000), ('South Pacific - C', 4000);
What is the average depth of the ocean floor in the North Pacific and South Pacific Oceans?
SELECT AVG(depth) FROM pacific_floor;
gretelai_synthetic_text_to_sql
CREATE TABLE ports(port_id INT, port_name TEXT);CREATE TABLE cargo(cargo_id INT, port_id INT, line_id INT);CREATE TABLE shipping_lines(line_id INT, line_name TEXT);INSERT INTO ports VALUES (1,'Port A'),(2,'Port B'),(3,'Port C');INSERT INTO cargo VALUES (1,1,1),(2,1,2),(3,2,1),(4,2,3),(5,3,4),(6,1,5);INSERT INTO shipping_lines VALUES (1,'Line A'),(2,'Line B'),(3,'Line C'),(4,'Line D'),(5,'Line E');
List the names and number of unique shipping lines serving each port, including ports with no shipping lines.
SELECT p.port_name, COUNT(DISTINCT c.line_id) as num_shipping_lines FROM ports p LEFT JOIN cargo c ON p.port_id = c.port_id GROUP BY p.port_id;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, location VARCHAR(20), depth FLOAT); INSERT INTO wells (id, location, depth) VALUES (1, 'Saudi Arabia', 4500.3); INSERT INTO wells (id, location, depth) VALUES (2, 'Iran', 5000.5);
Delete well records from Saudi Arabia.
DELETE FROM wells WHERE location = 'Saudi Arabia';
gretelai_synthetic_text_to_sql
CREATE TABLE project_timelines (project_id INT, project_type VARCHAR(20), city VARCHAR(20), start_date DATE); INSERT INTO project_timelines (project_id, project_type, city, start_date) VALUES (10, 'Residential', 'Denver', '2021-02-01'), (11, 'Commercial', 'Denver', '2020-06-15'), (12, 'Residential', 'Boulder', '2019-12-01');
What is the earliest start date for residential construction projects in Denver, Colorado?
SELECT MIN(start_date) FROM project_timelines WHERE project_type = 'Residential' AND city = 'Denver';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50), category VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO programs (id, name, category, budget) VALUES (1, 'Primary Education', 'Education', 25000.00); INSERT INTO programs (id, name, category, budget) VALUES (2, 'Secondary Education', 'Education', 30000.00); INSERT INTO programs (id, name, category, budget) VALUES (3, 'Healthcare', 'Health', 75000.00);
Get the total budget for programs in the 'Education' category
SELECT category, SUM(budget) as total_budget FROM programs WHERE category = 'Education' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_bikes (city VARCHAR(20), num_ebikes INT); INSERT INTO shared_bikes (city, num_ebikes) VALUES ('New York', 1200), ('London', 800);
What is the total number of shared electric bikes in New York and London?
SELECT SUM(num_ebikes) FROM shared_bikes WHERE city IN ('New York', 'London');
gretelai_synthetic_text_to_sql
CREATE TABLE Recyclable (RID INT, Industry VARCHAR(20), RecyclablePercentage FLOAT, Country VARCHAR(20)); INSERT INTO Recyclable VALUES (1, 'Electronics', 70, 'Australia'); INSERT INTO Recyclable VALUES (2, 'Electronics', 80, 'Australia');
What is the percentage of products that are recyclable in the electronics industry in Australia?
SELECT (SUM(RecyclablePercentage) / (COUNT(*) * 100)) FROM Recyclable WHERE Industry = 'Electronics' AND Country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT PRIMARY KEY, country VARCHAR(100), framework VARCHAR(100));
Update the 'regulatory_frameworks' table to set the 'framework' to 'Blockchain Regulation' for all records where the country is 'India'
UPDATE regulatory_frameworks SET framework = 'Blockchain Regulation' WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (id INT, delivery_time INT, destination VARCHAR(20)); INSERT INTO Shipments (id, delivery_time, destination) VALUES (1, 5, 'India'), (2, 7, 'USA'), (3, 3, 'India');
What is the minimum delivery time for shipments to India?
SELECT MIN(delivery_time) FROM Shipments WHERE destination = 'India'
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, diagnosis VARCHAR(255), location VARCHAR(255)); INSERT INTO patients (patient_id, age, diagnosis, location) VALUES (10, 45, 'diabetes', 'rural India'); INSERT INTO patients (patient_id, age, diagnosis, location) VALUES (11, 60, 'hypertension', 'rural India'); CREATE TABLE general_practitioners (gp_id INT, specialty VARCHAR(255), location VARCHAR(255)); INSERT INTO general_practitioners (gp_id, specialty, location) VALUES (100, 'general practitioner', 'rural India'); INSERT INTO general_practitioners (gp_id, specialty, location) VALUES (101, 'general practitioner', 'rural India');
What is the most common type of chronic disease among rural patients in India, and how many general practitioners are available per patient diagnosed with that disease?
SELECT diagnosis AS common_disease, COUNT(*) AS patients_count, COUNT(general_practitioners.gp_id) / COUNT(*) AS gps_per_patient FROM patients INNER JOIN general_practitioners ON patients.location = general_practitioners.location WHERE patients.location LIKE 'rural% India' GROUP BY patients.location ORDER BY patients_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE disasters (disaster_id INT, country VARCHAR(50), num_people_displaced INT); INSERT INTO disasters (disaster_id, country, num_people_displaced) VALUES (1, 'Country A', 5000), (2, 'Country B', 8000), (3, 'Country C', 12000), (4, 'Country A', 7000), (5, 'Country C', 9000); CREATE TABLE countries (country_id INT, name VARCHAR(50)); INSERT INTO countries (country_id, name) VALUES (1, 'Country A'), (2, 'Country B'), (3, 'Country C');
What is the average number of people displaced per disaster event for each country?
SELECT c.name, AVG(d.num_people_displaced) AS avg_displaced FROM disasters d JOIN countries c ON d.country = c.name GROUP BY c.name
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (business_id INT, district TEXT, owner_gender TEXT); INSERT INTO businesses (business_id, district, owner_gender) VALUES (1, 'Kisumu', 'Female'), (2, 'Nakuru', 'Male'), (3, 'Kericho', 'Female'), (4, 'Eldoret', 'Male');
What is the number of women-owned businesses in the rural districts of Kenya, and what percentage do they represent compared to the total number of businesses?
SELECT COUNT(CASE WHEN owner_gender = 'Female' THEN 1 END) as num_women_owned, (COUNT(CASE WHEN owner_gender = 'Female' THEN 1 END) / COUNT(business_id)) * 100 as percentage FROM businesses WHERE district IN ('Kisumu', 'Nakuru', 'Kericho', 'Eldoret');
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(50), years_of_experience INT, specialty VARCHAR(50)); INSERT INTO attorneys (id, name, years_of_experience, specialty) VALUES (1, 'John Doe', 12, 'Criminal Law'); INSERT INTO attorneys (id, name, years_of_experience, specialty) VALUES (2, 'Jane Smith', 3, 'Immigration Law'); CREATE TABLE cases (id INT, attorney_id INT, billing_amount DECIMAL(10,2), case_database VARCHAR(50)); INSERT INTO cases (id, attorney_id, billing_amount, case_database) VALUES (1, 1, 2500.00, 'Internal'); INSERT INTO cases (id, attorney_id, billing_amount, case_database) VALUES (2, 2, 1800.00, 'Legal Precedents');
What is the total billing amount for cases in the legal precedents database that were handled by attorneys with less than 5 years of experience and involved immigration law?
SELECT SUM(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.years_of_experience < 5 AND cases.case_database = 'Legal Precedents' AND attorneys.specialty = 'Immigration Law';
gretelai_synthetic_text_to_sql