context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE virtual_tours (tour_id INT, name TEXT, city TEXT, carbon_footprint FLOAT); INSERT INTO virtual_tours (tour_id, name, city, carbon_footprint) VALUES (1, 'Tour A', 'Paris', 5.6), (2, 'Tour B', 'Paris', 4.9), (3, 'Tour C', 'Paris', 6.3);
What is the average carbon footprint of virtual tours in Paris?
SELECT AVG(carbon_footprint) FROM virtual_tours WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(255)); INSERT INTO programs (program_id, program_name) VALUES (1, 'Artistic Expression'), (2, 'Dance'); CREATE TABLE attendee_demographics (attendee_id INT, program_id INT, state VARCHAR(2)); INSERT INTO attendee_demographics (attendee_id, program_id, state) V...
How many attendees were from California for the 'Dance' program?
SELECT COUNT(*) as num_ca_attendees FROM attendee_demographics WHERE state = 'CA' AND program_id = (SELECT program_id FROM programs WHERE program_name = 'Dance');
gretelai_synthetic_text_to_sql
CREATE TABLE artist_festivals (artist_id INT, festival_name VARCHAR(30), festival_country VARCHAR(20)); INSERT INTO artist_festivals (artist_id, festival_name, festival_country) VALUES (1, 'Coachella', 'USA'), (2, 'Osheaga', 'Canada'), (3, 'Bonnaroo', 'USA'), (4, 'WayHome', 'Canada');
Which artists have performed at music festivals in both the USA and Canada?
SELECT artist_id FROM artist_festivals WHERE festival_country IN ('USA', 'Canada') GROUP BY artist_id HAVING COUNT(DISTINCT festival_country) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT PRIMARY KEY, name TEXT, region TEXT); INSERT INTO states (id, name, region) VALUES (1, 'Alabama', 'South'); CREATE TABLE crops (id INT PRIMARY KEY, state_id INT, crop TEXT, yield REAL); INSERT INTO crops (id, state_id, crop, yield) VALUES (1, 1, 'rice', 2.5);
What is the average yield of 'rice' per state?
SELECT state_id, AVG(yield) FROM crops WHERE crop = 'rice' GROUP BY state_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, program_name VARCHAR(20), volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (id, program_name, volunteer_hours, volunteer_date) VALUES (1, 'program_x', 5, '2022-04-01'); INSERT INTO Volunteers (id, program_name, volunteer_hours, volunteer_date) VALUES (2, 'program_y', 3,...
How many volunteers engaged in 'program_x' in the 'q2' and 'q3' quarters?
SELECT COUNT(*) FROM Volunteers WHERE program_name = 'program_x' AND (QUARTER(volunteer_date) = 2 OR QUARTER(volunteer_date) = 3);
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthProviders (ProviderID INT, HealthEquityMetricScore INT); INSERT INTO MentalHealthProviders (ProviderID, HealthEquityMetricScore) VALUES (1, 80), (2, 85), (3, 70), (4, 90), (5, 95), (6, 88), (7, 89);
List the bottom 2 mental health providers with the lowest health equity metric scores, along with their corresponding scores.
SELECT ProviderID, HealthEquityMetricScore FROM (SELECT ProviderID, HealthEquityMetricScore, ROW_NUMBER() OVER (ORDER BY HealthEquityMetricScore ASC) as Rank FROM MentalHealthProviders) as RankedData WHERE Rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesign (GameID INT PRIMARY KEY, GameName VARCHAR(50), Genre VARCHAR(50), Platform VARCHAR(50)); INSERT INTO GameDesign (GameID, GameName, Genre, Platform) VALUES (1, 'Fortnite', 'Battle Royale', 'PC'), (2, 'Among Us', 'Party', 'Mobile'); CREATE VIEW TopGames AS SELECT * FROM GameDesign WHERE Platform =...
Select all data from 'TopGames'
SELECT * FROM TopGames;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation_by_material(year INT, material VARCHAR(255), amount INT); INSERT INTO waste_generation_by_material VALUES (2018, 'Paper', 400), (2018, 'Plastic', 200), (2018, 'Glass', 300), (2019, 'Paper', 420), (2019, 'Plastic', 210), (2019, 'Glass', 310), (2020, 'Paper', 450), (2020, 'Plastic', 230), (2...
What was the total waste generation by material type in 2018, 2019, and 2020?
SELECT material, year, SUM(amount) FROM waste_generation_by_material GROUP BY material, year;
gretelai_synthetic_text_to_sql
CREATE TABLE DrillingPlatforms (PlatformID int, PlatformName varchar(50), Location varchar(50), PlatformType varchar(50), NumberOfWells int); INSERT INTO DrillingPlatforms (PlatformID, PlatformName, Location, PlatformType, NumberOfWells) VALUES (1, 'A01', 'North Sea', 'Offshore', 10), (2, 'B02', 'Gulf of Mexico', 'Offs...
How many wells were drilled in the Gulf of Mexico in 2022?
SELECT COUNT(*) FROM DrillingLogs JOIN DrillingPlatforms ON DrillingLogs.PlatformID = DrillingPlatforms.PlatformID WHERE DrillingPlatforms.Location = 'Gulf of Mexico' AND YEAR(DrillingLogs.DrillingDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE paris_art(id INT, museum VARCHAR(20), art_type VARCHAR(20), count INT); INSERT INTO paris_art VALUES (1, 'Louvre', 'Painting', 500); INSERT INTO paris_art VALUES (2, 'Louvre', 'Sculpture', 300); CREATE TABLE berlin_art(id INT, museum VARCHAR(20), art_type VARCHAR(20), count INT); INSERT INTO berlin_art VAL...
What is the total number of paintings and sculptures in Paris and Berlin museums?
SELECT SUM(count) FROM (SELECT count FROM paris_art WHERE museum = 'Louvre' UNION ALL SELECT count FROM berlin_art WHERE museum = 'Pergamon') AS combined_museums;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (continent VARCHAR(255), consumption FLOAT, date DATE); INSERT INTO water_consumption (continent, consumption, date) VALUES ('South America', 120000, '2022-01-01'); INSERT INTO water_consumption (continent, consumption, date) VALUES ('Europe', 150000, '2022-01-01');
Identify the top 2 continents with the highest water consumption in the last 6 months.
SELECT continent, SUM(consumption) FROM (SELECT continent, consumption, ROW_NUMBER() OVER (PARTITION BY continent ORDER BY consumption DESC) as rank FROM water_consumption WHERE date >= '2021-07-01' GROUP BY continent, consumption) subquery WHERE rank <= 2 GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE health_facilities (facility_id INT, name VARCHAR(50), type VARCHAR(50), population INT, city VARCHAR(50), state VARCHAR(50));
What is the minimum population of a facility in the 'health_facilities' table?
SELECT MIN(population) FROM health_facilities;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (id INT, tool VARCHAR(20), application VARCHAR(50), country VARCHAR(20));
Insert new records into the 'creative_ai' table for 'Diffusion Models' in 'China'
INSERT INTO creative_ai (id, tool, application, country) VALUES (3, 'Diffusion Models', 'Image Generation', 'China');
gretelai_synthetic_text_to_sql
CREATE TABLE fans (id INT, name VARCHAR(50), age INT, last_game_date DATE); INSERT INTO fans (id, name, age, last_game_date) VALUES (1, 'Emily Davis', 22, '2021-01-01'); INSERT INTO fans (id, name, age, last_game_date) VALUES (2, 'Michael Chen', 30, '2020-01-01');
What is the total number of fans who have attended a tennis match and are under the age of 25?
SELECT COUNT(*) FROM fans WHERE age < 25 AND last_game_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), is_vegan BOOLEAN); CREATE TABLE sales (id INT PRIMARY KEY, product_id INT, supplier_id INT, quantity INT, date DATE);
Add a new "Eyeshadow" product to the cosmetics table with an id of 11, a price of $12.50, and a vegan status of true.
INSERT INTO cosmetics (id, name, category, price, is_vegan) VALUES (11, 'Eyeshadow', 'Eye', 12.50, true);
gretelai_synthetic_text_to_sql
CREATE SCHEMA trans schemas.trans; CREATE TABLE bus_fares (bus_number INT, fare FLOAT, fare_date DATE); INSERT INTO bus_fares (bus_number, fare, fare_date) VALUES (1201, 1.75, '2021-03-01'), (1201, 1.75, '2021-03-02'), (1201, 1.75, '2021-03-03'), (1201, 1.75, '2021-03-04'), (1201, 1.75, '2021-03-05'), (1202, 2.25, '202...
What was the total fare collected by bus number on the first week of March 2021?
SELECT bus_number, SUM(fare) OVER (PARTITION BY bus_number) FROM bus_fares WHERE fare_date BETWEEN '2021-03-01' AND '2021-03-05';
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT PRIMARY KEY, program_name VARCHAR(255), description TEXT, target_audience VARCHAR(255));
Insert a new record into the 'community_education' table
INSERT INTO community_education (id, program_name, description, target_audience) VALUES (1, 'Wildlife Warriors', 'A program to teach children about wildlife conservation.', 'Children');
gretelai_synthetic_text_to_sql
CREATE TABLE MetropolitanMuseum(id INT, type VARCHAR(20), artist VARCHAR(30)); CREATE TABLE GuggenheimMuseum(id INT, type VARCHAR(20), artist VARCHAR(30)); INSERT INTO MetropolitanMuseum(id, type, artist) VALUES (1, 'Painting', 'Rembrandt'), (2, 'Sculpture', 'Rodin'), (3, 'Painting', 'Van Gogh'); INSERT INTO Guggenheim...
List the art pieces that are present in both the Metropolitan Museum and the Guggenheim Museum.
SELECT type, artist FROM MetropolitanMuseum WHERE (type, artist) IN (SELECT type, artist FROM GuggenheimMuseum);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_patents (patent_id INT, company_name VARCHAR(30), country VARCHAR(20)); INSERT INTO ai_patents (patent_id, company_name, country) VALUES (1, 'IBM', 'USA'), (2, 'Microsoft', 'USA'), (3, 'TCS', 'India');
What is the maximum number of AI patents filed by companies based in the USA?
SELECT MAX(patent_id) FROM ai_patents WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, total_assets DECIMAL(10,2)); INSERT INTO customers (customer_id, total_assets) VALUES (1, 50000), (2, 75000), (3, 30000); CREATE TABLE investments (customer_id INT, stock_symbol VARCHAR(5), investment_amount DECIMAL(10,2)); INSERT INTO investments (customer_id, stock_symbol, inv...
Identify the customer with the highest investment in stock 'MSFT'
SELECT investments.customer_id, MAX(investments.investment_amount) FROM investments WHERE investments.stock_symbol = 'MSFT' GROUP BY investments.customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, campus TEXT, hours INT, project_id INT);
What is the maximum number of hours spent on a single project by students in each campus?
SELECT campus, MAX(hours) FROM students GROUP BY campus;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT PRIMARY KEY, source VARCHAR(255), recipient VARCHAR(255), amount FLOAT, date DATE); INSERT INTO climate_finance (id, source, recipient, amount, date) VALUES (1, 'World Bank', 'Brazil', 5000000, '2018-01-01'), (2, 'Asian Development Bank', 'India', 7000000, '2020-01-01');
How much climate finance has been provided by multilateral development banks in the last 5 years?
SELECT SUM(amount) FROM climate_finance WHERE source LIKE '%Multilateral Development Bank%' AND YEAR(date) >= 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, neighborhood VARCHAR(20), year INT, price INT); INSERT INTO properties (id, neighborhood, year, price) VALUES (1, 'Neighborhood X', 2020, 200000), (2, 'Neighborhood Y', 2020, 150000), (3, 'Neighborhood X', 2021, 250000), (4, 'Neighborhood Y', 2021, 180000);
What is the change in median property price between 2020 and 2021 in each neighborhood?
SELECT neighborhood, (LEAD(price) OVER (PARTITION BY neighborhood ORDER BY year)) - price AS price_change FROM properties WHERE year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE temperate_forests (id INT, name VARCHAR(255), country VARCHAR(255), sequestration INT); INSERT INTO temperate_forests (id, name, country, sequestration) VALUES (1, 'Temperate Forest 1', 'USA', 12000), (2, 'Temperate Forest 2', 'USA', 15000), (3, 'Temperate Forest 3', 'USA', 18000);
What is the maximum carbon sequestration achieved in a single year in temperate forests, and which forest was it?
SELECT name, MAX(sequestration) FROM temperate_forests WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE DrugSales (SalesCountry varchar(50), DrugName varchar(50), SalesDate date, TotalSalesRev decimal(18,2)); INSERT INTO DrugSales (SalesCountry, DrugName, SalesDate, TotalSalesRev) VALUES ('USA', 'DrugAF', '2021-03-15', 55000.00), ('Canada', 'DrugAG', '2021-02-01', 60000.00), ('Mexico', 'DrugAH', '2021-01-25'...
What is the total sales revenue per country, ranked by sales revenue?
SELECT SalesCountry, SUM(TotalSalesRev) as TotalSales, ROW_NUMBER() OVER (ORDER BY SUM(TotalSalesRev) DESC) as SalesRank FROM DrugSales GROUP BY SalesCountry;
gretelai_synthetic_text_to_sql
CREATE TABLE australia_users (transport_type VARCHAR(20), users INT);
What is the total number of multimodal transportation users in Australia?
SELECT SUM(users) AS total_multimodal_users FROM australia_users;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 78.3), (2, 'finance', 65.2), (3, 'technology', 74.5);
What is the maximum ESG score for companies in the 'finance' sector?
SELECT MAX(ESG_score) FROM companies WHERE sector = 'finance';
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (region VARCHAR(20), year INT, capacity INT); INSERT INTO landfill_capacity (region, year, capacity) VALUES ('Central', 2019, 500000), ('Central', 2020, 550000), ('Central', 2021, 600000);
What was the landfill capacity in cubic meters for the 'Central' region in 2020?
SELECT capacity FROM landfill_capacity WHERE region = 'Central' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, sector VARCHAR(20), amount DECIMAL(10,2)); INSERT INTO investments (id, sector, amount) VALUES (1, 'climate change', 10000.00), (2, 'climate change', 12000.00), (3, 'education', 22000.00);
What is the minimum investment made in the climate change sector?
SELECT MIN(amount) FROM investments WHERE sector = 'climate change';
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, order_date DATE, product_id INT, revenue FLOAT); CREATE TABLE products (product_id INT, product_name VARCHAR(50), revenue FLOAT, labor_practices VARCHAR(20), country VARCHAR(50)); INSERT INTO products (product_id, product_name, revenue, labor_practices, country) VALUES (1, 'T-Shirt', ...
How many ethical products were sold in the EU in Q2 2021?
SELECT COUNT(*) FROM orders JOIN products ON orders.product_id = products.product_id WHERE products.labor_practices = 'Ethical' AND EXTRACT(MONTH FROM order_date) BETWEEN 4 AND 6 AND EXTRACT(YEAR FROM order_date) = 2021 AND products.country IN ('Germany', 'France', 'Italy', 'Spain', 'Portugal', 'Belgium', 'Netherlands'...
gretelai_synthetic_text_to_sql
CREATE TABLE labor_force (miner_name VARCHAR(50), country VARCHAR(50), worker_count INT, PRIMARY KEY (miner_name, country));INSERT INTO labor_force (miner_name, country, worker_count) VALUES ('Li Wong', 'China', 500), ('Han Lee', 'South Korea', 400), ('Kim Park', 'Japan', 600);CREATE VIEW miner_country_worker_count AS ...
Which miner has the highest labor force in Asia?
SELECT context.miner_name, context.country, sql.worker_count, sql.rank FROM labor_force sql JOIN miner_country_worker_count context ON sql.miner_name = context.miner_name WHERE context.rank = 1 AND sql.country = 'Asia'
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), Country TEXT);
How many donors are there from Japan with a donation amount greater than 500?
SELECT COUNT(*) FROM Donors WHERE Country = 'Japan' AND DonationAmount > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, amount INT); INSERT INTO production (country, year, amount) VALUES ('China', 2019, 120000), ('China', 2020, 140000), ('USA', 2019, 36000), ('USA', 2020, 38000), ('Australia', 2019, 18000), ('Australia', 2020, 20000), ('India', 2019, 4000), ('India', 2020, 5000);
Which country had the highest production increase from 2019 to 2020?
SELECT country, MAX(amount - LAG(amount, 1) OVER (PARTITION BY country ORDER BY year)) AS production_increase FROM production GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE product_sales (product_category VARCHAR(50), region VARCHAR(50), operator VARCHAR(50), revenue FLOAT, subscribers INT); INSERT INTO product_sales VALUES ('Category A', 'Region A', 'Operator A', 2000, 100); INSERT INTO product_sales VALUES ('Category B', 'Region A', 'Operator A', 3000, 200); INSERT INTO pro...
What is the total revenue and number of subscribers for each product category, sales region, and mobile network operator?
SELECT region, operator, product_category, AVG(revenue) as avg_revenue, SUM(subscribers) as total_subscribers FROM product_sales GROUP BY region, operator, product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Country VARCHAR(20), GamePreference VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Country, GamePreference) VALUES (1, 25, 'USA', 'FPS');
Which country has the most players in the FPS genre?
SELECT Country, COUNT(*) FROM Players WHERE GamePreference = 'FPS' GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_name TEXT, coral_reef_area FLOAT);
Identify the top 3 countries with the largest coral reef area.
SELECT country_name, coral_reef_area FROM countries ORDER BY coral_reef_area DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE, max_speed FLOAT);
Which countries have launched the most spacecraft?
SELECT launch_country, COUNT(*) as num_spacecraft FROM spacecraft GROUP BY launch_country ORDER BY num_spacecraft DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (manufacturer_id INT, name VARCHAR(50)); INSERT INTO manufacturers (manufacturer_id, name) VALUES (1, 'ManufacturerA'), (2, 'ManufacturerB'), (3, 'ManufacturerC'); CREATE TABLE products (product_id INT, manufacturer_id INT, vegan CHAR(1)); INSERT INTO products (product_id, manufacturer_id, ve...
How many 'vegan' products are offered by each manufacturer?
SELECT manufacturers.name, COUNT(products.product_id) AS vegan_products_count FROM manufacturers JOIN products ON manufacturers.manufacturer_id = products.manufacturer_id WHERE products.vegan = 'Y' GROUP BY manufacturers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE fifa_teams (team_id INT, team_name VARCHAR(255)); INSERT INTO fifa_teams VALUES (1, 'TeamA'), (2, 'TeamB'), (3, 'TeamC'), (4, 'TeamD'); CREATE TABLE fifa_knockout_stage_stats (game_id INT, team_id INT, passes_attempted INT, passes_successful INT); INSERT INTO fifa_knockout_stage_stats VALUES (1, 1, 450, 40...
What is the percentage of successful passes by each team in the 2022 FIFA World Cup knockout stage?
SELECT t.team_name, (SUM(s.passes_successful) * 100.0 / SUM(s.passes_attempted)) AS pass_success_percentage FROM fifa_teams t JOIN fifa_knockout_stage_stats s ON t.team_id = s.team_id GROUP BY t.team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, EventName TEXT, Attendance INT); INSERT INTO Events (EventID, EventName, Attendance) VALUES (1, 'Jazz', 50), (2, 'Rock', 100);
How many attendees were there at the "Jazz" event from the "Events" table?
SELECT Attendance FROM Events WHERE EventName = 'Jazz';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, natural_ingredients BOOLEAN, certified_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO products VALUES (1, true, true, 25.99), (2, false, false, 10.99), (3, true, false, 15.49), (4, true, true, 22.50), (5, false, true, 30.00), (6, true, false, 9.99), (7, true, false, 12.35), (8, t...
What is the average price of products that contain natural ingredients and are certified vegan?
SELECT AVG(p.price) FROM products p WHERE p.natural_ingredients = true AND p.certified_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE country (country_id INT, country_name TEXT, PRIMARY KEY (country_id)); CREATE TABLE wildlife (wildlife_id INT, country_id INT, species_count INT, PRIMARY KEY (wildlife_id), FOREIGN KEY (country_id) REFERENCES country(country_id)); CREATE TABLE forest (forest_id INT, country_id INT, forest_count INT, PRIMAR...
List the total number of wildlife species and the number of forests for each country with wildlife sanctuaries, grouped by country, and sorted by the number of forests in descending order.
SELECT c.country_name, COUNT(w.species_count) AS total_wildlife_species, COUNT(f.forest_count) AS total_forests FROM country c INNER JOIN wildlife w ON c.country_id = w.country_id INNER JOIN forest f ON c.country_id = f.country_id GROUP BY c.country_name HAVING COUNT(w.species_count) > 0 ORDER BY total_forests DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ads (id INT, user_id INT, ad_date DATE); CREATE TABLE users (id INT);
How many advertisements were served to users in the past week, grouped by the day of the week?
SELECT DATE_TRUNC('day', ad_date) ad_date, COUNT(*) FROM ads JOIN users ON ads.user_id = users.id WHERE ad_date >= CURRENT_DATE - INTERVAL '7 days' GROUP BY 1 ORDER BY 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Talent_Acquisition (Applicant_ID INT, Job_Title VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10), Hire_Date DATE); INSERT INTO Talent_Acquisition (Applicant_ID, Job_Title, Department, Gender, Hire_Date) VALUES (1001, 'Software Engineer', 'IT', 'Male', '2021-06-01'), (1002, 'HR Coordinator', 'HR', 'F...
How many new hires were made in the 'HR' and 'Finance' departments in the first half of 2021?
SELECT Department, COUNT(*) FROM Talent_Acquisition WHERE Hire_Date >= '2021-01-01' AND Hire_Date < '2021-07-01' AND Department IN ('HR', 'Finance') GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE movie_revenue (id INT, movie TEXT, genre TEXT, revenue INT); INSERT INTO movie_revenue (id, movie, genre, revenue) VALUES (1, 'Movie1', 'Action', 5000000); INSERT INTO movie_revenue (id, movie, genre, revenue) VALUES (2, 'Movie2', 'Comedy', 4000000); INSERT INTO movie_revenue (id, movie, genre, revenue) VA...
What is the total revenue for movies by genre?
SELECT genre, SUM(revenue) as total_revenue FROM movie_revenue GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT, location TEXT, size FLOAT); CREATE TABLE animal_population (id INT, habitat_id INT, animal_count INT);
What is the average number of animals in habitats located in North America?
SELECT AVG(ap.animal_count) FROM animal_population ap INNER JOIN habitat h ON ap.habitat_id = h.id WHERE h.location = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE CompanyFunding(id INT, name TEXT, founding_year INT, funding_amount INT, racial_ethnicity TEXT); INSERT INTO CompanyFunding VALUES (1, 'TechCo', 2016, 6000000, 'Latinx'), (2, 'GreenTech', 2014, 8000000, 'Caucasian'), (3, 'AIStudio', 2021, 4000000, 'African'), (4, 'RenewableEnergy', 2018, 9000000, 'Latinx...
What is the average funding amount for companies founded by Latinx entrepreneurs in the last 7 years?
SELECT AVG(funding_amount) FROM CompanyFunding WHERE racial_ethnicity = 'Latinx' AND founding_year >= YEAR(CURRENT_DATE) - 7;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(255), revenue DECIMAL(10,2)); CREATE TABLE Artists (id INT, genre VARCHAR(255));
Find the top 5 cities with the highest revenue from concert ticket sales for artists from the Pop genre.
SELECT city, SUM(revenue) as total_revenue FROM Concerts INNER JOIN Artists ON Concerts.id = Artists.id WHERE genre = 'Pop' GROUP BY city ORDER BY total_revenue DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (Id INT, Name TEXT, Hours DECIMAL(10,2)); INSERT INTO Volunteers VALUES (1, 'Charlie', 50.00), (2, 'David', 30.00), (3, 'Eve', 40.00);
Who are the top 3 volunteers by total hours served?
SELECT Name, RANK() OVER (ORDER BY Hours DESC) as Rank FROM Volunteers WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, name TEXT, location TEXT, sector TEXT, total_employees INT, union_members INT, successful_cb BOOLEAN, cb_year INT);
What is the total number of workplaces with successful collective bargaining in 2021?
SELECT SUM(successful_cb) FROM workplaces WHERE cb_year = 2021 AND successful_cb = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE music_festivals (festival_name VARCHAR(255), location VARCHAR(255), date DATE, tier_1_price INT, tier_2_price INT);
What is the average ticket price for each concert in the 'music_festivals' table?
SELECT festival_name, (tier_1_price + tier_2_price)/2 as avg_ticket_price FROM music_festivals;
gretelai_synthetic_text_to_sql
CREATE TABLE sanctuary_g (animal_id INT, animal_name VARCHAR(50), population INT, sanctuary_name VARCHAR(50)); INSERT INTO sanctuary_g VALUES (1, 'lion', 60, 'sanctuary_1'); INSERT INTO sanctuary_g VALUES (2, 'zebra', 45, 'sanctuary_1'); INSERT INTO sanctuary_g VALUES (3, 'lion', 50, 'sanctuary_2'); INSERT INTO sanctua...
What is the total population of lions and zebras in all sanctuaries?
SELECT SUM(population) FROM sanctuary_g WHERE animal_name IN ('lion', 'zebra');
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, type TEXT); INSERT INTO hospitals (id, name, location, type) VALUES (1, 'Hospital A', 'City A, State A', 'Hospital'); INSERT INTO hospitals (id, name, location, type) VALUES (2, 'Clinic A', 'City B, State A', 'Clinic'); CREATE TABLE clinics (id INT, name TEXT, l...
What is the number of hospitals and clinics in urban areas, broken down by state?
SELECT h.state, COUNT(h.id) as hospital_count, COUNT(c.id) as clinic_count FROM hospitals h INNER JOIN clinics c ON h.state = c.state WHERE h.location LIKE '%urban%' GROUP BY h.state;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, strain_id INT, quantity INT, date DATE); INSERT INTO sales (id, strain_id, quantity, date) VALUES (1, 5, 10, '2022-05-01'), (2, 6, 15, '2022-05-02');
What is the total quantity of each strain type sold in Arizona dispensaries in May 2022?
SELECT strain_id, type, SUM(quantity) as total_quantity FROM sales s JOIN strains st ON s.strain_id = st.id WHERE st.state = 'Arizona' AND date BETWEEN '2022-05-01' AND '2022-05-31' GROUP BY strain_id, type;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (system_id INT, system_name TEXT, country TEXT, establishment_year INT); INSERT INTO indigenous_food_systems (system_id, system_name, country, establishment_year) VALUES (1, 'Milpa System', 'Mexico', 2000), (2, 'Maya System', 'Guatemala', 1500);
List the names of all indigenous food systems in Mexico and Guatemala, with their respective establishment years.
SELECT system_name, establishment_year FROM indigenous_food_systems WHERE country IN ('Mexico', 'Guatemala');
gretelai_synthetic_text_to_sql
CREATE TABLE disasters (id INT, type TEXT, location TEXT, year INT); INSERT INTO disasters (id, type, location, year) VALUES (1, 'Flood', 'South America', 2020), (2, 'Earthquake', 'Asia', 2019), (3, 'Tornado', 'North America', 2020);
What is the average number of natural disasters reported in each region per year?
SELECT AVG(total_disasters) FROM (SELECT location, COUNT(*) AS total_disasters FROM disasters GROUP BY location, year) AS disaster_counts GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ID INT, Regulation VARCHAR(50), State VARCHAR(50)); INSERT INTO MentalHealthParity (ID, Regulation, State) VALUES (1, 'Regulation 1', 'New York'); INSERT INTO MentalHealthParity (ID, Regulation, State) VALUES (2, 'Regulation 2', 'California');
What is the total number of mental health parity regulations?
SELECT COUNT(*) FROM MentalHealthParity;
gretelai_synthetic_text_to_sql
CREATE TABLE Missions (id INT, name VARCHAR(50), company VARCHAR(50), launch_date DATE); INSERT INTO Missions (id, name, company, launch_date) VALUES (1, 'Pegasus 1', 'GalacticExplorers', '2025-04-10'), (2, 'Pegasus 2', 'GalacticExplorers', '2027-07-04'), (3, 'Pegasus 3', 'GalacticExplorers', '2029-10-31');
What is the earliest launch date of a mission for 'GalacticExplorers'?
SELECT MIN(launch_date) FROM Missions WHERE company = 'GalacticExplorers';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (country VARCHAR(50), year INT, operation_count INT); INSERT INTO peacekeeping_operations (country, year, operation_count) VALUES ('Indonesia', 2017, 3), ('Indonesia', 2017, 4), ('Indonesia', 2018, 5), ('Indonesia', 2018, 6);
What is the total number of peacekeeping operations conducted by Indonesia in 2017 and 2018?
SELECT SUM(operation_count) FROM peacekeeping_operations WHERE country = 'Indonesia' AND year IN (2017, 2018);
gretelai_synthetic_text_to_sql
CREATE TABLE seafood_certifications (id INT, country VARCHAR(50), certification VARCHAR(50), species VARCHAR(50)); INSERT INTO seafood_certifications (id, country, certification, species) VALUES (1, 'Norway', 'MSC', 'Salmon'), (2, 'Norway', 'ASC', 'Salmon'), (3, 'Canada', 'MSC', 'Salmon');
Find countries with no sustainable seafood certifications for Salmon.
SELECT country FROM seafood_certifications WHERE species = 'Salmon' GROUP BY country HAVING COUNT(DISTINCT certification) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (restaurant_name TEXT, cuisine TEXT, dish TEXT, carbohydrates INTEGER, dish_date DATE); INSERT INTO dishes (restaurant_name, cuisine, dish, carbohydrates, dish_date) VALUES ('New York Wok', 'Chinese', 'Kung Pao Chicken', 45, '2022-06-01');
Identify the top 2 dishes with the highest carbohydrate content in Chinese cuisine restaurants in New York City, considering the month of June 2022.
SELECT dish, carbohydrates FROM (SELECT dish, carbohydrates, ROW_NUMBER() OVER (PARTITION BY dish_date ORDER BY carbohydrates DESC) as rn FROM dishes WHERE restaurant_name LIKE 'New York%' AND cuisine = 'Chinese' AND dish_date >= '2022-06-01' AND dish_date < '2022-07-01') t WHERE rn <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE CountrySales (id INT PRIMARY KEY, country VARCHAR(50), sale_price DECIMAL(10, 2));
Which country has the highest sum of military equipment sales?
SELECT country, SUM(sale_price) FROM CountrySales GROUP BY country ORDER BY SUM(sale_price) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (trench_name TEXT, ocean TEXT, avg_depth FLOAT);
What is the average depth of all trenches in the Pacific Ocean, excluding trenches with an average depth of over 8000 meters?
SELECT AVG(avg_depth) FROM ocean_trenches WHERE ocean = 'Pacific' HAVING AVG(avg_depth) < 8000;
gretelai_synthetic_text_to_sql
CREATE TABLE western_states (state VARCHAR(20), score INT); INSERT INTO western_states (state, score) VALUES ('California', 85), ('Washington', 82), ('Oregon', 88), ('Nevada', 78), ('Colorado', 75);
What is the average water conservation initiative score for Western states?
SELECT AVG(score) FROM western_states WHERE state IN ('California', 'Washington', 'Oregon', 'Nevada', 'Colorado')
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarding (carrier_id INT, carrier_name VARCHAR(50)); INSERT INTO freight_forwarding (carrier_id, carrier_name) VALUES (1, 'FedEx'), (2, 'UPS'), (3, 'USPS');
Get the top 2 'carrier_names' with the highest 'carrier_id' from the 'freight_forwarding' table
SELECT carrier_name FROM freight_forwarding ORDER BY carrier_id DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE age_restriction (program_name VARCHAR(50), city VARCHAR(50), min_age INT); INSERT INTO age_restriction (program_name, city, min_age) VALUES ('Dance for All', 'San Francisco', 16);
What was the minimum age of attendees who participated in 'Dance for All' programs in San Francisco?
SELECT MIN(min_age) FROM age_restriction WHERE program_name = 'Dance for All' AND city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE VIEW primary_care_physicians AS SELECT * FROM healthcare_staff WHERE role = 'Primary Care Physician'; CREATE TABLE healthcare_staff (id INT, name TEXT, role TEXT, location TEXT); INSERT INTO healthcare_staff (id, name, role, location) VALUES (1, 'Dr. Johnson', 'Primary Care Physician', 'Texas'), (2, 'Dr. Smith',...
How many primary care physicians work in rural healthcare facilities in Texas and California?
SELECT COUNT(*) FROM primary_care_physicians WHERE location IN ('Texas', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE Costs (id INT, item VARCHAR(255), cost DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO Costs (id, item, cost, country) VALUES (1, 'Dress', 120.00, 'France'); INSERT INTO Costs (id, item, cost, country) VALUES (2, 'Blouse', 80.00, 'France');
What is the average production cost of ethical fashion items in France?
SELECT AVG(cost) FROM Costs WHERE country = 'France' AND item IN ('Dress', 'Blouse')
gretelai_synthetic_text_to_sql
CREATE TABLE Wells (WellID INT, WellName VARCHAR(50), ProductionRate FLOAT, Country VARCHAR(50)); INSERT INTO Wells (WellID, WellName, ProductionRate, Country) VALUES (1, 'Well A', 500, 'USA'), (2, 'Well B', 600, 'Canada'), (3, 'Well C', 700, 'Mexico');
What is the average production rate per well for each country?
SELECT Country, AVG(ProductionRate) AS AvgProductionRate FROM Wells GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (WarehouseID int, WarehouseName varchar(50), City varchar(50)); INSERT INTO Warehouse VALUES (1, 'Warehouse 1', 'City X'), (2, 'Warehouse 2', 'City Z'), (3, 'Warehouse 3', 'City X');
Insert a new record into the Warehouse table for a new warehouse in 'City Y'.
INSERT INTO Warehouse (WarehouseID, WarehouseName, City) VALUES (4, 'Warehouse 4', 'City Y');
gretelai_synthetic_text_to_sql
CREATE TABLE project_summary (project_id INT, project_type VARCHAR(50), completion_year INT); INSERT INTO project_summary (project_id, project_type, completion_year) VALUES (1, 'Wind', 2010), (2, 'Solar', 2012), (3, 'Hydro', 2005);
What is the earliest completion year for any renewable energy project in the 'project_summary' table?
SELECT MIN(completion_year) FROM project_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE farm (id INT, name VARCHAR(50), size FLOAT, fertilizer VARCHAR(50), PRIMARY KEY(id)); INSERT INTO farm (id, name, size, fertilizer) VALUES (1, 'Farm A', 50.3, 'Fertilizer X'); INSERT INTO farm (id, name, size, fertilizer) VALUES (2, 'Farm B', 75.8, 'Fertilizer Y'); CREATE TABLE sensor (id INT, farm_id INT,...
Find the total area and average temperature for farms using a specific fertilizer.
SELECT f.fertilizer, SUM(f.size) AS total_area, AVG(s.temperature) AS avg_temperature FROM farm f INNER JOIN sensor s ON f.id = s.farm_id INNER JOIN fertilizer_application a ON f.id = a.farm_id WHERE f.fertilizer = 'Fertilizer X' GROUP BY f.fertilizer;
gretelai_synthetic_text_to_sql
CREATE TABLE order_quantities (id INT, material VARCHAR(20), order_quantity INT); INSERT INTO order_quantities (id, material, order_quantity) VALUES (1, 'Recycled Material A', 500), (2, 'Virgin Material B', 700), (3, 'Recycled Material C', 600);
What is the maximum order quantity for products made with recycled materials?
SELECT MAX(order_quantity) FROM order_quantities WHERE material LIKE 'Recycled%';
gretelai_synthetic_text_to_sql
CREATE TABLE resource_type (type VARCHAR(255), amount INT); INSERT INTO resource_type (type, amount) VALUES ('Gold', 500), ('Silver', 300), ('Coal', 700);
Show the total amount of resources extracted by resource type
SELECT rt.type, SUM(rt.amount) as total_resources_extracted FROM resource_type rt GROUP BY rt.type;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50)); CREATE TABLE DiversityTraining (EmployeeID INT, TrainingID INT, Completed DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Position) VALUES (1, 'John', 'Doe', 'IT...
List all managers and their respective departments who have not completed diversity and inclusion training.
SELECT Employees.FirstName, Employees.LastName, Employees.Department FROM Employees LEFT JOIN DiversityTraining ON Employees.EmployeeID = DiversityTraining.EmployeeID WHERE Employees.Position = 'Manager' AND DiversityTraining.Completed IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Hiring (HireID INT, Gender VARCHAR(10), Department VARCHAR(20), HireDate DATE); INSERT INTO Hiring (HireID, Gender, Department, HireDate) VALUES (1, 'Male', 'Engineering', '2022-01-01'), (2, 'Female', 'IT', '2022-02-01'), (3, 'Non-binary', 'HR', '2022-03-01');
How many employees who identify as male were hired in the last 3 months in the Engineering department?
SELECT COUNT(*) FROM Hiring WHERE Gender = 'Male' AND Department = 'Engineering' AND HireDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name TEXT, year INT, investment FLOAT);
What is the average investment in smart city initiatives per year?
SELECT AVG(investment) FROM initiatives GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE exploration_data (id INT, field VARCHAR(50), country VARCHAR(50), discovery_year INT, discovery_number FLOAT); INSERT INTO exploration_data (id, field, country, discovery_year, discovery_number) VALUES (1, 'Sahara', 'Algeria', 1999, 12345.67); INSERT INTO exploration_data (id, field, country, discovery_yea...
Delete all records from the 'exploration_data' table where the 'discovery_year' is less than 2000
DELETE FROM exploration_data WHERE discovery_year < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT); INSERT INTO Members (MemberID, Name, Age) VALUES (1, 'John Doe', 30); INSERT INTO Members (MemberID, Name, Age) VALUES (2, 'Jane Smith', 45); INSERT INTO Members (MemberID, Name, Age) VALUES (3, 'Alice Johnson', 28);
List the names of members who are older than 35.
SELECT Name FROM Members WHERE Age > 35;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, industry TEXT, founder_identity TEXT); INSERT INTO startup (id, industry, founder_identity) VALUES (1, 'Software', 'Latinx Female'), (2, 'Hardware', 'Asian Male'), (3, 'Healthcare', 'Latinx Non-binary'), (4, 'AI', 'Black Female'), (5, 'CleanTech', 'Latinx Male'), (6, 'FinTech', 'AAPI Femal...
List the unique industries for startups founded by Latinx individuals that have raised Series B or later funding.
SELECT DISTINCT industry FROM startup WHERE founder_identity LIKE '%Latinx%' AND funding IN ('Series B', 'Series C', 'Series D', 'Series E');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, city VARCHAR(255), quantity INT);
How many items were sold in each city?
SELECT city, SUM(quantity) FROM sales GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE events (name VARCHAR(255), location VARCHAR(255), category VARCHAR(255), year INT); INSERT INTO events (name, location, category, year) VALUES ('Van Gogh Alive', 'Tokyo', 'Art', 2019), ('Monet Exhibition', 'Tokyo', 'Art', 2020), ('Hamilton', 'Tokyo', 'Theatre', 2020);
What is the total number of art events in the city of Tokyo for the years 2019 and 2020?
SELECT COUNT(*) FROM events WHERE location = 'Tokyo' AND year IN (2019, 2020) AND category = 'Art';
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, team_id INT); CREATE TABLE tickets (ticket_id INT, game_id INT, price DECIMAL(5,2)); CREATE TABLE teams (team_id INT, team_name VARCHAR(20)); INSERT INTO teams (team_id, team_name) VALUES (5, 'Boston Celtics'); INSERT INTO games (game_id, team_id) VALUES (5, 5); INSERT INTO tickets (tic...
What is the total number of tickets sold for each game of the Boston Celtics?
SELECT COUNT(tickets.ticket_id), games.game_id FROM tickets INNER JOIN games ON tickets.game_id = games.game_id INNER JOIN teams ON games.team_id = teams.team_id WHERE teams.team_name = 'Boston Celtics' GROUP BY games.game_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Materials (material_id INT PRIMARY KEY, material VARCHAR(50), usage INT); INSERT INTO Materials (material_id, material, usage) VALUES (1, 'Organic Cotton', 500), (2, 'Recycled Polyester', 300), (3, 'Hemp', 100);
Which sustainable material has usage greater than 250?
SELECT material FROM Materials WHERE usage > 250;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselSafety (VesselID INT, SafetyScore DECIMAL(3,1)); INSERT INTO VesselSafety (VesselID, SafetyScore) VALUES (1, 60.2), (2, 82.1), (3, 73.3), (4, 91.1);
Identify vessels with safety scores between 70 and 85.
SELECT VesselID FROM VesselSafety WHERE SafetyScore BETWEEN 70 AND 85;
gretelai_synthetic_text_to_sql
CREATE TABLE cargoships (id INT PRIMARY KEY, name VARCHAR(50), status VARCHAR(20));
How many cargo ships are currently in the 'cargoships' table?
SELECT COUNT(*) FROM cargoships WHERE status = 'active';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255)); INSERT INTO Spacecraft (id, name, manufacturer) VALUES (1, 'Voyager 1', 'AstroCorp'); INSERT INTO Spacecraft (id, name, manufacturer) VALUES (2, 'Voyager 2', 'AstroCorp');
What is the total number of spacecraft manufactured by AstroCorp?
SELECT COUNT(*) FROM Spacecraft WHERE manufacturer = 'AstroCorp';
gretelai_synthetic_text_to_sql
CREATE TABLE arts (id INT, art_name VARCHAR(50), origin_country VARCHAR(50)); INSERT INTO arts (id, art_name, origin_country) VALUES (1, 'Ukiyo-e', 'Japan'), (2, 'Batik', 'Indonesia');
List all traditional arts and their origins from the "arts" table.
SELECT art_name, origin_country FROM arts;
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (id INT PRIMARY KEY, region VARCHAR(20), treatment_efficiency DECIMAL(5,2));
Update the 'wastewater_treatment' table to reflect a 15% increase in the 'treatment_efficiency' for the 'West' region
UPDATE wastewater_treatment SET treatment_efficiency = treatment_efficiency * 1.15 WHERE region = 'West';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID INT, Name VARCHAR(50)); CREATE TABLE Menu (MenuID INT, RestaurantID INT, Item VARCHAR(50), Price DECIMAL(10,2), LastOrderDate DATE);
Delete menu items that have not been ordered in the last 30 days.
DELETE FROM Menu WHERE LastOrderDate < DATE_SUB(CURDATE(), INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS public.projects (id SERIAL PRIMARY KEY, name TEXT, start_date DATE); INSERT INTO public.projects (name, start_date) SELECT 'ExampleProject1', CURRENT_DATE - INTERVAL '15 days' FROM generate_series(1, 10); INSERT INTO public.projects (name, start_date) SELECT 'ExampleProject2', CURRENT_DATE - ...
List all projects in the "public" schema that have a start date within the last 30 days?
SELECT name, start_date FROM public.projects WHERE start_date >= CURRENT_DATE - INTERVAL '30 days';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), EsportsInterest BOOLEAN, EventsPlayed INT);CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventType VARCHAR(20));
Update the records of players who are interested in esports events and have participated in more than 5 events to indicate that they are professional players.
UPDATE Players SET EsportsInterest = TRUE WHERE EventsPlayed > 5 AND EsportsInterest = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_health (id INT PRIMARY KEY, location VARCHAR(255), temperature FLOAT, ph FLOAT);
Create a table named 'ocean_health'
CREATE TABLE ocean_health (id INT PRIMARY KEY, location VARCHAR(255), temperature FLOAT, ph FLOAT);
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (id INT, year INT, company VARCHAR(50), co2_emissions INT, location VARCHAR(50)); INSERT INTO emissions (id, year, company, co2_emissions, location) VALUES (1, 2015, 'Neo Chemicals & Metals Ltd', 12000, 'India'); INSERT INTO emissions (id, year, company, co2_emissions, location) VALUES (2, 2016, ...
What are the companies that have CO2 emissions greater than 14000 and are located in Asia?
SELECT company FROM emissions WHERE co2_emissions > 14000 AND location LIKE 'Asia%';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ratings (hotel_id INT, name VARCHAR(255), city VARCHAR(255), energy_efficiency_rating DECIMAL(3,2)); INSERT INTO hotel_ratings (hotel_id, name, city, energy_efficiency_rating) VALUES (1, 'EcoHotel London', 'London', 4.20), (2, 'GreenHotel London', 'London', 4.80);
What is the average energy efficiency rating of hotels in London?
SELECT AVG(energy_efficiency_rating) FROM hotel_ratings WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE exploration_data (well_name VARCHAR(50), location VARCHAR(50), discovery_date DATE, reserves_oil NUMERIC(10,2), reserves_gas NUMERIC(10,2));
Insert new exploration data for Well K in the North Sea.
INSERT INTO exploration_data (well_name, location, discovery_date, reserves_oil, reserves_gas) VALUES ('Well K', 'North Sea', '2023-02-15', 5000000, 2000000);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT PRIMARY KEY, donor_name VARCHAR(50), disaster_type VARCHAR(50), donation_amount DECIMAL(10,2)); INSERT INTO donations (id, donor_name, disaster_type, donation_amount) VALUES (1, 'John Doe', 'Earthquake', 100.00), (2, 'Jane Smith', 'Flood', 200.00), (3, 'Mike Johnson', 'Tornado', 50.00);
What is the average donation amount for each disaster type?
SELECT disaster_type, AVG(donation_amount) as avg_donation FROM donations GROUP BY disaster_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Destinations (destination_id INT, destination_name TEXT, country TEXT, awards INT); INSERT INTO Destinations (destination_id, destination_name, country, awards) VALUES (1, 'City A', 'Germany', 3), (2, 'City B', 'Switzerland', 5), (3, 'City C', 'Norway', 2);
Which destinations have the most sustainable tourism awards?
SELECT destination_name, country, awards, RANK() OVER (PARTITION BY country ORDER BY awards DESC) AS rank FROM Destinations;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT, company_id INT, amount INT, industry TEXT, founding_year INT); INSERT INTO funding (id, company_id, amount, industry, founding_year) VALUES (1, 1, 75000, 'Renewable Energy', 2012); INSERT INTO funding (id, company_id, amount, industry, founding_year) VALUES (2, 2, 100000, 'Finance', 2008);
Calculate the total funding for startups in the renewable energy sector founded since 2010
SELECT SUM(amount) FROM funding JOIN company ON funding.company_id = company.id WHERE funding.industry = 'Renewable Energy' AND company.founding_year >= 2010
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_programs (program_id INT, name TEXT, state TEXT, spending INT); INSERT INTO cultural_competency_programs (program_id, name, state, spending) VALUES (1, 'Program A', 'Wisconsin', 11000), (2, 'Program B', 'Minnesota', 13000), (3, 'Program C', 'Wisconsin', 12000), (4, 'Program D', 'Minneso...
What is the total spending on cultural competency programs in Wisconsin and Minnesota?
SELECT state, SUM(spending) FROM cultural_competency_programs WHERE state IN ('Wisconsin', 'Minnesota') GROUP BY state;
gretelai_synthetic_text_to_sql