context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE healthcare_workers (id INT, name TEXT, age INT, city TEXT); INSERT INTO healthcare_workers (id, name, age, city) VALUES (1, 'John Doe', 35, 'Los Angeles'); INSERT INTO healthcare_workers (id, name, age, city) VALUES (2, 'Jane Smith', 40, 'Los Angeles'); | What is the average age of healthcare workers in Los Angeles County? | SELECT AVG(age) FROM healthcare_workers WHERE city = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_stations (id INT, station_name TEXT, country TEXT, depth FLOAT); | What is the average depth of marine life research stations in each country? | SELECT country, AVG(depth) FROM marine_life_research_stations GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists eai_techniques (technique_id INT PRIMARY KEY, name TEXT); INSERT INTO eai_techniques (technique_id, name) VALUES (1, 'Feature Attribution'), (2, 'Model Simplification'), (3, 'Rule Extraction'); CREATE TABLE if not exists ai_applications (app_id INT PRIMARY KEY, name TEXT, technique_id INT, industry TEXT); INSERT INTO ai_applications (app_id, name, technique_id, industry) VALUES (1, 'DeepHeart', 1, 'Healthcare'), (2, 'DeepDream', NULL, 'Art'), (3, 'Shelley', 3, 'Literature'); | What are the explainable AI techniques used in AI applications for healthcare? | SELECT DISTINCT eai_techniques.name FROM eai_techniques JOIN ai_applications ON eai_techniques.technique_id = ai_applications.technique_id WHERE ai_applications.industry = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (id INT, name VARCHAR(20), num_bridges INT); INSERT INTO states (id, name, num_bridges) VALUES (1, 'California', 25000), (2, 'Texas', 50000), (3, 'New York', 30000); | List the number of bridges in each state, ordered by the number of bridges in descending order. | SELECT name, num_bridges FROM states ORDER BY num_bridges DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE property_tax (id INT, state VARCHAR(20), property_tax INT, housing_type VARCHAR(20)); INSERT INTO property_tax (id, state, property_tax, housing_type) VALUES (1, 'California', 1500, 'affordable'), (2, 'California', 2000, 'affordable'), (3, 'California', 3000, 'market_rate'), (4, 'Texas', 1000, 'affordable'), (5, 'Texas', 1500, 'market_rate'); | What is the average property tax for affordable housing units in each state? | SELECT state, AVG(property_tax) FROM property_tax WHERE housing_type = 'affordable' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Intelligence_Operations (Name VARCHAR(255), Technology VARCHAR(255)); INSERT INTO Intelligence_Operations (Name, Technology) VALUES ('Operation Desert Spy', 'M1 Abrams'), ('Operation Desert Shield', 'AH-64 Apache'), ('Operation Desert Storm', 'M2 Bradley'); | What is the number of military technologies used in each intelligence operation? | SELECT Intelligence_Operations.Name, COUNT(Technology) FROM Intelligence_Operations GROUP BY Intelligence_Operations.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing_Union (union_member_id INT, member_id INT, salary FLOAT); INSERT INTO Manufacturing_Union (union_member_id, member_id, salary) VALUES (1, 101, 60000.00), (1, 102, 65000.00), (1, 103, 58000.00), (2, 201, 52000.00), (2, 202, 63000.00); | List the number of members in the 'Manufacturing_Union' who earn a salary above the average salary. | SELECT COUNT(union_member_id) FROM Manufacturing_Union WHERE salary > (SELECT AVG(salary) FROM Manufacturing_Union); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, year INT, region TEXT); INSERT INTO companies (id, name, year, region) VALUES (1, 'Zeta Pte', 2017, 'APAC'), (2, 'Eta Inc', 2018, 'NA'), (3, 'Theta LLC', 2016, 'EMEA'), (4, 'Iota Ltd', 2019, 'APAC'); | How many companies were founded in the last 5 years, by region? | SELECT region, COUNT(*) FROM companies WHERE year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists mental_health_parity (violation_id INT, violation_date DATE, state VARCHAR(255)); | Find the number of mental health parity violations by state in the last 6 months. | SELECT COUNT(*), state FROM mental_health_parity WHERE violation_date >= DATEADD(month, -6, GETDATE()) GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), HireDate DATE, Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Department, HireDate, Salary) VALUES (1, 'Sophia Lee', 'IT', '2023-01-15', 85000.00), (2, 'Ethan Chen', 'IT', '2023-02-20', 90000.00), (3, 'Mia Kim', 'HR', '2023-03-05', 70000.00); | What is the minimum salary among employees hired in the last six months, broken down by department? | SELECT Department, MIN(Salary) FROM Employees WHERE HireDate >= DATEADD(MONTH, -6, GETDATE()) GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(2), country VARCHAR(15), quantity INT, quarter INT, year INT); INSERT INTO production VALUES ('Dy', 'China', 500, 1, 2022), ('Tm', 'Australia', 200, 1, 2022), ('Dy', 'Australia', 300, 1, 2022); | What is the total quantity of Dy and Tm produced by each country in Q1 2022? | SELECT country, SUM(quantity) as total_quantity FROM production WHERE element IN ('Dy', 'Tm') AND quarter = 1 AND year = 2022 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_projects (project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO energy_efficiency_projects (project_name, location) VALUES ('Project A', 'Asia-Pacific'), ('Project B', 'Europe'), ('Project C', 'Asia-Pacific'), ('Project D', 'Americas'); | List all the energy efficiency projects in the Asia-Pacific region | SELECT project_name FROM energy_efficiency_projects WHERE location = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_customers (customer_id INT, data_usage FLOAT, country VARCHAR(50)); INSERT INTO broadband_customers (customer_id, data_usage, country) VALUES (1, 3.5, 'United States'), (2, 4.2, 'Canada'), (3, 5.1, 'Mexico'); CREATE VIEW data_usage_view AS SELECT country, SUM(data_usage) as total_data_usage FROM broadband_customers GROUP BY country; | What is the data usage for broadband customers in a specific country? | SELECT country, total_data_usage, total_data_usage/SUM(total_data_usage) OVER (PARTITION BY country) as data_usage_percentage FROM data_usage_view; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_basins (id INT, name TEXT); CREATE TABLE ocean_acidification (id INT, ocean_basin_id INT, acidification_level FLOAT); INSERT INTO ocean_basins VALUES (1, 'Atlantic'), (2, 'Pacific'), (3, 'Indian'); INSERT INTO ocean_acidification VALUES (1, 1, -7850), (2, 1, -7880), (3, 2, -7930), (4, 3, -7820); | What is the maximum ocean acidification level for each ocean basin? | SELECT ob.name, MAX(oa.acidification_level) as max_acidification FROM ocean_basins ob INNER JOIN ocean_acidification oa ON ob.id = oa.ocean_basin_id GROUP BY ob.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE trainings (training_id INT, year INT, country VARCHAR(255), num_farmers INT); INSERT INTO trainings VALUES (1, 2018, 'Guatemala', 500), (2, 2019, 'Guatemala', 600), (3, 2020, 'Guatemala', 700), (4, 2021, 'Guatemala', 800); | What is the number of farmers trained in sustainable farming practices in Guatemala in 2019? | SELECT num_farmers FROM trainings WHERE country = 'Guatemala' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours_co (tour_id INT, tour_name VARCHAR(255), country VARCHAR(255), duration INT); INSERT INTO virtual_tours_co (tour_id, tour_name, country, duration) VALUES (1, 'Virtual Tour Bogota', 'Colombia', 60); INSERT INTO virtual_tours_co (tour_id, tour_name, country, duration) VALUES (2, 'Virtual Tour Medellin', 'Colombia', 75); INSERT INTO virtual_tours_co (tour_id, tour_name, country, duration) VALUES (3, 'Virtual Tour Cartagena', 'Colombia', 90); | What is the average duration of virtual tours in Colombia? | SELECT country, AVG(duration) FROM virtual_tours_co WHERE country = 'Colombia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response (family_id INT, region VARCHAR(20), disaster_type VARCHAR(20), amount_aid FLOAT); INSERT INTO disaster_response (family_id, region, disaster_type, amount_aid) VALUES (1, 'Central America', 'Flood', 5000), (2, 'Central America', 'Earthquake', 7000), (3, 'Central America', 'Flood', 6000); | What is the average monetary aid received per family in Central America, grouped by disaster type, ordered by the highest average? | SELECT disaster_type, AVG(amount_aid) as avg_aid FROM disaster_response WHERE region = 'Central America' GROUP BY disaster_type ORDER BY avg_aid DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE biosensor_development (id INT, biosensor_name VARCHAR(50), sensor_type VARCHAR(50), data TEXT, date DATE); INSERT INTO biosensor_development (id, biosensor_name, sensor_type, data, date) VALUES (1, 'BioSensor 1', 'optical', 'Sensor data 1', '2023-01-01'); INSERT INTO biosensor_development (id, biosensor_name, sensor_type, data, date) VALUES (2, 'BioSensor 2', 'electrochemical', 'Sensor data 2', '2022-02-01'); | Display the names of biosensors, their types, and the date of development from the 'biosensor_development' table for biosensors developed on or after 'January 1, 2023'. | SELECT biosensor_name, sensor_type, date FROM biosensor_development WHERE date >= '2023-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, fabric TEXT, revenue DECIMAL); INSERT INTO sales (id, fabric, revenue) VALUES (1, 'Organic Cotton', 1500), (2, 'Recycled Polyester', 2000), (3, 'Conventional Cotton', 1000), (4, 'Nylon', 1200); | What is the proportion of sales from sustainable fabrics? | SELECT SUM(CASE WHEN fabric IN ('Organic Cotton', 'Recycled Polyester') THEN revenue ELSE 0 END) / SUM(revenue) FROM sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE ChemicalProduction (date DATE, chemical VARCHAR(10), mass FLOAT); INSERT INTO ChemicalProduction (date, chemical, mass) VALUES ('2021-01-01', 'A', 100), ('2021-01-01', 'B', 150), ('2021-01-02', 'A', 120), ('2021-01-02', 'B', 170); | What is the total mass of chemical 'A' produced per month? | SELECT DATE_FORMAT(date, '%Y-%m') as Month, SUM(mass) as TotalMass FROM ChemicalProduction WHERE chemical = 'A' GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE buses (route_id INT, city VARCHAR(50), fare DECIMAL(5,2)); INSERT INTO buses (route_id, city, fare) VALUES (1, 'New York', 2.50), (2, 'New York', 2.75), (3, 'Los Angeles', 1.75); | What is the average fare for buses in New York? | SELECT AVG(fare) FROM buses WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantGuide (RestaurantID int, City varchar(50), Stars int); | Which cities have the most restaurants with a Michelin star, and how many restaurants are there in each city? | SELECT City, COUNT(*) FROM RestaurantGuide WHERE Stars = 1 GROUP BY City ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE reservoirs (reservoir_id INT, reservoir_name VARCHAR(255), field_name VARCHAR(255), oil_grade VARCHAR(255), gas_content FLOAT); | Insert a new record into the 'reservoirs' table for reservoir 'R-02' in field 'F-01' with gas content 90 and oil grade 'heavy' | INSERT INTO reservoirs (reservoir_id, reservoir_name, field_name, oil_grade, gas_content) VALUES (NULL, 'R-02', 'F-01', 'heavy', 90); | gretelai_synthetic_text_to_sql |
CREATE TABLE harvested_trees (id INT, species VARCHAR(50), volume FLOAT); | List all the distinct 'species' names in the 'harvested_trees' table. | SELECT DISTINCT species FROM harvested_trees; | gretelai_synthetic_text_to_sql |
CREATE TABLE voyages (voyage_id INT, vessel_id VARCHAR(10), departure_date DATE); INSERT INTO voyages (voyage_id, vessel_id, departure_date) VALUES (1, 'vessel_x', '2022-01-02'), (2, 'vessel_y', '2022-02-03'), (3, 'vessel_z', '2022-03-04'); | What is the earliest departure date for vessel_x? | SELECT MIN(departure_date) FROM voyages WHERE vessel_id = 'vessel_x'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA attendance; CREATE TABLE event_attendance (attendance_id INT, event_id INT, country VARCHAR(50), event_month VARCHAR(10), attendees INT); INSERT INTO attendance.event_attendance (attendance_id, event_id, country, event_month, attendees) VALUES (1, 1, 'France', 'January', 200), (2, 2, 'Germany', 'February', 300), (3, 3, 'Italy', 'March', 150), (4, 4, 'Spain', 'January', 250), (5, 5, 'UK', 'February', 400); | What is the average attendance at cultural events in Europe by month? | SELECT event_month, AVG(attendees) as average_attendance FROM attendance.event_attendance GROUP BY event_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE org_ethics (org_id INT, org_name TEXT, region TEXT); INSERT INTO org_ethics (org_id, org_name, region) VALUES (1, 'OrgD', 'Europe'), (2, 'OrgE', 'Asia-Pacific'), (3, 'OrgF', 'Europe'); | What are the names of organizations working on ethical AI in Europe? | SELECT org_name FROM org_ethics WHERE region = 'Europe' AND initiative = 'ethical AI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, fund_name VARCHAR(255), sector VARCHAR(255), investment_amount FLOAT); | Which fund has invested the least in the renewable energy sector? | SELECT fund_name, MIN(investment_amount) as least_investment FROM investments WHERE sector = 'renewable energy' GROUP BY fund_name ORDER BY least_investment LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (id INT, dispensary VARCHAR(255), fine FLOAT, violation DATE); | Insert a new record into 'regulatory_compliance' table for 'Green Earth Dispensary' with a fine of $2000 and violation date of '2022-01-01'. | INSERT INTO regulatory_compliance (dispensary, fine, violation) VALUES ('Green Earth Dispensary', 2000, '2022-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE dams (id INT, name VARCHAR(50), category VARCHAR(50), year_built INT); INSERT INTO dams (id, name, category, year_built) VALUES (1, 'Hoover Dam', 'hydroelectric', 1936); INSERT INTO dams (id, name, category, year_built) VALUES (2, 'Grand Coulee Dam', 'hydroelectric', 1942); INSERT INTO dams (id, name, category, year_built) VALUES (3, 'Agua Caliente Dam', 'concrete', 1951); | Count the number of dams built before 1950 | SELECT COUNT(*) FROM dams WHERE year_built < 1950; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT, JoinDate DATE); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country, JoinDate) VALUES (1, 'Ali', 'Pakistan', '2021-01-01'), (2, 'Sophia', 'China', '2020-06-15'); | What is the number of volunteers from Asia who have joined in the last year? | SELECT COUNT(*) FROM Volunteers WHERE Country IN ('Pakistan', 'India', 'China', 'Japan', 'Vietnam') AND JoinDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists regulatory_violations (violation_id INT, network VARCHAR(255), violation_details VARCHAR(255)); INSERT INTO regulatory_violations (violation_id, network, violation_details) VALUES (1, 'Ethereum', 'Smart contract vulnerabilities'), (2, 'Binance Smart Chain', 'Lack of KYC'), (3, 'Tron', 'Centralization concerns'), (4, 'Cardano', 'Regulatory uncertainty'), (5, 'Polkadot', 'Data privacy issues'), (6, 'Solana', 'Lack of transparency'); | What is the number of regulatory violations for each blockchain network? | SELECT network, COUNT(*) as violation_count FROM regulatory_violations GROUP BY network; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipping.vessels (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO shipping.vessels (id, name, type, capacity) VALUES (1, 'VesselA', 'Refrigerated', 5000), (2, 'VesselB', 'Dry Bulk', 8000), (3, 'VesselC', 'Refrigerated', 6000), (4, 'VesselD', 'Dry Bulk', 9000); | List the number of vessels and their average capacity by type in the 'shipping' schema. | SELECT type, AVG(capacity) FROM shipping.vessels GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, FirstName VARCHAR(50), LastName VARCHAR(50)); INSERT INTO Members (MemberID, FirstName, LastName) VALUES (1, 'John', 'Doe'); INSERT INTO Members (MemberID, FirstName, LastName) VALUES (2, 'Jane', 'Doe'); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (1, 1, '2022-01-12'); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (2, 1, '2022-02-13'); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (3, 2, '2022-01-15'); | Identify members who attended workout sessions in both January and February 2022. | SELECT DISTINCT m.MemberID, m.FirstName, m.LastName FROM Members m INNER JOIN Workouts w1 ON m.MemberID = w1.MemberID INNER JOIN Workouts w2 ON m.MemberID = w2.MemberID WHERE w1.WorkoutDate >= '2022-01-01' AND w1.WorkoutDate < '2022-02-01' AND w2.WorkoutDate >= '2022-02-01' AND w2.WorkoutDate < '2022-03-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'John Doe', 35, 'USA'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Jane Smith', 40, 'Canada'); CREATE TABLE Crops (id INT, farmer_id INT, crop_name VARCHAR(50), yield INT, sale_price DECIMAL(5,2)); INSERT INTO Crops (id, farmer_id, crop_name, yield, sale_price) VALUES (1, 1, 'Corn', 120, 2.35); INSERT INTO Crops (id, farmer_id, crop_name, yield, sale_price) VALUES (2, 2, 'Soybeans', 80, 3.50); | Determine the most expensive crop type and the farmer who grows it. | SELECT c.crop_name, MAX(c.sale_price) as max_price FROM Crops c JOIN Farmers f ON c.farmer_id = f.id GROUP BY c.crop_name HAVING MAX(c.sale_price) = (SELECT MAX(c2.sale_price) FROM Crops c2); | gretelai_synthetic_text_to_sql |
CREATE TABLE language_stats (id INT, city VARCHAR(20), country VARCHAR(10), language VARCHAR(10), num_tourists INT); INSERT INTO language_stats (id, city, country, language, num_tourists) VALUES (1, 'Sydney', 'Australia', 'English', 50000), (2, 'Sydney', 'China', 'Mandarin', 20000), (3, 'Sydney', 'USA', 'English', 30000); | What percentage of tourists visiting Sydney speak English? | SELECT (SUM(CASE WHEN language = 'English' THEN num_tourists ELSE 0 END) * 100.0 / SUM(num_tourists)) AS percentage FROM language_stats WHERE city = 'Sydney'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_patents (country VARCHAR(50), patent_number INTEGER); INSERT INTO military_patents (country, patent_number) VALUES ('USA', 12345), ('USA', 67890), ('South Korea', 78901), ('UK', 34567), ('Canada', 90123); | List the military innovation patents filed by South Korea? | SELECT country, patent_number FROM military_patents WHERE country = 'South Korea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Faculty (FacultyID int, Name varchar(50), ResearchInterest varchar(50)); INSERT INTO Faculty (FacultyID, Name, ResearchInterest) VALUES (1, 'John Smith', 'Machine Learning'); INSERT INTO Faculty (FacultyID, Name, ResearchInterest) VALUES (2, 'Jane Doe', 'Data Science'); CREATE TABLE Grants (GrantID int, Grantor varchar(50), FacultyID int); INSERT INTO Grants (GrantID, Grantor, FacultyID) VALUES (1, 'National Science Foundation', 1); INSERT INTO Grants (GrantID, Grantor, FacultyID) VALUES (2, 'Microsoft Research', 2); | What are the names and research interests of faculty members who have received grants from the 'National Science Foundation'? | SELECT Faculty.Name, Faculty.ResearchInterest FROM Faculty INNER JOIN Grants ON Faculty.FacultyID = Grants.FacultyID WHERE Grants.Grantor = 'National Science Foundation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE freight_costs (country VARCHAR(255), import_value DECIMAL(10,2), quarter INT, year INT); INSERT INTO freight_costs (country, import_value, quarter, year) VALUES ('China', 15000.00, 3, 2022), ('USA', 12000.00, 3, 2022), ('India', 9000.00, 3, 2022); | What is the total freight cost for the top 2 countries that imported the most goods from Africa in Q3 2022? | SELECT f.country, SUM(f.import_value) as total_cost FROM freight_costs f WHERE f.quarter = 3 AND f.year = 2022 GROUP BY f.country ORDER BY total_cost DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (id INT, vessel_id INT, compliance_status VARCHAR(20)); | Insert a new record into the regulatory_compliance table with the following data: vessel_id 1301, compliance_status 'Compliant' | INSERT INTO regulatory_compliance (vessel_id, compliance_status) VALUES (1301, 'Compliant'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ResourcesDepleted (ResourceDepletedID INT, Operation VARCHAR(50), Quarter INT, Year INT, Quantity DECIMAL(10,2)); INSERT INTO ResourcesDepleted (ResourceDepletedID, Operation, Quarter, Year, Quantity) VALUES (1, 'Coal', 2, 2021, 550); INSERT INTO ResourcesDepleted (ResourceDepletedID, Operation, Quarter, Year, Quantity) VALUES (2, 'Iron', 2, 2021, 450); | List all mining operations that have depleted more than 500 units of resources in Q2 2021. | SELECT Operation FROM ResourcesDepleted WHERE Quarter = 2 AND Year = 2021 AND Quantity > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop (id INTEGER, type TEXT, temperature FLOAT, humidity FLOAT, date DATE, region_id INTEGER);CREATE TABLE region (id INTEGER, name TEXT); | What is the average temperature and humidity for each crop type in the current month, grouped by geographical regions? | SELECT r.name as region, c.type as crop, AVG(c.temperature) as avg_temp, AVG(c.humidity) as avg_hum FROM crop c INNER JOIN region r ON c.region_id = r.id WHERE c.date >= DATEADD(month, 0, DATEADD(day, DATEDIFF(day, 0, CURRENT_DATE), 0)) AND c.date < DATEADD(month, 1, DATEADD(day, DATEDIFF(day, 0, CURRENT_DATE), 0)) GROUP BY r.name, c.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_research_funding (id INT, researcher VARCHAR(255), project VARCHAR(255), amount FLOAT); INSERT INTO ai_research_funding (id, researcher, project, amount) VALUES (1, 'Dana', 'Fair AI', 50000), (2, 'Eli', 'Explainable AI', 75000), (3, 'Fiona', 'Fair AI', 60000), (4, 'Dana', 'Explainable AI', 80000); | Identify researchers who have received funding for both Fair AI and Explainable AI projects. | SELECT researcher FROM ai_research_funding WHERE project IN ('Fair AI', 'Explainable AI') GROUP BY researcher HAVING COUNT(DISTINCT project) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE models (model_id INT, name VARCHAR(255), country VARCHAR(255), safety_score FLOAT); INSERT INTO models (model_id, name, country, safety_score) VALUES (1, 'ModelA', 'USA', 0.92), (2, 'ModelB', 'Canada', 0.88), (3, 'ModelC', 'USA', 0.95); | What is the maximum safety score for models developed in the US? | SELECT MAX(safety_score) FROM models WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE academic_papers_by_dept (paper_id INT, student_id INT, department TEXT, published_year INT); INSERT INTO academic_papers_by_dept (paper_id, student_id, department, published_year) VALUES (1, 1, 'Mathematics', 2018), (2, 2, 'Computer Science', 2019), (3, 3, 'Physics', 2020), (4, 4, 'Mathematics', 2019); | Determine the annual trend of academic papers published per department from 2018 to 2021. | SELECT published_year, department, AVG(CASE WHEN published_year IS NOT NULL THEN 1.0 ELSE 0.0 END) as avg_papers_per_dept FROM academic_papers_by_dept GROUP BY published_year, department ORDER BY published_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (id INT, country VARCHAR(50), price DECIMAL(5,2)); INSERT INTO sustainable_materials (id, country, price) VALUES (1, 'United States', 15.99), (2, 'Brazil', 12.50); | Find the average price of sustainable materials sourced from each country. | SELECT country, AVG(price) FROM sustainable_materials GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, country TEXT, ocean TEXT, sustainable BOOLEAN, num_fish INT); INSERT INTO fish_farms (id, name, country, ocean, sustainable, num_fish) VALUES (1, 'Farm A', 'Country A', 'Pacific', true, 500), (2, 'Farm B', 'Country B', 'Pacific', false, 700), (3, 'Farm C', 'Country A', 'Pacific', true, 800); | What is the maximum number of fish in each sustainable fish farm in the Pacific ocean? | SELECT sustainable, MAX(num_fish) FROM fish_farms WHERE ocean = 'Pacific' GROUP BY sustainable; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (name VARCHAR(255), location VARCHAR(255), population INT); INSERT INTO marine_mammals (name, location, population) VALUES ('Blue Whale', 'Pacific Ocean', 2000), ('Dolphin', 'Atlantic Ocean', 1500), ('Seal', 'Arctic Ocean', 1000); | How many marine mammals are found in the Pacific Ocean? | SELECT SUM(population) FROM marine_mammals WHERE location = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_conservation_funding (year INT, funding INT); INSERT INTO marine_conservation_funding (year, funding) VALUES (2020, 5000000), (2021, 5500000), (2022, 6000000); | What is the maximum funding for marine conservation in a single year? | SELECT MAX(funding) FROM marine_conservation_funding; | gretelai_synthetic_text_to_sql |
CREATE TABLE promethium_production (country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO promethium_production (country, price) VALUES ('Australia', 120.00); | What is the minimum price of promethium produced in Australia? | SELECT MIN(price) FROM promethium_production WHERE country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Wind_Farms (project_id INT, location VARCHAR(50), capacity FLOAT); INSERT INTO Wind_Farms (project_id, location, capacity) VALUES (1, 'Germany', 120.5), (2, 'France', 95.3), (3, 'Germany', 152.8), (4, 'Spain', 119.9); | What is the maximum capacity of Wind Farms in Germany? | SELECT MAX(capacity) FROM Wind_Farms WHERE location = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, country VARCHAR(50), waste_amount FLOAT, quarter INT, year INT); INSERT INTO waste_generation (id, country, waste_amount, quarter, year) VALUES (1, 'Japan', 120000, 1, 2020), (2, 'Japan', 125000, 2, 2020), (3, 'Japan', 130000, 3, 2020), (4, 'Japan', 135000, 4, 2020); | Determine the change in waste generation per quarter for Japan in 2020, compared to the previous quarter. | SELECT LAG(waste_amount) OVER (PARTITION BY country ORDER BY year, quarter) + LAG(waste_amount) OVER (PARTITION BY country ORDER BY year, quarter) - waste_amount as diff FROM waste_generation WHERE country = 'Japan' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_grants (id INT, student_id INT, department VARCHAR(255), amount FLOAT); INSERT INTO research_grants (id, student_id, department, amount) VALUES (1, 1001, 'engineering', 50000.00), (2, 1002, 'biology', 75000.00), (3, 1003, 'engineering', 60000.00); CREATE TABLE graduate_students (id INT, name VARCHAR(255), department VARCHAR(255)); INSERT INTO graduate_students (id, name, department) VALUES (1001, 'Alice', 'engineering'), (1002, 'Bob', 'biology'), (1003, 'Charlie', 'engineering'); | Calculate the average amount of research grants awarded to graduate students in the "engineering" department | SELECT AVG(rg.amount) FROM research_grants rg INNER JOIN graduate_students gs ON rg.student_id = gs.id WHERE gs.department = 'engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Permits (PermitID INT, ProjectID INT, PermitType CHAR(1), PermitDate DATE, State CHAR(2)); | What is the total number of permits issued in each state for residential projects? | SELECT State, COUNT(*) FROM Permits WHERE PermitType='R' GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE TRAIN_RIDERS (id INT, name VARCHAR(50), boarding_time TIMESTAMP); CREATE TABLE TRAIN_ROUTES (route_number INT, start_time TIMESTAMP, end_time TIMESTAMP); INSERT INTO TRAIN_ROUTES VALUES (202, '2021-03-16 12:00:00', '2021-03-16 13:00:00'); INSERT INTO TRAIN_RIDERS VALUES (2, 'John Doe', '2021-03-16 12:30:00'); | Delete the record of the passenger who boarded the train with the route 202 on March 16, 2021 at 12:30 PM. | DELETE FROM TRAIN_RIDERS WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, WorkoutType VARCHAR(50), MemberID INT); INSERT INTO Workouts (WorkoutID, WorkoutType, MemberID) VALUES (1, 'Running', 1); INSERT INTO Workouts (WorkoutID, WorkoutType, MemberID) VALUES (2, 'Yoga', 2); CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Gender VARCHAR(50)); INSERT INTO Members (MemberID, Name, Gender) VALUES (1, 'John Doe', 'Male'); INSERT INTO Members (MemberID, Name, Gender) VALUES (2, 'Jane Smith', 'Female'); | List all the unique workout types that were performed by female members? | SELECT DISTINCT WorkoutType FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.Gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (id INT, name TEXT, type TEXT); INSERT INTO strains (id, name, type) VALUES (7, 'Sour Diesel', 'Sativa'), (8, 'Diesel', 'Indica'), (9, 'NYC Diesel', 'Hybrid'); CREATE TABLE sales (id INT, strain_id INT, retail_price DECIMAL, sale_date DATE, state TEXT); INSERT INTO sales (id, strain_id, retail_price, sale_date, state) VALUES (26, 7, 32.00, '2022-04-15', 'Colorado'), (27, 8, 34.00, '2022-05-01', 'Colorado'), (28, 9, 36.00, '2022-06-15', 'Colorado'); | Determine the total sales revenue for strains with 'Diesel' in their name in Colorado dispensaries during Q2 2022. | SELECT SUM(retail_price) FROM sales INNER JOIN strains ON sales.strain_id = strains.id WHERE state = 'Colorado' AND sale_date >= '2022-04-01' AND sale_date < '2022-07-01' AND strains.name LIKE '%Diesel%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tunnel (id INT, name TEXT, location TEXT, length FLOAT, type TEXT); INSERT INTO Tunnel (id, name, location, length, type) VALUES (1, 'Gotthard Base Tunnel', 'Switzerland', 57000, 'Rail'), (2, 'Brenner Base Tunnel', 'Italy', 64000, 'Rail'); | What is the maximum length for rail tunnels in Italy? | SELECT MAX(length) FROM Tunnel WHERE location = 'Italy' AND type = 'Rail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (project_id INT, region VARCHAR(50), start_date DATE); INSERT INTO DefenseProjects (project_id, region, start_date) VALUES (1, 'W', '2020-01-01'); INSERT INTO DefenseProjects (project_id, region, start_date) VALUES (2, 'W', '2021-01-01'); | What is the earliest and latest start date for defense projects in region W? | SELECT region, MIN(start_date) as earliest_start_date, MAX(start_date) as latest_start_date FROM DefenseProjects WHERE region = 'W' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT PRIMARY KEY, company VARCHAR(255), value DECIMAL(10,2), date DATE); | Create a view that displays the total number of defense contracts awarded to each company in the 'defense_contracts' table | CREATE VIEW contract_summary AS SELECT company, COUNT(*) as total_contracts FROM defense_contracts GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE nyc_water_consumption (id INT, date DATE, person_id INT, water_consumption FLOAT); INSERT INTO nyc_water_consumption (id, date, person_id, water_consumption) VALUES (1, '2023-02-01', 1, 20.0), (2, '2023-02-02', 2, 25.0); | What is the average daily water consumption per person in New York City over the last month? | SELECT AVG(water_consumption / person_size) FROM nyc_water_consumption WHERE date >= DATEADD(month, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, Name varchar(50), Gender varchar(10), Department varchar(50), Salary decimal(10,2), JoinDiversityInitiative int); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Salary, JoinDiversityInitiative) VALUES (1, 'John Doe', 'Male', 'IT', 75000.00, 1); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Salary, JoinDiversityInitiative) VALUES (2, 'Jane Smith', 'Female', 'IT', 80000.00, 1); | What is the average salary of employees who joined through a diversity initiative in the IT department, broken down by gender? | SELECT Gender, AVG(Salary) FROM Employees WHERE Department = 'IT' AND JoinDiversityInitiative = 1 GROUP BY Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE FashionTrends (TrendID INT, TrendName VARCHAR(50), Category VARCHAR(50)); | Insert new fashion trends for the fall season, associating them with the correct category. | INSERT INTO FashionTrends (TrendID, TrendName, Category) VALUES (1, 'Oversized Blazers', 'Outerwear'), (2, 'Wide Leg Pants', 'Bottoms'), (3, 'Cropped Cardigans', 'Tops'); | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity_south_america (country TEXT, capacity INTEGER, year INTEGER, area TEXT); | What is the total landfill capacity, in 2022, in urban areas in South America? | SELECT SUM(capacity) FROM landfill_capacity_south_america WHERE area = 'South America' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(50), country VARCHAR(50), training_sustainable BOOLEAN); | What is the total number of farmers who have received training in sustainable farming practices, per country, in the past year? | SELECT country, COUNT(*) as total_trained FROM farmers WHERE training_sustainable = TRUE AND date(training_date) >= date('now','-1 year') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, production_budget DECIMAL(10,2), director VARCHAR(255)); | Who are the top 3 directors with the highest total production budget? | SELECT director, SUM(production_budget) as total_budget FROM movies GROUP BY director ORDER BY total_budget DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE systems (system_id INT, system_name VARCHAR(255)); CREATE TABLE vulnerabilities (vulnerability_id INT, system_id INT, vulnerability_type VARCHAR(255)); | What are the top 10 most common vulnerabilities across all systems? | SELECT v.vulnerability_type, COUNT(*) as count FROM vulnerabilities v JOIN systems s ON v.system_id = s.system_id GROUP BY v.vulnerability_type ORDER BY count DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_data (country VARCHAR(255), year INT, score INT); INSERT INTO country_data (country, year, score) VALUES ('India', 2023, 98), ('China', 2023, 96), ('Japan', 2023, 99); | What is the maximum cultural heritage preservation score for any country in 2023? | SELECT MAX(score) FROM country_data WHERE year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Ethnicity VARCHAR(255), ImplicitBiasTraining DATE); INSERT INTO CommunityHealthWorkers (WorkerID, Ethnicity, ImplicitBiasTraining) VALUES (1, 'Hispanic', '2022-01-10'); INSERT INTO CommunityHealthWorkers (WorkerID, Ethnicity, ImplicitBiasTraining) VALUES (2, 'African American', '2021-12-15'); INSERT INTO CommunityHealthWorkers (WorkerID, Ethnicity, ImplicitBiasTraining) VALUES (3, 'Asian', '2022-02-03'); INSERT INTO CommunityHealthWorkers (WorkerID, Ethnicity, ImplicitBiasTraining) VALUES (4, 'Native American', '2021-08-02'); | What is the total number of community health workers who have received implicit bias training, broken down by their ethnicity? | SELECT Ethnicity, COUNT(*) as Total FROM CommunityHealthWorkers WHERE ImplicitBiasTraining IS NOT NULL GROUP BY Ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (restaurant VARCHAR(255), item VARCHAR(255), cost FLOAT); INSERT INTO menus (restaurant, item, cost) VALUES ('Home Cooking', 'chicken', 10.0); | What is the cost of 'chicken' at 'Home Cooking'? | SELECT cost FROM menus WHERE restaurant = 'Home Cooking' AND item = 'chicken'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_depths (ocean_name TEXT, avg_depth REAL); INSERT INTO ocean_depths (ocean_name, avg_depth) VALUES ('Pacific Ocean', 4028.0), ('Indian Ocean', 3963.0), ('Atlantic Ocean', 3926.0); | What is the average depth of all oceans? | SELECT AVG(avg_depth) FROM ocean_depths; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (product_id INT, product_origin VARCHAR(50), category VARCHAR(50), quantity INT); INSERT INTO inventory (product_id, product_origin, category, quantity) VALUES (1, 'Mexico', 'Low Stock', 20), (2, 'Peru', 'In Stock', 50), (3, 'Mexico', 'In Stock', 75); | What is the minimum quantity for each product category (low stock and in stock) for products made in Mexico? | SELECT product_origin, category, MIN(quantity) as min_quantity FROM inventory WHERE product_origin = 'Mexico' GROUP BY product_origin, category; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_category VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO menu_items (menu_category, revenue) VALUES ('Appetizers', 1500.00), ('Entrees', 3500.00), ('Desserts', 2000.00); CREATE TABLE time_dim (date DATE); INSERT INTO time_dim (date) VALUES ('2022-01-01'), ('2022-01-02'), ('2022-01-03'); | Find the total revenue for each menu category in the month of January 2022 | SELECT menu_category, SUM(revenue) as total_revenue FROM menu_items MI JOIN time_dim TD ON DATE('2022-01-01') = TD.date GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, employee_id INT, salary INT); INSERT INTO salaries (id, employee_id, salary) VALUES (1, 1, 50000), (2, 2, 55000), (3, 3, 60000); | What is the average salary of employees in the 'engineering' department? | SELECT AVG(salary) FROM salaries JOIN employees ON salaries.employee_id = employees.id WHERE employees.department = 'engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Monthly (MonthID INT, SongID INT, Month VARCHAR(50), Revenue INT); | What is the average revenue per month for the Rock genre? | SELECT Monthly.Month, AVG(Monthly.Revenue) as AvgRevenuePerMonth FROM Monthly INNER JOIN Song ON Monthly.SongID = Song.SongID WHERE Song.GenreID = (SELECT GenreID FROM Genre WHERE Name='Rock') GROUP BY Monthly.Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE GeothermalCapacity (project_id INT, name VARCHAR(100), location VARCHAR(100), capacity INT); INSERT INTO GeothermalCapacity (project_id, name, location, capacity) VALUES (1, 'Geothermal Plant 1', 'Iceland', 120), (2, 'Geothermal Plant 2', 'Italy', 180); | List all geothermal power plants in the "GeothermalProjects" schema, along with their total installed capacity in MW. | SELECT project_id, name, location, capacity FROM GeothermalProjects.GeothermalCapacity; | gretelai_synthetic_text_to_sql |
CREATE TABLE asiahotels (id INT, name VARCHAR(255), star_rating INT, has_ai BOOLEAN); INSERT INTO asiahotels (id, name, star_rating, has_ai) VALUES (1, 'AI Smart Hotel', 5, 1); INSERT INTO asiahotels (id, name, star_rating, has_ai) VALUES (2, 'Traditional Hotel', 5, 0); | How many 5-star hotels in the 'Asia' region have adopted AI-powered services? | SELECT COUNT(*) FROM asiahotels WHERE star_rating = 5 AND has_ai = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE california_water_usage (state VARCHAR(20), sector VARCHAR(20), usage INT); INSERT INTO california_water_usage (state, sector, usage) VALUES ('California', 'Agricultural', 12000); CREATE TABLE texas_water_usage (state VARCHAR(20), sector VARCHAR(20), usage INT); INSERT INTO texas_water_usage (state, sector, usage) VALUES ('Texas', 'Agricultural', 15000); | What is the total water usage by agricultural sector in California and Texas? | SELECT usage FROM california_water_usage WHERE sector = 'Agricultural' UNION SELECT usage FROM texas_water_usage WHERE sector = 'Agricultural' | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists funding_canada;CREATE TABLE if not exists funding_canada.startups (id INT, name VARCHAR(100), province VARCHAR(50), funding DECIMAL(10,2));INSERT INTO funding_canada.startups (id, name, province, funding) VALUES (1, 'StartupA', 'Ontario', 3000000.00), (2, 'StartupB', 'Quebec', 1000000.00), (3, 'StartupC', 'Ontario', 500000.00), (4, 'StartupD', 'British Columbia', 2000000.00); | What is the maximum and minimum funding received by biotech startups in each Canadian province? | SELECT province, MAX(funding) as max_funding, MIN(funding) as min_funding FROM funding_canada.startups GROUP BY province; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (violation_id INT, region_id INT, violation_count INT); CREATE TABLE regions (region_id INT, region_name TEXT); INSERT INTO violations (violation_id, region_id, violation_count) VALUES (1, 1, 10), (2, 1, 20), (3, 2, 30), (4, 3, 40); INSERT INTO regions (region_id, region_name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); | Find the number of labor rights violations in each region. | SELECT regions.region_name, SUM(violations.violation_count) FROM regions INNER JOIN violations ON regions.region_id = violations.region_id GROUP BY regions.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, organic BOOLEAN, product_id INT); | Calculate the percentage of ingredients sourced from organic farms in cosmetic products. | SELECT organic, COUNT(*) as num_ingredients, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM ingredients) as percentage FROM ingredients GROUP BY organic; | gretelai_synthetic_text_to_sql |
CREATE TABLE marketing_campaigns (destination VARCHAR(20), year INT); CREATE TABLE tourism_stats (destination VARCHAR(20), year INT, tourists INT); INSERT INTO marketing_campaigns (destination, year) VALUES ('Japan', 2020), ('France', 2020), ('Germany', 2021), ('Italy', 2020); INSERT INTO tourism_stats (destination, year, tourists) VALUES ('Japan', 2020, 20000), ('Japan', 2021, 25000), ('France', 2020, 16000), ('France', 2021, 18000), ('Germany', 2021, 12000), ('Italy', 2020, 15000), ('Italy', 2021, 17000); | Show the names of all destinations that were marketed in 2020 and had more than 15000 tourists visiting in that year. | SELECT destination FROM marketing_campaigns WHERE year = 2020 INTERSECT SELECT destination FROM tourism_stats WHERE tourists > 15000 AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE VolunteerEvents (EventID INT, EventName TEXT, Location TEXT, EventType TEXT); INSERT INTO VolunteerEvents (EventID, EventName, Location, EventType) VALUES (1, 'Beach Cleanup', 'California', 'Environment'), (2, 'Tree Planting', 'New York', 'Environment'); | How many volunteer hours were recorded for environmental programs in California? | SELECT SUM(VolunteerHours) FROM VolunteerEvents JOIN VolunteerHours ON VolunteerEvents.EventID = VolunteerHours.EventID WHERE VolunteerEvents.Location = 'California' AND VolunteerEvents.EventType = 'Environment'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists claims (claim_id INT PRIMARY KEY, policyholder_id INT, claim_amount DECIMAL(10,2), claim_date DATE); | Alter the 'claims' table to add a constraint that the 'claim_amount' should be non-negative | ALTER TABLE claims ADD CONSTRAINT non_negative_claim CHECK (claim_amount >= 0); | gretelai_synthetic_text_to_sql |
CREATE TABLE Plot1 (date DATE, soil_moisture FLOAT); | Update the 'soil_moisture' value to 50% in the 'Plot1' on 2022-07-15. | UPDATE Plot1 SET soil_moisture = 50 WHERE date = '2022-07-15'; | gretelai_synthetic_text_to_sql |
CREATE TABLE meals (user_id INT, meal_date DATE, calories INT); INSERT INTO meals (user_id, meal_date, calories) VALUES (1, '2022-01-01', 600), (1, '2022-01-02', 800), (3, '2022-01-01', 400); CREATE TABLE users (user_id INT, country VARCHAR(255)); INSERT INTO users (user_id, country) VALUES (1, 'Canada'), (2, 'USA'), (3, 'Canada'); | What is the average calorie intake per user in Canada, partitioned by day? | SELECT meal_date, AVG(calories) as avg_calories FROM (SELECT user_id, meal_date, calories FROM meals JOIN users ON meals.user_id = users.user_id WHERE users.country = 'Canada') t GROUP BY meal_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (vessel_id TEXT, speed FLOAT, distance FLOAT, timestamp TIMESTAMP); | Retrieve vessel performance data with the maximum speed and minimum distance traveled by vessels 'D' and 'E' from the 'vessel_performance' table | SELECT vessel_id, MAX(speed) as max_speed, MIN(distance) as min_distance FROM vessel_performance WHERE vessel_id IN ('D', 'E') GROUP BY vessel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_forms (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(30)); INSERT INTO art_forms (id, name, type) VALUES (1, 'Throat Singing', 'Music'), (2, 'Batik', 'Textile'), (3, 'Ikebana', 'Visual Arts'); | Delete all traditional art forms related to textile craftsmanship. | DELETE FROM art_forms WHERE type = 'Textile'; | gretelai_synthetic_text_to_sql |
CREATE TABLE merchandise (id INT, player VARCHAR(50), team VARCHAR(50), sales DECIMAL(5, 2)); INSERT INTO merchandise (id, player, team, sales) VALUES (1, 'James Johnson', 'TeamD', 500.00), (2, 'Jessica Smith', 'TeamD', 700.00), (3, 'Michael Brown', 'TeamD', 600.00), (4, 'Nicole White', 'TeamE', 800.00), (5, 'Oliver Green', 'TeamE', 900.00); | Who has sold the most merchandise among TeamD's players? | SELECT player FROM merchandise WHERE team = 'TeamD' ORDER BY sales DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (employee_id INT, name VARCHAR(50), position VARCHAR(50)); INSERT INTO employees (employee_id, name, position) VALUES (1, 'Greg', 'Project Manager'); INSERT INTO employees (employee_id, name, position) VALUES (2, 'Hannah', 'Data Scientist'); INSERT INTO employees (employee_id, name, position) VALUES (3, 'Ivan', 'Project Manager'); INSERT INTO employees (employee_id, name, position) VALUES (4, 'Judy', 'Developer'); | Who are the project managers for the 'technology for social good' sector? | SELECT name FROM employees INNER JOIN projects ON employees.employee_id = projects.project_manager WHERE sector = 'technology for social good'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, policy_id INT); INSERT INTO policyholders (id, policy_id) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE claims (id INT, policy_id INT, claim_amount INT); INSERT INTO claims (id, policy_id, claim_amount) VALUES (1, 1, 5000), (2, 2, 3000), (3, 3, 10000); | What is the total number of policies and the percentage of those policies that have a claim amount greater than 5000? | SELECT COUNT(DISTINCT policyholders.id) AS total_policies, COUNT(DISTINCT claims.policy_id) FILTER (WHERE claim_amount > 5000) * 100.0 / COUNT(DISTINCT policyholders.id) AS high_claim_percentage FROM policyholders LEFT JOIN claims ON policyholders.policy_id = claims.policy_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE bridge_lengths (bridge_id INT, length DECIMAL(10, 2)); | What is the number of bridges and their average length (in meters) in 'New York' from the 'bridges' and 'bridge_lengths' tables? | SELECT b.location, COUNT(b.id) as number_of_bridges, AVG(bl.length) as average_length FROM bridges b INNER JOIN bridge_lengths bl ON b.id = bl.bridge_id WHERE b.location = 'New York' GROUP BY b.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, ProgramID INT, DonorName TEXT); CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); | What is the number of unique donors for each program? | SELECT Programs.ProgramName, COUNT(DISTINCT Donors.DonorID) AS NumberOfDonors FROM Donors INNER JOIN Programs ON Donors.ProgramID = Programs.ProgramID GROUP BY Programs.ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT, program_name VARCHAR(50), total_volunteers INT); CREATE TABLE VolunteerEvents (id INT, program_id INT, event_date DATE, total_volunteers INT); | How many volunteers participated in each program in Q3 2021, sorted by the number of volunteers in descending order? | SELECT Programs.program_name, SUM(VolunteerEvents.total_volunteers) AS total_volunteers_q3 FROM Programs INNER JOIN VolunteerEvents ON Programs.id = VolunteerEvents.program_id WHERE VolunteerEvents.event_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY Programs.program_name ORDER BY total_volunteers_q3 DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT, price DECIMAL(5,2));CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT); | Which dish had the highest sales revenue in branch 1, 2, and 3? | SELECT dish_name, SUM(quantity * price) as total_revenue FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE branch_id IN (1, 2, 3) GROUP BY dish_name ORDER BY total_revenue DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (satellite_id INT, name VARCHAR(255), country VARCHAR(255), launch_date DATE, status VARCHAR(255)); INSERT INTO satellites (satellite_id, name, country, launch_date, status) VALUES (1, 'GSAT-1', 'India', '2001-06-18', 'Active'); | What is the status of satellites launched by India? | SELECT name, status FROM satellites WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_in_regions (species_id INT, region_id INT); INSERT INTO species_in_regions (species_id, region_id) VALUES (1, 1), (2, 2), (3, 1), (4, 2), (5, 3), (6, 1), (7, 2), (8, 3), (9, 1), (10, 2), (11, 3); | Show marine species that are present in all regions | SELECT species_id FROM species_in_regions GROUP BY species_id HAVING COUNT(DISTINCT region_id) = (SELECT COUNT(DISTINCT region_id) FROM regions); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityCenter (Name VARCHAR(255), Region VARCHAR(255), Type VARCHAR(255)); INSERT INTO CommunityCenter (Name, Region, Type) VALUES ('Southeast Community Center', 'Southeast', 'Public'), ('Northeast Community Center', 'Northeast', 'Public'), ('Southwest Community Center', 'Southwest', 'Public'), ('Northwest Community Center', 'Northwest', 'Public'); | How many public community centers are there in the Southeast region? | SELECT COUNT(*) FROM CommunityCenter WHERE Region = 'Southeast' AND Type = 'Public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hiv_patients(id INT, age INT, city TEXT, state TEXT); CREATE VIEW urban_areas AS SELECT * FROM areas WHERE population > 100000; | What is the average age of patients with HIV in urban areas? | SELECT AVG(age) FROM hiv_patients JOIN urban_areas USING(city); | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (facility_id INT, facility_name VARCHAR(50), country VARCHAR(50), region VARCHAR(50)); INSERT INTO facilities (facility_id, facility_name, country, region) VALUES (1, 'Accra Mental Health Clinic', 'Ghana', 'Africa'), (2, 'Nairobi Mental Health Institute', 'Kenya', 'Africa'); | Calculate the total number of mental health treatment facilities in Africa. | SELECT COUNT(facility_id) FROM facilities WHERE facilities.region = 'Africa'; | 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.