context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE TicketSales (id INT, event_type VARCHAR(255), location VARCHAR(255), tickets_sold INT, price DECIMAL(5,2), ticket_type VARCHAR(50), date DATE); INSERT INTO TicketSales (id, event_type, location, tickets_sold, price, ticket_type, date) VALUES (1, 'Concert', 'Indoor Arena', 1500, 150, 'VIP', '2021-11-01'), (... | What was the total revenue from VIP ticket sales for the last 5 concerts at indoor arenas? | SELECT SUM(price * tickets_sold) FROM TicketSales WHERE event_type = 'Concert' AND location = 'Indoor Arena' AND ticket_type = 'VIP' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name VARCHAR(255), has_ocean_acidification_monitoring BOOLEAN); INSERT INTO marine_protected_areas (area_name, has_ocean_acidification_monitoring) VALUES ('Galapagos Marine Reserve', TRUE), ('Great Barrier Reef', FALSE); | Retrieve the names of marine protected areas with ocean acidification monitoring. | SELECT area_name FROM marine_protected_areas WHERE has_ocean_acidification_monitoring = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material_id INT, material_name TEXT, is_eco_friendly BOOLEAN, price DECIMAL); INSERT INTO materials VALUES (1, 'organic cotton', TRUE, 2.5); INSERT INTO materials VALUES (2, 'recycled polyester', TRUE, 3.25); | What is the average price of eco-friendly materials in the materials table? | SELECT AVG(price) FROM materials WHERE is_eco_friendly = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(255), esg_score DECIMAL(3,2), sector VARCHAR(255), region VARCHAR(255), quarter DATE); | Find the average ESG score for Latin American healthcare companies in Q2 2021. | SELECT AVG(esg_score) FROM companies WHERE sector = 'Healthcare' AND region = 'Latin America' AND QUARTER(quarter) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE WinsByRank (PlayerID INT, GameName VARCHAR(20), Wins INT, Rank VARCHAR(10)); INSERT INTO WinsByRank (PlayerID, GameName, Wins, Rank) VALUES (3001, 'Space Arena', 10, 'Gold'), (3002, 'Space Arena', 7, 'Platinum'), (3003, 'Space Arena', 15, 'Silver'); | What is the percentage of wins by players in the "Space Arena" game who achieved a rank of Gold or higher? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM WinsByRank WHERE GameName = 'Space Arena') AS WinPercentage FROM WinsByRank WHERE GameName = 'Space Arena' AND Rank IN ('Gold', 'Platinum', 'Diamond'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(100), Age INT, Sport VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Players_Matches (PlayerID INT, MatchID INT, Goals INT, FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)); INSERT INTO Players_Matches (PlayerID, MatchID, Goals) VALUES (1, 1, 4); INSERT I... | What is the maximum number of goals scored by a player from Brazil in a single match? | SELECT MAX(Goals) as MaxGoals FROM Players_Matches JOIN Players ON Players.PlayerID = Players_Matches.PlayerID WHERE Players.Country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, city VARCHAR(50), year INT, ticket_price DECIMAL(5,2));INSERT INTO Exhibitions (id, city, year, ticket_price) VALUES (1, 'Paris', 2020, 25.50); | What was the average ticket price for art exhibitions in Paris in 2020? | SELECT AVG(ticket_price) FROM Exhibitions WHERE city = 'Paris' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer (customer_id INT, primary_advisor VARCHAR(255)); CREATE TABLE transaction (transaction_date DATE, customer_id INT, transaction_volume DECIMAL(10,2)); | List the top 5 customers with the highest average daily transaction volume in the last month, along with their primary investment advisor's name. | SELECT c.customer_id, c.primary_advisor, AVG(t.transaction_volume) as avg_daily_volume FROM customer c JOIN transaction t ON c.customer_id = t.customer_id WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY c.customer_id ORDER BY avg_daily_volume DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (compliance_id INT, regulation_name VARCHAR(50), compliance_status VARCHAR(50), compliance_date DATE); | Add a new record to the regulatory_compliance table | INSERT INTO regulatory_compliance (compliance_id, regulation_name, compliance_status, compliance_date) VALUES (22222, 'Data Privacy Act', 'Compliant', '2021-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryPeacekeeping (Country VARCHAR(50), OperationID INT); INSERT INTO CountryPeacekeeping (Country, OperationID) VALUES ('Bangladesh', 1), ('Pakistan', 2), ('Ethiopia', 3), ('Bangladesh', 4), ('Rwanda', 5); | Which countries have participated in the most peacekeeping operations? | SELECT Country, COUNT(*) AS OperationsParticipated FROM CountryPeacekeeping GROUP BY Country ORDER BY OperationsParticipated DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodTrends (product_id INT, product_name VARCHAR(255), category VARCHAR(100), popularity_score INT); INSERT INTO FoodTrends (product_id, product_name, category, popularity_score) VALUES (1, 'Quinoa Salad', 'Organic', 85), (2, 'Chia Seeds', 'Vegan', 90), (3, 'Grass-Fed Beef', 'Sustainable', 75); | What is the minimum popularity score for each category in the food trends table? | SELECT category, MIN(popularity_score) FROM FoodTrends GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE VIEW fan_demographics AS SELECT fan_id, age, gender, city, state, country FROM fan_info WHERE state IN ('NY', 'CA', 'TX'); | Create a view named 'fan_demographics' to show fan demographics data | CREATE VIEW fan_demographics AS SELECT fan_id, age, gender, city, state, country FROM fan_info WHERE state IN ('NY', 'CA', 'TX'); | gretelai_synthetic_text_to_sql |
CREATE TABLE UserStreamCountries2 (Country VARCHAR(20), UserCount INT); INSERT INTO UserStreamCountries2 (Country, UserCount) VALUES ('USA', '10000000'), ('UK', '6000000'), ('Canada', '4000000'), ('Australia', '3000000'), ('Germany', '5000000'), ('France', '2000000'), ('Spain', '2500000'); | List the top 3 countries with the lowest number of unique users who have streamed music. | SELECT Country, UserCount FROM UserStreamCountries2 ORDER BY UserCount ASC LIMIT 3; | gretelai_synthetic_text_to_sql |
endangered_language (language, status, total_speakers) | Update the endangered_language table's status to 'critical' where total_speakers is less than 1000 and the language is 'Ainu'. | UPDATE endangered_language SET status = 'critical' WHERE total_speakers < 1000 AND language = 'Ainu'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_projects (id INT, project_name VARCHAR(255), location VARCHAR(255), sector VARCHAR(255), cost FLOAT); | Insert a new rural infrastructure project with the given details and assign it a unique id. | INSERT INTO rural_infrastructure_projects (project_name, location, sector, cost) VALUES ('Waste Management System', 'Village E', 'Infrastructure', 60000.00) RETURNING id; | gretelai_synthetic_text_to_sql |
CREATE TABLE launches (id INT, agency_id INT, launch_result VARCHAR(10)); CREATE TABLE space_agencies (id INT, name VARCHAR(50)); | What is the success rate of each space agency's launches? | SELECT a.name, COUNT(l.id) AS total_launches, SUM(CASE WHEN l.launch_result = 'success' THEN 1 ELSE 0 END) AS successful_launches, 100.0 * SUM(CASE WHEN l.launch_result = 'success' THEN 1 ELSE 0 END) / COUNT(l.id) AS success_rate FROM launches l JOIN space_agencies a ON l.agency_id = a.id GROUP BY a.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location VARCHAR(255), level FLOAT); INSERT INTO ocean_acidification (location, level) VALUES ('Southern Ocean', 12.5), ('Atlantic Ocean', 45.6); | What is the minimum ocean acidification level in the Southern Ocean? | SELECT MIN(level) FROM ocean_acidification WHERE location = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiations (id INT, contract_name VARCHAR(50), negotiation_date DATE, customer VARCHAR(50), value DECIMAL(10,2)); | What is the total value of contract negotiations with the US government in the current fiscal year? | SELECT SUM(value) as total_value FROM contract_negotiations WHERE customer = 'US government' AND negotiation_date >= DATEADD(year, DATEDIFF(year, 0, GETDATE()), 0) AND negotiation_date < DATEADD(year, DATEDIFF(year, 0, GETDATE()) + 1, 0); | gretelai_synthetic_text_to_sql |
CREATE TABLE industry_4_0 (id INT PRIMARY KEY, initiative_name VARCHAR(100), implementation_date DATE); | Delete all records from the 'industry_4_0' table where the 'implementation_date' is after '2022-12-31' | DELETE FROM industry_4_0 WHERE implementation_date > '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (mission_id INT, country_id INT, year INT, FOREIGN KEY (country_id) REFERENCES country(id)); | What is the name of the country that conducted the most humanitarian assistance missions in 2019? | SELECT c.name FROM country c INNER JOIN (SELECT country_id, COUNT(mission_id) as total_missions FROM humanitarian_assistance WHERE year = 2019 GROUP BY country_id ORDER BY total_missions DESC LIMIT 1) h ON c.id = h.country_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donation_date DATE, amount DECIMAL(10,2)); INSERT INTO donations (donor_id, donation_date, amount) VALUES (1, '2021-01-01', 50.00), (2, '2021-01-15', 100.00), (1, '2021-03-05', 200.00); | How many donations were made in each month? | SELECT DATE_FORMAT(donation_date, '%Y-%m') AS month, COUNT(*) AS num_donations FROM donations GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (artwork_id INT, title VARCHAR(50), year INT, artist_id INT, country VARCHAR(50)); INSERT INTO artworks (artwork_id, title, year, artist_id, country) VALUES (1, 'Guernica', 1937, 1, 'Spain'); INSERT INTO artworks (artwork_id, title, year, artist_id, country) VALUES (2, 'Study for Portrait of Lucia... | What is the total number of artworks in the 'artworks' table? | SELECT COUNT(*) FROM artworks; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Oakland'), (2, 'Seattle'), (5, 'Mumbai'), (6, 'Singapore'); CREATE TABLE vessels (vessel_id INT, port_id INT); INSERT INTO vessels (vessel_id, port_id) VALUES (101, 5), (102, 5), (103, 6), (104, 5); CREATE TABLE ca... | List all the vessels that entered the port of Mumbai and their corresponding cargo types, sorted by the cargo type. | SELECT vessels.vessel_id, cargo.cargo_type FROM vessels JOIN port ON vessels.port_id = port.port_id JOIN cargo ON vessels.vessel_id = cargo.vessel_id WHERE port.port_name = 'Mumbai' ORDER BY cargo.cargo_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, customer_id INT, fund_type VARCHAR(50), transaction_amount DECIMAL(10,2)); INSERT INTO transactions (id, customer_id, fund_type, transaction_amount) VALUES (1, 1, 'Bond', 5000.00); INSERT INTO transactions (id, customer_id, fund_type, transaction_amount) VALUES (2, 2, 'Equity', 8000.0... | What is the maximum transaction amount for the 'Bond' fund type? | SELECT MAX(transaction_amount) FROM transactions WHERE fund_type = 'Bond'; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_literacy (id INT, name VARCHAR(50), score INT, gender VARCHAR(10), region VARCHAR(50)); INSERT INTO media_literacy (id, name, score, gender, region) VALUES (1, 'Student1', 85, 'Male', 'North America'), (2, 'Student2', 78, 'Female', 'Europe'), (3, 'Student3', 92, 'Female', 'South America'); | What is the distribution of media literacy scores for students in North America by gender? | SELECT gender, AVG(score) AS avg_score, STD(score) AS std_score FROM media_literacy WHERE region = 'North America' GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, common_name TEXT, scientific_name TEXT, conservation_status TEXT, location TEXT); INSERT INTO marine_species (id, common_name, scientific_name, conservation_status, location) VALUES (1, 'European Eel', 'Anguilla anguilla', 'Critically Endangered', 'Mediterranean Sea'), (2, 'Mediterr... | List all marine species that are endemic to the Mediterranean Sea. | SELECT * FROM marine_species WHERE location = 'Mediterranean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_launches (id INT, launch_company VARCHAR(50), launch_date DATE, launch_cost FLOAT); | What is the average cost of a space launch by SpaceX? | SELECT AVG(launch_cost) FROM space_launches WHERE launch_company = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name TEXT, industry TEXT); INSERT INTO department (id, name, industry) VALUES (1, 'Mining Operations', 'Mining'), (2, 'Environment', 'Mining'), (3, 'Human Resources', 'Mining'); CREATE TABLE employee (id INT, name TEXT, department_id INT, gender TEXT); INSERT INTO employee (id, name, de... | How many employees work in the mining operations department by gender? | SELECT department_id, gender, COUNT(*) as employee_count FROM employee GROUP BY department_id, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_population (city VARCHAR(50), country VARCHAR(50), population INT); INSERT INTO city_population (city, country, population) VALUES ('Paris', 'France', 2206486), ('London', 'United Kingdom', 8961989), ('Berlin', 'Germany', 3748144), ('Madrid', 'Spain', 3223252), ('Rome', 'Italy', 2872294), ('Bucharest'... | What is the total population of cities in Europe with a population greater than 1 million? | SELECT SUM(population) FROM city_population WHERE country IN ('France', 'United Kingdom', 'Germany', 'Spain', 'Italy', 'Romania', 'Austria', 'Poland') AND population > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_volume (stock_symbol VARCHAR(10), trading_date DATE, volume INT); INSERT INTO daily_volume (stock_symbol, trading_date, volume) VALUES ('AAPL', '2022-01-01', 1000000); INSERT INTO daily_volume (stock_symbol, trading_date, volume) VALUES ('AAPL', '2022-01-02', 1200000); INSERT INTO daily_volume (stock... | Find the stock with the highest daily trading volume for each month in the year 2022? | SELECT stock_symbol, MAX(volume) over (partition by EXTRACT(MONTH FROM trading_date)) as max_volume FROM daily_volume WHERE trading_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY stock_symbol, EXTRACT(MONTH FROM trading_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT); CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY, Name VARCHAR(255), StartDate DATE, EndDate DATE, VenueType VARCHAR(255)); C... | Which artworks by artists from Nigeria were exhibited in galleries in Paris? | SELECT Artworks.Title FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID INNER JOIN ExhibitionArtworks ON Artworks.ArtworkID = ExhibitionArtworks.ArtworkID INNER JOIN Exhibitions ON ExhibitionArtworks.ExhibitionID = Exhibitions.ExhibitionID WHERE Artists.Nationality = 'Nigerian' AND Exhibitions.Ve... | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (PortID INT, PortName VARCHAR(100), City VARCHAR(100), Country VARCHAR(100)); INSERT INTO Port (PortID, PortName, City, Country) VALUES (1, 'Port of Los Angeles', 'Los Angeles', 'USA'); INSERT INTO Port (PortID, PortName, City, Country) VALUES (2, 'Port of Rotterdam', 'Rotterdam', 'Netherlands'); CREA... | What is the total volume of cargo per country, ranked by the highest total? | SELECT Country, SUM(Volume) OVER(PARTITION BY Country ORDER BY Country) AS TotalVolume FROM Cargo ORDER BY TotalVolume DESC | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseDiplomacy (EventID INT, Country VARCHAR(50), EventName VARCHAR(100), EventDate DATE); | What is the total number of defense diplomacy events conducted by the UK and France? | SELECT COUNT(EventID) FROM DefenseDiplomacy WHERE Country IN ('UK', 'France'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_tracking (cargo_id INT, cargo_type TEXT, weight FLOAT, vessel_id INT); CREATE TABLE vessels (vessel_id INT, vessel_name TEXT); | List all unique cargo types, their respective total weights, and average weight per cargo for vessels 'W' and 'V' from the 'cargo_tracking' and 'vessels' tables | SELECT c.cargo_type, SUM(c.weight) as total_weight, AVG(c.weight) as avg_weight_per_cargo FROM cargo_tracking c INNER JOIN vessels v ON c.vessel_id = v.vessel_id WHERE v.vessel_name IN ('W', 'V') GROUP BY c.cargo_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_launches (id INT, spacecraft VARCHAR(30), launch_date DATE); INSERT INTO spacecraft_launches (id, spacecraft, launch_date) VALUES (1, 'Saturn V', '1967-11-09'), (2, 'Soyuz', '1966-11-28'), (3, 'Space Shuttle', '1981-04-12'), (4, 'Falcon 9', '2010-06-04'), (5, 'Long March 2F', '1999-01-19'), (6, ... | What is the earliest launch date for each type of spacecraft in the spacecraft_launches table? | SELECT * FROM earliest_launch_dates; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_reporting (article_id INT, category TEXT); INSERT INTO news_reporting (article_id, category) VALUES (1, 'politics'), (2, 'sports'), (3, 'politics'), (4, 'entertainment'); | What is the total number of news articles published in 'news_reporting' table for each category? | SELECT category, COUNT(*) FROM news_reporting GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, City VARCHAR(50)); INSERT INTO Workouts (WorkoutID, City) VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'); | What is the total number of workouts in each city? | SELECT City, COUNT(*) FROM Workouts GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (id INT, initiative_name TEXT, country TEXT); | List pollution control initiatives by country? | SELECT initiative_name, country FROM pollution_control_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, name TEXT, region TEXT, leader TEXT, start_date DATE); INSERT INTO initiatives (id, name, region, leader, start_date) VALUES (1, 'Initiative 1', 'rural India', 'Ms. Patel', '2015-01-01'), (2, 'Initiative 2', 'rural India', 'Mr. Patel', '2016-01-01'), (3, 'Initiative 3', 'urban India', ... | What is the number of 'women-led community development initiatives' in 'rural India' that have been implemented since 2015? | SELECT COUNT(initiatives.id) FROM initiatives WHERE initiatives.region = 'rural India' AND initiatives.leader LIKE 'Ms.%' AND initiatives.start_date >= '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm_data (id INT, farm_name VARCHAR(50), species VARCHAR(50), water_temperature FLOAT); INSERT INTO farm_data (id, farm_name, species, water_temperature) VALUES (1, 'Black Sea Sturgeon Farm', 'Sturgeon', 18.5), (2, 'Caspian Sea Sturgeon Farm', 'Sturgeon', 19.2), (3, 'Atlantic Salmon Farm', 'Salmon', 12.3)... | What is the average water temperature in farms that grow sturgeon? | SELECT AVG(water_temperature) as avg_temp FROM farm_data WHERE species = 'Sturgeon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255), region_id INT, FOREIGN KEY (region_id) REFERENCES regions(id));CREATE TABLE flights (id INT PRIMARY KEY, origin_country_id INT, destination_country_id INT, flight_type VARCHAR(50), CO2_emission IN... | What is the total CO2 emission of domestic flights in Europe? | SELECT SUM(CO2_emission) FROM flights WHERE flight_type = 'domestic' AND origin_country_id IN (SELECT id FROM countries WHERE region_id = (SELECT id FROM regions WHERE name = 'Europe')); | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_sequestration_2(year INT, region VARCHAR(255), forest VARCHAR(255), sequestration_volume FLOAT); INSERT INTO carbon_sequestration_2(year, region, forest, sequestration_volume) VALUES (2017, 'Asia', 'Tropical Forest', 1000.0), (2017, 'Asia', 'Temperate Forest', 1200.0), (2018, 'Africa', 'Tropical For... | What is the total carbon sequestration for each African forest in 2018? | SELECT forest, SUM(sequestration_volume) as total_sequestration FROM carbon_sequestration_2 WHERE year = 2018 AND region = 'Africa' GROUP BY forest; | gretelai_synthetic_text_to_sql |
CREATE TABLE Caribbean_Coastlines (country TEXT, coastline_km FLOAT); INSERT INTO Caribbean_Coastlines (country, coastline_km) VALUES ('Cuba', 5745), ('Jamaica', 1022); | Which countries in the Caribbean region have the longest coastlines? | SELECT country, coastline_km FROM Caribbean_Coastlines ORDER BY coastline_km DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSiteCount (Country TEXT, SiteCount INT); INSERT INTO ExcavationSiteCount (Country, SiteCount) VALUES ('Italy', 2), ('France', 1), ('Egypt', 1), ('China', 1); | How many excavation sites are there in each country? | SELECT Country, SiteCount FROM ExcavationSiteCount; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_tax (region VARCHAR(50), tax_percentage DECIMAL(5,2)); INSERT INTO sales_tax (region, tax_percentage) VALUES ('North America', 0.08), ('South America', 0.15), ('Europe', 0.20), ('Middle East', 0.12), ('Asia', 0.18); | Show me the tax percentage for the 'Middle East' region | SELECT tax_percentage FROM sales_tax WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_founding (company_name VARCHAR(255), founder_gender VARCHAR(50)); INSERT INTO company_founding (company_name, founder_gender) VALUES ('Acme Inc', 'Female'), ('Beta Corp', 'Male'), ('Charlie LLC', 'Female'), ('Delta Co', 'Male'); | Calculate the percentage of companies founded by women | SELECT (COUNT(*) * 100 / (SELECT COUNT(*) FROM company_founding)) AS percentage_female_founded FROM company_founding WHERE founder_gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(20));CREATE TABLE Events (EventID INT, EventName VARCHAR(20), EventCategory VARCHAR(20));CREATE TABLE VisitorEvent (VisitorID INT, EventID INT); | What is the total number of visitors who identified as 'Non-binary' and attended events in the 'Dance' category? | SELECT COUNT(DISTINCT V.VisitorID) AS Total_Visitors FROM Visitors V INNER JOIN VisitorEvent VE ON V.VisitorID = VE.VisitorID WHERE V.Gender = 'Non-binary' AND VE.EventID IN (SELECT EventID FROM Events WHERE EventCategory = 'Dance'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), email VARCHAR(50), subscribed_to_newsletter BOOLEAN); | Add new records of users who have signed up for the newsletter in the last week to the users table | INSERT INTO users (name, email, subscribed_to_newsletter) SELECT name, email, true FROM signups WHERE signup_date > DATE_SUB(CURDATE(), INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSite (SiteID INT, SiteName TEXT, Country TEXT, NumArtifacts INT); | Add a new excavation site to the database: 'Tikal', Guatemala, 80 artifacts. | INSERT INTO ExcavationSite (SiteName, Country, NumArtifacts) VALUES ('Tikal', 'Guatemala', 80); | gretelai_synthetic_text_to_sql |
CREATE TABLE Investments (InvestmentID INT, CustomerID INT, InvestmentType VARCHAR(20), Amount DECIMAL(10,2)); INSERT INTO Investments (InvestmentID, CustomerID, InvestmentType, Amount) VALUES (1, 1, 'Stocks', 5000.00); INSERT INTO Investments (InvestmentID, CustomerID, InvestmentType, Amount) VALUES (2, 1, 'Bonds', 70... | What is the total investment in bonds for customers who have invested more than $5000 in bonds? | SELECT CustomerID, SUM(Amount) FROM Investments WHERE InvestmentType = 'Bonds' GROUP BY CustomerID HAVING SUM(Amount) > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dishes (dish_id INT, dish_name VARCHAR(50), total_cost DECIMAL(5,2)); CREATE TABLE Ingredients (ingredient_id INT, dish_id INT, quantity INT, cost DECIMAL(5,2)); INSERT INTO Dishes (dish_id, dish_name) VALUES (1, 'Quinoa Salad'), (2, 'Cheeseburger'), (3, 'Veggie Burger'); INSERT INTO Ingredients (ingredien... | What is the total cost of ingredients for the most popular dish? | SELECT D.dish_name, SUM(I.cost * I.quantity) as total_cost FROM Dishes D JOIN Ingredients I ON D.dish_id = I.dish_id GROUP BY D.dish_name ORDER BY total_cost DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_initiatives (initiative TEXT, start_date DATE, budget INTEGER); | What are the circular economy initiatives in the EU, including their start dates and budgets? | SELECT initiative, start_date, budget FROM circular_initiatives WHERE country = 'EU'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name TEXT, region TEXT, assets_value DECIMAL); INSERT INTO customers (customer_id, name, region, assets_value) VALUES (1, 'John Doe', 'Southeast', 50000.00), (2, 'Jane Smith', 'Southeast', 100000.00); | Find the customer with the highest assets value in the 'Southeast' region. | SELECT name FROM customers WHERE region = 'Southeast' AND assets_value = (SELECT MAX(assets_value) FROM customers WHERE region = 'Southeast'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), type VARCHAR(10), donation_amount DECIMAL(10, 2)); | What is the count of donors by type and their respective total donation amounts, in the 'Donors' and 'Donations' tables? | SELECT d.type, COUNT(DISTINCT d.id) as num_donors, SUM(Donations.amount) as total_donations FROM Donors d JOIN Donations ON Donors.id = Donations.donor_id GROUP BY d.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence_sources (source_id INT, source_name VARCHAR(255), threat_type VARCHAR(255), last_updated TIMESTAMP); | List all the unique sources of threat intelligence related to malware in the last year. | SELECT DISTINCT source_name FROM threat_intelligence_sources WHERE threat_type = 'Malware' AND last_updated >= NOW() - INTERVAL '1 year'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MaintenanceRequests (request_date DATE, request_type TEXT); INSERT INTO MaintenanceRequests (request_date, request_type) VALUES ('2022-01-01', 'military equipment'), ('2022-01-15', 'non-military equipment'), ('2022-01-30', 'military equipment'); | What is the count of military equipment maintenance requests in January 2022? | SELECT COUNT(*) FROM MaintenanceRequests WHERE request_type = 'military equipment' AND request_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (drug_id INT, name VARCHAR(255), approval_date DATE, company_id INT);CREATE TABLE clinical_trials (trial_id INT, drug_id INT, outcome VARCHAR(255), country VARCHAR(255)); | What is the number of clinical trials and their outcomes for each drug, including the drug name and its approval date, grouped by the country where the trials were conducted? | SELECT ct.country, d.name as drug_name, d.approval_date, COUNT(ct.trial_id) as num_trials, STRING_AGG(ct.outcome, ',') as outcomes FROM drugs d JOIN clinical_trials ct ON d.drug_id = ct.drug_id GROUP BY ct.country, d.name, d.approval_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai (id INT, model_name VARCHAR(255), country VARCHAR(255), confidence_score FLOAT); INSERT INTO explainable_ai (id, model_name, country, confidence_score) VALUES (1, 'ExplainModelA', 'Nigeria', 0.80), (2, 'ExplainModelB', 'Egypt', 0.85), (3, 'ExplainModelC', 'South Africa', 0.90); | What is the average confidence score for explainable AI models in Africa? | SELECT AVG(confidence_score) FROM explainable_ai WHERE country IN ('Nigeria', 'Egypt', 'South Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE law_firms (firm_id INT, name VARCHAR(50), state VARCHAR(20)); INSERT INTO law_firms (firm_id, name, state) VALUES (1, 'Law Firm A', 'NY'), (2, 'Law Firm B', 'CA'), (3, 'Law Firm C', 'NY'), (4, 'Law Firm D', 'IL'), (5, 'Law Firm E', 'CA'); CREATE TABLE cases (case_id INT, firm_id INT, case_status VARCHAR(10... | Display the total number of cases and the number of dismissed cases for each law firm, partitioned by state, ordered by the total number of cases? | SELECT firm_id, state, COUNT(*) as total_cases, SUM(CASE WHEN case_status = 'dismissed' THEN 1 ELSE 0 END) as dismissed_cases FROM cases JOIN law_firms ON cases.firm_id = law_firms.firm_id GROUP BY firm_id, state ORDER BY total_cases DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE actors (id INT, name VARCHAR(255)); CREATE TABLE roles (id INT, actor_id INT, media_id INT, media_type VARCHAR(10)); INSERT INTO actors VALUES (1, 'Actor A'); INSERT INTO actors VALUES (2, 'Actor B'); INSERT INTO roles VALUES (1, 1, 1, 'movie'); INSERT INTO roles VALUES (2, 1, 2, 'tv_show'); INSERT INTO ro... | List the names of the actors who have acted in both movies and TV shows. | SELECT a.name FROM actors a JOIN roles r ON a.id = r.actor_id JOIN (SELECT media_id FROM roles WHERE media_type = 'movie' INTERSECT SELECT media_id FROM roles WHERE media_type = 'tv_show') intersect_table ON r.media_id = intersect_table.media_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RId INT, Name VARCHAR(50)); CREATE TABLE EmergencyResponses (ResponseId INT, RId INT, Type VARCHAR(50), Cost INT); CREATE TABLE DisasterRecovery (RecoveryId INT, RId INT, Type VARCHAR(50), Cost INT); | What is the total number of emergency responses and disaster recovery efforts in each region, separated by type and sorted by total cost in descending order? | SELECT R.Name, ER.Type, SUM(ER.Cost) + SUM(DR.Cost) AS TotalCost FROM Regions R LEFT JOIN EmergencyResponses ER ON R.RId = ER.RId LEFT JOIN DisasterRecovery DR ON R.RId = DR.RId GROUP BY R.Name, ER.Type ORDER BY TotalCost DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), extraction_rate DECIMAL(5,2)); INSERT INTO mining_sites (id, name, location, extraction_rate) VALUES (1, 'Gold Mine', 'California', 12.5), (2, 'Silver Mine', 'Nevada', 15.2), (3, 'Copper Mine', 'Arizona', 18.9), (4, 'Iron Mine', 'Minnesota', 21.... | list the mines in the mining_sites table that have extraction rates within 10% of the average extraction rate | SELECT * FROM mining_sites WHERE extraction_rate BETWEEN (SELECT AVG(extraction_rate) * 0.9 FROM mining_sites) AND (SELECT AVG(extraction_rate) * 1.1 FROM mining_sites); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), avg_depth FLOAT); INSERT INTO marine_protected_areas (name, location, avg_depth) VALUES ('Area 1', 'Pacific Ocean', 123.4), ('Area 2', 'Atlantic Ocean', 567.8), ('Area 3', 'Indian Ocean', 345.6), ('Area 4', 'Arctic Ocean', 100.0); | What is the maximum depth of all marine protected areas in the Pacific Ocean? | SELECT MAX(avg_depth) FROM marine_protected_areas WHERE location = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE justice_programs (id INT, participant_name VARCHAR(255), program_type VARCHAR(255), gender VARCHAR(10), age INT, participation_date DATE); INSERT INTO justice_programs (id, participant_name, program_type, gender, age, participation_date) VALUES (1, 'John Doe', 'Restorative Circle', 'Male', 35, '2021-10-05'... | How many individuals have participated in restorative justice programs in the 'justice_programs' table, grouped by their gender? | SELECT program_type, gender, COUNT(*) FROM justice_programs WHERE program_type = 'Restorative Circle' GROUP BY program_type, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_complaints (complaint_id INT, complaint_type VARCHAR(20), country VARCHAR(20)); INSERT INTO customer_complaints (complaint_id, complaint_type, country) VALUES (1, 'network coverage', 'USA'), (2, 'billing', 'Canada'), (3, 'network coverage', 'USA'); | What is the total number of customer complaints related to network coverage in the United States? | SELECT COUNT(*) FROM customer_complaints WHERE complaint_type = 'network coverage' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (farmer_id INT, farmer_name VARCHAR(255)); INSERT INTO farmers (farmer_id, farmer_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE crops (crop_id INT, crop_name VARCHAR(255), farmer_id INT, production INT); INSERT INTO crops (crop_id, crop_name, farmer_id, production) VALUES (1, 'corn'... | What is the total production of 'corn' and 'wheat' by each farmer? | SELECT farmers.farmer_name, SUM(crop_production) as total_production FROM farmers INNER JOIN crops ON farmers.farmer_id = crops.farmer_id WHERE crops.crop_name IN ('corn', 'wheat') GROUP BY farmers.farmer_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE co_ownership (property_id INT, owner VARCHAR(255), percentage INT); INSERT INTO co_ownership (property_id, owner, percentage) VALUES (1, 'Alice', 50), (1, 'Bob', 50), (2, 'Carol', 75), (2, 'Dave', 25), (3, 'Eve', 60), (3, 'Frank', 40); | List the names and the total co-owner percentage for all properties in the 'co_ownership' table where the co-owner percentage is greater than 50. | SELECT owner, SUM(percentage) FROM co_ownership WHERE percentage > 50 GROUP BY owner; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours(id INT, hotel_id INT, month INT, views INT); CREATE TABLE hotels(id INT, name TEXT, country TEXT, pool BOOLEAN); | List the number of virtual tours engaged per month for 'hotels' in 'Oceania' with 'pool' facilities? | SELECT h.country, v.month, COUNT(v.views) FROM hotels h JOIN virtual_tours v ON h.id = v.hotel_id WHERE h.country = 'Oceania' AND h.pool = TRUE GROUP BY h.country, v.month; | gretelai_synthetic_text_to_sql |
CREATE TABLE refugees (refugee_id INT, name TEXT, region TEXT, country TEXT); INSERT INTO refugees (refugee_id, name, region, country) VALUES (1, 'John Doe', 'East', 'Kenya'), (2, 'Jane Smith', 'West', 'Ivory Coast'), (3, 'Ahmed Aliyev', 'North', 'Egypt'), (4, 'Svetlana Ivanova', 'South', 'South Africa'); | How many refugees are there in 'Africa' by region? | SELECT region, COUNT(*) FROM refugees WHERE country = 'Africa' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (name VARCHAR(50), country VARCHAR(50), section VARCHAR(50), newspaper VARCHAR(50)); INSERT INTO authors (name, country, section, newspaper) VALUES ('Smith', 'USA', 'politics', 'New York Times'), ('Doe', 'Canada', 'technology', 'The Globe and Mail'), ('Gupta', 'India', 'arts', 'The Hindu'), ('Johns... | What is the number of unique authors from India who have contributed to the 'arts' section of the newspaper 'The Hindu'? | SELECT COUNT(DISTINCT name) FROM authors WHERE country = 'India' AND section = 'arts' AND newspaper = 'The Hindu'; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty_hires (id INT, year INT, gender VARCHAR(10)); INSERT INTO faculty_hires (id, year, gender) VALUES (1, 2017, 'Female'), (2, 2018, 'Male'), (3, 2017, 'Male'), (4, 2018, 'Female'); | How many female and male faculty members were hired each year? | SELECT year, gender, COUNT(*) as num_hires FROM faculty_hires GROUP BY year, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyID INT, PolicyName VARCHAR(50), StartDate DATE); INSERT INTO Policy (PolicyID, PolicyName, StartDate) VALUES (1, 'Accessible Technology Initiative', '2020-01-01'); INSERT INTO Policy (PolicyID, PolicyName, StartDate) VALUES (2, 'Inclusive Hiring Policy', '2019-05-15'); INSERT INTO Policy (Pol... | Identify the policy advocacy initiatives that were implemented in the last 3 years, along with the number of students reached by each initiative. | SELECT PolicyName, COUNT(*) AS StudentsReached FROM Policy JOIN StudentPolicy SP ON Policy.PolicyID = SP.PolicyID WHERE StartDate >= DATEADD(YEAR, -3, GETDATE()) GROUP BY PolicyName; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_durations (user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO user_durations (user_id, workout_type, duration) VALUES (1, 'Running', 60), (1, 'Cycling', 90), (2, 'Running', 90), (2, 'Cycling', 75), (3, 'Running', 75), (3, 'Cycling', 60), (4, 'Running', 105), (4, 'Cycling', 90), (5, 'Run... | List the top 3 users with the highest total workout duration for each workout type. | SELECT user_id, workout_type, SUM(duration) AS total_duration FROM user_durations GROUP BY user_id, workout_type ORDER BY total_duration DESC, workout_type; SELECT user_id, workout_type, total_duration FROM (SELECT user_id, workout_type, SUM(duration) AS total_duration, ROW_NUMBER() OVER (PARTITION BY workout_type ORDE... | gretelai_synthetic_text_to_sql |
CREATE TABLE enrollment (id INT, student_type VARCHAR(10), school VARCHAR(10)); INSERT INTO enrollment (id, student_type, school) VALUES (1, 'domestic', 'Engineering'), (2, 'international', 'Arts'); | How many international students are enrolled in the graduate programs of the Arts school? | SELECT COUNT(*) FROM enrollment WHERE student_type = 'international' AND school = 'Arts'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_data (field VARCHAR(255), temperature FLOAT, date DATE); | Find the top 5 dates in the 'satellite_data' table with the highest temperature, for 'Field_3'. | SELECT date, temperature FROM (SELECT date, temperature, ROW_NUMBER() OVER (PARTITION BY field ORDER BY temperature DESC) as rn FROM satellite_data WHERE field = 'Field_3') t WHERE rn <= 5; | 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 (3, 'Copper Fields', 'Chile', 'copper', 8000, '2021-01-01'); | Calculate the total amount of copper mined globally in 2021 | SELECT SUM(quantity) FROM mining_operations WHERE material = 'copper' AND date = '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT PRIMARY KEY, name TEXT, continent TEXT, area FLOAT, population INT); | Insert a new record into the "countries" table for 'Bolivia' | INSERT INTO countries (id, name, continent, area, population) VALUES (123, 'Bolivia', 'South America', 1098581.0, 11673029); | gretelai_synthetic_text_to_sql |
CREATE TABLE game_servers (server_id INT, region VARCHAR(10), player_capacity INT); | Delete records in the game_servers table where the region is 'Europe' | DELETE FROM game_servers WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO unions (id, name, region) VALUES (1, 'Union A', 'Western'), (2, 'Union B', 'Western'), (3, 'Union C', 'Eastern'); CREATE TABLE injuries (id INT, union_id INT, injury_count INT); INSERT INTO injuries (id, union_id, injury_count) VALUES (1,... | What is the total number of workplace injuries reported by each union in the Western region? | SELECT u.name, SUM(i.injury_count) as total_injuries FROM unions u JOIN injuries i ON u.id = i.union_id WHERE u.region = 'Western' GROUP BY u.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (debris_id INT, name VARCHAR(255), type VARCHAR(255), altitude INT); INSERT INTO space_debris (debris_id, name, type, altitude) VALUES (1, 'Defunct Satellite', 'Satellite', 800); | What is the distribution of space debris by altitude? | SELECT type, AVG(altitude) as avg_altitude, MIN(altitude) as min_altitude, MAX(altitude) as max_altitude FROM space_debris GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations_1 (id INT, name VARCHAR); INSERT INTO organizations_1 (id, name) VALUES (1, 'Tech For Good Inc'), (2, 'AI Ethics Foundation'), (3, 'Accessible Tech Group'); CREATE TABLE projects_1 (id INT, organization_id INT, type VARCHAR); INSERT INTO projects_1 (id, organization_id, type) VALUES (1, 1, 'E... | What is the average number of ethical AI projects per organization? | SELECT AVG(projects_1.type = 'Ethical AI') FROM projects_1 INNER JOIN organizations_1 ON projects_1.organization_id = organizations_1.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Gallery VARCHAR(100), ArtworkID INT, Country VARCHAR(50), Year INT); | What are the galleries displaying modern art in Paris? | SELECT DISTINCT Exhibitions.Gallery FROM Exhibitions INNER JOIN Artworks ON Exhibitions.ArtworkID = Artworks.ArtworkID WHERE Artworks.Year >= 1900 AND Exhibitions.Country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, state VARCHAR(20)); INSERT INTO mobile_customers (customer_id, data_usage, state) VALUES (1, 5.5, 'NY'), (2, 4.2, 'CA'), (3, 6.1, 'TX'); | What is the average data usage for postpaid mobile customers by state? | SELECT state, AVG(data_usage) FROM mobile_customers WHERE type = 'postpaid' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id int, project_name varchar(255), start_date date, num_contractors int); INSERT INTO projects (project_id, project_name, start_date, num_contractors) VALUES (1, 'Aircraft Carrier Construction', '2021-01-01', 5); INSERT INTO projects (project_id, project_name, start_date, num_contractors)... | Identify defense projects that started after June 2020 and rank them by the number of contractors involved, in descending order. | SELECT project_name, num_contractors, ROW_NUMBER() OVER (ORDER BY num_contractors DESC) as project_rank FROM projects WHERE start_date > '2020-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (id INTEGER, application TEXT, output_quality TEXT, last_updated TIMESTAMP); | Count the number of records in the creative_ai table grouped by application and output_quality having output_quality as 'excellent' and ordered by count in descending order | SELECT application, output_quality, COUNT(*) as count FROM creative_ai GROUP BY application, output_quality HAVING output_quality = 'excellent' ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_preferences (customer_id INT, organic_ingredient_purchase BOOLEAN, local_brand_purchase BOOLEAN); INSERT INTO customer_preferences (customer_id, organic_ingredient_purchase, local_brand_purchase) VALUES (1, true, true), (2, false, false), (3, true, true), (4, true, true), (5, false, false), (6, tr... | Determine the percentage of customers who have purchased a product with 'organic' ingredients, from 'local' brands. | SELECT (COUNT(*) FILTER (WHERE organic_ingredient_purchase AND local_brand_purchase))::float / COUNT(*) as percentage FROM customer_preferences; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (year INT, sector VARCHAR(255), usage FLOAT); INSERT INTO water_usage (year, sector, usage) VALUES (2020, 'urban', 1200000), (2020, 'urban', 1300000), (2021, 'urban', 1400000), (2021, 'urban', 1500000); | Determine the percentage change in water usage in the 'urban' sector between 2020 and 2021. | SELECT (SUM(CASE WHEN year = 2021 THEN usage ELSE 0 END) - SUM(CASE WHEN year = 2020 THEN usage ELSE 0 END)) * 100.0 / SUM(CASE WHEN year = 2020 THEN usage ELSE 0 END) AS percentage_change FROM water_usage WHERE sector = 'urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, order_date DATETIME, customer_id INT); CREATE TABLE order_items (item_id INT, order_id INT, menu_id INT, quantity INT); INSERT INTO menus (menu_id, name, category, is_vegetarian, price, quantity) VALUES (1, 'Chicken Caesar Salad', 'Salad', FALSE, 12.99, 300), (2, 'Margherita Pizza', '... | Which menu items have not been ordered in the past month? | SELECT menu_id, name, quantity FROM menus LEFT JOIN (SELECT menu_id, SUM(quantity) as total_quantity FROM order_items JOIN orders ON order_items.order_id = orders.order_id WHERE DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) <= order_date GROUP BY menu_id) x ON menus.menu_id = x.menu_id WHERE x.menu_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_organization (donor_id INTEGER, org_id INTEGER); INSERT INTO donor_organization (donor_id, org_id) VALUES (1, 1), (2, 1), (1, 2), (3, 2), (4, 3); CREATE TABLE organizations (org_id INTEGER, org_name TEXT); INSERT INTO organizations (org_id, org_name) VALUES (1, 'Acme Impact'), (2, 'GreenTech Initiati... | How many unique donors are there in each organization's donor list? | SELECT org_name, COUNT(DISTINCT donor_id) as unique_donors FROM donor_organization JOIN organizations ON donor_organization.org_id = organizations.org_id GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE wellness_trends (id INT, name VARCHAR(50), description TEXT, popularity_score DECIMAL(3,2)); | Update the name for the wellness trend with ID 1 to 'Mindfulness' | UPDATE wellness_trends SET name = 'Mindfulness' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (id INT, name VARCHAR(50), manager VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Departments (id, name, manager) VALUES (2, 'IT', 'John Smith'); INSERT INTO Departments (id, name, manager) VALUES (3, 'Marketing', 'Jim Brown'); | How many departments have more than 10 employees? | SELECT COUNT(DISTINCT d.name) as department_count FROM Departments d JOIN Employees e ON d.name = e.department GROUP BY d.name HAVING COUNT(e.id) > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (ID INT, CaseNumber INT, DateOpened DATE, DateClosed DATE, Resolution VARCHAR(255)); INSERT INTO Cases (ID, CaseNumber, DateOpened, DateClosed, Resolution) VALUES (1, 12345, '2022-01-01', '2022-03-15', 'Community Service'), (2, 67890, '2022-02-15', '2022-04-30', 'Fine'), (3, 111213, '2022-03-28', NUL... | What is the total number of cases that have been reopened after closure in the last 2 years, by resolution type? | SELECT Resolution, COUNT(*) as ReopenedCases FROM Cases WHERE DateOpened < DateClosed AND DateClosed >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY Resolution; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_price DECIMAL(5,2), product_category VARCHAR(20)); | Rank cosmetic products by sales in the 'sales' table, partitioned by product category. | SELECT product_id, sale_price, ROW_NUMBER() OVER (PARTITION BY product_category ORDER BY sale_price DESC) as rank FROM sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (advisory_id INT, country TEXT, year INT, reason TEXT, continent TEXT); INSERT INTO travel_advisories (advisory_id, country, year, reason, continent) VALUES (1, 'Canada', 2021, 'Health', 'North America'), (2, 'Mexico', 2021, 'Political', 'North America'), (3, 'USA', 2021, 'Safety', 'North... | What is the total number of travel advisories issued for South America in 2022? | SELECT continent, year, COUNT(*) FROM travel_advisories WHERE year = 2022 AND continent = 'South America' GROUP BY continent, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Instagram(id INT, user_id INT, content TEXT, deleted BOOLEAN); CREATE TABLE TikTok(id INT, user_id INT, content TEXT, deleted BOOLEAN); | What are the total number of posts and users from the 'Instagram' and 'TikTok' platforms, excluding deleted users? | SELECT COUNT(DISTINCT user_id) AS total_users, COUNT(*) AS total_posts FROM Instagram WHERE deleted = FALSE UNION ALL SELECT COUNT(DISTINCT user_id) AS total_users, COUNT(*) AS total_posts FROM TikTok WHERE deleted = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonorID int, Program varchar(50), DonationAmount numeric(10,2)); INSERT INTO Donations (DonorID, Program, DonationAmount) VALUES (1, 'ProgramA', 500.00), (2, 'ProgramB', 350.00); | List the top 3 donors by total donation to ProgramA. | SELECT DonorID, SUM(DonationAmount) AS TotalDonated FROM Donations WHERE Program = 'ProgramA' GROUP BY DonorID ORDER BY TotalDonated DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE mars_rovers (id INT, name VARCHAR(255), type VARCHAR(255), operational BOOLEAN, launch_country VARCHAR(255), launch_date DATE); INSERT INTO mars_rovers (id, name, type, operational, launch_country, launch_date) VALUES (1, 'Curiosity Rover', 'Rover', true, 'USA', '2012-11-26'); INSERT INTO mars_rovers (id, ... | List the names of all countries that have sent rovers to Mars and the launch dates of their rovers. | SELECT launch_country, launch_date FROM mars_rovers; | gretelai_synthetic_text_to_sql |
CREATE TABLE CosmeticsSales (product_name TEXT, product_type TEXT, sale_location TEXT); INSERT INTO CosmeticsSales (product_name, product_type, sale_location) VALUES ('Vegan Lipstick', 'Lipstick', 'United Kingdom'), ('Vegan Mascara', 'Eyeshadow', 'United Kingdom'), ('Vegan Foundation', 'Foundation', 'United Kingdom'), ... | What is the number of vegan cosmetic products sold in the United Kingdom, excluding nail polish and eyeshadow? | SELECT COUNT(*) FROM CosmeticsSales WHERE product_type NOT IN ('Nail Polish', 'Eyeshadow') AND sale_location = 'United Kingdom' AND product_name LIKE '%vegan%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (id INT, name TEXT, country TEXT, provider_community_owned BOOLEAN, revenue INT); INSERT INTO virtual_tours (id, name, country, provider_community_owned, revenue) VALUES (1, 'Venice Virtual Tour', 'Italy', true, 800), (2, 'Florence Virtual Tour', 'Italy', false, 900), (3, 'Rome Virtual Tour',... | What is the total revenue for virtual tours in Italy offered by providers owned by local communities? | SELECT SUM(revenue) FROM virtual_tours WHERE country = 'Italy' AND provider_community_owned = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityPolicing (id INT, neighborhood VARCHAR(20), event_date DATE); | What is the percentage of community policing events held in the "low-income" neighborhoods in the last year? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM CommunityPolicing WHERE event_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)) as percentage FROM CommunityPolicing WHERE neighborhood IN ('low-income1', 'low-income2', 'low-income3') AND event_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | 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.