context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE OnlineStore (id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO OnlineStore (id, date, revenue) VALUES (1, '2022-01-01', 500.00); INSERT INTO OnlineStore (id, date, revenue) VALUES (2, '2022-01-02', 750.00); | Show the total revenue for the museum's online store for the last 30 days | SELECT SUM(revenue) FROM OnlineStore WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE wearable_data (member_id INT, activity VARCHAR(20), heart_rate INT, record_date DATE); INSERT INTO wearable_data (member_id, activity, heart_rate, record_date) VALUES (1, 'Running', 160, '2021-07-01'), (1, 'Cycling', 140, '2021-07-02'), (2, 'Swimming', 120, '2021-07-03'); | Identify the top 3 workout activities with the highest average heart rate recorded in the month of July 2021. | SELECT activity, AVG(heart_rate) AS avg_heart_rate FROM wearable_data WHERE MONTH(record_date) = 7 GROUP BY activity ORDER BY avg_heart_rate DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle (id INT, name TEXT, safety_rating FLOAT, is_electric BOOLEAN); INSERT INTO Vehicle (id, name, safety_rating, is_electric) VALUES (1, 'Model S', 5.3, true), (2, 'Camry', 4.8, false); | What is the average safety rating of electric vehicles in the US? | SELECT AVG(safety_rating) FROM Vehicle WHERE is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE inmates (id INT, age INT, gender VARCHAR(10), participation BOOLEAN); CREATE TABLE restorative_justice_programs (id INT, program VARCHAR(50)); | What is the average age of inmates who have participated in restorative justice programs, by gender? | SELECT gender, AVG(age) FROM inmates i JOIN restorative_justice_programs rjp ON i.id = rjp.id WHERE i.participation GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE arts (name VARCHAR(255), country VARCHAR(255)); INSERT INTO arts (name, country) VALUES ('Terpsichorean', 'Brazil'); INSERT INTO arts (name, country) VALUES ('Arawak Weaving', 'Colombia'); | What is the least popular traditional art form in South America, and in which country is it located? | SELECT name, country FROM arts WHERE name = (SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY COUNT(*) ASC) as rnk FROM arts GROUP BY name) t WHERE rnk = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_handling (transaction_id INT, port VARCHAR(255), date DATE, weight INT); INSERT INTO cargo_handling (transaction_id, port, date, weight) VALUES (1, 'PortA', '2022-01-01', 500), (2, 'PortB', '2022-01-05', 700), (3, 'PortA', '2022-02-10', 400); | What is the total weight of cargo handled by each port in the cargo_handling table, grouped by month? | SELECT port, EXTRACT(MONTH FROM date) as month, SUM(weight) as monthly_total_weight FROM cargo_handling GROUP BY port, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE jobs_created (id INT, enterprise_type VARCHAR(50), industry VARCHAR(50), year INT, jobs_created INT); | What is the total number of jobs created by foreign-invested enterprises in the 'jobs_created' table, grouped by industry and year? | SELECT industry, year, SUM(jobs_created) FROM jobs_created WHERE enterprise_type = 'foreign-invested' GROUP BY industry, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE stocking_records (id INT, farm_id INT, date DATE, stocked FLOAT); | How many fish were stocked in Q3 2022 by each farm_id? | SELECT farm_id, EXTRACT(MONTH FROM date) AS month, SUM(stocked) FROM stocking_records WHERE date LIKE '2022-0%' OR date LIKE '2022-1%' OR date LIKE '2022-2%' GROUP BY farm_id, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE approvals (drug_name TEXT, year INTEGER, cost INTEGER); INSERT INTO approvals (drug_name, year, cost) VALUES ('DrugE', 2020, 3000000); | What is the total drug approval cost for 'DrugE' in '2020'? | SELECT cost FROM approvals WHERE drug_name = 'DrugE' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_regions (id INT, name VARCHAR(50)); CREATE TABLE sales (id INT, region_id INT, vehicle_count INT); CREATE TABLE vehicles (id INT, type VARCHAR(50)); INSERT INTO sales_regions VALUES (1, 'California'), (2, 'Texas'); INSERT INTO sales VALUES (1, 1, 5000), (2, 2, 6000); INSERT INTO vehicles VA... | What is the total number of electric vehicles sold in "Texas" in the "sales" schema? | SELECT SUM(sales.vehicle_count) FROM sales INNER JOIN sales_regions ON sales.region_id = sales_regions.id INNER JOIN vehicles ON sales.id = vehicles.id WHERE vehicles.type = 'electric vehicle' AND sales_regions.name = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding (program_id INT, program_focus VARCHAR(50), funding DECIMAL(10,2), funding_date DATE); INSERT INTO Funding (program_id, program_focus, funding, funding_date) VALUES (1, 'Accessibility', 25000.00, '2022-01-05'), (2, 'Education', 30000.00, '2022-02-10'), (3, 'Diversity and Inclusion', 35000.00, '2022... | What was the total funding received for programs focused on accessibility in H1 2022? | SELECT SUM(funding) AS total_funding FROM Funding WHERE program_focus = 'Accessibility' AND funding_date BETWEEN '2022-01-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT PRIMARY KEY, name VARCHAR(255), industry VARCHAR(255), funding FLOAT); INSERT INTO company (id, name, industry, funding) VALUES (1, 'BioGen', 'Biotechnology', 70000000), (2, 'BioSense', 'Biosensor Technology', 20000000), (3, 'BioProcess', 'Bioprocess Engineering', 10000000); | Find the name and industry of the company with the lowest funding in the Bioprocess Engineering department. | SELECT name, industry FROM company WHERE industry = 'Bioprocess Engineering' AND funding = (SELECT MIN(funding) FROM company WHERE industry = 'Bioprocess Engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_chatbots_adoption (chatbot_id INT, hotel_id INT, region VARCHAR(20), adoption_date DATE); | How many hotels have adopted AI-powered chatbots in the 'Americas' region? | SELECT region, COUNT(*) as total FROM ai_chatbots_adoption WHERE region = 'Americas' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_name VARCHAR(255), region_id INT); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), region_id INT, enrollment INT); | What is the total number of students enrolled in open pedagogy courses in the region of Mumbai? | SELECT SUM(enrollment) FROM courses WHERE region_name = 'Mumbai' AND course_name LIKE '%open pedagogy%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media_posts (id INT, platform VARCHAR(50), content TEXT, post_date DATE); INSERT INTO social_media_posts (id, platform, content, post_date) VALUES (1, 'Twitter', 'Climate change tweet', '2021-07-01'), (2, 'Facebook', 'Climate change post', '2021-07-02'), (3, 'Twitter', 'Another climate change tweet'... | List the number of social media posts containing keywords related to climate change, grouped by platform, for the month of July 2021. | SELECT platform, COUNT(*) as post_count FROM social_media_posts WHERE post_date >= '2021-07-01' AND post_date < '2021-08-01' AND content LIKE '%climate change%' GROUP BY platform; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(50)); INSERT INTO Employees (EmployeeID, Name, Department, Gender) VALUES (1, 'Samuel Adams', 'Finance', 'Non-binary'), (2, 'Olivia Johnson', 'Marketing', 'Female'), (3, 'James Taylor', 'Finance', 'Male'); | What is the count of employees who identify as non-binary in the Finance department? | SELECT COUNT(*) FROM Employees WHERE Department = 'Finance' AND Gender = 'Non-binary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_mars (id INT, spacecraft_name VARCHAR(255), launch_date DATE, organization VARCHAR(255)); INSERT INTO spacecraft_mars (id, spacecraft_name, launch_date, organization) VALUES (1, 'Mars Pathfinder', '1996-12-04', 'NASA'); | Which organizations have launched spacecraft to Mars? | SELECT DISTINCT organization FROM spacecraft_mars WHERE spacecraft_name IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country TEXT); INSERT INTO countries (country_id, country) VALUES (1, 'Spain'), (2, 'Italy'); CREATE TABLE virtual_tours (tour_id INT, country_id INT, views INT, revenue FLOAT); INSERT INTO virtual_tours (tour_id, country_id, views, revenue) VALUES (1, 1, 500, 200.0), (2, 1, 600,... | What is the average revenue generated by virtual tours in Spain and Italy? | SELECT AVG(revenue) FROM virtual_tours WHERE country_id IN (SELECT country_id FROM countries WHERE country IN ('Spain', 'Italy')); | gretelai_synthetic_text_to_sql |
CREATE TABLE police_officers (id INT, district INT, city VARCHAR(255), role VARCHAR(255)); INSERT INTO police_officers (id, district, city, role) VALUES (1, 1, 'Los Angeles', 'Police Officer'), (2, 2, 'Los Angeles', 'Police Officer'), (3, 1, 'Los Angeles', 'Sergeant'); | How many police officers are there in each district in Los Angeles? | SELECT district, COUNT(id) as officers FROM police_officers WHERE city = 'Los Angeles' AND role = 'Police Officer' GROUP BY district; | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_demographics (id INT PRIMARY KEY, employee_id INT, name VARCHAR(255), department VARCHAR(255), region VARCHAR(255)); | List all unique departments from 'employee_demographics' | SELECT DISTINCT department FROM employee_demographics; | gretelai_synthetic_text_to_sql |
CREATE TABLE astrobiology_discoveries (id INT, discovery_name VARCHAR(255), location VARCHAR(255), discovery_date DATE, discovery_type VARCHAR(255)); INSERT INTO astrobiology_discoveries (id, discovery_name, location, discovery_date, discovery_type) VALUES (1, 'Exoplanet Kepler-186f', 'Kepler-186', '2014-04-17', 'Exopl... | What is the total number of exoplanet and meteorite discoveries in astrobiology? | SELECT SUM(discovery_count) as total_discoveries FROM (SELECT 'Exoplanet' as discovery_type, COUNT(*) as discovery_count FROM astrobiology_discoveries WHERE discovery_type = 'Exoplanet' UNION ALL SELECT 'Meteorite' as discovery_type, COUNT(*) as discovery_count FROM astrobiology_discoveries WHERE discovery_type = 'Mete... | gretelai_synthetic_text_to_sql |
CREATE SCHEMA security_schema; CREATE TABLE threat (threat_id INT PRIMARY KEY, threat_date DATE); INSERT INTO threat (threat_id, threat_date) VALUES (1, '2022-01-01'); | Show the number of cybersecurity threats detected per day in the last week | SELECT threat_date, COUNT(*) FROM threat WHERE threat_date >= CURDATE() - INTERVAL 7 DAY GROUP BY threat_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stadiums (StadiumID INT, StadiumName VARCHAR(50), Capacity INT); INSERT INTO Stadiums (StadiumID, StadiumName, Capacity) VALUES (1, 'Rungrado 1st of May Stadium', 114000), (2, 'Michigan Stadium', 107601); | Which soccer stadiums have a capacity over 100,000? | SELECT StadiumName FROM Stadiums WHERE Capacity > 100000 | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency (id INT, name TEXT, country TEXT); INSERT INTO energy_efficiency (id, name, country) VALUES (1, 'Energy Efficiency Standard', 'UK'); INSERT INTO energy_efficiency (id, name, country) VALUES (2, 'Energy Conservation Act', 'India'); INSERT INTO energy_efficiency (id, name, country) VALUES (... | Find the number of energy efficiency policies in countries with more than 50 GW of total renewable capacity | SELECT COUNT(*) FROM energy_efficiency WHERE country IN (SELECT country FROM renewable_sources WHERE capacity > 50); | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, fund_name VARCHAR(255), sector VARCHAR(255), investment_amount FLOAT); | What is the distribution of investments by sector for Green Fund? | SELECT sector, COUNT(*) as num_investments, SUM(investment_amount) as total_invested FROM investments WHERE fund_name = 'Green Fund' GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, name TEXT, site TEXT); INSERT INTO virtual_tours (tour_id, name, site) VALUES (1, 'Rome Virtual Tour', 'Colosseum'); | Update the name of the virtual tour for the Colosseum to "Colosseum 360" | UPDATE virtual_tours SET name = 'Colosseum 360' WHERE site = 'Colosseum'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_data (subscriber_id INT, subscriber_type VARCHAR(10), city VARCHAR(20), region VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id, subscriber_type, city, region) VALUES (1, 'postpaid', 'LA', 'West'), (2, 'prepaid', 'San Diego', 'West'), (3, 'postpaid', 'Seattle', 'West'), (4, 'prepaid', 'P... | What is the total number of postpaid and prepaid mobile subscribers in each city in the region of West? | SELECT city, COUNT(*) as total_subscribers FROM subscriber_data WHERE region = 'West' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(100), department VARCHAR(50), publications INT, grant_amount DECIMAL(10,2)); INSERT INTO graduate_students (id, name, department, publications, grant_amount) VALUES (1, 'Jamie', 'Engineering', 25, 100000.00); | List the top 3 graduate students with the highest number of research publications in the Engineering department, who have received research grants. | SELECT name, department, publications FROM graduate_students WHERE department = 'Engineering' AND grant_amount > 0 ORDER BY publications DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (drug_name TEXT, country TEXT, sales INTEGER); | Which country has the highest sales of 'DrugB'? | SELECT drug_name, MAX(sales) FROM sales_data WHERE drug_name = 'DrugB' GROUP BY drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT, event_name VARCHAR(50), region VARCHAR(50), year INT, budget INT); | What is the maximum budget allocated to defense diplomacy events in Asia in 2018? | SELECT MAX(budget) FROM defense_diplomacy WHERE region = 'Asia' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), Gender VARCHAR(10), Nationality VARCHAR(20), BirthYear INT); INSERT INTO Artists (ArtistID, ArtistName, Gender, Nationality, BirthYear) VALUES (1, 'Meriem Bennani', 'Non-binary', 'American', 1988); CREATE TABLE Artworks (ArtworkID INT, ArtistID INT, ArtworkNam... | Identify the number of sculptures created by non-binary artists from the United States and their average size. | SELECT COUNT(Artworks.ArtworkID), AVG(Artworks.Size) FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID WHERE Artists.Gender = 'Non-binary' AND Artists.Nationality = 'American' AND Artworks.ArtworkType = 'Sculpture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_manufacturing_2 (id INT, manufacturing_date DATE, manufacturer VARCHAR(20), mass FLOAT);INSERT INTO spacecraft_manufacturing_2 (id, manufacturing_date, manufacturer, mass) VALUES (1, '2019-01-01', 'AstroCorp', 3000.0), (2, '2019-04-01', 'SpaceTech', 4000.0), (3, '2019-07-01', 'AstroCorp', 5000.0... | How many spacecraft were manufactured in each quarter of 2019? | SELECT DATE_PART('quarter', manufacturing_date) AS quarter, COUNT(*) FROM spacecraft_manufacturing_2 WHERE manufacturing_date BETWEEN '2019-01-01' AND '2019-12-31' GROUP BY quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, name TEXT, year INT, investment FLOAT); | What was the total investment in renewable energy projects in Asia in 2021? | SELECT SUM(investment) FROM renewable_energy_projects WHERE year = 2021 AND country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'... | Find the total number of marine species in the 'marine_species' table | SELECT COUNT(*) FROM marine_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attendees (attendee_id INT, event_id INT, age_group VARCHAR(50), attendee_date DATE); INSERT INTO Attendees (attendee_id, event_id, age_group, attendee_date) VALUES (1, 1, '18-24', '2020-01-01'), (2, 2, '25-34', '2020-02-01'), (3, 3, '35-44', '2020-03-01'); | What was the distribution of attendees by age group for each event in '2020'? | SELECT event_id, age_group, COUNT(*) AS num_attendees FROM Attendees WHERE YEAR(attendee_date) = 2020 GROUP BY event_id, age_group; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA transportation; CREATE TABLE transportation.buses (id INT PRIMARY KEY, model VARCHAR(255), year INT); INSERT INTO transportation.buses (id, model, year) VALUES (1, 'Mini Bus', 2015), (2, 'City Bus', 2018), (3, 'Electric Bus', 2020); | What is the total number of buses in the 'transportation' schema? | SELECT COUNT(*) FROM transportation.buses; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_humidity (sensor_id INT, timestamp TIMESTAMP, humidity INT); | Identify the top three sensors with the highest average humidity for the past week. | SELECT sensor_id, AVG(humidity) AS avg_humidity FROM sensor_humidity WHERE timestamp >= NOW() - INTERVAL '1 week' GROUP BY sensor_id ORDER BY avg_humidity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, country TEXT); INSERT INTO donations (id, donor_id, country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 1, 'USA'), (4, 3, 'Mexico'), (5, 2, 'Canada'); | Identify the top 3 countries with the most unique donors. | SELECT country, COUNT(DISTINCT donor_id) AS unique_donors FROM donations GROUP BY country ORDER BY unique_donors DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE neighborhoods (neighborhood VARCHAR(255), city VARCHAR(255), housing_affordability_index FLOAT); | Calculate the average housing affordability index in City A and City C. | SELECT city, AVG(housing_affordability_index) as avg_affordability_index FROM neighborhoods WHERE city IN ('City A', 'City C') GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocations (allocationID INT, allocationType VARCHAR(50), allocationAmount FLOAT, fiscalYear INT); | Find the average budget allocated for disability services in the BudgetAllocations table for the fiscal year 2021. | SELECT AVG(allocationAmount) FROM BudgetAllocations WHERE fiscalYear = 2021 AND allocationType = 'Disability Services'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy_events (event_id INT, organization1 VARCHAR(255), organization2 VARCHAR(255), event_name VARCHAR(255), event_date DATE); INSERT INTO defense_diplomacy_events (event_id, organization1, organization2, event_name, event_date) VALUES (1, 'NATO', 'Russia', 'Military Exercise', '2019-06-01'), (... | List all defense diplomacy events involving NATO and Russia in 2019 | SELECT * FROM defense_diplomacy_events WHERE (organization1 = 'NATO' AND organization2 = 'Russia') OR (organization1 = 'Russia' AND organization2 = 'NATO') AND YEAR(event_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_users (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO agricultural_users (id, state, water_usage) VALUES (1, 'Georgia', 22.5), (2, 'Georgia', 25.6), (3, 'California', 30.2); | What is the average water usage by agricultural users in the state of Georgia? | SELECT AVG(water_usage) FROM agricultural_users WHERE state = 'Georgia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipment (id INT PRIMARY KEY, cargo_id INT, vessel_id INT, port_id INT, FOREIGN KEY (cargo_id) REFERENCES Cargo(id), FOREIGN KEY (vessel_id) REFERENCES Vessel(id), FOREIGN KEY (port_id) REFERENCES Port(id)); CREATE TABLE Cargo (id INT PRIMARY KEY, description VARCHAR(50), weight FLOAT); | Delete all records of shipments with cargo weight less than 5000 units? | DELETE FROM Shipment S WHERE NOT EXISTS (SELECT 1 FROM Cargo C WHERE S.cargo_id = C.id AND C.weight >= 5000); | gretelai_synthetic_text_to_sql |
CREATE TABLE public.patient_data (id SERIAL PRIMARY KEY, age INTEGER, diagnosis TEXT, state TEXT); INSERT INTO public.patient_data (age, diagnosis, state) VALUES (50, 'Tuberculosis', 'Texas'), (45, 'Tuberculosis', 'Texas'), (60, 'Tuberculosis', 'New York'); | Identify the average age of patients diagnosed with tuberculosis in Texas and New York, and calculate the difference between the two averages. | SELECT AVG(p.age) FILTER (WHERE p.state = 'Texas') - AVG(p.age) FILTER (WHERE p.state = 'New York') FROM public.patient_data p WHERE p.diagnosis = 'Tuberculosis'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Space_Missions (ID INT, Year INT, Cost INT); INSERT INTO Space_Missions (ID, Year, Cost) VALUES (1, 2010, 1000), (2, 2015, 2000), (3, 2020, 3000); | What is the total cost of space missions by year? | SELECT Year, SUM(Cost) FROM Space_Missions GROUP BY Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE toll_booths (id INT, booth_id VARCHAR(255), location VARCHAR(255), price FLOAT); | Update 'price' to 500 for records in the 'toll_booths' table where 'location' is 'Boston' | UPDATE toll_booths SET price = 500 WHERE location = 'Boston'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cybersecurity_Incidents_2 (id INT, industry VARCHAR(50), year INT, month INT, reported_count INT); | How many cybersecurity incidents were reported in the defense industry in the last 6 months? | SELECT SUM(reported_count) FROM Cybersecurity_Incidents_2 WHERE industry = 'defense' AND year = YEAR(CURRENT_DATE) AND month >= MONTH(CURRENT_DATE) - 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streams (stream_id INT, song_id INT, streams INT, stream_date DATE); INSERT INTO Streams (stream_id, song_id, streams, stream_date) VALUES (1, 1, 1000, '2021-01-01'), (2, 2, 2000, '2021-01-02'), (3, 3, 3000, '2021-01-03'); CREATE TABLE Songs (song_id INT, song_name TEXT, duration INT, release_year INT); IN... | What is the minimum duration of songs in the Top 100 most streamed songs of 2021? | SELECT MIN(s.duration) FROM Songs s JOIN (SELECT song_id, COUNT(*) AS streams FROM Streams WHERE stream_date >= '2021-01-01' GROUP BY song_id ORDER BY streams DESC LIMIT 100) t ON s.song_id = t.song_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste (factory VARCHAR(50), date DATE, waste_amount INT); INSERT INTO waste (factory, date, waste_amount) VALUES ('factory1', '2021-01-01', 500), ('factory1', '2021-01-02', 600); | What is the number of days where waste production was under 500 for 'factory1'? | SELECT COUNT(*) FROM waste WHERE factory = 'factory1' AND waste_amount < 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE dapps (id INT, name TEXT, launch_date DATE); INSERT INTO dapps (id, name, launch_date) VALUES (1, 'AppA', '2020-01-01'), (2, 'AppB', '2019-06-15'), (3, 'AppC', '2021-03-20'); CREATE TABLE regulatory_frameworks (id INT, dapp_id INT, name TEXT, implementation_date DATE); INSERT INTO regulatory_frameworks (id... | List all regulatory frameworks and the decentralized applications they apply to, ordered by the date of implementation. | SELECT d.name, r.name, r.implementation_date FROM dapps d JOIN regulatory_frameworks r ON d.id = r.dapp_id ORDER BY r.implementation_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), culture VARCHAR(50), score INT); INSERT INTO community_health_workers (worker_id, name, culture, score) VALUES (1, 'John Doe', 'Hispanic', 90), (2, 'Jane Smith', 'African American', 85); | List all community health workers and their respective cultural competency scores. | SELECT * FROM community_health_workers; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT NOT NULL, published_at DATE, word_count INT); | Find the average word count for articles, grouped by the day | SELECT DATE(published_at) as date, AVG(word_count) as avg_word_count FROM articles GROUP BY date; | gretelai_synthetic_text_to_sql |
CREATE TABLE budgets (id INT, category TEXT, amount FLOAT, region TEXT); INSERT INTO budgets (id, category, amount, region) VALUES (1, 'transportation', 2000000, 'North'); | What is the budget allocated for transportation in each region? | SELECT budgets.region, SUM(budgets.amount) FROM budgets WHERE budgets.category = 'transportation' GROUP BY budgets.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_category VARCHAR(255), transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_date, transaction_category, transaction_value) VALUES (1, '2021-01-02', 'Food', 50.00), (2, '2021-01-05', 'Electronics', 300.00... | What is the total transaction value per category for the first quarter of 2021? | SELECT transaction_category, SUM(transaction_value) as total_value FROM transactions WHERE transaction_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY transaction_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Program varchar(50), Hours numeric(5,2)); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours) VALUES (1, 'Alice', 'ProgramA', 20.00), (2, 'Bob', 'ProgramB', 30.00), (3, 'Charlie', 'ProgramA', 25.00), (4, 'David', 'ProgramB', 15.00); | What is the total number of volunteers in ProgramA and ProgramB, and what is the average hours they have volunteered in these programs? | SELECT Program, COUNT(VolunteerID) AS NumVolunteers, AVG(Hours) AS AvgHours FROM Volunteers WHERE Program IN ('ProgramA', 'ProgramB') GROUP BY Program; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, volunteer_program TEXT, volunteer_hours INT, volunteer_date DATE); INSERT INTO volunteers (volunteer_id, volunteer_program, volunteer_hours, volunteer_date) VALUES (1, 'Education', 20, '2022-01-01'), (2, 'Food Bank', 30, '2022-02-01'), (3, 'Education', 10, '2022-03-01'), (4, '... | What was the total number of volunteers and total volunteer hours for each program in Q1 2022? | SELECT volunteer_program, COUNT(DISTINCT volunteer_id) AS total_volunteers, SUM(volunteer_hours) AS total_hours FROM volunteers WHERE YEAR(volunteer_date) = 2022 AND QUARTER(volunteer_date) = 1 GROUP BY volunteer_program; | gretelai_synthetic_text_to_sql |
CREATE TABLE sightings (species_name VARCHAR(255), sighting_count INT, location VARCHAR(255)); INSERT INTO sightings (species_name, sighting_count, location) VALUES ('Walrus', 15, 'Arctic Ocean'), ('Beluga Whale', 25, 'Arctic Ocean'), ('Narwhal', 10, 'Arctic Ocean'); | Which marine species have been observed the least in the Arctic Ocean? | SELECT species_name, MIN(sighting_count) FROM sightings WHERE location = 'Arctic Ocean' GROUP BY species_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_scores (student_id INT, school_id INT, lifelong_learning_score INT); INSERT INTO student_scores (student_id, school_id, lifelong_learning_score) VALUES (1, 101, 85), (2, 101, 90), (3, 102, 75), (4, 102, 80), (5, 103, 95); | What is the average lifelong learning score of students in each school? | SELECT school_id, AVG(lifelong_learning_score) as avg_score FROM student_scores GROUP BY school_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_number INT, coverage_start_date DATE, agent_id INT, region VARCHAR(20)); INSERT INTO policies (policy_number, coverage_start_date, agent_id, region) VALUES (98765, '2022-01-02', 2001, 'Illinois'); INSERT INTO policies (policy_number, coverage_start_date, agent_id, region) VALUES (45612, '2... | Retrieve the names of agents, policy numbers, and coverage start dates for policies in the 'Illinois' region with a coverage start date before '2022-01-01'. | SELECT agents.name, policies.policy_number, policies.coverage_start_date FROM policies INNER JOIN agents ON policies.agent_id = agents.agent_id WHERE policies.region = 'Illinois' AND policies.coverage_start_date < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), email VARCHAR(50), department VARCHAR(50)); INSERT INTO students (id, name, email, department) VALUES (12, 'Jane Doe', 'janedoe@example.com', 'Computer Science'); | Change the department of student with ID 12 in the students table | UPDATE students SET department = 'Information Technology' WHERE id = 12; | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_database (id INT, department TEXT, training_completed TEXT); INSERT INTO employee_database (id, department, training_completed) VALUES (1, 'Engineering', 'Diversity'), (2, 'Engineering', 'Inclusion'), (3, 'Engineering', 'None'); | How many employees in the engineering department have completed training in inclusion? | SELECT COUNT(*) as count FROM employee_database WHERE department = 'Engineering' AND training_completed = 'Inclusion'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cctv (project_id INT, project_name VARCHAR(50), source VARCHAR(20), investigative_journalism BOOLEAN); INSERT INTO cctv (project_id, project_name, source, investigative_journalism) VALUES (1, 'Project A', 'CCTV', TRUE), (2, 'Project B', 'CCTV', FALSE); CREATE TABLE al_arabiya (project_id INT, project_name ... | Identify any investigative journalism projects published by 'CCTV' or 'Al Arabiya' but not by 'BBC Persian'. | SELECT project_name, source FROM cctv WHERE investigative_journalism = TRUE UNION ALL SELECT project_name, source FROM al_arabiya WHERE investigative_journalism = TRUE EXCEPT SELECT project_name, source FROM bbc_persian WHERE investigative_journalism = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (species VARCHAR(255), num_fish INT); CREATE TABLE sustainable_seafood (species VARCHAR(255), num_fish INT); INSERT INTO fish_stock (species, num_fish) VALUES ('Tilapia', 500), ('Salmon', 600); INSERT INTO sustainable_seafood (species, num_fish) VALUES ('Tilapia', 450), ('Salmon', 650); | What is the total number of fish for each species, grouped by species, from the 'fish_stock' and 'sustainable_seafood' tables? | SELECT f.species, SUM(f.num_fish + s.num_fish) FROM fish_stock f INNER JOIN sustainable_seafood s ON f.species = s.species GROUP BY f.species; | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_waste_generation (month VARCHAR(10), year INT, material VARCHAR(20), quantity INT); INSERT INTO monthly_waste_generation (month, year, material, quantity) VALUES ('January', 2021, 'Metal', 500), ('February', 2021, 'Metal', 600), ('March', 2021, 'Metal', 700), ('April', 2021, 'Metal', 800), ('May', ... | What is the total waste generation by month for the material 'Metal' in 2021? | SELECT STRFTIME('%m', month) as month, SUM(quantity) as total_waste FROM monthly_waste_generation WHERE year = 2021 AND material = 'Metal' GROUP BY STRFTIME('%m', month); | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (id INT, date DATE, temperature FLOAT); INSERT INTO arctic_weather (id, date, temperature) VALUES (1, '2021-01-01', 10), (2, '2021-04-01', 12), (3, '2021-07-01', 15); | What is the maximum temperature recorded in the 'arctic_weather' table for each season? | SELECT DATE_FORMAT(date, '%Y-%m') AS season, MAX(temperature) AS max_temperature FROM arctic_weather GROUP BY season; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, platform VARCHAR(255), launched DATE); CREATE TABLE earnings (id INT, game_id INT, revenue INT, revenue_date DATE); | What is the total revenue generated from mobile games in the eSports industry for the last year? | SELECT SUM(earnings.revenue) as total_revenue FROM earnings JOIN games ON earnings.game_id = games.id WHERE games.platform = 'Mobile' AND earnings.revenue_date >= (CURRENT_DATE - INTERVAL '1 year'); | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_farms (farm_id INT, name TEXT, location TEXT, size REAL, city TEXT, state TEXT); INSERT INTO urban_farms (farm_id, name, location, size, city, state) VALUES (1, 'Green Acres', '850 10th Ave', 0.5, 'New York', 'NY'), (2, 'Urban Harvest', '154 West 10th St', 0.7, 'New York', 'NY'); | What is the average size of urban farms in New York, NY? | SELECT AVG(size) FROM urban_farms WHERE city = 'New York' AND state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT, project_type VARCHAR(50)); INSERT INTO water_infrastructure (id, project_name, location, cost, project_type) VALUES (1, 'Water Treatment Plant', 'San Francisco', 5000000, 'Water Treatment'); INSERT INTO water_infrastr... | What is the average cost of dam projects in the 'water_infrastructure' table? | SELECT AVG(cost) FROM water_infrastructure WHERE project_type = 'Dam'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_size(customer_id INT, size VARCHAR(10)); INSERT INTO customer_size(customer_id, size) VALUES(1, 'large'), (2, 'medium'), (3, 'extra-large'), (4, 'small'); | What is the total number of orders placed by customers in the 'extra-large' size range? | SELECT COUNT(*) FROM customer_size WHERE size = 'extra-large'; | gretelai_synthetic_text_to_sql |
CREATE TABLE port_vessels (id INT, port VARCHAR(50), vessel_id INT, name VARCHAR(50), speed DECIMAL(5,2)); INSERT INTO port_vessels VALUES (1, 'PortA', 1, 'Vessel1', 25.6), (2, 'PortA', 2, 'Vessel2', 27.3), (3, 'PortB', 3, 'Vessel3', 24.5); | What is the average speed of vessels for each port? | SELECT port, AVG(speed) FROM port_vessels GROUP BY port; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects_category (id INT PRIMARY KEY, project_name TEXT, project_category TEXT, cost FLOAT); INSERT INTO projects_category (id, project_name, project_category, cost) VALUES (1, 'Building Schools', 'Education', 500000); | What's the total cost of all projects in the education category? | SELECT SUM(cost) as total_cost FROM projects_category WHERE project_category = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, department VARCHAR(50)); CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), role VARCHAR(50)); INSERT INTO departments (id, department) VALUES (1, 'hr'), (2, 'operations'), (3, 'it'), (4, 'marketing'), (5, 'research'); | Add a new department 'research' and insert an employee named 'Eli' into it with the 'employee' role and an id of 5. | INSERT INTO employees (id, name, department, role) VALUES (5, 'Eli', 'research', 'employee'); | gretelai_synthetic_text_to_sql |
CREATE TABLE VesselCargoTransactions (id INT, vessel_id INT, cargo_type VARCHAR(20), transaction_time TIMESTAMP); INSERT INTO VesselCargoTransactions (id, vessel_id, cargo_type, transaction_time) VALUES (1, 789, 'Clothing', '2022-03-17 12:30:00'); | Identify the top 3 most frequently used cargo types in the VesselCargoTransactions table, for the last 6 months. | SELECT cargo_type, COUNT(*) as num_transactions FROM VesselCargoTransactions WHERE transaction_time > DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY cargo_type ORDER BY num_transactions DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT PRIMARY KEY, donor_name VARCHAR(255), donation_date DATE, donation_amount FLOAT); | Delete records in the 'Donations' table where the donation amount is less than $50 | DELETE FROM Donations WHERE donation_amount < 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE polar_bear_sightings (sighting_id INT PRIMARY KEY, sighting_date DATE); | show the number of polar bear sightings for each month in 2019 | SELECT EXTRACT(MONTH FROM sighting_date) AS month, COUNT(*) FROM polar_bear_sightings WHERE sighting_date BETWEEN '2019-01-01' AND '2019-12-31' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, UnderwriterID INT); INSERT INTO Policies (PolicyID, UnderwriterID) VALUES (1, 101), (2, 102), (3, 103); CREATE TABLE Underwriters (UnderwriterID INT, Name VARCHAR(50)); INSERT INTO Underwriters (UnderwriterID, Name) VALUES (101, 'John Doe'), (102, 'Jane Smith'), (103, 'Maria Garcia'... | List all policies in California and their respective underwriters | SELECT Policies.PolicyID, Underwriters.Name FROM Policies JOIN Underwriters ON Policies.UnderwriterID = Underwriters.UnderwriterID WHERE Underwriters.State = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists higher_ed;CREATE TABLE if not exists higher_ed.students(id INT, name VARCHAR(255), department VARCHAR(255), gpa DECIMAL(3,2));CREATE TABLE if not exists higher_ed.publications(id INT, title VARCHAR(255), author_id INT); | What is the maximum GPA of graduate students in the Mathematics department who have published at least one paper? | SELECT MAX(s.gpa) FROM higher_ed.students s JOIN higher_ed.publications p ON s.id = p.author_id WHERE s.department = 'Mathematics' GROUP BY s.id HAVING COUNT(p.id) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE emissions (id INT, site VARCHAR(50), year INT, co2_emission FLOAT); | What is the minimum CO2 emission in the 'emissions' table? | SELECT MIN(co2_emission) FROM emissions; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, state VARCHAR(20), year INT, usage FLOAT); CREATE TABLE households (id INT, state VARCHAR(20), year INT, count INT); | What is the average water usage per household in Texas for the year 2020? | SELECT AVG(w.usage) FROM water_usage w INNER JOIN households h ON w.state = h.state AND w.year = h.year WHERE w.state = 'Texas' AND w.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE VIEW sustainable_urbanism AS SELECT properties.id, properties.city, SUM(properties.square_footage) as total_square_footage FROM properties JOIN sustainable_developments ON properties.id = sustainable_developments.id GROUP BY properties.id, properties.city; INSERT INTO properties (id, city, square_footage) VALUES... | What is the average square footage of properties in the 'sustainable_urbanism' view that are located in low-income areas? | SELECT AVG(total_square_footage) FROM sustainable_urbanism WHERE low_income_area = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (permit_id INT, sector VARCHAR(50), quarter INT, year INT); INSERT INTO building_permits (permit_id, sector, quarter, year) VALUES (1, 'Residential', 1, 2021), (2, 'Commercial', 2, 2021), (3, 'Residential', 3, 2021), (4, 'Industrial', 4, 2021); | How many permits were issued in the residential sector in Q1 2021? | SELECT COUNT(permit_id) FROM building_permits WHERE sector = 'Residential' AND quarter = 1 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (trial VARCHAR(255), location VARCHAR(255), year INT); INSERT INTO clinical_trials (trial, location, year) VALUES ('Trial1', 'Germany', 2018), ('Trial2', 'UK', 2019), ('Trial3', 'USA', 2018), ('Trial4', 'Canada', 2017); | How many clinical trials were conducted in Germany in 2018? | SELECT COUNT(*) FROM clinical_trials WHERE location = 'Germany' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, name TEXT); INSERT INTO volunteers (volunteer_id, name) VALUES (1, 'Aarav'), (2, 'Bella'), (3, 'Charlie'); CREATE TABLE cases (case_id INT, volunteer_id INT, date TEXT, resolved_date TEXT); INSERT INTO cases (case_id, volunteer_id, date, resolved_date) VALUES (1, 1, '2022-01-0... | What is the average time taken to resolve cases for each volunteer? | SELECT volunteers.name, AVG(DATEDIFF('day', cases.date, cases.resolved_date)) as average_time_to_resolve FROM volunteers INNER JOIN cases ON volunteers.volunteer_id = cases.volunteer_id GROUP BY volunteers.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, industry TEXT, funding_round_size INT); INSERT INTO startup (id, name, industry, funding_round_size) VALUES (1, 'SocialImpactOne', 'Social Impact', 2000000); INSERT INTO startup (id, name, industry, funding_round_size) VALUES (2, 'TechStart', 'Tech', 10000000); | What is the total funding raised by startups with a social impact focus? | SELECT SUM(funding_round_size) FROM startup WHERE industry = 'Social Impact'; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (id INT, mine_id INT, impact_type VARCHAR(50), value INT, PRIMARY KEY (id), FOREIGN KEY (mine_id) REFERENCES mines(id)); INSERT INTO environmental_impact (id, mine_id, impact_type, value) VALUES (1, 1, 'CO2 Emissions', 1200); INSERT INTO environmental_impact (id, mine_id, impact_type, ... | What is the change in CO2 emissions for each mine over time? | SELECT mine_id, impact_type, value, LAG(value) OVER (PARTITION BY mine_id ORDER BY id) as previous_value FROM environmental_impact; | gretelai_synthetic_text_to_sql |
CREATE TABLE inmates (inmate_id INT, education_level VARCHAR(255), vocational_training BOOLEAN, gender VARCHAR(255)); INSERT INTO inmates (inmate_id, education_level, vocational_training, gender) VALUES (1, 'High School Diploma', TRUE, 'Male'), (2, 'Some College', FALSE, 'Female'); | What is the percentage of inmates who have completed education or vocational training programs, by type and gender? | SELECT education_level, vocational_training, gender, ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY education_level, vocational_training), 2) as pct_completion FROM inmates GROUP BY education_level, vocational_training, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE pacific_ocean_mapping (id INT, location TEXT, depth FLOAT, mapped BOOLEAN); | What is the maximum depth of the ocean floor in the Pacific Ocean that has been mapped? | SELECT MAX(depth) FROM pacific_ocean_mapping WHERE mapped = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_yearly (year INT, element VARCHAR(10), quantity INT); INSERT INTO production_yearly (year, element, quantity) VALUES (2015, 'Samarium', 3000), (2016, 'Samarium', 3500); | What is the average production of Samarium per year? | SELECT year, AVG(quantity) as avg_quantity FROM production_yearly WHERE element = 'Samarium' GROUP BY year | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (employee_id INT, state VARCHAR(2), job_title VARCHAR(50), employment_date DATE); | Identify unique job titles held by veterans in the 'veteran_employment' table | SELECT DISTINCT job_title FROM veteran_employment WHERE state IN ('CA', 'NY', 'TX', 'FL', 'PA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, factory_name VARCHAR(20)); INSERT INTO factories VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2)); INSERT INTO workers VALUES (1, 1, 35000.00), (2, 1, 36000.00), (3, 2, 45000.00), (4, 3, 34000.0... | How many workers are there in each factory, and what are their total salaries? | SELECT f.factory_name, COUNT(*), SUM(salary) FROM workers w INNER JOIN factories f ON w.factory_id = f.factory_id GROUP BY f.factory_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocations (Year INT, Service TEXT, Amount INT); INSERT INTO BudgetAllocations (Year, Service, Amount) VALUES (2019, 'PublicTransportation', 14000000), (2020, 'PublicTransportation', 15000000); | What was the total budget allocated for public transportation in 2019 and 2020, and which year had a lower allocation? | SELECT Year, SUM(Amount) FROM BudgetAllocations WHERE Service = 'PublicTransportation' GROUP BY Year HAVING Year IN (2019, 2020) ORDER BY SUM(Amount) LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (name TEXT, capacity INTEGER); INSERT INTO solar_plants (name, capacity) VALUES ('Plant A', 300), ('Plant B', 600); | How many solar power plants are there in the 'solar_plants' table? | SELECT COUNT(*) FROM solar_plants; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster (disaster_id INT, name TEXT, location TEXT, donations_received FLOAT); INSERT INTO disaster (disaster_id, name, location, donations_received) VALUES (1, 'Flood', 'USA', 500000.0), (2, 'Earthquake', 'Nepal', 200000.0), (3, 'Tornado', 'USA', 80000.0); | What is the average amount of donations received per disaster? | SELECT AVG(donations_received) FROM disaster; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (Id INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations VALUES (1, '2022-01-01', 50.00), (2, '2022-01-01', 100.00); | What's the average donation amount per day? | SELECT AVG(Amount) as AvgDonation, DATE_TRUNC('day', DonationDate) as DonationDay FROM Donations GROUP BY DonationDay; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales_9 (id INT, region VARCHAR, year INT, value FLOAT); | Find the average value of military equipment sales for each region in 2022 | SELECT region, AVG(value) AS avg_value FROM military_sales_9 WHERE year = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureProjects (ProjectID int, State varchar(2), CompletionDate date); INSERT INTO InfrastructureProjects (ProjectID, State, CompletionDate) VALUES (1, 'CA', '2021-12-31'), (2, 'NY', '2022-03-15'), (3, 'CA', '2022-08-05'); | Which infrastructure projects were completed in California? | SELECT ProjectID, State FROM InfrastructureProjects WHERE State = 'CA' AND YEAR(CompletionDate) = YEAR(GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_residential_water_usage (region VARCHAR(20), water_consumption FLOAT, usage_date DATE); INSERT INTO monthly_residential_water_usage (region, water_consumption, usage_date) VALUES ('United States', 50000000, '2022-01-01'), ('United States', 60000000, '2022-02-01'), ('United States', 70000000, '2022-... | What is the total water consumption in the residential sector in the United States for the year 2022, excluding the months of June, July, and August? | SELECT SUM(water_consumption) FROM monthly_residential_water_usage WHERE region = 'United States' AND usage_date < '2022-06-01' AND usage_date >= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE municipal_facilities (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO municipal_facilities (id, state, water_usage) VALUES (1, 'Florida', 250), (2, 'Florida', 300), (3, 'Florida', 220); | What is the maximum water usage in municipal facilities in Florida? | SELECT MAX(water_usage) FROM municipal_facilities WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, law_degree VARCHAR(50), success BOOLEAN); INSERT INTO attorneys (attorney_id, law_degree, success) VALUES (1, 'Harvard University', TRUE), (2, 'Yale University', TRUE), (3, 'Harvard University', FALSE); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_i... | What is the success rate of cases handled by attorneys with a law degree from Harvard University? | SELECT AVG(success) FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.law_degree = 'Harvard University'; | gretelai_synthetic_text_to_sql |
CREATE TABLE StreamingData (StreamID INT, UserID INT, SongID INT, StreamDate DATE); INSERT INTO StreamingData VALUES (1, 1, 1001, '2022-01-01'); INSERT INTO StreamingData VALUES (2, 2, 1002, '2022-01-02'); CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), ArtistID INT); INSERT INTO Songs VALUES (1001, 'Shake It Of... | What is the number of unique users who have streamed a specific song? | SELECT COUNT(DISTINCT UserID) FROM StreamingData JOIN Songs ON StreamingData.SongID = Songs.SongID WHERE Songs.SongName = 'Shake It Off'; | 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.