context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE sales_region (id INT, region VARCHAR(255)); INSERT INTO sales_region (id, region) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE equipment_sales (id INT, region_id INT, equipment_name VARCHAR(255), sale_date DATE, revenue INT); INSERT INTO equipment_sales (id, region_id, equipment_name, sale_date, revenue) VALUES (1, 1, 'Tank A', '2022-01-05', 500000), (2, 2, 'Helicopter B', '2022-02-10', 600000), (3, 3, 'Drone C', '2022-03-20', 400000), (4, 4, 'Jeep D', '2022-04-01', 700000), (5, 5, 'Ship E', '2022-05-15', 800000); | What is the total military equipment sales revenue per sales region in Q1 2022? | SELECT region, SUM(revenue) AS total_revenue FROM equipment_sales INNER JOIN sales_region ON equipment_sales.region_id = sales_region.id WHERE QUARTER(sale_date) = 1 AND YEAR(sale_date) = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE tickets (ticket_id INT, game_type VARCHAR(50), region VARCHAR(50), ticket_price DECIMAL(5,2)); INSERT INTO tickets (ticket_id, game_type, region) VALUES (1, 'Soccer', 'Southern Region'), (2, 'Baseball', 'Southern Region'), (3, 'Soccer', 'Southern Region'), (4, 'Basketball', 'Northern Region'), (5, 'Soccer', 'Southern Region'), (6, 'Hockey', 'Eastern Region'); INSERT INTO tickets (ticket_id, game_type, region, ticket_price) VALUES (7, 'Soccer', 'Southern Region', 35.00), (8, 'Baseball', 'Southern Region', 25.00), (9, 'Soccer', 'Southern Region', 40.00), (10, 'Basketball', 'Northern Region', 50.00), (11, 'Soccer', 'Southern Region', 30.00), (12, 'Hockey', 'Eastern Region', 60.00); | What is the average ticket price for soccer games in the 'Southern Region'? | SELECT AVG(ticket_price) FROM tickets WHERE game_type = 'Soccer' AND region = 'Southern Region'; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, size FLOAT, coowners INT, PRIMARY KEY (id)); INSERT INTO properties (id, size, coowners) VALUES (1, 1200.0, 2), (2, 800.0, 1), (3, 1500.0, 3); | What is the average size of co-owned properties in the 'properties' table? | SELECT AVG(size) FROM properties WHERE coowners > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (isp_id INT, compliance_date DATE, status VARCHAR(255)); | Create a table named 'regulatory_compliance' with columns 'isp_id', 'compliance_date' and 'status'. Then, insert records for the given isp_ids that meet specific compliance regulations. | INSERT INTO regulatory_compliance (isp_id, compliance_date, status) VALUES (1, '2021-01-01', 'compliant'), (2, '2021-02-15', 'non-compliant'), (3, '2021-03-01', 'compliant'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Location) VALUES (1, 'Green Markets', 'Michigan'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, Category VARCHAR(50), IsHalal BOOLEAN, Price DECIMAL(5, 2)); INSERT INTO Products (ProductID, ProductName, SupplierID, Category, IsHalal, Price) VALUES (1, 'Halal Beef', 1, 'Meat', true, 15.00); CREATE TABLE Sales (SaleID INT, ProductID INT, Quantity INT, SaleDate DATE, SupplierID INT); INSERT INTO Sales (SaleID, ProductID, Quantity, SaleDate, SupplierID) VALUES (1, 1, 20, '2022-03-15', 1); | List the top 5 suppliers with the highest revenue from halal products in the last month? | SELECT Suppliers.SupplierName, SUM(Products.Price * Sales.Quantity) AS Revenue FROM Suppliers JOIN Products ON Suppliers.SupplierID = Products.SupplierID JOIN Sales ON Products.ProductID = Sales.ProductID WHERE Products.IsHalal = true AND Sales.SaleDate >= DATEADD(MONTH, -1, GETDATE()) GROUP BY Suppliers.SupplierName ORDER BY Revenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT, object_id VARCHAR(50), object_name VARCHAR(50), mass FLOAT, size FLOAT); | What is the total mass (in kg) of all space debris objects larger than 1 cm in size? | SELECT SUM(mass) FROM space_debris WHERE size > 1.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (id INT, origin_city VARCHAR(255), destination_city VARCHAR(255), distance INT, etd DATE, eta DATE); CREATE TABLE Warehouse (id INT, country VARCHAR(255), city VARCHAR(255), opened_date DATE); | List the warehouses that have a higher average delivery time to Canada than to Mexico? | SELECT w.country, w.city FROM Warehouse w JOIN (SELECT origin_city, AVG(DATEDIFF(day, etd, eta)) as avg_delivery_time FROM Routes WHERE destination_city IN (SELECT city FROM Warehouse WHERE country = 'Canada') GROUP BY origin_city) r1 ON w.city = r1.origin_city JOIN (SELECT origin_city, AVG(DATEDIFF(day, etd, eta)) as avg_delivery_time FROM Routes WHERE destination_city IN (SELECT city FROM Warehouse WHERE country = 'Mexico') GROUP BY origin_city) r2 ON w.city = r2.origin_city WHERE r1.avg_delivery_time > r2.avg_delivery_time; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_genres(genre_id INT, name VARCHAR(50)); CREATE TABLE artist_activity(artist_id INT, genre_id INT, streams INT); | What is the average number of music streams per artist for each music genre? | SELECT music_genres.name, AVG(artist_activity.streams) AS avg_streams FROM music_genres JOIN artist_activity ON music_genres.genre_id = artist_activity.genre_id GROUP BY music_genres.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, order_date DATE, sustainable BOOLEAN); | How many sustainable fabric orders were there per day in the past week? | SELECT order_date, COUNT(*) FROM orders WHERE sustainable = TRUE AND order_date >= DATEADD(week, -1, CURRENT_DATE) GROUP BY order_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, is_vegan BOOLEAN, country VARCHAR(255), sales FLOAT); INSERT INTO products (product_id, is_vegan, country, sales) VALUES (1, true, 'US', 1200), (2, false, 'CA', 2000), (3, true, 'US', 1500), (4, false, 'MX', 800); | What is the percentage of vegan cosmetic products, by country, with sales greater than $1000, partitioned by country and ordered by sales in descending order? | SELECT country, 100.0 * COUNT(*) / SUM(COUNT(*)) OVER (PARTITION BY NULL) as percentage FROM products WHERE is_vegan = true AND sales > 1000 GROUP BY country ORDER BY percentage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE cargo_operations (id INT, port_id INT, company VARCHAR(50), type VARCHAR(50), weight INT); INSERT INTO ports (id, name, country) VALUES (1, 'Port of Oakland', 'USA'), (2, 'Port of Singapore', 'Singapore'), (3, 'Port of Hong Kong', 'China'), (4, 'Port of Rotterdam', 'Netherlands'); INSERT INTO cargo_operations (id, port_id, company, type, weight) VALUES (1, 1, 'Poseidon Shipping', 'import', 5000), (2, 1, 'Poseidon Shipping', 'export', 7000), (3, 3, 'Poseidon Shipping', 'import', 8000), (4, 3, 'Poseidon Shipping', 'export', 9000), (5, 4, 'Poseidon Shipping', 'import', 6000), (6, 4, 'Poseidon Shipping', 'export', 4000), (7, 1, 'Poseidon Shipping', 'import', 5500), (8, 1, 'Poseidon Shipping', 'export', 7500); | What is the average weight of cargo imported and exported by the company 'Poseidon Shipping' | SELECT AVG(weight) FROM cargo_operations WHERE company = 'Poseidon Shipping' AND (type = 'import' OR type = 'export'); | gretelai_synthetic_text_to_sql |
CREATE TABLE feedback (id INT, year INT, service TEXT, sentiment TEXT); INSERT INTO feedback (id, year, service, sentiment) VALUES (1, 2021, 'Healthcare', 'Positive'), (2, 2022, 'Healthcare', 'Neutral'); | How many citizens provided positive feedback for healthcare services in 2021? | SELECT COUNT(*) FROM feedback WHERE year = 2021 AND service = 'Healthcare' AND sentiment = 'Positive'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (mission_id INT, name VARCHAR(50), country VARCHAR(50), launch_date DATE); INSERT INTO SpaceMissions (mission_id, name, country, launch_date) VALUES (1, 'Chandrayaan-1', 'India', '2008-10-22'); | Which countries have launched the most space missions? | SELECT country, COUNT(mission_id) FROM SpaceMissions GROUP BY country ORDER BY COUNT(mission_id) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(255), studio VARCHAR(255), rating FLOAT); INSERT INTO movies (title, genre, studio, rating) VALUES ('Movie7', 'Action', 'France Studio1', 6.5), ('Movie8', 'Drama', 'France Studio2', 5.0); | Find the title and genre of the bottom 2 movies with the lowest ratings from studios based in France, ordered by ratings in ascending order. | SELECT title, genre FROM (SELECT title, genre, studio, rating, ROW_NUMBER() OVER (PARTITION BY studio ORDER BY rating ASC) as rank FROM movies WHERE studio LIKE '%France%') subquery WHERE rank <= 2 ORDER BY rating ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE aquaculture_facilities_v2 (id INT, facility_name VARCHAR(50), location VARCHAR(50), facility_type VARCHAR(50), biomass FLOAT); INSERT INTO aquaculture_facilities_v2 (id, facility_name, location, facility_type, biomass) VALUES (1, 'Facility H', 'Asia', 'Fish Farm', 2500), (2, 'Facility I', 'Europe', 'Hatchery', 1000), (3, 'Facility J', 'Asia', 'Hatchery', 3000), (4, 'Facility K', 'Africa', 'Fish Farm', 1000); | List the top 3 aquaculture facility types in Asia with the highest biomass. | SELECT facility_type, AVG(biomass) as avg_biomass FROM aquaculture_facilities_v2 WHERE location = 'Asia' GROUP BY facility_type ORDER BY avg_biomass DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, severity INT, timestamp TIMESTAMP); INSERT INTO vulnerabilities (id, severity, timestamp) VALUES (1, 8, '2022-01-20 16:30:00'), (2, 5, '2022-01-18 09:00:00'); | What are the vulnerabilities that were found in the last week and have a severity rating of 7 or higher? | SELECT * FROM vulnerabilities WHERE severity >= 7 AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(50), population INT); | Delete all marine species records with a population less than 50 | DELETE FROM marine_species WHERE population < 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_safety_inspections (location VARCHAR(255), inspection_date DATE, violations INT); INSERT INTO food_safety_inspections (location, inspection_date, violations) VALUES ('Location A', '2022-01-01', 3), ('Location B', '2022-01-02', 5), ('Location A', '2022-01-03', 2), ('Location C', '2022-01-04', 4), ('Location A', '2022-01-05', 1); | What is the number of food safety inspections and average number of violations for each location in the past year? | SELECT location, COUNT(*) as total_inspections, AVG(violations) as average_violations FROM food_safety_inspections WHERE inspection_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Buses (id INT, model VARCHAR(255), last_maintenance DATETIME); | Which buses have not had a maintenance check in the last 3 months? | SELECT B.id, B.model FROM Buses B LEFT JOIN (SELECT bus_id, MAX(last_maintenance) as max_maintenance FROM Buses GROUP BY bus_id) BM ON B.id = BM.bus_id WHERE B.last_maintenance < BM.max_maintenance - INTERVAL 3 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO customers (customer_id, name, region) VALUES (1, 'Li Mei', 'Asia-Pacific'), (2, 'Park Soo-Young', 'Asia-Pacific'), (3, 'Jon Tsukuda', 'Asia-Pacific'); | What is the number of customers in the Asia-Pacific region? | SELECT region, COUNT(*) FROM customers WHERE region = 'Asia-Pacific' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityCommittees (CommitteeID INT PRIMARY KEY, CommitteeName VARCHAR(50), CommitteeDescription VARCHAR(255)); CREATE TABLE CommitteeMembers (MemberID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), CommitteeID INT, FOREIGN KEY (CommitteeID) REFERENCES CityCommittees(CommitteeID)); INSERT INTO CityCommittees (CommitteeID, CommitteeName, CommitteeDescription) VALUES (1, 'Public Works Committee', 'Committee responsible for overseeing city public works'), (2, 'Health Committee', 'Committee responsible for overseeing city health'); INSERT INTO CommitteeMembers (MemberID, FirstName, LastName, CommitteeID) VALUES (1, 'Jane', 'Smith', 2); | Who are the members of the Health Committee? | SELECT Members.FirstName, Members.LastName FROM CommitteeMembers AS Members JOIN CityCommittees ON Members.CommitteeID = CityCommittees.CommitteeID WHERE CityCommittees.CommitteeName = 'Health Committee'; | gretelai_synthetic_text_to_sql |
CREATE TABLE voter_registration (voter_id INT, voter_name VARCHAR(255), registration_date DATE, new_address VARCHAR(255)); | How many registered voters have changed their address in 'voter_registration' table, in the last 6 months? | SELECT COUNT(voter_id) FROM (SELECT voter_id FROM voter_registration WHERE new_address IS NOT NULL AND registration_date >= DATEADD(month, -6, GETDATE())) AS address_changes; | gretelai_synthetic_text_to_sql |
CREATE TABLE sector_waste (id INT, sector VARCHAR(50), month DATE, waste_kg INT); INSERT INTO sector_waste (id, sector, month, waste_kg) VALUES (1, 'Industrial', '2021-01-01', 200), (2, 'Commercial', '2021-01-01', 150), (3, 'Residential', '2021-01-01', 120), (4, 'Industrial', '2021-02-01', 180), (5, 'Commercial', '2021-02-01', 140), (6, 'Residential', '2021-02-01', 110); | How much waste is generated by each sector per month? | SELECT sector, EXTRACT(MONTH FROM month) AS month, SUM(waste_kg) FROM sector_waste GROUP BY sector, EXTRACT(MONTH FROM month); | gretelai_synthetic_text_to_sql |
CREATE TABLE ShariahCompliantTransactions (transactionID INT, userID VARCHAR(20), transactionAmount DECIMAL(10,2), transactionDate DATE); INSERT INTO ShariahCompliantTransactions (transactionID, userID, transactionAmount, transactionDate) VALUES (1, 'JohnDoe', 500.00, '2022-01-01'), (2, 'JaneDoe', 300.00, '2022-01-02'); | Calculate the average transaction amount for users in the ShariahCompliantTransactions table. | SELECT AVG(transactionAmount) FROM ShariahCompliantTransactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE Oil_Spills (id INT, spill_name VARCHAR(50), location VARCHAR(50), volume FLOAT); INSERT INTO Oil_Spills (id, spill_name, location, volume) VALUES (1, 'MT Haven', 'Mediterranean Sea', 140000); | Find oil spills larger than 50,000 cubic meters in the Mediterranean | SELECT spill_name, volume FROM Oil_Spills WHERE location = 'Mediterranean Sea' AND volume > 50000; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, mine_name TEXT, location TEXT, material TEXT, quantity INT, date DATE); INSERT INTO mining_operations (id, mine_name, location, material, quantity, date) VALUES (11, 'Copper Core', 'Australia', 'copper', 5000, '2019-01-01'); | Show the total amount of copper mined in Australia in 2019 | SELECT SUM(quantity) FROM mining_operations WHERE material = 'copper' AND location = 'Australia' AND date = '2019-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, age INT, gender TEXT); INSERT INTO users (id, age, gender) VALUES ('1', '25', 'Female'), ('2', '35', 'Male'), ('3', '45', 'Non-binary'); CREATE TABLE likes (user_id INT, article_id INT); INSERT INTO likes (user_id, article_id) VALUES ('1', '123'), ('2', '123'), ('3', '456'); | Who is the youngest user who has liked an article? | SELECT users.age FROM users JOIN likes ON users.id = likes.user_id GROUP BY users.id HAVING COUNT(*) > 0 ORDER BY users.age ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tournament (Team VARCHAR(50), MatchesPlayed INT, MatchesWon INT); INSERT INTO Tournament (Team, MatchesPlayed, MatchesWon) VALUES ('Team A', 10, 7); INSERT INTO Tournament (Team, MatchesPlayed, MatchesWon) VALUES ('Team B', 12, 9); INSERT INTO Tournament (Team, MatchesPlayed, MatchesWon) VALUES ('Team C', 8, 5); | Determine the team with the highest win rate in the eSports tournament. | SELECT Team, 100.0 * SUM(MatchesWon) / SUM(MatchesPlayed) AS WinRate FROM Tournament GROUP BY Team ORDER BY WinRate DESC FETCH FIRST 1 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkerHours (Id INT, Name VARCHAR(50), ProjectId INT, Hours FLOAT, State VARCHAR(50), WorkDate DATE); INSERT INTO WorkerHours (Id, Name, ProjectId, Hours, State, WorkDate) VALUES (1, 'Jane Doe', 1, 8, 'Arizona', '2020-01-01'); | What is the average number of hours worked per day by construction workers in Arizona? | SELECT State, AVG(Hours/DATEDIFF(WorkDate, DATE_FORMAT(WorkDate, '%Y-%m-%d') + INTERVAL 1 DAY)) AS AvgHoursPerDay FROM WorkerHours GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE Social_Good_Tech_Africa (country VARCHAR(50), project_type VARCHAR(50), projects INT); INSERT INTO Social_Good_Tech_Africa (country, project_type, projects) VALUES ('Nigeria', 'social_good_tech', 100), ('Nigeria', 'digital_divide', 120), ('Kenya', 'social_good_tech', 80), ('Kenya', 'digital_divide', 110), ('Egypt', 'social_good_tech', 150), ('Egypt', 'digital_divide', 130); | What is the total number of social good technology projects and digital divide reduction programs in the top 3 most active countries in Africa in H1 and H2 of 2022? | SELECT Social_Good_Tech_Africa.country, SUM(Social_Good_Tech_Africa.projects) FROM Social_Good_Tech_Africa WHERE Social_Good_Tech_Africa.country IN (SELECT Social_Good_Tech_Africa.country FROM Social_Good_Tech_Africa GROUP BY Social_Good_Tech_Africa.country ORDER BY SUM(Social_Good_Tech_Africa.projects) DESC LIMIT 3) GROUP BY Social_Good_Tech_Africa.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE VendorParticipation (ParticipationID INT, Country VARCHAR(50), Vendors INT); INSERT INTO VendorParticipation (ParticipationID, Country, Vendors) VALUES (1, 'Mexico', 50), (2, 'Mexico', 60); | What is the increase in the number of local vendors participating in sustainable events in Mexico? | SELECT SUM(Vendors) FROM VendorParticipation WHERE Country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_probes (id INT, name VARCHAR(255), country VARCHAR(255), launch_date DATE, mass FLOAT); INSERT INTO space_probes (id, name, country, launch_date, mass) VALUES (1, 'Voyager 1', 'USA', '1977-09-05', 825.0); INSERT INTO space_probes (id, name, country, launch_date, mass) VALUES (2, 'Cassini', 'USA', '1997-10-15', 5712.0); | What is the average mass of all space probes launched by NASA? | SELECT AVG(mass) FROM space_probes WHERE country = 'USA' AND type = 'Space Probe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists sydney_ferry_trips (id INT, trip_id INT, fare DECIMAL(5,2), route_id INT, vehicle_id INT, timestamp TIMESTAMP); | What is the maximum fare for ferry trips in Sydney? | SELECT MAX(fare) FROM sydney_ferry_trips WHERE fare IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEngagement (id INT, country VARCHAR(255), year INT, events INT); INSERT INTO CommunityEngagement (id, country, year, events) VALUES (1, 'Country A', 2021, 10), (2, 'Country B', 2021, 7), (3, 'Country A', 2020, 8), (4, 'Country B', 2020, 12); | How many community engagement events were held in each country last year? | SELECT country, year, SUM(events) FROM CommunityEngagement GROUP BY country, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE sourcing (id INT, fabric_type VARCHAR(20), country VARCHAR(10), quantity INT); INSERT INTO sourcing (id, fabric_type, country, quantity) VALUES (1, 'organic cotton', 'Kenya', 500), (2, 'recycled polyester', 'South Africa', 750); | What is the total quantity of sustainable fabric sourced from Africa? | SELECT SUM(quantity) FROM sourcing WHERE fabric_type LIKE 'sustainable%' AND country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE foodborne_illness (report_id INT, region VARCHAR(255), year INT); INSERT INTO foodborne_illness (report_id, region, year) VALUES (1, 'Northeast', 2019), (2, 'Southeast', 2018), (3, 'Midwest', 2019); | How many cases of foodborne illness were reported in each region in 2019? | SELECT region, COUNT(*) FROM foodborne_illness WHERE year = 2019 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (country VARCHAR(50), year INT, genre VARCHAR(50), price DECIMAL(5,2)); INSERT INTO Concerts (country, year, genre, price) VALUES ('Canada', 2022, 'Jazz', 65.99); INSERT INTO Concerts (country, year, genre, price) VALUES ('Canada', 2022, 'Jazz', 60.49); | What is the maximum ticket price for Jazz concerts in Canada in 2022? | SELECT MAX(price) FROM Concerts WHERE country = 'Canada' AND year = 2022 AND genre = 'Jazz'; | gretelai_synthetic_text_to_sql |
CREATE TABLE zip_codes (zip_code INT, name VARCHAR(255)); CREATE TABLE properties (property_id INT, size INT, zip_code INT, PRIMARY KEY (property_id), FOREIGN KEY (zip_code) REFERENCES zip_codes(zip_code)); CREATE TABLE inclusive_housing_policies (property_id INT, PRIMARY KEY (property_id), FOREIGN KEY (property_id) REFERENCES properties(property_id)); | Find the ratio of properties with inclusive housing policies to the total number of properties for each zip code. | SELECT zip_codes.name, 100.0 * COUNT(inclusive_housing_policies.property_id) / COUNT(properties.property_id) as pct FROM zip_codes LEFT JOIN properties ON zip_codes.zip_code = properties.zip_code LEFT JOIN inclusive_housing_policies ON properties.property_id = inclusive_housing_policies.property_id GROUP BY zip_codes.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_access_2 (id INT, community TEXT, location TEXT, metric TEXT); INSERT INTO healthcare_access_2 (id, community, location, metric) VALUES (1, 'Community A', 'rural', 'Accessibility'), (2, 'Community B', 'urban', 'Availability'), (3, 'Community A', 'rural', 'Quality'); | What is the maximum number of healthcare access metrics for rural communities, grouped by community? | SELECT community, MAX(COUNT(*)) FROM healthcare_access_2 WHERE location = 'rural' GROUP BY community; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(50), city VARCHAR(50), has_ai_tech BOOLEAN); INSERT INTO Hotels (hotel_id, hotel_name, city, has_ai_tech) VALUES (1, 'Hotel1', 'CityA', TRUE), (2, 'Hotel2', 'CityB', FALSE); | How many hotels in 'CityA' have adopted AI technology? | SELECT COUNT(*) FROM Hotels WHERE city = 'CityA' AND has_ai_tech = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'C123', 500, 'USA'), (2, 'C456', 300, 'Canada'), (3, 'C123', 100, 'Germany'), (4, 'C456', 250, 'USA'), (5, 'C456', 350, 'Canada'), (6, 'C123', 400, 'Mexico'); | Find the country with the highest production quantity of chemical 'C123' | SELECT country FROM chemical_production WHERE chemical_id = 'C123' GROUP BY country ORDER BY SUM(quantity) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_conservation_funding (project_id INT PRIMARY KEY, funding_source VARCHAR(50), amount INT); | Insert a new record in the 'water_conservation_funding' table with the following data: project_id = 5, funding_source = 'State Grants', amount = 50000 | INSERT INTO water_conservation_funding (project_id, funding_source, amount) VALUES (5, 'State Grants', 50000); | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_type VARCHAR(255), likes INT); | Get the average number of likes per post for each user, pivoted by post type in the "posts" table | SELECT user_id, SUM(CASE WHEN post_type = 'photo' THEN likes ELSE 0 END) / COUNT(CASE WHEN post_type = 'photo' THEN 1 ELSE NULL END) AS photo_avg, SUM(CASE WHEN post_type = 'video' THEN likes ELSE 0 END) / COUNT(CASE WHEN post_type = 'video' THEN 1 ELSE NULL END) AS video_avg, SUM(CASE WHEN post_type = 'text' THEN likes ELSE 0 END) / COUNT(CASE WHEN post_type = 'text' THEN 1 ELSE NULL END) AS text_avg FROM posts GROUP BY user_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_revenue (restaurant_id INT, cuisine VARCHAR(255), revenue FLOAT); INSERT INTO restaurant_revenue (restaurant_id, cuisine, revenue) VALUES (1, 'Italian', 5000.00), (2, 'Mexican', 6000.00), (3, 'Italian', 4000.00), (4, 'Italian', 7000.00), (5, 'Mexican', 8000.00), (6, 'Mexican', 9000.00); | Which cuisine type has the highest average revenue? | SELECT cuisine, AVG(revenue) as avg_revenue FROM restaurant_revenue GROUP BY cuisine ORDER BY avg_revenue DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, name VARCHAR(50), county VARCHAR(25), state VARCHAR(25)); INSERT INTO mental_health_facilities (facility_id, name, county, state) VALUES (1, 'Sunshine Mental Health', 'Harris County', 'Texas'); INSERT INTO mental_health_facilities (facility_id, name, county, state) VALUES (2, 'Serenity Mental Health', 'Los Angeles County', 'California'); INSERT INTO mental_health_facilities (facility_id, name, county, state) VALUES (3, 'Harmony Mental Health', 'Dallas County', 'Texas'); | What is the minimum number of mental health facilities in each county in Texas? | SELECT county, MIN(facility_id) FROM mental_health_facilities WHERE state = 'Texas' GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE audience_demographics (id INT, name VARCHAR(50), gender VARCHAR(20), age INT); INSERT INTO audience_demographics (id, name, gender, age) VALUES (1, 'Young Adults', 'Female', 25), (2, 'Middle Aged', 'Male', 45), (3, 'Senior Citizens', 'Non-binary', 55), (4, 'Teenagers', 'Male', 15), (5, 'Young Adults', 'Non-binary', 32); | What is the minimum age for audience demographics in the "audience_demographics" table with a gender of 'Non-binary'? | SELECT MIN(age) FROM audience_demographics WHERE gender = 'Non-binary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inclusive_units (id INT, city VARCHAR(20), property_type VARCHAR(20), units INT); INSERT INTO inclusive_units (id, city, property_type, units) VALUES (1, 'Paris', 'Apartment', 100), (2, 'Paris', 'House', 50), (3, 'London', 'Apartment', 150), (4, 'London', 'House', 75); | What is the total number of inclusive housing units available in each city, grouped by property type? | SELECT city, property_type, SUM(units) FROM inclusive_units GROUP BY city, property_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge (bridge_id INT, state VARCHAR(20), construction_cost DECIMAL(10,2), resilience_score DECIMAL(3,2)); INSERT INTO Bridge (bridge_id, state, construction_cost, resilience_score) VALUES (1, 'California', 1500000.00, 80.00), (2, 'Texas', 2000000.00, 85.00); | What is the correlation between construction cost and resilience score for bridges in California? | SELECT CORR(construction_cost, resilience_score) FROM Bridge WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name TEXT, location TEXT, water_consumption FLOAT); INSERT INTO mining_operations (id, name, location, water_consumption) VALUES (1, 'Gold Ridge Mine', 'California', 1200000); | What is the total amount of water consumed by the mining operations in California last year? | SELECT SUM(water_consumption) FROM mining_operations WHERE location = 'California' AND EXTRACT(YEAR FROM timestamp) = EXTRACT(YEAR FROM CURRENT_DATE) - 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_violations_canada (id INT, report_date DATE, state TEXT, incident_count INT); INSERT INTO labor_violations_canada (id, report_date, state, incident_count) VALUES (1, '2022-01-01', 'Ontario', 25); INSERT INTO labor_violations_canada (id, report_date, state, incident_count) VALUES (2, '2022-02-01', 'Quebec', 30); | What is the number of labor rights violation incidents per month in the past year for each state in Canada, ordered by month? | SELECT state, DATE_TRUNC('month', report_date) as month, SUM(incident_count) as total_incidents FROM labor_violations_canada WHERE report_date >= DATE_TRUNC('year', NOW() - INTERVAL '1 year') GROUP BY state, month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (state VARCHAR(20), year INT, permits INT); INSERT INTO building_permits VALUES ('Texas', 2021, 12000), ('Texas', 2020, 11000), ('Florida', 2021, 15000); | How many building permits were issued in Texas in 2021? | SELECT permits FROM building_permits WHERE state = 'Texas' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA PrecisionFarming; CREATE TABLE IoT_Sensors (sensor_id INT, sensor_name VARCHAR(50), measurement VARCHAR(50)); INSERT INTO IoT_Sensors (sensor_id, sensor_name, measurement) VALUES (1, 'Sensor1', 'temperature'), (2, 'Sensor2', 'humidity'); | Find the number of IoT sensors in the 'PrecisionFarming' schema that have a 'temperature' measurement. | SELECT COUNT(*) FROM PrecisionFarming.IoT_Sensors WHERE measurement = 'temperature'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (strain_type VARCHAR(10), state VARCHAR(20), production_quantity INT); INSERT INTO production (strain_type, state, production_quantity) VALUES ('indica', 'California', 100); INSERT INTO production (strain_type, state, production_quantity) VALUES ('sativa', 'California', 200); INSERT INTO production (strain_type, state, production_quantity) VALUES ('indica', 'Colorado', 150); INSERT INTO production (strain_type, state, production_quantity) VALUES ('sativa', 'Colorado', 250); | Compare the production quantity of indica and sativa strains in California and Colorado. | SELECT strain_type, state, production_quantity FROM production WHERE state IN ('California', 'Colorado') ORDER BY state, strain_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE rare_earth_production (year INT, element VARCHAR(10), production_quantity FLOAT); INSERT INTO rare_earth_production (year, element, production_quantity) VALUES (2015, 'Neodymium', 12000), (2016, 'Neodymium', 15000), (2017, 'Neodymium', 18000), (2018, 'Neodymium', 20000), (2019, 'Neodymium', 22000), (2020, 'Neodymium', 25000), (2021, 'Neodymium', 28000), (2015, 'Dysprosium', 1000), (2016, 'Dysprosium', 1200), (2017, 'Dysprosium', 1400), (2018, 'Dysprosium', 1500), (2019, 'Dysprosium', 1700), (2020, 'Dysprosium', 2000), (2021, 'Dysprosium', 2300), (2019, 'Lanthanum', 3000), (2020, 'Lanthanum', 3500), (2021, 'Lanthanum', 4000); | What is the total production quantity of all rare earth elements in 2020, from the 'rare_earth_production' table? | SELECT SUM(production_quantity) FROM rare_earth_production WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cities (city_id INT, name TEXT, country TEXT, population INT); CREATE TABLE Hotels (hotel_id INT, city_id INT, name TEXT, stars FLOAT); INSERT INTO Cities (city_id, name, country, population) VALUES (1, 'New York', 'USA', 8500000), (2, 'Los Angeles', 'USA', 4000000), (3, 'Paris', 'France', 2200000), (4, 'Rio de Janeiro', 'Brazil', 6500000); INSERT INTO Hotels (hotel_id, city_id, name, stars) VALUES (1, 1, 'Central Park Hotel', 4.3), (2, 1, 'Times Square Hotel', 4.1), (3, 2, 'Hollywood Hotel', 4.5), (4, 2, 'Santa Monica Hotel', 4.7), (5, 3, 'Eiffel Tower Hotel', 4.6), (6, 3, 'Louvre Hotel', 4.8), (7, 4, 'Copacabana Hotel', 4.4); | What is the average rating of hotels in the top 3 most popular cities for virtual tours? | SELECT AVG(stars) FROM Hotels INNER JOIN (SELECT city_id FROM Cities ORDER BY population DESC LIMIT 3) AS top_cities ON Hotels.city_id = top_cities.city_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE PatientTreatmentCosts (PatientID INT, Condition VARCHAR(50), TreatmentCost DECIMAL(10,2), CompletedProgram BOOLEAN); | What is the average treatment cost for patients with depression who have completed a treatment program? | SELECT AVG(TreatmentCost) FROM PatientTreatmentCosts WHERE Condition = 'depression' AND CompletedProgram = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (building_id INT, city VARCHAR(255), energy_efficiency FLOAT); INSERT INTO buildings (building_id, city, energy_efficiency) VALUES (1, 'Berlin', 150), (2, 'Berlin', 160), (3, 'Berlin', 140), (4, 'Berlin', 170), (5, 'Berlin', 130), (6, 'Paris', 180), (7, 'Paris', 190), (8, 'Paris', 175), (9, 'London', 190), (10, 'London', 180), (11, 'London', 170); | What is the energy efficiency (in kWh/m2) of the most efficient building in the city of Paris? | SELECT MAX(energy_efficiency) FROM buildings WHERE city = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (id INT, name VARCHAR(255), country VARCHAR(255), registered_date DATE); INSERT INTO Suppliers (id, name, country, registered_date) VALUES (1, 'Supplier X', 'Country X', '2021-01-01'); INSERT INTO Suppliers (id, name, country, registered_date) VALUES (2, 'Supplier Y', 'Country Y', '2021-02-01'); INSERT INTO Suppliers (id, name, country, registered_date) VALUES (3, 'Supplier Z', 'Country Z', '2020-01-01'); | Find the average registration duration for suppliers from 'Country Z'? | SELECT country, AVG(DATEDIFF(CURDATE(), registered_date)) as avg_registration_duration FROM Suppliers WHERE country = 'Country Z' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE households (id INT, city VARCHAR(50), state VARCHAR(50), size INT); INSERT INTO households (id, city, state, size) VALUES (1, 'City A', 'California', 3), (2, 'City B', 'California', 4), (3, 'City C', 'Texas', 5); | What is the average household size in each city in the state of California? | SELECT state, city, AVG(size) as avg_size FROM households WHERE state = 'California' GROUP BY state, city; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, state VARCHAR(50), quarter VARCHAR(10), strain VARCHAR(50), revenue INT); | Insert a new sale for the state of Texas in Q4 2022 with a revenue of 25000 and a strain of "Green Crack" | INSERT INTO sales (state, quarter, strain, revenue) VALUES ('Texas', 'Q4', 'Green Crack', 25000); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name TEXT, disability TEXT, sign_language_interpreter BOOLEAN); INSERT INTO students (id, name, disability, sign_language_interpreter) VALUES (1, 'John Doe', 'hearing impairment', true); INSERT INTO students (id, name, disability, sign_language_interpreter) VALUES (2, 'Jane Smith', 'learning disability', false); | How many students with hearing impairments have utilized sign language interpreters in the past year? | SELECT COUNT(*) FROM students WHERE disability = 'hearing impairment' AND sign_language_interpreter = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (drug_name TEXT, approval_quarter TEXT, year INTEGER, approved BOOLEAN); INSERT INTO drug_approval (drug_name, approval_quarter, year, approved) VALUES ('DrugT', 'Q1', 2021, true), ('DrugT', 'Q2', 2021, true), ('DrugU', 'Q3', 2021, true), ('DrugV', 'Q4', 2021, true), ('DrugW', 'Q1', 2021, true), ('DrugX', 'Q2', 2021, true); | Count the number of drug approvals for each quarter in 2021. | SELECT approval_quarter, COUNT(*) as drugs_approved FROM drug_approval WHERE year = 2021 AND approved = true GROUP BY approval_quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (id INT, company_name VARCHAR(50), initiative VARCHAR(50)); INSERT INTO circular_economy_initiatives (id, company_name, initiative) VALUES (1, 'Company M', 'Product Remanufacturing'), (2, 'Company N', 'Product Repurposing'); | What companies have implemented a circular economy initiative for Product Repurposing? | SELECT * FROM circular_economy_initiatives WHERE initiative = 'Product Repurposing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE game_reviews (review_id INT, game TEXT, review_score INT); INSERT INTO game_reviews (review_id, game, review_score) VALUES (1, 'The Witcher 3: Wild Hunt', 92), (2, 'Red Dead Redemption 2', 89), (3, 'The Legend of Zelda: Breath of the Wild', 97); CREATE TABLE games (game_id INT, game TEXT, genre TEXT, studio TEXT); INSERT INTO games (game_id, game, genre, studio) VALUES (1, 'The Witcher 3: Wild Hunt', 'Adventure', 'CD Projekt'), (2, 'Red Dead Redemption 2', 'Adventure', 'Rockstar Games'), (3, 'The Legend of Zelda: Breath of the Wild', 'Adventure', 'Nintendo'); | What is the average review score for adventure games, and the maximum review score for each studio? | SELECT games.studio, AVG(game_reviews.review_score) FILTER (WHERE games.genre = 'Adventure') AS average_review_score, MAX(game_reviews.review_score) AS max_review_score FROM game_reviews JOIN games ON game_reviews.game = games.game GROUP BY games.studio; | gretelai_synthetic_text_to_sql |
CREATE TABLE subways (id INT, line VARCHAR(20)); INSERT INTO subways (id, line) VALUES (1, 'Ginza'), (2, 'Marunouchi'), (3, 'Hibiya'); CREATE TABLE subway_fares (id INT, subway_id INT, fare DECIMAL(5,2)); INSERT INTO subway_fares (id, subway_id, fare) VALUES (1, 1, 180), (2, 1, 180), (3, 2, 210), (4, 3, 240); | What is the total fare collected for each subway line in Tokyo? | SELECT s.line, SUM(sf.fare) FROM subway_fares sf JOIN subways s ON sf.subway_id = s.id GROUP BY s.line; | gretelai_synthetic_text_to_sql |
CREATE TABLE Agents (AgentID INT, AgentName VARCHAR(255), PolicyID INT); INSERT INTO Agents VALUES (1, 'John Smith', 1), (2, 'Jane Doe', 2), (1, 'John Smith', 3), (2, 'Jane Doe', 4), (3, 'Mike Johnson', 5), (3, 'Mike Johnson', 6); CREATE TABLE Policies (PolicyID INT, ClaimAmount DECIMAL(10, 2)); INSERT INTO Policies VALUES (1, 500), (2, 1000), (3, 750), (4, 1200), (5, 300), (6, 1500); | What is the total claim amount per sales agent? | SELECT a.AgentName, SUM(p.ClaimAmount) AS TotalClaimAmount FROM Agents a JOIN Policies p ON a.PolicyID = p.PolicyID GROUP BY a.AgentName; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities (city VARCHAR(50), technology VARCHAR(50), energy_consumption FLOAT); INSERT INTO smart_cities (city, technology, energy_consumption) VALUES ('CityA', 'SmartLighting', 1000), ('CityB', 'SmartLighting', 1200), ('CityC', 'SmartTransport', 2000), ('CityD', 'SmartTransport', 1800), ('CityE', 'SmartWasteManagement', 3000); | What is the total energy consumption (in kWh) and the number of smart city technologies in use in the smart_cities table, grouped by city and technology type? | SELECT city, technology, SUM(energy_consumption) as total_energy_consumption, COUNT(*) as num_technologies FROM smart_cities GROUP BY city, technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE service_complaints (complaint_id INT, complaint_type VARCHAR(50), complaint_date DATE); INSERT INTO service_complaints (complaint_id, complaint_type, complaint_date) VALUES (1, 'Mobile Data', '2022-03-01'), (2, 'Broadband Internet', '2022-03-15'), (3, 'VoIP', '2022-04-01'); | How many complaints were received for each service type in the last month? | SELECT COUNT(*) as total_complaints, complaint_type FROM service_complaints WHERE complaint_date >= DATE_TRUNC('month', NOW()) - INTERVAL '1 month' GROUP BY complaint_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, country TEXT); INSERT INTO artists (id, name, country) VALUES (1, 'Picasso', 'Spain'), (2, 'El Anatsui', 'Ghana'), (3, 'Monet', 'France'); CREATE TABLE artworks (id INT, artist_id INT, category TEXT, value DECIMAL); INSERT INTO artworks (id, artist_id, category, value) VALUES (1, 2, 'sculpture', 800.00); | What is the average value of all artworks in the 'sculpture' category that were created by artists from Africa? | SELECT AVG(value) FROM artworks a JOIN artists ar ON a.artist_id = ar.id WHERE a.category = 'sculpture' AND ar.country = 'Ghana'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_figures (well_name VARCHAR(255), year INT, monthly_production INT); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well A', 2018, 90000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well A', 2019, 110000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well A', 2020, 130000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well B', 2018, 105000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well B', 2019, 125000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well B', 2020, 145000); | What were the total production figures for each well in 2020? | SELECT well_name, SUM(monthly_production) FROM production_figures WHERE year = 2020 GROUP BY well_name | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, city VARCHAR(255), year INT, attendance INT); INSERT INTO events (id, city, year, attendance) VALUES (1, 'Tokyo', 2019, 5000), (2, 'Tokyo', 2020, 3000), (3, 'Tokyo', 2021, 6000), (4, 'Paris', 2019, 4000), (5, 'Paris', 2020, 2000), (6, 'Paris', 2021, 7000); | What is the average attendance for cultural events in Tokyo over the past 3 years? | SELECT AVG(attendance) FROM events WHERE city = 'Tokyo' AND year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers_2 (id INT, age INT, country TEXT, role TEXT); INSERT INTO volunteers_2 (id, age, country, role) VALUES (1, 35, 'Brazil', 'Community Engagement'), (2, 45, 'Colombia', 'Community Engagement'), (3, 28, 'Argentina', 'Community Engagement'); | What is the average age of community engagement volunteers in South America? | SELECT AVG(age) FROM volunteers_2 WHERE country IN ('Brazil', 'Colombia', 'Argentina') AND role = 'Community Engagement'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RainfallData (region INT, farm VARCHAR(50), rainfall FLOAT); INSERT INTO RainfallData (region, farm, rainfall) VALUES (3, 'Farm A', 50), (3, 'Farm B', 60), (4, 'Farm A', 70), (4, 'Farm C', 80); | Show the total rainfall in regions 3 and 4, excluding data from farm A. | SELECT SUM(rainfall) FROM RainfallData WHERE region IN (3, 4) AND farm != 'Farm A' | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(255), section VARCHAR(64), word_count INT); INSERT INTO articles (id, title, section, word_count) VALUES (1, 'ArticleA', 'science', 1200), (2, 'ArticleB', 'politics', 800), (3, 'ArticleC', 'science', 1500); | What is the minimum word count for articles in the 'science' section? | SELECT MIN(word_count) FROM articles WHERE section = 'science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, quantity FLOAT); INSERT INTO production (element, year, quantity) VALUES ('Dysprosium', 2015, 700), ('Dysprosium', 2016, 800), ('Dysprosium', 2017, 900), ('Dysprosium', 2018, 1000), ('Dysprosium', 2019, 1100); | What is the total production of Dysprosium in 2018 and 2019 combined? | SELECT SUM(quantity) FROM production WHERE element = 'Dysprosium' AND (year = 2018 OR year = 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE housing_schemes (scheme_id INT, property_id INT, co_ownership BOOLEAN); INSERT INTO housing_schemes (scheme_id, property_id, co_ownership) VALUES (1, 101, TRUE), (1, 102, FALSE), (2, 103, TRUE), (3, 104, TRUE), (3, 105, FALSE); CREATE TABLE scheme_types (scheme_id INT, scheme_name VARCHAR(50)); INSERT INTO scheme_types (scheme_id, scheme_name) VALUES (1, 'Apartment'), (2, 'House'), (3, 'Condominium'); | How many properties in each type of inclusive housing scheme are co-owned? | SELECT st.scheme_name, COUNT(*) FROM housing_schemes hs JOIN scheme_types st ON hs.scheme_id = st.scheme_id WHERE co_ownership = TRUE GROUP BY st.scheme_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_id INT, name VARCHAR(255)); INSERT INTO region (region_id, name) VALUES (1, 'Arctic'); CREATE TABLE community_program (program_id INT, name VARCHAR(255), region_id INT, people_served INT); INSERT INTO community_program (program_id, name, region_id, people_served) VALUES (1, 'Program1', 1, 200), (2, 'Program2', 1, 300); | What is the maximum number of people served by a community program in the Arctic region? | SELECT MAX(people_served) FROM community_program WHERE region_id = (SELECT region_id FROM region WHERE name = 'Arctic'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, first_name VARCHAR(50), last_name VARCHAR(50), dob DATE, last_purchase_date DATE); INSERT INTO fans (fan_id, first_name, last_name, dob, last_purchase_date) VALUES (1, 'John', 'Doe', '1990-05-01', '2021-03-20'), (2, 'Jane', 'Smith', '1985-08-12', '2021-01-15'); | Delete records of fans who have not made a purchase in the last 6 months | DELETE FROM fans WHERE last_purchase_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_id INT, debris_name VARCHAR(255), launch_date DATE, location VARCHAR(255), type VARCHAR(255)); | Delete the 'space_debris' table | DROP TABLE space_debris; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Cultivator X', 'Nevada'); INSERT INTO cultivators (id, name, state) VALUES (2, 'Cultivator Y', 'Nevada'); CREATE TABLE strains (cultivator_id INT, name TEXT, year INT, potency INT, sales INT); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain A', 2020, 25, 500); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain B', 2020, 23, 700); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (2, 'Strain C', 2020, 28, 800); | What are the total sales and average potency for each strain produced by cultivators in Nevada in 2020? | SELECT s.name as strain_name, c.state as cultivator_state, SUM(s.sales) as total_sales, AVG(s.potency) as average_potency FROM strains s INNER JOIN cultivators c ON s.cultivator_id = c.id WHERE c.state = 'Nevada' AND s.year = 2020 GROUP BY s.name, c.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_records (id INT PRIMARY KEY, vessel_id INT, inspection_date DATE, status VARCHAR(255)); | Insert records into the safety_records table for the vessel with an id of 3, with the following data: (inspection_date, status) = ('2022-03-01', 'Passed') | INSERT INTO safety_records (vessel_id, inspection_date, status) VALUES (3, '2022-03-01', 'Passed'); | gretelai_synthetic_text_to_sql |
CREATE TABLE regional_weather_data (id INT, region VARCHAR(255), temperature INT, timestamp TIMESTAMP); INSERT INTO regional_weather_data (id, region, temperature, timestamp) VALUES (1, 'Asia', 25, '2022-01-01 10:00:00'), (2, 'Africa', 30, '2022-01-01 10:00:00'); | What is the minimum temperature recorded for each region in the past week? | SELECT region, MIN(temperature) FROM regional_weather_data WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 WEEK) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_data (id INT, crop_type VARCHAR(255), temperature INT, humidity INT, measurement_date DATE); | Insert new records for a new crop type 'Millet' with temperature and humidity readings. | INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (5, 'Millet', 23, 70, '2021-08-01'); INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (6, 'Millet', 25, 72, '2021-08-02'); | gretelai_synthetic_text_to_sql |
CREATE TABLE traffic_courts (court_id INT, court_state VARCHAR(2)); INSERT INTO traffic_courts VALUES (1, 'NY'), (2, 'CA'), (3, 'IL'); | What is the total number of cases heard in traffic courts in each state? | SELECT SUM(1) FROM traffic_courts tc INNER JOIN court_cases tc ON tc.court_id = tc.court_id GROUP BY tc.court_state; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists military_tech AUTHORIZATION defsec;CREATE TABLE if not exists military_tech.bases (id INT, name VARCHAR(100), type VARCHAR(50), region VARCHAR(50));INSERT INTO military_tech.bases (id, name, type, region) VALUES (1, 'Fort Bragg', 'Army Base', 'US - East');INSERT INTO military_tech.bases (id, name, type, region) VALUES (2, 'Camp Pendleton', 'Marine Corps Base', 'US - West');INSERT INTO military_tech.bases (id, name, type, region) VALUES (3, 'Camp Smith', 'Army Base', 'Hawaii'); | What is the total number of military bases in each region? | SELECT region, COUNT(*) as base_count FROM military_tech.bases GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE brand (brand_id INT, name TEXT); CREATE TABLE product (product_id INT, name TEXT, brand_id INT, cruelty_free BOOLEAN); CREATE TABLE safety_record (record_id INT, product_id INT, incident_count INT); | How many safety incidents have been reported for each cosmetics brand? | SELECT brand.name, COUNT(safety_record.product_id) FROM brand INNER JOIN product ON brand.brand_id = product.brand_id INNER JOIN safety_record ON product.product_id = safety_record.product_id GROUP BY brand.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name VARCHAR(50), position VARCHAR(50), age INT); | What is the average age of employees in the "mining_operations" table? | SELECT AVG(age) FROM mining_operations; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT, name VARCHAR(255)); INSERT INTO drugs (id, name) VALUES (1, 'DrugA'), (2, 'DrugB'); CREATE TABLE sales (id INT, drug_id INT, year INT, revenue INT); | What was the total revenue for a specific drug in a given year? | SELECT SUM(sales.revenue) FROM sales JOIN drugs ON sales.drug_id = drugs.id WHERE drugs.name = 'DrugA' AND sales.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE PoliceStations (station_id INT, district_id INT, num_officers INT); CREATE TABLE District (district_id INT, district_name VARCHAR(20)); INSERT INTO District (district_id, district_name) VALUES (1, 'Urban'), (2, 'Rural'); INSERT INTO PoliceStations (station_id, district_id, num_officers) VALUES (1, 1, 50), (2, 1, 75), (3, 2, 30), (4, 2, 40); | What is the total number of police officers in each district? | SELECT District.district_name, SUM(PoliceStations.num_officers) FROM District INNER JOIN PoliceStations ON District.district_id = PoliceStations.district_id GROUP BY District.district_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_outlets (id INT, name TEXT, language TEXT); INSERT INTO media_outlets VALUES (1, 'Outlet A', 'English'), (2, 'Outlet B', 'Spanish'), (3, 'Outlet C', 'French'), (4, 'Outlet D', 'Portuguese'), (5, 'Outlet E', 'Chinese'), (6, 'Outlet F', 'Japanese'), (7, 'Outlet G', 'Hindi'), (8, 'Outlet H', 'German'), (9, 'Outlet I', 'Arabic'), (10, 'Outlet J', 'Russian'), (11, 'Outlet K', 'Bengali'), (12, 'Outlet L', 'French'), (13, 'Outlet M', 'Italian'), (14, 'Outlet N', 'Turkish'), (15, 'Outlet O', 'Korean'), (16, 'Outlet P', 'Persian'), (17, 'Outlet Q', 'Punjabi'), (18, 'Outlet R', 'Polish'), (19, 'Outlet S', 'Urdu'), (20, 'Outlet T', 'Telugu'); | What is the distribution of media outlets by language? | SELECT language, COUNT(*) as outlet_count FROM media_outlets GROUP BY language; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), LaunchDate DATE, Manufacturer VARCHAR(50), Country VARCHAR(50), Weight DECIMAL(10,2)); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, Manufacturer, Country, Weight) VALUES (1, 'Kompsat-5', '2013-08-10', 'KARI', 'South Korea', 1250.00), (2, 'GSAT-7', '2013-09-30', 'ISRO', 'India', 2650.00); | List the top 3 heaviest satellites launched by each country | SELECT SatelliteID, Name, LaunchDate, Manufacturer, Country, Weight, ROW_NUMBER() OVER(PARTITION BY Country ORDER BY Weight DESC) as Rank FROM Satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (id INT, name VARCHAR(100), manufacturer VARCHAR(100), country VARCHAR(50)); INSERT INTO Spacecraft (id, name, manufacturer, country) VALUES (3, 'Shenzhou', 'CASIC', 'China'); | What is the name of spacecraft manufactured by China? | SELECT name FROM Spacecraft WHERE country = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_details(id INT, country VARCHAR(50), last_workout_date DATE); INSERT INTO member_details(id, country, last_workout_date) VALUES (1,'USA','2022-01-14'),(2,'Canada','2022-02-15'),(3,'Mexico','2022-02-16'),(4,'Brazil','2022-02-17'),(5,'Argentina','2022-02-18'),(6,'Colombia','2022-02-19'),(7,'Peru','2022-02-20'),(8,'Venezuela','2022-02-21'),(9,'Chile','2022-02-22'),(10,'Ecuador','2022-02-23'),(11,'Guatemala','2022-02-24'),(12,'Cuba','2022-02-25'); CREATE TABLE workout_summary(member_id INT, workout_date DATE); INSERT INTO workout_summary(member_id, workout_date) VALUES (1,'2022-01-14'),(2,'2022-02-15'),(3,'2022-02-16'),(4,'2022-02-17'),(5,'2022-02-18'),(6,'2022-02-19'),(7,'2022-02-20'),(8,'2022-02-21'),(9,'2022-02-22'),(10,'2022-02-23'),(11,'2022-02-24'),(12,'2022-02-25'); | What is the total number of workouts completed by members in each country in the last month? | SELECT country, COUNT(*) FROM (SELECT member_id, country FROM member_details JOIN workout_summary ON member_details.id = workout_summary.member_id WHERE workout_summary.workout_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY member_id, country) subquery GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_id INT, item_id INT, name VARCHAR(50), category VARCHAR(50), description TEXT, price DECIMAL(5,2)); | Update the menu_items table to set the price of the item with item_id 789 to $8.99 | UPDATE menu_items SET price = 8.99 WHERE item_id = 789; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (user_id INT, username VARCHAR(50), registration_date DATE, unsubscription_date DATE, country VARCHAR(50)); INSERT INTO Users (user_id, username, registration_date, unsubscription_date, country) VALUES (8, 'UserH', '2022-01-01', '2022-02-01', 'Japan'); INSERT INTO Users (user_id, username, registration_date, unsubscription_date, country) VALUES (9, 'UserI', '2022-01-02', NULL, 'USA'); INSERT INTO Users (user_id, username, registration_date, unsubscription_date, country) VALUES (10, 'UserJ', '2022-01-03', '2022-03-01', 'Japan'); | How many users unsubscribed from the music streaming service in Japan? | SELECT COUNT(*) FROM Users WHERE unsubscription_date IS NOT NULL AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_workers (worker_id INT, worker_name VARCHAR(50), community_type VARCHAR(50), patients_served INT); INSERT INTO community_workers (worker_id, worker_name, community_type, patients_served) VALUES (1, 'John Doe', 'African American', 50), (2, 'Jane Smith', 'Hispanic', 75), (3, 'Alice Johnson', 'LGBTQ+', 60), (4, 'Bob Brown', 'Rural', 40), (5, 'Maria Garcia', 'Asian', 45), (6, 'David Kim', 'Native American', 35); | Who are the community health workers with the most diverse patient populations? | SELECT worker_name, COUNT(DISTINCT community_type) as diverse_population FROM community_workers GROUP BY worker_name ORDER BY diverse_population DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (Year INT, Operation VARCHAR(50), Country VARCHAR(50)); INSERT INTO PeacekeepingOperations (Year, Operation, Country) VALUES (2017, 'Operation 1', 'Country 1'), (2017, 'Operation 2', 'Country 2'); | How many peacekeeping operations were conducted by the UN in 2017? | SELECT COUNT(*) FROM PeacekeepingOperations WHERE Year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, country VARCHAR(20), initiative_name VARCHAR(50), completion_date DATE); INSERT INTO community_development (id, country, initiative_name, completion_date) VALUES (1, 'Cambodia', 'Health Center', '2021-01-05'), (2, 'Cambodia', 'Waste Management', '2022-03-01'); | Update the completion date of the community development initiative with ID 4 to '2022-04-15' in the Cambodia table. | UPDATE community_development SET completion_date = '2022-04-15' WHERE id = 4 AND country = 'Cambodia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE global_giving (donor_type VARCHAR(20), avg_donation DECIMAL(10,2)); INSERT INTO global_giving (donor_type, avg_donation) VALUES ('international_donors', 250.00), ('local_donors', 100.00); | What is the average donation amount for 'international_donors' in the 'global_giving' table? | SELECT AVG(avg_donation) FROM global_giving WHERE donor_type = 'international_donors'; | gretelai_synthetic_text_to_sql |
CREATE TABLE program (id INT, name VARCHAR(255)); CREATE TABLE publication (id INT, program_id INT, title VARCHAR(255)); | What is the number of publications per program? | SELECT program.name, COUNT(publication.id) FROM program LEFT JOIN publication ON program.id = publication.program_id GROUP BY program.name; | 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.