context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE animal_populations (id INT, species VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO animal_populations (id, species, population, region) VALUES (1, 'Giraffe', 1000, 'Africa'), (2, 'Elephant', 500, 'Asia'), (3, 'Lion', 200, 'Africa'), (4, 'Rhinoceros', 100, 'Asia'), (5, 'Hippopotamus', 300, 'A... | Determine the total number of animals in each region | SELECT region, SUM(population) as total_animals FROM animal_populations GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (drug VARCHAR(255), quarter INT, year INT, sales FLOAT); INSERT INTO sales_data (drug, quarter, year, sales) VALUES ('DrugA', 1, 2023, 12000), ('DrugA', 2, 2023, 15000), ('DrugB', 1, 2023, 8000); | What is the sales figure for DrugA in Q1 2023? | SELECT sales FROM sales_data WHERE drug = 'DrugA' AND quarter = 1 AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE volunteers (id INT, name VARCHAR(50), program_id INT); INSERT INTO programs (id, name, location) VALUES (1, 'Education', 'California'), (2, 'Environment', 'Oregon'), (3, 'Arts', 'Washington'); INSERT INTO volunteers (id, name, program_... | Which programs have more than 5 volunteers in the Western region? | SELECT p.name FROM programs p INNER JOIN volunteers v ON p.id = v.program_id WHERE p.location IN ('California', 'Oregon', 'Washington') GROUP BY p.name HAVING COUNT(v.id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Founders (id INT, name TEXT, ethnicity TEXT); INSERT INTO Founders (id, name, ethnicity) VALUES (1, 'Charity Inc', 'Latinx'); INSERT INTO Founders (id, name, ethnicity) VALUES (2, 'Diverse Enterprises', 'Black'); INSERT INTO Founders (id, name, ethnicity) VALUES (3, 'Eco Solutions', 'Asian'); CREATE TABLE ... | Find the number of unique investors for companies founded by Latinx or Black individuals? | SELECT COUNT(DISTINCT Investments.investor_id) FROM Founders JOIN Investments ON Founders.id = Investments.company_id WHERE Founders.ethnicity IN ('Latinx', 'Black'); | gretelai_synthetic_text_to_sql |
CREATE TABLE process (process_id INT, process_name VARCHAR(50), year INT); CREATE TABLE co2 (co2_id INT, process_id INT, co2_amount DECIMAL(5,2)); INSERT INTO process (process_id, process_name, year) VALUES (1, 'Process 1', 2021), (2, 'Process 2', 2021), (3, 'Process 1', 2022), (4, 'Process 2', 2022); INSERT INTO co2 (... | What is the change in CO2 emissions per manufacturing process between 2021 and 2022? | SELECT a.process_name, (b.co2_amount - a.co2_amount) AS co2_change FROM (SELECT process_name, co2_amount, year FROM process JOIN co2 ON process.process_id = co2.process_id WHERE year = 2021) AS a JOIN (SELECT process_name, co2_amount, year FROM process JOIN co2 ON process.process_id = co2.process_id WHERE year = 2022) ... | gretelai_synthetic_text_to_sql |
CREATE TABLE Claim (ClaimId INT, PolicyId INT, ClaimDate DATE); CREATE TABLE Policy (PolicyId INT, PolicyType VARCHAR(50), IssueDate DATE, ExpirationDate DATE, Region VARCHAR(50)); | Show the average policy duration and number of claims, by policy type, for policyholders in Florida. | SELECT Policy.PolicyType, AVG(DATEDIFF(day, IssueDate, ExpirationDate)) as AveragePolicyDuration, COUNT(Claim.ClaimId) as NumberOfClaims FROM Policy LEFT JOIN Claim ON Policy.PolicyId = Claim.PolicyId WHERE Policy.Region = 'Florida' GROUP BY Policy.PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'UK'), (4, 'Australia'); CREATE TABLE conferences (id INT, country_id INT, name TEXT, topic TEXT); INSERT INTO conferences (id, country_id, name, topic) VALUES (1, 1, 'Conf1', 'AI Safety'), (2, 1, 'Conf2',... | Display the names of all countries that have held AI safety conferences and the number of such conferences. | SELECT countries.name, COUNT(conferences.id) as conferences_count FROM countries INNER JOIN conferences ON countries.id = conferences.country_id WHERE conferences.topic = 'AI Safety' GROUP BY countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE total_donations (sector VARCHAR(50), total_donations DECIMAL(10,2)); INSERT INTO total_donations (sector, total_donations) VALUES ('Animal Welfare', 25000.00), ('Global Health', 40000.00), ('Education', 30000.00), ('Environment', 35000.00), ('Human Rights', 45000.00); | What is the difference in total donations between the animal welfare and global health sectors? | SELECT (a.total_donations - b.total_donations) AS difference FROM total_donations a, total_donations b WHERE a.sector = 'Global Health' AND b.sector = 'Animal Welfare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 72.5); | What is the average ESG score of companies in the technology sector? | SELECT AVG(ESG_score) FROM companies WHERE sector = 'technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (id INT, country VARCHAR(50), is_eco_certified BOOLEAN); INSERT INTO accommodations (id, country, is_eco_certified) VALUES (1, 'France', TRUE), (2, 'Italy', FALSE), (3, 'Japan', TRUE), (4, 'Germany', TRUE), (5, 'Spain', TRUE), (6, 'Canada', FALSE); | Find the number of eco-certified accommodations in each country | SELECT country, COUNT(*) FROM accommodations WHERE is_eco_certified = TRUE GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE flight_safety (accident_id INT, airline TEXT, accident_date DATE); INSERT INTO flight_safety (accident_id, airline, accident_date) VALUES (1, 'Delta Airlines', '2019-01-05'), (2, 'Delta Airlines', '2015-07-31'), (3, 'American Airlines', '2018-04-17'), (4, 'American Airlines', '2013-07-06'), (5, 'Lufthansa'... | How many flight accidents has each airline had in the last 10 years? | SELECT airline, COUNT(*) as accident_count FROM flight_safety WHERE accident_date >= DATEADD(year, -10, GETDATE()) GROUP BY airline; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA humanitarian_assistance;CREATE TABLE un_assistance (assistance_amount INT, year INT, region VARCHAR(50));INSERT INTO un_assistance (assistance_amount, year, region) VALUES (500000, 2015, 'Middle East'), (700000, 2016, 'Middle East'), (900000, 2017, 'Middle East'), (600000, 2018, 'Middle East'), (800000, 2... | What is the minimum amount of humanitarian assistance provided by the UN in a single year for the Middle East? | SELECT MIN(assistance_amount) FROM humanitarian_assistance.un_assistance WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech;CREATE TABLE biotech.startups (id INT, name VARCHAR(50), country VARCHAR(50), total_funding DECIMAL(10,2));INSERT INTO biotech.startups (id, name, country, total_funding) VALUES (1, 'StartupA', 'USA', 15000000.00), (2, 'StartupB', 'USA', 22000000.00), (3, 'StartupC', 'Canada', 110000... | What is the total funding raised by biotech startups in the US? | SELECT SUM(total_funding) FROM biotech.startups WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE world_heritage_sites (country VARCHAR(20), site VARCHAR(50), location VARCHAR(20), visitors INT); INSERT INTO world_heritage_sites (country, site, location, visitors) VALUES ('Brazil', 'Rio de Janeiro', 'urban', 2000000), ('Peru', 'Machu Picchu', 'rural', 1500000), ('Brazil', 'Rio de Janeiro', 'urban', 220... | What is the percentage of tourists who visited South American world heritage sites located in urban areas? | SELECT country, (SUM(CASE WHEN location = 'urban' THEN visitors ELSE 0 END) * 100.0 / SUM(visitors)) as urban_percentage FROM world_heritage_sites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE aid_distribution_s_america (family_id INT, region VARCHAR(20), disaster_type VARCHAR(20)); INSERT INTO aid_distribution_s_america (family_id, region, disaster_type) VALUES (1, 'South America', 'Flood'), (2, 'South America', 'Earthquake'), (3, 'South America', 'Flood'), (4, 'South America', 'Tsunami'), (5, ... | What is the number of families who received humanitarian aid in South America, grouped by disaster type, ordered by the number of families? | SELECT disaster_type, COUNT(family_id) as num_families FROM aid_distribution_s_america JOIN disaster_type ON aid_distribution_s_america.disaster_type = disaster_type.disaster_type GROUP BY disaster_type ORDER BY num_families; | gretelai_synthetic_text_to_sql |
CREATE TABLE machines (id INT PRIMARY KEY, mine_site_id INT, machine_name VARCHAR(255)); CREATE TABLE mine_sites (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255)); | Count the number of mining sites in Russia and Peru with more than 20 machines each. | SELECT COUNT(DISTINCT ms.id) as num_sites FROM mine_sites ms JOIN machines m ON ms.id = m.mine_site_id WHERE ms.location IN ('Russia', 'Peru') GROUP BY ms.location HAVING COUNT(m.id) > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(255)); INSERT INTO drugs (drug_id, drug_name) VALUES (1, 'DrugA'), (2, 'DrugB'); CREATE TABLE sales (sale_id INT, drug_id INT, region VARCHAR(255), sales_amount DECIMAL(10, 2), quarter INT, year INT); INSERT INTO sales (sale_id, drug_id, region, sales_amount, quarter, ... | What were the total sales of each drug in the Southeast region in Q2 2021? | SELECT d.drug_name, SUM(s.sales_amount) as total_sales FROM drugs d JOIN sales s ON d.drug_id = s.drug_id WHERE s.region = 'Southeast' AND s.quarter = 2 AND s.year = 2021 GROUP BY d.drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT, manufacturing_location VARCHAR(255)); | Insert new records for 2 chemical compounds, 'Styrene', 'Ethylene Glycol', with safety_ratings 6, 7 respectively, and manufacturing_location 'USA' for both | INSERT INTO chemical_compounds (name, safety_rating, manufacturing_location) VALUES ('Styrene', 6, 'USA'), ('Ethylene Glycol', 7, 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE PatientTreatmentOutcomes (PatientID INT, Condition VARCHAR(50), Treatment VARCHAR(50), Success BOOLEAN); | What is the success rate of the DBT treatment approach for patients with borderline personality disorder? | SELECT 100.0 * SUM(Success) / COUNT(*) AS SuccessRate FROM PatientTreatmentOutcomes WHERE Condition = 'borderline personality disorder' AND Treatment = 'DBT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AltruisticBank (id INT, loan_type VARCHAR(20), loan_amount INT, issue_date DATE); INSERT INTO AltruisticBank (id, loan_type, loan_amount, issue_date) VALUES (1, 'Socially Responsible', 7000, '2021-01-05'); | What is the total amount of socially responsible loans issued by AltruisticBank in Q1 2021? | SELECT SUM(loan_amount) FROM AltruisticBank WHERE loan_type = 'Socially Responsible' AND QUARTER(issue_date) = 1 AND YEAR(issue_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE plants (plant_id INT, plant_name VARCHAR(50), city VARCHAR(50), production_output INT); INSERT INTO plants (plant_id, plant_name, city, production_output) VALUES (1, 'PlantA', 'CityA', 500), (2, 'PlantB', 'CityB', 700), (3, 'PlantC', 'CityC', 600); | What is the total production output of the plant located in 'CityA'? | SELECT SUM(production_output) FROM plants WHERE city = 'CityA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'Barcelona'), (2, 'Berlin'), (3, 'Vienna'); CREATE TABLE properties (id INT, city_id INT, size INT, coowners INT); INSERT INTO properties (id, city_id, size, coowners) VALUES (1, 1, 800, 2), (2, 1, 1200, 1), (3, 2, 1000, 3), (4, 2... | What is the ratio of co-owned properties to total properties in each city? | SELECT city_id, AVG(CASE WHEN coowners > 1 THEN 1.0 ELSE 0.0 END) / COUNT(*) as coowners_ratio FROM properties GROUP BY city_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE UrbanPolicies (id INT, policy_id INT, city VARCHAR(50), state VARCHAR(2), policy_text TEXT); CREATE VIEW InclusivePolicies AS SELECT policy_id, city, state FROM UrbanPolicies WHERE policy_text LIKE '%inclusive%' AND policy_text LIKE '%affordable%'; | Delete records for properties with inclusive housing policies that do not have 'affordable' in the policy_text. | DELETE FROM InclusivePolicies WHERE policy_id NOT IN (SELECT policy_id FROM UrbanPolicies WHERE policy_text LIKE '%affordable%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (id INT, location TEXT, type TEXT, date DATE); INSERT INTO violations (id, location, type, date) VALUES (1, 'California', 'wage theft', '2021-01-01'), (2, 'New York', 'unsafe working conditions', '2021-02-01'); | How many labor rights violations were reported in 'California' and 'New York'? | SELECT COUNT(*) FROM violations WHERE location IN ('California', 'New York'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), gender VARCHAR(10), program VARCHAR(50), publications INT); INSERT INTO students (id, name, gender, program, publications) VALUES (1, 'Charlie', 'Non-binary', 'Arts', 2), (2, 'Dana', 'Female', 'Physics', 5), (3, 'Eli', 'Male', 'Engineering', 0), (4, 'Fatima', 'Female', '... | What is the maximum number of publications for graduate students in the Physics program? | SELECT MAX(s.publications) FROM students s WHERE s.program = 'Physics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ferries (ferry_id INT, region VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO Ferries (ferry_id, region, fare) VALUES (701, 'Oceanview', 6.00), (702, 'Oceanview', 7.00), (703, 'Oceanview', 8.00); | What is the average fare for ferries in the 'Oceanview' region? | SELECT AVG(fare) FROM Ferries WHERE region = 'Oceanview'; | gretelai_synthetic_text_to_sql |
CREATE TABLE developers (developer_id INT, name VARCHAR(100), contributions INT); INSERT INTO developers (developer_id, name, contributions) VALUES (1, 'Developer1', 500), (2, 'Developer2', 350), (3, 'Developer3', 250), (4, 'Developer4', 175), (5, 'Developer5', 100); | Who are the developers who have contributed to the Ethereum codebase? | SELECT name FROM developers ORDER BY contributions DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryName TEXT);CREATE TABLE VirtualTours (CountryName TEXT, TourID INTEGER); INSERT INTO Countries ('CountryName') VALUES ('Italy'), ('France'), ('Spain'), ('Japan'), ('Brazil'); INSERT INTO VirtualTours (CountryName, TourID) VALUES ('Italy', 1001), ('Italy', 1002), ('France', 2001), ('France... | What are the top 3 countries with the most virtual tours? | SELECT CountryName, COUNT(TourID) as NumTours FROM VirtualTours GROUP BY CountryName ORDER BY NumTours DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255), country VARCHAR(255), year_of_birth INT); CREATE TABLE artworks (id INT, artist_id INT, title VARCHAR(255), year_of_creation INT); | How many artworks have been created by artists from each country, grouped by country? | SELECT country, COUNT(*) FROM artists a JOIN artworks aw ON a.id = aw.artist_id GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR, age INT, donation_amount DECIMAL, donation_date DATE); | Find total donation amount and number of donors from 'young' donors in 2021. | SELECT SUM(donation_amount) as total_donation_amount, COUNT(DISTINCT donors.id) as num_donors FROM donors | gretelai_synthetic_text_to_sql |
CREATE TABLE aquaculture_facilities (id INT, facility_name VARCHAR(50), location VARCHAR(50), facility_type VARCHAR(50)); INSERT INTO aquaculture_facilities (id, facility_name, location, facility_type) VALUES (1, 'Facility A', 'Asia', 'Fish Farm'), (2, 'Facility B', 'Europe', 'Hatchery'), (3, 'Facility C', 'Asia', 'Hat... | What is the total number of aquaculture facilities in Asia? | SELECT COUNT(*) FROM aquaculture_facilities WHERE location = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE producers (id INT PRIMARY KEY, name TEXT, region TEXT, product TEXT, quantity INT, price FLOAT); INSERT INTO producers (id, name, region, product, quantity, price) VALUES (1, 'South Growers', 'South', 'Cannabis Oil', 800, 20), (2, 'Southern Harvest', 'South', 'Cannabis Capsules', 500, 25); CREATE TABLE dis... | Calculate the total revenue for each producer in the South, considering their quantity, price, and the corresponding dispensary's sales, grouped by product type. | SELECT producers.product, dispensaries.name, SUM(producers.quantity * dispensaries.sales * producers.price) as total_revenue FROM producers INNER JOIN dispensaries ON producers.region = dispensaries.region GROUP BY producers.product, dispensaries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEngagements (id INT, event VARCHAR(255), budget DECIMAL(10, 2), heritage_site VARCHAR(255)); INSERT INTO CommunityEngagements (id, event, budget, heritage_site) VALUES (1, 'Music Festival', 15000, 'Petra'), (2, 'Art Exhibition', 12000, 'Petra'), (3, 'Dance Competition', 8000, 'Petra'); | What is the total budget for each community engagement event at the specified heritage site? | SELECT event, SUM(budget) as total_budget FROM CommunityEngagements WHERE heritage_site = 'Petra' GROUP BY event; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name VARCHAR(255)); INSERT INTO organizations (id, name) VALUES (1, 'WHO'), (2, 'MSF'), (3, 'IFRC'); CREATE TABLE medical_supplies (id INT, organization_id INT, medical_supply VARCHAR(255), quantity INT, distribution_date DATE, location VARCHAR(255)); INSERT INTO medical_supplies (id... | Which organizations provided medical supplies in 'Asia' in 2019? | SELECT DISTINCT organization_id FROM medical_supplies WHERE YEAR(distribution_date) = 2019 AND location = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (metric_id INT, metric_date DATE, region VARCHAR(255)); INSERT INTO threat_intelligence (metric_id, metric_date, region) VALUES (1, '2022-01-01', 'Middle East'), (2, '2021-06-15', 'Europe'), (3, '2022-02-14', 'Middle East'); | Count the number of threat intelligence metrics reported in the Middle East in the last year. | SELECT COUNT(*) FROM threat_intelligence WHERE region = 'Middle East' AND metric_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (policy_number INT, policyholder_name VARCHAR(50), car_make VARCHAR(20), policy_effective_date DATE); | List the policy numbers, policyholder names, and car makes for policyholders who have a policy effective date on or after '2022-01-01' | SELECT policy_number, policyholder_name, car_make FROM policyholders WHERE policy_effective_date >= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_streams (user_id INT, song_id INT); CREATE TABLE songs (song_id INT, genre VARCHAR(10)); | Find the total number of unique users who have streamed any hip-hop or R&B songs, without listing users more than once. | SELECT COUNT(DISTINCT user_id) FROM user_streams JOIN songs ON user_streams.song_id = songs.song_id WHERE genre IN ('hip-hop', 'R&B'); | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_process (id INT PRIMARY KEY, process VARCHAR(50), emission_rating INT); INSERT INTO manufacturing_process (id, process, emission_rating) VALUES (1, 'Dyeing', 50), (2, 'Cutting', 40); | Insert new record into 'manufacturing_process' table for 'leather_tanning' with 'emission_rating' of 60 | INSERT INTO manufacturing_process (process, emission_rating) VALUES ('leather_tanning', 60); | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (hotel_id INT, revenue_source VARCHAR(50), revenue INT); INSERT INTO revenue (hotel_id, revenue_source, revenue) VALUES (1, 'Room revenue', 10000), (1, 'Food and beverage', 5000), (1, 'Other revenue', 2000); | What is the total revenue of 'Hotel Ritz' from all sources? | SELECT SUM(revenue) FROM revenue WHERE hotel_id = (SELECT hotel_id FROM hotels WHERE name = 'Hotel Ritz'); | gretelai_synthetic_text_to_sql |
CREATE TABLE boeing_defense_projects (project_id INT, project_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE raytheon_defense_projects (project_id INT, project_name VARCHAR(50), country VARCHAR(50)); | What is the total number of defense projects with Boeing and Raytheon combined? | SELECT COUNT(*) FROM (SELECT * FROM boeing_defense_projects UNION ALL SELECT * FROM raytheon_defense_projects) AS combined_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE agri_projects (project_id INT, district_id INT, budget FLOAT, project_category VARCHAR(50)); | Insert a new agricultural innovation project with an ID of 6, a budget of 100000, and a project_category of 'Precision Agriculture' in district 13. | INSERT INTO agri_projects (project_id, district_id, budget, project_category) VALUES (6, 13, 100000, 'Precision Agriculture'); | gretelai_synthetic_text_to_sql |
CREATE TABLE efforts(id INT, name TEXT, country TEXT, start_date DATE, end_date DATE, success BOOLEAN); INSERT INTO efforts(id, name, country, start_date, end_date, success) VALUES (1, 'Small Business Loans', 'Zambia', '2020-01-01', '2021-12-31', true), (2, 'Vocational Training', 'Zambia', '2019-01-01', '2020-12-31', f... | What is the success rate of economic diversification efforts in Zambia in the last 2 years? | SELECT COUNT(*)/COUNT(DISTINCT id) FROM efforts WHERE country = 'Zambia' AND start_date >= DATE('2020-01-01') AND end_date <= DATE('2021-12-31') AND success = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE disasters (year INT, continent TEXT, disaster TEXT); INSERT INTO disasters (year, continent, disaster) VALUES (2005, 'Oceania', 'Cyclone'), (2006, 'Oceania', 'Flood'), (2007, 'Oceania', 'Drought'), (2008, 'Oceania', 'Heatwave'), (2009, 'Oceania', 'Tornado'), (2010, 'Oceania', 'Volcanic Eruption'), (2011, '... | What is the number of climate change related disasters in Oceania from 2005 to 2015? | SELECT continent, COUNT(DISTINCT year) FROM disasters WHERE continent = 'Oceania' AND year BETWEEN 2005 AND 2015 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Healthcare'), (3, 'Environment'); CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, Pro... | List all the programs that have been funded by at least one donation, along with their total funding amounts and the number of individual donors. | SELECT Programs.ProgramName, SUM(Donations.DonationAmount) AS TotalFunding, COUNT(DISTINCT Donors.DonorID) AS DonorCount FROM Programs INNER JOIN Donations ON Programs.ProgramID = Donations.ProgramID INNER JOIN Donors ON Donations.DonorID = Donors.DonorID GROUP BY Programs.ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE exploited_vulnerabilities (vulnerability VARCHAR(50), exploit_count INT, exploit_date DATE); INSERT INTO exploited_vulnerabilities (vulnerability, exploit_count, exploit_date) VALUES ('Vulnerability A', 20, '2023-01-01'), ('Vulnerability B', 15, '2023-01-02'), ('Vulnerability C', 12, '2023-01-03'), ('Vulne... | List all the unique vulnerabilities that have been exploited in the last 30 days, along with the number of times each vulnerability has been exploited. | SELECT vulnerability, SUM(exploit_count) AS total_exploits FROM exploited_vulnerabilities WHERE exploit_date >= DATEADD(day, -30, GETDATE()) GROUP BY vulnerability; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO Countries (id, name, region) VALUES (1, 'Indonesia', 'Southeast Asia'), (2, 'Philippines', 'Southeast Asia'), (3, 'Malaysia', 'Southeast Asia'), (4, 'Myanmar', 'Southeast Asia'), (5, 'Thailand', 'Southeast Asia'); CREATE TABLE Endangered... | What is the average number of endangered languages in Southeast Asian countries? | SELECT AVG(e.count) as avg_endangered_languages FROM (SELECT COUNT(*) as count FROM EndangeredLanguages WHERE country_id = Countries.id GROUP BY country_id) e JOIN Countries ON e.country_id = Countries.id WHERE Countries.region = 'Southeast Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (restaurant VARCHAR(255), item VARCHAR(255), cost FLOAT); INSERT INTO menus (restaurant, item, cost) VALUES ('Burger Spot', 'beef burger', 8.5), ('Gourmet Delight', 'beef burger', 12.0); | What is the average cost of a 'beef burger' at all restaurants? | SELECT AVG(cost) FROM menus WHERE item = 'beef burger'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenues (restaurant VARCHAR(255), year INT, revenue INT); INSERT INTO revenues (restaurant, year, revenue) VALUES ('Tasty Bites', 2021, 350000); | What is the total revenue for 'Tasty Bites' in 2021? | SELECT revenue FROM revenues WHERE restaurant = 'Tasty Bites' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(50)); INSERT INTO countries VALUES ('US', 'United States'), ('CA', 'Canada'), ('MX', 'Mexico'); CREATE TABLE freight (id INT, country_code CHAR(2), weight INT, pallets INT); INSERT INTO freight VALUES (1, 'US', 500, 10), (2, 'CA', 400, 8), (3, 'MX', 600... | Show the number of pallets and total weight of freight for each country. | SELECT c.country_name, SUM(f.weight) as total_weight, SUM(f.pallets) as total_pallets FROM freight f INNER JOIN countries c ON f.country_code = c.country_code GROUP BY c.country_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (ConcertID INT PRIMARY KEY, ConcertName VARCHAR(100), Location VARCHAR(100), Genre VARCHAR(50), TicketsSold INT, TicketPrice DECIMAL(5,2), SaleDate DATE); INSERT INTO Concerts (ConcertID, ConcertName, Location, Genre, TicketsSold, TicketPrice, SaleDate) VALUES (1, 'Concert 1', 'USA', 'Pop', 500, 5... | What is the total number of tickets sold for pop concerts in North America since 2021? | SELECT SUM(TicketsSold) FROM Concerts WHERE Genre = 'Pop' AND Location LIKE 'North%' AND YEAR(SaleDate) >= 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Country VARCHAR(255)); INSERT INTO Employees (EmployeeID, Country) VALUES (1, 'USA'); INSERT INTO Employees (EmployeeID, Country) VALUES (2, 'Canada'); INSERT INTO Employees (EmployeeID, Country) VALUES (3, 'Mexico'); | What is the total number of employees from each country, and the percentage of the total workforce they represent? | SELECT E.Country, COUNT(E.EmployeeID) AS Num_Employees, COUNT(E.EmployeeID) * 100.0 / (SELECT COUNT(*) FROM Employees) AS Pct_Total_Workforce FROM Employees E GROUP BY E.Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE immunization_coverage (id INT PRIMARY KEY, country VARCHAR(50), coverage FLOAT); | Insert data into the 'immunization_coverage' table | INSERT INTO immunization_coverage (id, country, coverage) VALUES (1, 'Nepal', 85.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, sale_date DATE, vehicle_type VARCHAR(20)); | How many electric vehicles were sold per month in the 'sales' table? | SELECT DATE_TRUNC('month', sale_date) AS month, COUNT(*) FILTER (WHERE vehicle_type = 'Electric') AS electric_sales FROM sales GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (category TEXT, donation_date DATE, donation_amount FLOAT); INSERT INTO donations (category, donation_date, donation_amount) VALUES ('effective_altruism', '2020-01-01', 2000.00), ('impact_investing', '2019-12-31', 3000.00); | What is the total donation amount for the 'effective_altruism' category in the year 2020? | SELECT SUM(donation_amount) FROM donations WHERE category = 'effective_altruism' AND YEAR(donation_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, title TEXT, topic TEXT); INSERT INTO articles (article_id, title, topic) VALUES (1, 'Immigration Reform in the US', 'immigration'), (2, 'European Immigration Trends', 'immigration'); CREATE TABLE user_comments (comment_id INT, article_id INT, user_id INT, comment TEXT, word_count... | What is the total number of user comments related to articles about immigration, having more than 10 words? | SELECT SUM(word_count) FROM user_comments JOIN articles ON user_comments.article_id = articles.article_id WHERE articles.topic = 'immigration' AND word_count > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_streams (stream_id INT, country VARCHAR(255), user_id INT); CREATE TABLE user (user_id INT, user_name VARCHAR(255)); | What is the total number of unique users who have streamed music in each country? | SELECT country, COUNT(DISTINCT user_id) FROM country_streams GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(50), year INT, soldiers INT); | List countries with peacekeeping operations exceeding 500 soldiers in 2019 | SELECT country FROM peacekeeping_operations WHERE year = 2019 AND soldiers > 500 GROUP BY country HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cnn (article_id INT, title VARCHAR(255), publish_date DATE, author VARCHAR(255), category VARCHAR(255)); INSERT INTO cnn (article_id, title, publish_date, author, category) VALUES (1, 'Article 13', '2022-01-13', 'Author 13', 'world'); CREATE TABLE world (article_id INT, title VARCHAR(255), publish_date DAT... | What is the total number of articles published by 'CNN' in the 'world' category? | SELECT COUNT(*) FROM cnn WHERE category = 'world'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AlgorithmicFairnessTeam (TeamMemberID INT PRIMARY KEY, Name VARCHAR(30), Role VARCHAR(30)); INSERT INTO AlgorithmicFairnessTeam (TeamMemberID, Name, Role) VALUES (1, 'Alice', 'Data Scientist'), (2, 'Bob', 'Team Lead'); | Identify Algorithmic Fairness team members and their respective roles. | SELECT Name, Role FROM AlgorithmicFairnessTeam; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat (id INT, location TEXT, size FLOAT); | What is the average size of habitats (in square kilometers) for each continent? | SELECT h.location, AVG(size) FROM habitat h GROUP BY h.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE branches (branch_id INT, branch_country VARCHAR(50)); INSERT INTO branches (branch_id, branch_country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Australia'), (4, 'Japan'); CREATE TABLE customers (customer_id INT, branch_id INT, account_opening_date DATE); INSERT INTO customers (customer_id, branch_id, account... | How many customers have opened new accounts in the last month in the Asia-Pacific region? | SELECT COUNT(*) FROM customers WHERE account_opening_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE() AND branch_id IN (SELECT branch_id FROM branches WHERE branch_country LIKE 'Asia%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT, name TEXT, location TEXT); INSERT INTO manufacturers (id, name, location) VALUES (1, 'Manufacturer1', 'USA'), (2, 'Manufacturer2', 'USA'); CREATE TABLE military_vehicles (id INT, model TEXT, manufacturer_id INT, year INT, quantity INT); INSERT INTO military_vehicles (id, model, manuf... | What is the total number of military vehicles produced by domestic manufacturers in 2020? | SELECT SUM(quantity) FROM military_vehicles JOIN manufacturers ON military_vehicles.manufacturer_id = manufacturers.id WHERE manufacturers.location = 'USA' AND military_vehicles.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE); INSERT INTO members (member_id, name, gender, dob) VALUES (1, 'Carlos Gomez', 'Male', '2002-01-18'); INSERT INTO members (member_id, name, gender, dob) VALUES (2, 'Dana Peterson', 'Female', '2001-09-09'); CREATE TABLE workout_sessions... | What is the minimum duration of a single workout session for each member? | SELECT member_id, MIN(duration) AS min_duration FROM workout_sessions GROUP BY member_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE design_standards (id INT, name VARCHAR(50), description TEXT, standard_date DATE); | Insert a new record in the 'design_standards' table with id 5, name 'Seismic Resistant Design', description 'New standards for seismic resistance', and standard_date '2022-03-15' | INSERT INTO design_standards (id, name, description, standard_date) VALUES (5, 'Seismic Resistant Design', 'New standards for seismic resistance', '2022-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GameRatings (RatingID INT, GameID INT, UserRating INT); INSERT INTO GameRatings (RatingID, GameID, UserRating) VALUES (1, 1, 5); INSERT INTO GameRatings (RatingID, GameID, UserRating) VALUES (2, 2, 4); | What is the total revenue generated by games with a user rating of 4 or higher? | SELECT SUM(gs.Revenue) FROM GameSales gs JOIN Games g ON gs.GameID = g.GameID JOIN GameRatings gr ON g.GameID = gr.GameID WHERE gr.UserRating >= 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_activity_data (player_id INT, last_played_date DATE); INSERT INTO player_activity_data VALUES (1, '2023-03-01'), (2, '2023-02-25'), (3, '2023-03-15'), (4, '2023-01-28'), (5, '2023-02-03'), (6, '2023-03-08'); | What is the number of players who played a game in the last 30 days in the 'player_activity_data' schema? | SELECT COUNT(*) AS num_players FROM player_activity_data WHERE last_played_date >= CURDATE() - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE EquipmentTypes (equipment_type VARCHAR(50), manufacturer VARCHAR(50), sale_price DECIMAL(10, 2)); INSERT INTO EquipmentTypes (equipment_type, manufacturer, sale_price) VALUES ('Tank', 'XYZ', 5000000.00); INSERT INTO EquipmentTypes (equipment_type, manufacturer, sale_price) VALUES ('Fighter Jet', 'XYZ', 800... | What is the average sale price of military equipment by type for defense contractor XYZ? | SELECT equipment_type, AVG(sale_price) as avg_sale_price FROM EquipmentTypes WHERE manufacturer = 'XYZ' GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_sales (id INT, equipment_name VARCHAR, quantity INT, country VARCHAR, sale_price DECIMAL(10,2)); | What is the total value of military equipment sales to Oceania? | SELECT SUM(quantity * sale_price) FROM equipment_sales WHERE country = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (attorney_id INT, name TEXT, gender TEXT, region TEXT); INSERT INTO Attorneys (attorney_id, name, gender, region) VALUES (1, 'John Doe', 'Male', 'New York'), (2, 'Jane Smith', 'Female', 'California'), (3, 'Mike Johnson', 'Male', 'California'); CREATE TABLE Cases (case_id INT, attorney_id INT, won... | How many cases were lost by attorneys who identify as female and are from the 'California' region? | SELECT COUNT(Cases.case_id) FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.attorney_id WHERE Attorneys.gender = 'Female' AND Attorneys.region = 'California' AND Cases.won = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(50), firm VARCHAR(50)); INSERT INTO attorneys (attorney_id, attorney_name, firm) VALUES (1, 'Jane Jones', 'Jones'), (2, 'Robert Smith', 'Smith'); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, ... | How many cases were handled by attorneys in the 'Jones' firm? | SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.firm = 'Jones'; | gretelai_synthetic_text_to_sql |
CREATE TABLE life_expectancy (id INT, country VARCHAR(20), year INT, life_expectancy FLOAT); INSERT INTO life_expectancy (id, country, year, life_expectancy) VALUES (1, 'Kenya', 2018, 65.0), (2, 'Kenya', 2019, 65.5), (3, 'Nigeria', 2019, 59.0); | What is the life expectancy in each country in Africa? | SELECT country, life_expectancy FROM life_expectancy WHERE year = (SELECT MAX(year) FROM life_expectancy) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (clinic_location VARCHAR(255), healthcare_provider_name VARCHAR(255), appointment_date DATE); INSERT INTO rural_clinics (clinic_location, healthcare_provider_name, appointment_date) VALUES ('Location1', 'Provider1', '2022-01-01'), ('Location1', 'Provider1', '2022-01-05'), ('Location2', 'Provi... | Identify the earliest appointment date for each healthcare provider at each clinic location, in the "rural_clinics" table with appointment data. | SELECT clinic_location, healthcare_provider_name, MIN(appointment_date) OVER (PARTITION BY clinic_location, healthcare_provider_name) AS earliest_appointment_date FROM rural_clinics; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, category VARCHAR(50), risk_assessment FLOAT); INSERT INTO initiatives (id, category, risk_assessment) VALUES (1, 'clean water', 65.0), (2, 'gender equality', 72.5), (3, 'clean water', 70.0), (4, 'affordable housing', 75.2); | What is the average risk assessment score for initiatives in the 'clean water' category? | SELECT AVG(risk_assessment) FROM initiatives WHERE category = 'clean water'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, timestamp TIMESTAMP, industry VARCHAR(255), country VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO security_incidents (id, timestamp, industry, country, incident_type) VALUES (1, '2022-04-01 10:00:00', 'Healthcare', 'USA', 'malware'), (2, '2022-04-02 15:00:00', 'Healthca... | Calculate the percentage of each incident type out of the total incidents for the 'Healthcare' industry in the last quarter. | SELECT incident_type, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM security_incidents WHERE industry = 'Healthcare' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 3 MONTH)) , 2) as percentage FROM security_incidents WHERE industry = 'Healthcare' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 3 MONTH... | gretelai_synthetic_text_to_sql |
CREATE TABLE Subscribers (SubscriberID int, DataUsage int, Area varchar(10), BillingIssue bit); INSERT INTO Subscribers (SubscriberID, DataUsage, Area, BillingIssue) VALUES (1, 20000, 'rural', 0), (2, 30000, 'urban', 1), (3, 15000, 'rural', 1), (4, 25000, 'urban', 0), (5, 35000, 'urban', 0); | What is the total data usage for subscribers in 'urban' areas, excluding those who have had a billing issue in the past year? | SELECT DataUsage FROM Subscribers WHERE Area = 'urban' AND BillingIssue = 0 | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id VARCHAR(10), well_location VARCHAR(20)); INSERT INTO wells (well_id, well_location) VALUES ('I09', 'Brazilian Atlantic'); CREATE TABLE production (well_id VARCHAR(10), production_count INT); INSERT INTO production (well_id, production_count) VALUES ('I09', 13000); | What is the production count for well 'I09' in 'Brazilian Atlantic'? | SELECT production_count FROM production WHERE well_id = 'I09'; | gretelai_synthetic_text_to_sql |
CREATE TABLE national_parks (park_id INT, location TEXT, visitors INT, date DATE); INSERT INTO national_parks (park_id, location, visitors, date) VALUES (1, 'Uluru-Kata Tjuta National Park', 2000, '2021-10-01'), (2, 'Great Barrier Reef Marine Park', 3000, '2021-11-01'); | What is the average number of visitors to national parks in Australia per month? | SELECT AVG(visitors) FROM national_parks WHERE location = 'Australia' GROUP BY date_format(date, '%Y-%m'); | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_metrics(id INT, company_name VARCHAR(50), founder_name VARCHAR(50), gender VARCHAR(10), age INT); INSERT INTO diversity_metrics VALUES (1, 'Startup X', 'Founder A', 'Male', 40); INSERT INTO diversity_metrics VALUES (2, 'Startup Y', 'Founder B', 'Female', 35); INSERT INTO diversity_metrics VALUES ... | Update the name of the founder of Startup X to 'Founder Y' in the diversity metrics table | UPDATE diversity_metrics SET founder_name = 'Founder Y' WHERE company_name = 'Startup X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (name VARCHAR(255), patient_count INT, total_salary NUMERIC(10, 2)); INSERT INTO departments (name, patient_count, total_salary) VALUES (1, 100, 300000), (2, 150, 400000); | What are the names of the rural health departments, ordered by the total patient count, and including the total salary expenditure for each department? | SELECT name, patient_count, total_salary FROM departments ORDER BY patient_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (subscriber_id INT, subscription_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, subscription_type, data_usage, region) VALUES (1, 'postpaid', 3.5, 'North'), (2, 'postpaid', 4.2, 'South'), (3, 'postpaid', 3.8, 'North'); | What is the average monthly data usage for each postpaid mobile subscriber by region, sorted by the highest average usage? | SELECT region, AVG(data_usage) as avg_data_usage FROM subscribers WHERE subscription_type = 'postpaid' GROUP BY region ORDER BY avg_data_usage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, RaceEthnicity VARCHAR(255)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, RaceEthnicity) VALUES (1, 35, 'Latinx'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, RaceEthnicity) VALUES (2, 42, 'African American'); INSERT INTO CommunityHealthWorkers (W... | What is the average age of community health workers by their race/ethnicity? | SELECT RaceEthnicity, AVG(Age) FROM CommunityHealthWorkers GROUP BY RaceEthnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, user_id INT, comment_count INT); INSERT INTO posts (post_id, user_id, comment_count) VALUES (1, 1, 100), (2, 2, 50), (3, 3, 150); | What is the maximum number of comments on a single post, from users in the 'athlete' category? | SELECT MAX(comment_count) FROM posts JOIN users ON posts.user_id = users.user_id WHERE users.category = 'athlete'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Road_Construction (project_id INT, project_name VARCHAR(100), status VARCHAR(20)); INSERT INTO Road_Construction (project_id, project_name, status) VALUES (1, 'Highway Expansion', 'in_progress'), (3, 'Bridge Replacement', 'pending'); | Update the 'status' column to 'completed' for the project with ID 3 in the 'Road_Construction' table. | UPDATE Road_Construction SET status = 'completed' WHERE project_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_schools (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO public_schools (id, name, city, state) VALUES (1, 'School 1', 'New York City', 'NY'); INSERT INTO public_schools (id, name, city, state) VALUES (2, 'School 2', 'New York City', 'NY'); | What is the number of public schools in New York City? | SELECT COUNT(*) FROM public_schools WHERE city = 'New York City' AND state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ingredients (id INT, name VARCHAR(50), origin VARCHAR(50), safety_rating DECIMAL(3,2)); INSERT INTO Ingredients (id, name, origin, safety_rating) VALUES (1, 'Aloe Vera', 'USA', 9.75), (2, 'Argan Oil', 'Morocco', 9.50), (3, 'Cocoa Butter', 'Ghana', 9.25); | What is the average safety rating of ingredients sourced from the United States? | SELECT AVG(i.safety_rating) as avg_safety_rating FROM Ingredients i WHERE i.origin = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_sources (product_id INT, ingredient TEXT, supplier_sustainability_rating INT, region TEXT); CREATE VIEW sustainable_suppliers AS SELECT supplier, AVG(supplier_sustainability_rating) as avg_rating FROM ingredient_sources GROUP BY supplier; | What are the top 5 ingredients sourced from sustainable suppliers for cosmetic products in the European Union? | SELECT ingredient FROM ingredient_sources INNER JOIN sustainable_suppliers ON ingredient_sources.supplier = sustainable_suppliers.supplier WHERE region = 'European Union' GROUP BY ingredient ORDER BY avg_rating DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(50), esg_rating VARCHAR(1)); INSERT INTO companies (id, name, esg_rating) VALUES (1, 'ABC Inc.', 'A'); INSERT INTO companies (id, name, esg_rating) VALUES (2, 'DEF Inc.', 'B'); INSERT INTO companies (id, name, esg_rating) VALUES (3, 'XYZ Inc.', 'C'); | How many companies have an ESG rating of 'A' or higher? | SELECT COUNT(*) FROM companies WHERE esg_rating IN ('A', 'B', 'C+', 'A-'); | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_practices (factory_id INT, location TEXT, fair_labor_practices BOOLEAN); INSERT INTO labor_practices (factory_id, location, fair_labor_practices) VALUES (1, 'Spain', true), (2, 'Portugal', false); | Determine the number of factories with fair labor practices in Spain. | SELECT COUNT(factory_id) FROM labor_practices WHERE location = 'Spain' AND fair_labor_practices = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (title VARCHAR(255), genre VARCHAR(50), budget INT, rating INT); INSERT INTO tv_shows (title, genre, budget, rating) VALUES ('Show1', 'Comedy', 6000000, 6), ('Show2', 'Drama', 4000000, 8), ('Show3', 'Action', 7000000, 5); | Delete all TV shows with a production budget over 5 million and a rating below 7 | DELETE FROM tv_shows WHERE budget > 5000000 AND rating < 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE all_blacks_stats (player TEXT, tries INT); INSERT INTO all_blacks_stats (player, tries) VALUES ('Beauden Barrett', 41); INSERT INTO all_blacks_stats (player, tries) VALUES ('Aaron Smith', 35); | What is the total number of tries scored by the All Blacks Rugby Union Team? | SELECT SUM(tries) FROM all_blacks_stats; | gretelai_synthetic_text_to_sql |
CREATE TABLE Digital_Engagement (id INT, visitor_id INT, exhibition_id INT, platform VARCHAR(255), views INT, clicks INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(255), theme VARCHAR(255)); INSERT INTO Digital_Engagement (id, visitor_id, exhibition_id, platform, views, clicks) VALUES (1, 1001, 1, 'Website', 100,... | Find the total digital engagement for exhibitions related to African history. | SELECT SUM(views + clicks) FROM Digital_Engagement de JOIN Exhibitions e ON de.exhibition_id = e.id WHERE e.theme LIKE '%African%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (Id INT, Name VARCHAR(50), Category VARCHAR(50), Funding DECIMAL(10,2)); | What is the total funding received by arts education programs? | SELECT SUM(Funding) FROM Programs WHERE Category = 'Arts Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthProviders (ProviderID INT, Region VARCHAR(255), Language VARCHAR(255)); INSERT INTO MentalHealthProviders (ProviderID, Region, Language) VALUES (1, 'North', 'English'), (2, 'South', 'Spanish'), (3, 'East', 'Mandarin'), (4, 'West', 'English'); | Identify the number of mental health providers who speak a language other than English, by region, in descending order of the number of providers. | SELECT Region, COUNT(*) as Count FROM MentalHealthProviders WHERE Language <> 'English' GROUP BY Region ORDER BY Count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (5, 'Charlie', 'Brown', 'Manufacturing', 58000.00); INSERT INTO Employees (EmployeeID, FirstN... | Which employees in the Manufacturing department have a salary above the average salary in the Safety department? | SELECT Employees.FirstName, Employees.LastName, Employees.Department, Employees.Salary FROM Employees, (SELECT AVG(Salary) AS AverageSalary FROM Employees WHERE Department = 'Safety') AS SafetyAverage WHERE Employees.Department = 'Manufacturing' AND Employees.Salary > SafetyAverage.AverageSalary; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(255)); INSERT INTO attorneys (attorney_id, attorney_name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE billing (bill_id INT, attorney_id INT, amount DECIMAL(10, 2)); INSERT INTO billing (bill_id, attorney_id, amount) VALUES (1, 1, 500.00), (2, 1,... | What is the total billing amount for each attorney? | SELECT a.attorney_name, SUM(b.amount) as total_billing FROM attorneys a INNER JOIN billing b ON a.attorney_id = b.attorney_id GROUP BY a.attorney_id, a.attorney_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_data_usage (id INT, user_id INT, data_usage FLOAT, usage_time DATETIME); INSERT INTO mobile_data_usage (id, user_id, data_usage, usage_time) VALUES (1, 1, 3.5, '2021-08-01 12:30:00'); INSERT INTO mobile_data_usage (id, user_id, data_usage, usage_time) VALUES (2, 2, 5.2, '2021-08-02 16:45:00'); INSER... | What is the distribution of mobile data usage by hour of the day, for the past 7 days? | SELECT DATEPART(hour, usage_time) as hour, AVG(data_usage) as avg_data_usage FROM mobile_data_usage WHERE usage_time >= DATEADD(day, -7, GETDATE()) GROUP BY hour ORDER BY hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE diabetes (id INT, state VARCHAR(20), rural BOOLEAN, prevalence FLOAT); INSERT INTO diabetes (id, state, rural, prevalence) VALUES (1, 'Alabama', true, 12.3), (2, 'Alabama', false, 9.8), (3, 'Georgia', true, 10.5); | What is the prevalence of diabetes in rural Alabama? | SELECT prevalence FROM diabetes WHERE state = 'Alabama' AND rural = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (offender_id INT, offender_name VARCHAR(255)); CREATE TABLE offenses (offense_id INT, offender_id INT, offense_date DATE); | Who are the top 5 offenders by total number of offenses? | SELECT offender_name, COUNT(*) as total_offenses FROM offenders JOIN offenses ON offenders.offender_id = offenses.offender_id GROUP BY offender_name ORDER BY total_offenses DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (id INT, date DATE, type TEXT); | How many AI safety incidents were reported in the last month? | SELECT COUNT(*) as num_incidents FROM incidents WHERE date >= (CURRENT_DATE - INTERVAL '1 month'); | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_orders (order_id INT, aircraft_id INT, manufacturer VARCHAR(50), production_year INT); CREATE TABLE aircraft (aircraft_id INT, manufacturer VARCHAR(50)); | List all aircraft with more than 100 orders by manufacturer and year of production | SELECT manufacturer, production_year, COUNT(aircraft_id) as num_orders FROM aircraft_orders JOIN aircraft ON aircraft_orders.aircraft_id = aircraft.aircraft_id GROUP BY manufacturer, production_year HAVING COUNT(aircraft_id) > 100; | 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.