context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE sports_teams (team_id INT, team_name VARCHAR(50), sport VARCHAR(20), city VARCHAR(20), division VARCHAR(20)); CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), team_id INT, position VARCHAR(20), age INT);
|
List all sports in the sports_teams table along with the number of players in each sport.
|
SELECT s.sport, COUNT(a.athlete_id) as num_players FROM sports_teams s JOIN athletes a ON s.team_id = a.team_id GROUP BY s.sport;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ev (ev_id INT, make TEXT, model TEXT, year INT, CO2_emissions FLOAT);
|
Calculate the average CO2 emissions of electric vehicles in California.
|
SELECT AVG(CO2_emissions) FROM ev WHERE make IS NOT NULL AND model IS NOT NULL AND year IS NOT NULL AND state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_consumption (country VARCHAR(255), consumption FLOAT, date DATE); INSERT INTO water_consumption (country, consumption, date) VALUES ('India', 15, '2022-01-01'); INSERT INTO water_consumption (country, consumption, date) VALUES ('India', 16, '2022-01-02');
|
What is the average daily water consumption per capita in India for the past 6 months?
|
SELECT AVG(consumption) FROM (SELECT consumption, DATE_TRUNC('day', date) AS day FROM water_consumption WHERE country = 'India' AND date >= '2021-07-01' AND date < '2022-01-01' GROUP BY day, consumption ORDER BY day) subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Properties (PropertyID int, Price int, City varchar(20), OwnershipType varchar(20)); INSERT INTO Properties (PropertyID, Price, City, OwnershipType) VALUES (1, 500000, 'Seattle', 'Co-Owned'); INSERT INTO Properties (PropertyID, Price, City, OwnershipType) VALUES (2, 700000, 'Portland', 'Individual');
|
What is the average property price for co-owned properties in Seattle?
|
SELECT AVG(Price) FROM Properties WHERE City = 'Seattle' AND OwnershipType = 'Co-Owned';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT PRIMARY KEY, donor_id INT, city VARCHAR(50), state VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, city, state, amount) VALUES (1, 1, 'Albany', 'NY', 50.00);
|
Which cities in NY have donated?
|
SELECT donations.city, donors.name FROM donors INNER JOIN donations ON donors.id = donations.donor_id WHERE donations.state = 'NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, rating DECIMAL(3,2), country VARCHAR(50)); INSERT INTO movies (id, title, genre, release_year, rating, country) VALUES (1, 'Movie1', 'Comedy', 2020, 8.2, 'India'); INSERT INTO movies (id, title, genre, release_year, rating, country) VALUES (2, 'Movie2', 'Drama', 2019, 7.5, 'India'); INSERT INTO movies (id, title, genre, release_year, rating, country) VALUES (3, 'Movie3', 'Action', 2021, 6.8, 'India');
|
What is the minimum rating for movies released in India?
|
SELECT MIN(rating) FROM movies WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Building_Permits (Permit_ID INT, Building_Type VARCHAR(50), Floors INT, Issue_Date DATE, Location VARCHAR(50));
|
What was the total count of building permits issued for multi-family residential buildings taller than 10 floors in Toronto between 2010 and 2019?
|
SELECT COUNT(Permit_ID) FROM Building_Permits WHERE Building_Type = 'Residential' AND Floors > 10 AND Location = 'Toronto' AND Issue_Date BETWEEN '2010-01-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Art (id INT, title VARCHAR(255), artist_id INT, creation_date DATE); CREATE TABLE Artist (id INT, name VARCHAR(255));
|
Find the earliest and latest creation dates for artworks by each artist.
|
SELECT Artist.name, MIN(Art.creation_date) AS earliest_date, MAX(Art.creation_date) AS latest_date FROM Artist JOIN Art ON Artist.id = Art.artist_id GROUP BY Artist.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_generation (id INT, source VARCHAR(255), capacity FLOAT, location VARCHAR(255)); CREATE TABLE energy_demand (id INT, location VARCHAR(255), demand FLOAT, timestamp DATETIME); INSERT INTO renewable_generation (id, source, capacity, location) VALUES (1, 'Wind', 5000.0, 'NY'), (2, 'Solar', 7000.0, 'FL'); INSERT INTO energy_demand (id, location, demand, timestamp) VALUES (1, 'NY', 8000.0, '2022-01-01 10:00:00'), (2, 'FL', 6000.0, '2022-01-01 10:00:00');
|
What is the average energy demand and the corresponding energy source for locations with a demand greater than 7000 in the energy_demand and renewable_generation tables?
|
SELECT e.location, r.source, AVG(e.demand) as avg_demand FROM renewable_generation r RIGHT JOIN energy_demand e ON r.location = e.location WHERE e.demand > 7000.0 GROUP BY e.location, r.source;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CulturalOrgs (org_id INT, org_name VARCHAR(50)); CREATE TABLE Visits (org_id INT, attendee_id INT, visit_date DATE, amount INT);
|
How many unique attendees have visited each cultural organization, and what is the total amount they have spent?
|
SELECT org_name, COUNT(DISTINCT attendee_id) AS unique_attendees, SUM(amount) AS total_spent FROM Visits v JOIN CulturalOrgs o ON v.org_id = o.org_id GROUP BY org_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE); CREATE TABLE SpaceMissions (MissionID INT, SpacecraftID INT, Destination VARCHAR(50)); INSERT INTO Spacecraft VALUES (1, 'Juno', 'NASA', '2011-08-05'); INSERT INTO SpaceMissions VALUES (1, 1, 'Jupiter');
|
List all spacecraft that have been used in missions to Jupiter's moons.
|
SELECT Spacecraft.Name FROM Spacecraft INNER JOIN SpaceMissions ON Spacecraft.SpacecraftID = SpaceMissions.SpacecraftID WHERE SpaceMissions.Destination LIKE '%Jupiter%' AND SpaceMissions.Destination LIKE '%moons%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asia_initiatives (region VARCHAR(50), initiative_name VARCHAR(50), budget NUMERIC(10,2), start_date DATE); INSERT INTO asia_initiatives (region, initiative_name, budget, start_date) VALUES (NULL, NULL, NULL, NULL);
|
Insert new circular economy initiatives in 'Asia' with the given details.
|
INSERT INTO asia_initiatives (region, initiative_name, budget, start_date) VALUES ('Asia', 'E-Waste Recycling', 600000, '2021-04-01'), ('Asia', 'Smart Cities', 900000, '2021-10-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CybersecurityStrategies (Id INT PRIMARY KEY, Country VARCHAR(50), Name VARCHAR(50), Budget INT);
|
Identify unique cybersecurity strategies implemented by countries with a high military technology budget
|
SELECT DISTINCT Name FROM CybersecurityStrategies WHERE Country IN (SELECT Country FROM MilitaryBudget WHERE Budget > 1000000) GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students (ID INT, Name VARCHAR(50), Disability VARCHAR(50), Program VARCHAR(50), Region VARCHAR(50)); INSERT INTO Students (ID, Name, Disability, Program, Region) VALUES (1, 'Jane Doe', 'Mobility Impairment', 'Wheelchair Tennis', 'Southeast'), (2, 'John Doe', 'Learning Disability', 'Wheelchair Tennis', 'Southeast'), (3, 'Jim Smith', 'Mobility Impairment', 'Adapted Yoga', 'Southeast');
|
How many students with mobility impairments are enrolled in each program in the Southeast?
|
SELECT Program, COUNT(*) FROM Students WHERE Disability = 'Mobility Impairment' GROUP BY Program;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_reviews (id INT, hotel_id INT, guest_name VARCHAR(50), rating INT, review_date DATE);
|
Add new records to hotel_reviews_table with random ratings for hotel_id 1004 and 1005
|
INSERT INTO hotel_reviews (id, hotel_id, guest_name, rating, review_date) VALUES (1, 1004, 'John Doe', FLOOR(1 + RAND() * 5), CURDATE()), (2, 1005, 'Jane Smith', FLOOR(1 + RAND() * 5), CURDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, sector TEXT, total_funding DECIMAL); INSERT INTO projects (id, sector, total_funding) VALUES (1, 'Health', 10000.00), (2, 'Education', 15000.00), (3, 'Agriculture', 20000.00);
|
What is the total funding amount for projects in the 'Education' sector?
|
SELECT SUM(total_funding) FROM projects WHERE sector = 'Education';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title TEXT, author TEXT, publish_date DATE);
|
Delete all records from the "articles" table where the "publish_date" is before 2020-01-01
|
DELETE FROM articles WHERE publish_date < '2020-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student (student_id INT, student_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE lifelong_learning (student_id INT, program_name VARCHAR(50)); INSERT INTO student (student_id, student_name, country) VALUES (1, 'Alex Johnson', 'USA'), (2, 'Pedro Martinez', 'Mexico'), (3, 'Sophia Lee', 'Canada'), (4, 'Lucas Nguyen', 'Vietnam'); INSERT INTO lifelong_learning (student_id, program_name) VALUES (1, 'Adult Education'), (2, 'English as a Second Language'), (3, 'Coding Bootcamp'), (4, 'Online Degree Program');
|
How many students have participated in lifelong learning programs in each country?
|
SELECT country, COUNT(DISTINCT student_id) as num_students FROM student INNER JOIN lifelong_learning ON student.student_id = lifelong_learning.student_id GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT, name VARCHAR(255), genre VARCHAR(255)); CREATE TABLE streams (id INT, song_id INT, user_id INT, location VARCHAR(255), timestamp TIMESTAMP); INSERT INTO artists (id, name, genre) VALUES (1, 'Eminem', 'Hip-Hop'), (2, 'Dr. Dre', 'Hip-Hop'); INSERT INTO streams (id, song_id, user_id, location, timestamp) VALUES (1, 1, 1, 'USA', NOW()), (2, 1, 2, 'Canada', NOW()); CREATE VIEW hip_hop_songs AS SELECT song_id FROM artists WHERE genre = 'Hip-Hop';
|
Find the total number of streams for all hip-hop songs on the platform, excluding any streams from the United States.
|
SELECT COUNT(*) FROM streams WHERE song_id IN (SELECT song_id FROM hip_hop_songs) AND location != 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (id INT PRIMARY KEY, year INT, location VARCHAR(50), usage FLOAT); INSERT INTO water_usage (id, year, location, usage) VALUES (1, 2018, 'New York', 1234.56), (2, 2019, 'New York', 1567.89), (3, 2020, 'New York', 1890.12), (4, 2018, 'Los Angeles', 2234.56), (5, 2019, 'Los Angeles', 2567.89), (6, 2020, 'Los Angeles', 2890.12);
|
Find the total water usage in cubic meters for the year 2020
|
SELECT SUM(usage) FROM water_usage WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africa_eco_tourists (country VARCHAR(50), eco_tourists INT); INSERT INTO africa_eco_tourists (country, eco_tourists) VALUES ('South Africa', 400000), ('Tanzania', 350000), ('Kenya', 450000), ('Namibia', 250000), ('Botswana', 300000); CREATE TABLE africa_countries (country VARCHAR(50)); INSERT INTO africa_countries (country) VALUES ('South Africa'), ('Tanzania'), ('Kenya'), ('Namibia'), ('Botswana'), ('Egypt');
|
Which African countries have the highest number of eco-tourists?
|
SELECT country FROM africa_eco_tourists WHERE eco_tourists IN (SELECT MAX(eco_tourists) FROM africa_eco_tourists) INTERSECT SELECT country FROM africa_countries;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, amount DECIMAL(10, 2)); INSERT INTO transactions (transaction_id, transaction_date, amount) VALUES (1, '2022-03-01', 100.50), (2, '2022-03-02', 200.75), (3, '2022-03-03', 50.00);
|
What is the total transaction amount for each day in March 2022, sorted by transaction date in ascending order?
|
SELECT transaction_date, SUM(amount) as daily_total FROM transactions WHERE transaction_date >= '2022-03-01' AND transaction_date < '2022-04-01' GROUP BY transaction_date ORDER BY transaction_date ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, area VARCHAR(20), reported_crimes INT, month INT);
|
What is the maximum number of crimes reported in 'Hillside' in the last 3 months?
|
SELECT MAX(reported_crimes) FROM crimes WHERE area = 'Hillside' AND month BETWEEN MONTH(CURRENT_DATE) - 3 AND MONTH(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_sequestration (id INT, year INT, amount FLOAT); INSERT INTO carbon_sequestration (id, year, amount) VALUES (1, 2020, 500.3), (2, 2021, 700.5), (3, 2022, 800.2);
|
What is the total carbon sequestration for 2021?
|
SELECT SUM(amount) FROM carbon_sequestration WHERE year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT); INSERT INTO movies (id, title, genre, release_year) VALUES (1, 'Movie1', 'Action', 2018); INSERT INTO movies (id, title, genre, release_year) VALUES (2, 'Movie2', 'Action', 2019); INSERT INTO movies (id, title, genre, release_year) VALUES (3, 'Movie3', 'Action', 2020);
|
How many 'Action' genre movies were released between 2018 and 2020?
|
SELECT COUNT(*) FROM movies WHERE genre = 'Action' AND release_year BETWEEN 2018 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(255), genre VARCHAR(255)); CREATE TABLE songs (song_id INT, song_name VARCHAR(255), release_year INT, artist_id INT); INSERT INTO artists (artist_id, artist_name, genre) VALUES (1, 'Taylor Swift', 'Pop'); INSERT INTO songs (song_id, song_name, release_year, artist_id) VALUES (1, 'Shake it Off', 2014, 1);
|
Which artists have released songs in the pop genre since 2010?
|
SELECT artists.artist_name FROM artists JOIN songs ON artists.artist_id = songs.artist_id WHERE artists.genre = 'Pop' AND songs.release_year >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name TEXT, rating FLOAT, category TEXT); INSERT INTO products (product_id, name, rating, category) VALUES (1, 'Shirt', 4.5, 'Eco'); INSERT INTO products (product_id, name, rating, category) VALUES (2, 'Pants', 4.7, 'Eco'); INSERT INTO products (product_id, name, rating, category) VALUES (3, 'Jacket', 4.3, 'Eco');
|
Update the rating of the product 'Shirt' in the 'Eco' category to 4.8.
|
UPDATE products SET rating = 4.8 WHERE name = 'Shirt' AND category = 'Eco';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonationDate date, DonationAmount int); INSERT INTO Donors (DonorID, DonorName, DonationDate, DonationAmount) VALUES (1, 'John Doe', '2021-01-01', 500), (2, 'Jane Smith', '2021-02-10', 300), (1, 'John Doe', '2021-12-25', 700);
|
What is the total amount donated by each donor in 2021, grouped by donor name?
|
SELECT DonorName, SUM(DonationAmount) as TotalDonation FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels ( id INT, name VARCHAR(255), country VARCHAR(255), capacity INT); INSERT INTO vessels (id, name, country, capacity) VALUES (1, 'Vessel A', 'USA', 5000), (2, 'Vessel B', 'USA', 6000), (3, 'Vessel C', 'Canada', 4000);
|
What is the total capacity of vessels in a specific country?
|
SELECT SUM(capacity) as total_capacity FROM vessels WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinics (id INT, location VARCHAR(20), latitude FLOAT, longitude FLOAT); CREATE TABLE pharmacies (id INT, location VARCHAR(20), latitude FLOAT, longitude FLOAT);
|
What is the average distance between rural health clinics and the nearest pharmacy?
|
SELECT AVG(ST_Distance(clinics.geom, pharmacies.geom)) FROM clinics, pharmacies WHERE ST_DWithin(clinics.geom, pharmacies.geom, 50000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie (id INT, title VARCHAR(100), production_company VARCHAR(50)); CREATE TABLE tv_show (id INT, title VARCHAR(100), production_company VARCHAR(50)); INSERT INTO movie (id, title, production_company) VALUES (1, 'Movie1', 'ProductionCompany1'); INSERT INTO movie (id, title, production_company) VALUES (2, 'Movie2', 'ProductionCompany2'); INSERT INTO tv_show (id, title, production_company) VALUES (1, 'TVShow1', 'ProductionCompany1');
|
Which movies and TV shows have the same production company?
|
SELECT movie.title, tv_show.title FROM movie INNER JOIN tv_show ON movie.production_company = tv_show.production_company;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditure(trial_id TEXT, country TEXT, year INT, amount FLOAT); INSERT INTO rd_expenditure (trial_id, country, year, amount) VALUES ('Trial1', 'CountryX', 2021, 2500000), ('Trial2', 'CountryY', 2020, 3000000), ('Trial3', 'CountryF', 2021, 2000000), ('Trial4', 'CountryF', 2021, 2200000);
|
What is the minimum R&D expenditure for trials in 'CountryF' in 2021?
|
SELECT MIN(amount) FROM rd_expenditure WHERE country = 'CountryF' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destinations (destination TEXT, region TEXT, sustainability_score FLOAT); INSERT INTO destinations (destination, region, sustainability_score) VALUES ('Bali', 'Asia Pacific', 4.7), ('Paris', 'Europe', 4.5), ('New York', 'North America', 4.3);
|
What is the average sustainable tourism score for each region?
|
SELECT region, AVG(sustainability_score) OVER (PARTITION BY region) AS avg_sustainability_score FROM destinations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biotech_startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO biotech_startups (id, name, location, funding) VALUES (1, 'Startup A', 'India', 12000000); INSERT INTO biotech_startups (id, name, location, funding) VALUES (2, 'Startup B', 'India', 18000000); INSERT INTO biotech_startups (id, name, location, funding) VALUES (3, 'Startup C', 'India', 20000000);
|
What is the maximum funding amount for Indian biotech startups?
|
SELECT MAX(funding) FROM biotech_startups WHERE location = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tour_operators (operator_id INT, name VARCHAR, location VARCHAR, sustainable_practices BOOLEAN); CREATE VIEW european_tour_operators AS SELECT * FROM tour_operators WHERE location LIKE '%%Europe%%'; CREATE VIEW paris_rome_tours AS SELECT * FROM tours WHERE location IN ('Paris', 'Rome');
|
List the names of sustainable tour operators in Europe that offer tours in Paris or Rome.
|
SELECT name FROM european_tour_operators WHERE sustainable_practices = TRUE AND operator_id IN (SELECT operator_id FROM paris_rome_tours);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE song_releases (song_id INT, artist_name VARCHAR(50), genre VARCHAR(20));
|
Which artists have released songs in both the rock and pop genres?
|
SELECT artist_name FROM song_releases WHERE genre IN ('rock', 'pop') GROUP BY artist_name HAVING COUNT(DISTINCT genre) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountryFishSpecies (Country varchar(50), SpeciesID int, SpeciesName varchar(50), Quantity int); INSERT INTO CountryFishSpecies (Country, SpeciesID, SpeciesName, Quantity) VALUES ('Canada', 1, 'Salmon', 5000), ('Canada', 2, 'Tuna', 6000), ('USA', 1, 'Salmon', 7000);
|
What is the total quantity of fish farmed in each country by species in January?
|
SELECT Country, SpeciesName, SUM(Quantity) as TotalQuantity FROM CountryFishSpecies WHERE MONTH(Date) = 1 GROUP BY Country, SpeciesName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), conference VARCHAR(50));CREATE TABLE tickets (ticket_id INT, team_id INT, price DECIMAL(5,2)); INSERT INTO teams VALUES (1, 'TeamA', 'Eastern'), (2, 'TeamB', 'Eastern'), (3, 'TeamC', 'Western'); INSERT INTO tickets VALUES (1, 1, 100.50), (2, 1, 110.00), (3, 2, 95.00), (4, 2, 92.50), (5, 3, 120.00);
|
What was the average ticket price for each team in the eastern conference?
|
SELECT t.conference, AVG(t.price) as avg_price FROM tickets t JOIN teams te ON t.team_id = te.team_id WHERE te.conference = 'Eastern' GROUP BY t.conference;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, worker_name TEXT, race TEXT, mental_health_score INT); INSERT INTO community_health_workers (worker_id, worker_name, race, mental_health_score) VALUES (1, 'John Doe', 'White', 75), (2, 'Jane Smith', 'Black', 80), (3, 'Alice Johnson', 'Asian', 85), (4, 'Bob Brown', 'Hispanic', 70);
|
What is the average mental health score for community health workers by race, ordered by the highest average score?
|
SELECT race, AVG(mental_health_score) as avg_score FROM community_health_workers GROUP BY race ORDER BY avg_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, mental_health_score INT, improvement_1year INT); INSERT INTO students (student_id, mental_health_score, improvement_1year) VALUES (1, 60, 0), (2, 70, 0), (3, 50, 5), (4, 80, -3), (5, 40, 10);
|
What is the percentage of students who have not shown any improvement in their mental health scores in the past year?
|
SELECT (COUNT(student_id) / (SELECT COUNT(student_id) FROM students)) * 100 AS percentage FROM students WHERE improvement_1year = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_projects (id INT, project_name VARCHAR(50), budget INT); INSERT INTO rural_projects (id, project_name, budget) VALUES (1, 'Drip Irrigation', 40000), (2, 'Solar Powered Pumps', 70000), (3, 'Organic Fertilizers', 30000);
|
What are the names of all agricultural innovation projects in the 'rural_projects' table, excluding those with a budget over 50000?
|
SELECT project_name FROM rural_projects WHERE budget <= 50000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (id INT, state VARCHAR(2), cost FLOAT); INSERT INTO wells (id, state, cost) VALUES (1, 'TX', 500000.0), (2, 'TX', 600000.0), (3, 'OK', 400000.0);
|
Find the number of wells drilled in Texas and their total cost
|
SELECT COUNT(*) as num_wells, SUM(cost) as total_cost FROM wells WHERE state = 'TX';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hiv_tests (id INT, test_date DATE, location TEXT); INSERT INTO hiv_tests (id, test_date, location) VALUES (1, '2021-12-31', 'Kenya'); INSERT INTO hiv_tests (id, test_date, location) VALUES (2, '2022-02-05', 'Kenya');
|
How many HIV tests were conducted in Kenya in the last year?
|
SELECT COUNT(*) FROM hiv_tests WHERE location = 'Kenya' AND test_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT); INSERT INTO hotels (hotel_id, hotel_name, country) VALUES (1, 'Heritage Hotel Delhi', 'India'), (2, 'Eco Hotel Cancun', 'Mexico'), (3, 'Cultural Hotel Rome', 'Italy'); CREATE TABLE bookings (booking_id INT, hotel_id INT, revenue INT); INSERT INTO bookings (booking_id, hotel_id, revenue) VALUES (1, 1, 500), (2, 1, 600), (3, 2, 400);
|
What is the total revenue generated by heritage hotels in India and Mexico?
|
SELECT SUM(bookings.revenue) FROM bookings INNER JOIN hotels ON bookings.hotel_id = hotels.hotel_id WHERE hotels.country IN ('India', 'Mexico') AND hotels.hotel_name LIKE '%heritage%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorType TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, DonorType, Country) VALUES (1, 'Ramesh Kumar', 'Individual', 'India'), (2, 'Kiran Reddy', 'Individual', 'India'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount INT); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 500), (2, 1, 750), (3, 2, 1000);
|
What is the average donation amount for individual donors from India?
|
SELECT AVG(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'India' AND Donors.DonorType = 'Individual';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE market_trends (id INT, country VARCHAR(50), year INT, price FLOAT); INSERT INTO market_trends (id, country, year, price) VALUES (1, 'Mexico', 2018, 35.56); INSERT INTO market_trends (id, country, year, price) VALUES (2, 'Colombia', 2017, 28.43);
|
Delete all records from the 'market_trends' table where the 'price' is less than 30
|
DELETE FROM market_trends WHERE price < 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HumanitarianAssistance (Organization VARCHAR(50), Year INT, Amount DECIMAL(10,2)); INSERT INTO HumanitarianAssistance (Organization, Year, Amount) VALUES ('UNHCR', 2019, 500000), ('WFP', 2020, 700000), ('Red Cross', 2019, 600000), ('CARE', 2020, 800000), ('Oxfam', 2021, 900000), ('UNHCR', 2020, 600000), ('WFP', 2021, 800000), ('Red Cross', 2020, 700000), ('CARE', 2021, 900000), ('Oxfam', 2019, 800000);
|
What is the total amount of humanitarian assistance provided by each organization in the last 3 years?
|
SELECT Organization, SUM(Amount) AS TotalAssistance FROM HumanitarianAssistance WHERE Year >= 2019 GROUP BY Organization;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sourcing (id INT, product TEXT, origin TEXT, organic BOOLEAN, local BOOLEAN); INSERT INTO sourcing (id, product, origin, organic, local) VALUES (1, 'Carrots', 'local', true, true), (2, 'Quinoa', 'imported', true, false), (3, 'Chicken', 'local', false, true), (4, 'Olive Oil', 'imported', true, false);
|
What is the total number of organic products sourced from local farms?
|
SELECT COUNT(*) FROM sourcing WHERE organic = true AND local = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_models (model_id INT, model_name TEXT, explainability_score DECIMAL(3,2), domain TEXT, country TEXT); INSERT INTO ai_models (model_id, model_name, explainability_score, domain, country) VALUES (1, 'ExplainableBoosting', 4.65, 'Education', 'Brazil'), (2, 'XGBoost', 4.35, 'Finance', 'Brazil'), (3, 'TabTransformer', 4.55, 'Education', 'Brazil');
|
What is the minimum explainability score for AI models used in education in Brazil?
|
SELECT MIN(explainability_score) as min_explainability_score FROM ai_models WHERE domain = 'Education' AND country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ResearchPapers (ID INT, Title TEXT, Author TEXT, PublicationDate DATE); INSERT INTO ResearchPapers (ID, Title, Author, PublicationDate) VALUES (1, 'Deep Learning for Autonomous Driving', 'John Doe', '2021-03-15'); INSERT INTO ResearchPapers (ID, Title, Author, PublicationDate) VALUES (2, 'Reinforcement Learning in Autonomous Vehicles', 'Jane Smith', '2021-07-22');
|
How many autonomous driving research papers were published per month in 2021?
|
SELECT COUNT(*) FROM ResearchPapers WHERE YEAR(PublicationDate) = 2021 GROUP BY MONTH(PublicationDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, project_type VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO community_development (id, project_type, location, start_date, end_date) VALUES (1, 'Education', 'Afghanistan', '2020-01-01', '2020-12-31'), (2, 'Health', 'Nigeria', '2020-01-01', '2020-12-31');
|
How many community development projects were carried out in 'community_development' table, grouped by 'project_type'?
|
SELECT project_type, COUNT(*) FROM community_development GROUP BY project_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ports VALUES (1, 'Tanjung Priok', 'Indonesia'); INSERT INTO ports VALUES (2, 'Belawan', 'Indonesia'); CREATE TABLE cargo (cargo_id INT, port_id INT, weight_ton FLOAT); INSERT INTO cargo VALUES (1, 1, 5000); INSERT INTO cargo VALUES (2, 1, 7000); INSERT INTO cargo VALUES (3, 2, 3000); INSERT INTO cargo VALUES (4, 2, 4000);
|
What is the maximum cargo weight (in metric tons) for each port?
|
SELECT ports.port_name, MAX(cargo.weight_ton) FROM cargo JOIN ports ON cargo.port_id = ports.port_id GROUP BY ports.port_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, amount DECIMAL, donation_date DATE);
|
What was the average donation amount in 2021 by quarter?
|
SELECT DATE_FORMAT(donation_date, '%Y-%V') as quarter, AVG(amount) as avg_donation_amount FROM donations WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' GROUP BY quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_properties (location VARCHAR(255), dissolved_oxygen FLOAT); INSERT INTO ocean_properties (location, dissolved_oxygen) VALUES ('Arctic Ocean', 5.6), ('Antarctic Ocean', 6.2);
|
What is the minimum dissolved oxygen level recorded in the Arctic Ocean?
|
SELECT MIN(dissolved_oxygen) FROM ocean_properties WHERE location = 'Arctic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_reviews(review_id INT, hotel_id INT, hotel_name TEXT, review_count INT); INSERT INTO hotel_reviews(review_id, hotel_id, hotel_name, review_count) VALUES (1, 1, 'Hotel Eco Ville', 250), (2, 2, 'Eco Chateau', 300), (3, 3, 'Green Provence Hotel', 350), (4, 4, 'Eco Hotel Roma', 280), (5, 5, 'Green Palace Hotel', 400), (6, 6, 'Eco Paradise Hotel', 320), (7, 7, 'Hotel Verde', 260);
|
Find the top 5 most reviewed eco-friendly hotels globally, and display their hotel_id, hotel_name, and review_count.
|
SELECT hotel_id, hotel_name, review_count FROM (SELECT hotel_id, hotel_name, review_count, ROW_NUMBER() OVER (ORDER BY review_count DESC) rn FROM hotel_reviews WHERE hotel_name LIKE 'Eco%' OR hotel_name LIKE 'Green%') subquery WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(100), Age INT, Gender VARCHAR(10), Genre VARCHAR(50)); CREATE TABLE Songs (SongID INT PRIMARY KEY, SongName VARCHAR(100), Genre VARCHAR(50), Listens INT, ArtistID INT, CONSTRAINT FK_Artists FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)); CREATE TABLE Festivals (FestivalID INT PRIMARY KEY, FestivalName VARCHAR(100), City VARCHAR(50), TotalTicketSales INT); CREATE VIEW TotalListens AS SELECT ArtistID, SUM(Listens) as TotalListens FROM Songs GROUP BY ArtistID; CREATE VIEW ArtistFestivals AS SELECT ArtistID, FestivalID FROM Artists INNER JOIN TotalListens ON Artists.ArtistID = TotalListens.ArtistID WHERE TotalListens > 1000000; CREATE VIEW FestivalCities AS SELECT City, COUNT(ArtistFestivals.ArtistID) as NumberOfArtists FROM Festivals INNER JOIN ArtistFestivals ON Festivals.FestivalID = ArtistFestivals.FestivalID GROUP BY City;
|
Identify cities with music festivals having the highest number of artists who have had over 1,000,000 listens?
|
SELECT City, MAX(NumberOfArtists) as HighestNumberOfArtists FROM FestivalCities GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE impact_investing_orgs (name TEXT, country TEXT); INSERT INTO impact_investing_orgs (name, country) VALUES ('Acme Impact', 'USA'), ('GreenTech Initiatives', 'Canada'), ('EcoVentures', 'USA'), ('Global Philanthropic', 'UK'), ('Sustainable Development Foundation', 'Brazil'), ('Green Initiatives', 'India');
|
Which countries have the least number of impact investing organizations?
|
SELECT country, COUNT(*) as org_count FROM impact_investing_orgs GROUP BY country ORDER BY org_count ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, Name TEXT, State TEXT, DonationAmount DECIMAL); INSERT INTO Donors (DonorID, Name, State, DonationAmount) VALUES (1, 'John Doe', 'New York', 50.00), (2, 'Jane Smith', 'Texas', 100.00); CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, State TEXT, LastContactDate DATE); INSERT INTO Volunteers (VolunteerID, Name, State, LastContactDate) VALUES (1, 'James Johnson', 'New York', '2021-08-01'), (2, 'Sarah Lee', 'Texas', '2021-09-15');
|
What is the total number of volunteers and total donation amount for the state of New York?
|
SELECT COUNT(DISTINCT Donors.DonorID) AS TotalVolunteers, SUM(Donors.DonationAmount) AS TotalDonations FROM Donors WHERE Donors.State = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IoTDevices (device_id INT, device_type VARCHAR(20), region VARCHAR(10)); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (1, 'Soil Moisture Sensor', 'West'); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (2, 'Light Sensor', 'East'); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (3, 'Temperature Sensor', 'North');
|
How many IoT devices are present in total?
|
SELECT COUNT(*) FROM IoTDevices;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE causes (cause_id INT, cause TEXT, created_at TIMESTAMP); INSERT INTO causes (cause_id, cause, created_at) VALUES (1, 'Education', '2020-01-01 00:00:00'), (2, 'Health', '2019-01-01 00:00:00'), (3, 'Environment', '2021-01-01 00:00:00'); CREATE TABLE donations (donation_id INT, donor_id INT, cause INT, amount DECIMAL(10,2), donor_country TEXT); INSERT INTO donations (donation_id, donor_id, cause, amount, donor_country) VALUES (1, 1, 1, 500.00, 'Australia'), (2, 2, 1, 300.00, 'USA'), (3, 3, 2, 750.00, 'Canada'), (4, 4, 2, 250.00, 'Australia'), (5, 5, 3, 600.00, 'USA');
|
Which causes received the most funding in the past year, including the total amount donated, for donors from Australia?
|
SELECT c.cause, SUM(d.amount) as total_donated FROM donations d JOIN causes c ON d.cause = c.cause WHERE c.created_at >= DATEADD(year, -1, CURRENT_TIMESTAMP) AND d.donor_country = 'Australia' GROUP BY c.cause ORDER BY total_donated DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Engine_Manufacturers (manufacturer VARCHAR(255), engine_model VARCHAR(255), quantity INT); INSERT INTO Engine_Manufacturers (manufacturer, engine_model, quantity) VALUES ('Pratt & Whitney', 'PW1000G', 500), ('Rolls-Royce', 'Trent XWB', 600), ('General Electric', 'GE9X', 700), ('Rolls-Royce', 'Trent 700', 800), ('CFM International', 'CFM56', 900);
|
Count the number of engines produced by 'Rolls-Royce' and 'CFM International'.
|
SELECT manufacturer, SUM(quantity) FROM Engine_Manufacturers WHERE manufacturer IN ('Rolls-Royce', 'CFM International') GROUP BY manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co_ownership (id INT, property_id INT, owner TEXT, city TEXT, size INT); INSERT INTO co_ownership (id, property_id, owner, city, size) VALUES (1, 101, 'Alice', 'Austin', 1200), (2, 104, 'Alice', 'Seattle', 800), (3, 105, 'Alice', 'Portland', 1000);
|
What is the total number of properties co-owned by 'Alice' in all cities?
|
SELECT COUNT(DISTINCT property_id) FROM co_ownership WHERE owner = 'Alice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_center (center_id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mental_health_center (center_id, name, location) VALUES (1, 'Mental Health Center 1', 'Miami'), (2, 'Mental Health Center 2', 'Miami'), (3, 'Mental Health Center 3', 'New York'); CREATE TABLE patient (patient_id INT, center_id INT, age INT, language VARCHAR(255)); CREATE TABLE therapy_session (session_id INT, patient_id INT, session_language VARCHAR(255));
|
What is the average age of patients who received therapy in Spanish in mental health centers located in Miami?
|
SELECT AVG(patient.age) FROM patient JOIN therapy_session ON patient.patient_id = therapy_session.patient_id JOIN mental_health_center ON patient.center_id = mental_health_center.center_id WHERE mental_health_center.location = 'Miami' AND therapy_session.session_language = 'Spanish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_name TEXT, drilling_date DATE, production_qty INT); INSERT INTO wells (well_name, drilling_date, production_qty) VALUES ('Well K', '2020-12-19', 4000), ('Well L', '2021-04-25', 4200);
|
Delete wells drilled before 2021 in the Amazon Basin.
|
DELETE FROM wells WHERE drilling_date < '2021-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GalleryRevenue (Gallery VARCHAR(255), ArtWork VARCHAR(255), Year INT, Revenue DECIMAL(10,2)); INSERT INTO GalleryRevenue (Gallery, ArtWork, Year, Revenue) VALUES ('Gallery 1', 'Artwork 1', 2021, 500.00), ('Gallery 1', 'Artwork 2', 2021, 400.00), ('Gallery 2', 'Artwork 3', 2021, 750.00), ('Gallery 2', 'Artwork 4', 2021, 1000.00);
|
Which gallery had the highest total revenue in 2021?
|
SELECT Gallery, SUM(Revenue) as TotalRevenue FROM GalleryRevenue WHERE Year = 2021 GROUP BY Gallery ORDER BY TotalRevenue DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_cities_carbon_offsets (id INT, project_id INT, annual_carbon_offsets INT);
|
List the top 10 smart city projects with the highest annual carbon offsets
|
SELECT smart_cities.project_name, smart_cities_carbon_offsets.annual_carbon_offsets FROM smart_cities JOIN smart_cities_carbon_offsets ON smart_cities.id = smart_cities_carbon_offsets.project_id ORDER BY annual_carbon_offsets DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id int, investment_amount float, country varchar(20)); INSERT INTO network_investments (investment_id, investment_amount, country) VALUES (1, 1000000, 'USA'), (2, 2000000, 'Canada'), (3, 1500000, 'Mexico'); CREATE TABLE network_upgrades (upgrade_id int, upgrade_date date, investment_id int); INSERT INTO network_upgrades (upgrade_id, upgrade_date, investment_id) VALUES (1, '2021-01-01', 1), (2, '2021-02-01', 2), (3, '2021-03-01', 3);
|
What is the total number of network infrastructure investments in each country?
|
SELECT country, COUNT(*) as num_investments FROM network_investments GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tech_for_social_good (project_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO tech_for_social_good (project_id, region, budget) VALUES (1, 'Europe', 45000.00), (2, 'North America', 55000.00), (3, 'Europe', 60000.00);
|
What is the maximum budget allocated for technology for social good projects in Europe?
|
SELECT MAX(budget) FROM tech_for_social_good WHERE region = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE binance_smart_chain_wallets (wallet_address VARCHAR(255), interaction_count INT);
|
What is the total number of unique wallet addresses that have interacted with decentralized finance (DeFi) protocols on the Binance Smart Chain network, and what is the average number of interactions per address?
|
SELECT COUNT(DISTINCT wallet_address) as total_wallets, AVG(interaction_count) as avg_interactions FROM binance_smart_chain_wallets WHERE interaction_count > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_health_centers (center_id INT, center_name VARCHAR(100), country VARCHAR(50), num_patients INT); INSERT INTO rural_health_centers (center_id, center_name, country, num_patients) VALUES (1, 'Center A', 'Brazil', 45000), (2, 'Center B', 'Brazil', 38000), (3, 'Center C', 'Argentina', 52000), (4, 'Center D', 'Argentina', 59000);
|
What is the minimum and maximum number of patients served per rural health center in South America, and how many of these centers serve more than 40000 patients?
|
SELECT MIN(num_patients) AS min_patients_per_center, MAX(num_patients) AS max_patients_per_center, COUNT(*) FILTER (WHERE num_patients > 40000) AS centers_with_more_than_40000_patients FROM rural_health_centers WHERE country IN (SELECT name FROM countries WHERE continent = 'South America');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VesselCountry (VesselCountryID INT, VesselCountry VARCHAR(50)); INSERT INTO VesselCountry (VesselCountryID, VesselCountry) VALUES (1, 'USA'); INSERT INTO VesselCountry (VesselCountryID, VesselCountry) VALUES (2, 'Netherlands');
|
Calculate the average length for vessels in each country.
|
SELECT v.VesselCountry, AVG(v.Length) as AverageLength FROM Vessel v JOIN Port p ON v.PortID = p.PortID JOIN VesselCountry vc ON p.Country = vc.VesselCountry GROUP BY v.VesselCountry;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (id INT, category TEXT, price DECIMAL(5,2), is_organic BOOLEAN); INSERT INTO Products (id, category, price, is_organic) VALUES (1, 'Cleanser', 19.99, true), (2, 'Toner', 14.99, false);
|
What is the total revenue of organic skincare products?
|
SELECT SUM(price) FROM Products WHERE is_organic = true AND category = 'Skincare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_capability_programs (provider VARCHAR(50), program VARCHAR(50), country VARCHAR(50)); INSERT INTO financial_capability_programs (provider, program, country) VALUES ('Bank G', 'Financial Literacy for Seniors', 'Japan'), ('Credit Union H', 'Youth Financial Education', 'India');
|
List all financial capability programs offered by providers in Japan?
|
SELECT DISTINCT provider, program FROM financial_capability_programs WHERE country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, GameName VARCHAR(20), Genre VARCHAR(20)); INSERT INTO Games (GameID, GameName, Genre) VALUES (1, 'Fortnite', 'Battle Royale'), (2, 'Minecraft', 'Sandbox'), (3, 'Super Mario Odyssey', 'Platformer'), (4, 'Final Fantasy XV', 'RPG'); CREATE TABLE Players_Games (PlayerID INT, GameID INT); INSERT INTO Players_Games (PlayerID, GameID) VALUES (1, 1), (2, 2), (3, 3), (4, 3), (5, 4); CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'USA'), (2, 30, 'Female', 'Japan'), (3, 15, 'Male', 'Japan'), (4, 35, 'Female', 'Mexico'), (5, 45, 'Male', 'Japan');
|
What is the most played game genre among players from Japan?
|
SELECT Genre, COUNT(*) AS Popularity FROM Players INNER JOIN Players_Games ON Players.PlayerID = Players_Games.PlayerID INNER JOIN Games ON Players_Games.GameID = Games.GameID WHERE Players.Country = 'Japan' GROUP BY Genre ORDER BY Popularity DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE worker_data (id INT, sector VARCHAR(20), wage FLOAT); INSERT INTO worker_data (id, sector, wage) VALUES (1, 'retail', 15.50), (2, 'retail', 16.25), (3, 'manufacturing', 20.00), (4, 'manufacturing', 18.75);
|
How many 'retail' workers are there in total, and what is the average wage for this sector?
|
SELECT COUNT(*), AVG(wage) FROM worker_data WHERE sector = 'retail';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, sustainability_rating FLOAT); CREATE TABLE sustainable_material (id INT PRIMARY KEY, project_id INT, material_name VARCHAR(255), quantity INT);
|
What is the average quantity of sustainable materials used in projects located in California?
|
SELECT AVG(sm.quantity) as avg_quantity FROM project p INNER JOIN sustainable_material sm ON p.id = sm.project_id WHERE p.location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArt (name VARCHAR(255), artists_count INT); INSERT INTO TraditionalArt (name, artists_count) VALUES ('Batik', 135);
|
Delete the Batik traditional art?
|
DELETE FROM TraditionalArt WHERE name = 'Batik';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_images (id INT, image_url VARCHAR(255), location VARCHAR(255), processing_time DATETIME); INSERT INTO satellite_images (id, image_url, location, processing_time) VALUES (1, 'image1.jpg', 'field1', '2022-01-01 12:00:00'), (2, 'image2.jpg', 'field2', '2022-01-01 13:00:00');
|
How many satellite images were processed for the "field1" location?
|
SELECT COUNT(*) FROM satellite_images WHERE location = 'field1';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spain_ride_sharing (id INT, vehicle VARCHAR(20), city VARCHAR(20)); INSERT INTO spain_ride_sharing (id, vehicle, city) VALUES (1, 'bike', 'Madrid'), (2, 'e-scooter', 'Madrid'), (3, 'bike', 'Barcelona'), (4, 'e-scooter', 'Barcelona');
|
Find the total number of shared bikes and e-scooters in Madrid and Barcelona?
|
SELECT COUNT(*) FROM spain_ride_sharing WHERE city IN ('Madrid', 'Barcelona') AND vehicle IN ('bike', 'e-scooter');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, gender VARCHAR(6), school VARCHAR(10)); INSERT INTO faculty (id, gender, school) VALUES (1, 'male', 'Arts'), (2, 'female', 'Engineering');
|
How many female faculty members are there in the Engineering school?
|
SELECT COUNT(*) FROM faculty WHERE gender = 'female' AND school = 'Engineering';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DeliveryRegions (SupplierID INT, Region VARCHAR(50)); INSERT INTO DeliveryRegions (SupplierID, Region) VALUES (1, 'East Coast'); INSERT INTO DeliveryRegions (SupplierID, Region) VALUES (2, 'West Coast'); CREATE TABLE DeliveryTimes (DeliveryID INT, SupplierID INT, DeliveryTime INT); INSERT INTO DeliveryTimes (DeliveryID, SupplierID, DeliveryTime) VALUES (1, 1, 5); INSERT INTO DeliveryTimes (DeliveryID, SupplierID, DeliveryTime) VALUES (2, 2, 7);
|
Find suppliers that deliver to specific regions and their average delivery time.
|
SELECT DR.SupplierID, DR.Region, AVG(DT.DeliveryTime) as AverageDeliveryTime FROM DeliveryRegions DR INNER JOIN DeliveryTimes DT ON DR.SupplierID = DT.SupplierID WHERE DR.Region IN ('East Coast', 'West Coast') GROUP BY DR.SupplierID, DR.Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Clients (ClientID INT, Name VARCHAR(50), Category VARCHAR(50), BillingAmount DECIMAL(10,2)); INSERT INTO Clients (ClientID, Name, Category, BillingAmount) VALUES (1, 'John Doe', 'Personal Injury', 5000.00), (2, 'Jane Smith', 'Personal Injury', 3000.00);
|
Who are the clients with a billing amount greater than $5000 in the 'Personal Injury' category?
|
SELECT Name FROM Clients WHERE Category = 'Personal Injury' AND BillingAmount > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); CREATE TABLE posts (id INT, user_id INT, hashtags VARCHAR(255), post_date DATE);
|
What is the maximum number of followers for users from Germany who have posted about #music in the last month?
|
SELECT MAX(users.followers) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE users.country = 'Germany' AND hashtags LIKE '%#music%' AND post_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_tech (tech VARCHAR(255)); INSERT INTO military_tech (tech) VALUES ('encryption_algorithm'), ('cipher_machine'), ('secure_communications'), ('biometric_access'), ('laser_weapon');
|
What are the military technologies related to encryption in the 'military_tech' table?
|
SELECT tech FROM military_tech WHERE tech LIKE '%encryption%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, capacity INT); INSERT INTO hospitals (id, name, state, capacity) VALUES (1, 'Hospital A', 'NY', 200), (2, 'Hospital B', 'NY', 300), (3, 'Clinic C', 'NY', 50), (4, 'Hospital D', 'CA', 250), (5, 'Clinic E', 'CA', 40);
|
What is the total capacity of hospitals and clinics in each state?
|
SELECT state, SUM(capacity) FROM hospitals GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory(item_id INT, supplier_id INT, quantity INT, cost_price DECIMAL); CREATE TABLE menu_items(menu_item_id INT, name TEXT, supplier_id INT, type TEXT, price DECIMAL);
|
What is the profit margin for each supplier's items?
|
SELECT suppliers.name, SUM((menu_items.price - inventory.cost_price) * inventory.quantity) / SUM(menu_items.price * inventory.quantity) as profit_margin FROM inventory JOIN menu_items ON inventory.item_id = menu_items.menu_item_id JOIN suppliers ON menu_items.supplier_id = suppliers.supplier_id GROUP BY suppliers.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy (id INT PRIMARY KEY, material_name VARCHAR(255), type VARCHAR(255), waste_reduction INT); INSERT INTO circular_economy (id, material_name, type, waste_reduction) VALUES (1, 'Cotton', 'Natural Fibers', 15), (2, 'Hemp', 'Natural Fibers', 10), (3, 'Silk', 'Natural Fibers', 12);
|
Update the circular_economy table to set waste_reduction to 20 for all materials with type as 'Natural Fibers'
|
UPDATE circular_economy SET waste_reduction = 20 WHERE type = 'Natural Fibers';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (id INT PRIMARY KEY, product_id INT, size VARCHAR(10), quantity INT); INSERT INTO inventory (id, product_id, size, quantity) VALUES (1, 1, 'S', 20), (2, 1, 'M', 30), (3, 3, 'L', 25), (4, 3, 'XL', 10);
|
What is the average quantity of product 3 in inventory?
|
SELECT AVG(quantity) FROM inventory WHERE product_id = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_assistance (id INT, name TEXT, age INT, country TEXT, year INT); INSERT INTO medical_assistance (id, name, age, country, year) VALUES (1, 'Zainab Khan', 25, 'Afghanistan', 2022), (2, 'Hamid Karzai', 30, 'Afghanistan', 2022), (3, 'Najibullah Ahmadzai', 35, 'Afghanistan', 2022);
|
What is the name and age of the youngest person who received medical assistance in Afghanistan in 2022?
|
SELECT name, age FROM medical_assistance WHERE country = 'Afghanistan' AND year = 2022 ORDER BY age LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garages (garage_id INT, garage_name VARCHAR(255)); INSERT INTO garages (garage_id, garage_name) VALUES (1, 'Bronx'); CREATE TABLE service (service_id INT, garage_id INT, service_date DATE); INSERT INTO service (service_id, garage_id, service_date) VALUES (1, 1, '2021-12-15');
|
How many vehicles were serviced in the Bronx garage on December 15th, 2021?
|
SELECT COUNT(*) FROM service WHERE garage_id = 1 AND service_date = '2021-12-15';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, HireDate, Department) VALUES (1, '2022-01-01', 'Sales'), (2, '2022-02-15', 'IT'), (3, '2021-07-01', 'HR');
|
How many employees have been hired in the last 6 months in the Sales department?
|
SELECT COUNT(*) FROM Employees WHERE Department = 'Sales' AND HireDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE online_course (id INT, student_id INT, course_name VARCHAR(50), score INT, completed BOOLEAN);
|
What is the average score of students who have completed the online_course for the data_science course?
|
SELECT AVG(score) FROM online_course WHERE course_name = 'data_science' AND completed = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vineyard_soil_moisture (vineyard_name VARCHAR(30), record_date DATE, soil_moisture INT); INSERT INTO vineyard_soil_moisture (vineyard_name, record_date, soil_moisture) VALUES ('Vineyard A', '2022-05-01', 60), ('Vineyard B', '2022-05-01', 65), ('Vineyard C', '2022-05-01', 70);
|
What is the maximum soil moisture level recorded for vineyards in the past week?
|
SELECT MAX(soil_moisture) as max_soil_moisture FROM vineyard_soil_moisture WHERE record_date >= DATEADD(week, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VESSEL_TRAVEL (id INT, vessel_name VARCHAR(50), destination VARCHAR(50), speed FLOAT);
|
Find the average speed of vessels that traveled to both Japan and South Korea
|
SELECT AVG(speed) FROM (SELECT speed FROM VESSEL_TRAVEL WHERE destination = 'Japan' INTERSECT SELECT speed FROM VESSEL_TRAVEL WHERE destination = 'South Korea') AS SubQuery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tank_data (tank_id INT, species VARCHAR(255), water_ph DECIMAL(5,2)); INSERT INTO tank_data (tank_id, species, water_ph) VALUES (1, 'Tilapia', 7.5), (2, 'Salmon', 6.0), (3, 'Tilapia', 7.8), (4, 'Catfish', 7.2), (5, 'Salmon', 6.5);
|
What is the minimum and maximum water pH for each tank in the 'tank_data' table?
|
SELECT tank_id, MIN(water_ph) as min_ph, MAX(water_ph) as max_ph FROM tank_data GROUP BY tank_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farms (id INT, name TEXT, ras BOOLEAN); INSERT INTO farms (id, name, ras) VALUES (1, 'Farm A', TRUE); INSERT INTO farms (id, name, ras) VALUES (2, 'Farm B', FALSE); INSERT INTO farms (id, name, ras) VALUES (3, 'Farm C', TRUE); INSERT INTO farms (id, name, ras) VALUES (4, 'Farm D', FALSE);
|
List all farms in the 'farms' table that use recirculating aquaculture systems (RAS).
|
SELECT name FROM farms WHERE ras = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name VARCHAR(50), grade FLOAT, mental_health_score INT); INSERT INTO students (id, name, grade, mental_health_score) VALUES (1, 'John Doe', 85.5, 70); INSERT INTO students (id, name, grade, mental_health_score) VALUES (2, 'Jane Smith', 68.0, 85);
|
What is the difference in mental health scores between the student with the highest grade and the student with the lowest grade?
|
SELECT (SELECT mental_health_score FROM students WHERE id = (SELECT id FROM students WHERE grade = (SELECT MAX(grade) FROM students))) - (SELECT mental_health_score FROM students WHERE id = (SELECT id FROM students WHERE grade = (SELECT MIN(grade) FROM students)));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(100)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Barcelona'), (2, 'Bayern Munich'); CREATE TABLE matches (match_id INT, team_home_id INT, team_away_id INT, tickets_sold INT); INSERT INTO matches (match_id, team_home_id, team_away_id, tickets_sold) VALUES (1, 1, 2, 5000), (2, 2, 1, 6000);
|
Determine the rank of each team based on their total ticket sales.
|
SELECT team_name, RANK() OVER (ORDER BY total_sales DESC) as team_rank FROM (SELECT team_home_id, SUM(tickets_sold) as total_sales FROM matches GROUP BY team_home_id UNION ALL SELECT team_away_id, SUM(tickets_sold) as total_sales FROM matches GROUP BY team_away_id) total_sales JOIN teams t ON total_sales.team_home_id = t.team_id OR total_sales.team_away_id = t.team_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Location VARCHAR(50), Position VARCHAR(50), Salary DECIMAL(10,2), Gender VARCHAR(50)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Location, Position, Salary, Gender) VALUES (1, 'John', 'Doe', 'IT', 'New York', 'Developer', 80000.00, 'Male'), (2, 'Jane', 'Doe', 'IT', 'New York', 'Developer', 75000.00, 'Female');
|
What is the average salary difference between male and female employees in the same department and location?
|
SELECT AVG(Salary) FROM Employees WHERE Gender = 'Male' INTERSECT SELECT AVG(Salary) FROM Employees WHERE Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2), policy_state VARCHAR(2));
|
Display the policy type and average claim amount for policies with more than one claim in the state of California
|
SELECT policy_type, AVG(claim_amount) FROM claims WHERE policy_state = 'CA' GROUP BY policy_type HAVING COUNT(policy_id) > 1;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.