context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE SpacecraftManufacturing (id INT, model VARCHAR, cost FLOAT); | What is the rank of spacecraft models based on their manufacturing cost? | SELECT model, RANK() OVER (ORDER BY cost DESC) FROM SpacecraftManufacturing; | gretelai_synthetic_text_to_sql |
CREATE TABLE cyberwarfare (country VARCHAR(50), year INT, involved BOOLEAN); | Countries involved in cyberwarfare in 2020 | SELECT country FROM cyberwarfare WHERE year = 2020 AND involved = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE CharacterStats (CharacterID int, CharacterName varchar(50), CharacterType varchar(50), WinRate decimal(5,2)); INSERT INTO CharacterStats (CharacterID, CharacterName, CharacterType, WinRate) VALUES (1, 'Knight', 'Melee', 0.58), (2, 'Mage', 'Ranged', 0.63), (3, 'Archer', 'Ranged', 0.59), (4, 'Healer', 'Suppo... | What is the average win rate for each character, grouped by character type? | SELECT cs.CharacterType, AVG(cs.WinRate) as AvgWinRate FROM CharacterStats cs GROUP BY cs.CharacterType; | gretelai_synthetic_text_to_sql |
CREATE TABLE basin_production (basin VARCHAR(50), year INT, production_qty INT); INSERT INTO basin_production (basin, year, production_qty) VALUES ('Permian Basin', 2018, 500000), ('Permian Basin', 2017, 400000); | Calculate the total production in the Permian Basin for the year 2018 | SELECT SUM(production_qty) FROM basin_production WHERE basin = 'Permian Basin' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE oil_wells (state text, status text, depth real); INSERT INTO oil_wells (state, status, depth) VALUES ('Texas', 'active', 12000), ('Texas', 'inactive', 15000), ('North Dakota', 'active', 9000), ('Alaska', 'inactive', 8000), ('California', 'active', 14000), ('California', 'inactive', 11000), ('Louisiana', 'a... | How many active oil wells are there in each state in the USA? | SELECT state, COUNT(*) FROM oil_wells WHERE status = 'active' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE StateCannabisData (State VARCHAR(20), AvgWholesalePrice DECIMAL(5,2)); INSERT INTO StateCannabisData (State, AvgWholesalePrice) VALUES ('California', 2500), ('Colorado', 2000), ('Oregon', 1800), ('Washington', 2200), ('Nevada', 2700); | What are the top 5 states with the highest average wholesale price of cannabis flower? | SELECT State, AvgWholesalePrice FROM StateCannabisData ORDER BY AvgWholesalePrice DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), type VARCHAR(50), launch_date DATE); CREATE TABLE AstronautMissions (astronaut_id INT, mission_id INT); CREATE TABLE Astronauts (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), nationality VARCHAR(50), missions VARCHAR(500)); INSERT INT... | Identify all spacecraft that have had astronauts from multiple countries aboard, and display the spacecraft name and number of countries represented. | SELECT s.name, COUNT(DISTINCT a.nationality) AS country_count FROM Spacecraft s JOIN AstronautMissions am ON TRUE JOIN Astronauts a ON am.astronaut_id = a.id GROUP BY s.id HAVING COUNT(DISTINCT a.nationality) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments (id INT, warehouse_id INT, shipped_date DATE, packages INT); INSERT INTO Shipments (id, warehouse_id, shipped_date, packages) VALUES (1, 1, '2022-01-01', 50), (2, 1, '2022-01-02', 75), (3, 2, '2022-01-03', 100); CREATE TABLE Warehouses (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(... | What is the total number of packages shipped from Germany? | SELECT SUM(s.packages) FROM Shipments s JOIN Warehouses w ON s.warehouse_id = w.id WHERE w.country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions_3 (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_date DATE, customer_region VARCHAR(20)); INSERT INTO customer_transactions_3 (transaction_id, customer_id, transaction_value, transaction_date, customer_region) VALUES (1, 8, 12000, '2021-04-01', 'No... | Show the total transaction value per customer in the first quarter of the year, ordered by the customer ID in ascending order for customers in North America? | SELECT customer_region, customer_id, SUM(transaction_value) as total_transaction_value FROM customer_transactions_3 WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND customer_region = 'North America' GROUP BY customer_region, customer_id ORDER BY cu... | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founder_country TEXT); INSERT INTO company (id, name, founder_country) VALUES (1, 'MiddleEastInvestments', 'United Arab Emirates'); INSERT INTO company (id, name, founder_country) VALUES (2, 'GulfTech', 'Saudi Arabia'); | What is the minimum funding amount received by startups founded by people from the Middle East? | SELECT MIN(funding_amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.founder_country IN ('United Arab Emirates', 'Saudi Arabia', 'Iran', 'Iraq', 'Israel', 'Jordan', 'Kuwait', 'Lebanon', 'Oman', 'Palestine', 'Qatar', 'Syria', 'Yemen'); | gretelai_synthetic_text_to_sql |
CREATE TABLE public.patients (id SERIAL PRIMARY KEY, gender TEXT, hospital TEXT, appointment_date DATE); INSERT INTO public.patients (gender, hospital, appointment_date) VALUES ('Male', 'NYC General Hospital', '2022-01-01'), ('Female', 'NYC General Hospital', '2022-01-02'), ('Male', 'NYC Children''s Hospital', '2022-01... | What is the difference in the number of male and female patients in each hospital in the state of New York? | SELECT hospital, COUNT(*) FILTER (WHERE gender = 'Male') - COUNT(*) FILTER (WHERE gender = 'Female') FROM public.patients GROUP BY hospital; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, program VARCHAR(255), hours INT); INSERT INTO volunteers (id, program, hours) VALUES (1, 'Animal Welfare', 20), (2, 'Education', 30); | How many unique volunteers participated in each program? | SELECT program, COUNT(DISTINCT id) FROM volunteers GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT, total_tons_cargo_2021 FLOAT);CREATE TABLE cargo (cargo_id INT, port_id INT, ship_type TEXT, tons_cargo FLOAT, year INT); | What are the total tons of cargo handled by each port in the US for all ship types? | SELECT ports.port_name, SUM(cargo.tons_cargo) as total_tons_cargo FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'US' AND cargo.year = 2021 GROUP BY ports.port_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE phishing_emails (email_id INT, email_date DATE, email_subject VARCHAR(200), sender_email VARCHAR(100), targeted_department VARCHAR(50)); | What are the details of the 5 most recent phishing emails that targeted users in the human resources department, including the email subject and the sender's email address? | SELECT * FROM phishing_emails WHERE targeted_department = 'human resources' ORDER BY email_date DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (expedition_id INT, name VARCHAR(100), discovered_new_species BOOLEAN); INSERT INTO deep_sea_expeditions (expedition_id, name, discovered_new_species) VALUES (1, 'Challenger Expedition', TRUE); INSERT INTO deep_sea_expeditions (expedition_id, name, discovered_new_species) VALUES (2, 'G... | Which deep-sea expeditions have discovered new species? | SELECT name FROM deep_sea_expeditions WHERE discovered_new_species = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE london_bus (route_id INT, fare DECIMAL(5,2), num_riders INT); | What is the average fare for the most popular bus route in London? | SELECT AVG(fare) FROM london_bus WHERE route_id = (SELECT route_id FROM london_bus GROUP BY route_id ORDER BY SUM(num_riders) DESC LIMIT 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE ClinicalTrials (medicine_name TEXT, dosage TEXT); INSERT INTO ClinicalTrials (medicine_name, dosage) VALUES ('MedicineB', '100mg'); | Update the dosage for 'MedicineB' to '250mg' in 'ClinicalTrials' table. | UPDATE ClinicalTrials SET dosage = '250mg' WHERE medicine_name = 'MedicineB'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists americas; USE americas; CREATE TABLE if not exists military_bases (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO military_bases (id, name, type, location) VALUES (1, 'Fort Bragg', 'Army Base', 'USA'), (2, 'Camp Lejeune', 'Marine Corps Base', 'USA'), (3, 'C... | What is the total number of military bases in the 'americas' schema? | SELECT COUNT(*) FROM americas.military_bases; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_employees (id INT, name VARCHAR(50), type VARCHAR(10)); INSERT INTO mining_employees (id, name, type) VALUES (1, 'John Doe', 'Employee'), (2, 'Jane Smith', 'Contractor'); | What's the total number of employees and contractors in the mining industry? | SELECT SUM(CASE WHEN type = 'Employee' THEN 1 ELSE 0 END) AS total_employees, SUM(CASE WHEN type = 'Contractor' THEN 1 ELSE 0 END) AS total_contractors FROM mining_employees; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Country VARCHAR(20), AR boolean, Playtime INT); INSERT INTO Players (PlayerID, Country, AR, Playtime) VALUES (1, 'Japan', true, 80), (2, 'South Korea', false, 60), (3, 'China', true, 90); | What is the average playtime for players who play games in AR, by country? | SELECT Country, AVG(Playtime) FROM Players WHERE AR = true GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE irrigation_sensors (sensor_id VARCHAR(10), irrigation_percentage INT); | Update the irrigation data for sensor with ID S101 to 60% | UPDATE irrigation_sensors SET irrigation_percentage = 60 WHERE sensor_id = 'S101'; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), hire_date DATE); INSERT INTO employees (id, name, hire_date) VALUES (1, 'John Doe', '2022-01-01'); INSERT INTO employees (id, name, hire_date) VALUES (2, 'Jane Smith', '2022-02-01'); INSERT INTO employees (id, name, hire_date) VALUES (3, 'Alice Johnson', '2022-04-01'); ... | How many employees have been hired in each quarter of the past year? | SELECT EXTRACT(QUARTER FROM hire_date) AS quarter, COUNT(*) FROM employees GROUP BY quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (school_id INT, school_name TEXT); INSERT INTO schools VALUES (1, 'Oak Grove High'), (2, 'Maplewood Middle'), (3, 'Pine Park Elementary'); CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT); INSERT INTO student_mental_health VALUES (1, 1, 80), (2, 1, 85), (3... | What is the percentage of students who scored above the average mental health score in each school? | SELECT s.school_name, 100.0 * AVG(CASE WHEN smh.mental_health_score > avg_score THEN 1.0 ELSE 0.0 END) as pct_above_avg FROM student_mental_health smh JOIN (SELECT school_id, AVG(mental_health_score) as avg_score FROM student_mental_health GROUP BY school_id) avg_scores ON smh.school_id = avg_scores.school_id JOIN scho... | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning_race (student_id INT, race TEXT, course TEXT, completion_date DATE); INSERT INTO lifelong_learning_race (student_id, race, course, completion_date) VALUES (1, 'Asian', 'Data Science', '2022-01-10'), (2, 'Hispanic', 'Programming', '2021-06-15'), (3, 'African American', 'Data Science', '202... | What is the distribution of lifelong learning course completion rates by race/ethnicity? | SELECT race, COUNT(*) / (SELECT COUNT(*) FROM lifelong_learning_race) AS completion_rate FROM lifelong_learning_race GROUP BY race; | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkoutEquipment (equipment_id INT, equipment_type VARCHAR(30)); INSERT INTO WorkoutEquipment (equipment_id, equipment_type) VALUES (1, 'Treadmill'); INSERT INTO WorkoutEquipment (equipment_id, equipment_type) VALUES (2, 'Dumbbell'); CREATE TABLE WearableTech (tech_id INT, tech_type VARCHAR(30)); INSERT IN... | What is the list of unique equipment types used in the WorkoutEquipment table and the WearableTech table, excluding the 'Dumbbell' equipment type? | SELECT DISTINCT equipment_type FROM WorkoutEquipment WHERE equipment_type != 'Dumbbell' UNION SELECT DISTINCT tech_type FROM WearableTech; | gretelai_synthetic_text_to_sql |
CREATE TABLE vegan_leather_garments (id INT, production_quantity INT, region VARCHAR(20)); INSERT INTO vegan_leather_garments (id, production_quantity, region) VALUES (1, 500, 'Europe'), (2, 750, 'Asia'), (3, 600, 'Europe'); | Determine the number of vegan leather garments produced in Europe. | SELECT SUM(production_quantity) FROM vegan_leather_garments WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, name TEXT, developer INT, deployment_date DATE); INSERT INTO smart_contracts (id, name, developer, deployment_date) VALUES (1, 'Contract1', 1, '2023-01-01'), (2, 'Contract2', 2, '2023-03-01'); CREATE TABLE developers (id INT, name TEXT); INSERT INTO developers (id, name) VALUES (1,... | Who are the developers of smart contracts deployed in '2023'? | SELECT developers.name FROM developers INNER JOIN smart_contracts ON developers.id = smart_contracts.developer WHERE YEAR(smart_contracts.deployment_date) = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE FabricData (FabricID INT, SupplierID INT, FabricType TEXT, Quantity FLOAT, Organic BOOLEAN); INSERT INTO FabricData (FabricID, SupplierID, FabricType, Quantity, Organic) VALUES (1001, 1, 'Cotton', 500, true), (1002, 1, 'Polyester', 700, false), (1003, 2, 'Organic Cotton', 800, true); | What is the total quantity of organic cotton fabric used by each supplier in the past 3 months? | SELECT SupplierID, SUM(Quantity) FROM FabricData WHERE Organic = true AND FabricDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY SupplierID; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProteinSources (source_id INT, protein_source VARCHAR(255), caloric_content INT, market VARCHAR(255)); INSERT INTO ProteinSources (source_id, protein_source, caloric_content, market) VALUES (1, 'Tofu', 144, 'Asian'), (2, 'Lentils', 230, 'Global'), (3, 'Quinoa', 220, 'Global'); | What is the minimum caloric content of plant-based protein sources available in the Asian market? | SELECT MIN(caloric_content) FROM ProteinSources WHERE protein_source IN ('Tofu', 'Tempeh', 'Seitan') AND market = 'Asian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ChemicalSubstances (SubstanceID INT, SubstanceName VARCHAR(50), ProductionVolume INT, Region VARCHAR(50), ProductionDate DATE); INSERT INTO ChemicalSubstances (SubstanceID, SubstanceName, ProductionVolume, Region, ProductionDate) VALUES (1, 'Ethylene', 13000, 'Europe', '2019-01-01'), (2, 'Propylene', 9000,... | What is the average production volume of chemical substances in the Europe region for the year 2019? | SELECT AVG(ProductionVolume) FROM ChemicalSubstances WHERE Region = 'Europe' AND YEAR(ProductionDate) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_competency_scores (state VARCHAR(2), score INT); | What is the maximum cultural competency score per state? | SELECT state, MAX(score) FROM cultural_competency_scores GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, date DATE, outreach_hours INT, PRIMARY KEY(id)); | Insert new record '2022-05-01' for 'community_policing' table | INSERT INTO community_policing (id, date, outreach_hours) VALUES (3, '2022-05-01', 7); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(255), data_allowance INT, contract_start DATE); INSERT INTO mobile_subscribers (id, name, data_allowance, contract_start) VALUES (1, 'John Doe', 5000, '2020-01-01'), (2, 'Jane Doe', 3000, '2019-01-01'); CREATE TABLE customer_complaints (id INT, subscriber_id INT, co... | Increase data allowance for customers with network downtime complaints | UPDATE mobile_subscribers SET data_allowance = 7000 WHERE id IN (SELECT subscriber_id FROM customer_complaints WHERE complaint_type = 'Network Downtime'); | gretelai_synthetic_text_to_sql |
CREATE TABLE defunct_satellites_leo (id INT, name VARCHAR(255), mass FLOAT, orbit VARCHAR(255)); INSERT INTO defunct_satellites_leo (id, name, mass, orbit) VALUES (1, 'Defunct Satellite 1', 800.0, 'Low Earth Orbit'), (2, 'Defunct Satellite 2', 1200.0, 'Low Earth Orbit'), (3, 'Defunct Satellite 3', 1500.0, 'Low Earth Or... | What is the average mass of defunct satellites in low Earth orbit? | SELECT AVG(mass) FROM defunct_satellites_leo WHERE orbit = 'Low Earth Orbit' AND status = 'Defunct'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_id INT, movement VARCHAR(255), cultural_impact DECIMAL(10, 2)); | What was the average cultural impact score for all artworks in the 'Fauvist' movement? | SELECT AVG(cultural_impact) FROM Artworks WHERE movement = 'Fauvist'; | gretelai_synthetic_text_to_sql |
CREATE TABLE co_ownership (property_id INT, co_owner_name TEXT, share FLOAT); INSERT INTO co_ownership VALUES (1, 'Alice', 0.5), (1, 'Bob', 0.5), (2, 'Carol', 1.0) | List co-owner_names and their shares from the co_ownership table where 'share' > 0.6. | SELECT co_owner_name, share FROM co_ownership WHERE share > 0.6; | gretelai_synthetic_text_to_sql |
CREATE TABLE philanthropy.donations (donor_id INT, cause_id INT, amount DECIMAL, donation_date DATE); | What is the total donation amount for each cause in the 'philanthropy.donations' table? | SELECT cause_id, SUM(amount) FROM philanthropy.donations GROUP BY cause_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, quarter INT, quantity INT); INSERT INTO production (element, year, quarter, quantity) VALUES ('Europium', 2018, 1, 100), ('Europium', 2018, 2, 120), ('Europium', 2019, 3, 140), ('Europium', 2019, 4, 160); | What is the total quantity of Europium produced in the first half of 2018 and the last quarter of 2019? | SELECT SUM(quantity) FROM production WHERE element = 'Europium' AND (year = 2018 AND quarter BETWEEN 1 AND 2) OR (year = 2019 AND quarter BETWEEN 4 AND 4); | gretelai_synthetic_text_to_sql |
CREATE TABLE WeatherData (crop_type VARCHAR(20), temperature FLOAT, record_date DATE); INSERT INTO WeatherData (crop_type, temperature, record_date) VALUES ('Corn', 22.5, '2022-01-01'); INSERT INTO WeatherData (crop_type, temperature, record_date) VALUES ('Rice', 30.1, '2022-01-05'); INSERT INTO WeatherData (crop_type,... | What is the average temperature recorded for crop 'Rice'? | SELECT AVG(temperature) FROM WeatherData WHERE crop_type = 'Rice'; | gretelai_synthetic_text_to_sql |
CREATE TABLE weekly_visitor_count (date DATE, exhibition_id INT, visitor_count INT); INSERT INTO weekly_visitor_count (date, exhibition_id, visitor_count) VALUES ('2022-05-01', 2, 750); | What is the maximum number of visitors in a single day for the "Contemporary" exhibition? | SELECT MAX(visitor_count) FROM weekly_visitor_count WHERE exhibition_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Practices (id INT, name VARCHAR(255), type VARCHAR(255), implementation_location VARCHAR(255), industry VARCHAR(255)); INSERT INTO Practices (id, name, type, implementation_location, industry) VALUES (1, 'Living Wage', 'Fair Labor Practice', 'Indonesia', 'Footwear'); INSERT INTO Practices (id, name, type, ... | Which fair labor practices are most frequently implemented in the footwear industry across countries? | SELECT implementation_location, COUNT(*) FROM Practices WHERE type = 'Fair Labor Practice' AND industry = 'Footwear' GROUP BY implementation_location ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE stellar_accounts (account_id VARCHAR(56), balance INTEGER); | Which Stellar accounts have a balance greater than 100,000 XLM? | SELECT account_id FROM stellar_accounts WHERE balance > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, professional_development_programs INT, location VARCHAR(10), last_update DATE); INSERT INTO teachers (teacher_id, professional_development_programs, location, last_update) VALUES (1, 3, 'Urban', '2022-01-01'), (2, 2, 'Rural', '2022-02-01'); | How many professional development programs were offered to teachers in urban areas? | SELECT t.location, AVG(t.professional_development_programs) as avg_programs_per_teacher FROM teachers t WHERE t.location = 'Urban' GROUP BY t.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE machines (id INT, name VARCHAR(50), industry VARCHAR(50), energy_consumption FLOAT); INSERT INTO machines (id, name, industry, energy_consumption) VALUES (1, 'Machine A', 'Renewable Energy', 10.5), (2, 'Machine B', 'Renewable Energy', 12.0), (3, 'Machine C', 'Metal', 14.5); | What is the energy consumption of machines in the renewable energy sector? | SELECT industry, energy_consumption FROM machines WHERE industry = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE albums (album_id INT, album_name VARCHAR(100), genre VARCHAR(10)); CREATE TABLE tracks (track_id INT, track_name VARCHAR(100), album_id INT); INSERT INTO albums (album_id, album_name, genre) VALUES (1, 'AlbumA', 'Pop'), (2, 'AlbumB', 'Pop'), (3, 'AlbumC', 'Rock'); INSERT INTO tracks (track_id, track_n... | What is the average number of tracks per album for Pop genre? | SELECT AVG(cnt) FROM (SELECT album_id, COUNT(*) AS cnt FROM tracks JOIN albums ON tracks.album_id = albums.album_id WHERE albums.genre = 'Pop' GROUP BY album_id) AS t; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT); INSERT INTO players (id, name, age) VALUES (1, 'John Doe', 25), (2, 'Jane Smith', 30), (3, 'Marie Lee', 28); | Update the player names to be the initial of their first name and their full last name | UPDATE players SET name = CONCAT(SUBSTRING(name, 1, 1), '.', SUBSTRING(name, INSTR(name, ' ') + 1)); | gretelai_synthetic_text_to_sql |
CREATE TABLE HospitalBeds (StateName VARCHAR(50), HospitalName VARCHAR(50), NumBeds INT); INSERT INTO HospitalBeds (StateName, HospitalName, NumBeds) VALUES ('Alabama', 'HospitalA', 250), ('Alabama', 'HospitalB', 300), ('Alaska', 'HospitalX', 50), ('Arizona', 'HospitalY', 400), ('Arizona', 'HospitalZ', 350); | What is the hospital capacity by hospital name, ordered within each state? | SELECT StateName, HospitalName, NumBeds, RANK() OVER (PARTITION BY StateName ORDER BY NumBeds DESC) AS Rank FROM HospitalBeds | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_show (id INT PRIMARY KEY, title VARCHAR(255), year INT, country VARCHAR(255), genre VARCHAR(255)); CREATE TABLE viewership (id INT PRIMARY KEY, tv_show_id INT, viewership_count INT); INSERT INTO tv_show (id, title, year, country, genre) VALUES (1, 'TVShowA', 2010, 'Japan', 'Comedy'), (2, 'TVShowB', 2015... | What's the most popular genre for TV shows in Japan? | SELECT genre, MAX(SUM(viewership_count)) FROM tv_show JOIN viewership ON tv_show.id = viewership.tv_show_id GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_maintenance (id INT, vehicle_type VARCHAR(20), maintenance_date DATE, cost FLOAT); INSERT INTO vehicle_maintenance (id, vehicle_type, maintenance_date, cost) VALUES (1, 'Bus', '2021-07-01', 500), (2, 'Tram', '2021-07-03', 800), (3, 'Train', '2021-07-05', 1200), (4, 'Bus', '2021-10-01', 600), (5, 'T... | What was the maximum maintenance cost for each vehicle type in the third quarter of 2021? | SELECT vehicle_type, MAX(cost) as max_cost FROM vehicle_maintenance WHERE maintenance_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(year INT, state VARCHAR(20), material VARCHAR(20), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates VALUES (2018, 'New York', 'Plastic', 0.3), (2018, 'New York', 'Glass', 0.4), (2019, 'New York', 'Plastic', 0.35), (2019, 'New York', 'Glass', 0.45), (2019, 'New York', 'Metal', 0.5); | What is the recycling rate for each material type in New York in 2019? | SELECT year, state, material, AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates WHERE state = 'New York' AND year = 2019 GROUP BY year, state, material; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, DonationAmount numeric, State varchar(2)); INSERT INTO Donations (DonationID, DonationAmount, State) VALUES (1, 500, 'NY'), (2, 1200, 'CA'), (3, 250, 'TX'); | What is the average donation amount per state for donations greater than $1000? | SELECT AVG(DonationAmount) as AvgDonation, State FROM Donations WHERE DonationAmount > 1000 GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessel (ID INT, Name TEXT, AverageSpeed DECIMAL); INSERT INTO Vessel (ID, Name, AverageSpeed) VALUES (1, 'VesselA', 20.5), (2, 'VesselB', 22.3), (3, 'VesselC', 18.9); | Find the vessels with an average speed in the top 25% of average speeds in the Vessel table. | SELECT Name FROM (SELECT Name, AverageSpeed, NTILE(4) OVER (ORDER BY AverageSpeed DESC) AS Tile FROM Vessel) AS RankedVessels WHERE Tile <= 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers_Andes (FarmerID INT, Country VARCHAR(20), Scale VARCHAR(10), Metric FLOAT); INSERT INTO Farmers_Andes (FarmerID, Country, Scale, Metric) VALUES (1, 'Peru', 'Small', 2.1), (2, 'Bolivia', 'Small', 2.5), (3, 'Ecuador', 'Small', 1.9), (4, 'Peru', 'Large', 4.2), (5, 'Bolivia', 'Large', 3.8), (6, 'Ecuado... | What is the difference in agricultural innovation metrics between small-scale and large-scale farmers in the Andean region, partitioned by country and ordered by the largest difference? | SELECT Country, Scale, AVG(Metric) - LAG(AVG(Metric)) OVER (PARTITION BY Scale ORDER BY Country) as Difference FROM Farmers_Andes WHERE Scale IN ('Small', 'Large') GROUP BY Country, Scale ORDER BY Difference DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_violation_safety (union_id INT, violation_count INT, safety_focus BOOLEAN); INSERT INTO union_violation_safety (union_id, violation_count, safety_focus) VALUES (1, 10, true), (2, 20, false), (3, 30, true), (4, 40, true); | Find the total number of labor rights violations for unions that have a focus on worker safety. | SELECT SUM(union_violation_safety.violation_count) FROM union_violation_safety WHERE union_violation_safety.safety_focus = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID int, RouteName varchar(255), Region varchar(255)); INSERT INTO Routes (RouteID, RouteName, Region) VALUES (1, 'North', 'East'), (2, 'South', 'Central'), (3, 'West', 'West'), (4, 'Red Line', 'East'), (5, 'Green Line', 'North'), (6, 'Blue Line', 'West'), (7, 'South', 'South'); CREATE TABLE Tr... | What is the maximum fare for passengers using the 'South' bus route in the last week? | SELECT MAX(Fare) FROM Routes JOIN Trips ON Routes.RouteID = Trips.RouteID WHERE Routes.RouteName = 'South' AND Trips.TripDateTime >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending (account_number INT, account_type VARCHAR(255), balance DECIMAL(10, 2)); INSERT INTO socially_responsible_lending (account_number, account_type, balance) VALUES (12345, 'Checking', 5000.00), (67890, 'Savings', 10000.00), (11121, 'Checking', 7000.00); | What is the average account balance for socially responsible lending accounts? | SELECT AVG(balance) FROM socially_responsible_lending WHERE account_type = 'Checking' OR account_type = 'Savings'; | gretelai_synthetic_text_to_sql |
CREATE TABLE flu_vaccinations (vaccination_id INT, vaccine_name VARCHAR(20), date DATE, state VARCHAR(20)); INSERT INTO flu_vaccinations VALUES (1, 'Flu', '2021-01-05', 'California'), (2, 'Flu', '2021-01-10', 'California'), (3, 'Shingles', '2021-02-15', 'California'); | How many flu vaccinations were administered in California in January 2021? | SELECT COUNT(*) FROM flu_vaccinations WHERE vaccine_name = 'Flu' AND state = 'California' AND date BETWEEN '2021-01-01' AND '2021-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_ocean (id INT, min_depth FLOAT, max_depth FLOAT); INSERT INTO arctic_ocean (id, min_depth, max_depth) VALUES (1, 3000, 5000); | What is the minimum and maximum depth of the Arctic Ocean? | SELECT MIN(min_depth) AS min_depth, MAX(max_depth) AS max_depth FROM arctic_ocean WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesData (ItemID INT, ItemName TEXT, TextileType TEXT, Quantity INT); INSERT INTO SalesData (ItemID, ItemName, TextileType, Quantity) VALUES (1, 'Top', 'Cotton', 250), (2, 'Pants', 'Polyester', 300), (3, 'Dress', 'Wool', 150); | What is the percentage of sales by textile type? | SELECT TextileType, 100.0 * SUM(Quantity) / (SELECT SUM(Quantity) FROM SalesData) as PercentageOfSales FROM SalesData GROUP BY TextileType; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (id INT, game_date DATE, sport VARCHAR(50), tickets_sold INT, country VARCHAR(50)); | What is the total number of tickets sold for baseball games in the US in the last quarter? | SELECT SUM(tickets_sold) FROM ticket_sales WHERE sport = 'baseball' AND country = 'USA' AND game_date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, account_id INT, transaction_date DATE, transaction_type VARCHAR(50), transaction_amount DECIMAL(10,2)); CREATE TABLE customers (id INT, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(50)); | Identify customers from India who have made international transactions in the last month. | SELECT c.id, c.name FROM customers c JOIN (SELECT account_id FROM transactions t WHERE t.transaction_date >= DATEADD(month, -1, CURRENT_DATE) AND t.transaction_type = 'international' GROUP BY account_id) t ON c.id = t.account_id WHERE c.state = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT PRIMARY KEY, name VARCHAR(100), certification_level VARCHAR(20)); | Delete all building records with a certification level of 'platinum' from the 'green_buildings' table | DELETE FROM green_buildings WHERE certification_level = 'platinum'; | gretelai_synthetic_text_to_sql |
CREATE TABLE beds (name VARCHAR(255), region VARCHAR(255), beds INT); INSERT INTO beds (name, region, beds) VALUES ('Hospital A', 'Western', 100), ('Hospital B', 'Western', 200); | What is the number of hospital beds in the Western region of the US? | SELECT SUM(beds) FROM beds WHERE region = 'Western'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, location VARCHAR(50), name VARCHAR(100), certification_level VARCHAR(50)); | Determine the total number of Green Buildings by certification level globally | SELECT certification_level, COUNT(*) as building_count FROM green_buildings GROUP BY certification_level; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, price) VALUES (1, 1, 20.99), (2, 2, 50.00), (3, 3, 75.00); CREATE TABLE circular_supply_chain_products (product_id INT); INSERT INTO circular_supply_chain_products (product_id) VALUES (1), (3); | What is the total revenue generated from circular supply chain products? | SELECT SUM(sales.price) FROM sales INNER JOIN circular_supply_chain_products ON sales.product_id = circular_supply_chain_products.product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, founder_ethnicity TEXT, industry TEXT); CREATE TABLE investments (id INT, startup_id INT, funding_amount INT); | What is the average funding amount for startups founded by individuals who identify as African American in the artificial intelligence sector? | SELECT AVG(funding_amount) FROM (SELECT funding_amount FROM investments INNER JOIN startups ON investments.startup_id = startups.id WHERE startups.founder_ethnicity = 'African American' AND startups.industry = 'Artificial Intelligence') AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE local_businesses (id INT, name TEXT, country TEXT, hotel_name TEXT, is_eco BOOLEAN); INSERT INTO local_businesses (id, name, country, hotel_name, is_eco) VALUES (1, 'Souvenir Shop', 'Australia', 'Hotel Sydney', FALSE); | Delete all local businesses in 'Australia' associated with hotels that are not eco-friendly | DELETE FROM local_businesses WHERE country = 'Australia' AND is_eco = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE case_hearing (case_id INT, county_name VARCHAR(50), court_type VARCHAR(20), case_quarter DATE); INSERT INTO case_hearing VALUES (1, 'County A', 'Community', '2021-01-01'), (2, 'County A', 'Community', '2021-01-05'), (3, 'County B', 'Traditional', '2021-02-02'), (4, 'County B', 'Traditional', '2021-02-06'); | What is the total number of cases heard in each county and the case type per quarter? | SELECT county_name, court_type, DATE_FORMAT(case_quarter, '%Y-%m') AS case_month, COUNT(*) AS cases_per_quarter FROM case_hearing GROUP BY county_name, court_type, case_quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT, product TEXT, year INT); INSERT INTO mines (id, name, location, production_volume, product, year) VALUES (1, 'Zinc Zone Mine', 'Chile', 10000, 'Zinc', 2020); INSERT INTO mines (id, name, location, production_volume, product, year) VALUES (2, '... | What is the total amount of zinc produced in 'Chile' in 2020?' | SELECT SUM(production_volume) FROM mines WHERE location = 'Chile' AND product = 'Zinc' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE non_organic_inventory (item_id INT, item_name VARCHAR(255), category VARCHAR(255), quantity INT, unit_price DECIMAL(5,2)); INSERT INTO non_organic_inventory (item_id, item_name, category, quantity, unit_price) VALUES (1, 'Chicken', 'Proteins', 100, 1.99), (2, 'Rice', 'Grains', 75, 0.99), (3, 'Potatoes', 'S... | List the top 3 non-organic items with the highest inventory value? | SELECT item_name, quantity * unit_price as total_value FROM non_organic_inventory ORDER BY total_value DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE package_shipments (id INT, package_weight FLOAT, shipped_from VARCHAR(20), shipped_to VARCHAR(20), shipped_date DATE); INSERT INTO package_shipments (id, package_weight, shipped_from, shipped_to, shipped_date) VALUES (1, 3.0, 'Canada', 'Brazil', '2022-01-05'); | How many packages were shipped from Canada to South America in the last quarter? | SELECT COUNT(*) FROM package_shipments WHERE shipped_from = 'Canada' AND shipped_to LIKE 'South%' AND shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (id INT, name VARCHAR(20), subject VARCHAR(20)); INSERT INTO teachers (id, name, subject) VALUES (1, 'Ms. Green', 'Science'); INSERT INTO teachers (id, name, subject) VALUES (2, 'Mr. Blue', 'Math'); INSERT INTO teachers (id, name, subject) VALUES (3, 'Mrs. Red', 'English'); CREATE TABLE students_t... | List all the teachers who teach 'Science' and their number of students | SELECT teachers.name, COUNT(students_teachers.student_id) as num_students FROM teachers JOIN students_teachers ON teachers.id = students_teachers.teacher_id WHERE teachers.subject = 'Science' GROUP BY teachers.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE FINANCIAL_CAPABILITY_PROGRAMS (BANK_NAME VARCHAR(50), PROGRAM_NAME VARCHAR(50), START_DATE DATE); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank F', 'Program I', '2022-04-15'); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank G', 'Program J', '2022-05-20'); INSERT INTO FINANCIAL_CAPABILITY_... | List the banks with the lowest number of financial capability programs offered in Q2 2022, in ascending order? | SELECT BANK_NAME, COUNT(*) TOTAL_PROGRAMS FROM FINANCIAL_CAPABILITY_PROGRAMS WHERE START_DATE >= '2022-04-01' AND START_DATE < '2022-07-01' GROUP BY BANK_NAME ORDER BY TOTAL_PROGRAMS ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (MissionID INT, Name VARCHAR(50), StartDate DATE, EndDate DATE, Duration INT); | What is the sum of total mission durations for all missions to Neptune? | SELECT SUM(Duration) FROM SpaceMissions WHERE Destination = 'Neptune'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, artist VARCHAR(100), city VARCHAR(100), revenue DECIMAL(10,2)); CREATE TABLE Songs (id INT, title VARCHAR(100), artist VARCHAR(100), streams INT); CREATE TABLE Artists (id INT, name VARCHAR(100), country VARCHAR(100)); | What is the total revenue generated from concert ticket sales for artists who have released a song with the word 'heart' in the title? | SELECT SUM(revenue) FROM Concerts c JOIN (SELECT artist FROM Songs WHERE title LIKE '%heart%') s ON c.artist = s.artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), join_date DATE, data_usage FLOAT); INSERT INTO customers VALUES (1, 'Jane Doe', '2022-07-10', 45.6), (2, 'John Smith', '2022-07-20', 30.1); | How many customers have joined in the last month, and what is the total data usage in GB for these customers in their joining month? | SELECT COUNT(*) as new_customers, SUM(data_usage)/1024/1024/1024 as total_data_usage_gb FROM customers WHERE join_date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE inclusive_housing_developments (id INT, property_price FLOAT, city VARCHAR(255)); INSERT INTO inclusive_housing_developments (id, property_price, city) VALUES (1, 400000, 'Los Angeles'), (2, 500000, 'San Francisco'), (3, 600000, 'New York'), (4, 450000, 'Chicago'), (5, 350000, 'Miami'); | What is the average property price in each city in the inclusive_housing_developments table? | SELECT city, AVG(property_price) FROM inclusive_housing_developments GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (show_id INT, title VARCHAR(100), release_year INT, rating FLOAT); INSERT INTO tv_shows (show_id, title, release_year, rating) VALUES (1, 'Game of Thrones', 2011, 4.1), (2, 'Stranger Things', 2016, 4.6), (3, 'Breaking Bad', 2008, 4.8); | Update the rating of 'Stranger Things' to 4.7. | UPDATE tv_shows SET rating = 4.7 WHERE title = 'Stranger Things'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), CulturalCompetencyScore INT); CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), MentalHealthParityScore INT); | Calculate the average Mental Health Parity Score | SELECT AVG(MentalHealthParityScore) FROM MentalHealthParity; | gretelai_synthetic_text_to_sql |
CREATE TABLE JobApplications (ApplicationID INT, ApplicantID INT, JobCategory VARCHAR(50), ApplicationDate DATE); | What is the number of job applicants by job category, for the last 3 months? | SELECT JobCategory, COUNT(DISTINCT ApplicantID) FROM JobApplications WHERE ApplicationDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY JobCategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.emergency_responses (id serial PRIMARY KEY, city varchar(255), response_time int); INSERT INTO public.emergency_responses (city, response_time) VALUES ('New York', 120), ('New York', 130), ('New York', 140); | What is the maximum emergency response time in the city of New York? | SELECT MAX(response_time) FROM public.emergency_responses WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE meals (id INT, customer_id INT, calories INT, daily_recommended_intake INT); INSERT INTO meals (id, customer_id, calories, daily_recommended_intake) VALUES (1, 1, 800, 2000), (2, 1, 600, 2000), (3, 2, 500, 2500); CREATE TABLE customers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO customers ... | What is the percentage of meals that meet the daily recommended nutrient intake for customers in India? | SELECT (COUNT(*) FILTER (WHERE meals.calories >= (meals.daily_recommended_intake * 0.8))) * 100.0 / COUNT(*) AS percentage FROM meals JOIN customers ON meals.customer_id = customers.id WHERE customers.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE acidification_levels (measurement_id INTEGER, acidification_level FLOAT); INSERT INTO acidification_levels (measurement_id, acidification_level) VALUES (1, 7.5), (2, 7.8), (3, 8.2); | What are the minimum and maximum ocean acidification levels recorded? | SELECT MIN(acidification_level), MAX(acidification_level) FROM acidification_levels; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_race TEXT); INSERT INTO company (id, name, industry, founder_race) VALUES (1, 'EduBoost', 'Education', 'Latinx'); INSERT INTO company (id, name, industry, founder_race) VALUES (2, 'Shopify', 'E-commerce', 'Asian'); CREATE TABLE funding_round (company_id IN... | What is the count of startups founded by Latinx individuals in the education sector? | SELECT COUNT(*) FROM company WHERE company.founder_race = 'Latinx' AND company.industry = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name TEXT, age INT, state TEXT);CREATE TABLE treatments (id INT, patient_id INT, therapy TEXT);INSERT INTO patients (id, name, age, state) VALUES (1, 'John Doe', 45, 'California');INSERT INTO treatments (id, patient_id, therapy) VALUES (1, 1, 'Psychotherapy'); | What is the average age of patients who have received psychotherapy in California? | SELECT AVG(patients.age) FROM patients INNER JOIN treatments ON patients.id = treatments.patient_id WHERE patients.state = 'California' AND treatments.therapy = 'Psychotherapy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE instructors (id INT, name VARCHAR(50), country VARCHAR(50), expertise VARCHAR(50)); INSERT INTO instructors (id, name, country, expertise) VALUES (1, 'John Doe', 'Canada', 'AI'), (2, 'Jane Smith', 'USA', 'Data Science'), (3, 'Alice Johnson', 'UK', 'Machine Learning'); | Delete all records from the 'instructors' table where the instructor's 'country' is 'Canada' | DELETE FROM instructors WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE videos (id INT, title TEXT, release_year INT, views INT, country TEXT); INSERT INTO videos (id, title, release_year, views, country) VALUES (1, 'Video1', 2019, 10000, 'Nigeria'), (2, 'Video2', 2018, 15000, 'Egypt'); | What is the maximum number of views of videos produced in Africa? | SELECT MAX(views) FROM videos WHERE country IN ('Nigeria', 'Egypt', 'South Africa', 'Kenya', 'Algeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability_minority (id INT, business_id INT, minority VARCHAR(255), region VARCHAR(255), score FLOAT); | What is the average financial capability score for minority-owned businesses in North America? | SELECT AVG(score) FROM financial_capability_minority WHERE minority = 'yes' AND region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy (project_id INT, project_name VARCHAR(255), word_count INT); INSERT INTO open_pedagogy VALUES (1, 'Digital Citizenship', 500); INSERT INTO open_pedagogy VALUES (2, 'Community Building', 700); | What is the number of open pedagogy projects and their total word count? | SELECT COUNT(*), SUM(word_count) FROM open_pedagogy; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites_in_orbit(id INT, country VARCHAR(255), satellites INT, last_update DATE); | List the number of satellites in orbit for each country that has launched a satellite as of 2022-01-01, ordered by the number of satellites in descending order. | SELECT country, satellites FROM satellites_in_orbit WHERE last_update <= '2022-01-01' GROUP BY country ORDER BY satellites DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_conservation_initiatives (year INT, region VARCHAR(255), initiative_type VARCHAR(255), number_of_initiatives INT);INSERT INTO marine_conservation_initiatives (year, region, initiative_type, number_of_initiatives) VALUES (2020, 'Caribbean Sea', 'marine protected area creation', 5), (2019, 'Caribbean ... | How many marine conservation initiatives were launched in the Caribbean Sea in 2020? | SELECT number_of_initiatives FROM marine_conservation_initiatives WHERE region = 'Caribbean Sea' AND initiative_type = 'marine protected area creation' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(50), category VARCHAR(20), author_id INT, last_modified_date DATE); INSERT INTO articles (id, title, category, author_id, last_modified_date) VALUES (1, 'Healthcare Reform', 'health', 1, '2021-05-03'), (2, 'Education Cuts', 'education', 2, '2021-04-18'), (3, 'Sports News', '... | How many articles about education and health were updated or deleted in the last month? | SELECT COUNT(*) FROM articles WHERE category IN ('education', 'health') AND last_modified_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND (articles.author_id IS NULL OR articles.author_id NOT IN (SELECT authors.id FROM authors)); | gretelai_synthetic_text_to_sql |
CREATE TABLE org_communication (org_size VARCHAR(20), method VARCHAR(20)); INSERT INTO org_communication (org_size, method) VALUES ('small', 'email'), ('medium', 'phone'), ('large', 'video_conference'), ('extra_large', 'virtual_reality'); | What are the unique communication methods used by 'large' and 'extra_large' organizations? | SELECT DISTINCT method FROM org_communication WHERE org_size IN ('large', 'extra_large'); | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation(year INT, sector VARCHAR(255), amount INT); INSERT INTO waste_generation VALUES (2018, 'Residential', 1200), (2018, 'Commercial', 1800), (2018, 'Industrial', 2500), (2019, 'Residential', 1300), (2019, 'Commercial', 1900), (2019, 'Industrial', 2600), (2020, 'Residential', 1500), (2020, 'Com... | What is the total waste generated by each sector in 2020? | SELECT sector, SUM(amount) FROM waste_generation WHERE year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (id INT, name VARCHAR(50), gender VARCHAR(10), role VARCHAR(20), location VARCHAR(50)); INSERT INTO healthcare_providers (id, name, gender, role, location) VALUES (1, 'Dr. Smith', 'Female', 'Doctor', 'Rural Pakistan'); INSERT INTO healthcare_providers (id, name, gender, role, location)... | What is the percentage of female doctors in rural Pakistan? | SELECT ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM healthcare_providers WHERE location = 'Rural Pakistan' AND role = 'Doctor'), 2) FROM healthcare_providers WHERE location = 'Rural Pakistan' AND gender = 'Female' AND role = 'Doctor'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, source_country VARCHAR(20), destination_state VARCHAR(20), weight FLOAT, shipping_date DATE); INSERT INTO shipments (id, source_country, destination_state, weight, shipping_date) VALUES (1, 'Canada', 'Ontario', 15.6, '2022-02-01'), (2, 'Canada', 'Ontario', 22.2, '2021-02-04'); | What is the total weight of packages shipped from Canada to Ontario in the last year? | SELECT SUM(weight) FROM shipments WHERE source_country = 'Canada' AND destination_state = 'Ontario' AND shipping_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE TrainingSessions (SessionID INT, EmployeeID INT, TrainingType VARCHAR(20), SessionDate DATE, Rating INT); INSERT INTO TrainingSessions (SessionID, EmployeeID, TrainingType, SessionDate, Rating) VALUES (1, 1, 'Diversity', '2021-01-05', 8), (2, 1, 'Diversity', '2021-02-10', 9), (3, 2, 'Diversity', '2021-01-0... | What is the number of diversity training sessions attended by each employee, and what is the average rating for each employee? | SELECT EmployeeID, COUNT(*) AS NumSessions, AVG(Rating) AS AvgRating FROM TrainingSessions WHERE TrainingType = 'Diversity' GROUP BY EmployeeID; | gretelai_synthetic_text_to_sql |
CREATE TABLE life_habitat (habitat VARCHAR(50), biomass FLOAT); INSERT INTO life_habitat VALUES ('Habitat 1', 123.4), ('Habitat 1', 234.5), ('Habitat 2', 345.6); | What is the total biomass for marine life in each type of habitat, along with the habitat type? | SELECT habitat, SUM(biomass) as total_biomass FROM life_habitat GROUP BY habitat; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (PolicyholderState VARCHAR(2), InsuranceType VARCHAR(10), ClaimAmount NUMERIC(10,2)); INSERT INTO Claims VALUES ('CA', 'Home', 5000); INSERT INTO Claims VALUES ('CA', 'Auto', 2000); INSERT INTO Claims VALUES ('TX', 'Home', 8000); INSERT INTO Claims VALUES ('CA', 'Auto', 3000); | Show me the total number of insurance claims and their average amount for policyholders living in California, for each type of insurance. | SELECT InsuranceType, COUNT(*) AS TotalClaims, AVG(ClaimAmount) AS AvgClaimAmount FROM Claims WHERE PolicyholderState = 'CA' GROUP BY InsuranceType; | gretelai_synthetic_text_to_sql |
CREATE TABLE prices (year INT, element VARCHAR(10), price DECIMAL(5,2)); INSERT INTO prices (year, element, price) VALUES (2015, 'Dy', 250.50), (2015, 'Tm', 180.25), (2016, 'Dy', 300.00), (2016, 'Tm', 200.00), (2017, 'Er', 100.00), (2017, 'Yb', 500.00); | What is the average price per element for each year? | SELECT p.year, p.element, AVG(p.price) as avg_price FROM prices p GROUP BY p.year, p.element; | 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.