context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE water_waste (waste_id INT, waste_date DATE, city VARCHAR(50), amount FLOAT); INSERT INTO water_waste (waste_id, waste_date, city, amount) VALUES (1, '2019-07-01', 'Dallas', 100), (2, '2019-07-02', 'Houston', 120), (3, '2019-07-03', 'Dallas', 150);
|
Identify the total amount of water wasted in the city of Dallas for the month of July in 2019
|
SELECT SUM(amount) as total_wasted FROM water_waste WHERE waste_date BETWEEN '2019-07-01' AND '2019-07-31' AND city = 'Dallas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite_Launches (launch_date DATE, country VARCHAR(255), success BOOLEAN); INSERT INTO Satellite_Launches (launch_date, country, success) VALUES ('2020-01-01', 'Japan', TRUE), ('2020-02-01', 'Brazil', FALSE), ('2020-03-01', 'Japan', TRUE), ('2020-04-01', 'Brazil', TRUE), ('2020-05-01', 'Japan', FALSE);
|
What is the total number of successful satellite launches by Japanese and Brazilian space programs?
|
SELECT SUM(success) FROM (SELECT success FROM Satellite_Launches WHERE country IN ('Japan', 'Brazil')) AS subquery WHERE success = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Game VARCHAR(50), Wins INT); INSERT INTO Players (PlayerID, PlayerName, Game, Wins) VALUES (1, 'Sophia Garcia', 'Virtual Reality Chess Extreme', 35), (2, 'Daniel Kim', 'Rhythm Game 2023', 40), (3, 'Lila Hernandez', 'Racing Simulator 2022', 28), (4, 'Kenji Nguyen', 'Rhythm Game 2023', 45);
|
What is the minimum number of wins for players who play "Rhythm Game 2023"?
|
SELECT MIN(Wins) FROM Players WHERE Game = 'Rhythm Game 2023';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT PRIMARY KEY, name VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); CREATE TABLE songs (id INT PRIMARY KEY, title VARCHAR(255), artist_id INT, released DATE); CREATE TABLE streams (id INT PRIMARY KEY, song_id INT, user_id INT, stream_date DATE, FOREIGN KEY (song_id) REFERENCES songs(id)); CREATE TABLE users (id INT PRIMARY KEY, gender VARCHAR(50), age INT, country VARCHAR(255));
|
List the top 3 most streamed songs for users from South America.
|
SELECT s.title, COUNT(s.id) AS total_streams FROM streams s JOIN users u ON s.user_id = u.id WHERE u.country = 'South America' GROUP BY s.title ORDER BY total_streams DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (article_id INT, title VARCHAR(50), category VARCHAR(20), country VARCHAR(20)); INSERT INTO articles (article_id, title, category, country) VALUES (1, 'Politics in 2022', 'politics', 'USA'), (2, 'British Politics', 'politics', 'UK'), (3, 'Indian Economy', 'economy', 'India');
|
What is the total number of articles and the percentage of articles in the 'politics' category, for each country?
|
SELECT country, COUNT(*) as article_count, 100.0 * COUNT(CASE WHEN category = 'politics' THEN 1 END) / COUNT(*) as politics_percentage FROM articles GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, state VARCHAR(2), parity_law TEXT, year INT);
|
List all states that have mental health parity laws
|
SELECT state FROM mental_health_parity WHERE parity_law IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE survey_results (id VARCHAR(10), mine_id VARCHAR(10), survey_date DATE, result VARCHAR(50));
|
Insert a new record into the 'survey_results' table with ID '001', mine_id 'Mine_001', survey_date '2022-03-15', and result 'Satisfactory'
|
INSERT INTO survey_results (id, mine_id, survey_date, result) VALUES ('001', 'Mine_001', '2022-03-15', 'Satisfactory');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, age INT, donation FLOAT); INSERT INTO donors (id, name, age, donation) VALUES (1, 'John Doe', 35, 500.00); INSERT INTO donors (id, name, age, donation) VALUES (2, 'Jane Smith', 25, 200.00); INSERT INTO donors (id, name, age, donation) VALUES (3, 'Bob Johnson', 45, 1000.00);
|
What is the total amount donated by donors with an age between 20 and 30?
|
SELECT SUM(donation) FROM donors WHERE age BETWEEN 20 AND 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_table_2021 (union_name VARCHAR(255), total_injuries INT); INSERT INTO union_table_2021 (union_name, total_injuries) VALUES ('Union A', 350), ('Union B', 450), ('Union C', 550), ('Union D', 600);
|
What is the percentage of total workplace injuries for Union D, in the year 2021?
|
SELECT (SUM(total_injuries) / (SELECT SUM(total_injuries) FROM union_table_2021) * 100) as injury_percentage FROM union_table_2021 WHERE union_name = 'Union D' AND YEAR(incident_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (id INT, name TEXT, total_population INT, vaccinated_individuals INT); INSERT INTO states (id, name, total_population, vaccinated_individuals) VALUES (1, 'State A', 1000000, 600000), (2, 'State B', 700000, 450000), (3, 'State C', 1200000, 900000), (4, 'State D', 800000, 550000);
|
What is the number of vaccinated individuals and total population in each state, ordered by the percentage of vaccinated individuals, descending?
|
SELECT name, total_population, vaccinated_individuals, (vaccinated_individuals * 100.0 / total_population) as vaccination_percentage FROM states ORDER BY vaccination_percentage DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors(id INT, name TEXT, country TEXT, donation INT); INSERT INTO donors(id, name, country, donation) VALUES (1, 'USAID', 'USA', 50000), (2, 'European Union', 'Belgium', 40000); CREATE TABLE donations(id INT, donor_id INT, initiative_id INT, amount INT); INSERT INTO donations(id, donor_id, initiative_id, amount) VALUES (1, 1, 1, 10000), (2, 2, 2, 15000);
|
Who are the top 5 donors to community development initiatives in Guatemala?
|
SELECT d.name FROM donors d JOIN (SELECT donor_id, SUM(amount) as total_donation FROM donations GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5) dd ON d.id = dd.donor_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sites (site_id INT, site_name VARCHAR(50), country VARCHAR(50), year INT, visitors INT); INSERT INTO sites (site_id, site_name, country, year, visitors) VALUES (1, 'Chichen Itza', 'Mexico', 2021, 18000), (2, 'Teotihuacan', 'Mexico', 2021, 16000), (3, 'Machu Picchu', 'Peru', 2021, 19000), (4, 'Nazca Lines', 'Peru', 2021, 14000);
|
Which cultural heritage sites in Mexico and Peru had over 15000 visitors in 2021?
|
SELECT COUNT(*) FROM sites WHERE country IN ('Mexico', 'Peru') AND year = 2021 AND visitors > 15000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AttorneyInfo (AttorneyID INT, Cases INT, Amount DECIMAL(10,2)); INSERT INTO AttorneyInfo (AttorneyID, Cases, Amount) VALUES (1, 1000, 5000), (2, 1500, 7000);
|
Present the total number of cases and billing amount for each attorney.
|
SELECT a.Name, SUM(a.Cases) AS TotalCases, SUM(a.Amount) AS TotalBilling FROM AttorneyInfo a GROUP BY a.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE port (port_id INT, name TEXT, created_at DATETIME);CREATE TABLE crane (crane_id INT, port_id INT, name TEXT);CREATE TABLE container (container_id INT, crane_id INT, weight INT, created_at DATETIME);INSERT INTO port VALUES (4, 'Hong Kong', '2022-01-01');
|
What is the average number of containers handled per day by each crane in 'Hong Kong'?
|
SELECT crane.name, AVG(COUNT(container.container_id)) FROM crane JOIN port ON crane.port_id = port.port_id JOIN container ON crane.crane_id = container.crane_id WHERE port.name = 'Hong Kong' GROUP BY crane.name, DATE(container.created_at);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists oil_wells (id INT PRIMARY KEY, well_name TEXT, region TEXT, type TEXT); INSERT INTO oil_wells (id, well_name, region, type) VALUES (1, 'Well A', 'Onshore', 'Oil'), (2, 'Well B', 'Offshore', 'Oil'), (3, 'Well C', 'Onshore', 'Gas');
|
What is the total number of oil wells in the 'Onshore' and 'Offshore' regions?
|
SELECT COUNT(*) FROM oil_wells WHERE region IN ('Onshore', 'Offshore') AND type = 'Oil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_site_labor_hours (site_id INT, hours INT, labor_date DATE); INSERT INTO mining_site_labor_hours (site_id, hours, labor_date) VALUES (1, 250, '2022-01-01'), (1, 275, '2022-01-02'), (1, 300, '2022-02-01'), (1, 350, '2022-02-02'), (1, 400, '2022-03-01'), (1, 450, '2022-03-02');
|
How many labor hours have been spent on mining site A in each month of the past year?
|
SELECT DATE_FORMAT(labor_date, '%Y-%m') AS month, SUM(hours) FROM mining_site_labor_hours WHERE site_id = 1 AND labor_date >= '2022-01-01' AND labor_date < '2023-01-01' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_streams (user_id INT, artist_id INT, stream_date DATE); CREATE TABLE artist_albums (artist_id INT, release_date DATE);
|
What is the number of unique users who have streamed songs from artists who have released a new album in the last year?
|
SELECT COUNT(DISTINCT u.user_id) FROM user_streams u JOIN artist_albums a ON u.artist_id = a.artist_id WHERE a.release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT, name VARCHAR(255), ethnicity VARCHAR(255)); INSERT INTO authors (id, name, ethnicity) VALUES (1, 'Toni Morrison', 'African American'); CREATE TABLE books (id INT, title VARCHAR(255), sentiment FLOAT, author_id INT); INSERT INTO books (id, title, sentiment, author_id) VALUES (1, 'Beloved', 8.5, 1);
|
What is the average sentiment score for African American authors' books?
|
SELECT AVG(sentiment) FROM books JOIN authors ON books.author_id = authors.id WHERE authors.ethnicity = 'African American'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (category VARCHAR(255), price NUMERIC); INSERT INTO menu (category, price) VALUES ('Appetizers', 10), ('Entrees', 20), ('Desserts', 15);
|
What is the total revenue for each menu category this month, with a 15% discount applied?
|
SELECT category, SUM(price * 0.85) FROM menu GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SafetyTestingVehicle (TestID INT, Vehicle VARCHAR(20), TestResult VARCHAR(10)); CREATE TABLE AutonomousDrivingData (TestID INT, Vehicle VARCHAR(20), MaxSpeed FLOAT, MinSpeed FLOAT);
|
Show the vehicles that were tested in safety tests but not included in autonomous driving research.
|
SELECT Vehicle FROM SafetyTestingVehicle WHERE Vehicle NOT IN (SELECT Vehicle FROM AutonomousDrivingData);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, name, type, budget) VALUES (1, 'Solar Irrigation', 'Agricultural Innovation', 150000.00), (2, 'Wind Turbines', 'Rural Infrastructure', 200000.00); CREATE TABLE community_development (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO community_development (id, name, type, budget) VALUES (1, 'Green Spaces', 'Community Development', 75000.00), (2, 'Smart Street Lighting', 'Community Development', 120000.00), (3, 'Cultural Center', 'Community Development', 100000.00);
|
Which rural infrastructure projects have a higher budget than any community development project?
|
SELECT name, budget FROM rural_infrastructure WHERE budget > (SELECT MAX(budget) FROM community_development);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics_sales (product VARCHAR(255), country VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255), vegan BOOLEAN); CREATE TABLE countries (country VARCHAR(255), continent VARCHAR(255)); INSERT INTO countries (country, continent) VALUES ('USA', 'North America'); CREATE VIEW q2_sales AS SELECT * FROM cosmetics_sales WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30';
|
Find the number of vegan nail polish products sold in the USA in Q2 2021.
|
SELECT COUNT(*) FROM q2_sales JOIN cosmetics ON q2_sales.product = cosmetics.product JOIN countries ON q2_sales.country = countries.country WHERE cosmetics.product_category = 'Nail Polishes' AND cosmetics.vegan = true AND countries.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Organizations (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50));
|
What is the total donation amount for organizations with the word "effective" in their names, in the 'Donations' and 'Organizations' tables?
|
SELECT SUM(amount) as total_effective_donations FROM Donations JOIN Organizations ON Donations.organization_id = Organizations.id WHERE Organizations.name LIKE '%effective%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE racial_composition (id INT, state VARCHAR(50), population INT, african_american INT); INSERT INTO racial_composition (id, state, population, african_american) VALUES (1, 'Louisiana', 4648794, 1168666);
|
What is the percentage of the population that is African American in Louisiana?
|
SELECT (african_american * 100.0 / population) FROM racial_composition WHERE state = 'Louisiana';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing (id INT, company VARCHAR(255), mass FLOAT); INSERT INTO SpacecraftManufacturing (id, company, mass) VALUES (1, 'Aerospace Inc.', 5000.0), (2, 'Galactic Corp.', 7000.0), (3, 'Space Tech', 6500.0);
|
Which spacecraft have a mass between 5000 and 7000 tons?
|
SELECT * FROM SpacecraftManufacturing WHERE mass BETWEEN 5000 AND 7000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InvestmentStrategies (InvestmentStrategyID INT, CustomerID INT, TransactionDate DATE, TransactionAmount DECIMAL(10,2));
|
Find the minimum transaction date for each investment strategy in the "InvestmentStrategies" table.
|
SELECT InvestmentStrategyID, MIN(TransactionDate) as MinTransactionDate FROM InvestmentStrategies GROUP BY InvestmentStrategyID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronaut (Id INT, Name VARCHAR(50), SpaceMissionId INT, FlightExperience VARCHAR(50), TotalTimeInSpace INT);
|
What is the total time spent in space for astronauts with flight experience in military aviation?
|
SELECT SUM(TotalTimeInSpace) FROM Astronaut WHERE FlightExperience LIKE '%military%aviation%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare.CommunityHealthWorker( worker_id INT PRIMARY KEY, name VARCHAR(100), cultural_competency_score FLOAT); INSERT INTO healthcare.CommunityHealthWorker (worker_id, name, cultural_competency_score) VALUES (1, 'Jane Smith', 85.5), (2, 'Maria Garcia', 92.3), (3, 'David Kim', 88.7), (4, 'Fatima Patel', 93.1);
|
Show the total number of community health workers
|
SELECT COUNT(*) FROM healthcare.CommunityHealthWorker;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_generation (country VARCHAR(255), energy_source VARCHAR(255), percentage INT); INSERT INTO energy_generation (country, energy_source, percentage) VALUES ('Mexico', 'Fossil Fuels', 80), ('Mexico', 'Renewable', 20);
|
What is the percentage of energy generated from fossil fuels in Mexico?
|
SELECT percentage FROM energy_generation WHERE country = 'Mexico' AND energy_source = 'Fossil Fuels';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (id INT, client_type VARCHAR(20), asset_value DECIMAL(15, 2)); INSERT INTO clients (id, client_type, asset_value) VALUES (1, 'Institutional', 5000000.00), (2, 'Retail', 100000.00), (3, 'Institutional', 7000000.00);
|
What is the total value of assets for institutional clients?
|
SELECT SUM(asset_value) FROM clients WHERE client_type = 'Institutional';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (id INT, region VARCHAR(50), completion_year INT);
|
How many renewable energy projects were completed in each region in the past 3 years?
|
SELECT region, COUNT(*) FROM renewable_projects WHERE completion_year >= YEAR(CURRENT_DATE) - 3 GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50), risk_level INT); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE);
|
What is the daily transaction volume for high-risk customers in the past week?
|
SELECT t.transaction_date, c.customer_id, COUNT(t.transaction_id) as transaction_count FROM transactions t INNER JOIN customers c ON t.customer_id = c.customer_id WHERE c.risk_level > 7 AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) GROUP BY t.transaction_date, c.customer_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Daily_Transportation (id INT, city VARCHAR(50), trips INT, date DATE);
|
What is the maximum number of public transportation trips taken in a single day in each city?
|
SELECT city, MAX(trips) FROM Daily_Transportation GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (date DATE, cuisine VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO restaurant_revenue (date, cuisine, revenue) VALUES ('2021-06-01', 'Italian', 5000.00), ('2021-06-01', 'Mexican', 7000.00), ('2021-06-02', 'Italian', 6000.00), ('2021-06-02', 'Mexican', 8000.00);
|
What was the total revenue for each cuisine type in June 2021?
|
SELECT cuisine, SUM(revenue) as total_revenue FROM restaurant_revenue WHERE date in ('2021-06-01', '2021-06-02') GROUP BY cuisine;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tech_companies (name TEXT, industry TEXT, year_founded INTEGER, location TEXT); INSERT INTO tech_companies (name, industry, year_founded, location) VALUES ('Google', 'Cloud Computing', 1998, 'Mountain View'); INSERT INTO tech_companies (name, industry, year_founded, location) VALUES ('Microsoft', 'Cloud Computing', 1975, 'Redmond'); INSERT INTO tech_companies (name, industry, year_founded, location) VALUES ('Amazon', 'E-commerce', 1994, 'Seattle');
|
Delete all records in the "tech_companies" table where the "industry" is "cloud computing"
|
DELETE FROM tech_companies WHERE industry = 'Cloud Computing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ticket_sales (id INT PRIMARY KEY, event_id INT, sport VARCHAR(50), tickets_sold INT, price DECIMAL(5,2)); CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(100), date DATE, location VARCHAR(100));
|
What is the total revenue generated from ticket sales for each sport in the 'ticket_sales' table?
|
SELECT t.sport, SUM(t.price * t.tickets_sold) as total_revenue FROM ticket_sales t JOIN events e ON t.event_id = e.id GROUP BY t.sport;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name VARCHAR(255));CREATE TABLE crimes (id INT, district_id INT, crime_type VARCHAR(255), crime_date DATE, crime_count INT);
|
Identify the most common types of crimes in each district.
|
SELECT district_name, crime_type, SUM(crime_count) AS total_crimes FROM districts d JOIN crimes c ON d.district_id = c.district_id GROUP BY district_name, crime_type ORDER BY total_crimes DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Retail (customer_id INT, name VARCHAR(50), division VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO Retail (customer_id, name, division, account_balance) VALUES (1, 'John Doe', 'Retail', 5000.00), (2, 'Jane Smith', 'Retail', 12000.00), (3, 'Jim Brown', 'Retail', 7000.00);
|
What is the maximum account balance for customers in the Retail division, excluding customers with account balances below $10,000?
|
SELECT MAX(account_balance) FROM Retail WHERE division = 'Retail' AND account_balance >= 10000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Relief_Aid (id INT, disaster_id INT, organization VARCHAR(50), amount FLOAT, date DATE); INSERT INTO Relief_Aid (id, disaster_id, organization, amount, date) VALUES (4, 5, 'UNICEF', 9000, '2021-09-05'); CREATE TABLE Disaster (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO Disaster (id, name, location, type, start_date, end_date) VALUES (5, 'Typhoon', 'Country X', 'Water', '2021-09-01', '2021-09-10');
|
What is the total amount of relief aid provided by 'UNICEF' for disasters in 'Country X'?
|
SELECT SUM(Relief_Aid.amount) FROM Relief_Aid WHERE Relief_Aid.organization = 'UNICEF' AND Relief_Aid.disaster_id IN (SELECT Disaster.id FROM Disaster WHERE Disaster.location = 'Country X')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Country) VALUES (1, 'John Doe', 25, 'USA'), (2, 'Jane Smith', 28, 'Canada'), (3, 'James Johnson', 30, 'England'), (4, 'Emily Davis', 24, 'France');
|
What's the total number of players from North America and Europe?
|
SELECT COUNT(*) FROM Players WHERE Country IN ('USA', 'Canada', 'England', 'France');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OnlineStore (id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO OnlineStore (id, date, revenue) VALUES (1, '2022-01-01', 500.00); INSERT INTO OnlineStore (id, date, revenue) VALUES (2, '2022-01-02', 750.00);
|
Calculate the total revenue for the museum's online store for the last year
|
SELECT SUM(revenue) FROM OnlineStore WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 365 DAY) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Funding (id INT, state VARCHAR(2), program VARCHAR(20), amount FLOAT); INSERT INTO Funding (id, state, program, amount) VALUES (1, 'NY', 'Art for All', 150000.00), (2, 'CA', 'Art Reach', 200000.00), (3, 'NY', 'Unseen Art', 120000.00);
|
What is the total funding received by art programs for unrepresented communities in New York and California?
|
SELECT SUM(amount) FROM Funding WHERE state IN ('NY', 'CA') AND program IN ('Art for All', 'Art Reach', 'Unseen Art') AND state IN (SELECT state FROM Communities WHERE underrepresented = 'yes');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_population (community VARCHAR(50), year INT, population INT); INSERT INTO community_population (community, year, population) VALUES ('Inuit', 2000, 50000), ('Inuit', 2001, 50500);
|
What is the population trend in Arctic indigenous communities since 2000?
|
SELECT c.community, c.year, c.population, LAG(c.population) OVER (PARTITION BY c.community ORDER BY c.year) as prev_year_population FROM community_population c;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_employment (id INT, sector TEXT, hire_date DATE); INSERT INTO veteran_employment (id, sector, hire_date) VALUES (1, 'IT', '2021-10-01'), (2, 'Finance', '2021-04-01');
|
Determine the number of veterans hired in the 'IT' sector in the last financial year.
|
SELECT COUNT(*) FROM veteran_employment WHERE sector = 'IT' AND hire_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (item_name VARCHAR(255), price DECIMAL(5,2));
|
Delete records in the menu_items table where the item_name is 'Fish Tacos'
|
DELETE FROM menu_items WHERE item_name = 'Fish Tacos';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50), medals_won INT, medal VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport, medals_won, medal) VALUES (1, 'Serena Williams', 'Tennis', 23, 'Gold'), (2, 'Roger Federer', 'Tennis', 20, 'Gold'), (3, 'Novak Djokovic', 'Tennis', 18, 'Gold');
|
List all athletes who have won a gold medal in any sport.
|
SELECT name FROM athletes WHERE medal = 'Gold';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargos(id INT, vessel_id INT, cargo_weight FLOAT); CREATE TABLE vessel_locations(id INT, vessel_id INT, location VARCHAR(50), timestamp TIMESTAMP);
|
What was the average cargo weight for vessels in the North sea in the past week?
|
SELECT AVG(cargo_weight) FROM cargos JOIN vessel_locations ON cargos.vessel_id = vessel_locations.vessel_id WHERE location LIKE '%North Sea%' AND timestamp > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Works (id INT, artist_id INT, title VARCHAR(50)); CREATE TABLE Gallery_Works (id INT, gallery_id INT, work_id INT); CREATE TABLE Galleries (id INT, name VARCHAR(30), city VARCHAR(20)); INSERT INTO Galleries (id, name, city) VALUES (1, 'Gallery A', 'Tokyo'), (2, 'Gallery B', 'Tokyo'), (3, 'Gallery C', 'Tokyo');
|
Identify the artist with the most works displayed in galleries located in Tokyo, and show the number of works and gallery names.
|
SELECT a.name, COUNT(w.id) as num_works, GROUP_CONCAT(g.name) as gallery_names FROM Artists a JOIN Works w ON a.id = w.artist_id JOIN Gallery_Works gw ON w.id = gw.work_id JOIN Galleries g ON gw.gallery_id = g.id WHERE g.city = 'Tokyo' GROUP BY a.name ORDER BY num_works DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vehicle_Manufacturers (id INT, name TEXT, safety_rating FLOAT, production_country TEXT); INSERT INTO Vehicle_Manufacturers (id, name, safety_rating, production_country) VALUES (1, 'Manufacturer1', 4.3, 'UK'); INSERT INTO Vehicle_Manufacturers (id, name, safety_rating, production_country) VALUES (2, 'Manufacturer2', 4.7, 'UK');
|
Who is the manufacturer with the highest safety rating for vehicles produced in the UK?
|
SELECT name FROM Vehicle_Manufacturers WHERE production_country = 'UK' ORDER BY safety_rating DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals_india (id INT, name TEXT, beds INT); INSERT INTO hospitals_india (id, name, beds) VALUES (1, 'Hospital X', 500);
|
What is the maximum number of beds available in hospitals in India?
|
SELECT MAX(beds) FROM hospitals_india;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (country VARCHAR(255), region VARCHAR(255), number_of_sites INT); INSERT INTO marine_protected_areas (country, region, number_of_sites) VALUES ('Norway', 'Atlantic Ocean', 55), ('Spain', 'Atlantic Ocean', 45), ('Portugal', 'Atlantic Ocean', 35), ('France', 'Atlantic Ocean', 25), ('Ireland', 'Atlantic Ocean', 15);
|
Identify the top 3 countries with the highest number of marine protected areas in the Atlantic Ocean.
|
SELECT country, number_of_sites, ROW_NUMBER() OVER (ORDER BY number_of_sites DESC) as rn FROM marine_protected_areas WHERE region = 'Atlantic Ocean' LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE courses (course_id INT, academic_year INT, subject_area VARCHAR(50), pedagogy_type VARCHAR(50)); INSERT INTO courses (course_id, academic_year, subject_area, pedagogy_type) VALUES (1, 2022, 'Math', 'Open'), (2, 2022, 'English', 'Traditional'), (3, 2022, 'Science', 'Open'), (4, 2022, 'History', 'Traditional'), (5, 2022, 'Math', 'Traditional'), (6, 2022, 'English', 'Open'), (7, 2021, 'Math', 'Open'), (8, 2021, 'English', 'Traditional'), (9, 2021, 'Science', 'Open'), (10, 2021, 'History', 'Traditional');
|
What is the number of open pedagogy courses offered in '2022' grouped by subject area?
|
SELECT subject_area, COUNT(*) AS number_of_courses FROM courses WHERE academic_year = 2022 AND pedagogy_type = 'Open' GROUP BY subject_area;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vaccinations (id INT, patient_id INT, vaccine VARCHAR(50), date DATE, city VARCHAR(50)); INSERT INTO vaccinations (id, patient_id, vaccine, date, city) VALUES (5, 5, 'AstraZeneca', '2022-02-15', 'Sydney'); INSERT INTO vaccinations (id, patient_id, vaccine, date, city) VALUES (6, 6, 'Pfizer', '2022-03-15', 'Sydney');
|
How many patients have been vaccinated in Sydney with AstraZeneca this year?
|
SELECT COUNT(*) FROM vaccinations WHERE city = 'Sydney' AND vaccine = 'AstraZeneca' AND date >= '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GAS_WELLS (WELL_NAME VARCHAR(255), PRODUCTION_QTY INT);
|
What are the names and production quantities of all gas wells in the 'GAS_WELLS' table?
|
SELECT WELL_NAME, PRODUCTION_QTY FROM GAS_WELLS;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (artwork_id INT, year_created INT, gallery_name VARCHAR(50)); INSERT INTO Artworks (artwork_id, year_created, gallery_name) VALUES (1, 1907, 'Cubism'), (2, 1912, 'Cubism');
|
What is the average year of creation for artworks in the 'Cubism' gallery?
|
SELECT AVG(year_created) FROM Artworks WHERE gallery_name = 'Cubism';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museums (id INT, name VARCHAR(50), city VARCHAR(50), artworks_count INT); INSERT INTO museums (id, name, city, artworks_count) VALUES (1, 'Louvre Museum', 'Paris', 55000); INSERT INTO museums (id, name, city, artworks_count) VALUES (2, 'Vatican Museums', 'Rome', 70000);
|
Which museums in Paris and Rome have more than 5000 artworks in their collections?
|
SELECT name, city FROM museums WHERE city IN ('Paris', 'Rome') AND artworks_count > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emissions (country VARCHAR(50), emissions INT); INSERT INTO emissions (country, emissions) VALUES ('China', 12000), ('USA', 3500), ('Australia', 1800), ('India', 500), ('Brazil', 200);
|
Which countries have greenhouse gas emissions from rare earth element production greater than 3000?
|
SELECT country FROM emissions WHERE emissions > 3000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft_manufacturing (id INT, year INT, manufacturer VARCHAR(255), quantity INT);
|
How many spacecraft were manufactured per year by each manufacturer?
|
SELECT manufacturer, year, AVG(quantity) as avg_yearly_production FROM spacecraft_manufacturing GROUP BY manufacturer, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, name TEXT, organization TEXT, sector TEXT); INSERT INTO volunteers (id, name, organization, sector) VALUES (1, 'John Doe', 'UNICEF', 'Education'), (2, 'Jane Smith', 'Save the Children', 'Health');
|
What is the name and organization of volunteers who have provided support in the education sector?
|
SELECT name, organization FROM volunteers WHERE sector = 'Education';
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW asia_hotels AS SELECT * FROM hotels WHERE continent = 'Asia'; CREATE TABLE hotel_ratings (hotel_id INT, rating INT);
|
What is the average rating of each hotel in the asia_hotels view?
|
SELECT h.hotel_name, AVG(hr.rating) FROM asia_hotels h JOIN hotel_ratings hr ON h.id = hr.hotel_id GROUP BY h.hotel_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Routes (RouteID int, RouteType varchar(10), StartingLocation varchar(20), Length float); CREATE TABLE VehicleSpeeds (VehicleID int, RouteID int, Speed float); INSERT INTO Routes VALUES (1, 'Bus', 'City Center', 20.0), (2, 'Tram', 'City Center', 15.0), (3, 'Bus', 'Suburbs', 30.0); INSERT INTO VehicleSpeeds VALUES (1, 1, 30), (2, 1, 25), (3, 2, 16), (4, 3, 28), (5, 3, 32);
|
What is the average speed of buses, by route?
|
SELECT Routes.RouteID, Routes.RouteType, AVG(VehicleSpeeds.Speed) as avg_speed FROM Routes INNER JOIN VehicleSpeeds ON Routes.RouteID = VehicleSpeeds.RouteID WHERE Routes.RouteType = 'Bus' GROUP BY Routes.RouteID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(50), minority_owned BOOLEAN, award_year INT, contract_value DECIMAL(10, 2)); INSERT INTO defense_contracts (contract_id, company_name, minority_owned, award_year, contract_value) VALUES (1, 'Lockheed Martin', FALSE, 2020, 5000000.00), (2, 'Raytheon', FALSE, 2020, 7000000.00), (3, 'Minority-owned Co.', TRUE, 2019, 1000000.00);
|
How many defense contracts were awarded to minority-owned businesses in 2019?
|
SELECT COUNT(*) FROM defense_contracts WHERE minority_owned = TRUE AND award_year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LaborRightsViolations (id INT, type VARCHAR(50), violation VARCHAR(50)); INSERT INTO LaborRightsViolations (id, type, violation) VALUES (1, 'TypeA', 'Violation1'), (2, 'TypeB', 'Violation2'), (3, 'TypeA', 'Violation3');
|
List the total number of labor rights violations for each type in the 'LaborRightsViolations' table
|
SELECT type, COUNT(*) as total_violations FROM LaborRightsViolations GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnergyEfficiencyRatings (RatingID int, RatingName varchar(50)); CREATE TABLE GreenBuildings (BuildingID int, RatingID int, CarbonOffsets int);
|
What is the average carbon offset for each energy efficiency rating?
|
SELECT EnergyEfficiencyRatings.RatingName, AVG(GreenBuildings.CarbonOffsets) as AvgCarbonOffsets FROM EnergyEfficiencyRatings INNER JOIN GreenBuildings ON EnergyEfficiencyRatings.RatingID = GreenBuildings.RatingID GROUP BY EnergyEfficiencyRatings.RatingName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_cruelty_free BOOLEAN, is_vegan BOOLEAN, rating DECIMAL(2,1)); INSERT INTO products (product_id, product_name, is_cruelty_free, is_vegan, rating) VALUES (1, 'Cruelty-Free Mascara', true, true, 4.5); INSERT INTO products (product_id, product_name, is_cruelty_free, is_vegan, rating) VALUES (2, 'Vegan Lipstick', true, false, 4.7);
|
Determine the average rating of beauty products that are both cruelty-free and vegan.
|
SELECT AVG(rating) FROM products WHERE is_cruelty_free = true AND is_vegan = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE refinery_table (rare_earth_element VARCHAR(20), year INT, production_volume INT);
|
Insert a new record into the refinery_table for 'Promethium' with the given data: year = 2022, production_volume = 125
|
INSERT INTO refinery_table (rare_earth_element, year, production_volume) VALUES ('Promethium', 2022, 125);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE impact_investments (id INT, project VARCHAR(50), location VARCHAR(50), investment_amount DECIMAL(10,2), impact_score INT, primary_sector VARCHAR(50)); INSERT INTO impact_investments (id, project, location, investment_amount, impact_score, primary_sector) VALUES (1, 'School Construction', 'Nigeria', 750000.00, 85, 'Education');
|
What is the average environmental factor score for projects in the education sector with an investment amount greater than $700,000?
|
SELECT AVG(e.environmental_factor) as avg_env_factor FROM esg_factors e JOIN impact_investments i ON e.investment_id = i.id WHERE i.primary_sector = 'Education' AND i.investment_amount > 700000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT);
|
What is the average number of employees per mining operation?
|
SELECT AVG(num_employees) FROM mining_operations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeritageSites (SiteID INT, Name TEXT, Country TEXT); INSERT INTO HeritageSites (SiteID, Name, Country) VALUES (1, 'Palenque', 'Mexico'); INSERT INTO HeritageSites (SiteID, Name, Country) VALUES (2, 'Teotihuacan', 'Mexico');
|
How many heritage sites are in Mexico?
|
SELECT COUNT(*) FROM HeritageSites WHERE Country = 'Mexico';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name TEXT, league TEXT, sport TEXT); INSERT INTO teams (team_id, team_name, league, sport) VALUES (1, 'India', 'Asian Games', 'Field Hockey'); CREATE TABLE games (game_id INT, team_id INT, goals INT, season_year INT); INSERT INTO games (game_id, team_id, goals, season_year) VALUES (1, 1, 7, 2020), (2, 1, 6, 2020), (3, 1, 8, 2018);
|
What is the highest number of goals scored by the 'India' women's field hockey team in a single match in the 'Asian Games'?
|
SELECT MAX(goals) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'India') AND league = 'Asian Games';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (id INT, name VARCHAR(50), region VARCHAR(50), accessibility_rating INT);
|
What is the total number of accessible technology initiatives by region?
|
SELECT region, COUNT(*) as count FROM initiatives WHERE accessibility_rating > 6 GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SiteF (site_id INT, site_name TEXT, artifact_type TEXT); INSERT INTO SiteF (site_id, site_name, artifact_type) VALUES (1, 'SiteA', 'Pottery'), (2, 'SiteB', 'Tools'), (3, 'SiteC', 'Jewelry'); INSERT INTO SiteF (site_id, site_name, artifact_type) VALUES (4, 'SiteD', 'Pottery'), (5, 'SiteE', 'Tools'), (6, 'SiteF', 'Jewelry');
|
What are the names of the excavation sites that have 'Tools' as an artifact type?
|
SELECT site_name FROM SiteF WHERE artifact_type = 'Tools';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (id INT, company_id INT, amount INT, industry TEXT); INSERT INTO funding (id, company_id, amount, industry) VALUES (1, 1, 50000, 'Technology'); INSERT INTO funding (id, company_id, amount, industry) VALUES (2, 2, 75000, 'Finance'); INSERT INTO funding (id, company_id, amount, industry) VALUES (3, 3, 100000, 'Healthcare');
|
Identify the top 3 industries with the highest average funding amounts
|
SELECT industry, AVG(amount) as avg_funding FROM funding GROUP BY industry ORDER BY avg_funding DESC LIMIT 3
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, student_name VARCHAR(255), student_community VARCHAR(255)); CREATE TABLE research_grants (grant_id INT, student_id INT, grant_amount DECIMAL(10,2), grant_start_date DATE, grant_end_date DATE);
|
Find the number of graduate students from African and Asian backgrounds who have not received any research grants.
|
SELECT COUNT(DISTINCT s.student_id) FROM students s LEFT JOIN research_grants rg ON s.student_id = rg.student_id WHERE rg.grant_id IS NULL AND s.student_community IN ('African', 'Asian');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PublicTransit (transit_id INT, transit_type VARCHAR(20), city VARCHAR(20)); INSERT INTO PublicTransit (transit_id, transit_type, city) VALUES (1, 'Bus', 'New York'), (2, 'Subway', 'New York'), (3, 'Train', 'Los Angeles');
|
Count the number of 'Bus' records in the 'PublicTransit' table where 'city' is 'New York'
|
SELECT COUNT(*) FROM PublicTransit WHERE transit_type = 'Bus' AND city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonationDate date, DonationAmount numeric);
|
What is the total amount donated by new donors in H2 2019?
|
SELECT SUM(DonationAmount) FROM (SELECT DonationAmount FROM Donors WHERE DonationDate BETWEEN '2019-07-01' AND '2019-12-31' AND DonorID NOT IN (SELECT DonorID FROM Donors WHERE DonationDate < '2019-07-01')) AS NewDonors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE); INSERT INTO customers (customer_id, customer_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO orders (order_id, customer_id, order_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-02-01'), (3, 2, '2022-03-01');
|
Which customers have not placed an order in the last 3 months?
|
SELECT c.customer_name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH) IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_purchases(customer_id INT, garment_id INT, quantity INT, sustainable BOOLEAN); INSERT INTO customer_purchases(customer_id, garment_id, quantity, sustainable) VALUES (101, 1, 2, true), (102, 2, 1, false), (101, 3, 3, true);
|
Who are the top 3 customers with the highest quantity of sustainable garments purchased?
|
SELECT customer_id, SUM(quantity) as total_quantity FROM customer_purchases WHERE sustainable = true GROUP BY customer_id ORDER BY total_quantity DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT, brand_name TEXT, country TEXT, certification TEXT); INSERT INTO brands (brand_id, brand_name, country, certification) VALUES (1, 'EcoBrand', 'Germany', 'fair trade'), (2, 'GreenFashion', 'France', 'organic'), (3, 'SustainableStyle', 'USA', 'fair trade'); CREATE TABLE material_usage (brand_id INT, material_type TEXT, quantity INT, co2_emissions INT); INSERT INTO material_usage (brand_id, material_type, quantity, co2_emissions) VALUES (1, 'recycled_polyester', 1200, 2000), (1, 'organic_cotton', 800, 1000), (3, 'recycled_polyester', 1500, 2500);
|
What is the total quantity of recycled polyester used by brands with a 'fair trade' certification?
|
SELECT SUM(mu.quantity) AS total_quantity FROM brands b JOIN material_usage mu ON b.brand_id = mu.brand_id WHERE b.certification = 'fair trade' AND mu.material_type = 'recycled_polyester';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation_projects (project_id INT, location VARCHAR(50), investment_amount FLOAT, investment_year INT); INSERT INTO climate_mitigation_projects (project_id, location, investment_amount, investment_year) VALUES (1, 'Nigeria', 8000000, 2020), (2, 'Kenya', 6000000, 2020), (3, 'South Africa', 9000000, 2020), (4, 'Tanzania', 7000000, 2020), (5, 'Ghana', 5000000, 2020);
|
What is the total investment in climate mitigation projects in Sub-Saharan Africa in 2020?
|
SELECT SUM(investment_amount) FROM climate_mitigation_projects WHERE location LIKE 'Sub-Saharan Africa' AND investment_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecordLabels (LabelName TEXT, Country TEXT, Quarter TEXT(2), Year INTEGER, NewArtists INTEGER); INSERT INTO RecordLabels (LabelName, Country, Quarter, Year, NewArtists) VALUES ('Label1', 'USA', 'Q1', 2021, 12), ('Label2', 'Canada', 'Q2', 2021, 15), ('Label3', 'UK', 'Q3', 2021, 8), ('Label4', 'Germany', 'Q4', 2021, 11);
|
List all the record labels and their respective countries that have signed more than 10 new artists in any quarter of 2021.
|
SELECT LabelName, Country FROM RecordLabels WHERE Year = 2021 GROUP BY LabelName, Country HAVING SUM(NewArtists) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_exploration (id INT, location VARCHAR(50), depth INT, date DATE);
|
Insert a new record in the table "deep_sea_exploration" with values 'Indian Ocean', 6000, '2022-03-04'
|
INSERT INTO deep_sea_exploration (location, depth, date) VALUES ('Indian Ocean', 6000, '2022-03-04');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (animal_id INT, animal_type VARCHAR(10), age INT); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (1, 'zebra', 7); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (2, 'monkey', 3); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (3, 'zebra', 5);
|
What is the minimum age of all animals in the 'animal_population' table?
|
SELECT MIN(age) FROM animal_population;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (debris_id INT, name VARCHAR(255), type VARCHAR(255), location POINT); INSERT INTO space_debris (debris_id, name, type, location) VALUES (1, 'Defunct Satellite', 'Satellite', ST_POINT(0, 0));
|
What is the distribution of space debris by location?
|
SELECT type, ST_X(location) as longitude, ST_Y(location) as latitude, COUNT(*) as count FROM space_debris GROUP BY type, ST_X(location), ST_Y(location);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinics (clinic_id INT, clinic_name TEXT, state TEXT); INSERT INTO clinics (clinic_id, clinic_name, state) VALUES (1, 'Rural Health Clinic', 'Texas');
|
Which clinics in Texas need to increase their pediatric vaccine stock?
|
SELECT clinic_name FROM clinics WHERE state = 'Texas' AND clinic_id NOT IN (SELECT clinic_id FROM vaccine_stocks WHERE vaccine_type = 'Pediatric' AND quantity >= 500);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE innovation_metrics (id INT, name TEXT, score INT, region TEXT); INSERT INTO innovation_metrics (id, name, score, region) VALUES (1, 'Soil Monitoring', 7, 'Central America'), (2, 'Irrigation', 6, 'Caribbean'), (3, 'Crop Yield', 8, 'Central America'), (4, 'Livestock Management', 9, 'Caribbean');
|
Identify the agricultural innovation metrics that have the lowest average score in Central America and the Caribbean.
|
SELECT name, AVG(score) as avg_score FROM innovation_metrics WHERE region IN ('Central America', 'Caribbean') GROUP BY name ORDER BY avg_score LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug_name TEXT, approval_status TEXT); INSERT INTO drug_approval (drug_name, approval_status) VALUES ('DrugA', 'approved'), ('DrugB', 'approved'), ('DrugC', 'pending'), ('DrugD', 'approved'); CREATE TABLE manufacturing_costs (drug_name TEXT, cost_per_unit INTEGER); INSERT INTO manufacturing_costs (drug_name, cost_per_unit) VALUES ('DrugA', 85), ('DrugB', 98), ('DrugC', 120), ('DrugD', 76); CREATE TABLE drug_sales (drug_name TEXT, sales INTEGER); INSERT INTO drug_sales (drug_name, sales) VALUES ('DrugA', 25000000), ('DrugB', 30000000), ('DrugC', 0), ('DrugD', 22000000);
|
What are the total sales for approved drugs with a manufacturing cost of less than $100 per unit?
|
SELECT SUM(sales) FROM drug_sales INNER JOIN drug_approval ON drug_sales.drug_name = drug_approval.drug_name INNER JOIN manufacturing_costs ON drug_sales.drug_name = manufacturing_costs.drug_name WHERE drug_approval.approval_status = 'approved' AND manufacturing_costs.cost_per_unit < 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AquaticFarm (date DATE, temperature FLOAT); INSERT INTO AquaticFarm (date, temperature) VALUES ('2022-02-01', 21.0), ('2022-02-02', 22.0), ('2022-02-03', 23.0);
|
Update the temperature for the record with date '2022-02-02' in the AquaticFarm table to 22.5 degrees.
|
UPDATE AquaticFarm SET temperature = 22.5 WHERE date = '2022-02-02';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE systems (system_id INT, system_name VARCHAR(255), department VARCHAR(255));CREATE TABLE cve_scores (system_id INT, score INT, scan_date DATE);CREATE TABLE scan_dates (scan_date DATE, system_id INT);
|
What are the total CVE scores and number of scans for each system in the Security department in the last month, and which systems were scanned the most?
|
SELECT s.system_name, SUM(c.score) as total_score, COUNT(sd.scan_date) as scan_count, ROW_NUMBER() OVER (ORDER BY COUNT(sd.scan_date) DESC) as scan_rank FROM systems s INNER JOIN cve_scores c ON s.system_id = c.system_id INNER JOIN scan_dates sd ON s.system_id = sd.system_id WHERE s.department = 'Security' AND sd.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY s.system_name ORDER BY scan_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE criminal_cases (case_id INT, filing_date DATE, county VARCHAR(50)); INSERT INTO criminal_cases (case_id, filing_date, county) VALUES (1, '2020-01-01', 'Harris'), (2, '2019-02-01', 'Dallas'), (3, '2018-03-01', 'Travis');
|
What is the total number of criminal cases filed in each county in Texas in the last 5 years?
|
SELECT county, COUNT(*) FILTER (WHERE filing_date >= NOW() - INTERVAL '5 years') AS total_cases FROM criminal_cases GROUP BY county;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE savings (account_number INT, customer_name VARCHAR(50), balance DECIMAL(10, 2), is_shariah_compliant BOOLEAN); INSERT INTO savings (account_number, customer_name, balance, is_shariah_compliant) VALUES (1, 'Ahmed', 5000, true), (2, 'Sara', 7000, false), (3, 'Mohammed', 8000, true);
|
What is the balance for the savings account with the highest balance?
|
SELECT MAX(balance) FROM savings;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name TEXT);CREATE TABLE emergencies (emergency_id INT, district_id INT, response_time INT);
|
Delete all emergency records with a response time greater than 60 minutes in the 'Northside' district.
|
DELETE e FROM emergencies e INNER JOIN districts d ON e.district_id = d.district_id WHERE d.district_name = 'Northside' AND e.response_time > 60;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MenuItems (category VARCHAR(20), sourcing_score FLOAT); INSERT INTO MenuItems (category, sourcing_score) VALUES ('Asian', 9.5),('Asian', 10.0),('Asian', 9.2);
|
What is the maximum sustainable sourcing score for 'Asian' menu items?
|
SELECT MAX(sourcing_score) FROM MenuItems WHERE category = 'Asian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (Claim_Amount NUMERIC, Risk_Level TEXT); INSERT INTO Claims (Claim_Amount, Risk_Level) VALUES (2500, 'High'), (3000, 'Very High'), (2000, 'Medium'), (1500, 'Low');
|
What is the total claim amount for each risk level?
|
SELECT Risk_Level, SUM(Claim_Amount) FROM Claims GROUP BY Risk_Level;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (restaurant_id INT, item_name TEXT, item_type TEXT, price DECIMAL); INSERT INTO menu (restaurant_id, item_name, item_type, price) VALUES (1, 'Spaghetti', 'Entree', 12.99), (1, 'Quinoa Salad', 'Entree', 14.99), (1, 'Garden Burger', 'Entree', 13.49);
|
Update the price of the 'Quinoa Salad' in Restaurant A to $15.49.
|
UPDATE menu SET price = 15.49 WHERE restaurant_id = 1 AND item_name = 'Quinoa Salad';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EFG_transaction (transaction_hash VARCHAR(255), block_number INT, transaction_index INT, from_address VARCHAR(255), to_address VARCHAR(255), value DECIMAL(18,2), gas_price DECIMAL(18,2), gas_limit INT, timestamp TIMESTAMP, miner VARCHAR(255));
|
List the top 10 miners with the highest transaction fees earned in the EFG blockchain.
|
SELECT miner, SUM(gas_price * gas_limit) AS total_fees_earned FROM EFG_transaction GROUP BY miner ORDER BY total_fees_earned DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id INT PRIMARY KEY, name VARCHAR(255), creation_date DATETIME, asset_type VARCHAR(50)); INSERT INTO digital_assets (asset_id, name, creation_date, asset_type) VALUES (1, 'Asset1', '2022-01-01 10:00:00', 'TypeA'), (2, 'Asset2', '2022-01-02 11:00:00', 'TypeB'), (3, 'Asset3', '2022-01-03 12:00:00', 'TypeA');
|
Calculate the average age of digital assets (in days) grouped by their asset type.
|
SELECT asset_type, AVG(DATEDIFF(CURRENT_DATE, creation_date)) AS avg_age_days FROM digital_assets GROUP BY asset_type;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW Transportation_Emissions AS SELECT product_id, product_name, transportation_emissions FROM Products; INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (501, 'Backpack', 4, 6, 1); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (502, 'Notebook', 2, 3, 0); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (503, 'Pen', 1, 1, 0);
|
What is the sum of transportation emissions for all products in the Transportation_Emissions view?
|
SELECT SUM(transportation_emissions) FROM Transportation_Emissions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies(movie_id INT, title VARCHAR(50), genre VARCHAR(20), release_year INT, budget INT, gross INT); INSERT INTO movies(movie_id, title, genre, release_year, budget, gross) VALUES (1, 'Avatar', 'Sci-Fi', 2009, 237000000, 2787965087), (2, 'Avengers: Endgame', 'Superhero', 2019, 356000000, 2797800564), (3, 'Titanic', 'Romance', 1997, 200000000, 2187454640), (4, 'The Avengers', 'Superhero', 2012, 220000000, 1518812988), (5, 'Batman v Superman', 'Superhero', 2016, 250000000, 873434451);
|
What's the total production budget for the superhero genre?
|
SELECT SUM(budget) FROM movies WHERE genre = 'Superhero';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_generation (province VARCHAR(20), energy_source VARCHAR(20), generation INT, year INT); INSERT INTO energy_generation (province, energy_source, generation, year) VALUES ('Alberta', 'Solar', 1500, 2022), ('Alberta', 'Wind', 3500, 2022);
|
What is the total energy generation from solar and wind in the province of Alberta for the year 2022?
|
SELECT SUM(generation) FROM energy_generation WHERE province = 'Alberta' AND (energy_source = 'Solar' OR energy_source = 'Wind') AND year = 2022;
|
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.