context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Exhibition_Demographics (id INT, exhibition VARCHAR(20), visitor_count INT, disability VARCHAR(20)); INSERT INTO Exhibition_Demographics (id, exhibition, visitor_count, disability) VALUES (1, 'Pop Art', 1000, 'Yes'), (2, 'Ancient Civilizations', 1200, 'No'), (3, 'Pop Art', 1500, 'No'), (4, 'Ancient Civiliz... | What percentage of visitors to each exhibition identified as having a disability? | SELECT exhibition, (SUM(CASE WHEN disability = 'Yes' THEN visitor_count ELSE 0 END) * 100.0 / SUM(visitor_count)) AS pct_disability FROM Exhibition_Demographics GROUP BY exhibition; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_consumption (country VARCHAR(20), year INT, consumption FLOAT); INSERT INTO water_consumption (country, year, consumption) VALUES ('Indonesia', 2017, 34000000); | What is the total water consumption in Indonesia in 2017? | SELECT consumption FROM water_consumption WHERE country = 'Indonesia' AND year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_data (contributor VARCHAR(20), recycling_rate FLOAT); INSERT INTO recycling_data (contributor, recycling_rate) VALUES ('Contributor A', 0.35), ('Contributor B', 0.27), ('Contributor C', 0.4), ('Contributor D', NULL); | Update the recycling rate for 'Contributor D' to 0.3 in the 'recycling_data' table. | UPDATE recycling_data SET recycling_rate = 0.3 WHERE contributor = 'Contributor D'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO Brands (BrandID, BrandName) VALUES (1, 'H&M'), (2, 'Zara'), (3, 'Levi''s'); CREATE TABLE Materials (MaterialID INT, MaterialName VARCHAR(50), BrandID INT, QuantityUsed INT, TotalQuantity INT); INSERT INTO Materials (MaterialID, MaterialName, BrandID,... | What is the percentage of sustainable material used out of the total material used by each brand? | SELECT BrandName, (SUM(QuantityUsed) * 100.0 / SUM(TotalQuantity)) AS Percentage FROM Materials GROUP BY BrandName; | gretelai_synthetic_text_to_sql |
CREATE TABLE missions(name TEXT, agency TEXT, launch_date TEXT, joint_mission BOOLEAN); INSERT INTO missions(name, agency, launch_date, joint_mission) VALUES('Apollo 11', 'NASA', '1969-07-16', FALSE), ('Apollo-Soyuz', 'NASA', '1975-07-15', TRUE); | How many space missions were joint missions? | SELECT COUNT(*) FROM missions WHERE joint_mission = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm (farm_id INT, country VARCHAR(50), production DECIMAL(10,2)); INSERT INTO Farm (farm_id, country, production) VALUES (1, 'Norway', 5000.5), (2, 'Chile', 3500.3), (3, 'Canada', 2000.0); | How many aquaculture farms are located in each country and their total production in metric tons? | SELECT Farm.country, COUNT(Farm.farm_id) as NumFarms, SUM(Farm.production) as TotalProduction FROM Farm GROUP BY Farm.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE mars_rovers (id INT, rover_name VARCHAR(50), agency VARCHAR(50), status VARCHAR(20)); INSERT INTO mars_rovers (id, rover_name, agency, status) VALUES (1, 'Spirit', 'NASA', 'decommissioned'), (2, 'Opportunity', 'NASA', 'decommissioned'), (3, 'Curiosity', 'NASA', 'active'); | How many Mars rovers have been deployed by NASA? | SELECT COUNT(*) FROM mars_rovers WHERE agency = 'NASA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity_violations (violation_id INT, region VARCHAR(255), score INT); INSERT INTO mental_health_parity_violations (violation_id, region, score) VALUES (1, 'Northeast', 80), (2, 'Southeast', 70), (3, 'Midwest', 60), (4, 'West', 90), (5, 'Northeast', 85), (6, 'Southeast', 75), (7, 'Midwest', 65... | What is the average mental health parity violation score for facilities in the Midwest region? | SELECT AVG(score) as avg_score FROM mental_health_parity_violations WHERE region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GamePlay (PlayerID INT, GameID INT); INSERT INTO GamePlay (PlayerID, GameID) VALUES (2, 2); CREATE TABLE Games (GameID INT, Name VARCHAR(50), Genre VARCHAR(20), ReleaseDate DATETIME, Publisher VARCHAR(50)); INSERT INTO Games (GameID, Name, Genre, ReleaseDate, Publisher) VALUES (4, 'The Elder Scrolls V: Sk... | What is the earliest release date for a game with a genre of 'Role-playing' and the number of players who have played it? | SELECT MIN(ReleaseDate) AS Earliest_Release_Date, COUNT(DISTINCT gp.PlayerID) FROM Games g INNER JOIN GamePlay gp ON g.GameID = gp.GameID WHERE g.Genre = 'Role-playing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_exploration ( id INT, mission_name VARCHAR(255), country VARCHAR(255), success BOOLEAN ); | How many space missions have been attempted by India? | SELECT COUNT(*) FROM space_exploration WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (clinic_location VARCHAR(255), patient_wait_time INT); INSERT INTO rural_clinics (clinic_location, patient_wait_time) VALUES ('Location1', 15), ('Location1', 20), ('Location1', 25), ('Location2', 10), ('Location2', 12), ('Location3', 30), ('Location3', 35), ('Location3', 40); | Find the clinic location with the highest total patient wait time, in the "rural_clinics" table with patient wait time data. | SELECT clinic_location, SUM(patient_wait_time) AS total_wait_time FROM rural_clinics GROUP BY clinic_location ORDER BY total_wait_time DESC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streaming (user INT, song VARCHAR(50), streams INT); INSERT INTO Streaming (user, song, streams) VALUES (1, 'Shape of You', 10), (1, 'Bad Guy', 5), (2, 'Shape of You', 7), (2, 'Bad Guy', 8), (3, 'Shape of You', 9), (3, 'Bad Guy', 6); | What was the average number of streams per user for a specific song? | SELECT song, AVG(streams) FROM Streaming GROUP BY song; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArtists (id INT, name VARCHAR(50), art VARCHAR(50), country VARCHAR(50)); | Identify the traditional art forms that are unique to each country. | SELECT art, country FROM TraditionalArtists GROUP BY art, country HAVING COUNT(*) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_complaints (complaint_id INT, complaint_category VARCHAR(50), region VARCHAR(50), complaint_date DATE); INSERT INTO customer_complaints (complaint_id, complaint_category, region, complaint_date) VALUES (1, 'Billing', 'Asia-Pacific', '2023-03-01'), (2, 'Network', 'Asia-Pacific', '2023-03-05'), (3, ... | What is the distribution of customer complaints by category in the 'Asia-Pacific' region in the past month? | SELECT region, complaint_category, COUNT(*) as complaint_count, PERCENT_RANK() OVER (PARTITION BY region ORDER BY complaint_count DESC) as complaint_percentile FROM customer_complaints WHERE region = 'Asia-Pacific' AND complaint_date >= CURRENT_DATE - INTERVAL '1 month' GROUP BY region, complaint_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (Id INT, Name TEXT, Country TEXT); INSERT INTO HeritageSites (Id, Name, Country) VALUES (1, 'Angkor Wat', 'Thailand'); | Update the country of 'Angkor Wat' to 'Cambodia' | UPDATE HeritageSites SET Country = 'Cambodia' WHERE Name = 'Angkor Wat'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, exhibition_name VARCHAR(50), start_date DATE, end_date DATE); | Insert a new record for an exhibition 'Indigenous Art' starting from 2025-01-01 until 2025-12-31. | INSERT INTO Exhibitions (exhibition_id, exhibition_name, start_date, end_date) VALUES (5, 'Indigenous Art', '2025-01-01', '2025-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (id INT, name VARCHAR, facility_type VARCHAR); INSERT INTO facilities (id, name, facility_type) VALUES (1, 'Rural General Hospital', 'hospital'), (2, 'Urban Community Clinic', 'clinic'), (3, 'Remote Pharmacy', 'pharmacy'); CREATE TABLE state_codes (id INT, state VARCHAR, country VARCHAR); INSERT... | List the number of hospitals, clinics, and pharmacies in each state of Mexico, sorted by the total number of rural healthcare facilities. | SELECT state_codes.country, state_codes.state, COUNT(facilities.id), SUM(facilities.id) FROM facilities INNER JOIN state_codes ON facilities.id = state_codes.id AND facilities.facility_type IN ('hospital', 'clinic', 'pharmacy') GROUP BY state_codes.country, state_codes.state ORDER BY SUM(facilities.id) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE msy (species VARCHAR(255), msy_value FLOAT, year INT, region VARCHAR(255), PRIMARY KEY (species, year, region)); INSERT INTO msy (species, msy_value, year, region) VALUES ('Tilapia', 25000, 2022, 'Mediterranean'), ('Tuna', 30000, 2022, 'Mediterranean'), ('Salmon', 15000, 2022, 'North Atlantic'); | What is the maximum sustainable yield of Tilapia in the Mediterranean in 2022? | SELECT msy_value FROM msy WHERE species = 'Tilapia' AND year = 2022 AND region = 'Mediterranean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices_3 (practice_id INT, state VARCHAR(20), building_type VARCHAR(20), description TEXT); INSERT INTO sustainable_practices_3 (practice_id, state, building_type, description) VALUES (1, 'WA', 'Residential', 'Use of recycled materials'), (2, 'WA', 'Commercial', 'Solar panel installations'),... | List all sustainable building practices in Washington state, with their respective descriptions | SELECT * FROM sustainable_practices_3 WHERE state = 'WA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tech_social_good (project VARCHAR(255), budget FLOAT, region VARCHAR(255)); INSERT INTO tech_social_good (project, budget, region) VALUES ('Project X', 800000, 'APAC'), ('Project Y', 650000, 'APAC'), ('Project Z', 700000, 'EMEA'), ('Project W', 500000, 'APAC'); | List the top 2 technology for social good projects by budget in the APAC region? | SELECT project, budget FROM (SELECT project, budget, RANK() OVER (PARTITION BY region ORDER BY budget DESC) AS rank FROM tech_social_good WHERE region = 'APAC') WHERE rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (id INT, name TEXT, speed FLOAT, depart_port TEXT, arrive_port TEXT); INSERT INTO Vessels (id, name, speed, depart_port, arrive_port) VALUES (1, 'Vessel1', 22.5, 'Port C', 'Port D'); INSERT INTO Vessels (id, name, speed, depart_port, arrive_port) VALUES (2, 'Vessel2', 27.0, 'Port C', 'Port D'); | What is the maximum speed recorded for vessels traveling from Port C to Port D? | SELECT MAX(speed) FROM Vessels WHERE depart_port = 'Port C' AND arrive_port = 'Port D'; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT, num_students INT); CREATE TABLE activities (activity_id INT, activity_name TEXT, district_id INT, student_id INT, hours_spent INT); INSERT INTO districts (district_id, district_name, num_students) VALUES (1, 'North District', 500), (2, 'South District', 400),... | What is the minimum number of hours spent by students in lifelong learning activities in each district? | SELECT district_name, MIN(hours_spent) as min_hours FROM districts JOIN activities ON districts.district_id = activities.district_id GROUP BY district_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, sustainability_rating INT); INSERT INTO hotels (hotel_id, hotel_name, city, sustainability_rating) VALUES (1, 'Hotel A', 'New York', 3), (2, 'Hotel B', 'New York', NULL), (3, 'Hotel C', 'New York', 5); | How many hotels in New York have achieved a sustainability rating? | SELECT COUNT(*) FROM hotels WHERE city = 'New York' AND sustainability_rating IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, country TEXT, cancer_treatment BOOLEAN); | What is the total number of hospitals in Mexico providing cancer treatment? | SELECT COUNT(*) FROM hospitals WHERE country = 'Mexico' AND cancer_treatment = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_efforts (id INT, species VARCHAR(50), year INT, protected_area VARCHAR(50), efforts VARCHAR(50)); INSERT INTO conservation_efforts (id, species, year, protected_area, efforts) VALUES (1, 'Green Sea Turtle', 2010, 'Galapagos Marine Reserve', 'Habitat protection'); INSERT INTO conservation_effor... | How many conservation efforts have been implemented for turtles? | SELECT SUM(CASE WHEN species LIKE '%Turtle%' THEN 1 ELSE 0 END) FROM conservation_efforts; | gretelai_synthetic_text_to_sql |
CREATE TABLE galleries (id INT, name TEXT, location TEXT, city TEXT, state TEXT, zip INT); INSERT INTO galleries (id, name, location, city, state, zip) VALUES (1, 'Gallery A', 'Central Business District', 'Los Angeles', 'CA', 90001); CREATE TABLE artists (id INT, name TEXT, age INT, gallery_id INT); INSERT INTO artists... | What is the average age of artists who have exhibited in galleries located in the Central Business District? | SELECT AVG(age) FROM artists JOIN galleries ON artists.gallery_id = galleries.id WHERE galleries.location = 'Central Business District'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_fire (id INT, call_type VARCHAR(20), call_date TIMESTAMP); INSERT INTO rural_fire VALUES (1, 'fire', '2022-01-01 15:00:00'), (2, 'fire', '2022-01-03 16:00:00'); | How many calls were made before '2022-01-02' in the 'rural_fire' table? | SELECT COUNT(*) FROM rural_fire WHERE call_date < '2022-01-02'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_reservations (reservation_id INT, hotel_id INT, guest_name TEXT, arrival_date DATE, departure_date DATE, num_guests INT, payment_amount FLOAT, is_cancelled BOOLEAN); | List all the columns in table 'hotel_reservations' | SELECT * FROM hotel_reservations; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, month INT, quantity INT); INSERT INTO production (element, year, month, quantity) VALUES ('Yttrium', 2015, 1, 40), ('Yttrium', 2015, 2, 45), ('Yttrium', 2016, 1, 50), ('Yttrium', 2016, 2, 55), ('Samarium', 2015, 1, 60), ('Samarium', 2015, 2, 65), ('Samarium', 2016... | Show the unique months in which Yttrium and Samarium had the highest production quantity | SELECT element, month FROM (SELECT element, month, ROW_NUMBER() OVER (PARTITION BY element ORDER BY quantity DESC) AS rn FROM production WHERE element IN ('Yttrium', 'Samarium')) t WHERE rn = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClientDemographics (ClientID INT, Age INT, Won BOOLEAN); INSERT INTO ClientDemographics (ClientID, Age, Won) VALUES (1, 35, TRUE), (2, 45, FALSE); | What is the average age of clients who won their cases? | SELECT AVG(ClientDemographics.Age) FROM ClientDemographics WHERE ClientDemographics.Won = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE potatoes (id INT, state VARCHAR(20), variety VARCHAR(20), yield INT); INSERT INTO potatoes (id, state, variety, yield) VALUES (1, 'Idaho', 'Russet', 2000), (2, 'Idaho', 'Red', 1800), (3, 'Idaho', 'Yukon Gold', 2200), (4, 'Idaho', 'Russet', 2100), (5, 'Idaho', 'Red', 1900); | What is the average yield of potatoes in Idaho, broken down by variety? | SELECT variety, AVG(yield) FROM potatoes WHERE state = 'Idaho' GROUP BY variety; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255), habitat VARCHAR(255)); | Delete the record with ID 3 from the marine_species table | WITH deleted_species AS (DELETE FROM marine_species WHERE id = 3 RETURNING *) SELECT * FROM deleted_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE cruise_ships (id INT, name TEXT, passengers INT, registry TEXT); | What is the maximum number of passengers allowed on cruise ships registered in the Baltic Sea? | SELECT MAX(passengers) FROM cruise_ships WHERE registry = 'Baltic Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT);CREATE TABLE shipments (shipment_id INT, shipment_weight INT, ship_date DATE, port_id INT); INSERT INTO ports VALUES (1, 'Port of Oakland', 'USA'), (2, 'Port of Rotterdam', 'Netherlands'); INSERT INTO shipments VALUES (1, 2000, '2019-01-01', 1), (2, 1500, '... | How many containers were shipped from the US to the Netherlands in Q1 of 2019? | SELECT COUNT(*) FROM shipments JOIN ports ON shipments.port_id = ports.port_id WHERE ports.country = 'USA' AND ports.port_name = 'Port of Oakland' AND ship_date BETWEEN '2019-01-01' AND '2019-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_communication_data (id INT, initiative_name VARCHAR(50), year INT, trees_planted INT); INSERT INTO climate_communication_data (id, initiative_name, year, trees_planted) VALUES (1, 'Tree Planting Initiative 1', 2018, 25000); INSERT INTO climate_communication_data (id, initiative_name, year, trees_pl... | What is the total number of trees planted as part of climate communication initiatives in 2018? | SELECT SUM(trees_planted) FROM climate_communication_data WHERE initiative_name LIKE '%Tree Planting%' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE UrbanResidents (ResidentID INT, EducationLevel VARCHAR(20), Income FLOAT); CREATE TABLE HigherEducation (ResidentID INT, Degree VARCHAR(20)); INSERT INTO UrbanResidents VALUES (1, 'Bachelor', 60000), (2, 'Master', 75000), (3, 'Associate', 50000); INSERT INTO HigherEducation VALUES (1, 'Bachelor'), (2, 'Mas... | What is the average income of residents in urban areas who have completed higher education? | SELECT AVG(UrbanResidents.Income) FROM UrbanResidents INNER JOIN HigherEducation ON UrbanResidents.ResidentID = HigherEducation.ResidentID WHERE UrbanResidents.EducationLevel = 'Bachelor' OR UrbanResidents.EducationLevel = 'Master'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_category VARCHAR(20), user_followers INT); CREATE TABLE posts (post_id INT, user_id INT, post_category VARCHAR(20), post_date DATE); | What is the maximum number of followers for users in the 'celebrity' category from the 'users' table, who have posted in the 'music' category from the 'posts' table, in the past 90 days? | SELECT MAX(user_followers) FROM (SELECT user_followers FROM users WHERE user_category = 'celebrity' AND user_id IN (SELECT user_id FROM posts WHERE post_category = 'music' AND post_date >= CURDATE() - INTERVAL 90 DAY)) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment_model VARCHAR(255), quantity INT, sale_date DATE); | What is the total quantity of military equipment sold to 'African Union' by 'Alpha Corp' and 'Beta Corp' combined? | SELECT SUM(quantity) FROM (SELECT quantity FROM MilitaryEquipmentSales WHERE seller = 'Alpha Corp' AND buyer = 'African Union' UNION ALL SELECT quantity FROM MilitaryEquipmentSales WHERE seller = 'Beta Corp' AND buyer = 'African Union') AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE soldiers_personal_data (soldier_id INT, name VARCHAR(50), rank VARCHAR(50), departure_date DATE, discharge_type VARCHAR(50)); | Delete all records of soldiers who were dishonorably discharged from the soldiers_personal_data table | DELETE FROM soldiers_personal_data WHERE discharge_type = 'dishonorable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name VARCHAR(50)); CREATE TABLE accessible_tech_patents (id INT, organization_id INT, patents INT); INSERT INTO organizations (id, name) VALUES (1, 'Microsoft'), (2, 'Google'), (3, 'IBM'), (4, 'Oracle'), (5, 'SAP'); INSERT INTO accessible_tech_patents (id, organization_id, patents) V... | Who are the top 3 organizations with the highest number of accessible technology patents, and what is their total number of patents? | SELECT organizations.name, SUM(accessible_tech_patents.patents) as total_patents FROM organizations INNER JOIN accessible_tech_patents ON organizations.id = accessible_tech_patents.organization_id GROUP BY organizations.name ORDER BY total_patents DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (volunteer_id INT, volunteer_name VARCHAR(50), program_id INT, volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (volunteer_id, volunteer_name, program_id, volunteer_hours, volunteer_date) VALUES (1, 'Sophia', 1, 5, '2022-06-05'), (2, 'James', 2, 8, '2022-04-12'), (3, 'Leila', 1,... | How many unique volunteers contributed to each program in 2022? | SELECT program_id, COUNT(DISTINCT volunteer_id) as unique_volunteers_per_program_in_2022 FROM Volunteers WHERE volunteer_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, region TEXT, donation_amount DECIMAL(10,2)); INSERT INTO donors (id, name, region, donation_amount) VALUES (1, 'John Smith', 'Asia-Pacific', 500.00), (2, 'Jane Doe', 'Europe', 1500.00), (3, 'James Lee', 'Middle East', 3000.00), (4, 'Fatima Al-Faisal', 'Middle East', 4000.00), (5,... | What's the total donation amount for each region, excluding the top 2 donors in each region? | SELECT region, SUM(donation_amount) FROM donors d1 WHERE donation_amount < (SELECT DISTINCT donation_amount FROM donors d2 WHERE d1.region = d2.region ORDER BY donation_amount DESC LIMIT 2 OFFSET 1) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (UserID INT, MemberSince DATE, MembershipLength INT); INSERT INTO Members (UserID, MemberSince, MembershipLength) VALUES (1, '2021-01-01', 7), (2, '2021-02-01', 6), (3, '2020-12-01', 12); | Count the number of users who joined in the year 2021 and have a membership longer than 6 months. | SELECT COUNT(*) FROM Members WHERE YEAR(MemberSince) = 2021 AND MembershipLength > 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT PRIMARY KEY, name TEXT, age INT); INSERT INTO students (id, name, age) VALUES (1, 'John Doe', 18), (2, 'Jane Smith', 20); CREATE TABLE courses (id INT PRIMARY KEY, student_id INT, course_name TEXT); INSERT INTO courses (id, student_id, course_name) VALUES (1, 1, 'Math'), (2, 1, 'Science'),... | Delete records of students who have not taken any courses | DELETE FROM students WHERE id NOT IN (SELECT student_id FROM courses); | gretelai_synthetic_text_to_sql |
CREATE TABLE Publications (PublicationID int, FacultyID int, Topic varchar(50)); INSERT INTO Publications (PublicationID, FacultyID, Topic) VALUES (1, 1, 'Quantum Mechanics'); INSERT INTO Publications (PublicationID, FacultyID, Topic) VALUES (2, 2, 'Particle Physics'); CREATE TABLE Faculty (FacultyID int, Department va... | List all the unique research topics that faculty members in the 'Physics' department have published on. | SELECT DISTINCT Publications.Topic FROM Publications INNER JOIN Faculty ON Publications.FacultyID = Faculty.FacultyID WHERE Faculty.Department = 'Physics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255)); INSERT INTO donors (id, name) VALUES (1, 'Doctors Without Borders'), (2, 'Heart Foundation'), (3, 'Cancer Relief'); CREATE TABLE donation_details (donor_id INT, category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donation_details (donor_id, category, amount) VALUE... | Find the average donation amount per donor for donations made in the 'health' category. | SELECT donors.name, AVG(donation_details.amount) AS avg_donation FROM donors INNER JOIN donation_details ON donors.id = donation_details.donor_id WHERE category = 'health' GROUP BY donors.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (employee_id INT, name VARCHAR(50), age INT, position VARCHAR(50), country VARCHAR(50)); INSERT INTO mining_operations (employee_id, name, age, position, country) VALUES (1, 'John Doe', 35, 'Engineer', 'USA'); INSERT INTO mining_operations (employee_id, name, age, position, country) VALUE... | What is the number of employees working in each country in the 'mining_operations' and 'workforce_diversity' tables? | SELECT mining_operations.country, COUNT(*) FROM mining_operations INNER JOIN workforce_diversity ON mining_operations.employee_id = workforce_diversity.employee_id GROUP BY mining_operations.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_os (id INT, country VARCHAR(50), os_name VARCHAR(50), num_users INT); | What is the most popular mobile operating system in each country? | SELECT country, os_name, MAX(num_users) FROM mobile_os GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories_ext (id INT, name VARCHAR(50), country VARCHAR(50), sector VARCHAR(50), is_circular BOOLEAN); INSERT INTO factories_ext (id, name, country, sector, is_circular) VALUES (1, 'Solar Factory', 'Germany', 'renewable energy', TRUE), (2, 'Wind Factory', 'China', 'renewable energy', TRUE), (3, 'Coal Fact... | What are the top 5 countries with the highest number of factories in the 'circular economy' sector? | SELECT country, COUNT(*) as factory_count FROM factories_ext WHERE is_circular = TRUE GROUP BY country ORDER BY factory_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (project_name VARCHAR(50), country VARCHAR(50), implementation_year INT); INSERT INTO green_buildings (project_name, country, implementation_year) VALUES ('ProjectA', 'Australia', 2019), ('ProjectB', 'Australia', 2018), ('ProjectC', 'Australia', 2020); | Delete all Green building projects in Australia that were implemented before 2018. | DELETE FROM green_buildings WHERE country = 'Australia' AND implementation_year < 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (menu_item VARCHAR(255), initial_inventory INT, final_inventory INT, COST DECIMAL(10,2)); INSERT INTO inventory (menu_item, initial_inventory, final_inventory, COST) VALUES ('Bruschetta', 50, 25, 10.00), ('Spaghetti Bolognese', 100, 50, 20.00), ('Cheesecake', 75, 55, 15.00); | What is the inventory turnover rate for each menu item? | SELECT menu_item, (SUM(initial_inventory) + SUM(final_inventory))/2 as average_inventory, SUM(initial_inventory - final_inventory) as total_sold, SUM(initial_inventory - final_inventory) * COST as total_cost FROM inventory GROUP BY menu_item; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_sourcing (ingredient_name VARCHAR(255), sourcing_location VARCHAR(255), last_updated DATE); INSERT INTO ingredient_sourcing (ingredient_name, sourcing_location, last_updated) VALUES ('Palm Oil', 'Non-Organic Farm, Brazil', '2022-03-01'), ('Microplastics', 'Lab, USA', '2022-02-15'), ('Parabens', ... | Which ingredients have been sourced from non-organic farms for cosmetic products in the past year? | SELECT ingredient_name FROM ingredient_sourcing WHERE sourcing_location NOT LIKE '%Organic Farm%' AND last_updated >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_organizations (org_id INT, org_name VARCHAR(255), PRIMARY KEY (org_id)); CREATE TABLE org_cases (org_id INT, case_id INT, PRIMARY KEY (org_id, case_id), FOREIGN KEY (org_id) REFERENCES legal_organizations(org_id), FOREIGN KEY (case_id) REFERENCES cases(case_id)); INSERT INTO legal_organizations (org_... | Show the number of cases handled by each legal organization in the justice system | SELECT o.org_name, COUNT(oc.org_id) FROM legal_organizations o INNER JOIN org_cases oc ON o.org_id = oc.org_id GROUP BY o.org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (advisory_id INT, country TEXT, year INT, reason TEXT); INSERT INTO travel_advisories (advisory_id, country, year, reason) VALUES (1, 'Canada', 2021, 'Health'), (2, 'Mexico', 2021, 'Political'), (3, 'USA', 2021, 'Safety'), (4, 'Canada', 2022, 'Safety'), (5, 'Mexico', 2022, 'Natural Disast... | How many travel advisories were issued in 2021 and 2022? | SELECT YEAR, COUNT(*) FROM travel_advisories WHERE YEAR IN (2021, 2022) GROUP BY YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title TEXT, length FLOAT, genre TEXT); INSERT INTO songs (id, title, length, genre) VALUES (1, 'Song1', 245.6, 'Pop'), (2, 'Song2', 189.3, 'Rock'), (3, 'Song3', 215.9, 'Pop'); | What is the average length of songs (in seconds) in the pop genre? | SELECT AVG(length) FROM songs WHERE genre = 'Pop'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_storage (id INT PRIMARY KEY, chemical_name VARCHAR(255), storage_temperature FLOAT);INSERT INTO chemical_storage (id, chemical_name, storage_temperature) VALUES (2, 'Nitric Acid', -20); | What is the storage temperature for Nitric Acid? | SELECT storage_temperature FROM chemical_storage WHERE chemical_name = 'Nitric Acid'; | gretelai_synthetic_text_to_sql |
CREATE TABLE decentralized_applications (id INT, name VARCHAR, developer_country VARCHAR); INSERT INTO decentralized_applications (id, name, developer_country) VALUES (1, 'DA1', 'India'), (2, 'DA2', 'USA'), (3, 'DA3', 'Germany'), (4, 'DA4', 'Brazil'), (5, 'DA5', 'India'), (6, 'DA6', 'Nigeria'); | What is the total number of decentralized applications created by developers from India? | SELECT COUNT(*) FROM decentralized_applications WHERE developer_country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecrafts (Spacecraft_ID INT, Name VARCHAR(255), Manufacturer VARCHAR(255), Mass FLOAT); INSERT INTO Spacecrafts (Spacecraft_ID, Name, Manufacturer, Mass) VALUES (1, 'Galactic Explorer', 'Galactic Instruments', 4500.2), (2, 'Nebula One', 'AstroTech', 2000.5), (3, 'Stellar Voyager', 'Cosmos Inc', 6000.0),... | What is the total mass of spacecraft manufactured by 'Cosmos Inc'? | SELECT SUM(Mass) FROM Spacecrafts WHERE Manufacturer = 'Cosmos Inc'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation(project_name TEXT, country TEXT, budget FLOAT); INSERT INTO climate_mitigation(project_name, country, budget) VALUES ('Project E', 'Jamaica', 100000.00), ('Project F', 'Barbados', 150000.00), ('Project G', 'Cuba', 120000.00), ('Project H', 'Trinidad and Tobago', 180000.00); | What is the average budget for climate mitigation projects in the Caribbean? | SELECT AVG(budget) FROM climate_mitigation WHERE country IN ('Jamaica', 'Barbados', 'Cuba', 'Trinidad and Tobago'); | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT, location VARCHAR(20), total_inventory DECIMAL(10,2)); INSERT INTO warehouse (id, location, total_inventory) VALUES (1, 'Atlanta', 2000.00), (2, 'Dallas', 3000.00), (3, 'Houston', 1500.00); | List all warehouse locations and their corresponding total inventory value, sorted by inventory value in descending order. | SELECT location, total_inventory FROM warehouse ORDER BY total_inventory DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_pollution (location VARCHAR(255), pollution_level FLOAT); INSERT INTO ocean_pollution (location, pollution_level) VALUES ('Pacific Ocean', 7.5), ('Atlantic Ocean', 6.2); | What is the minimum pollution level recorded in the Atlantic Ocean? | SELECT MIN(pollution_level) FROM ocean_pollution WHERE location = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (region VARCHAR(255), incident_date DATE); INSERT INTO security_incidents (region, incident_date) VALUES ('North America', '2022-01-01'), ('Europe', '2022-02-01'), ('Asia', '2022-03-01'), ('Asia', '2022-04-01'), ('Africa', '2022-05-01'); | How many security incidents were reported in each region in the last month? | SELECT region, COUNT(*) as incident_count FROM security_incidents WHERE incident_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE support_programs (program_id INT, program_name VARCHAR(30), budget DECIMAL(10,2), initiation_date DATE); INSERT INTO support_programs (program_id, program_name, budget, initiation_date) VALUES (1, 'Mobility Support', 25000, '2021-01-01'), (2, 'Assistive Technology', 30000, '2020-06-15'), (3, 'Note Taking',... | Calculate the total budget for support programs in the past year | SELECT SUM(budget) FROM support_programs WHERE initiation_date >= '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, account_risk_level VARCHAR(10), region VARCHAR(20), num_investments INT); INSERT INTO investments (id, account_risk_level, region, num_investments) VALUES (1, 'high', 'Latin America', 3), (2, 'medium', 'North America', 2), (3, 'low', 'Europe', 1), (4, 'high', 'Asia-Pacific', 4); | What is the maximum number of investments for high-risk accounts in the Latin America region? | SELECT MAX(num_investments) FROM investments WHERE account_risk_level = 'high' AND region = 'Latin America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT, name VARCHAR(255), population INT, endangered BOOLEAN, region VARCHAR(255)); INSERT INTO animals (id, name, population, endangered, region) VALUES (1, 'African Elephant', 400000, true, 'Africa'), (2, 'Lion', 20000, false, 'Africa'); | What is the total population of endangered animals in Africa? | SELECT SUM(population) FROM animals WHERE endangered = true AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenses (drug_name TEXT, rd_expenses INTEGER); INSERT INTO rd_expenses (drug_name, rd_expenses) VALUES ('Vac1', 200000000), ('Vac2', 350000000), ('Vac3', 425000000); CREATE TABLE vaccine_sales (drug_name TEXT, sales INTEGER); INSERT INTO vaccine_sales (drug_name, sales) VALUES ('Vac1', 600000000), ('Va... | What are the total R&D expenses for vaccines with sales greater than $500 million? | SELECT SUM(rd_expenses) FROM rd_expenses INNER JOIN vaccine_sales ON rd_expenses.drug_name = vaccine_sales.drug_name WHERE sales > 500000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_programs (id INT PRIMARY KEY, program_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, capacity INT); INSERT INTO training_programs (id, program_name, location, start_date, end_date, capacity) VALUES (1, 'SQL Fundamentals', 'New York City', '2023-04-01', '2023-04-05', 50),... | Show the number of training programs in each location from 'training_programs' | SELECT location, COUNT(*) FROM training_programs GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (Brand_ID INT PRIMARY KEY, Brand_Name TEXT); CREATE TABLE Safety_Inspections (Inspection_ID INT PRIMARY KEY, Brand_ID INT, Inspection_Date DATE, Compliance_Rating TEXT); INSERT INTO Brands (Brand_ID, Brand_Name) VALUES (1, 'Aromatica'), (2, 'Herbivore'), (3, 'Kora'), (4, 'Lush'); INSERT INTO Safety_... | Which brands have never had a non-compliant safety rating? | SELECT Brand_Name FROM Brands b WHERE NOT EXISTS (SELECT * FROM Safety_Inspections si WHERE b.Brand_ID = si.Brand_ID AND Compliance_Rating = 'Non-Compliant'); | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeTraining (EmployeeID INT, TrainingDate DATE); INSERT INTO EmployeeTraining (EmployeeID, TrainingDate) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2021-12-01'); | How many employees have been trained in the last 6 months? | SELECT COUNT(*) FROM EmployeeTraining WHERE TrainingDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE zoo_exhibits (exhibit_id INT, animal_type VARCHAR(255), num_visitors INT); INSERT INTO zoo_exhibits (exhibit_id, animal_type, num_visitors) VALUES (1, 'Mammal', 500), (2, 'Bird', 400), (3, 'Reptile', 600); | What is the maximum number of visitors at the "zoo_exhibits" table grouped by animal_type? | SELECT animal_type, MAX(num_visitors) FROM zoo_exhibits GROUP BY animal_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (id INT, project_name VARCHAR(50), state VARCHAR(50), timeline INT); INSERT INTO project_timeline (id, project_name, state, timeline) VALUES (1, 'Solar Panel Installation', 'New York', 50); INSERT INTO project_timeline (id, project_name, state, timeline) VALUES (2, 'Wind Turbine Installati... | What is the maximum project timeline for green building projects in New York? | SELECT MAX(timeline) FROM project_timeline WHERE state = 'New York' AND project_name LIKE '%green%' | gretelai_synthetic_text_to_sql |
CREATE SCHEMA labor_schema; CREATE TABLE veteran_employment (employment_id INT PRIMARY KEY, veteran_status VARCHAR(255), employment_date DATE); INSERT INTO veteran_employment (employment_id, veteran_status, employment_date) VALUES (1, 'unemployed', '2022-01-01'); INSERT INTO veteran_employment (employment_id, veteran_s... | Calculate the veteran unemployment rate for the last month | SELECT (SUM(CASE WHEN veteran_status = 'unemployed' THEN 1 ELSE 0 END) / COUNT(*)) * 100 FROM veteran_employment WHERE employment_date >= LAST_DAY(CURRENT_DATE - INTERVAL 2 MONTH) + INTERVAL 1 DAY AND employment_date < LAST_DAY(CURRENT_DATE - INTERVAL 1 MONTH) + INTERVAL 1 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, donation_date DATE, sector TEXT, country TEXT); INSERT INTO donors (donor_id, donor_name, donation_amount, donation_date, sector, country) VALUES (1, 'Save the Children', 75000, '2020-01-01', 'education', 'Latin America'); | What is the total amount of funds donated by each organization for the education sector in Latin America in 2020? | SELECT donor_name, SUM(donation_amount) as total_donation FROM donors WHERE country = 'Latin America' AND sector = 'education' GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget(Date DATE, Region VARCHAR(20), Department VARCHAR(20), Amount INT); INSERT INTO Budget(Date, Region, Department, Amount) VALUES ('2023-01-01', 'North', 'Healthcare', 3000000), ('2023-01-05', 'North', 'Healthcare', 2500000), ('2023-02-10', 'North', 'Healthcare', 2000000); | Calculate the total budget allocated for 'Healthcare' services in the 'North' region in Q1 2023. | SELECT SUM(Amount) FROM Budget WHERE Region = 'North' AND Department = 'Healthcare' AND Date BETWEEN '2023-01-01' AND '2023-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE editors (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, experience INT); INSERT INTO editors (id, name, gender, age, experience) VALUES (1, 'John Doe', 'Male', 50, 15); INSERT INTO editors (id, name, gender, age, experience) VALUES (2, 'Jim Brown', 'Male', 45, 12); INSERT INTO editors (id, name, ge... | What is the average age of all male editors in the 'editors' table? | SELECT AVG(age) FROM editors WHERE gender = 'Male' AND position = 'Editor'; | gretelai_synthetic_text_to_sql |
CREATE TABLE diplomacy (id INT, event VARCHAR(50), year INT); INSERT INTO diplomacy (id, event, year) VALUES (1, 'Innovation Summit', 2016); INSERT INTO diplomacy (id, event, year) VALUES (2, 'Peace Summit', 2018); | Show the names of all defense diplomacy events with the word 'summit' in them from 2016 to 2018. | SELECT event FROM diplomacy WHERE event LIKE '%summit%' AND year BETWEEN 2016 AND 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_vehicles (vehicle_id INT, model VARCHAR(255), manufacturer VARCHAR(255)); | list all autonomous vehicle models and their manufacturers | SELECT model, manufacturer FROM autonomous_vehicles; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (ticket_id INT, event_id INT, price DECIMAL(5,2)); | Delete records in the 'ticket_sales' table where the price was below the average ticket price for a given event. | DELETE FROM ticket_sales WHERE price < (SELECT AVG(price) FROM ticket_sales GROUP BY event_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, HasSmartwatch BOOLEAN); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE, Duration INT, WorkoutType VARCHAR(10)); | What is the total duration of strength training workouts in the last month for members over 30 years old? | SELECT SUM(Duration) FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.Age > 30 AND WorkoutType = 'strength' AND WorkoutDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE VIEW rural_neighborhoods AS SELECT * FROM properties WHERE neighborhood_type = 'rural'; | What is the average square footage of properties in the rural_neighborhoods view? | SELECT AVG(square_footage) FROM rural_neighborhoods; | gretelai_synthetic_text_to_sql |
CREATE TABLE Districts (District_ID INT, District_Name VARCHAR(50), Feedback_Count INT, Year INT); INSERT INTO Districts (District_ID, District_Name, Feedback_Count, Year) VALUES (1, 'Downtown', 500, 2018), (2, 'Uptown', 300, 2018), (3, 'Harbor', 400, 2018), (4, 'Beach', 600, 2018), (5, 'Forest', 700, 2018); | List the number of citizens providing feedback for each district in 2018 | SELECT District_Name, Feedback_Count FROM Districts WHERE Year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_ph_2 (id INT, month INT, ph FLOAT, hemisphere VARCHAR(255)); INSERT INTO ocean_ph_2 (id, month, ph, hemisphere) VALUES (1, 1, 8.1, 'Northern'); INSERT INTO ocean_ph_2 (id, month, ph, hemisphere) VALUES (2, 2, 8.0, 'Southern'); INSERT INTO ocean_ph_2 (id, month, ph, hemisphere) VALUES (3, 3, 7.9, 'Nor... | What is the maximum ocean pH, grouped by month and hemisphere? | SELECT hemisphere, month, MAX(ph) FROM ocean_ph_2 GROUP BY hemisphere, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50)); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10, 2)); CREATE TABLE volunteers (id INT, name VARCHAR(50)); CREATE TABLE volunteer_events (id INT, volunteer_id INT, organization_id INT, hours DECIMAL(10, 2)); CREATE TABLE organizations (... | What is the average donation amount and average volunteer hours for each category? | SELECT organizations.category, AVG(donations.amount) AS avg_donation, AVG(volunteer_events.hours) AS avg_volunteer_hours FROM organizations JOIN donations ON organizations.id = donations.organization_id JOIN volunteer_events ON organizations.id = volunteer_events.organization_id GROUP BY organizations.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE victims (id INT, name VARCHAR(50), age INT, state VARCHAR(2)); CREATE TABLE incidents (id INT, incident_date DATE, location VARCHAR(50), victim_id INT, crime_id INT); | Which victims from Texas were involved in incidents in 2020? | SELECT victims.name, incidents.incident_date FROM victims JOIN incidents ON victims.id = incidents.victim_id WHERE victims.state = 'TX' AND incidents.incident_date >= '2020-01-01' AND incidents.incident_date <= '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE eu_military_budgets (country VARCHAR(50), year INT, budget FLOAT); INSERT INTO eu_military_budgets (country, year, budget) VALUES ('Germany', 2022, 49.3), ('France', 2022, 41.2), ('UK', 2022, 39.8), ('Italy', 2022, 26.7), ('Spain', 2022, 17.4), ('Poland', 2022, 11.6), ('Netherlands', 2022, 11.1), ('Greece'... | What is the distribution of military budgets for countries in the European Union in 2022? | SELECT country, budget FROM eu_military_budgets WHERE year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Services (Service VARCHAR(20), Revenue INT); INSERT INTO Services (Service, Revenue) VALUES ('Mobile', 50000), ('Broadband', 30000); CREATE TABLE Customers (CustomerID INT, Service VARCHAR(20), Region VARCHAR(20)); INSERT INTO Customers (CustomerID, Service, Region) VALUES (1, 'Mobile', 'Eastern'), (2, 'Br... | What is the total revenue from the 'Mobile' services in the 'Eastern' region? | SELECT SUM(s.Revenue) as TotalRevenue FROM Services s JOIN Customers c ON s.Service = c.Service WHERE c.Region = 'Eastern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE gold_mines (id INT, name TEXT, location TEXT, production_rate FLOAT); INSERT INTO gold_mines (id, name, location, production_rate) VALUES (1, 'Brewer Gold Mine', 'Nevada, USA', 5000.0), (2, 'Cortez Gold Mine', 'Nevada, USA', 12000.0); | What is the average production rate of gold mines in the US? | SELECT AVG(production_rate) FROM gold_mines WHERE location LIKE '%USA%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_occupancy (hotel_id INT, segment VARCHAR(20), occupancy INT, date DATE); | What is the occupancy rate for hotels in the 'budget' segment over the last month? | SELECT segment, AVG(occupancy) as avg_occupancy FROM hotel_occupancy WHERE segment = 'budget' AND date >= DATE(NOW()) - INTERVAL 1 MONTH GROUP BY segment; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_plants (plant_id INT, plant_name VARCHAR(255), waste_generated INT); INSERT INTO manufacturing_plants (plant_id, plant_name, waste_generated) VALUES (1, 'Plant A', 500), (2, 'Plant B', 700), (3, 'Plant C', 800); | List the total waste generated per manufacturing plant | SELECT plant_name, SUM(waste_generated) as total_waste FROM manufacturing_plants GROUP BY plant_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE bike_share (user_id INT, bike_id INT, rental_start_time TIMESTAMP, rental_end_time TIMESTAMP); | How many unique users used the public bike-share system in the last week, grouped by day? | SELECT DATE(rental_start_time) AS rental_day, COUNT(DISTINCT user_id) AS unique_users FROM bike_share WHERE rental_start_time >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) GROUP BY rental_day; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_gender TEXT); INSERT INTO company (id, name, founding_year, founder_gender) VALUES (1, 'Acme Inc', 2010, 'female'); INSERT INTO company (id, name, founding_year, founder_gender) VALUES (2, 'Beta Corp', 2015, 'male'); | What is the earliest founding year for companies with a female founder? | SELECT MIN(founding_year) FROM company WHERE founder_gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Disability_Accommodations (id INT, individual_id INT, region VARCHAR(50), accommodation_count INT, accommodation_date DATE); | What is the average number of disability accommodations provided per individual with a disability in each region for the past year? | SELECT region, AVG(accommodation_count) as avg_accommodation_count FROM Disability_Accommodations WHERE accommodation_date >= DATEADD(year, -1, GETDATE()) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists PublicTransit (id INT, city VARCHAR(20), trips INT, date DATE); INSERT INTO PublicTransit (id, city, trips, date) VALUES (1, 'Beijing', 15000, '2022-03-15'), (2, 'Beijing', 18000, '2022-03-16'), (3, 'Shanghai', 12000, '2022-03-15'); | What is the maximum number of public transit trips in Beijing in a day? | SELECT MAX(trips) FROM PublicTransit WHERE city = 'Beijing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE contacts (id INT, name TEXT, sector TEXT, region TEXT, email TEXT); INSERT INTO contacts (id, name, sector, region, email) VALUES (1, 'John Doe', 'community development', 'Asia', 'john.doe@example.com'); INSERT INTO contacts (id, name, sector, region, email) VALUES (2, 'Jane Doe', 'refugee support', 'Afric... | Who are the contacts for the 'community development' sector in Asia? | SELECT name, email FROM contacts WHERE sector = 'community development' AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_info (building_id INT, building_type VARCHAR(50), floors INT, state VARCHAR(50)); INSERT INTO building_info (building_id, building_type, floors, state) VALUES (1, 'Residential', 3, 'California'), (2, 'Commercial', 10, 'New York'), (3, 'Residential', 4, 'Texas'), (4, 'Commercial', 8, 'New York'); | What is the minimum number of floors in commercial buildings in the state of New York? | SELECT MIN(floors) FROM building_info WHERE building_type = 'Commercial' AND state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_pieces (piece_id INT, artist_name VARCHAR(50), artist_gender VARCHAR(10), artist_ethnicity VARCHAR(20), movement VARCHAR(20)); INSERT INTO art_pieces (piece_id, artist_name, artist_gender, artist_ethnicity, movement) VALUES (1, 'Pablo Picasso', 'Male', 'Spanish', 'Cubism'); INSERT INTO art_pieces (piec... | Which artist from the 'Cubism' movement has the most art pieces in the collection? | SELECT artist_name, COUNT(*) as art_piece_count FROM art_pieces WHERE movement = 'Cubism' GROUP BY artist_name ORDER BY art_piece_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, user_id INT, country VARCHAR(50), hours DECIMAL(10, 2), volunteer_date DATE); INSERT INTO Volunteers (id, user_id, country, hours, volunteer_date) VALUES (4, 204, 'Brazil', 2.00, '2021-10-01'); INSERT INTO Volunteers (id, user_id, country, hours, volunteer_date) VALUES (8, 208, 'Argenti... | What is the average number of volunteer hours in Brazil? | SELECT AVG(hours) FROM Volunteers WHERE country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_hours_3 (worker_id INT, state VARCHAR(20), building_type VARCHAR(20), hours_per_week DECIMAL(5,2)); INSERT INTO labor_hours_3 (worker_id, state, building_type, hours_per_week) VALUES (1, 'CA', 'Residential', 25.00), (2, 'CA', 'Commercial', 35.00), (3, 'CA', 'Industrial', 45.00); | Find the total construction labor hours per week in California, for each building type | SELECT state, building_type, SUM(hours_per_week) as total_hours FROM labor_hours_3 WHERE state = 'CA' GROUP BY state, building_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Songs (song_id INT, title TEXT, genre TEXT, release_date DATE, price DECIMAL(5,2)); | What is the average price of rap songs? | SELECT AVG(Songs.price) FROM Songs WHERE Songs.genre = 'rap'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (id INT PRIMARY KEY, name VARCHAR(255), capacity_mw FLOAT, country VARCHAR(255)); | Delete records in the 'solar_plants' table where the 'capacity_mw' is less than 10 | DELETE FROM solar_plants WHERE capacity_mw < 10; | 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.