context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE drug_approval (drug_name VARCHAR(255), approval_body VARCHAR(255), approval_year INT); CREATE TABLE rd_expenditure (drug_name VARCHAR(255), rd_expenditure FLOAT); INSERT INTO drug_approval (drug_name, approval_body, approval_year) VALUES ('DrugA', 'EMA', 2019), ('DrugB', 'EMA', 2018), ('DrugC', 'EMA', 2020), ('DrugD', 'EMA', 2019), ('DrugE', 'EMA', 2021); INSERT INTO rd_expenditure (drug_name, rd_expenditure) VALUES ('DrugA', 45000000), ('DrugB', 35000000), ('DrugC', 55000000), ('DrugD', 40000000), ('DrugE', 60000000);
|
What is the minimum R&D expenditure for drugs approved by the EMA since 2018?
|
SELECT MIN(rd_expenditure) FROM rd_expenditure INNER JOIN drug_approval ON rd_expenditure.drug_name = drug_approval.drug_name WHERE drug_approval.approval_body = 'EMA' AND drug_approval.approval_year >= 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pacific_ocean (temperature FLOAT, month INT, year INT, PRIMARY KEY (temperature, month, year)); INSERT INTO pacific_ocean (temperature, month, year) VALUES (16.5, 5, 2021), (17.3, 5, 2022), (16.8, 5, 2023);
|
What is the average water temperature in the Pacific Ocean for fish farms in May?
|
SELECT AVG(temperature) FROM pacific_ocean WHERE month = 5 AND region = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LoginAttempts (id INT, username VARCHAR(255), date DATE, success BOOLEAN); INSERT INTO LoginAttempts (id, username, date, success) VALUES (7, 'guest', '2022-02-15', FALSE);
|
What is the maximum number of failed login attempts in a single day for the 'guest' account in the last week?
|
SELECT MAX(failed_attempts) FROM (SELECT COUNT(*) AS failed_attempts FROM LoginAttempts WHERE username = 'guest' AND success = FALSE AND date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY date) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dams (name VARCHAR(255), capacity INT); INSERT INTO dams (name, capacity) VALUES ('Dam1', 5000000), ('Dam2', 6000000), ('Hoover', 7000000);
|
Which dams in the 'public_works' schema have a capacity lower than the dam named 'Hoover'?
|
SELECT name FROM dams WHERE capacity < (SELECT capacity FROM dams WHERE name = 'Hoover');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_inventory (product_name VARCHAR(255), product_cost DECIMAL(5,2));
|
Update 'product_cost' in 'product_inventory' table for product 'Bamboo Toothbrush' to '3.50'
|
UPDATE product_inventory SET product_cost = 3.50 WHERE product_name = 'Bamboo Toothbrush';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists destinations (destination_id int, destination_name varchar(50), region_id int); INSERT INTO destinations (destination_id, destination_name, region_id) VALUES (1, 'Seattle', 1), (2, 'Portland', 1), (3, 'London', 2); CREATE TABLE if not exists visitor_stats (visitor_id int, destination_id int, visit_date date, departure_date date); INSERT INTO visitor_stats (visitor_id, destination_id, visit_date, departure_date) VALUES (1, 1, '2022-06-01', '2022-06-04'), (2, 1, '2022-06-03', '2022-06-05'), (3, 2, '2022-06-02', '2022-06-06'), (4, 3, '2022-06-04', '2022-06-08'), (5, 3, '2022-06-30', '2022-07-02');
|
What is the average visit duration by destination?
|
SELECT d.destination_name, AVG(DATEDIFF('day', visit_date, departure_date)) as avg_duration FROM destinations d JOIN visitor_stats vs ON d.destination_id = vs.destination_id GROUP BY d.destination_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_advocacy (union_name TEXT, region TEXT); INSERT INTO union_advocacy (union_name, region) VALUES ('Union A', 'central_region'), ('Union E', 'west_region'), ('Union B', 'south_region'), ('Union F', 'central_region');
|
What are the union names with labor rights advocacy activities in the 'central_region' and 'west_region'?
|
SELECT union_name FROM union_advocacy WHERE region IN ('central_region', 'west_region');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteGeneration (country VARCHAR(255), year INT, waste_generation FLOAT); INSERT INTO WasteGeneration (country, year, waste_generation) VALUES ('USA', 2020, 5000), ('Canada', 2020, 4000), ('Mexico', 2020, 3000);
|
What is the total waste generation in grams for each country in 2020?
|
SELECT country, SUM(waste_generation) FROM WasteGeneration WHERE year = 2020 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
SAME AS ABOVE
|
What is the total salary cost for the entire company?
|
SELECT SUM(Employees.Salary) FROM Employees;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE libraries (library_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), num_books_loaned INT);
|
Which city has the most public libraries in the libraries table?
|
SELECT city FROM libraries WHERE (SELECT COUNT(*) FROM libraries AS e2 WHERE libraries.city = e2.city) = (SELECT MAX(count_libs) FROM (SELECT city, COUNT(*) AS count_libs FROM libraries GROUP BY city) AS e3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT, name TEXT, city TEXT); INSERT INTO teams (id, name, city) VALUES (1, 'Boston Celtics', 'Boston'), (2, 'NY Knicks', 'NY'), (3, 'LA Lakers', 'LA'), (4, 'Atlanta Hawks', 'Atlanta'), (5, 'Chicago Bulls', 'Chicago'), (6, 'Golden State Warriors', 'San Francisco'); CREATE TABLE tickets (id INT, team TEXT, home_team TEXT, price DECIMAL(5,2)); INSERT INTO tickets (id, team, price) VALUES (1, 'Boston Celtics', 125.99), (2, 'NY Knicks', 130.99), (3, 'LA Lakers', 150.99), (4, 'Atlanta Hawks', 160.99), (5, 'Chicago Bulls', 110.99), (6, 'Golden State Warriors', 170.99);
|
Get the names of all teams with an average ticket price above $130.
|
SELECT DISTINCT team as name FROM tickets WHERE price > (SELECT AVG(price) FROM tickets);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (EventID INT, Name TEXT, Country TEXT, Type TEXT); INSERT INTO Events (EventID, Name, Country, Type) VALUES (1, 'Festival de la Candelaria', 'Peru', 'Community Engagement'); INSERT INTO Events (EventID, Name, Country, Type) VALUES (2, 'Mistura', 'Peru', 'Community Engagement');
|
How many community engagement events have been held in Peru?
|
SELECT COUNT(*) FROM Events WHERE Country = 'Peru' AND Type = 'Community Engagement';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (port_code CHAR(3), port_name VARCHAR(20)); INSERT INTO ports (port_code, port_name) VALUES ('LA', 'Los Angeles'), ('NY', 'New York'); CREATE TABLE carriers (carrier_code CHAR(3), carrier_name VARCHAR(20)); INSERT INTO carriers (carrier_code, carrier_name) VALUES ('ABC', 'ABC Shipping'), ('DEF', 'DEF Shipping'), ('GHI', 'GHI Shipping'); CREATE TABLE shipments (carrier_code CHAR(3), port_code CHAR(3)); INSERT INTO shipments (carrier_code, port_code) VALUES ('ABC', 'LA'), ('ABC', 'NY'), ('DEF', 'LA'), ('GHI', 'NY');
|
What are the distinct carrier names that have shipped to port 'LA'?
|
SELECT DISTINCT carriers.carrier_name FROM carriers JOIN shipments ON carriers.carrier_code = shipments.carrier_code JOIN ports ON shipments.port_code = ports.port_code WHERE ports.port_name = 'LA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_temperature (date DATE, temperature DECIMAL(5,2), location VARCHAR(50));
|
Insert a new record into the 'ocean_temperature' table with the following data: date '2022-03-01', temperature 25.5, location 'Pacific Ocean'
|
INSERT INTO ocean_temperature (date, temperature, location) VALUES ('2022-03-01', 25.5, 'Pacific Ocean');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE national_security_spending (id INT, country VARCHAR(255), year INT, amount DECIMAL(10, 2)); INSERT INTO national_security_spending (id, country, year, amount) VALUES (1, 'United States', 2019, 7000000000), (2, 'China', 2019, 4000000000), (3, 'Russia', 2019, 3000000000), (4, 'United Kingdom', 2019, 2000000000);
|
What is the total spending on national security by country?
|
SELECT country, SUM(amount) as total_spending FROM national_security_spending WHERE year = 2019 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_members (member_id INT, name VARCHAR(50), union_id INT); CREATE TABLE unions (union_id INT, union_name VARCHAR(50), involved_in_cb BOOLEAN); INSERT INTO union_members (member_id, name, union_id) VALUES (1, 'John Doe', 1), (2, 'Jane Smith', 1), (3, 'Mike Johnson', 2); INSERT INTO unions (union_id, union_name, involved_in_cb) VALUES (1, 'Healthcare Workers Union', true), (2, 'Teachers Union', false);
|
What is the total number of members in unions that are involved in collective bargaining?
|
SELECT COUNT(DISTINCT um.union_id) FROM union_members um INNER JOIN unions u ON um.union_id = u.union_id WHERE u.involved_in_cb = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE items (id INT, name VARCHAR(50), material VARCHAR(50)); INSERT INTO items (id, name, material) VALUES (1, 'Tote Bag', 'organic cotton'), (2, 'Hoodie', 'organic cotton'), (3, 'Backpack', 'recycled polyester'); CREATE TABLE supplier_items (id INT, supplier_id INT, item_id INT); INSERT INTO supplier_items (id, supplier_id, item_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3); CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO suppliers (id, name, country) VALUES (1, 'Green Trade', 'India'), (2, 'EcoFriendly Co.', 'China'), (3, 'Sustainable Source', 'Brazil');
|
Who are the suppliers of items made from organic cotton?
|
SELECT suppliers.name FROM suppliers INNER JOIN supplier_items ON suppliers.id = supplier_items.supplier_id INNER JOIN items ON supplier_items.item_id = items.id WHERE items.material = 'organic cotton';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, attorney_id INT, category VARCHAR(20), billing_amount DECIMAL); INSERT INTO cases (case_id, attorney_id, category, billing_amount) VALUES (1, 1, 'Civil', 500.00), (2, 2, 'Criminal', 400.00), (3, 1, 'Civil', 700.00), (4, 3, 'Civil', 600.00);
|
What is the maximum billing amount for cases in the 'Civil' category?
|
SELECT MAX(billing_amount) FROM cases WHERE category = 'Civil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Permits_Over_Time (id INT, permit_number TEXT, permit_type TEXT, date DATE, location TEXT);
|
What is the average number of building permits issued per month for commercial construction in the United Kingdom?
|
SELECT AVG(COUNT(*)) FROM Permits_Over_Time WHERE permit_type = 'Commercial' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND location = 'United Kingdom' GROUP BY EXTRACT(YEAR_MONTH FROM date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_contracts (id INT, worker_id INT, occupation VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO union_contracts (id, worker_id, occupation, start_date, end_date) VALUES (1, 1, 'Engineer', '2022-01-01', '2023-12-31'), (2, 2, 'Clerk', '2021-06-15', '2022-06-14'), (3, 3, 'Clerk', '2022-01-01', '2023-12-31'), (4, 4, 'Engineer', '2021-06-15', '2022-06-14');
|
Update all records with the occupation 'Clerk' to 'Admin' in the 'union_contracts' table
|
UPDATE union_contracts SET occupation = 'Admin' WHERE occupation = 'Clerk';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (id INT PRIMARY KEY AUTO_INCREMENT, company_id INT, amount FLOAT, funding_date DATE);
|
Insert a new row into the "funding" table for "GreenTech Solutions" with a funding amount of 5000000 and a funding date of 2022-06-15
|
INSERT INTO funding (company_id, amount, funding_date) VALUES ((SELECT id FROM company WHERE name = 'GreenTech Solutions'), 5000000, '2022-06-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ads (brand VARCHAR(20), category VARCHAR(20), platform VARCHAR(20), spend INT, impressions INT, date DATE); INSERT INTO ads VALUES ('BrandA', 'tech', 'Instagram', 1000, 5000, '2022-01-01'), ('BrandB', 'fashion', 'Instagram', 1500, 7000, '2022-01-01');
|
Find the total ad spend by all brands in the 'tech' category on Instagram in the past year, along with the number of impressions generated.
|
SELECT SUM(a.spend) as total_spend, SUM(a.impressions) as total_impressions FROM ads a WHERE a.platform = 'Instagram' AND a.category = 'tech' AND a.date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(255), rating DECIMAL(2,1), country VARCHAR(255)); INSERT INTO hotels (hotel_id, hotel_name, rating, country) VALUES (1, 'Hotel Tokyo', 4.3, 'Japan'), (2, 'Hotel Mumbai', 4.0, 'India'), (3, 'Hotel Bangkok', 4.7, 'Thailand');
|
What is the average rating of hotels in 'Asia' that have been reviewed more than 50 times?
|
SELECT AVG(rating) FROM (SELECT rating FROM hotels WHERE country = 'Asia' GROUP BY rating HAVING COUNT(*) > 50) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergencies (eid INT, incident_type VARCHAR(255), response_time INT);
|
What is the average response time for emergency calls, categorized by incident type?
|
SELECT i.incident_type, AVG(e.response_time) FROM emergencies e INNER JOIN incidents i ON e.eid = i.iid GROUP BY i.incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Concerts (id INT, state VARCHAR(50), revenue FLOAT);
|
List all concerts in the United States that had a higher revenue than the average revenue in California.
|
SELECT * FROM Concerts WHERE revenue > (SELECT AVG(revenue) FROM Concerts WHERE state = 'California') AND state = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (id INT, name VARCHAR(20), category VARCHAR(20), visitors INT); INSERT INTO Exhibitions VALUES (1, 'Exhibition A', 'Art', 3000), (2, 'Exhibition B', 'Science', 2000), (3, 'Exhibition C', 'Art', 4000), (4, 'Exhibition D', 'History', 5000); CREATE TABLE Visitors (id INT, exhibition_id INT, age INT, country VARCHAR(20)); INSERT INTO Visitors VALUES (1, 1, 35, 'USA'), (2, 1, 45, 'Canada'), (3, 2, 25, 'Mexico'), (4, 3, 50, 'Brazil'), (5, 3, 30, 'USA');
|
What is the total number of visitors who attended exhibitions in the 'History' category, and the percentage of visitors who attended each exhibition in this category?
|
SELECT E.category, E.name, SUM(E.visitors) AS total_visitors, (SUM(E.visitors) * 100.0 / (SELECT SUM(visitors) FROM Exhibitions WHERE category = 'History')) AS percentage FROM Exhibitions E INNER JOIN Visitors V ON E.id = V.exhibition_id WHERE E.category = 'History' GROUP BY E.category, E.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students (StudentID INT PRIMARY KEY, Name VARCHAR(50), Disability VARCHAR(20));
|
Update the disability type for all students with IDs between 100 and 200 to 'Learning'
|
UPDATE Students SET Disability = 'Learning' WHERE StudentID BETWEEN 100 AND 200;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_ratings (hotel_id INT, country TEXT, rating FLOAT, has_gym BOOLEAN); INSERT INTO hotel_ratings (hotel_id, country, rating, has_gym) VALUES (1, 'Egypt', 4.2, true), (2, 'Morocco', 4.5, false), (3, 'South Africa', 4.7, true), (4, 'Egypt', 4.3, false), (5, 'Kenya', 4.6, true);
|
What is the maximum and minimum rating of hotels in 'Africa' with a gym?
|
SELECT MAX(rating) as max_rating, MIN(rating) as min_rating FROM hotel_ratings WHERE country LIKE 'Africa%' AND has_gym = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Pedro Martinez', 'Mexico');
|
What is the total number of registered users from each country?
|
SELECT country, COUNT(*) OVER (PARTITION BY country) as total_users FROM users;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecyclingRates (country VARCHAR(50), recycling_rate FLOAT); INSERT INTO RecyclingRates (country, recycling_rate) VALUES ('Nigeria', 0.15), ('Egypt', 0.2), ('South Africa', 0.35);
|
What is the minimum recycling rate for the top 3 most populous countries in Africa?
|
SELECT MIN(recycling_rate) FROM (SELECT * FROM RecyclingRates WHERE country IN ('Nigeria', 'Egypt', 'South Africa') ORDER BY recycling_rate DESC LIMIT 3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports(port_id INT, port_name TEXT);CREATE TABLE cargo(cargo_id INT, port_id INT);INSERT INTO ports VALUES (1,'Port A'),(2,'Port B'),(3,'Port C'),(4,'Port D'),(5,'Port E');INSERT INTO cargo VALUES (1,1),(2,1),(3,2),(4,3),(5,5);
|
List the total number of cargo items handled at each port, including ports that have not handled any cargo. Display the port name and its corresponding total cargo count, even if the count is zero.
|
SELECT p.port_name, COUNT(c.cargo_id) as total_cargo FROM ports p LEFT JOIN cargo c ON p.port_id = c.port_id GROUP BY p.port_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(20), assets DECIMAL(10,2)); INSERT INTO customers (id, name, region, assets) VALUES (1, 'John Doe', 'Southwest', 50000.00), (2, 'Jane Smith', 'Northeast', 75000.00), (3, 'Michael Johnson', 'North America', 30000.00), (4, 'Sarah Lee', 'North America', 40000.00);
|
What is the minimum assets value for customers in 'North America'?
|
SELECT MIN(assets) FROM customers WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), type VARCHAR(50)); CREATE TABLE cargo (cargo_id INT, vessel_id INT, port_id INT, weight FLOAT, handling_date DATE);
|
Identify vessels that have handled cargo at both the ports of 'Hong Kong' and 'Shanghai'.
|
SELECT v.vessel_name FROM vessels v JOIN cargo c ON v.vessel_id = c.vessel_id WHERE c.port_id IN (SELECT port_id FROM ports WHERE port_name = 'Hong Kong') AND c.port_id IN (SELECT port_id FROM ports WHERE port_name = 'Shanghai') GROUP BY v.vessel_name HAVING COUNT(DISTINCT c.port_id) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibitions (id INT, city VARCHAR(50), visitor_count INT); INSERT INTO exhibitions (id, city, visitor_count) VALUES (1, 'Tokyo', 100), (2, 'Tokyo', 200), (3, 'Tokyo', 300);
|
What is the total number of visitors who attended exhibitions in Tokyo?
|
SELECT city, SUM(visitor_count) FROM exhibitions WHERE city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ice_hockey_games(id INT, team VARCHAR(50), location VARCHAR(50), year INT, attendance INT); INSERT INTO ice_hockey_games(id, team, location, year, attendance) VALUES (1, 'Boston Bruins', 'TD Garden', 2020, 17500), (2, 'Buffalo Sabres', 'KeyBank Center', 2020, 15000), (3, 'Montreal Canadiens', 'Bell Centre', 2020, 21000);
|
What is the average attendance for ice hockey games in the Northeast in the 2020 season?
|
SELECT AVG(attendance) FROM ice_hockey_games WHERE location IN ('TD Garden', 'KeyBank Center', 'Bell Centre') AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VRAdoption (Region VARCHAR(20), HeadsetsSold INT); INSERT INTO VRAdoption (Region, HeadsetsSold) VALUES ('Canada', 80000), ('United States', 500000), ('United Kingdom', 150000);
|
Get the total number of VR headsets sold in Canada and the United Kingdom
|
SELECT SUM(HeadsetsSold) FROM VRAdoption WHERE Region IN ('Canada', 'United Kingdom')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (id INT, hotel_id INT, country TEXT, engagements INT); INSERT INTO virtual_tours (id, hotel_id, country, engagements) VALUES (1, 1, 'Japan', 300), (2, 2, 'Australia', 450), (3, 3, 'New Zealand', 500), (4, 4, 'China', 250); CREATE TABLE hotels (id INT, name TEXT, region TEXT); INSERT INTO hotels (id, name, region) VALUES (1, 'Hotel A', 'Asia-Pacific'), (2, 'Hotel B', 'Asia-Pacific'), (3, 'Hotel C', 'Asia-Pacific'), (4, 'Hotel D', 'Asia-Pacific');
|
Which country in the 'Asia-Pacific' region has the most virtual tour engagements?
|
SELECT country, MAX(engagements) FROM virtual_tours v JOIN hotels h ON v.hotel_id = h.id WHERE h.region = 'Asia-Pacific' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ParkingTickets (ID INT, Gender VARCHAR(50), City VARCHAR(50)); INSERT INTO ParkingTickets VALUES (1, 'Male', 'San Francisco'), (2, 'Female', 'San Francisco'), (3, 'Other', 'San Francisco');
|
How many parking tickets were issued by gender in San Francisco?
|
SELECT Gender, COUNT(*) OVER (PARTITION BY Gender) AS Count FROM ParkingTickets WHERE City = 'San Francisco';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InfrastructureProjects (id INT, category VARCHAR(20), cost FLOAT); INSERT INTO InfrastructureProjects (id, category, cost) VALUES (1, 'Roads', 500000), (2, 'Bridges', 750000), (3, 'Buildings', 900000);
|
What is the maximum cost of a project in the 'Buildings' category?
|
SELECT MAX(cost) FROM InfrastructureProjects WHERE category = 'Buildings';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (species VARCHAR(50), animal_count INT);
|
Identify the top 3 animal populations in the 'animal_population' table
|
SELECT species, SUM(animal_count) as total FROM animal_population GROUP BY species ORDER BY total DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete_wellbeing (athlete_id INT PRIMARY KEY, name VARCHAR(100), age INT, sport VARCHAR(50), wellbeing_score INT); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport, wellbeing_score) VALUES (1, 'Aisha Smith', 25, 'Basketball', 80);
|
Create a view with athletes above 25
|
CREATE VIEW athlete_view AS SELECT * FROM athlete_wellbeing WHERE age > 25;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (event_id INT, event_name VARCHAR(50)); CREATE TABLE Attendees (attendee_id INT, event_id INT, age INT); INSERT INTO Events (event_id, event_name) VALUES (3, 'Poetry Slam'); INSERT INTO Attendees (attendee_id, event_id, age) VALUES (4, 3, 18), (5, 3, 28), (6, 3, 38);
|
How many people attended the 'Poetry Slam' event by age group?
|
SELECT e.event_name, a.age, COUNT(a.attendee_id) FROM Events e JOIN Attendees a ON e.event_id = a.event_id WHERE e.event_name = 'Poetry Slam' GROUP BY e.event_name, a.age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name VARCHAR(255), material VARCHAR(50), price DECIMAL(5,2)); INSERT INTO products (product_id, name, material, price) VALUES (1, 'T-Shirt', 'Recycled Polyester', 19.99), (2, 'Hoodie', 'Organic Cotton', 49.99), (3, 'Pants', 'Tencel', 39.99), (4, 'Shorts', 'Hemp', 29.99), (5, 'Dress', 'Bamboo Viscose', 59.99), (6, 'Skirt', 'Recycled Polyester', 24.99);
|
What is the average price of products made from each material?
|
SELECT material, AVG(price) FROM products GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, type VARCHAR(20)); INSERT INTO events (id, type) VALUES (1, 'Theater'), (2, 'Dance'), (3, 'Workshop'); CREATE TABLE attendees (id INT, event_id INT); INSERT INTO attendees (id, event_id) VALUES (1, 1), (2, 1), (3, 2), (1, 3), (4, 2);
|
What is the total number of attendees for performing arts events and workshops, excluding repeat attendees?
|
SELECT COUNT(DISTINCT a.id) FROM attendees a JOIN events e ON a.event_id = e.id WHERE e.type IN ('Theater', 'Workshop');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT PRIMARY KEY, GameName VARCHAR(50), GamingCommunity VARCHAR(50)); CREATE TABLE GameSessions (SessionID INT PRIMARY KEY, GameName VARCHAR(50), Playtime MINUTE, FOREIGN KEY (GameName) REFERENCES Games(GameName)); INSERT INTO Games (GameID, GameName, GamingCommunity) VALUES (1, 'ClashOfClans', 'MobileGamingCommunity'), (2, 'PUBGMobile', 'MobileGamingCommunity'), (3, 'FortniteMobile', 'MobileGamingCommunity'); INSERT INTO GameSessions (SessionID, GameName, Playtime) VALUES (1, 'ClashOfClans', 120), (2, 'ClashOfClans', 150), (3, 'PUBGMobile', 200), (4, 'FortniteMobile', 250);
|
What is the total playtime (in minutes) for each game in the "MobileGamingCommunity"?
|
SELECT GameName, SUM(Playtime) FROM GameSessions JOIN Games ON GameSessions.GameName = Games.GameName WHERE Games.GamingCommunity = 'MobileGamingCommunity' GROUP BY GameName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (location VARCHAR(50), capacity INT);
|
Update records in landfill_capacity table where capacity is less than 20000 tons
|
UPDATE landfill_capacity SET capacity = capacity + 5000 WHERE capacity < 20000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Country VARCHAR(255)); INSERT INTO Players (PlayerID, Age, Country) VALUES (1, 25, 'USA'); INSERT INTO Players (PlayerID, Age, Country) VALUES (2, 30, 'Canada'); CREATE TABLE Events (EventID INT, Location VARCHAR(255)); INSERT INTO Events (EventID, Location) VALUES (1, 'New York'); INSERT INTO Events (EventID, Location) VALUES (2, 'Toronto'); CREATE TABLE Winners (PlayerID INT, EventID INT); INSERT INTO Winners (PlayerID, EventID) VALUES (1, 1); INSERT INTO Winners (PlayerID, EventID) VALUES (2, 2);
|
What is the average age of players who have won an esports event in North America?
|
SELECT AVG(Players.Age) FROM Players INNER JOIN Winners ON Players.PlayerID = Winners.PlayerID INNER JOIN Events ON Winners.EventID = Events.EventID WHERE Events.Location LIKE '%North America%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE highways (id INT, name TEXT, length_km FLOAT, location TEXT, built YEAR); INSERT INTO highways (id, name, length_km, location, built) VALUES (1, 'Autobahn A9', 530.5, 'Germany', 1936); INSERT INTO highways (id, name, length_km, location, built) VALUES (2, 'I-90', 498.7, 'USA', 1956); INSERT INTO highways (id, name, length_km, location, built) VALUES (3, 'Trans-Canada', 7821, 'Canada', 1962); INSERT INTO highways (id, name, length_km, location, built) VALUES (4, 'Hume', 820, 'Australia', 1928);
|
Rank the highways in Australia by length.
|
SELECT name, length_km, RANK() OVER(ORDER BY length_km DESC) as length_rank FROM highways WHERE location = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, subscription_type VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id, subscription_type) VALUES (1, 'Postpaid'), (2, 'Prepaid');
|
Which mobile subscribers have a subscription type of 'Postpaid'?
|
SELECT subscriber_id FROM mobile_subscribers WHERE subscription_type = 'Postpaid';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, crime_date DATE, severity_score FLOAT); INSERT INTO crimes VALUES (1, '2021-01-01', 8.5), (2, '2022-01-01', 9.2);
|
What is the maximum crime severity score in each year?
|
SELECT YEAR(crime_date) AS year, MAX(severity_score) FROM crimes GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy_projects (project_id INT, project_name VARCHAR(50), city VARCHAR(50), installed_capacity FLOAT, certification_level VARCHAR(50)); INSERT INTO renewable_energy_projects (project_id, project_name, city, installed_capacity, certification_level) VALUES (1, 'Solar Farm 1', 'CityA', 10000.0, 'Gold'), (2, 'Wind Farm 1', 'CityB', 15000.0, 'Platinum'), (3, 'Hydro Plant 1', 'CityA', 20000.0, 'Silver');
|
What is the installed capacity and location of renewable energy projects with certification level?
|
SELECT city, installed_capacity, certification_level FROM renewable_energy_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, location VARCHAR(50)); INSERT INTO mining_operations (id, location) VALUES (1, 'Canada'), (2, 'Peru'), (3, 'Chile'); CREATE TABLE employees (id INT, age INT, position VARCHAR(50), operation_id INT); INSERT INTO employees (id, age, position, operation_id) VALUES (1, 35, 'Engineer', 1), (2, 42, 'Manager', 1), (3, 28, 'Operator', 2), (4, 31, 'Supervisor', 3);
|
What is the average age of all employees working in mining operations across Canada, Peru, and Chile?
|
SELECT AVG(e.age) FROM employees e INNER JOIN mining_operations m ON e.operation_id = m.id WHERE m.location IN ('Canada', 'Peru', 'Chile');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_missions (id INT PRIMARY KEY, name VARCHAR(50), objective VARCHAR(50)); INSERT INTO space_missions (id, name, objective) VALUES (1, 'Mars Pathfinder', 'Mars exploration'), (2, 'Galileo', 'Jupiter exploration'), (3, 'Cassini-Huygens', 'Saturn exploration'), (4, 'Voyager 1', 'Interstellar mission'), (5, 'New Horizons', 'Pluto exploration');
|
Delete all records from the 'space_missions' table that are not related to Mars exploration
|
DELETE FROM space_missions WHERE objective NOT LIKE '%Mars exploration%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (Region VARCHAR(255)); INSERT INTO Regions (Region) VALUES ('Hokkaido'), ('Tohoku'), ('Kanto'), ('Chubu'), ('Kansai'), ('Chugoku'), ('Shikoku'), ('Kyushu'); CREATE TABLE Performances (PerformanceID INT, Name VARCHAR(255), Region VARCHAR(255), Year INT, PRIMARY KEY (PerformanceID));
|
What is the average number of traditional art performances per year in Japan, partitioned by region?
|
SELECT Region, AVG(Year) AS AvgYear FROM (SELECT Region, YEAR(PerformanceDate) AS Year, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY YEAR(PerformanceDate)) AS RN FROM Performances) AS PerformancesPerYear WHERE RN = 1 GROUP BY Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Rocket_Engine_Types (ID INT, Engine_Type VARCHAR(20), Failure_Rate DECIMAL(5,2)); INSERT INTO Rocket_Engine_Types (ID, Engine_Type, Failure_Rate) VALUES (1, 'Kerosene', 0.05), (2, 'Liquid Hydrogen', 0.02), (3, 'Solid', 0.01);
|
What is the failure rate of rocket engines by type?
|
SELECT Engine_Type, Failure_Rate FROM Rocket_Engine_Types;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArts (Id INT, Art TEXT, Description TEXT);
|
Insert new traditional art records for 'Kente Cloth' and 'Batik'
|
INSERT INTO TraditionalArts (Id, Art, Description) VALUES (1, 'Kente Cloth', 'Handwoven fabric from Ghana'), (2, 'Batik', 'Indonesian art of wax-resist dyeing');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spending_Categories (id INT, category VARCHAR(50), amount FLOAT); INSERT INTO Spending_Categories (id, category, amount) VALUES (1, 'Threat Intelligence', 500000), (2, 'Incident Response', 750000); CREATE TABLE Spending_Mapping (spending_id INT, category_id INT); INSERT INTO Spending_Mapping (spending_id, category_id) VALUES (1, 1), (2, 2), (3, 1);
|
List all the unique defense contract categories and their total spending?
|
SELECT Spending_Categories.category, SUM(Spending_Mapping.spending_id) AS total_spending FROM Spending_Categories JOIN Spending_Mapping ON Spending_Categories.id = Spending_Mapping.category_id GROUP BY Spending_Categories.category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), HireDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, HireDate) VALUES (1, 'Tony', 'Stark', 'Finance', '2021-06-12');
|
Retrieve the ID, name, and department of employees who were hired after the latest hire date in the 'Finance' department, excluding employees from the 'Finance' department.
|
SELECT EmployeeID, FirstName, Department FROM Employees WHERE Department <> 'Finance' AND HireDate > (SELECT MAX(HireDate) FROM Employees WHERE Department = 'Finance');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists carbon_offset_projects (project_id INT PRIMARY KEY, project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO carbon_offset_projects (project_id, project_name, start_date, end_date) VALUES (1, 'Reforestation', '2022-07-01', '2023-01-01'), (2, 'Soil Carbon Sequestration', '2021-07-15', '2022-12-31'), (3, 'Blue Carbon', '2023-02-01', '2024-01-31');
|
List the names of carbon offset projects that started after 2021-06-30 and were completed before 2023-01-01.
|
SELECT project_name FROM carbon_offset_projects WHERE start_date > '2021-06-30' AND end_date < '2023-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication (campaign_name VARCHAR(255), country VARCHAR(255), launch_date DATE);
|
How many climate communication campaigns were launched in each country during 2021?
|
SELECT country, COUNT(DISTINCT campaign_name) FROM climate_communication WHERE EXTRACT(YEAR FROM launch_date) = 2021 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, sector VARCHAR(20), year INT, waste_generated FLOAT); INSERT INTO waste_generation (id, sector, year, waste_generated) VALUES (1, 'residential', 2018, 120.2), (2, 'residential', 2017, 110.1), (3, 'commercial', 2018, 180.5);
|
What is the total amount of waste generated in the year 2018 in the residential sector?
|
SELECT SUM(waste_generated) FROM waste_generation WHERE sector = 'residential' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE railway_info (railway_id INT, railway_name VARCHAR(50)); CREATE TABLE railway_lengths (railway_id INT, railway_length INT); INSERT INTO railway_info (railway_id, railway_name) VALUES (1, 'Trans-Siberian Railway'), (2, 'California High-Speed Rail'), (3, 'China Railway High-speed'); INSERT INTO railway_lengths (railway_id, railway_length) VALUES (1, 9289), (2, 1300), (3, 25000);
|
List all the railways along with their lengths from the 'railway_info' and 'railway_lengths' tables.
|
SELECT railway_info.railway_name, railway_lengths.railway_length FROM railway_info INNER JOIN railway_lengths ON railway_info.railway_id = railway_lengths.railway_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (id INT, drug VARCHAR(255), country VARCHAR(255), status VARCHAR(255)); INSERT INTO clinical_trials (id, drug, country, status) VALUES (1, 'Drug Z', 'France', 'Completed');
|
How many clinical trials are ongoing or have been completed for drug Z in France?
|
SELECT COUNT(*) FROM clinical_trials WHERE drug = 'Drug Z' AND country = 'France' AND status IN ('Completed', 'Ongoing');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Age INT, CountryOfOrigin VARCHAR(50)); INSERT INTO Astronauts (AstronautID, Name, Age, CountryOfOrigin) VALUES (1, 'Anna Ivanova', 35, 'Russia'), (2, 'John Doe', 45, 'USA'), (3, 'Pedro Gomez', 50, 'Mexico'); CREATE TABLE MedicalExaminations (ExaminationID INT, AstronautID INT, ExaminationDate DATE); INSERT INTO MedicalExaminations (ExaminationID, AstronautID, ExaminationDate) VALUES (1, 1, '2020-01-01'), (2, 1, '2021-01-01'), (3, 2, '2020-01-01'), (4, 3, '2021-01-01');
|
How many medical examinations have been conducted on each astronaut?
|
SELECT Astronauts.Name, COUNT(*) FROM Astronauts INNER JOIN MedicalExaminations ON Astronauts.AstronautID = MedicalExaminations.AstronautID GROUP BY Astronauts.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (PolicyholderID INT, ClaimAmount DECIMAL(10,2), PolicyState VARCHAR(20)); INSERT INTO Claims (PolicyholderID, ClaimAmount, PolicyState) VALUES (7, 1200, 'New York'), (8, 1500, 'New York');
|
What is the total claim amount for policyholders living in 'New York'?
|
SELECT SUM(ClaimAmount) FROM Claims WHERE PolicyState = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_compliant_banks (id INT, bank_name VARCHAR(50), country VARCHAR(50), num_loans INT); INSERT INTO shariah_compliant_banks (id, bank_name, country, num_loans) VALUES (1, 'Kuveyt Turk Participation Bank', 'Turkey', 5000), (2, 'Albaraka Turk Participation Bank', 'Turkey', 6000);
|
Which Shariah-compliant banks have the highest number of loans in Turkey?
|
SELECT country, bank_name, num_loans, RANK() OVER (ORDER BY num_loans DESC) as rank FROM shariah_compliant_banks WHERE country = 'Turkey';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE org_roles (role VARCHAR(10), gender VARCHAR(6), count INT); INSERT INTO org_roles (role, gender, count) VALUES ('Volunteer', 'Female', 20), ('Volunteer', 'Male', 10), ('Staff', 'Female', 25), ('Staff', 'Male', 15);
|
What is the total number of male and female volunteers and staff in the organization?
|
SELECT gender, SUM(count) FROM org_roles GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation(waste_type VARCHAR(50), location VARCHAR(50), year INT, amount FLOAT); INSERT INTO waste_generation(waste_type, location, year, amount) VALUES('Plastic', 'RuralArea', 2021, 10000), ('Paper', 'RuralArea', 2021, 12000), ('Glass', 'RuralArea', 2021, 15000), ('Metal', 'RuralArea', 2021, 18000);
|
What is the total amount of waste generation in kg for each waste type in 'RuralArea' in 2021?
|
SELECT waste_type, SUM(amount) FROM waste_generation WHERE location = 'RuralArea' AND year = 2021 GROUP BY waste_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_incidents (id INT, borough VARCHAR(255), incident_type VARCHAR(255), reported_date DATE); INSERT INTO emergency_incidents (id, borough, incident_type, reported_date) VALUES (1, 'Manhattan', 'Fire', '2022-01-01'); INSERT INTO emergency_incidents (id, borough, incident_type, reported_date) VALUES (2, 'Brooklyn', 'Medical Emergency', '2022-01-02');
|
What is the total number of emergency incidents in each borough of New York City in 2022?
|
SELECT borough, SUM(number_of_incidents) FROM (SELECT borough, COUNT(*) as number_of_incidents FROM emergency_incidents WHERE borough IN ('Manhattan', 'Brooklyn', 'Queens', 'Bronx', 'Staten Island') AND reported_date >= '2022-01-01' AND reported_date < '2023-01-01' GROUP BY borough) as incidents_by_borough GROUP BY borough;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClinicalTrials (clinical_trial_id TEXT, medicine_name TEXT); INSERT INTO ClinicalTrials (clinical_trial_id, medicine_name) VALUES ('Trial002', 'DrugY');
|
Delete 'Trial002' from 'ClinicalTrials' table.
|
DELETE FROM ClinicalTrials WHERE clinical_trial_id = 'Trial002';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Infrastructure_Projects_Bangladesh (id INT, country VARCHAR(50), year INT, cost FLOAT); INSERT INTO Infrastructure_Projects_Bangladesh (id, country, year, cost) VALUES (1, 'Bangladesh', 2018, 120000.0), (2, 'Bangladesh', 2019, 150000.0), (3, 'Bangladesh', 2020, 130000.0);
|
What was the total cost of all infrastructure projects in Bangladesh in 2018?
|
SELECT SUM(cost) FROM Infrastructure_Projects_Bangladesh WHERE country = 'Bangladesh' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE health_centers (id INT, name TEXT, location TEXT, beds INT); INSERT INTO health_centers (id, name, location, beds) VALUES (1, 'Health Center A', 'Rural Alaska', 25); INSERT INTO health_centers (id, name, location, beds) VALUES (4, 'Health Center D', 'Rural Guam', 40);
|
Update the number of beds in Rural Health Center D in Guam to 50.
|
UPDATE health_centers SET beds = 50 WHERE name = 'Health Center D' AND location = 'Rural Guam';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name VARCHAR(50), role VARCHAR(50)); INSERT INTO employees (id, name, role) VALUES (1, 'John Doe', 'Employee'), (2, 'Jane Smith', 'Contractor'), (3, 'Alice Johnson', 'Intern');
|
What is the total number of employees, contractors, and interns in the mining industry?
|
SELECT SUM(CASE WHEN role = 'Employee' THEN 1 ELSE 0 END) AS employees, SUM(CASE WHEN role = 'Contractor' THEN 1 ELSE 0 END) AS contractors, SUM(CASE WHEN role = 'Intern' THEN 1 ELSE 0 END) AS interns FROM employees;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_life_habitats (id INT, name VARCHAR(255), water_temp DECIMAL(5,2), ph DECIMAL(3,2)); INSERT INTO marine_life_habitats (id, name, water_temp, ph) VALUES (1, 'Coral Reef', 28.5, 8.2), (2, 'Open Ocean', 18.0, 8.0), (3, 'Estuary', 22.0, 7.5);
|
What is the average water temperature and pH level for all marine life habitats?
|
SELECT AVG(water_temp) AS avg_water_temp, AVG(ph) AS avg_ph FROM marine_life_habitats;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, state TEXT, donation_amount DECIMAL); INSERT INTO donors (id, name, state, donation_amount) VALUES (1, 'John Doe', 'California', 150.00), (2, 'Jane Smith', 'Texas', 200.00);
|
What is the average donation amount from donors in California?
|
SELECT AVG(donation_amount) FROM donors WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geothermal_plants (id INT, name VARCHAR(255), capacity INT); INSERT INTO geothermal_plants (id, name, capacity) VALUES (1, 'Sample Geothermal Plant', 60);
|
Find the names of geothermal_plants with capacity greater than 50 MW.
|
SELECT name FROM geothermal_plants WHERE capacity > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT PRIMARY KEY, brand_name VARCHAR(50)); CREATE TABLE products (product_id INT, brand_id INT, PRIMARY KEY (product_id, brand_id), FOREIGN KEY (brand_id) REFERENCES brands(brand_id)); CREATE TABLE vegan_products (product_id INT, brand_id INT, PRIMARY KEY (product_id, brand_id), FOREIGN KEY (product_id) REFERENCES products(product_id), FOREIGN KEY (brand_id) REFERENCES brands(brand_id)); INSERT INTO brands (brand_id, brand_name) VALUES (1, 'Kat Von D'), (2, 'LUSH'), (3, 'The Body Shop'); INSERT INTO products (product_id, brand_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3); INSERT INTO vegan_products (product_id, brand_id) VALUES (1, 1), (2, 1), (3, 2), (5, 3);
|
Which brands offer the most vegan-friendly products?
|
SELECT brand_name, COUNT(*) as product_count FROM vegan_products JOIN brands ON vegan_products.brand_id = brands.brand_id GROUP BY brand_id ORDER BY product_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, language VARCHAR(255), timestamp TIMESTAMP); INSERT INTO posts (id, language, timestamp) VALUES (1, 'English', '2022-01-01 10:00:00'), (2, 'Spanish', '2022-01-02 12:00:00'), (3, 'French', '2022-01-03 14:00:00'), (4, 'English', '2022-01-01 10:00:00'), (5, 'Spanish', '2022-01-02 12:00:00');
|
What is the total number of posts in a given language for a given time period?
|
SELECT language, COUNT(*) FROM posts WHERE language IN ('English', 'Spanish') AND timestamp BETWEEN '2022-01-01' AND '2022-01-05' GROUP BY language;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, name, location, production) VALUES (1, 'A1', 'North Sea', 10000);
|
What are the production figures for wells in the North Sea?
|
SELECT production FROM wells WHERE location = 'North Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT PRIMARY KEY, ingredient_name VARCHAR(50)); CREATE TABLE lipsticks (product_id INT, ingredient_id INT, FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id)); INSERT INTO lipsticks (product_id, ingredient_id) VALUES (1, 1), (1, 2), (2, 2), (2, 3); CREATE TABLE foundation (product_id INT, ingredient_id INT, FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id)); INSERT INTO foundation (product_id, ingredient_id) VALUES (1, 2), (1, 3), (2, 3), (2, 4);
|
Which ingredients are used in both lipstick and foundation products?
|
SELECT ingredient_name FROM ingredients WHERE ingredient_id IN (SELECT ingredient_id FROM lipsticks INTERSECT SELECT ingredient_id FROM foundation);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africa_tourists (visited_africa BOOLEAN, took_safari BOOLEAN); INSERT INTO africa_tourists (visited_africa, took_safari) VALUES (TRUE, TRUE), (TRUE, FALSE), (FALSE, FALSE), (TRUE, TRUE), (FALSE, TRUE), (TRUE, FALSE);
|
What is the percentage of tourists who visited Africa in 2021 and took a guided safari tour?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM africa_tourists WHERE visited_africa = TRUE)) AS percentage FROM africa_tourists WHERE visited_africa = TRUE AND took_safari = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Streams (id INT, genre VARCHAR(20), date DATE, streams INT); INSERT INTO Streams (id, genre, date, streams) VALUES (1, 'Folk', '2022-07-01', 100), (2, 'Pop', '2022-06-15', 150), (3, 'Folk', '2022-07-10', 200);
|
What is the minimum number of streams for Folk music in July?
|
SELECT MIN(streams) FROM Streams WHERE genre = 'Folk' AND date BETWEEN '2022-07-01' AND '2022-07-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forest_carbon (id INT, country VARCHAR(30), region VARCHAR(20), year INT, carbon_value FLOAT);
|
Identify the top 3 countries with the highest carbon sequestration values in temperate forests for the last 5 years.
|
SELECT country, SUM(carbon_value) as total_carbon_value FROM forest_carbon WHERE region = 'Temperate' GROUP BY country ORDER BY total_carbon_value DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance_adaptation (country VARCHAR(50), year INT, project_type VARCHAR(50), amount FLOAT); INSERT INTO climate_finance_adaptation (country, year, project_type, amount) VALUES ('Australia', 2015, 'Climate Adaptation', 5000000), ('New Zealand', 2016, 'Climate Adaptation', 6000000), ('Papua New Guinea', 2017, 'Climate Adaptation', 7000000);
|
What is the total number of climate finance investments in Oceania for climate adaptation projects between 2015 and 2017?
|
SELECT SUM(amount) FROM climate_finance_adaptation WHERE country IN ('Australia', 'New Zealand', 'Papua New Guinea') AND project_type = 'Climate Adaptation' AND year BETWEEN 2015 AND 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_floor_depth (location VARCHAR(255), depth INTEGER);
|
Find the average depth of the ocean floor in the 'atlantic_ocean'.
|
SELECT AVG(depth) FROM ocean_floor_depth WHERE location = 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (id INT, name VARCHAR(50), age INT); INSERT INTO Employees (id, name, age) VALUES (1, 'John Doe', 35), (2, 'Jane Smith', 30);
|
What is the average age of employees in the company?
|
SELECT AVG(age) FROM Employees;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication (project VARCHAR(50), country VARCHAR(50), roi FLOAT, date DATE); INSERT INTO climate_communication (project, country, roi, date) VALUES ('Climate News', 'UK', 1.2, '2020-01-01'); INSERT INTO climate_communication (project, country, roi, date) VALUES ('Climate Talks', 'Germany', -0.5, '2020-01-01');
|
Delete all climate communication projects with a negative ROI.
|
DELETE FROM climate_communication WHERE roi < 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (id INT, project_name VARCHAR(100), capacity FLOAT, country VARCHAR(50)); INSERT INTO renewable_projects (id, project_name, capacity, country) VALUES (1, 'Renewable Project 1', 100.2, 'Germany'), (2, 'Renewable Project 2', 150.3, 'Sweden');
|
What is the total capacity of renewable energy projects in each country, in MW?
|
SELECT country, SUM(capacity) FROM renewable_projects GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (id INT PRIMARY KEY, species VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO animals (id, species, population, region) VALUES (1, 'Polar Bear', 3000, 'Arctic');
|
Update population of 'Polar Bear' in animals table by 20%
|
WITH cte AS (UPDATE animals SET population = population * 1.2 WHERE species = 'Polar Bear') SELECT * FROM animals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (product_id INT, category VARCHAR(255), production_date DATE); INSERT INTO production (product_id, category, production_date) VALUES (1, 'CategoryA', '2021-01-01'), (2, 'CategoryB', '2021-03-15'), (3, 'CategoryA', '2021-07-01');
|
What is the earliest and latest production date for each product category?
|
SELECT category, MIN(production_date) AS earliest_production_date, MAX(production_date) AS latest_production_date FROM production GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MiningLocation (id INT, name VARCHAR(255)); INSERT INTO MiningLocation (id, name) VALUES (1, 'Mountain X'), (2, 'Hill Y'); CREATE TABLE EnvironmentalImpact (location_id INT, score INT); INSERT INTO EnvironmentalImpact (location_id, score) VALUES (1, 70), (2, 80);
|
List all unique mining locations and their environmental impact scores.
|
SELECT DISTINCT l.name, e.score FROM MiningLocation l, EnvironmentalImpact e WHERE l.id = e.location_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, Program TEXT, Budget DECIMAL); INSERT INTO Programs (ProgramID, Program, Budget) VALUES (1, 'Education Equality', 25000);
|
Update the budget for 'Education Equality' program to 30000
|
UPDATE Programs SET Budget = 30000 WHERE Program = 'Education Equality';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT PRIMARY KEY, company_name VARCHAR(255), location VARCHAR(255), ethical_certification VARCHAR(255), last_audit_date DATE);
|
Create a table named 'suppliers' with columns for company name, location, ethical_certification, and last_audit_date
|
CREATE TABLE suppliers (id INT PRIMARY KEY, company_name VARCHAR(255), location VARCHAR(255), ethical_certification VARCHAR(255), last_audit_date DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_test (vehicle_type VARCHAR(10), safety_rating INT, sale_region VARCHAR(10));
|
Calculate the difference in safety ratings between hybrid and electric vehicles in the 'safety_test' table, for each region.
|
SELECT sale_region, AVG(safety_rating) FILTER (WHERE vehicle_type = 'Electric') - AVG(safety_rating) FILTER (WHERE vehicle_type = 'Hybrid') AS safety_diff FROM safety_test GROUP BY sale_region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hydroelectric_power_plants (id INT, name VARCHAR(100), country VARCHAR(50), capacity FLOAT, completion_date DATE); INSERT INTO hydroelectric_power_plants (id, name, country, capacity, completion_date) VALUES (1, 'Hydroelectric Power Plant A', 'China', 2000, '2010-01-01'); INSERT INTO hydroelectric_power_plants (id, name, country, capacity, completion_date) VALUES (2, 'Hydroelectric Power Plant B', 'Brazil', 2500, '2011-01-01');
|
What is the maximum installed capacity of hydroelectric power plants in each of the top 3 countries with the most hydroelectric power plants?
|
SELECT country, MAX(capacity) AS max_capacity FROM hydroelectric_power_plants GROUP BY country ORDER BY max_capacity DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_trams(id INT, tram_number INT, city VARCHAR(20), fare FLOAT);
|
What is the average fare of public trams in Melbourne?
|
SELECT AVG(fare) FROM public_trams WHERE city = 'Melbourne';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, category VARCHAR(50), recycled BOOLEAN); INSERT INTO products (product_id, category, recycled) VALUES (101, 'Electronics', TRUE), (102, 'Clothing', FALSE), (103, 'Furniture', TRUE), (104, 'Clothing', TRUE), (105, 'Electronics', FALSE);
|
How many products in each category are made from recycled materials?
|
SELECT category, COUNT(*) AS product_count FROM products WHERE recycled = TRUE GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (sector VARCHAR(20), name VARCHAR(50), description TEXT); INSERT INTO vulnerabilities (sector, name, description) VALUES ('Financial', 'Heartbleed', '...');
|
What are the names and descriptions of all vulnerabilities found in the financial sector?
|
SELECT name, description FROM vulnerabilities WHERE sector = 'Financial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing_countries (country VARCHAR(50), manufacturing_sector VARCHAR(50), total_emissions INT); INSERT INTO manufacturing_countries (country, manufacturing_sector, total_emissions) VALUES ('India', 'textile_recycling', 35000);
|
What is the number of employees in the 'textile_recycling' sector in 'India'?
|
SELECT total_employees FROM manufacturing_countries WHERE country = 'India' AND manufacturing_sector = 'textile_recycling';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (EventID INT, EventName TEXT, State TEXT); INSERT INTO Events (EventID, EventName, State) VALUES (1001, 'Community Pottery Workshop', 'NY'), (1002, 'Weaving Techniques Demonstration', 'CA'), (1003, 'Traditional Dance Festival', 'TX');
|
Calculate the number of traditional arts events in each state of the USA, ordered by the number of events in descending order.
|
SELECT State, COUNT(EventID) AS Number_Of_Events FROM Events WHERE State IN ('NY', 'CA', 'TX', 'FL', 'IL') GROUP BY State ORDER BY Number_Of_Events DESC;
|
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.