context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE events(id INT, city VARCHAR(255), year INT, num_events INT); INSERT INTO events (id, city, year, num_events) VALUES (1, 'Tokyo', 2021, 15), (2, 'Tokyo', 2022, 20), (3, 'Paris', 2021, 25); | How many cultural events were held in 'Tokyo' in 2021? | SELECT SUM(num_events) FROM events WHERE city = 'Tokyo' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Audience (audience_id INT, event_city VARCHAR(50), audience_age INT); INSERT INTO Audience (audience_id, event_city, audience_age) VALUES (1, 'New York', 35), (2, 'Chicago', 40), (3, 'New York', 32), (4, 'Chicago', 45), (5, 'New York', 38), (6, 'Chicago', 35); | What is the average age of audience members who attended events in New York or Chicago in 2021, and update their records with the calculated average age? | SELECT AVG(audience_age) FROM Audience WHERE event_city IN ('New York', 'Chicago') AND event_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT); INSERT INTO teachers (teacher_id, teacher_name) VALUES (1, 'Mrs. Doe'), (2, 'Mr. Smith'), (3, 'Ms. Johnson'); CREATE TABLE professional_development (program_id INT, program_name TEXT, teacher_id INT); INSERT INTO professional_development (program_id, program_name, teacher_id) VALUES (1, 'Python for Educators', 1), (2, 'Data Science for Teachers', 2), (3, 'Inclusive Teaching', 4), (4, 'Open Pedagogy', 5); | Who are the teachers that have not attended any professional development programs? | SELECT t.teacher_name FROM teachers t LEFT JOIN professional_development pd ON t.teacher_id = pd.teacher_id WHERE pd.teacher_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (state VARCHAR(255), year INT, school_count INT); INSERT INTO schools (state, year, school_count) VALUES ('California', 2015, 150), ('California', 2016, 200), ('California', 2017, 250), ('California', 2018, 300), ('California', 2019, 350), ('California', 2020, 400); | How many public schools were built in the state of California between 2015 and 2020? | SELECT SUM(school_count) AS total_schools_built FROM schools WHERE state = 'California' AND year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodInspections (restaurant_id INT, region VARCHAR(50), passed BOOLEAN); INSERT INTO FoodInspections (restaurant_id, region, passed) VALUES (1, 'North', TRUE), (1, 'North', FALSE), (2, 'North', TRUE), (2, 'South', TRUE), (2, 'South', FALSE); | What is the percentage of restaurants that passed their food safety inspections in each region? | SELECT region, AVG(IF(passed, 1, 0)) as pass_percentage FROM foodinspections GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'), (1004, 'Hawksbill Sea Turtle', 'Endangered'); | List all marine species in the 'marine_species' table, ordered by conservation status | SELECT species_name FROM marine_species ORDER BY conservation_status ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE affordable_housing (id INT, property_tax FLOAT, state VARCHAR(20)); INSERT INTO affordable_housing (id, property_tax, state) VALUES (1, 5000, 'California'), (2, 7000, 'New York'), (3, 3000, 'Texas'); | What is the maximum property tax for affordable housing units in the state of California? | SELECT MAX(property_tax) FROM affordable_housing WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (genre VARCHAR(255), country VARCHAR(255), sales FLOAT); CREATE TABLE genres (genre VARCHAR(255)); INSERT INTO genres (genre) VALUES ('Pop'), ('Rock'), ('Jazz'), ('Classical'); | What are the total sales for each genre in the United States? | SELECT s.genre, SUM(s.sales) as total_sales FROM sales s JOIN genres g ON s.genre = g.genre WHERE s.country = 'United States' GROUP BY s.genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE OilFields (FieldID INT, FieldName VARCHAR(50), Country VARCHAR(50), Production INT, Reserves INT); INSERT INTO OilFields (FieldID, FieldName, Country, Production, Reserves) VALUES (1, 'Galaxy', 'USA', 20000, 500000); INSERT INTO OilFields (FieldID, FieldName, Country, Production, Reserves) VALUES (2, 'Apollo', 'Canada', 15000, 400000); | List all oil fields in Canada and their production figures. | SELECT FieldName, Production FROM OilFields WHERE Country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20), country VARCHAR(20)); INSERT INTO Warehouse (id, name, city, country) VALUES (1, 'Seoul Warehouse', 'Seoul', 'South Korea'), (2, 'Mumbai Warehouse', 'Mumbai', 'India'), (3, 'Tokyo Warehouse', 'Tokyo', 'Japan'); CREATE TABLE Packages (id INT, warehouse_id INT, status VARCHAR(20)); INSERT INTO Packages (id, warehouse_id, status) VALUES (1, 1, 'received'), (2, 1, 'processing'), (3, 2, 'received'), (4, 2, 'received'), (5, 3, 'processing'); | What is the count of packages in 'received' status at each warehouse in 'Asia'? | SELECT warehouse_id, COUNT(*) FROM Packages WHERE status = 'received' GROUP BY warehouse_id HAVING country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Meetings (meeting_id INT, meeting_date DATE); | How many public meetings were held in 'Meetings' table by month? | SELECT MONTH(meeting_date), COUNT(meeting_id) FROM Meetings GROUP BY MONTH(meeting_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtistSales2 (GalleryName TEXT, ArtistName TEXT, NumPieces INTEGER, PricePerPiece FLOAT); INSERT INTO ArtistSales2 (GalleryName, ArtistName, NumPieces, PricePerPiece) VALUES ('Contemporary Art Gallery', 'Warhol', 12, 75.5), ('Contemporary Art Gallery', 'Matisse', 15, 60.0), ('Contemporary Art Gallery', 'Kahlo', 18, 80.0); | Which artist had the highest revenue generated from sales at the "Contemporary Art Gallery" in 2021? | SELECT ArtistName, SUM(NumPieces * PricePerPiece) AS Revenue FROM ArtistSales2 WHERE GalleryName = 'Contemporary Art Gallery' AND YEAR(SaleDate) = 2021 GROUP BY ArtistName ORDER BY Revenue DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, avg_depth FLOAT); INSERT INTO marine_protected_areas (name, location, avg_depth) VALUES ('Bermuda Park', 'Atlantic', 50.0), ('Azores', 'Atlantic', 20.0); | What is the average depth of marine protected areas in the Atlantic? | SELECT AVG(avg_depth) FROM marine_protected_areas WHERE location = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventID INT, Players INT, UsesVR BOOLEAN); INSERT INTO EsportsEvents (EventID, Players, UsesVR) VALUES (1, 10, TRUE); | How many players use VR technology in esports events? | SELECT SUM(Players) FROM EsportsEvents WHERE UsesVR = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sustainable_Practices ( id INT PRIMARY KEY, country_id INT, certification_date DATE, FOREIGN KEY (country_id) REFERENCES Countries(id) ); INSERT INTO Sustainable_Practices (id, country_id, certification_date) VALUES (1, 1, '2018-07-01'); INSERT INTO Sustainable_Practices (id, country_id, certification_date) VALUES (2, 12, '2019-03-01'); | How many countries in Oceania have been promoting sustainable tourism since 2018? | SELECT COUNT(DISTINCT c.id) as country_count FROM Countries c INNER JOIN Sustainable_Practices sp ON c.id = sp.country_id WHERE c.continent = 'Oceania' AND sp.certification_date >= '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE test_drives (drive_id INT, vehicle_make VARCHAR(20), avg_speed FLOAT); INSERT INTO test_drives (drive_id, vehicle_make, avg_speed) VALUES (1, 'Tesla', 65.3), (2, 'Tesla', 68.1), (3, 'Rivian', 62.9), (4, 'Rivian', 64.5); | What is the average speed of electric vehicles in the 'test_drives' table, grouped by 'vehicle_make'? | SELECT vehicle_make, AVG(avg_speed) avg_speed FROM test_drives GROUP BY vehicle_make; | gretelai_synthetic_text_to_sql |
CREATE TABLE r_d_expenditure (drug_name TEXT, expenditure INTEGER, approval_year TEXT); INSERT INTO r_d_expenditure (drug_name, expenditure, approval_year) VALUES ('Drug1', 2500, 'Year1'), ('Drug2', 3000, 'Year2'), ('Drug3', 3500, 'Year1'), ('Drug4', 4000, 'Year3'); | What is the maximum R&D expenditure for drugs approved in 'Year1'? | SELECT MAX(expenditure) FROM r_d_expenditure WHERE approval_year = 'Year1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (country VARCHAR(20), year INT, advisory VARCHAR(50)); INSERT INTO travel_advisories (country, year, advisory) VALUES ('Japan', 2022, 'avoid non-essential travel'), ('Brazil', 2022, 'avoid all travel'); | Update the travel advisory for Brazil in 2022 to 'exercise caution'. | UPDATE travel_advisories SET advisory = 'exercise caution' WHERE country = 'Brazil' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameB_Participants (player_id INT, game_id INT); CREATE TABLE GameB_eSportsEvents (event_id INT, game_id INT); INSERT INTO GameB_Participants (player_id, game_id) VALUES (1, 1), (2, 1), (3, 2), (4, 1), (5, 2); INSERT INTO GameB_eSportsEvents (event_id, game_id) VALUES (101, 1), (102, 2), (103, 1); | How many players have participated in eSports events for game 'B'? | SELECT COUNT(DISTINCT GameB_Participants.player_id) as num_players FROM GameB_Participants JOIN GameB_eSportsEvents ON GameB_Participants.game_id = GameB_eSportsEvents.game_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_equity_metrics (id INT PRIMARY KEY, metric VARCHAR(255), value FLOAT); | Create a table named 'health_equity_metrics' | CREATE TABLE health_equity_metrics (id INT PRIMARY KEY, metric VARCHAR(255), value FLOAT); | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name VARCHAR(255), industry VARCHAR(255), member_age INT); INSERT INTO unions (id, name, industry, member_age) VALUES (1, 'Union D', 'hospitality', 30), (2, 'Union E', 'hospitality', 35), (3, 'Union F', 'hospitality', 40); | What is the maximum age of members in unions with a 'hospitality' industry classification? | SELECT MAX(member_age) FROM unions WHERE industry = 'hospitality'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (id INT, district VARCHAR(20), capacity INT, region VARCHAR(10)); INSERT INTO LandfillCapacity (id, district, capacity, region) VALUES (1, 'DistrictA', 250000, 'RegionA'), (2, 'DistrictB', 500000, 'RegionB'), (3, 'DistrictC', 300000, 'RegionA'); | Calculate the average landfill capacity for districts in each region. | SELECT region, AVG(capacity) FROM LandfillCapacity GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE haircare (product_id INT, product_name VARCHAR(50), price DECIMAL(5,2)); | What is the difference in price between the most and least expensive products in the 'haircare' table? | SELECT product_name, price, MAX(price) OVER() - MIN(price) OVER() as price_difference FROM haircare; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitats (habitat_id INT, habitat_name VARCHAR(50), year INT, area INT); INSERT INTO wildlife_habitats (habitat_id, habitat_name, year, area) VALUES (1, 'Forest', 2018, 1000), (2, 'Wetland', 2018, 2000), (3, 'Grassland', 2018, 3000), (4, 'Forest', 2019, 900), (5, 'Wetland', 2019, 1800), (6, 'Grassland', 2019, 2800); | Identify the wildlife habitats that have a decrease in area between 2018 and 2019, and order them by the largest decrease first. | SELECT habitat_name, (LAG(area, 1) OVER (PARTITION BY habitat_name ORDER BY year)) - area AS area_decrease FROM wildlife_habitats WHERE year = 2019 GROUP BY habitat_name, area ORDER BY area_decrease DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, AttorneyID INT, Outcome VARCHAR(10)); INSERT INTO Cases (CaseID, AttorneyID, Outcome) VALUES (1, 1, 'Won'), (2, 1, 'Lost'), (3, 2, 'Settled'); | Show the number of cases won, lost, and settled by attorneys in the corporate law department. | SELECT c.AttorneyID, SUM(CASE WHEN c.Outcome = 'Won' THEN 1 ELSE 0 END) AS Wins, SUM(CASE WHEN c.Outcome = 'Lost' THEN 1 ELSE 0 END) AS Losses, SUM(CASE WHEN c.Outcome = 'Settled' THEN 1 ELSE 0 END) AS Settled FROM Cases c WHERE c.AttorneyID IN (SELECT a.AttorneyID FROM Attorneys a WHERE a.PracticeArea = 'Corporate Law') GROUP BY c.AttorneyID; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (id INT, mine_id INT, pollution_index FLOAT, impact_date DATE); INSERT INTO environmental_impact (id, mine_id, pollution_index, impact_date) VALUES (3, 3, 28.1, '2020-01-01'); INSERT INTO environmental_impact (id, mine_id, pollution_index, impact_date) VALUES (4, 4, 32.5, '2020-02-01'); | What is the average pollution index for each mine in Country A? | SELECT e.mine_id, AVG(e.pollution_index) as avg_pollution FROM environmental_impact e WHERE e.location = 'Country A' GROUP BY e.mine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (id INT, name VARCHAR(50), outage BOOLEAN, state VARCHAR(50)); INSERT INTO broadband_subscribers (id, name, outage, state) VALUES (7, 'Charlie White', true, 'OH'); INSERT INTO broadband_subscribers (id, name, outage, state) VALUES (8, 'David Black', false, 'OH'); | How many broadband subscribers are there in Ohio who have had a service outage in the last year? | SELECT COUNT(*) FROM broadband_subscribers WHERE outage = true AND state = 'OH' AND YEAR(registration_date) = YEAR(CURRENT_DATE) - 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, factory VARCHAR(255), country VARCHAR(255), quantity INT, production_date DATE); INSERT INTO production (id, factory, country, quantity, production_date) VALUES (1, 'Fabric Inc', 'India', 700, '2021-05-01'), (2, 'Stitch Time', 'India', 800, '2021-06-15'), (3, 'Sew Good', 'India', 600, '2021-04-01'), (4, 'Fabric Inc', 'USA', 900, '2021-05-01'); | How many garments were produced in each country in the last month? | SELECT country, COUNT(quantity) FROM production WHERE production_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_moisture (id INT, field_id INT, value INT, timestamp TIMESTAMP); | Delete all records from the soil moisture table for the past week. | DELETE FROM soil_moisture WHERE timestamp >= NOW() - INTERVAL '1 week'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tickets (id INT, game_id INT, team VARCHAR(255), price DECIMAL(10,2)); | Which team has the highest average ticket price? | SELECT team, AVG(price) AS avg_price FROM tickets GROUP BY team ORDER BY avg_price DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_waste (id INT, waste_date DATE, ingredient_name TEXT, quantity INT); | What is the total amount of food waste generated in the last month, categorized by ingredient type? | SELECT ingredient_name, SUM(quantity) FROM food_waste WHERE waste_date >= DATE(NOW()) - INTERVAL 1 MONTH GROUP BY ingredient_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name VARCHAR(255), category VARCHAR(255), organic_sourced BOOLEAN, fair_trade_sourced BOOLEAN, revenue INT); INSERT INTO menu_items (id, name, category, organic_sourced, fair_trade_sourced, revenue) VALUES (1, 'Quinoa Salad', 'Salads', TRUE, TRUE, 500), (2, 'Grilled Chicken Sandwich', 'Sandwiches', FALSE, FALSE, 700), (3, 'Black Bean Burger', 'Burgers', TRUE, FALSE, 600); | What is the total revenue generated from 'Organic' and 'Fair Trade' sourced menu items? | SELECT SUM(revenue) as total_revenue FROM menu_items WHERE organic_sourced = TRUE AND fair_trade_sourced = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (site_id INT, state VARCHAR(2), num_workers INT, acres FLOAT); | Calculate the total number of workers at mining sites located in 'CO' or 'WY'. | SELECT state, SUM(num_workers) as total_workers FROM sites WHERE state IN ('CO', 'WY') GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_plans (id INT, plan_type VARCHAR(20), quarter DATE, revenue DECIMAL(10,2)); CREATE TABLE customers (id INT, plan_id INT); INSERT INTO mobile_plans (id, plan_type, quarter, revenue) VALUES (1, 'postpaid', '2022-01-01', 50.00), (2, 'postpaid', '2022-01-01', 60.00), (3, 'prepaid', '2022-01-01', 40.00); INSERT INTO customers (id, plan_id) VALUES (1, 1), (2, 2), (3, 3); | What is the total revenue generated from postpaid mobile plans in the last quarter? | SELECT SUM(revenue) FROM mobile_plans INNER JOIN customers ON mobile_plans.id = customers.plan_id WHERE plan_type = 'postpaid' AND quarter BETWEEN DATE_SUB('2022-04-01', INTERVAL 3 MONTH) AND '2022-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer (customer_id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE debit_card (transaction_id INT, customer_id INT, value DECIMAL(10,2), timestamp TIMESTAMP); | Identify the top 5 customers with the highest transaction values in the "debit_card" table for the month of January 2022. | SELECT c.name, SUM(dc.value) as total_value FROM customer c JOIN debit_card dc ON c.customer_id = dc.customer_id WHERE MONTH(dc.timestamp) = 1 AND YEAR(dc.timestamp) = 2022 GROUP BY c.customer_id ORDER BY total_value DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_activity (player_id INT, activity_date DATE, region VARCHAR(255)); INSERT INTO daily_activity (player_id, activity_date, region) VALUES (1, '2022-05-01', 'North America'), (2, '2022-05-02', 'Europe'), (3, '2022-05-03', 'Asia'); | How many players are active in each region per day? | SELECT activity_date, region, COUNT(player_id) as num_players FROM daily_activity GROUP BY activity_date, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_concerts (concert_id INT, participant_name VARCHAR(50), instrument VARCHAR(50)); INSERT INTO music_concerts (concert_id, participant_name, instrument) VALUES (1, 'Mia', 'Violin'), (2, 'Nora', 'Piano'), (3, 'Olivia', 'Flute'); | Update the instrument of the participant 'Mia' in the 'Music Concerts' table to 'Cello'. | UPDATE music_concerts SET instrument = 'Cello' WHERE participant_name = 'Mia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_data (user_id INT, username VARCHAR(50), country VARCHAR(50), followers INT, posts INT); INSERT INTO user_data (user_id, username, country, followers, posts) VALUES (1, 'user1', 'USA', 100000, 50), (2, 'user2', 'Canada', 120000, 75), (3, 'user3', 'Mexico', 150000, 100), (4, 'user4', 'Brazil', 200000, 125), (5, 'user5', 'Australia', 80000, 80), (6, 'user6', 'India', 250000, 150), (7, 'user7', 'China', 300000, 175), (8, 'user8', 'Germany', 180000, 110); | What is the total number of posts for users from the "social_media" platform who have more than 100000 followers? | SELECT SUM(posts) as total_posts FROM user_data WHERE followers > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_contents (content_id INTEGER, title VARCHAR(255), duration INTEGER, production_country VARCHAR(100)); INSERT INTO media_contents (content_id, title, duration, production_country) VALUES (1, 'Content1', 120, 'USA'), (2, 'Content2', 90, 'Canada'), (3, 'BollywoodRocks', 180, 'India'), (4, 'Content4', 100, 'France'); | What is the average duration of Indian movies? | SELECT AVG(duration) FROM media_contents WHERE production_country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name TEXT, age INT, state TEXT, transaction_amount DECIMAL(10,2)); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (1, 'John Doe', 35, 'Florida', 700.00); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (2, 'Jane Smith', 40, 'Florida', 650.50); | What is the maximum transaction amount in Florida? | SELECT MAX(transaction_amount) FROM clients WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE advocacy (id INT, campaign VARCHAR(50), launch_date DATE, end_date DATE); INSERT INTO advocacy (id, campaign, launch_date, end_date) VALUES (1, 'Child Rights', '2021-01-01', '2021-12-31'), (2, 'Gender Equality', '2021-02-01', '2021-12-31'), (3, 'Human Rights', '2020-01-01', '2020-12-31'); | Which advocacy campaigns were launched in 'advocacy' table, and when, excluding campaigns launched in 2021? | SELECT campaign, launch_date FROM advocacy WHERE launch_date < '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (inventory_id INT, item_name VARCHAR(50), inventory_category VARCHAR(50), quantity INT, revenue DECIMAL(10,2)); INSERT INTO inventory (inventory_id, item_name, inventory_category, quantity, revenue) VALUES (1, 'Tomato', 'Produce', 50, 500.00), (2, 'Chicken Breast', 'Meat', 100, 1200.00), (3, 'Vanilla Ice Cream', 'Dairy', 75, 750.00); | What is the total revenue for each inventory category? | SELECT inventory_category, SUM(revenue) FROM inventory GROUP BY inventory_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees(id INT, name VARCHAR(255), title VARCHAR(255), age INT); INSERT INTO employees(id, name, title, age) VALUES ('1', 'Jane Smith', 'Mining Engineer', '50'); | Who is the oldest employee with the title 'Mining Engineer' in the 'mining_company' database? | SELECT name, age FROM employees WHERE title = 'Mining Engineer' ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (material_name TEXT, recycled_content_percentage FLOAT, embodied_carbon_kg_co2 FLOAT); INSERT INTO sustainable_materials (material_name, recycled_content_percentage, embodied_carbon_kg_co2) VALUES ('Recycled Steel', 95, 0.65), ('Reclaimed Concrete', 85, 0.95), ('New Timber', 10, 1.5); | List all materials with their embodied carbon and recycled content percentage, ordered by recycled content percentage in descending order | SELECT * FROM sustainable_materials ORDER BY recycled_content_percentage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE TVShows (tv_show_id INT, title VARCHAR(255), rating FLOAT, production_country VARCHAR(50)); INSERT INTO TVShows (tv_show_id, title, rating, production_country) VALUES (1, 'TVShow1', 7.5, 'USA'), (2, 'TVShow2', 8.2, 'Canada'), (3, 'TVShow3', 6.9, 'Mexico'); | What is the minimum rating of TV shows produced in the USA and Canada? | SELECT MIN(rating) FROM TVShows WHERE production_country IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE battery_storage (id INT PRIMARY KEY, manufacturer VARCHAR(50), installed_year INT, capacity FLOAT); | Update the capacity of the record with id 2001 in the 'battery_storage' table to 1500 | UPDATE battery_storage SET capacity = 1500 WHERE id = 2001; | gretelai_synthetic_text_to_sql |
CREATE TABLE bankruptcy_cases (case_id INT, attorney_id INT, attorney_last_name VARCHAR(50)); | List unique last names of attorneys who handled more than 30 bankruptcy cases and their respective counts. | SELECT attorney_last_name, COUNT(*) as case_count FROM bankruptcy_cases GROUP BY attorney_last_name HAVING COUNT(*) > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sharks (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), location VARCHAR(50), population INT); INSERT INTO Sharks (id, name, species, location, population) VALUES (1, 'James', 'Great White', 'Pacific Ocean', 3000), (2, 'Sam', 'Hammerhead', 'Atlantic Ocean', 2000); | What is the total population of each shark species, excluding the Great White? | SELECT species, SUM(population) FROM Sharks WHERE species != 'Great White' GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE Construction_Workers (Worker_ID INT, Name TEXT, Salary FLOAT, State TEXT); INSERT INTO Construction_Workers (Worker_ID, Name, Salary, State) VALUES (1, 'John Doe', 60000, 'California'), (2, 'Jane Smith', 65000, 'California'), (3, 'Mike Johnson', 70000, 'Texas'), (4, 'Sara Williams', 75000, 'Texas'); | What are the names and average salaries of construction workers in California and Texas? | SELECT cw.Name, AVG(cw.Salary) FROM Construction_Workers cw WHERE cw.State IN ('California', 'Texas') GROUP BY cw.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_info (restaurant_id INT, name VARCHAR(50), address VARCHAR(100), city VARCHAR(50), state VARCHAR(2), has_vegan_options BOOLEAN); | Insert a new record into the restaurant_info table for a new restaurant with an ID of 78, a name of "Tasty Bites", an address of "123 Main St", a city of "Anytown", a state of "CA", and a has_vegan_options field of false | INSERT INTO restaurant_info (restaurant_id, name, address, city, state, has_vegan_options) VALUES (78, 'Tasty Bites', '123 Main St', 'Anytown', 'CA', false); | gretelai_synthetic_text_to_sql |
CREATE TABLE Weather (field VARCHAR(50), date DATE, temperature FLOAT); INSERT INTO Weather (field, date, temperature) VALUES ('Field B', '2022-06-01', 25.1), ('Field B', '2022-06-02', 28.6), ('Field B', '2022-06-03', 22.3); | What is the maximum temperature in field B in the past week? | SELECT MAX(temperature) FROM Weather WHERE field = 'Field B' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_energy (country VARCHAR(20), installed_capacity INT); INSERT INTO wind_energy (country, installed_capacity) VALUES ('Germany', 62000), ('France', 16000); | What is the total installed capacity of wind energy in Germany and France? | SELECT SUM(installed_capacity) FROM wind_energy WHERE country IN ('Germany', 'France'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Inspectors (InspectorID INT, InspectorName TEXT); CREATE TABLE Inspections (InspectionID INT, InspectorID INT, ChemicalID INT); INSERT INTO Inspectors (InspectorID, InspectorName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Bob Johnson'); INSERT INTO Inspections (InspectionID, InspectorID, ChemicalID) VALUES (1001, 1, 1), (1002, 2, 2), (1003, 3, 3); | Which chemical safety inspectors have inspected chemicals with a safety stock level above 1000? | SELECT InspectorName FROM Inspectors INNER JOIN Inspections ON Inspectors.InspectorID = Inspections.InspectorID INNER JOIN Chemicals ON Inspections.ChemicalID = Chemicals.ChemicalID WHERE Chemicals.SafetyStockLevel > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (employee_id INT, name TEXT, role TEXT, department TEXT); INSERT INTO Employees (employee_id, name, role, department) VALUES (1, 'John', 'Genetic Researcher', 'Lab1'), (2, 'Jane', 'Bioprocess Engineer', 'Lab1'), (3, 'Mike', 'Data Scientist', 'Lab2'); | How many genetic researchers work in 'Lab1'? | SELECT COUNT(*) FROM Employees WHERE role = 'Genetic Researcher' AND department = 'Lab1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Foundations (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2), spf DECIMAL(3,1)); INSERT INTO Foundations (product_id, product_name, category, price, spf) VALUES (1, 'Foundation 1', 'Foundations', 24.99, 15), (2, 'Foundation 2', 'Foundations', 29.99, 20), (3, 'Foundation 3', 'Foundations', 34.99, 30), (4, 'Foundation 4', 'Foundations', 39.99, 35); | What is the average SPF value of foundations? | SELECT AVG(spf) FROM Foundations; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity_trend (state VARCHAR(2), year INT, violations INT); INSERT INTO mental_health_parity_trend (state, year, violations) VALUES ('CA', 2020, 15), ('CA', 2021, 25), ('NY', 2020, 20), ('NY', 2021, 30), ('TX', 2020, 10), ('TX', 2021, 20); | How many mental health parity violations have occurred in each state, and what is the trend over the past three years? | SELECT m.state, m.year, m.violations, LAG(m.violations) OVER (PARTITION BY m.state ORDER BY m.year) as prev_year_violations FROM mental_health_parity_trend m; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health.patients (patient_id INT, age INT, country VARCHAR(255)); INSERT INTO mental_health.patients (patient_id, age, country) VALUES (1, 35, 'USA'), (2, 40, 'Canada'), (3, 30, 'USA'); CREATE TABLE mental_health.treatments (treatment_id INT, patient_id INT, treatment_name VARCHAR(255)); INSERT INTO mental_health.treatments (treatment_id, patient_id, treatment_name) VALUES (1, 1, 'CBT'), (2, 2, 'Medication'), (3, 3, 'CBT'); | What is the average age of patients who received cognitive behavioral therapy (CBT) in the US? | SELECT AVG(p.age) FROM mental_health.patients p INNER JOIN mental_health.treatments t ON p.patient_id = t.patient_id WHERE t.treatment_name = 'CBT' AND p.country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infra (id INT, name VARCHAR(255), region VARCHAR(255), budget FLOAT, status VARCHAR(255)); INSERT INTO rural_infra (id, name, region, budget, status) VALUES (1, 'Road Construction', 'Oceania', 250000.00, 'completed'); | Calculate the total budget for completed rural infrastructure projects in Oceania. | SELECT SUM(budget) FROM rural_infra WHERE region = 'Oceania' AND status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); CREATE TABLE players (player_id INT, player_name VARCHAR(255), team_id INT); CREATE TABLE players_stats (player_id INT, game_id INT, points INT); | What is the average points per game scored by players from the players_stats table, grouped by their team? | SELECT t.team_name, AVG(ps.points) AS avg_points FROM players_stats ps JOIN players p ON ps.player_id = p.player_id JOIN teams t ON p.team_id = t.team_id GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), EmployeeCount INT); INSERT INTO Brands (BrandID, BrandName, EmployeeCount) VALUES (1, 'Brand1', 500), (2, 'Brand2', 300), (3, 'Brand3', 700); | Display the number of employees working for each brand. | SELECT BrandName, EmployeeCount FROM Brands; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (offset_id INT, project_id INT, emission_date DATE, status VARCHAR(255)); INSERT INTO carbon_offsets (offset_id, project_id, emission_date, status) VALUES (1, 1, '2019-01-01', 'active'), (2, 2, '2020-01-01', 'active'), (3, 3, '2018-01-01', 'active'); | Update the carbon_offsets table to set the 'status' column to 'inactive' for all records with an 'emission_date' older than 2020-01-01. | UPDATE carbon_offsets SET status = 'inactive' WHERE emission_date < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE astro_research (id INT, name VARCHAR(50), location VARCHAR(50), discovery_date DATE, research_type VARCHAR(50)); INSERT INTO astro_research (id, name, location, discovery_date, research_type) VALUES (1, 'Black Hole', 'M87', '2019-04-10', 'Imaging'); INSERT INTO astro_research (id, name, location, discovery_date, research_type) VALUES (2, 'Pulsar', 'Vela', '1967-11-28', 'Radio'); INSERT INTO astro_research (id, name, location, discovery_date, research_type) VALUES (3, 'Dark Matter', 'Bullet Cluster', '2006-08-22', 'Collision'); INSERT INTO astro_research (id, name, location, discovery_date, research_type) VALUES (4, 'Exoplanet', 'Kepler-22b', '2011-12-05', 'Habitable Zone'); | What are the names and discovery dates of the astrophysics research discovered before the 'Dark Matter' discovery? | SELECT name, discovery_date FROM astro_research WHERE discovery_date < (SELECT discovery_date FROM astro_research WHERE name = 'Dark Matter'); | gretelai_synthetic_text_to_sql |
CREATE TABLE institutions (id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO institutions (id, name, type) VALUES (1, 'University X', 'Public'), (2, 'College Y', 'Private'), (3, 'Institute Z', 'Private'); CREATE TABLE enrollments (id INT, institution_id INT, course_type VARCHAR(20), student_count INT); INSERT INTO enrollments (id, institution_id, course_type, student_count) VALUES (1, 1, 'Online', 1000), (2, 2, 'Online', 1500), (3, 3, 'Online', 800), (4, 1, 'In-person', 500); | What is the number of online course enrollments by institution and course type? | SELECT i.name, e.course_type, SUM(e.student_count) as total_enrolled FROM institutions i JOIN enrollments e ON i.id = e.institution_id GROUP BY i.name, e.course_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inspections (InspectionID INT, RestaurantID INT, InspectionDate DATETIME, CriticalViolationCount INT); | Show the number of food safety inspections and the percentage of inspections with critical violations for restaurants in Georgia, for the last 12 months. | SELECT RestaurantID, COUNT(*) OVER (PARTITION BY RestaurantID) as TotalInspections, (COUNT(*) FILTER (WHERE CriticalViolationCount > 0) OVER (PARTITION BY RestaurantID) * 100.0 / COUNT(*) OVER (PARTITION BY RestaurantID)) as CriticalViolationPercentage FROM Inspections WHERE RestaurantID IN (SELECT RestaurantID FROM Restaurants WHERE State = 'Georgia') AND InspectionDate > CURRENT_DATE - INTERVAL '12 months'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username VARCHAR(50), followers INT); CREATE TABLE posts (id INT, user_id INT, content VARCHAR(500)); | List the top 10 most active users in terms of total number of posts, along with the number of followers they have. | SELECT u.username, u.followers, COUNT(p.id) as total_posts FROM users u JOIN posts p ON u.id = p.user_id GROUP BY u.id ORDER BY total_posts DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_investment (country VARCHAR(50), investment_amount INT); | Insert renewable energy investment data for Kenya and Nigeria. | INSERT INTO renewable_investment (country, investment_amount) VALUES ('Kenya', 1200), ('Nigeria', 1800); | gretelai_synthetic_text_to_sql |
CREATE TABLE patch_delays (subsystem VARCHAR(255), delay INT); INSERT INTO patch_delays (subsystem, delay) VALUES ('applications', 5), ('database', 7), ('network', 3); | What is the maximum patch delay for the 'database' subsystem? | SELECT MAX(delay) FROM patch_delays WHERE subsystem = 'database'; | gretelai_synthetic_text_to_sql |
CREATE TABLE runners (athlete_id INT, name VARCHAR(50), races_won INT); INSERT INTO runners (athlete_id, name, races_won) VALUES (1, 'Mo Farah', 10); INSERT INTO runners (athlete_id, name, races_won) VALUES (2, 'Galen Rupp', 8); | What is the total number of races won by each athlete in the 'runners' table? | SELECT name, SUM(races_won) FROM runners GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Garments (id INT, name VARCHAR(255), category VARCHAR(255), color VARCHAR(255), size VARCHAR(10), price DECIMAL(5, 2)); | List all garments that are not available in size 'S' | SELECT * FROM Garments WHERE size != 'S'; | gretelai_synthetic_text_to_sql |
CREATE TABLE plant_temperature (plant_id INT, temp_date DATE, plant_location TEXT, temperature FLOAT); INSERT INTO plant_temperature (plant_id, temp_date, plant_location, temperature) VALUES (1, '2021-06-15', 'Plant A', 32.5), (2, '2021-07-20', 'Plant B', 36.7), (3, '2021-08-05', 'Plant C', 41.2); | What is the maximum temperature recorded in each chemical plant during the summer season, and the corresponding date? | SELECT plant_location, temp_date, MAX(temperature) AS max_temp FROM plant_temperature WHERE temp_date >= DATEADD(month, 5, DATEADD(year, DATEDIFF(year, 0, CURRENT_DATE), 0)) AND temp_date < DATEADD(month, 8, DATEADD(year, DATEDIFF(year, 0, CURRENT_DATE), 0)) GROUP BY plant_location, temp_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (id INT PRIMARY KEY, completion_date DATE, budget DECIMAL(10, 2), project_name VARCHAR(100)); INSERT INTO military_innovation (id, completion_date, budget, project_name) VALUES (1, '2020-02-28', 300000, 'Project 1'), (2, '2019-05-15', 150000, 'Project 2'), (3, '2018-12-31', 250000, 'Project 3'); | How many military innovation projects were completed in the last 3 years, with a budget over 200000? | SELECT COUNT(*) FROM military_innovation WHERE completion_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND CURRENT_DATE AND budget > 200000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, DiversityTraining BOOLEAN); INSERT INTO Employees (EmployeeID, DiversityTraining) VALUES (1, 1), (2, 0), (3, 1); | What is the percentage of employees who have completed diversity and inclusion training? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees)) AS Percentage FROM Employees WHERE DiversityTraining = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (1, 30, 'Female', 'CBT', 'Texas'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (2, 45, 'Male', 'DBT', 'California'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (3, 25, 'Non-binary', 'Therapy', 'Washington'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (4, 18, 'Male', 'Therapy', 'Colorado'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (5, 50, 'Female', 'Therapy', 'California'); | What is the number of patients who identified as female and received therapy in California? | SELECT COUNT(*) FROM patients WHERE gender = 'Female' AND treatment = 'Therapy' AND state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_sustainability (id INT PRIMARY KEY, menu_item VARCHAR(255), sustainability_rating DECIMAL(3,2)); CREATE TABLE menu_items (id INT PRIMARY KEY, menu_item VARCHAR(255), is_vegan BOOLEAN); | Find the average sustainability rating for all vegan menu items | SELECT AVG(sustainability_rating) FROM menu_sustainability ms JOIN menu_items mi ON ms.menu_item = mi.menu_item WHERE mi.is_vegan = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Species ( id INT PRIMARY KEY, species_name VARCHAR(100), population INT, conservation_status VARCHAR(50)); INSERT INTO Species (id, species_name, population, conservation_status) VALUES (5, 'Vaquita', 10, 'Critically Endangered'); INSERT INTO Species (id, species_name, population, conservation_status) VALUES (6, 'Javan Rhino', 67, 'Critically Endangered'); | How many species are listed as 'Critically Endangered' and their population? | SELECT species_name, population FROM Species WHERE conservation_status = 'Critically Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturers (id INT, name VARCHAR(255)); INSERT INTO Manufacturers (id, name) VALUES (1, 'Tesla'); INSERT INTO Manufacturers (id, name) VALUES (2, 'Audi'); CREATE TABLE Autonomous_Vehicles (id INT, manufacturer_id INT, make VARCHAR(255), model VARCHAR(255)); INSERT INTO Autonomous_Vehicles (id, manufacturer_id, make, model) VALUES (1, 1, 'Tesla', 'Model S'); INSERT INTO Autonomous_Vehicles (id, manufacturer_id, make, model) VALUES (2, 1, 'Tesla', 'Model X'); INSERT INTO Autonomous_Vehicles (id, manufacturer_id, make, model) VALUES (3, 2, 'Audi', 'e-Tron'); | What is the number of autonomous driving research vehicles produced by each manufacturer? | SELECT m.name, COUNT(av.id) FROM Manufacturers m JOIN Autonomous_Vehicles av ON m.id = av.manufacturer_id GROUP BY m.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transport_cities (city VARCHAR(255), system_name VARCHAR(255), num_vehicles INT); INSERT INTO public_transport_cities (city, system_name, num_vehicles) VALUES ('New York', 'NYC Subway', 6000), ('New York', 'NYC Bus', 2000), ('London', 'London Tube', 4000), ('London', 'London Bus', 3000), ('Paris', 'Paris Metro', 2500), ('Paris', 'Paris Bus', 1500); | What is the total number of public transportation vehicles in the 'public_transport' schema, grouped by city? | SELECT city, SUM(num_vehicles) FROM public_transport_cities GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE CybersecurityIncidents (Incident VARCHAR(50), ImpactLevel VARCHAR(10)); INSERT INTO CybersecurityIncidents (Incident, ImpactLevel) VALUES ('Data Breach', 'High'), ('Phishing Attack', 'Low'), ('Ransomware Attack', 'Medium'), ('Insider Threat', 'High'), ('Botnet Attack', 'Medium'); | List all unique cybersecurity incidents with an impact level of 'high' or 'critical'. | SELECT DISTINCT Incident FROM CybersecurityIncidents WHERE ImpactLevel IN ('High', 'Critical'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, is_eco_friendly BOOLEAN); INSERT INTO hotels (id, name, country, is_eco_friendly) VALUES (1, 'Green Hotel', 'France', true), (2, 'Le Château', 'France', false); CREATE TABLE bookings (id INT, hotel_id INT, revenue INT); INSERT INTO bookings (id, hotel_id, revenue) VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 1500); | What is the total revenue generated by eco-friendly hotels in France? | SELECT SUM(bookings.revenue) FROM bookings JOIN hotels ON bookings.hotel_id = hotels.id WHERE hotels.country = 'France' AND hotels.is_eco_friendly = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(drug_name TEXT, country TEXT, sales_half INT, revenue FLOAT, return_amount FLOAT); INSERT INTO sales (drug_name, country, sales_half, revenue, return_amount) VALUES ('DrugA', 'CountryY', 1, 1200000, 100000), ('DrugB', 'CountryX', 1, 1000000, 50000), ('DrugG', 'CountryI', 1, 1500000, 0), ('DrugC', 'CountryX', 2, 1300000, 200000); | What was the total revenue for 'DrugG' in 'CountryI' in the first half of 2019, excluding returns? | SELECT SUM(sales.revenue - COALESCE(sales.return_amount, 0)) AS total_revenue FROM sales WHERE drug_name = 'DrugG' AND country = 'CountryI' AND sales_half = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (SatelliteId INT, Name VARCHAR(50), LaunchDate DATE, OrbitType VARCHAR(50), Country VARCHAR(50)); INSERT INTO Satellites (SatelliteId, Name, LaunchDate, OrbitType, Country) VALUES (5, 'Ekspress-AM5', '2013-12-15', 'GEO', 'Russia'); | What is the earliest launch date of a geostationary satellite from Russia? | SELECT Country, MIN(LaunchDate) FROM Satellites WHERE OrbitType = 'GEO' AND Country = 'Russia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams (dam_id INT, dam_name VARCHAR(50), location VARCHAR(50), length DECIMAL(10,2), reservoir_capacity INT); | What is the maximum length of a dam in the 'dams' table? | SELECT MAX(length) FROM dams; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (drug_id INT, drug_name TEXT, sales_figure INT, region TEXT); INSERT INTO drugs (drug_id, drug_name, sales_figure, region) VALUES (1, 'DrugA', 500, 'Asia-Pacific'), (2, 'DrugB', 750, 'Europe'); | What are the total sales figures for each drug in the 'drugs' table, including drugs with no sales, in the Asia-Pacific region? | SELECT d.drug_name, COALESCE(SUM(s.sales_figure), 0) AS total_sales FROM drugs d LEFT JOIN sales s ON d.drug_id = s.drug_id WHERE d.region = 'Asia-Pacific' GROUP BY d.drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT PRIMARY KEY, location VARCHAR(255), waste_type VARCHAR(255), quantity INT, date DATE); | Update the quantity of 'Plastic Bottles' to 1500 in waste_generation table | UPDATE waste_generation SET quantity = 1500 WHERE waste_type = 'Plastic Bottles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, volunteer_id INT, donation_amount DECIMAL); INSERT INTO donations (id, volunteer_id, donation_amount) VALUES (1, 1, '100.00'), (2, 1, '75.00'), (3, 2, '25.00'), (4, 2, '150.00'); | Delete all records from the 'donations' table that are under $50. | DELETE FROM donations WHERE donation_amount < 50.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_supply (product_id INT, product_name TEXT, price DECIMAL); INSERT INTO circular_supply (product_id, product_name, price) VALUES (1, 'Reusable Bag', 25), (2, 'Refillable Bottle', 15), (3, 'Solar-Powered Lamp', 60); | What is the maximum price of a product in the circular_supply table? | SELECT MAX(price) FROM circular_supply; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports(id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE vessels(id INT, name VARCHAR(255), flag VARCHAR(255), port_id INT); CREATE TABLE regulatory_authorities(id INT, name VARCHAR(255), country VARCHAR(255)); | List all ports and their corresponding regulatory authority for vessels flying the flag of Panama. | SELECT ports.name, regulatory_authorities.name FROM ports INNER JOIN vessels ON ports.id = vessels.port_id INNER JOIN regulatory_authorities ON ports.country = regulatory_authorities.country WHERE vessels.flag = 'Panama'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tickets (ticket_id INT, game_id INT, quantity INT, price DECIMAL(5,2)); INSERT INTO tickets VALUES (1, 1, 50, 25.99); INSERT INTO tickets VALUES (2, 2, 30, 19.99); CREATE TABLE games (game_id INT, team VARCHAR(20), location VARCHAR(20)); INSERT INTO games VALUES (1, 'Cubs', 'Chicago'); INSERT INTO games VALUES (2, 'White Sox', 'Chicago'); | Find the number of tickets sold for each game of the baseball team in Chicago. | SELECT games.team, SUM(tickets.quantity) FROM tickets INNER JOIN games ON tickets.game_id = games.game_id WHERE games.team = 'Cubs' GROUP BY games.team; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_vehicles (vehicle_type VARCHAR(50), fleet_name VARCHAR(50), is_accessible BOOLEAN); INSERT INTO accessible_vehicles (vehicle_type, fleet_name, is_accessible) VALUES ('Green Line', 'Bus', true), ('Green Line', 'Train', false), ('Blue Line', 'Bus', true); | Display the number of accessible vehicles in the 'Green Line' fleet | SELECT COUNT(*) FROM accessible_vehicles WHERE fleet_name = 'Green Line' AND is_accessible = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_map (id INT, project_name VARCHAR(255), region VARCHAR(255), avg_depth FLOAT); | What is the average depth of ocean floor mapping project sites in the Pacific region? | SELECT avg(avg_depth) FROM ocean_floor_map WHERE region = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (year INT, country VARCHAR(50), purpose VARCHAR(50), amount FLOAT); INSERT INTO climate_finance (year, country, purpose, amount) VALUES (2019, 'Brazil', 'Mitigation', 500000), (2019, 'India', 'Mitigation', 700000), (2019, 'Indonesia', 'Adaptation', 600000), (2019, 'South Africa', 'Mitigation', 800000); | Which countries received climate finance for mitigation projects in 2019? | SELECT DISTINCT country FROM climate_finance WHERE year = 2019 AND purpose = 'Mitigation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_management (waste_id INT PRIMARY KEY, waste_type VARCHAR(20)); INSERT INTO waste_management (waste_id, waste_type) VALUES (1, 'Non-Toxic'), (2, 'Toxic'), (3, 'Non-Toxic'); | Delete all records in the "waste_management" table where the "waste_type" is 'Toxic' | DELETE FROM waste_management WHERE waste_type = 'Toxic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, name VARCHAR(50), start_date DATE, end_date DATE, day VARCHAR(10)); INSERT INTO Exhibitions (exhibition_id, name, start_date, end_date, day) VALUES (1, 'Impressionist', '2020-05-01', '2021-01-01', 'Saturday'), (2, 'Cubism', '2019-08-15', '2020-03-30', 'Sunday'), (3, 'Surrealism', '2018-12-15', '2019-09-15', 'Saturday'); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT, gender VARCHAR(50)); | How many visitors attended each exhibition on Saturday? | SELECT exhibition_id, COUNT(*) FROM Visitors INNER JOIN Exhibitions ON Visitors.exhibition_id = Exhibitions.exhibition_id WHERE day = 'Saturday' GROUP BY exhibition_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, studio_country VARCHAR(50)); INSERT INTO movies (id, title, release_year, studio_country) VALUES (1, 'Movie1', 2000, 'USA'), (2, 'Movie2', 2005, 'Canada'), (3, 'Movie3', 2010, 'USA'); | What is the total number of movies produced by studios based in the United States and Canada? | SELECT COUNT(*) FROM movies WHERE studio_country IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, region TEXT, start_year INT); CREATE TABLE publications (id INT, student_id INT, year INT); INSERT INTO students (id, region, start_year) VALUES (1, 'Nigeria', 2019); INSERT INTO publications (id, student_id, year) VALUES (1, 1, 2021); | How many publications were made by graduate students from 'Africa' in 2021? | SELECT COUNT(*) FROM publications JOIN students ON publications.student_id = students.id WHERE students.region = 'Nigeria' AND publications.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE routes (line VARCHAR(10), revenue FLOAT); INSERT INTO routes (line, revenue) VALUES ('red', 15000.00), ('blue', 20000.00), ('green', 12000.00); | What is the total revenue generated from adult passengers in the 'red' line? | SELECT SUM(revenue) FROM routes WHERE line = 'red' AND revenue=(SELECT revenue FROM routes WHERE line = 'red' AND passenger_type = 'adult'); | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name VARCHAR(50), category VARCHAR(20)); CREATE TABLE donations (id INT, organization_id INT, amount DECIMAL(10, 2)); INSERT INTO organizations (id, name, category) VALUES (1, 'Org1', 'Arts & Culture'), (2, 'Org2', 'Arts & Culture'), (3, 'Org3', 'Education'), (4, 'Org4', 'Health'); INSERT INTO donations (id, organization_id, amount) VALUES (1, 1, 500), (2, 1, 700), (3, 2, 1000), (4, 2, 1200), (5, 3, 800), (6, 4, 900); | List the top 5 organizations with the highest total donation amounts in the 'Arts & Culture' category. | SELECT organizations.name, SUM(donations.amount) as total_donation FROM organizations JOIN donations ON organizations.id = donations.organization_id WHERE organizations.category = 'Arts & Culture' GROUP BY organizations.name ORDER BY total_donation DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_devices (id INT, device_name VARCHAR(255), max_attempts INT); INSERT INTO network_devices (id, device_name, max_attempts) VALUES (1, 'Switch1', 5), (2, 'Router1', 3), (3, 'Firewall1', 7); | What is the maximum number of attempts before a lockout for failed authentication on network devices? | SELECT MAX(max_attempts) FROM network_devices; | gretelai_synthetic_text_to_sql |
CREATE TABLE CoLivingProperties(id INT, name VARCHAR(50), city VARCHAR(20));INSERT INTO CoLivingProperties(id, name, city) VALUES (1, 'GreenSpaces', 'Portland'), (2, 'EcoVillage', 'SanFrancisco'), (3, 'UrbanNest', 'Portland'), (4, 'EcoHaven', 'Austin'); | List the names of the cities with co-living properties and their respective co-living property counts. | SELECT city, COUNT(*) FROM CoLivingProperties GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (country TEXT, year INT, population INT, co2_emissions FLOAT); INSERT INTO co2_emissions (country, year, population, co2_emissions) VALUES ('Nigeria', 2017, 196.0, 510.0), ('Nigeria', 2022, 205.0, 550.0), ('Kenya', 2017, 49.0, 110.0), ('Kenya', 2022, 52.0, 120.0), ('South Africa', 2017, 57.0, 490.0), ('South Africa', 2022, 59.0, 520.0); | What is the average CO2 emissions (tCO2) per capita in Nigeria, Kenya, and South Africa, for the years 2017 and 2022? | SELECT country, AVG(co2_emissions/population) FROM co2_emissions WHERE country IN ('Nigeria', 'Kenya', 'South Africa') AND year IN (2017, 2022) GROUP BY country; | 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.