context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE departments (dept_id INT, dept_name VARCHAR(50)); CREATE TABLE grants (grant_id INT, dept_id INT, grant_type VARCHAR(10), grant_amount DECIMAL(10,2)); INSERT INTO departments (dept_id, dept_name) VALUES (10, 'Computer Science'), (20, 'English'), (30, 'Mathematics'); INSERT INTO grants (grant_id, dept_id, grant_type, grant_amount) VALUES (100, 10, 'Research', 50000), (101, 10, 'Teaching', 25000), (102, 20, 'Research', 60000), (103, 20, 'Teaching', 30000), (104, 30, 'Research', 40000), (105, 30, 'Teaching', 20000); | What is the total funding received by each department, broken down by grant type? | SELECT d.dept_name, g.grant_type, SUM(g.grant_amount) AS total_funding FROM departments d INNER JOIN grants g ON d.dept_id = g.dept_id GROUP BY d.dept_name, g.grant_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (country VARCHAR(50), region VARCHAR(50), operations INT); INSERT INTO humanitarian_assistance (country, region, operations) VALUES ('France', 'Europe', 30), ('Germany', 'Europe', 40), ('UK', 'Europe', 50); | What is the total number of humanitarian assistance operations in the 'europe' region? | SELECT region, SUM(operations) as total_operations FROM humanitarian_assistance WHERE region = 'Europe' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (rep_id INT, quarter INT, sales FLOAT); INSERT INTO sales (rep_id, quarter, sales) VALUES (1, 1, 500), (1, 2, 600), (2, 1, 400), (2, 2, 500), (3, 1, 300), (3, 2, 400); | What is the change in sales amount per sales representative between the first and the second quarter? | SELECT rep_id, sales - LAG(sales) OVER (PARTITION BY rep_id ORDER BY quarter) as sales_change FROM sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO products (product_id, category, price) VALUES (1, 'Electronics', 200.00), (2, 'Fashion', 50.00), (3, 'Electronics', 300.00); | What is the average product price for each category, ordered by the highest average price? | SELECT category, AVG(price) as avg_price FROM products GROUP BY category ORDER BY avg_price DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (rep_name TEXT, drug_name TEXT, region TEXT, quarter INT, total_sales FLOAT); INSERT INTO sales_data (rep_name, drug_name, region, quarter, total_sales) VALUES ('RepA', 'DrugZ', 'Latin America', 2, 500000), ('RepB', 'DrugZ', 'Latin America', 2, 600000), ('RepC', 'DrugZ', 'Latin America', 2, 700000), ('RepD', 'DrugZ', 'Latin America', 2, 400000); | Who are the top 3 sales representatives by total sales for 'DrugZ' in the Latin America region in Q2 2021? | SELECT rep_name, SUM(total_sales) AS total_sales FROM sales_data WHERE drug_name = 'DrugZ' AND region = 'Latin America' AND quarter = 2 GROUP BY rep_name ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (id INT, route_id VARCHAR(5), weight DECIMAL(5,2)); INSERT INTO packages (id, route_id, weight) VALUES (100, 'R01', 12.3), (101, 'R02', 15.6), (102, 'R03', 8.8), (103, 'R04', 20.1), (104, 'R04', 18.5); CREATE TABLE routes (id VARCHAR(5), name VARCHAR(10)); INSERT INTO routes (id, name) VALUES ('R01', 'Route One'), ('R02', 'Route Two'), ('R03', 'Route Three'), ('R04', 'Route Four'); | What is the weight of the heaviest package on route 'R04'? | SELECT MAX(weight) FROM packages WHERE route_id = 'R04'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 30, 'Female', 'Basic'), (2, 45, 'Male', 'Premium'), (3, 25, 'Female', 'Basic'), (4, 32, 'Male', 'Premium'), (5, 50, 'Female', 'Basic'); CREATE TABLE ClubMembership (MemberID INT, Club VARCHAR(20)); INSERT INTO ClubMembership (MemberID, Club) VALUES (1, 'Cycling'), (2, 'Yoga'), (3, 'Cycling'), (4, 'Pilates'), (5, 'Cycling'); | What is the average age of members with a Basic membership in the Cycling club? | SELECT AVG(Age) FROM Members JOIN ClubMembership ON Members.MemberID = ClubMembership.MemberID WHERE Members.MembershipType = 'Basic' AND ClubMembership.Club = 'Cycling'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, department VARCHAR(255), incident_time TIMESTAMP); INSERT INTO security_incidents (id, department, incident_time) VALUES (1, 'HR', '2022-01-17 15:45:00'), (2, 'IT', '2022-01-25 11:00:00'), (3, 'HR', '2022-01-04 08:30:00'); | What are the security incidents that occurred in the HR department in the last month? | SELECT * FROM security_incidents WHERE department = 'HR' AND incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_categories (menu_category VARCHAR(50), num_vegetarian INT); INSERT INTO menu_categories (menu_category, num_vegetarian) VALUES ('Appetizers', 2), ('Entrees', 3), ('Desserts', 1); | What is the percentage of vegetarian items in each menu category? | SELECT menu_category, (num_vegetarian::DECIMAL / (SELECT SUM(num_vegetarian) FROM menu_categories)) * 100 FROM menu_categories; | gretelai_synthetic_text_to_sql |
CREATE TABLE salary_data (id INT, employee_name VARCHAR(255), department VARCHAR(255), salary FLOAT); INSERT INTO salary_data (id, employee_name, department, salary) VALUES (1, 'Alice Johnson', 'robotics', 50000.00), (2, 'Bob Smith', 'automation', 60000.00), (3, 'Charlie Brown', 'robotics', 55000.00), (4, 'David Kim', 'automation', 65000.00); | What is the average salary of employees in the 'automation' department? | SELECT AVG(salary) FROM salary_data WHERE department = 'automation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Soil_Moisture (ID INT, Moisture FLOAT, Timestamp DATETIME); INSERT INTO Soil_Moisture (ID, Moisture, Timestamp) VALUES (1, 45, '2022-01-01 10:00:00'), (2, 52, '2022-01-15 12:00:00'); | Delete any soil moisture readings that are older than 30 days. | DELETE FROM Soil_Moisture WHERE Timestamp < NOW() - INTERVAL '30 days'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fantom_transactions (transaction_id INTEGER, gas_price INTEGER); | What's the highest gas price paid for a transaction on the Fantom Opera blockchain? | SELECT MAX(gas_price) FROM fantom_transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT); CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT, product_id INT); INSERT INTO products (product_id, product_name) VALUES (1, 'Product 1'); INSERT INTO products (product_id, product_name) VALUES (2, 'Product 2'); INSERT INTO products (product_id, product_name) VALUES (3, 'Product 3'); INSERT INTO suppliers (supplier_id, supplier_name, product_id) VALUES (1, 'Supplier A', 1); INSERT INTO suppliers (supplier_id, supplier_name, product_id) VALUES (2, 'Supplier B', 2); INSERT INTO suppliers (supplier_id, supplier_name, product_id) VALUES (3, 'Supplier A', 3); INSERT INTO suppliers (supplier_id, supplier_name, product_id) VALUES (4, 'Supplier C', 1); INSERT INTO suppliers (supplier_id, supplier_name, product_id) VALUES (5, 'Supplier B', 3); | How many products does each supplier provide? | SELECT supplier_id, COUNT(*) FROM suppliers GROUP BY supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE producers (id INT, name VARCHAR(255), location VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO producers (id, name, location, cost) VALUES (1, 'Fabric Inc', 'Spain', 150.00), (2, 'Stitch Time', 'USA', 120.00); | What is the average production cost of garments produced in Spain? | SELECT AVG(cost) FROM producers WHERE location = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, museum_name VARCHAR(255), artist_id INT, artwork_id INT); INSERT INTO Exhibitions (exhibition_id, museum_name, artist_id, artwork_id) VALUES (1, 'Museum X', 101, 201), (2, 'Museum Y', 102, 202), (3, 'Museum Z', 103, 203); CREATE TABLE Artworks (artwork_id INT, artist_id INT, artwork_title VARCHAR(255)); INSERT INTO Artworks (artwork_id, artist_id, artwork_title) VALUES (201, 101, 'Painting 1'), (202, 102, 'Sculpture 1'), (203, 103, 'Drawing 1'); | Who is the artist of artwork '202'? | SELECT artist_id FROM Artworks WHERE artwork_id = 202; SELECT CONCAT(artist_first_name, ' ', artist_last_name) AS artist_name FROM Artists WHERE artist_id = (SELECT artist_id FROM Artworks WHERE artwork_id = 202); | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS applicants (id INT, gender VARCHAR(10), domestic BOOLEAN, grescore INT, program VARCHAR(20), applicationdate DATE); | What is the average GRE score for female domestic applicants to the Computer Science PhD program in the last 3 years? | SELECT AVG(grescore) FROM applicants WHERE gender='Female' AND domestic=TRUE AND program='Computer Science PhD' AND applicationdate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE doctors (id INT, name TEXT, gender TEXT, state TEXT); INSERT INTO doctors (id, name, gender, state) VALUES (1, 'James', 'Male', 'Texas'); INSERT INTO doctors (id, name, gender, state) VALUES (2, 'Emily', 'Female', 'California'); | What is the number of female doctors in Texas? | SELECT COUNT(*) FROM doctors WHERE gender = 'Female' AND state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_stock (stock_id INT, product_name TEXT, brand_name TEXT, expiry_date DATE); | Delete records of expired cosmetic products from the 'cosmetics_stock' table. | DELETE FROM cosmetics_stock WHERE expiry_date < CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE north_america (user_id INT, username VARCHAR(50), age INT); | How many users from "north_america" table are above 30 years old? | SELECT COUNT(*) FROM north_america WHERE age > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE europe_accommodations (id INT, name TEXT, type TEXT, country TEXT, sustainable BOOLEAN); | Which countries in Europe have the most sustainable accommodations? | SELECT country, COUNT(*) AS sustainable_accommodation_count FROM europe_accommodations WHERE sustainable = 'true' GROUP BY country ORDER BY sustainable_accommodation_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(255), location VARCHAR(255), language VARCHAR(255), years_experience INT); INSERT INTO community_health_workers (worker_id, name, location, language, years_experience) VALUES (1, 'Ana Flores', 'Los Angeles, CA', 'Spanish', 10), (2, 'Han Kim', 'Seattle, WA', 'Korean', 7), (3, 'Leila Nguyen', 'Houston, TX', 'Vietnamese', 12); CREATE TABLE cultural_competency_trainings (worker_id INT, training VARCHAR(255), date DATE, duration INT); INSERT INTO cultural_competency_trainings (worker_id, training, date, duration) VALUES (1, 'Language Access', '2022-06-01', 3), (1, 'Cultural Sensitivity', '2022-07-01', 5), (2, 'Language Access', '2022-06-05', 4), (2, 'Cultural Sensitivity', '2022-07-05', 2), (3, 'Language Access', '2022-06-10', 5), (3, 'Cultural Sensitivity', '2022-07-10', 4); | What is the total duration of cultural competency trainings for each community health worker, ordered by worker name? | SELECT c.worker_id, c.name, SUM(cc.duration) as total_duration FROM community_health_workers c JOIN cultural_competency_trainings cc ON c.worker_id = cc.worker_id GROUP BY c.worker_id, c.name ORDER BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT);CREATE TABLE donations (donation_id INT, donor_id INT, org_id INT, donation_amount DECIMAL(10,2)); INSERT INTO donors VALUES (1, 'James Smith'); INSERT INTO donors VALUES (2, 'Nancy Jones'); INSERT INTO donations VALUES (1, 1, 1, 50.00); INSERT INTO donations VALUES (2, 1, 2, 75.00); INSERT INTO donations VALUES (3, 2, 1, 100.00); | How many unique donors have donated to each nonprofit, and what is the total amount donated by these donors? | SELECT organizations.org_name, COUNT(DISTINCT donations.donor_id) AS unique_donors, SUM(donations.donation_amount) AS total_donated FROM organizations INNER JOIN donations ON organizations.org_id = donations.org_id GROUP BY organizations.org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_events (event_id INT, artist_id INT, event_date DATE, event_location VARCHAR(255), attendance INT, revenue DECIMAL(10,2), country VARCHAR(50)); INSERT INTO concert_events (event_id, artist_id, event_date, event_location, attendance, revenue, country) VALUES (1, 1, '2025-01-01', 'NYC', 15000, 500000.00, 'South Africa'); CREATE TABLE artist_demographics (artist_id INT, artist_name VARCHAR(255), gender VARCHAR(50), ethnicity VARCHAR(50), country VARCHAR(50)); INSERT INTO artist_demographics (artist_id, artist_name, gender, ethnicity, country) VALUES (1, 'Amina Mohamed', 'female', 'African', 'South Africa'); | What is the number of concerts for artists who identify as female and are from Africa in 2025? | SELECT COUNT(*) FROM concert_events ce JOIN artist_demographics ad ON ce.artist_id = ad.artist_id WHERE ad.gender = 'female' AND ad.ethnicity = 'African' AND ce.event_date BETWEEN '2025-01-01' AND '2025-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floors (ocean VARCHAR(50), avg_depth FLOAT); INSERT INTO ocean_floors (ocean, avg_depth) VALUES ('Atlantic Ocean', 3646), ('Pacific Ocean', 4280), ('Indian Ocean', 3963), ('Southern Ocean', 3480), ('Arctic Ocean', 1205); | What is the average depth of the ocean floor in the Indian Ocean? | SELECT avg_depth FROM ocean_floors WHERE ocean = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT PRIMARY KEY, home_team VARCHAR(50), away_team VARCHAR(50), city VARCHAR(50), stadium VARCHAR(50), game_date DATE); | Insert a new record for a soccer game between the "LA Galaxy" and "Seattle Sounders" into the "games" table | INSERT INTO games (game_id, home_team, away_team, city, stadium, game_date) VALUES (201, 'LA Galaxy', 'Seattle Sounders', 'Los Angeles', 'Dignity Health Sports Park', '2022-08-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE speeding_tickets (ticket_id INT, license_type VARCHAR(20), fine INT, issue_date DATE); INSERT INTO speeding_tickets (ticket_id, license_type, fine, issue_date) VALUES (1, 'CDL', 200, '2022-01-15'), (2, 'Passenger', 150, '2022-01-17'), (3, 'CDL', 250, '2022-02-03'); | What is the average fine for speeding tickets issued in the last month, partitioned by license type? | SELECT license_type, AVG(fine) as avg_fine FROM (SELECT license_type, fine, ROW_NUMBER() OVER (PARTITION BY license_type ORDER BY issue_date DESC) as rn FROM speeding_tickets WHERE issue_date >= DATEADD(month, -1, GETDATE())) x WHERE rn = 1 GROUP BY license_type; | gretelai_synthetic_text_to_sql |
ARTIST(artist_id, old_name, new_name) | Update the name of artists who have changed their name | UPDATE ARTIST SET old_name = new_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics (fan_id INT, age INT, state VARCHAR(2)); CREATE TABLE ticket_sales (ticket_id INT, fan_id INT, event_id INT, price DECIMAL(5,2)); | How many unique fans reside in 'FL' and have an average ticket spending of over $50 in the 'fan_demographics' and 'ticket_sales' tables? | SELECT COUNT(DISTINCT fan_id) FROM fan_demographics fd JOIN ticket_sales ts ON fd.fan_id = ts.fan_id WHERE fd.state = 'FL' AND (ts.price / (SELECT COUNT(*) FROM ticket_sales ts2 WHERE ts.fan_id = ts2.fan_id)) > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (student_id INT, dept_name VARCHAR(50), gender VARCHAR(10)); | What is the percentage of female and male graduate students in each department, and what is the overall gender distribution in the graduate program? | SELECT dept_name, SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*) as pct_female, SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) / COUNT(*) as pct_male FROM graduate_students GROUP BY dept_name; SELECT SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*) as pct_female, SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) / COUNT(*) as pct_male FROM graduate_students; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_power (country TEXT, capacity INTEGER); INSERT INTO wind_power (country, capacity) VALUES ('Germany', 62000), ('France', 17000); CREATE TABLE solar_power (country TEXT, capacity INTEGER); INSERT INTO solar_power (country, capacity) VALUES ('Germany', 50000), ('France', 10000); | What is the total installed capacity of wind and solar power plants in Germany and France? | (SELECT capacity FROM wind_power WHERE country = 'Germany') UNION (SELECT capacity FROM wind_power WHERE country = 'France') UNION (SELECT capacity FROM solar_power WHERE country = 'Germany') UNION (SELECT capacity FROM solar_power WHERE country = 'France') | gretelai_synthetic_text_to_sql |
CREATE TABLE ProgramAttendance (city VARCHAR(50), program VARCHAR(50), attendees INT); INSERT INTO ProgramAttendance (city, program, attendees) VALUES ('New York', 'Art', 120), ('New York', 'Music', 15), ('New York', 'Dance', 180), ('New York', 'Theater', 30); | List the number of attendees for each unique program type, excluding any programs with less than 20 attendees, in the city of New York? | SELECT program, attendees FROM ProgramAttendance WHERE attendees >= 20 AND city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism_practices_ext (id INT, country VARCHAR(50), practice VARCHAR(100), start_date DATE, end_date DATE, continent VARCHAR(10)); INSERT INTO sustainable_tourism_practices_ext (id, country, practice, start_date, end_date, continent) VALUES (1, 'Kenya', 'Reduced Water Usage', '2020-01-01', '2025-12-31', 'Africa'); | List all practices implemented by African countries for sustainable tourism and the duration of those practices. | SELECT stp.practice, stp.country, stp.start_date, stp.end_date FROM sustainable_tourism_practices_ext stp WHERE stp.continent = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE journalist_ethics (id INT, journalist VARCHAR(100), country VARCHAR(50), violation VARCHAR(50), date DATE); INSERT INTO journalist_ethics (id, journalist, country, violation, date) VALUES (1, 'Emily Lee', 'Canada', 'Conflict of Interest', '2022-01-01'); INSERT INTO journalist_ethics (id, journalist, country, violation, date) VALUES (2, 'Oliver Chen', 'Canada', 'Plagiarism', '2022-01-02'); | Which investigative journalists in Canada have been involved in more than 5 media ethics violations? | SELECT journalist, COUNT(*) FROM journalist_ethics WHERE country = 'Canada' GROUP BY journalist HAVING COUNT(*) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(50), Gender VARCHAR(10), Salary FLOAT, HireDate DATE, DiversityTraining BOOLEAN); INSERT INTO Employees (EmployeeID, Department, Gender, Salary, HireDate, DiversityTraining) VALUES (1, 'IT', 'Male', 85000, '2021-04-20', TRUE), (2, 'HR', 'Female', 75000, '2019-12-15', FALSE), (3, 'IT', 'Female', 80000, '2020-01-08', TRUE), (4, 'IT', 'Male', 90000, '2021-04-01', FALSE), (5, 'Finance', 'Male', 75000, '2019-12-28', TRUE), (6, 'IT', 'Male', 88000, '2021-05-12', TRUE), (7, 'Marketing', 'Female', 78000, '2021-07-01', TRUE), (8, 'HR', 'Male', 80000, '2021-02-15', TRUE), (9, 'Finance', 'Female', 70000, '2020-04-18', TRUE), (10, 'Finance', 'Male', 72000, '2019-11-05', FALSE); | Delete records of employees who have not completed diversity training | DELETE FROM Employees WHERE DiversityTraining = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Country VARCHAR(50), ComplianceTraining BOOLEAN); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, ComplianceTraining) VALUES (1, 'John', 'Doe', 'USA', true); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, ComplianceTraining) VALUES (2, 'Jane', 'Doe', 'Canada', false); | Show the number of employees who have completed compliance training, by country, and display the results in a table | SELECT Country, COUNT(*) as NumberOfEmployees FROM Employees WHERE ComplianceTraining = true GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, country VARCHAR(50), sustainable BOOLEAN); | What is the percentage of sustainable fabric orders for each country? | SELECT country, PERCENTAGE(COUNT(*) FILTER (WHERE sustainable)) OVER (PARTITION BY country) FROM orders; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (student_id INT, student_name TEXT, accommodation_type TEXT, accommodation_year INT); INSERT INTO accommodations (student_id, student_name, accommodation_type, accommodation_year) VALUES (1, 'Alice', 'Extra Time', 2018), (2, 'Bob', 'Note Taker', 2018), (3, 'Carol', 'Sign Language Interpreter', 2019), (4, 'Dave', 'Assistive Listening Device', 2019); | How many students with mobility impairments received accommodations in each academic year? | SELECT accommodation_year, COUNT(*) AS accommodations_received FROM accommodations WHERE student_name IN (SELECT student_name FROM students WHERE disability = true AND disability_type = 'mobility impairment') GROUP BY accommodation_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT PRIMARY KEY, age INT, signup_date DATE); INSERT INTO volunteers (id, age, signup_date) VALUES (1, 25, '2021-03-15'); | How many volunteers signed up in H1 2021, categorized by age group? | SELECT (age - 1) DIV 10 * 10 AS age_group, COUNT(*) FROM volunteers WHERE signup_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_change_projects (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), start_year INT, end_year INT, funding_amount DECIMAL(10,2)); | What is the maximum funding received by a climate change adaptation project in Africa? | SELECT MAX(funding_amount) FROM climate_change_projects WHERE type = 'climate change adaptation' AND location LIKE '%Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, project_name, location, budget) VALUES (1, 'Precision Agriculture', 'Nigeria', 300000.00); | Find the average budget for rural infrastructure projects in Africa. | SELECT AVG(budget) FROM rural_infrastructure WHERE location LIKE '%Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), certification VARCHAR(50), sqft_area INT, PRIMARY KEY (id)); | What is the average square footage of green buildings in each city and state, sorted by the building count in descending order? | SELECT city, state, AVG(sqft_area) as avg_sqft_area, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as ranking FROM green_buildings GROUP BY city, state; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (vuln_id INT, sector VARCHAR(50), department VARCHAR(50), vuln_severity VARCHAR(50), vuln_report_date DATE, vuln_patch_date DATE); INSERT INTO vulnerabilities (vuln_id, sector, department, vuln_severity, vuln_report_date, vuln_patch_date) VALUES (1, 'Technology', 'IT', 'critical', '2022-01-01', '2022-01-05'), (2, 'Technology', 'IT', 'high', '2022-01-02', '2022-01-07'), (3, 'Technology', 'Security', 'critical', '2022-01-03', '2022-01-10'); | What is the average time to patch critical vulnerabilities for each department in the technology sector? | SELECT department, AVG(DATEDIFF(day, vuln_report_date, vuln_patch_date)) as avg_patch_time FROM vulnerabilities WHERE sector = 'Technology' AND vuln_severity = 'critical' GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_incidents (id INT, incident_type VARCHAR(255), year INT, affected_systems VARCHAR(255), region VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, incident_type, year, affected_systems, region) VALUES (1, 'Data Breach', 2020, 'Web Servers', 'Asia'), (2, 'Phishing', 2019, 'Email Accounts', 'Asia'), (3, 'Malware', 2020, 'Workstations', 'Europe'); | List all cybersecurity incidents that occurred in Asia in the year 2020, along with the incident type and affected systems. | SELECT incident_type, affected_systems FROM cybersecurity_incidents WHERE year = 2020 AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AlbumStreams (AlbumID int, SongID int, StreamCount int, Genre varchar(255)); INSERT INTO AlbumStreams (AlbumID, SongID, StreamCount, Genre) VALUES (1, 1, 1000, 'Pop'), (2, 2, 2000, 'Rock'), (3, 3, 1500, 'Jazz'), (4, 4, 2500, 'Hip-Hop'), (5, 5, 1800, 'Country'); | What is the total number of streams per genre? | SELECT Genre, SUM(StreamCount) as TotalStreams FROM AlbumStreams GROUP BY Genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE rare_earth_market_trends ( id INT PRIMARY KEY, year INT, country VARCHAR(255), element VARCHAR(255), price_usd FLOAT); | Update the rare_earth_market_trends table to reflect the increased cerium price in the US | WITH updated_price AS (UPDATE rare_earth_market_trends SET price_usd = 15.2 WHERE year = 2022 AND country = 'US' AND element = 'Cerium') SELECT * FROM rare_earth_market_trends WHERE country = 'US' AND element = 'Cerium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE material_use (id INT, material_name VARCHAR(255), garment_type VARCHAR(255)); CREATE TABLE ethical_materials (id INT, garment_type VARCHAR(255), production_cost DECIMAL(10,2)); | Find the number of sustainable materials that are used in the production of ethical garments. | SELECT COUNT(DISTINCT material_name) FROM material_use WHERE garment_type IN (SELECT garment_type FROM ethical_materials); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (id INT, country VARCHAR(255), year INT, plastics DECIMAL(3,2), paper DECIMAL(3,2), metals DECIMAL(3,2)); | Insert new recycling rates for country 'UK' in 2021 for plastics, paper, and metals into the recycling_rates table. | INSERT INTO recycling_rates (id, country, year, plastics, paper, metals) VALUES (5, 'UK', 2021, 0.35, 0.62, 0.78); | gretelai_synthetic_text_to_sql |
CREATE TABLE EV_Sales (id INT, vehicle_type VARCHAR(50), year INT, quantity_sold INT); | List the number of electric vehicles sold in the US by year. | SELECT year, SUM(quantity_sold) FROM EV_Sales WHERE vehicle_type = 'Electric' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Excavations (ExcavationID INT, Site VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Excavations (ExcavationID, Site, Budget) VALUES (1, 'Ancient City', 50000.00); INSERT INTO Excavations (ExcavationID, Site, Budget) VALUES (2, 'Lost Village', 65000.00); INSERT INTO Excavations (ExcavationID, Site, Budget) VALUES (3, 'Mesoamerican Ruins', 80000.00); | What is the total budget for all excavations in the 'Mesoamerican' region? | SELECT SUM(Budget) FROM Excavations WHERE Site LIKE 'Mesoamerican%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_handling (id INT, cargo_id INT, handling_date DATE, tonnage INT, PRIMARY KEY(id)); | Insert a new record in the 'cargo_handling' table with the following details: cargo ID 5001, handling date of 2022-03-25, tonnage of 5000. | INSERT INTO cargo_handling (cargo_id, handling_date, tonnage) VALUES (5001, '2022-03-25', 5000); | gretelai_synthetic_text_to_sql |
CREATE TABLE City_Budget(City VARCHAR(20), Department VARCHAR(20), Budget INT); INSERT INTO City_Budget(City, Department, Budget) VALUES('Los Angeles', 'Parks', 20000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('Los Angeles', 'Education', 40000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('San Francisco', 'Parks', 15000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('San Francisco', 'Education', 30000000); | What is the total budget for education in each city? | SELECT City, SUM(Budget) FROM City_Budget WHERE Department = 'Education' GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE Microfinance (id INT, institution_name VARCHAR(50), location VARCHAR(50), avg_loan_amount DECIMAL(10,2), num_loans INT, start_date DATE, end_date DATE); | List socially responsible microfinance institutions in Southeast Asia, along with their average loan amounts and total number of loans issued between 2018 and 2020, in descending order of average loan amounts? | SELECT institution_name, AVG(avg_loan_amount) as avg_loan_amount, SUM(num_loans) as total_loans FROM Microfinance WHERE location LIKE '%Southeast Asia%' AND start_date BETWEEN '2018-01-01' AND '2020-12-31' GROUP BY institution_name ORDER BY avg_loan_amount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (year INT, country TEXT, project_type TEXT); | List the top 5 countries with the highest number of climate adaptation projects in the last 5 years? | SELECT country, COUNT(*) as total_projects FROM climate_projects WHERE project_type = 'adaptation' AND year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY country ORDER BY total_projects DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, transaction_date DATE, is_fraud BOOLEAN); INSERT INTO transactions (id, transaction_date, is_fraud) VALUES (1, '2022-03-01', FALSE); INSERT INTO transactions (id, transaction_date, is_fraud) VALUES (2, '2022-03-03', TRUE); | What is the number of fraudulent transactions detected per day in the last week? | SELECT DATE(t.transaction_date) as transaction_date, COUNT(*) as num_fraudulent_transactions FROM transactions t WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND t.is_fraud = TRUE GROUP BY transaction_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_stats (id INT, year INT, primary_energy_consumption FLOAT, final_energy_consumption FLOAT, primary_energy_production FLOAT, co2_emissions FLOAT); | Update the 'co2_emissions' of all records in the 'energy_efficiency_stats' table where the 'year' is between 2000 and 2010 to 10% less than the current value | UPDATE energy_efficiency_stats SET co2_emissions = co2_emissions * 0.9 WHERE year BETWEEN 2000 AND 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE commercial_customers (customer_id INT, location VARCHAR(255), daily_water_usage FLOAT); INSERT INTO commercial_customers (customer_id, location, daily_water_usage) VALUES (1, 'New York', 5000), (2, 'New York', 6000), (3, 'Los Angeles', 4500), (4, 'Tokyo', 7000); | What is the maximum water usage per day for a commercial customer in Tokyo? | SELECT MAX(daily_water_usage) FROM commercial_customers WHERE location = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE State (id INT, Name VARCHAR(50)); INSERT INTO State (id, Name) VALUES (1, 'StateA'); INSERT INTO State (id, Name) VALUES (2, 'StateB'); CREATE TABLE Voter (id INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), State INT); INSERT INTO Voter (id, Name, Age, Gender, State) VALUES (1, 'Voter1', 25, 'Female', 1); INSERT INTO Voter (id, Name, Age, Gender, State) VALUES (2, 'Voter2', 19, 'Male', 1); INSERT INTO Voter (id, Name, Age, Gender, State) VALUES (3, 'Voter3', 22, 'Female', 2); | What is the number of voters and the percentage of voters aged 18-24 in each state? | SELECT s.Name AS StateName, COUNT(v.id) AS NumberOfVoters, COUNT(CASE WHEN v.Age BETWEEN 18 AND 24 THEN 1 ELSE NULL END) * 100.0 / COUNT(v.id) AS PercentageOfVotersAged18_24 FROM State s JOIN Voter v ON s.id = v.State GROUP BY s.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, first_name TEXT, last_name TEXT, date_of_birth DATE, ethnicity TEXT); | Insert a new patient record with the following details: patient_id 4, first_name 'Jamila', last_name 'Ahmed', date_of_birth '1980-05-15', and ethnicity 'Hispanic' into the 'patients' table. | INSERT INTO patients (patient_id, first_name, last_name, date_of_birth, ethnicity) VALUES (4, 'Jamila', 'Ahmed', '1980-05-15', 'Hispanic'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, name TEXT, genre TEXT, visitor_count INT); | What was the maximum visitor count for exhibitions in the 'Fauvism' genre? | SELECT MAX(visitor_count) FROM Exhibitions WHERE genre = 'Fauvism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations_4 (id INT PRIMARY KEY, donor_id INT, city VARCHAR(50), state VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO donations_4 (id, donor_id, city, state, amount) VALUES (1, 1, 'Albany', 'NY', 50.00), (2, 2, 'Buffalo', 'NY', 75.00), (3, 3, 'Boston', 'MA', 100.00), (4, 1, 'Albany', 'NY', 25.00); | What is the total donation amount by each donor? | SELECT donor_id, SUM(amount) as total_donations FROM donations_4 GROUP BY donor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255)); INSERT INTO farmers (farmer_id, name, age, location) VALUES (1, 'John Doe', 35, 'Springfield'), (2, 'Jane Doe', 28, 'Springfield'); | Delete the record with farmer_id 1 from the 'farmers' table | DELETE FROM farmers WHERE farmer_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Research_Studies (study_id INT, study_name VARCHAR(50), pi_id INT); INSERT INTO Research_Studies (study_id, study_name, pi_id) VALUES (1, 'Autonomous Driving in Rural Areas', 1002); CREATE TABLE Principal_Investigators (pi_id INT, pi_name VARCHAR(50)); INSERT INTO Principal_Investigators (pi_id, pi_name) VALUES (1002, 'Dr. Amina Ahmed'); | List all autonomous driving research studies and their respective principal investigators. | SELECT r.study_name, p.pi_name FROM Research_Studies r JOIN Principal_Investigators p ON r.pi_id = p.pi_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE nhl_games (id INT, date DATE, home_team VARCHAR(50), away_team VARCHAR(50), goals_home INT, goals_away INT); CREATE TABLE nhl_players_goals (id INT, game_id INT, player_id INT, goals INT, assists INT); CREATE TABLE nhl_players (id INT, name VARCHAR(100), team VARCHAR(50)); | List the names of all NHL players who have scored a hat-trick (3 goals) in a single game, along with the team they played for and the date of the match. | SELECT p.name, g.home_team, g.date FROM nhl_games g JOIN nhl_players_goals pg ON g.id = pg.game_id JOIN nhl_players p ON pg.player_id = p.id WHERE pg.goals >= 3 GROUP BY p.name, g.date, g.home_team ORDER BY g.date; | gretelai_synthetic_text_to_sql |
CREATE TABLE developers (developer_id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), developer_id INT); INSERT INTO developers (developer_id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'USA'); INSERT INTO digital_assets (asset_id, name, developer_id) VALUES (1, 'CryptoCoin', 1), (2, 'DecentralizedApp', 2), (3, 'SmartContract', 3), (4, 'DataToken', 1); | What is the total number of digital assets created by developers from the US? | SELECT COUNT(*) FROM digital_assets da JOIN developers d ON da.developer_id = d.developer_id WHERE d.country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditure (drug_class TEXT, expenditure INTEGER); | What was the total R&D expenditure for anti-inflammatory drugs? | SELECT SUM(expenditure) FROM rd_expenditure WHERE drug_class = 'anti-inflammatory'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantSales (sale_id INT, restaurant_id INT, menu_item_id INT, revenue DECIMAL(10,2)); INSERT INTO RestaurantSales (sale_id, restaurant_id, menu_item_id, revenue) VALUES (1, 1, 1, 100), (2, 1, 1, 200), (3, 1, 2, 150), (4, 2, 1, 250), (5, 2, 3, 300); | Identify the least profitable menu item for each restaurant | SELECT r.restaurant_name, m.menu_item_name, MIN(rs.revenue) as min_revenue FROM Restaurants r INNER JOIN RestaurantMenu rm ON r.restaurant_id = rm.restaurant_id INNER JOIN RestaurantSales rs ON rm.menu_item_id = rs.menu_item_id INNER JOIN MenuItems m ON rs.menu_item_id = m.menu_item_id GROUP BY r.restaurant_name, m.menu_item_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_investment (year INT, investor TEXT, investment_type TEXT, amount INT); INSERT INTO climate_investment (year, investor, investment_type, amount) VALUES (2020, 'World Bank', 'Climate Adaptation', 5000000), (2020, 'Asian Development Bank', 'Climate Adaptation', 7000000), (2020, 'African Development Bank', 'Climate Adaptation', 3000000), (2020, 'Inter-American Development Bank', 'Climate Adaptation', 8000000), (2020, 'European Investment Bank', 'Climate Adaptation', 4000000); | What is the total investment in climate adaptation by multilateral development banks in 2020? | SELECT SUM(amount) FROM climate_investment WHERE year = 2020 AND investment_type = 'Climate Adaptation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteH (id INT PRIMARY KEY, artifact_name VARCHAR(50), date_found DATE); CREATE TABLE SiteI (id INT PRIMARY KEY, artifact_name VARCHAR(50), description TEXT); INSERT INTO SiteH (id, artifact_name, date_found) VALUES (1, 'Copper Ring', '2021-01-05'), (2, 'Stone Bead', '2021-01-06'); INSERT INTO SiteI (id, artifact_name, description) VALUES (1, 'Bronze Mirror', 'An ancient bronze mirror'), (2, 'Clay Figurine', 'A small clay figurine'); | How many artifacts are present in 'SiteH' and 'SiteI'? | SELECT COUNT(*) FROM SiteH; SELECT COUNT(*) FROM SiteI; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, rating, ai_adoption) VALUES (1, 'Hotel A', 'India', 4.5, true), (2, 'Hotel B', 'Brazil', 4.2, false), (3, 'Hotel C', 'India', 4.7, true); | What is the average rating of hotels in India that have adopted AI technology? | SELECT AVG(rating) FROM hotels WHERE country = 'India' AND ai_adoption = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (date DATE, temperature FLOAT, region VARCHAR(255)); INSERT INTO arctic_weather (date, temperature, region) VALUES ('2020-01-01', -15.0, 'North'), ('2020-01-02', -16.5, 'North'); | Calculate the average temperature for each month across all regions in the 'arctic_weather' table. | SELECT EXTRACT(MONTH FROM date) AS month, AVG(temperature) AS avg_temperature FROM arctic_weather GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_vessels (vessel_name VARCHAR(255), location VARCHAR(255)); INSERT INTO research_vessels (vessel_name, location) VALUES ('Thompson', 'Pacific Ocean'), ('Franklin', 'Atlantic Ocean'); | How many research vessels are in the Pacific Ocean? | SELECT COUNT(*) FROM research_vessels WHERE location = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE geological_survey (mine_id INT, x_coordinate INT, y_coordinate INT, geological_feature TEXT); INSERT INTO geological_survey (mine_id, x_coordinate, y_coordinate, geological_feature) VALUES (1, 10, 20, 'Granite'), (1, 12, 22, 'Quartz'), (2, 15, 25, 'Shale'), (2, 18, 28, 'Limestone'); CREATE TABLE mines (mine_id INT, mine_name TEXT); INSERT INTO mines (mine_id, mine_name) VALUES (1, 'MineA'), (2, 'MineB'); | List the geological survey information for each mine, including the mine name, coordinates, and geological features. | SELECT m.mine_name, gs.x_coordinate, gs.y_coordinate, gs.geological_feature FROM geological_survey gs JOIN mines m ON gs.mine_id = m.mine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerId INT, CustomerName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Customers (CustomerId, CustomerName, Country) VALUES (1, 'Customer A', 'USA'); INSERT INTO Customers (CustomerId, CustomerName, Country) VALUES (2, 'Customer B', 'Canada'); INSERT INTO Customers (CustomerId, CustomerName, Country) VALUES (3, 'Customer C', 'Mexico'); INSERT INTO Customers (CustomerId, CustomerName, Country) VALUES (4, 'Customer D', 'Brazil'); | Which countries have more than 100 customers? | SELECT Country, COUNT(CustomerId) AS CustomerCount FROM Customers GROUP BY Country HAVING CustomerCount > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE FairTradeWorkers (id INT, country VARCHAR(50), num_workers INT); | What is the total number of workers in factories that are certified fair trade, by country? | SELECT country, SUM(num_workers) as total_workers FROM FairTradeWorkers GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE criminal_incidents (id INT, city VARCHAR(20), incident_date DATE); INSERT INTO criminal_incidents (id, city, incident_date) VALUES (1, 'Toronto', '2020-12-31'); | How many criminal incidents were reported in 'Toronto' in the year of '2020'? | SELECT COUNT(*) FROM criminal_incidents WHERE city = 'Toronto' AND incident_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE festivals (festival_id INT, festival_name VARCHAR(100), ticket_price DECIMAL(5,2), total_tickets_sold INT); INSERT INTO festivals (festival_id, festival_name, ticket_price, total_tickets_sold) VALUES (1, 'Platinum Music Fest', 150.00, 30000); INSERT INTO festivals (festival_id, festival_name, ticket_price, total_tickets_sold) VALUES (2, 'Summer Nights', 75.00, 25000); | What is the total revenue for 'Platinum Music Fest'? | SELECT festival_name, ticket_price * total_tickets_sold AS total_revenue FROM festivals WHERE festival_name = 'Platinum Music Fest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_population(city VARCHAR(50), year INT, population INT); INSERT INTO city_population(city, year, population) VALUES('CityA', 2021, 100000), ('CityA', 2020, 95000), ('CityB', 2021, 120000), ('CityB', 2020, 115000); | What was the average waste generation in kg per capita for each city in 2021? | SELECT w.city, AVG(w.amount/c.population) FROM waste_generation w JOIN city_population c ON w.city = c.city WHERE w.year = 2021 GROUP BY w.city; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, dish_id INT, order_date DATE); INSERT INTO orders (order_id, dish_id, order_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-01'), (3, 3, '2022-01-02'); CREATE TABLE category_mapping (category_id INT, category_name VARCHAR(255)); INSERT INTO category_mapping (category_id, category_name) VALUES (1, 'Pizza'), (2, 'Pasta'), (3, 'Salad'); | Identify the most popular category of dishes ordered | SELECT category_name, COUNT(*) as order_count FROM orders o JOIN category_mapping cm ON o.dish_id = cm.category_id GROUP BY category_name ORDER BY order_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact_assessments (mine_type VARCHAR(20), num_assessments INT); INSERT INTO environmental_impact_assessments (mine_type, num_assessments) VALUES ('Gold', 120), ('Gold', 130), ('Coal', 110), ('Coal', 115), ('Silver', 105), ('Silver', 100); | What's the total number of environmental impact assessments conducted in the gold mining sector? | SELECT SUM(num_assessments) FROM environmental_impact_assessments WHERE mine_type = 'Gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fashion_trends (id INT PRIMARY KEY, trend VARCHAR(25), popularity INT); | Create table for fashion trends | CREATE TABLE fashion_trends (id INT PRIMARY KEY, trend VARCHAR(25), popularity INT); | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name TEXT, cuisine TEXT, revenue INT); INSERT INTO restaurants (id, name, cuisine, revenue) VALUES (1, 'Restaurant A', 'Chinese', 8000), (2, 'Restaurant B', 'Mexican', 6000), (3, 'Restaurant C', 'Chinese', 9000), (4, 'Restaurant D', 'Indian', 7000); | Identify restaurants with the highest revenue in the Chinese cuisine type. | SELECT name, revenue FROM restaurants WHERE cuisine = 'Chinese' ORDER BY revenue DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritagesites2 (id INT, site_name VARCHAR(100), location VARCHAR(50)); INSERT INTO heritagesites2 (id, site_name, location) VALUES (1, 'Taj Mahal', 'India'), (2, 'Forbidden City', 'China'); | Identify overlapping heritage sites between India and China. | SELECT site_name FROM heritagesites2 WHERE location IN ('India', 'China') GROUP BY site_name HAVING COUNT(DISTINCT location) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE biomass_plants (name TEXT, capacity INTEGER, country TEXT); INSERT INTO biomass_plants (name, capacity, country) VALUES ('Biomass Plant 1', 800, 'India'), ('Biomass Plant 2', 900, 'India'); | What are the names and capacities of all biomass power plants in India? | SELECT name, capacity FROM biomass_plants WHERE country = 'India' | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(100), TotalVeganProducts INT); INSERT INTO Brands (BrandID, BrandName, TotalVeganProducts) VALUES (1, 'Brand X', 50), (2, 'Brand Y', 30), (3, 'Brand Z', 70), (4, 'Brand W', 40), (5, 'Brand V', 60); | List the top 3 brands with the most vegan products in the US. | SELECT BrandName, TotalVeganProducts FROM (SELECT BrandName, TotalVeganProducts, ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY TotalVeganProducts DESC) as rn FROM Brands WHERE Country = 'US') t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_projects (id INT, name VARCHAR(255), region VARCHAR(255), budget FLOAT, status VARCHAR(255)); INSERT INTO rural_projects (id, name, region, budget, status) VALUES (1, 'Water Supply', 'Africa', 150000.00, 'completed'); | What is the average budget of completed rural infrastructure projects in Africa? | SELECT AVG(budget) FROM rural_projects WHERE region = 'Africa' AND status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Program_Budgets (id INT, program_id INT, year INT, budget DECIMAL); INSERT INTO Program_Budgets (id, program_id, year, budget) VALUES (1, 1001, 2021, 10000.00), (2, 1002, 2021, 15000.00); | Remove a program's budget information | DELETE FROM Program_Budgets WHERE program_id = 1001; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_institutions (id INT, name TEXT, location TEXT, last_shariah_activity DATE); | List all financial institutions offering Shariah-compliant loans in Asia within the last 2 years. | SELECT name FROM financial_institutions WHERE location LIKE 'Asia%' AND last_shariah_activity BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) AND CURRENT_DATE AND offering_shariah_loans = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intel_2 (ip_address VARCHAR(20), threat_level VARCHAR(20), threat_score INT); INSERT INTO threat_intel_2 (ip_address, threat_level, threat_score) VALUES ('192.168.1.1', 'low', 10), ('10.0.0.1', 'high', 90), ('172.16.0.1', 'medium', 50); | What are the top 5 IP addresses with the highest threat levels? | SELECT ip_address, threat_level, threat_score FROM threat_intel_2 ORDER BY threat_score DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title TEXT, release_year INT, genre TEXT, streams INT); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (1, 'Song1', 2021, 'Pop', 180000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (2, 'Song2', 2021, 'Rock', 160000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (3, 'Song3', 2020, 'Jazz', 150000); CREATE TABLE artists (id INT, artist_name TEXT); | Calculate the total number of streams for each genre in 2021. | SELECT genre, SUM(streams) AS total_streams FROM songs WHERE release_year = 2021 GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255)); CREATE TABLE sales (sale_id INT, sale_date DATE, product_id INT); | Which products were sold in the first quarter of the year? | SELECT products.product_name FROM products JOIN sales ON products.product_id = sales.product_id WHERE QUARTER(sales.sale_date) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety (scenario TEXT, risk TEXT, description TEXT, mitigation TEXT); INSERT INTO ai_safety (scenario, risk, description, mitigation) VALUES ('Explainable AI', 'High', 'Lack of interpretability', 'Develop interpretable models'), ('Explainable AI', 'Medium', 'Limited transparency', 'Improve model documentation'); | Select records from 'ai_safety' table where 'Scenario' is 'Explainable AI' and 'Risk' is 'High' | SELECT * FROM ai_safety WHERE scenario = 'Explainable AI' AND risk = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (ID INT PRIMARY KEY, Country VARCHAR(50), AccommodationType VARCHAR(50), Quantity INT); INSERT INTO Accommodations (ID, Country, AccommodationType, Quantity) VALUES (1, 'USA', 'Sign Language Interpretation', 300), (2, 'Canada', 'Wheelchair Ramp', 250), (3, 'Mexico', 'Assistive Listening Devices', 150); | What is the total number of accommodations provided, per accommodation type? | SELECT AccommodationType, SUM(Quantity) as Total FROM Accommodations GROUP BY AccommodationType; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_pd (teacher_id INT, state VARCHAR(50), course VARCHAR(50)); INSERT INTO teacher_pd (teacher_id, state, course) VALUES (1, 'California', 'Open Pedagogy 101'), (2, 'Texas', 'Open Pedagogy 101'), (3, 'California', 'Open Pedagogy 202'); | How many teachers in each state have completed professional development courses on open pedagogy? | SELECT state, COUNT(DISTINCT teacher_id) as num_teachers FROM teacher_pd WHERE course = 'Open Pedagogy 101' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_ops (id INT, country VARCHAR(30), operation_type VARCHAR(30), operation_date DATE); INSERT INTO intelligence_ops (id, country, operation_type, operation_date) VALUES (1, 'USA', 'Surveillance', '2021-06-15'); INSERT INTO intelligence_ops (id, country, operation_type, operation_date) VALUES (2, 'Russia', 'Cyber Espionage', '2022-02-03'); | Show the number of intelligence operations conducted in the last 6 months by country. | SELECT country, COUNT(*) FROM intelligence_ops WHERE operation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name VARCHAR(50), gender VARCHAR(50), ethnicity VARCHAR(20), company_id INT, founding_year INT, two_spirit BOOLEAN); | How many companies were founded by individuals who identify as Two-Spirit in 2019? | SELECT COUNT(DISTINCT founders.company_id) FROM founders WHERE founders.two_spirit = true AND founders.founding_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_training (id INT PRIMARY KEY, employee_id INT, training_type VARCHAR(255), completion_date DATE); | List all unique training types in the diversity_training table | SELECT DISTINCT training_type FROM diversity_training; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorker (WorkerID INT, State CHAR(2), CulturalCompetencyScore INT); INSERT INTO CommunityHealthWorker (WorkerID, State, CulturalCompetencyScore) VALUES (1, 'CA', 85), (2, 'TX', 80), (3, 'CA', 90), (4, 'TX', 82); | Determine the difference in cultural competency scores between the highest and lowest scoring community health workers in each state. | SELECT State, MAX(CulturalCompetencyScore) - MIN(CulturalCompetencyScore) AS ScoreDifference FROM CommunityHealthWorker GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE attendees (id INT, event_name TEXT, attendee_age INT); INSERT INTO attendees (id, event_name, attendee_age) VALUES (1, 'Family-Friendly Concert', 30), (2, 'Family-Friendly Play', 40); | What is the average age of attendees at 'family-friendly' events? | SELECT AVG(attendee_age) FROM attendees WHERE event_name IN (SELECT event_name FROM events WHERE audience_rating = 'family-friendly'); | gretelai_synthetic_text_to_sql |
CREATE VIEW cruelty_free_products AS SELECT product_id, product_name FROM products WHERE cruelty_free = 'yes'; | Create a view to show cruelty-free certified products | CREATE VIEW cruelty_free_products AS SELECT product_id, product_name FROM products WHERE cruelty_free = 'yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cruelty_free_makeup (brand VARCHAR(255), product VARCHAR(255), rating DECIMAL(2,1), cruelty_free BOOLEAN); INSERT INTO cruelty_free_makeup (brand, product, rating, cruelty_free) VALUES ('Pacifica', 'Foundation', 4.3, true), ('NYX', 'Mascara', 4.5, true), ('e.l.f.', 'Eyeshadow', 4.2, true), ('Milani', 'Lipstick', 4.4, true); | Which cruelty-free makeup brands have the highest average rating? | SELECT brand, AVG(rating) as avg_rating FROM cruelty_free_makeup WHERE cruelty_free = true GROUP BY brand ORDER BY avg_rating DESC; | 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.