context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE green_buildings ( id INT PRIMARY KEY, building_name VARCHAR(255), state VARCHAR(255), certification_level VARCHAR(255) ); | Delete green building records for the state of California that have a certification level of 'Gold'. | DELETE FROM green_buildings WHERE state = 'California' AND certification_level = 'Gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtWorks (ArtWorkID INT, Title VARCHAR(100), YearCreated INT, ArtistID INT, Medium VARCHAR(50), MuseumID INT); | Update artwork's year created | UPDATE ArtWorks SET YearCreated = 1940 WHERE ArtWorkID = 2 AND Title = 'The Two Fridas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, category VARCHAR(255), content TEXT, likes INT, created_at TIMESTAMP); | What was the most popular post in the "tech" category in January 2022, based on the number of likes? | SELECT content FROM posts WHERE category = 'tech' AND created_at >= '2022-01-01' AND created_at < '2022-02-01' ORDER BY likes DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), research_interest TEXT); INSERT INTO faculty (id, name, department, research_interest) VALUES (1, 'Alice', 'Mathematics', 'Applied Mathematics'); INSERT INTO faculty (id, name, department, research_interest) VALUES (2, 'Bob', 'Physics', 'Theoretica... | Update the research interest of all faculty members in the Mathematics department to 'Pure Mathematics'. | UPDATE faculty SET research_interest = 'Pure Mathematics' WHERE department = 'Mathematics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20), account_balance DECIMAL(10, 2)); INSERT INTO clients (client_id, name, region, account_balance) VALUES (1, 'John Doe', 'Western', 25000.00), (2, 'Jane Smith', 'Eastern', 30000.00), (3, 'Mike Johnson', 'Western', 40000.00); | Find the top 3 clients with the highest account balances in the Western region. | SELECT client_id, name, account_balance FROM clients WHERE region = 'Western' ORDER BY account_balance DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, country VARCHAR(50)); INSERT INTO wells (well_id, country) VALUES (1, 'Saudi Arabia'), (2, 'Iran'), (3, 'Iraq'), (4, 'United Arab Emirates'); | Find the number of wells drilled in each country and the total in the Middle East. | SELECT country, COUNT(*) as num_wells FROM wells WHERE country IN ('Saudi Arabia', 'Iran', 'Iraq', 'United Arab Emirates') GROUP BY country UNION ALL SELECT 'Total' as country, COUNT(*) as num_wells FROM wells WHERE country IN ('Saudi Arabia', 'Iran', 'Iraq', 'United Arab Emirates'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_projects (id INT, project_name VARCHAR(255), location VARCHAR(255), sector VARCHAR(255), cost FLOAT); INSERT INTO rural_infrastructure_projects (id, project_name, location, sector, cost) VALUES (1, 'Water Supply System', 'Village A', 'Infrastructure', 50000.00), (2, 'Electricity Grid E... | Delete the rural infrastructure project with id 4 and update the remaining project's id to be consecutive. | WITH cte AS (DELETE FROM rural_infrastructure_projects WHERE id = 4) SELECT ROW_NUMBER() OVER (ORDER BY id) AS new_id, project_name, location, sector, cost FROM rural_infrastructure_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor TEXT, program TEXT, amount FLOAT); INSERT INTO donations (id, donor, program, amount) VALUES (1, 'Donor A', 'Education', 500.00), (2, 'Donor B', 'Health', 1000.00), (3, 'Donor C', 'Environment', 750.00), (4, 'Donor D', 'Education', 250.00), (5, 'Donor A', 'Health', 750.00), (6, 'Do... | Display the names and total donation amounts for donors that have donated to programs in both the Education and Health categories, excluding any duplicate records. | SELECT donor, SUM(amount) as total_donation FROM donations WHERE program IN ('Education', 'Health') GROUP BY donor; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, game_genre VARCHAR(255), player_id INT, playtime_mins INT); CREATE TABLE players (player_id INT, player_country VARCHAR(255)); | What is the average playtime, in hours, for players from the United Kingdom, for games in the 'Adventure' genre? | SELECT AVG(playtime_mins / 60) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'United Kingdom' AND game_genre = 'Adventure'; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50), email VARCHAR(50)); INSERT INTO graduate_students VALUES (1, 'Charlie', 'Physics', 'charlie@math.edu'), (2, 'David', 'Physics', 'david@gmail.com'), (3, 'Eve', 'Chemistry', 'eve@chemistry.edu'); | Update the email addresses of all graduate students in the Physics department with the domain 'physics.edu'. | UPDATE graduate_students SET email = CONCAT(SUBSTRING_INDEX(email, '@', 1), '@physics.edu') WHERE department = 'Physics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecrafts (id INT, name VARCHAR(255), launch_date DATE, PRIMARY KEY(id)); INSERT INTO spacecrafts (id, name, launch_date) VALUES (1, 'Apollo 11', '1969-07-16'), (2, 'Soyuz T-15', '1986-03-13'), (3, 'Gemini 6A', '1965-12-15'); CREATE TABLE rendezvous (id INT, spacecraft_id INT, PRIMARY KEY(id), FOREIGN KE... | What are the names of the spacecrafts that performed rendezvous maneuvers, along with their launch dates? | SELECT spacecrafts.name, spacecrafts.launch_date FROM spacecrafts INNER JOIN rendezvous ON spacecrafts.id = rendezvous.spacecraft_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonorID int, DonationDate date, Amount decimal(10,2)); INSERT INTO Donations (DonorID, DonationDate, Amount) VALUES (1, '2021-01-01', 500.00), (2, '2021-02-15', 300.00); | Delete records of donors who haven't donated since 2020 from the Donations table. | DELETE d1 FROM Donations d1 LEFT JOIN Donations d2 ON d1.DonorID = d2.DonorID AND YEAR(d2.DonationDate) >= 2020 WHERE YEAR(d1.DonationDate) < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_revenue(location VARCHAR(255), revenue INT); INSERT INTO restaurant_revenue(location, revenue) VALUES ('Location1', 5000), ('Location2', 7000), ('Location3', 3000), ('Restaurant4', 6000), ('Restaurant5', 4000); | What is the total revenue for restaurants in Los Angeles? | SELECT SUM(revenue) FROM restaurant_revenue WHERE location LIKE '%Los Angeles%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerName TEXT); INSERT INTO Players (PlayerID, PlayerName) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE Games (GameID INT, PlayerID INT, GameDateTime TIMESTAMP, Duration INT); INSERT INTO Games (GameID, PlayerID, GameDateTime, Duration) VALUES (1, 1, '2021-01-01 10:00:00... | What is the average playtime per game for each player? | SELECT Players.PlayerName, AVG(Games.Duration) as AverageDuration FROM Players JOIN Games ON Players.PlayerID = Games.PlayerID GROUP BY Players.PlayerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(year INT, state VARCHAR(255), plastic_recycling FLOAT, paper_recycling FLOAT, glass_recycling FLOAT); INSERT INTO recycling_rates VALUES (2018, 'Florida', 0.6, 0.7, 0.5), (2019, 'Florida', 0.7, 0.8, 0.6); | Delete records of recycling rates for 2018 in Florida. | DELETE FROM recycling_rates WHERE year = 2018 AND state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sightings (Species VARCHAR(25), Ocean VARCHAR(25), Sightings INT); INSERT INTO Sightings (Species, Ocean, Sightings) VALUES ('Dolphin', 'Atlantic Ocean', 200), ('Turtle', 'Pacific Ocean', 350), ('Shark', 'Indian Ocean', 150), ('Whale', 'Pacific Ocean', 400); | What is the average sighting frequency of marine species in the 'Pacific Ocean'? | SELECT AVG(Sightings) FROM Sightings WHERE Ocean = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethereum_transactions (tx_hash VARCHAR(255), block_number INT, timestamp TIMESTAMP, from_address VARCHAR(42), to_address VARCHAR(42), value DECIMAL(20, 8)); | What is the total number of Ethereum transactions for each day in January 2021? | SELECT DATE(timestamp) AS transaction_date, COUNT(*) AS num_transactions FROM ethereum_transactions WHERE timestamp >= '2021-01-01 00:00:00' AND timestamp < '2021-02-01 00:00:00' GROUP BY transaction_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (ConcertID INT, ArtistID INT, ConcertDate DATE, Venue VARCHAR(100), TicketRevenue DECIMAL(10, 2), Genre VARCHAR(50)); CREATE VIEW RevenuePerGenre AS SELECT Genre, SUM(TicketRevenue) AS TotalRevenue FROM Concerts GROUP BY Genre; | What is the total revenue for pop concerts? | SELECT Genre, TotalRevenue FROM RevenuePerGenre WHERE Genre = 'Pop'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RainfallData (id INT, Region VARCHAR(255), Precipitation INT, Timestamp DATETIME); INSERT INTO RainfallData (id, Region, Precipitation, Timestamp) VALUES (1, 'South America', 100, '2022-05-20 12:00:00'), (2, 'North America', 50, '2022-05-20 12:00:00'); | What is the total precipitation for each region for the last week, ranked in descending order? | SELECT Region, SUM(Precipitation) as TotalPrecip FROM RainfallData WHERE Timestamp BETWEEN DATEADD(day, -7, GETDATE()) AND GETDATE() GROUP BY Region ORDER BY TotalPrecip DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Events (id INT, country VARCHAR(20), event_date DATE, event_count INT); | What is the maximum number of community events held in a single day in Germany? | SELECT MAX(event_count) FROM Community_Events WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shelter_support (id INT, name TEXT, occupation TEXT, age INT, country TEXT, year INT); INSERT INTO shelter_support (id, name, occupation, age, country, year) VALUES (1, 'Sophia Gonzalez', 'Doctor', 45, 'Greece', 2021), (2, 'Pedro Lopez', 'Engineer', 50, 'Greece', 2021), (3, 'Maria Rodriguez', 'Teacher', 60... | What is the name and occupation of the oldest person who provided shelter support in Greece in 2021? | SELECT name, occupation FROM shelter_support WHERE country = 'Greece' AND year = 2021 ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions (transaction_date DATE, customer_id INT, transaction_amt DECIMAL(10, 2)); INSERT INTO customer_transactions (transaction_date, customer_id, transaction_amt) VALUES ('2022-01-01', 1, 200.00), ('2022-01-05', 1, 300.00), ('2022-01-01', 2, 100.00); | Find the number of transactions per customer in the past 30 days. | SELECT customer_id, COUNT(*) OVER (PARTITION BY customer_id) AS num_transactions_in_past_30_days FROM customer_transactions WHERE transaction_date >= CURRENT_DATE - INTERVAL '30 days'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Periods (PeriodID int, Period varchar(15)); INSERT INTO Periods (PeriodID, Period) VALUES ('P001', 'Stone Age'), ('P002', 'Bronze Age'), ('P003', 'Iron Age'); | What is the oldest historical period in the database? | SELECT Period FROM Periods ORDER BY PeriodID LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name TEXT, location TEXT); CREATE TABLE Visitors_Events (visitor_id INT, event_id INT); INSERT INTO Events (id, name, location) VALUES (1, 'Dance Performance', 'Chicago'), (2, 'Film Festival', 'San Francisco'); INSERT INTO Visitors_Events (visitor_id, event_id) VALUES (1, 1), (1, 2); | List the names of all visitors who attended events in both 'Chicago' and 'San Francisco'. | SELECT Visitors_Events.visitor_id FROM Visitors_Events INNER JOIN Events ON Visitors_Events.event_id = Events.id GROUP BY Visitors_Events.visitor_id HAVING COUNT(DISTINCT Events.location) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name TEXT, weight FLOAT, shipped_to TEXT); INSERT INTO products (product_id, name, weight, shipped_to) VALUES (1, 'Glass Water Bottle', 300.00, 'New York'), (2, 'Wooden Spoon', 50.00, 'California'); CREATE TABLE orders (order_id INT, product_id INT, shipped BOOLEAN); INSERT INTO o... | What is the total weight of products shipped to 'New York'? | SELECT SUM(products.weight) FROM products INNER JOIN orders ON products.product_id = orders.product_id WHERE products.shipped_to = 'New York' AND orders.shipped = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodInspections (RestaurantID int, InspectionDate date, Score int); | Insert new records into the FoodInspections table for restaurants A, B, and C in the month of February 2022 with a score of 90, 85, and 92 respectively. | INSERT INTO FoodInspections (RestaurantID, InspectionDate, Score) VALUES ('A', '2022-02-01', 90), ('B', '2022-02-15', 85), ('C', '2022-02-28', 92); | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, date DATE, comments INT, content TEXT); CREATE TABLE hashtags (id INT, post_id INT, hashtag TEXT); | Calculate the average number of comments received by posts containing the hashtag '#travel' in 'Italy', per day. | SELECT AVG(comments / DATEDIFF('2023-03-01', date)) AS avg_comments_per_day | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, farm_id INT, name TEXT, water_usage FLOAT); INSERT INTO crops (id, farm_id, name, water_usage) VALUES (1, 1, 'Corn', 15.5), (2, 2, 'Soybeans', 12.3), (3, 3, 'Cotton', 18.7), (4, 4, 'Wheat', 10.0); | Update the crop type for farm 'Farm 4' to 'Sunflowers' in the crops table. | UPDATE crops SET name = 'Sunflowers' WHERE farm_id = (SELECT id FROM farm_locations WHERE farm_name = 'Farm 4'); | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning (student_id INT, age_group VARCHAR(255), gender VARCHAR(255), course_id INT); CREATE TABLE courses (course_id INT, course_name VARCHAR(255)); | What is the distribution of lifelong learning course enrollments by age group and gender? | SELECT l.age_group, l.gender, COUNT(l.course_id) FROM lifelong_learning l INNER JOIN courses c ON l.course_id = c.course_id GROUP BY l.age_group, l.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityPrograms (ID INT, City VARCHAR(50), Program VARCHAR(50), StartDate TIMESTAMP, EndDate TIMESTAMP); INSERT INTO CommunityPrograms (ID, City, Program, StartDate, EndDate) VALUES (17, 'CityC', 'YouthCamps', '2015-01-02 00:00:00', '2015-01-12 00:00:00'), (18, 'CityC', 'SeniorCenter', '2015-01-06 00:00:... | What is the number of days each program runs in each city, ordered by start date? | SELECT City, Program, StartDate, EndDate, DATEDIFF(day, StartDate, EndDate) AS DaysRunning FROM CommunityPrograms ORDER BY StartDate; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_inspections (restaurant_id INT, violation_count INT);CREATE TABLE restaurant_ratings (restaurant_id INT, overall_rating VARCHAR(20)); | Identify the number of food safety violations for each restaurant in the 'safety_inspections' table, with an overall rating of 'excellent' or 'good' in the 'restaurant_ratings' table? | SELECT s.restaurant_id, SUM(s.violation_count) as total_violations FROM safety_inspections s INNER JOIN restaurant_ratings r ON s.restaurant_id = r.restaurant_id WHERE r.overall_rating IN ('excellent', 'good') GROUP BY s.restaurant_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran (id INT, name VARCHAR(255), age INT, employment_status VARCHAR(255)); INSERT INTO veteran (id, name, age, employment_status) VALUES (1, 'James Brown', 30, 'Employed'); INSERT INTO veteran (id, name, age, employment_status) VALUES (2, 'Sarah Johnson', 35, 'Unemployed'); CREATE TABLE employment (id I... | What is the number of veterans employed and the average age for veterans in each employment status, ordered by the number of veterans employed in descending order? | SELECT e.status, COUNT(v.id) as num_veterans_employed, AVG(v.age) as avg_age, ROW_NUMBER() OVER (ORDER BY COUNT(v.id) DESC) as rank FROM veteran v JOIN employment e ON v.employment_status = e.status GROUP BY e.status ORDER BY num_veterans_employed DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID int, Name varchar(50), Country varchar(50), CircularSupplyChainInitiatives bool); INSERT INTO Suppliers (SupplierID, Name, Country, CircularSupplyChainInitiatives) VALUES (1, 'Supplier A', 'USA', true), (2, 'Supplier B', 'Canada', false), (3, 'Supplier C', 'USA', true), (4, 'Supplier ... | Which circular supply chain initiatives have been implemented by suppliers in the USA? | SELECT Name FROM Suppliers WHERE Country = 'USA' AND CircularSupplyChainInitiatives = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteData (WasteID INT, WasteType VARCHAR(50), Weight FLOAT, CollectionDate DATE, Location VARCHAR(50)); INSERT INTO WasteData (WasteID, WasteType, Weight, CollectionDate, Location) VALUES (1, 'Plastic', 100, '2022-06-01', 'Indian Ocean'); | What is the total weight of plastic waste collected in the Indian Ocean during the monsoon season? | SELECT SUM(w.Weight) FROM WasteData w WHERE w.WasteType = 'Plastic' AND w.CollectionDate BETWEEN '2022-06-01' AND '2022-09-30' AND w.Location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TV_Shows (show_id INT, show_name VARCHAR(255), production_budget INT, release_year INT, viewership INT); INSERT INTO TV_Shows (show_id, show_name, production_budget, release_year, viewership) VALUES (1, 'Show A', 12000000, 2018, 1500000), (2, 'Show B', 11000000, 2019, 1800000), (3, 'Show C', 13000000, 2020... | What's the viewership trend for TV shows with a budget over 10 million in the last 5 years? | SELECT release_year, AVG(viewership) FROM TV_Shows WHERE production_budget > 10000000 GROUP BY release_year ORDER BY release_year DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityWaterUsage_CapeTown (id INT, city VARCHAR, state VARCHAR, year INT, household INT, consumption FLOAT); INSERT INTO CityWaterUsage_CapeTown (id, city, state, year, household, consumption) VALUES (1, 'Cape Town', 'South Africa', 2019, 1, 150.2), (2, 'Cape Town', 'South Africa', 2019, 2, 280.4), (3, 'Cape... | What is the maximum water consumption per household in the city of Cape Town, South Africa in 2019? | SELECT MAX(consumption) FROM CityWaterUsage_CapeTown WHERE city = 'Cape Town' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_site (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE water_consumption (mining_site_id INT, month INT, year INT, consumption INT); | What is the total water consumption for each mining site by month? | SELECT mining_site.name, water_consumption.year, water_consumption.month, SUM(water_consumption.consumption) FROM water_consumption JOIN mining_site ON water_consumption.mining_site_id = mining_site.id GROUP BY mining_site.name, water_consumption.year, water_consumption.month; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetic_research;CREATE TABLE if not exists genetic_research.projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255)); INSERT INTO genetic_research.projects (id, name, location, status) VALUES (1, 'ProjectA', 'Germany', 'Active'), (2, 'ProjectB', 'France',... | How many genetic research projects are there in Australia? | SELECT COUNT(*) FROM genetic_research.projects WHERE location = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_wellbeing (program_id INT, program_name VARCHAR(255), description TEXT, cost DECIMAL(5,2), date_started DATE, date_ended DATE); | Delete all the athlete wellbeing programs that have a cost greater than $1000. | DELETE FROM athlete_wellbeing WHERE cost > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParityViolations (ViolationID INT, State VARCHAR(25), ViolationYear INT); INSERT INTO MentalHealthParityViolations (ViolationID, State, ViolationYear) VALUES (1, 'California', 2019), (2, 'Texas', 2020), (3, 'California', 2021); | What is the percentage of mental health parity violations by state and year? | SELECT State, ViolationYear, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM MentalHealthParityViolations) AS Percentage FROM MentalHealthParityViolations GROUP BY State, ViolationYear; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_sales(product_name TEXT, quantity INTEGER, is_cruelty_free BOOLEAN, sale_date DATE); INSERT INTO cosmetics_sales(product_name, quantity, is_cruelty_free, sale_date) VALUES('Cruelty-Free Lipstick 1', 125, true, '2020-01-01'); | How many cruelty-free lipsticks were sold in the first half of 2020? | SELECT SUM(quantity) FROM cosmetics_sales WHERE is_cruelty_free = true AND sale_date >= '2020-01-01' AND sale_date < '2020-07-01' AND product_name LIKE '%lipstick%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), age INT, status VARCHAR(10)); | Delete all records from the 'animals' table where the 'species' is 'Tiger' | DELETE FROM animals WHERE species = 'Tiger'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (id INT, program_name VARCHAR(255), country VARCHAR(255), start_year INT, end_year INT); INSERT INTO restorative_justice_programs (id, program_name, country, start_year, end_year) VALUES (1, 'Victim Offender Mediation Program', 'Nigeria', 2016, 2021), (2, 'Restorative Circles',... | How many restorative justice programs were implemented in Nigeria and Kenya between 2015 and 2022? | SELECT COUNT(*) AS total_programs FROM restorative_justice_programs WHERE country IN ('Nigeria', 'Kenya') AND start_year BETWEEN 2015 AND 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_events(event_id INT, region VARCHAR(50), status VARCHAR(50), ticket_sales INT); | Delete all concert events in 'Asia' that were cancelled and have no ticket sales. | DELETE FROM concert_events WHERE region = 'Asia' AND status = 'cancelled' AND ticket_sales = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE textile_sourcing (id INT, material VARCHAR(20), country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO textile_sourcing (id, material, country, price) VALUES (1, 'cotton', 'India', 3.50), (2, 'silk', 'China', 15.00), (3, 'wool', 'Australia', 12.00); | What is the average price of cotton textiles sourced from India? | SELECT AVG(price) FROM textile_sourcing WHERE material = 'cotton' AND country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, student_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE lifelong_learning (ll_id INT, student_id INT, program_name VARCHAR(50)); INSERT INTO students (student_id, student_name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'Mexico'); INSERT INTO li... | What is the number of students enrolled in lifelong learning programs by country? | SELECT students.country, COUNT(DISTINCT students.student_id) as num_students FROM students INNER JOIN lifelong_learning ON students.student_id = lifelong_learning.student_id GROUP BY students.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, program_name VARCHAR(255), city VARCHAR(255), budget INT); INSERT INTO community_policing (id, program_name, city, budget) VALUES (1, 'Youth Mentoring', 'Oakland', 50000); | What is the total number of community policing programs in Oakland and their respective budgets?" | SELECT program_name, SUM(budget) as total_budget FROM community_policing WHERE city = 'Oakland' GROUP BY program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatments (patient_id INT, condition VARCHAR(30)); INSERT INTO treatments (patient_id, condition) VALUES (1, 'Anxiety'), (2, 'Depression'), (3, 'Anxiety'), (4, 'Anxiety'), (5, 'Depression'), (6, 'Anxiety'), (7, 'Anxiety, Depression'); | How many patients have received treatment for both Anxiety and Depression? | SELECT COUNT(*) FROM treatments WHERE condition IN ('Anxiety', 'Depression') GROUP BY patient_id HAVING COUNT(DISTINCT condition) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE reverse_logistics (id INT PRIMARY KEY, warehouse_id INT, FOREIGN KEY (warehouse_id) REFERENCES warehouse(id)); INSERT INTO warehouse (id, name) VALUES (1, 'ABC'), (2, 'XYZ'), (3, 'GHI'); INSERT INTO reverse_logistics (id, warehouse_id) VALUES ... | Delete the 'GHI' warehouse and all associated reverse logistics records | WITH w AS (DELETE FROM warehouse WHERE name = 'GHI' RETURNING id) DELETE FROM reverse_logistics WHERE warehouse_id IN (SELECT id FROM w); DELETE FROM warehouse WHERE name = 'GHI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO rural_clinics (clinic_id, state, latitude, longitude) VALUES (1, 'Wisconsin', 44.452345, -89.605645), (2, 'Wisconsin', 44.501235, -89.452645), (3, 'Minnesota', 45.452345, -93.605645); CREATE TABLE ho... | What is the average distance from rural clinics to the nearest hospital in Wisconsin? | SELECT AVG(ST_Distance(rural_clinics.geometry, hospitals.geometry)) FROM rural_clinics, hospitals WHERE rural_clinics.state = 'Wisconsin' AND hospitals.state = 'Wisconsin' ORDER BY rural_clinics.clinic_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, sale_year INT, equipment_type VARCHAR(50), country VARCHAR(50), sale_value FLOAT); INSERT INTO MilitaryEquipmentSales (id, sale_year, equipment_type, country, sale_value) VALUES (1, 2020, 'Aircraft', 'United States', 12000000), (2, 2021, 'Vehicles', 'United State... | What is the total value of military equipment sales to the United Kingdom and Canada combined from 2018 to 2021? | SELECT SUM(sale_value) FROM MilitaryEquipmentSales WHERE (country = 'United Kingdom' OR country = 'Canada') AND sale_year BETWEEN 2018 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (Brand_ID INT, Brand_Name TEXT); INSERT INTO Brands (Brand_ID, Brand_Name) VALUES (1, 'H&M'); CREATE TABLE Material_Types (Material_ID INT, Material_Type TEXT, Brand_ID INT); | How many sustainable material types are used by each brand? | SELECT B.Brand_Name, COUNT(DISTINCT MT.Material_Type) AS Number_Of_Sustainable_Material_Types FROM Brands B | gretelai_synthetic_text_to_sql |
CREATE TABLE district (did INT, name VARCHAR(255)); INSERT INTO district VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE calls (call_id INT, district_id INT, response_time INT, year INT, call_type VARCHAR(255)); | List the total number of emergency calls and community policing events in each district in 2022. | SELECT d.name, COUNT(c.call_id) FILTER (WHERE c.call_type = 'Emergency') as total_emergency_calls, COUNT(c.call_id) FILTER (WHERE c.call_type = 'Community Policing') as total_community_policing_events FROM district d JOIN calls c ON d.did = c.district_id WHERE c.year = 2022 GROUP BY d.did; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_projects (project_id INT, name TEXT, start_date DATE); INSERT INTO marine_life_research_projects (project_id, name, start_date) VALUES (4, 'Project D', '2018-05-01'), (5, 'Project E', '2019-10-15'), (6, 'Project F', '2020-08-03'), (7, 'Project G', '2021-01-09'); | List all marine life research projects and their start dates. | SELECT name, start_date FROM marine_life_research_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stores (StoreID int, StoreName varchar(50)); INSERT INTO Stores VALUES (1, 'Store A'), (2, 'Store B'), (3, 'Store C'); CREATE TABLE MenuItems (MenuItemID int, MenuItemName varchar(50), IsOrganic bit, StoreID int, QuantitySold int); INSERT INTO MenuItems VALUES (1, 'Organic Chicken', 1, 1, 200), (2, 'Organi... | What is the total quantity of organic chicken sold per store, ranked by the highest sales? | SELECT StoreID, SUM(QuantitySold) AS TotalQuantitySold FROM MenuItems WHERE IsOrganic = 1 GROUP BY StoreID ORDER BY TotalQuantitySold DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_species (id INT, species TEXT, biomass_tolerance FLOAT);CREATE TABLE fish_population (id INT, species TEXT, population INT, biomass FLOAT, date DATE); | What is the average biomass of fish in the aquaculture facility for each species, sorted by the highest biomass? | SELECT species, AVG(biomass) as avg_biomass FROM fish_population GROUP BY species ORDER BY avg_biomass DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE dapps (dapp_id INT, name VARCHAR(100), network VARCHAR(100)); INSERT INTO dapps (dapp_id, name, network) VALUES (1, 'Dapp1', 'EOS'), (2, 'Dapp2', 'EOS'), (3, 'Dapp3', 'EOS'), (4, 'Dapp4', 'EOS'), (5, 'Dapp5', 'EOS'); | What are the decentralized applications built on the EOS network? | SELECT name FROM dapps WHERE network = 'EOS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_materials (id INT, material_type VARCHAR(255), project_type VARCHAR(255), cost FLOAT); INSERT INTO construction_materials (id, material_type, project_type, cost) VALUES (1, 'Steel', 'Bridge', 150000.00), (2, 'Asphalt', 'Road', 50000.00), (3, 'Concrete', 'Building', 200000.00); | What is the total cost of each type of construction material used in public works projects? | SELECT material_type, SUM(cost) as total_cost FROM construction_materials GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_race TEXT);CREATE TABLE funds (id INT, company_id INT, amount INT, funding_round TEXT); | What is the total funding amount for companies founded by people from underrepresented racial or ethnic groups? | SELECT SUM(funds.amount) FROM funds INNER JOIN companies ON funds.company_id = companies.id WHERE companies.founder_race = 'underrepresented racial or ethnic group'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_data (year INT, element VARCHAR(10), quantity INT); INSERT INTO production_data (year, element, quantity) VALUES (2017, 'Dysprosium', 6), (2018, 'Dysprosium', 7), (2019, 'Dysprosium', 8), (2020, 'Dysprosium', 9); | What was the production of Dysprosium in 2017 and 2020? | SELECT quantity FROM production_data WHERE element = 'Dysprosium' AND year IN (2017, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE spanish_virtual_tours (id INT, year INT, revenue FLOAT); INSERT INTO spanish_virtual_tours (id, year, revenue) VALUES (1, 2022, 1000.00), (2, 2022, 1200.00); | What is the total revenue generated from all virtual tours conducted in Spain in the year 2022? | SELECT SUM(revenue) FROM spanish_virtual_tours WHERE year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO farmers (id, name, age, location) VALUES (1, 'John Doe', 35, 'New York'); INSERT INTO farmers (id, name, age, location) VALUES (2, 'Jane Smith', 40, 'Los Angeles'); CREATE TABLE crops (id INT PRIMARY KEY, name VARCHA... | Who are the farmers that planted carrots? | SELECT farmers.name FROM crops INNER JOIN farmers ON crops.planted_by = farmers.id WHERE crops.name = 'Carrots'; | gretelai_synthetic_text_to_sql |
CREATE TABLE plastic_debris (debris_id INT, country TEXT, amount INT, year INT); | Which countries have reported the most plastic debris in their waters? | SELECT country, SUM(amount) FROM plastic_debris GROUP BY country ORDER BY SUM(amount) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), last_name VARCHAR(20), win_rate DECIMAL(5, 2)); INSERT INTO attorneys (attorney_id, name, last_name, win_rate) VALUES (1, 'Alexandra Smith', 'Smith', 0.9), (2, 'James Johnson', 'Johnson', 0.6), (3, 'Fatima Ahmed', 'Ahmed', 0.8), (4, 'Marcus Lee', 'Lee', 0.7); C... | What is the average billing amount for cases handled by attorneys whose last name contains the letter 'a' and have a win rate of at least 60%? | SELECT AVG(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.last_name LIKE '%a%' AND attorneys.win_rate >= 0.6; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_details (id INT, product_name VARCHAR(50), carbon_footprint DECIMAL(10, 2), country_of_sale VARCHAR(50)); INSERT INTO product_details (id, product_name, carbon_footprint, country_of_sale) VALUES (1, 'Eco T-Shirt', 5.00, 'France'), (2, 'Sustainable Shoes', 7.50, 'Germany'), (3, 'Recycled Backpack', ... | What is the average carbon footprint of products sold in France? | SELECT AVG(carbon_footprint) FROM product_details WHERE country_of_sale = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Fair_Labor_Practices (Practice VARCHAR(255), Score FLOAT); INSERT INTO Fair_Labor_Practices (Practice, Score) VALUES ('Safe Working Conditions', 8.5), ('Working Hours Control', 8.8), ('Child Labor Prevention', 9.2); | Insert a new fair labor practice, 'Living Wage', with a score of 9.0. | INSERT INTO Fair_Labor_Practices (Practice, Score) VALUES ('Living Wage', 9.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(30)); INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (1, 'John Doe', 35, 'Male', 'Caucasian', 'Non-Hispanic'); | Insert a new patient record into the patients table. | INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (2, 'Jane Smith', 40, 'Female', 'African American', 'African American'); | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name VARCHAR(50), location VARCHAR(50), area FLOAT, sustainability_rating INT); | Find the total area of all buildings in the 'green_buildings' table | SELECT SUM(area) FROM green_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE models (id INT, dataset VARCHAR(20), satisfaction FLOAT, region VARCHAR(20)); INSERT INTO models VALUES (1, 'datasetA', 4.3, 'Europe'), (2, 'datasetA', 4.5, 'Asia'), (3, 'datasetB', 3.9, 'Africa'), (4, 'datasetB', 4.1, 'Africa'), (5, 'datasetA', 4.2, 'North America'); | What is the minimum satisfaction score for models trained on dataset A, for each region, excluding North America? | SELECT region, MIN(satisfaction) FROM models WHERE dataset = 'datasetA' AND region != 'North America' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE risk_assessment (assessment_id INT, assesse_name VARCHAR(255), gender VARCHAR(10), assessment_score INT, assessment_year INT); INSERT INTO risk_assessment (assessment_id, assesse_name, gender, assessment_score, assessment_year) VALUES (1, 'John Doe', 'Male', 80, 2021), (2, 'Jane Smith', 'Female', 85, 2021)... | Which gender had the highest risk assessment score in 2021? | SELECT gender, MAX(assessment_score) as highest_score FROM risk_assessment WHERE assessment_year = 2021 GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists countries (country_name text); INSERT INTO countries (country_name) VALUES ('Mexico'); CREATE TABLE if not exists hotels (hotel_name text, country text, rating integer); INSERT INTO hotels (hotel_name, country, rating) VALUES ('Hotel A', 'Mexico', 4), ('Hotel B', 'Mexico', 2), ('Hotel C', 'Me... | Delete all hotels with a rating below 3 in Mexico. | DELETE FROM hotels WHERE country = 'Mexico' AND rating < 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_data (year INT, quantity INT); INSERT INTO waste_data (year, quantity) VALUES (2016, 12000), (2017, 15000), (2018, 18000), (2019, 20000), (2020, 22000); | What is the total quantity of waste produced by the fashion industry in the last 5 years? | SELECT SUM(quantity) as total_waste FROM waste_data WHERE year BETWEEN 2016 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE forest_type (forest_type_id INT, forest_type_name TEXT, PRIMARY KEY (forest_type_id)); CREATE TABLE forest (forest_id INT, forest_type_id INT, tree_species_count INT, age INT, PRIMARY KEY (forest_id), FOREIGN KEY (forest_type_id) REFERENCES forest_type(forest_type_id)); | Show the number of tree species in each forest type, along with the average age of those forests, sorted by the number of tree species in ascending order. | SELECT f.forest_type_name, AVG(f.age) AS average_age, COUNT(f.tree_species_count) AS tree_species_count FROM forest f GROUP BY f.forest_type_name ORDER BY tree_species_count ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); | Identify the top 3 countries with the highest average donation amounts in 2022. | SELECT country, AVG(donation_amount) AS avg_donation FROM Donations WHERE EXTRACT(YEAR FROM donation_date) = 2022 GROUP BY country ORDER BY avg_donation DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_initiatives (id INT, name VARCHAR(255), region VARCHAR(255), budget FLOAT); INSERT INTO community_initiatives (id, name, region, budget) VALUES (1, 'Education Center', 'Asia', 300000.00); | Identify the number of community development initiatives in Asia with a budget greater than $200,000. | SELECT COUNT(*) FROM community_initiatives WHERE region = 'Asia' AND budget > 200000; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), city VARCHAR(50), rating DECIMAL(2,1), pool BOOLEAN); INSERT INTO hotels (hotel_id, name, city, rating, pool) VALUES (1, 'Hotel Ritz', 'Paris', 4.5, true), (2, 'Hotel de Crillon', 'Paris', 4.7, false); | What is the average rating of hotels in 'Paris' that have a pool? | SELECT AVG(rating) FROM hotels WHERE city = 'Paris' AND pool = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification (id INT, country VARCHAR(50), year INT, progress DECIMAL(5,2)); INSERT INTO economic_diversification (id, country, year, progress) VALUES (1, 'Pakistan', 2018, 55.60), (2, 'Pakistan', 2019, 58.20), (3, 'Pakistan', 2020, 62.10); | What is the average economic diversification progress in Pakistan in the last 4 years? | SELECT AVG(progress) FROM economic_diversification WHERE country = 'Pakistan' AND year BETWEEN (SELECT YEAR(CURRENT_DATE) - 4) AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE ships (id INT, country_id INT, name TEXT, tonnage INT); INSERT INTO countries VALUES (1, 'Japan'), (2, 'China'), (3, 'South Korea'); INSERT INTO ships VALUES (1, 1, 'Japanese Ship 1', 10000), (2, 1, 'Japanese Ship 2', 12000), (3, 2, 'Chinese Ship 1', 15000), (4, ... | What is the total tonnage of ships from each country? | SELECT c.name, SUM(s.tonnage) as total_tonnage FROM countries c INNER JOIN ships s ON c.id = s.country_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_tech (tech_name TEXT, cost INTEGER); INSERT INTO military_tech (tech_name, cost) VALUES ('UAV', 15000), ('Satellite', 20000), ('AI System', 10000); | Return the names and costs of the top 2 most expensive military technologies. | SELECT tech_name, cost FROM (SELECT tech_name, cost, ROW_NUMBER() OVER (ORDER BY cost DESC) AS rn FROM military_tech) t WHERE rn <= 2 | gretelai_synthetic_text_to_sql |
CREATE TABLE dapps (id INT, name VARCHAR(255), category VARCHAR(50)); INSERT INTO dapps (id, name, category) VALUES (1, 'DApp1', 'Finance'); INSERT INTO dapps (id, name, category) VALUES (2, 'DApp2', 'Gaming'); INSERT INTO dapps (id, name, category) VALUES (3, 'DApp3', 'Social'); INSERT INTO dapps (id, name, category) ... | Which decentralized applications belong to the 'Finance' category? | SELECT name FROM dapps WHERE category = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID INT, Name VARCHAR(100), Grade INT); | Create a view named 'TopStudents' that selects 'Name' and 'Grade' from 'Students' table where 'Grade' is greater than or equal to 12 | CREATE VIEW TopStudents AS SELECT Name, Grade FROM Students WHERE Grade >= 12; | gretelai_synthetic_text_to_sql |
CREATE TABLE FabricInventory (InventoryID INT, Brand VARCHAR(50), Fabric VARCHAR(50), Quantity INT, InventoryDate DATE); INSERT INTO FabricInventory (InventoryID, Brand, Fabric, Quantity, InventoryDate) VALUES (1, 'BrandA', 'Organic Cotton', 500, '2022-05-01'), (2, 'BrandB', 'Recycled Polyester', 600, '2022-05-01'), (3... | What is the total quantity of each fabric type used in the last month? | SELECT Fabric, SUM(Quantity) as TotalQuantity FROM FabricInventory WHERE InventoryDate >= '2022-05-01' GROUP BY Fabric; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_grants (id INT PRIMARY KEY, name VARCHAR(50), lead_investigator_id INT, amount DECIMAL(10,2)); | Update research grant data with the new grant amount. | UPDATE research_grants SET amount = 150000 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name TEXT, year INT, co2_emission FLOAT); | What is the average CO2 emission of green buildings constructed between 2015-2020? | SELECT AVG(co2_emission) FROM green_buildings WHERE year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesign (GameName VARCHAR(50), GameEngine VARCHAR(50), GameGraphics VARCHAR(50)); INSERT INTO GameDesign (GameName, GameEngine, GameGraphics) VALUES ('Galactic Conquest', 'Unreal Engine', 'High'); INSERT INTO GameDesign (GameName, GameEngine, GameGraphics) VALUES ('Space Crusaders', 'Unity', 'Medium'); | List all the game design elements for the game 'Galactic Conquest' | SELECT * FROM GameDesign WHERE GameName = 'Galactic Conquest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_development (teacher_id INT, course_year INT, courses_completed INT); INSERT INTO teacher_development (teacher_id, course_year, courses_completed) VALUES (101, 2018, 3), (101, 2019, 2), (101, 2020, 5), (101, 2021, 4), (102, 2018, 4), (102, 2019, 1), (102, 2020, 6), (102, 2021, 3); | How many professional development courses did each teacher complete in 2019 and 2021? | SELECT teacher_id, course_year, SUM(courses_completed) FROM teacher_development WHERE course_year IN (2019, 2021) GROUP BY teacher_id, course_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE forestry.trees (id INT, species VARCHAR(50), age INT); | Get the number of trees in the 'forestry' DB for each species. | SELECT species, COUNT(*) FROM forestry.trees GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), population INT); | What is the average population of marine species with more than one record, grouped by name? | SELECT name, AVG(population) FROM marine_species GROUP BY name HAVING COUNT(id) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brand_Sustainable_Material_Monthly(Brand_ID INT, Month DATE, Quantity INT); INSERT INTO Brand_Sustainable_Material_Monthly(Brand_ID, Month, Quantity) VALUES (1, '2022-01-01', 500), (1, '2022-01-02', 500), (1, '2022-02-01', 600), (2, '2022-01-01', 600), (2, '2022-01-02', 600), (2, '2022-02-01', 700); | Find the percentage of sustainable material used by each brand in the last month as compared to the total quantity of sustainable material used by the brand in the last 3 months. | SELECT Brand_ID, (SUM(CASE WHEN Month >= DATEADD(MONTH, -1, GETDATE()) THEN Quantity ELSE 0 END) * 100.0 / SUM(Quantity) OVER (PARTITION BY Brand_ID)) as Percentage FROM Brand_Sustainable_Material_Monthly; | gretelai_synthetic_text_to_sql |
CREATE TABLE client_transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO client_transactions (transaction_id, client_id, amount, transaction_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 1, 100.00, '2022-01-15'), (3, 2, 75.00, '2022-02-03'), (4, 3, 120.00, '2022-03... | What is the total transaction amount per day for clients in the Asia region? | SELECT DATE_FORMAT(transaction_date, '%Y-%m-%d') AS date, SUM(amount) FROM client_transactions ct JOIN clients cl ON ct.client_id = cl.client_id WHERE cl.region = 'Asia' GROUP BY date; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name TEXT, department TEXT); INSERT INTO attorneys (attorney_id, name, department) VALUES (1, 'Sara Gonzalez', 'Family Law'), (2, 'Mike Johnson', 'Criminal Law'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount INT); INSERT INTO cases (case_id, attorney_id, bill... | What is the maximum billing amount for cases handled by attorneys in the family law department? | SELECT MAX(billing_amount) FROM cases WHERE attorney_id IN (SELECT attorney_id FROM attorneys WHERE department = 'Family Law') | gretelai_synthetic_text_to_sql |
CREATE TABLE Safety_Protocols (protocol_id INT, department VARCHAR(20), protocol_description VARCHAR(100), protocol_date DATE); | How many new safety protocols were added in the 'Metal Fabrication' department in the last month? | SELECT COUNT(*) FROM Safety_Protocols WHERE department = 'Metal Fabrication' AND protocol_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, name TEXT, genre TEXT, visitor_count INT); | What was the average visitor count for all exhibitions in the 'Impressionist' genre? | SELECT AVG(visitor_count) FROM Exhibitions WHERE genre = 'Impressionist'; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT, visit_year INT, exhibit_id INT); INSERT INTO visitors (id, visit_year, exhibit_id) VALUES (1, 2021, 101), (2, 2021, 102), (3, 2022, 101), (4, 2022, 103), (5, 2021, 103), (6, 2022, 101), (7, 2022, 102); | What is the percentage of repeat visitors to our exhibits in the last year? | SELECT (COUNT(DISTINCT CASE WHEN visit_year = 2021 AND visit_year = 2022 THEN visitor_id END) / COUNT(DISTINCT visitor_id)) * 100 AS percentage_repeat_visitors FROM visitors; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, name TEXT, developer_id INT, deployment_date DATE); INSERT INTO smart_contracts (id, name, developer_id, deployment_date) VALUES (1, 'ContractA', 1, '2021-01-01'), (2, 'ContractB', 2, '2020-12-15'), (3, 'ContractC', 3, '2021-03-20'), (4, 'ContractD', 4, '2021-06-01'); CREATE TABLE ... | How many smart contracts were deployed by developers from underrepresented communities in 2021? | SELECT COUNT(*) FROM smart_contracts sc JOIN underrepresented_developers ud ON sc.developer_id = ud.developer_id WHERE sc.deployment_date >= '2021-01-01' AND sc.deployment_date < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists blockchain; CREATE TABLE if not exists blockchain.digital_assets ( asset_id INT AUTO_INCREMENT, asset_name VARCHAR(255), market_cap DECIMAL(18,2), PRIMARY KEY (asset_id)); INSERT INTO blockchain.digital_assets (asset_name, market_cap) VALUES ('Bitcoin', 80000000000.00), ('Ethereum', 32000000... | What is the third-largest digital asset by market cap? | SELECT asset_name, market_cap FROM ( SELECT asset_name, market_cap, ROW_NUMBER() OVER (ORDER BY market_cap DESC) AS row_num FROM blockchain.digital_assets ) AS subquery WHERE row_num = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_equity_metrics (id INT, worker_id INT, metric1 BOOLEAN, metric2 BOOLEAN, metric3 BOOLEAN); INSERT INTO health_equity_metrics (id, worker_id, metric1, metric2, metric3) VALUES (1, 1, true, true, false), (2, 2, true, false, true), (3, 3, false, true, true); | What is the percentage of health equity metrics met by each community health worker? | SELECT worker_id, (SUM(CASE WHEN metric1 THEN 1 ELSE 0 END) + SUM(CASE WHEN metric2 THEN 1 ELSE 0 END) + SUM(CASE WHEN metric3 THEN 1 ELSE 0 END)) * 100.0 / 3 as percentage_met FROM health_equity_metrics GROUP BY worker_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_development (id INT AUTO_INCREMENT, employee_name VARCHAR(50), role VARCHAR(50), years_of_experience INT, PRIMARY KEY(id)); | Delete the record with id 1 in the 'workforce_development' table | DELETE FROM workforce_development WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (id INT, artist_name VARCHAR(255), gender VARCHAR(10), ethnicity VARCHAR(255)); CREATE TABLE Artworks (id INT, artist_id INT, artwork_name VARCHAR(255), year_created INT, price FLOAT); INSERT INTO Artists (id, artist_name, gender, ethnicity) VALUES (1, 'Vincent van Gogh', 'Male', 'Dutch'); | Insert a new artwork 'The Starry Night' created by 'Vincent van Gogh' in 1889 | INSERT INTO Artworks (id, artist_id, artwork_name, year_created, price) VALUES (6, 1, 'The Starry Night', 1889, NULL); UPDATE Artists SET id = 1 WHERE artist_name = 'Vincent van Gogh'; UPDATE Artworks SET artist_id = 1 WHERE artwork_name = 'The Starry Night'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Carlos Garcia', 'Colombia'), (2, 'Maria Rodriguez', 'Cuba'), (3, 'James Smith', 'USA'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL); INSERT INTO Donations (Donat... | What's the total amount donated by individual donors from Latin America and the Caribbean? | SELECT SUM(DonationAmount) FROM Donations D JOIN Donors DON ON D.DonorID = DON.DonorID WHERE DON.Country IN ('Colombia', 'Cuba', 'Puerto Rico'); | 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.