context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE clean_energy_policies (policy_id INT, policy_name TEXT, country TEXT, implementation_date DATE); INSERT INTO clean_energy_policies (policy_id, policy_name, country, implementation_date) VALUES (1, 'Solar Subsidies', 'Country Z', '2018-01-01'), (2, 'Wind Energy Mandate', 'Country W', '2017-05-15'), (3, 'Ene... | Which clean energy policies were implemented in 'Country W'? | SELECT * FROM clean_energy_policies WHERE country = 'Country W'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID INT, EducationLevel VARCHAR(20), MentalHealthScore INT, Semester VARCHAR(10)); INSERT INTO Students (StudentID, EducationLevel, MentalHealthScore, Semester) VALUES (1, 'High School', 65, 'Fall 2021'), (2, 'College', 70, 'Fall 2021'), (3, 'High School', 60, 'Fall 2021'); | What is the average mental health score of students in the 'Fall 2021' semester, grouped by their 'Education Level'? | SELECT EducationLevel, AVG(MentalHealthScore) FROM Students WHERE Semester = 'Fall 2021' GROUP BY EducationLevel; | gretelai_synthetic_text_to_sql |
CREATE TABLE Production_Sites (site_id INT, site_name VARCHAR(50), energy_consumption INT); CREATE TABLE Production_Chemicals (site_id INT, chemical_id INT, energy_consumption INT); | Get the total energy consumption for each production site and the average energy consumption per chemical per site | SELECT ps.site_name, SUM(ps.energy_consumption) as total_energy, AVG(pc.energy_consumption/cnt.chemical_count) as avg_energy_per_chemical FROM Production_Sites ps JOIN Production_Chemicals pc ON ps.site_id = pc.site_id JOIN (SELECT site_id, COUNT(DISTINCT chemical_id) as chemical_count FROM Production_Chemicals GROUP B... | gretelai_synthetic_text_to_sql |
CREATE TABLE project (project_id INT, name VARCHAR(50), location VARCHAR(50), success_rate FLOAT); CREATE TABLE continent (continent_id INT, name VARCHAR(50), description TEXT); | What is the success rate of agricultural innovation projects in Asia? | SELECT p.name, AVG(p.success_rate) FROM project p JOIN continent c ON p.location = c.name WHERE c.name = 'Asia' GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT, name VARCHAR(255), department VARCHAR(255), fda_approval_date DATE, sales FLOAT); INSERT INTO drugs (id, name, department, fda_approval_date, sales) VALUES (1, 'DrugA', 'Oncology', '2016-01-01', 1000000), (2, 'DrugB', 'Oncology', '2017-06-15', 2000000), (3, 'DrugC', 'Cardiology', '2014-03-23... | What is the total sales revenue for all drugs in the oncology department that were approved by the FDA after 2015? | SELECT SUM(sales) FROM drugs WHERE department = 'Oncology' AND fda_approval_date > '2015-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_ratings (id INT, sector TEXT, location TEXT, rating FLOAT); INSERT INTO building_ratings (id, sector, location, rating) VALUES (1, 'residential', 'Berlin', 80.0), (2, 'commercial', 'Berlin', 60.0); | What is the average energy efficiency rating of residential buildings in Berlin? | SELECT AVG(rating) FROM building_ratings WHERE sector = 'residential' AND location = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterQualityViolations (report_date DATE, state VARCHAR(20)); | How many water quality violations were reported in the state of California in the last 3 years? | SELECT COUNT(*) FROM WaterQualityViolations WHERE report_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND CURRENT_DATE AND state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT PRIMARY KEY, researcher_id INT, name VARCHAR(255), start_date DATE); INSERT INTO genetics.research_projects (id, researcher_id, name, start_date) VALUES (1, 1, 'ProjectA', '2022-01-01'), (2, 2, 'ProjectB', '2021-06-15'), ... | What is the number of genetic research projects by researcher and their corresponding start date, ordered by start date? | SELECT researcher_id, COUNT(*) AS num_projects, MIN(start_date) AS start_date FROM genetics.research_projects WINDOW W AS (PARTITION BY researcher_id ORDER BY start_date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) GROUP BY researcher_id, W.start_date ORDER BY start_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Developers (developer_id INT, developer_name TEXT, developer_continent TEXT); INSERT INTO Developers (developer_id, developer_name, developer_continent) VALUES (1, 'Alice', 'Africa'), (2, 'Bob', 'Asia'); CREATE TABLE SmartContracts (contract_id INT, contract_name TEXT, developer_id INT); INSERT INTO SmartC... | List all smart contracts deployed by developers from Africa. | SELECT SmartContracts.contract_name FROM SmartContracts INNER JOIN Developers ON SmartContracts.developer_id = Developers.developer_id WHERE Developers.developer_continent = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyNumber INT, PolicyholderID INT, PolicyState VARCHAR(20)); INSERT INTO Policies (PolicyNumber, PolicyholderID, PolicyState) VALUES (2001, 9, 'Ontario'), (2002, 10, 'Ontario'), (2003, 11, 'Quebec'), (2004, 12, 'Quebec'); | Find the difference in the number of policies between 'Ontario' and 'Quebec'. | SELECT COUNT(CASE WHEN PolicyState = 'Ontario' THEN 1 END) - COUNT(CASE WHEN PolicyState = 'Quebec' THEN 1 END) AS PolicyDifference FROM Policies; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_productivity (id INT, mine_id INT, productivity_score FLOAT, FOREIGN KEY (mine_id) REFERENCES mines(id)); CREATE TABLE mines (id INT, name VARCHAR(50), location VARCHAR(50), PRIMARY KEY(id)); INSERT INTO mines (id, name, location) VALUES (13, 'Arizona Mine', 'Arizona'); INSERT INTO mines (id, name, l... | Insert new labor productivity records for mines in Arizona with productivity scores above 4.5. | INSERT INTO labor_productivity (id, mine_id, productivity_score) VALUES (9, 13, 4.6), (10, 14, 4.8); | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT PRIMARY KEY, title TEXT, content TEXT); CREATE TABLE comments (id INT PRIMARY KEY, post_id INT, content TEXT, score INT); INSERT INTO posts (id, title, content) VALUES (1, 'News Post', 'Content 1'), (2, 'Post 2', 'Content 2'); INSERT INTO comments (id, post_id, content, score) VALUES (1, 1, '... | Calculate the average score of comments on posts with the word "news" in the title. | SELECT AVG(c.score) FROM comments c JOIN posts p ON c.post_id = p.id WHERE p.title LIKE '%news%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, title VARCHAR(255), location VARCHAR(255), start_year INT, end_year INT); INSERT INTO Exhibitions (id, title, location, start_year, end_year) VALUES (1, 'Exhibition1', 'Paris, France', 1985, 1986); | How many exhibitions were there in France before 1990? | SELECT COUNT(*) FROM Exhibitions WHERE location LIKE '%France%' AND start_year < 1990; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_programs (country TEXT, marine_conservation BOOLEAN); INSERT INTO conservation_programs (country, marine_conservation) VALUES ('Canada', true), ('Brazil', false), ('Spain', true); | What are the names of countries with marine conservation programs? | SELECT country FROM conservation_programs WHERE marine_conservation = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (equipment_id INT, region VARCHAR(50), sale_price DECIMAL(10,2)); INSERT INTO MilitaryEquipmentSales (equipment_id, region, sale_price) VALUES (1, 'Europe', 500000.00), (2, 'Africa', 350000.00); | Find the total number of military equipment sales in Europe and compare it to those in Africa. | SELECT SUM(sale_price) FROM MilitaryEquipmentSales WHERE region = 'Europe' UNION SELECT SUM(sale_price) FROM MilitaryEquipmentSales WHERE region = 'Africa' | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tourism_france (location TEXT, year INT, revenue INT); INSERT INTO virtual_tourism_france (location, year, revenue) VALUES ('Paris', 2022, 1000000), ('Paris', 2023, 1200000); | What is the virtual tourism revenue in Paris for 2022? | SELECT revenue FROM virtual_tourism_france WHERE location = 'Paris' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_plants (plant TEXT, region TEXT, recycling_rate DECIMAL(5,4)); INSERT INTO wastewater_plants (plant, region, recycling_rate) VALUES ('Plant A', 'North America', 0.85), ('Plant B', 'North America', 0.80), ('Plant C', 'Europe', 0.90), ('Plant D', 'Europe', 0.92), ('Plant E', 'Asia', 0.75), ('Plant... | List the water treatment plants with the highest water recycling rate, comparing at least 3 regions worldwide. | SELECT region, MAX(recycling_rate) AS highest_recycling_rate FROM wastewater_plants GROUP BY region ORDER BY highest_recycling_rate DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_trenches (name TEXT, location TEXT, ocean TEXT);INSERT INTO marine_trenches (name, location, ocean) VALUES ('Mariana Trench', 'Pacific Ocean', 'Pacific'), ('Southern Antiltic Trench', 'Southern Ocean', 'Southern'); | Which ocean has the greatest number of marine trenches? | SELECT ocean, COUNT(*) FROM marine_trenches GROUP BY ocean ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_records (employee_id INT PRIMARY KEY, name TEXT, gender TEXT, leaving_date DATE); INSERT INTO employee_records (employee_id, name, gender, leaving_date) VALUES (1, 'John Doe', 'Male', '2018-01-01'); INSERT INTO employee_records (employee_id, name, gender, leaving_date) VALUES (2, 'Jane Smith', 'Fe... | Get the number of employees who identify as female or male from the "employee_records" table | SELECT COUNT(*) AS count FROM employee_records WHERE gender IN ('Male', 'Female'); | gretelai_synthetic_text_to_sql |
CREATE TABLE user (id INT, name TEXT, reg_date DATE); CREATE TABLE tour_registration (user_id INT, tour_id INT, registration_date DATE); INSERT INTO user (id, name, reg_date) VALUES (1, 'Jane Doe', '2022-05-22'); INSERT INTO tour_registration (user_id, tour_id, registration_date) VALUES (1, 1, '2022-05-29'); | How many users registered for virtual tours of cultural heritage sites in the last week? | SELECT COUNT(*) as num_users FROM user JOIN tour_registration ON user.id = tour_registration.user_id WHERE tour_registration.registration_date >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE country_investments (country VARCHAR(255), sector VARCHAR(255), investment_amount NUMERIC, quarter VARCHAR(255)); | What was the average investment in climate mitigation per quarter for the top 3 investing countries? | SELECT country, AVG(investment_amount) FROM (SELECT country, sector, investment_amount, quarter FROM country_investments WHERE sector = 'mitigation' ORDER BY investment_amount DESC LIMIT 3) subquery GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE costs (company_id INT, year INT, ree_production_cost INT); INSERT INTO costs (company_id, year, ree_production_cost) VALUES (1, 2019, 12000), (1, 2020, 15000), (1, 2021, 18000), (2, 2019, 8000), (2, 2020, 10000), (2, 2021, 12000); | Calculate REE production cost for each company. | SELECT company_id, SUM(ree_production_cost) as total_cost FROM costs GROUP BY company_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (expedition_id INTEGER, leader_name TEXT, year INTEGER); INSERT INTO deep_sea_expeditions (expedition_id, leader_name, year) VALUES (1, 'John Doe', 1999), (2, 'Jane Smith', 2002), (3, 'Alice Johnson', 2005); | List all deep-sea expeditions led by female researchers since 2000? | SELECT expedition_id, leader_name FROM deep_sea_expeditions WHERE year >= 2000 AND leader_name LIKE '%%%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE irrigation_systems (id INT PRIMARY KEY, farm_id INT, system_type VARCHAR(255), status VARCHAR(255), date DATE); | Insert a new record into the "irrigation_systems" table with the following data: farm_id: 5, system_type: 'Drip', status: 'Active', date: '2023-01-07 | INSERT INTO irrigation_systems (farm_id, system_type, status, date) VALUES (5, 'Drip', 'Active', '2023-01-07'); | gretelai_synthetic_text_to_sql |
CREATE TABLE paris_evs (id INT, vehicle_type VARCHAR(20), registration_date DATE); | Identify the number of electric vehicles in Paris per month. | SELECT EXTRACT(MONTH FROM registration_date) AS month, COUNT(*) FROM paris_evs WHERE vehicle_type = 'electric' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousDrivingResearch (StudyID INT, StudyName VARCHAR(50), LeadResearcher VARCHAR(50)); INSERT INTO AutonomousDrivingResearch (StudyID, StudyName, LeadResearcher) VALUES (1, 'Impact of Autonomous Vehicles on Urban Mobility', 'Dr. Jane Smith'), (2, 'Deep Learning Algorithms for Autonomous Driving', 'Dr.... | List all autonomous driving research studies and their respective lead researchers. | SELECT StudyName, LeadResearcher FROM AutonomousDrivingResearch; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (id INT, user_name VARCHAR, membership_type VARCHAR, signup_date DATE); CREATE TABLE WearableMetrics (id INT, user_id INT, metric_date DATE, heart_rate INT); INSERT INTO Members (id, user_name, membership_type, signup_date) VALUES (1, 'John Doe', 'Premium', '2020-01-01'), (2, 'Jane Smith', 'Basic',... | What is the average heart rate per day for users with a membership type of 'Premium'? | SELECT DATE(metric_date) AS date, AVG(heart_rate) AS avg_heart_rate FROM WearableMetrics JOIN Members ON WearableMetrics.user_id = Members.id WHERE Members.membership_type = 'Premium' GROUP BY date; | gretelai_synthetic_text_to_sql |
use rural_health; CREATE TABLE hospital_beds (id int, hospital_id int, available_beds int); INSERT INTO hospital_beds (id, hospital_id, available_beds) VALUES (1, 1, 50); INSERT INTO hospital_beds (id, hospital_id, available_beds) VALUES (2, 1, 25); INSERT INTO hospital_beds (id, hospital_id, available_beds) VALUES (3,... | What is the average availability of hospital beds per hospital? | SELECT hospital_id, AVG(available_beds) as avg_beds FROM rural_health.hospital_beds GROUP BY hospital_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_sales(menu_category VARCHAR(255), total_sales DECIMAL(10,2)); INSERT INTO menu_sales(menu_category, total_sales) VALUES('Appetizers', 5000.00), ('Entrees', 12000.00), ('Desserts', 6000.00); | What are the total sales for each menu category? | SELECT menu_category, SUM(total_sales) FROM menu_sales GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.projects (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50)); INSERT INTO genetics.projects (id, name, country) VALUES (1, 'ProjectX', 'Germany'), (2, 'ProjectY', 'USA'), (3, 'ProjectZ', 'Canada'); | How many genetic research projects have been conducted in total? | SELECT COUNT(*) FROM genetics.projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_material (id INT PRIMARY KEY, permit_id INT, material_name VARCHAR(50), FOREIGN KEY (permit_id) REFERENCES building_permit(id)); INSERT INTO sustainable_material (id, permit_id, material_name) VALUES (1, 1, 'Bamboo Flooring'); | Identify projects with bamboo flooring and their permit numbers | SELECT p.name, bp.permit_number FROM project p INNER JOIN building_permit bp ON p.id = bp.project_id INNER JOIN sustainable_material sm ON bp.id = sm.permit_id WHERE sm.material_name = 'Bamboo Flooring'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (initiative_id INT, initiative_name TEXT, status TEXT); INSERT INTO pollution_control_initiatives (initiative_id, initiative_name, status) VALUES (301, 'Initiative X', 'non-compliant'), (302, 'Initiative Y', 'compliant'); | Update the pollution control initiative status to 'compliant' for initiative ID 301. | UPDATE pollution_control_initiatives SET status = 'compliant' WHERE initiative_id = 301; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_sudan_assistance (id INT, year INT, people_assisted INT); INSERT INTO south_sudan_assistance (id, year, people_assisted) VALUES (1, 2020, 250000), (2, 2021, 300000); CREATE TABLE ca_assistance (id INT, year INT, people_assisted INT); INSERT INTO ca_assistance (id, year, people_assisted) VALUES (1, 20... | How many people received humanitarian assistance in South Sudan and Central African Republic in 2020 and 2021? | SELECT s.year, SUM(s.people_assisted + c.people_assisted) AS total_people_assisted FROM south_sudan_assistance s, ca_assistance c WHERE s.year IN (2020, 2021) AND c.year IN (2020, 2021) GROUP BY s.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_research (researcher_id SERIAL PRIMARY KEY, researcher_name TEXT, researcher_location TEXT, research_topic TEXT, published_date DATE); INSERT INTO ai_research (researcher_name, researcher_location, research_topic, published_date) VALUES ('Adebola Adeleke', 'Nigeria', 'AI-generated music', '2022-07-22'),... | List creative AI research topics by researchers from Africa. | SELECT researcher_name, research_topic FROM ai_research WHERE researcher_location LIKE 'Africa%' AND research_topic LIKE 'Creative AI%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ports VALUES (1, 'Port of Los Angeles', 'USA'); INSERT INTO ports VALUES (2, 'Port of Rotterdam', 'Netherlands'); CREATE TABLE cargo (cargo_id INT, port_id INT, cargo_weight INT, handling_date DATE); INSERT INTO cargo VALUES (1, 1... | What was the total cargo weight handled by each port in 2020? | SELECT port_name, SUM(cargo_weight) as total_cargo_weight FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE handling_date >= '2020-01-01' AND handling_date < '2021-01-01' GROUP BY port_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, precinct VARCHAR(20), response_time INT, call_date DATE); INSERT INTO emergency_calls (id, precinct, response_time, call_date) VALUES (1, 'riverside', 8, '2022-02-01'); | Calculate the minimum response time for emergency calls in the 'riverside' precinct for each day in the month of February 2022. | SELECT precinct, call_date, MIN(response_time) FROM emergency_calls WHERE precinct = 'riverside' AND call_date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY precinct, call_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE crypto_assets (asset_id INT, asset_name VARCHAR(50), total_transactions INT, timestamp TIMESTAMP); INSERT INTO crypto_assets (asset_id, asset_name, total_transactions, timestamp) VALUES (1, 'Bitcoin', 1000, '2022-01-01 00:00:00'); INSERT INTO crypto_assets (asset_id, asset_name, total_transactions, timesta... | What is the average number of transactions per day for each digital asset in the 'crypto_assets' table? | SELECT asset_name, AVG(total_transactions / DATEDIFF('day', MIN(timestamp), MAX(timestamp))) FROM crypto_assets GROUP BY asset_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (permit_number TEXT, contractor TEXT); INSERT INTO building_permits (permit_number, contractor) VALUES ('2022-008', 'Contractor E'); | Delete permit 2022-008 from the database | WITH cte AS (DELETE FROM building_permits WHERE permit_number = '2022-008') SELECT * FROM cte; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials(country varchar(20), year int, trials int);INSERT INTO clinical_trials VALUES ('CountryB', 2017, 300);INSERT INTO clinical_trials VALUES ('CountryB', 2018, 350);INSERT INTO clinical_trials VALUES ('CountryB', 2019, 400); | How many clinical trials were approved in 'CountryB' between 2017 and 2019? | SELECT SUM(trials) FROM clinical_trials WHERE country = 'CountryB' AND year BETWEEN 2017 AND 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (id INT, genre VARCHAR(255), artist VARCHAR(255), streams INT); INSERT INTO streams (id, genre, artist, streams) VALUES (1, 'Rock', 'Artist1', 1000000), (2, 'Pop', 'Artist2', 800000), (3, 'Rock', 'Artist1', 1200000), (4, 'Jazz', 'Artist3', 900000); | What is the total number of streams for each genre of music? | SELECT genre, SUM(streams) AS total_streams FROM streams GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE members(id INT, name VARCHAR(50), gender VARCHAR(10), age INT, membership_type VARCHAR(20)); INSERT INTO members(id, name, gender, age, membership_type) VALUES (1, 'John Doe', 'Male', 30, 'Gym'); CREATE TABLE wearables(id INT, member_id INT, device_type VARCHAR(20), usage_hours INT); INSERT INTO wearables(... | What is the total number of members who have a gym membership and also use wearable technology? | SELECT COUNT(*) FROM members m JOIN wearables w ON m.id = w.member_id WHERE m.membership_type = 'Gym' AND w.device_type IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_investments (id INT, sector VARCHAR(20), value DECIMAL(10,2), risk_rating INT); INSERT INTO sustainable_investments (id, sector, value, risk_rating) VALUES (1, 'healthcare', 5000.00, 8), (2, 'technology', 7000.00, 5), (3, 'healthcare', 6000.00, 9); | What is the average transaction value for sustainable investments in the healthcare sector with a risk rating above 7? | SELECT AVG(value) FROM sustainable_investments WHERE sector = 'healthcare' AND risk_rating > 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Juan Rodriguez', 'Argentina'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Maria Gonzalez', 'Brazil'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3, ... | What is the average donation amount for donors from Latin America? | SELECT AVG(DonationAmount) as AverageDonationAmount FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country IN ('Argentina', 'Brazil', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Race VARCHAR(50), EnrollmentDate DATE); INSERT INTO GraduateStudents (StudentID, Name, Race, EnrollmentDate) VALUES (1, 'Carla', 'Latino', '2018-01-01'); INSERT INTO GraduateStudents (StudentID, Name, Race, EnrollmentDate) VALUES (2, 'Dan', 'Asian', '2017-... | What is the number of publications by graduate students from underrepresented racial and ethnic groups in the past 5 years? | SELECT COUNT(p.PublicationID) FROM Publications p INNER JOIN GraduateStudents gs ON p.StudentID = gs.StudentID WHERE gs.Race IN ('Black', 'Latino', 'Native American') AND p.PublicationDate >= DATEADD(year, -5, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_facilities (id INT, state VARCHAR(20), type VARCHAR(20)); INSERT INTO recycling_facilities (id, state, type) VALUES (1, 'California', 'recycling'), (2, 'New York', 'recycling'), (3, 'California', 'landfill'), (4, 'Texas', 'recycling'); | How many recycling facilities are there in the state of New York and what percentage of the total facilities do they represent? | SELECT COUNT(*) AS total_recycling_facilities, (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM recycling_facilities)) AS percentage_of_total FROM recycling_facilities WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_regions (region_id INT, region_name VARCHAR(50)); CREATE TABLE species (species_id INT, species_name VARCHAR(50)); CREATE TABLE species_observations (observation_id INT, species_id INT, region_id INT, observation_date DATE); INSERT INTO arctic_regions (region_id, region_name) VALUES (1, 'Alaska'), (... | Calculate the total number of species observed in each Arctic region. | SELECT region_name, COUNT(DISTINCT species_id) as species_count FROM arctic_regions JOIN species_observations ON arctic_regions.region_id = species_observations.region_id GROUP BY region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_emission (id INT, country VARCHAR(20), co2_emission DECIMAL(10,2)); INSERT INTO country_emission (id, country, co2_emission) VALUES (1, 'China', 2000.5), (2, 'Norway', 1500.3), (3, 'Indonesia', 1200.2); CREATE TABLE country (id INT, name VARCHAR(20), emission_id INT); INSERT INTO country (id, name... | What is the total CO2 emission from aquaculture in the top 3 emitting countries? | SELECT SUM(ce.co2_emission) FROM country_emission ce INNER JOIN country c ON ce.id = c.emission_id WHERE c.name IN (SELECT name FROM (SELECT * FROM country LIMIT 3) t); | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production_by_region (id INT, region VARCHAR(255), year INT, cubic_meters FLOAT); INSERT INTO timber_production_by_region (id, region, year, cubic_meters) VALUES (1, 'North America', 2020, 789456.12), (2, 'South America', 2020, 678345.12), (3, 'Europe', 2020, 567890.12); | What is the average timber production, in cubic meters, for each region in the year 2020? | SELECT region, AVG(cubic_meters) FROM timber_production_by_region WHERE year = 2020 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (id INT, name VARCHAR(50)); CREATE TABLE FactoryItems (id INT, factory INT, quantity INT); INSERT INTO Factories (id, name) VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); INSERT INTO FactoryItems (id, factory, quantity) VALUES (1, 1, 500), (2, 1, 700), (3, 2, 300), (4, 2, 800), (5, ... | How many items are produced in each factory? | SELECT f.name, SUM(fi.quantity) FROM Factories f INNER JOIN FactoryItems fi ON f.id = fi.factory GROUP BY f.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (school_id INT, school_name VARCHAR(255)); INSERT INTO schools VALUES (1, 'East High'); INSERT INTO schools VALUES (2, 'West Middle'); CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT); | What is the average mental health score for students in each school? | SELECT s.school_name, AVG(smh.mental_health_score) FROM student_mental_health smh INNER JOIN schools s ON smh.school_id = s.school_id GROUP BY smh.school_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (id INT, drug_id INT, country VARCHAR(50)); INSERT INTO drug_approval (id, drug_id, country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 3, 'Mexico'), (4, 1, 'UK'); | Which drugs have been approved in a specific country? | SELECT da.drug_id, da.country FROM drug_approval da WHERE da.country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects_asia_pacific (id INT, project_name VARCHAR(255), region VARCHAR(255)); INSERT INTO renewable_energy_projects_asia_pacific (id, project_name, region) VALUES (1, 'Solar Farm A', 'Asia-Pacific'), (2, 'Wind Farm B', 'Asia-Pacific'); | What is the number of renewable energy projects in 'Asia-Pacific' region? | SELECT COUNT(*) FROM renewable_energy_projects_asia_pacific WHERE region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE heart_rate_data (id INT, user_id INT, heart_rate INT, date DATE); INSERT INTO heart_rate_data (id, user_id, heart_rate, date) VALUES (1, 1, 75, '2022-01-01'), (2, 1, 76, '2022-01-02'), (3, 1, 77, '2022-01-03'); | What is the change in heart rate over time for a specific user? | SELECT date, heart_rate, LEAD(heart_rate) OVER (PARTITION BY user_id ORDER BY date) as next_heart_rate FROM heart_rate_data WHERE user_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (VisitorID INT, Community VARCHAR(255), HasTakenVirtualTour BOOLEAN); INSERT INTO Visitors (VisitorID, Community, HasTakenVirtualTour) VALUES (1, 'Underrepresented Community', true); INSERT INTO Visitors (VisitorID, Community, HasTakenVirtualTour) VALUES (2, 'Represented Community', false); INSERT... | What is the total number of virtual tours taken by visitors from underrepresented communities? | SELECT COUNT(V.VisitorID) as TotalVisitors FROM Visitors V WHERE V.Community = 'Underrepresented Community' AND V.HasTakenVirtualTour = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects_2 (project_id INT, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50)); INSERT INTO renewable_projects_2 (project_id, name, type, location) VALUES (1, 'Germany Renewable Project 1', 'Wind', 'Germany'); | Find the number of Renewable Energy projects in Germany | SELECT COUNT(*) FROM renewable_projects_2 WHERE location = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_achievements (player_id INT, achievement_name VARCHAR(255), achievement_date DATE); | Insert records for 3 players into 'player_achievements' | INSERT INTO player_achievements (player_id, achievement_name, achievement_date) VALUES (1, 'First Blood', '2021-05-01'), (2, 'Top Fragger', '2021-04-15'), (3, 'MVP', '2021-03-28'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_features (id INT, hotel_name TEXT, location TEXT, ai_features INT, revenue FLOAT); INSERT INTO hotel_features (id, hotel_name, location, ai_features, revenue) VALUES (1, 'Hotel A', 'Americas', 5, 1200000), (2, 'Hotel B', 'Europe', 7, 900000), (3, 'Hotel C', 'Americas', 3, 1000000), (4, 'Hotel D', 'Af... | What is the average revenue generated by hotels in the Americas that have virtual tours? | SELECT AVG(revenue) FROM hotel_features WHERE location = 'Americas' AND EXISTS (SELECT * FROM virtual_tours WHERE hotel_features.id = virtual_tours.id); | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, size FLOAT, city VARCHAR(20), build_year INT, inclusive BOOLEAN); INSERT INTO properties (property_id, size, city, build_year, inclusive) VALUES (1, 2000, 'Chicago', 1995, true); INSERT INTO properties (property_id, size, city, build_year, inclusive) VALUES (2, 1800, 'Chicago',... | What is the total property size in Chicago for properties built before 2000 and have inclusive housing policies? | SELECT SUM(size) FROM properties WHERE city = 'Chicago' AND build_year < 2000 AND inclusive = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE museum_attendance (museum_id INT, name VARCHAR(50), year INT, visitors INT); | List the top 3 most visited museums in Berlin, Germany for each year. | SELECT year, name, visitors FROM (SELECT year, name, visitors, DENSE_RANK() OVER(PARTITION BY year ORDER BY visitors DESC) AS rank FROM museum_attendance WHERE city = 'Berlin') AS berlin_museums WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.investment (id INT PRIMARY KEY, type VARCHAR(255), country VARCHAR(255), amount FLOAT); INSERT INTO biotech.investment (id, type, country, amount) VALUES (1, 'Biosensor Technology Development', 'Argentina', 1000000); INSERT INTO biotech.investment ... | What is the minimum investment in genetic research in Argentina? | SELECT MIN(amount) FROM biotech.investment WHERE country = 'Argentina' AND type = 'Genetic Research'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investor (investor_id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO investor (investor_id, name, country) VALUES (1, 'Acme Corp', 'Germany'), (2, 'Beta Inc', 'France'); CREATE TABLE investment (investment_id INT, investor_id INT, strategy VARCHAR(255)); | How many investors are focusing on renewable energy in Europe? | SELECT COUNT(DISTINCT investor.investor_id) FROM investor JOIN investment ON investor.investor_id = investment.investor_id WHERE investor.country = 'Germany' OR investor.country = 'France' AND investment.strategy LIKE '%Renewable Energy%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists blockchain; CREATE TABLE if not exists blockchain.smart_contracts ( contract_id INT AUTO_INCREMENT, contract_name VARCHAR(255), contract_address VARCHAR(255), ROW_NUM INT, PRIMARY KEY (contract_id)); INSERT INTO blockchain.smart_contracts (contract_name, contract_address, row_num) VALUES ('U... | Delete the smart contract with the lowest ROW_NUM from the smart_contracts table. | DELETE FROM blockchain.smart_contracts WHERE row_num = (SELECT MIN(row_num) FROM blockchain.smart_contracts); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vulnerable_Species(id INT, location VARCHAR(50), species VARCHAR(50), population INT, vulnerable_status VARCHAR(50)); | What is the total population of vulnerable underwater species by location? | SELECT location, SUM(population) AS Total_Population FROM Vulnerable_Species WHERE vulnerable_status = 'Vulnerable' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerPreferences (id INT PRIMARY KEY, player_id INT, preference_type VARCHAR(255), preference_value VARCHAR(255), preferred_controller VARCHAR(255)); INSERT INTO PlayerPreferences (id, player_id, preference_type, preference_value) VALUES (1, 101, 'Color', 'Blue'); | Update the 'preferred_controller' for player 101 to 'DualShock 4' | UPDATE PlayerPreferences SET preferred_controller = 'DualShock 4' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing (id INT, country VARCHAR(20), score INT); INSERT INTO financial_wellbeing (id, country, score) VALUES (1, 'Brazil', 65), (2, 'Mexico', 70), (3, 'Colombia', 72), (4, 'Jamaica', 68); | Total financial wellbeing score for Latin America and the Caribbean. | SELECT SUM(score) FROM financial_wellbeing WHERE country IN ('Latin America', 'Caribbean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (operation_name VARCHAR(50), start_year INT, end_year INT); INSERT INTO peacekeeping_operations (operation_name, start_year, end_year) VALUES ('MONUSCO', 2010, 2022), ('MINUSMA', 2013, 2022), ('UNMISS', 2011, 2022), ('UNAMID', 2007, 2021), ('MINUSTAH', 2004, 2017), ('UNMIL', 2003, 2... | How many peacekeeping operations were conducted annually by the United Nations from 2010 to 2020? | SELECT YEAR(start_year) as year, COUNT(*) as num_operations FROM peacekeeping_operations WHERE start_year BETWEEN 2010 AND 2020 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50)); CREATE TABLE Brand_Materials (brand_id INT, material_id INT, quantity INT); CREATE TABLE Materials (material_id INT, material_name VARCHAR(50)); INSERT INTO Brands (brand_id, brand_name) VALUES (1, 'EcoFabric'), (2, 'GreenThreads'), (3, 'SustainableStyle'); IN... | Who are the top 3 brands using organic cotton? | SELECT brand_name, SUM(quantity) as total_quantity FROM Brands b INNER JOIN Brand_Materials bm ON b.brand_id = bm.brand_id INNER JOIN Materials m ON bm.material_id = m.material_id WHERE m.material_name = 'Organic Cotton' GROUP BY brand_name ORDER BY total_quantity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleData (Id INT, Name VARCHAR(50), Year INT, Horsepower INT); INSERT INTO VehicleData (Id, Name, Year, Horsepower) VALUES (1, 'Corvette', 2017, 460), (2, '911 Turbo', 2017, 540), (3, 'M4 GTS', 2016, 493); | What is the total horsepower of vehicles released in 2017? | SELECT SUM(Horsepower) FROM VehicleData WHERE Year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, eia_date DATE); INSERT INTO mine (id, name, location, eia_date) VALUES (1, 'Jade Junction', 'CA', '2021-09-01'), (2, 'Onyx Oasis', 'AZ', '2021-11-15'), (3, 'Diamond Dell', 'AR', '2022-02-28'), (4, 'Jade Junction', 'CA', '2022-03-01'), (5, 'Onyx Oasis', 'AZ', '2022-04... | Identify mines with environmental impact assessments overdue | SELECT name FROM mine WHERE eia_date < DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(50), country VARCHAR(50), ai_features INT, last_updated DATE); INSERT INTO Hotels (hotel_id, hotel_name, country, ai_features, last_updated) VALUES (1, 'Hotel1', 'CountryB', 3, '2021-05-01'), (2, 'Hotel2', 'CountryA', 2, '2021-05-01'), (3, 'Hotel3', 'CountryB', 4, '... | What is the year-over-year growth in AI-based hotel feature adoption in 'CountryB'? | SELECT h2021.country, (SUM(h2021.ai_features) - SUM(h2020.ai_features))*100.0 / SUM(h2020.ai_features) as yoy_growth FROM Hotels h2021 JOIN Hotels h2020 ON h2021.country = h2020.country WHERE h2021.last_updated >= '2021-01-01' AND h2020.last_updated >= '2020-01-01' AND h2020.last_updated < '2021-01-01' AND h2021.countr... | gretelai_synthetic_text_to_sql |
CREATE TABLE MuseumA(id INT, type VARCHAR(20), artist VARCHAR(30)); CREATE TABLE MuseumB(id INT, type VARCHAR(20), artist VARCHAR(30)); INSERT INTO MuseumA(id, type, artist) VALUES (1, 'Painting', 'Van Gogh'), (2, 'Sculpture', 'Rodin'); INSERT INTO MuseumB(id, type, artist) VALUES (1, 'Painting', 'Monet'), (2, 'Install... | What is the total number of art pieces and historical artifacts in Museum A and Museum B? | SELECT COUNT(*) FROM MuseumA UNION ALL SELECT COUNT(*) FROM MuseumB; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_mobility (id INT, city VARCHAR(50), mode VARCHAR(50), users INT); | Insert data into the 'multimodal_mobility' table | INSERT INTO multimodal_mobility (id, city, mode, users) VALUES (1, 'San Francisco', 'Bike Sharing', 1500); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id int, product_id int, vendor_id int, quantity int, sale_date date); CREATE TABLE vendors (vendor_id int, vendor_name varchar(255), country varchar(50)); INSERT INTO sales (sale_id, product_id, vendor_id, quantity, sale_date) VALUES (1, 1, 101, 10, '2022-01-01'); INSERT INTO vendors (vendor_id... | What is the total quantity of products sold by each vendor in France? | SELECT vendor_id, SUM(quantity) AS total_sold FROM sales JOIN vendors ON sales.vendor_id = vendors.vendor_id WHERE country = 'France' GROUP BY vendor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (ID INT, Gender VARCHAR(10), Age INT, Disease VARCHAR(20), Country VARCHAR(30), Diagnosis_Date DATE); INSERT INTO Patients (ID, Gender, Age, Disease, Country, Diagnosis_Date) VALUES (1, 'Female', 34, 'Zika Virus', 'Colombia', '2020-02-01'); | What is the average age of patients diagnosed with Zika Virus in Colombia in 2020? | SELECT AVG(Age) FROM Patients WHERE Disease = 'Zika Virus' AND Country = 'Colombia' AND YEAR(Diagnosis_Date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (program_id INT, program_name VARCHAR(255), location VARCHAR(255), carbon_offsets INT); INSERT INTO carbon_offset_programs (program_id, program_name, location, carbon_offsets) VALUES (1, 'Tree Planting Program 1', 'Country A', 5000), (2, 'Renewable Energy Program 1', 'Country B', 800... | What is the average carbon offset per project in the 'carbon_offset_programs' table? | SELECT AVG(carbon_offsets) FROM carbon_offset_programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (route_id INT, route_name TEXT, vehicle_type TEXT, is_autonomous BOOLEAN, passengers INT); | List all public transportation routes with more than 50% autonomous bus usage in Singapore. | SELECT route_name FROM public_transportation WHERE vehicle_type = 'Bus' AND is_autonomous = TRUE GROUP BY route_name HAVING COUNT(*) FILTER (WHERE is_autonomous = TRUE) / COUNT(*) > 0.5 AND route_name LIKE 'Singapore%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT, created_at DATETIME, source TEXT); INSERT INTO articles (id, title, category, likes, created_at, source) VALUES (1, 'New tax bill passed in Congress', 'politics', 100, '2022-01-01 10:30:00', 'Online'); | Update the 'source' field for all articles about politics to 'Mainstream Media' | UPDATE articles SET source = 'Mainstream Media' WHERE category = 'politics' | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50)); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10, 2)); CREATE TABLE organizations (id INT, name VARCHAR(50), category VARCHAR(20)); INSERT INTO donors (id, name) VALUES (1, 'Donor1'), (2, 'Donor2'), (3, 'Donor3'), (4, 'Donor4'), (5, 'Do... | Which organizations have received donations from donors who have also donated to organizations in the 'Education' category? | SELECT organizations.name FROM donations d1 JOIN donations d2 ON d1.donor_id = d2.donor_id JOIN organizations o1 ON d1.organization_id = o1.id JOIN organizations o2 ON d2.organization_id = o2.id WHERE o1.category = 'Environment' AND o2.category = 'Education' GROUP BY organizations.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT PRIMARY KEY, work_id INT, sale_price FLOAT, sale_date DATE, FOREIGN KEY (work_id) REFERENCES works(work_id)); | What is the total value of works in the impressionism category? | SELECT SUM(s.sale_price) AS total_value FROM sales s JOIN works w ON s.work_id = w.work_id WHERE w.style = 'Impressionism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RareEarthElements_Production (Year INT, Element VARCHAR(10), Quantity INT); INSERT INTO RareEarthElements_Production (Year, Element, Quantity) VALUES (2020, 'Neodymium', 3000), (2020, 'Dysprosium', 2500), (2020, 'Praseodymium', 2200); | List the production quantities for all Rare earth elements in 2020. | SELECT Element, Quantity FROM RareEarthElements_Production WHERE Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA news;CREATE TABLE NewsSource (name varchar(255), type varchar(10), region varchar(10));INSERT INTO NewsSource (name, type, region) VALUES ('NewsSourceA', 'news', 'eastern'), ('NewsSourceB', 'investigative', 'western'), ('NewsSourceC', 'news', 'western'), ('NewsSourceD', 'opinion', 'eastern'), ('NewsSource... | What is the total number of investigative journalism articles and news articles published by news sources in the eastern and western regions, excluding articles published by NewsSourceA and NewsSourceB? | SELECT COUNT(*) FROM ( (SELECT * FROM news.NewsSource WHERE (region = 'eastern' OR region = 'western') AND type IN ('investigative', 'news') AND name NOT IN ('NewsSourceA', 'NewsSourceB')) EXCEPT (SELECT * FROM news.NewsSource WHERE name IN ('NewsSourceA', 'NewsSourceB')) ) AS eastern_western_news | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (product_id VARCHAR(10), sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO sales_data (product_id, sale_date, revenue) VALUES ('ProdE', '2021-07-01', 800), ('ProdE', '2021-10-15', 900); | What are the sales figures for product 'ProdE' in Q3 2021? | SELECT SUM(revenue) FROM sales_data WHERE product_id = 'ProdE' AND sale_date BETWEEN '2021-07-01' AND '2021-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesignData (Game VARCHAR(20), Genre VARCHAR(20), Players INT); INSERT INTO GameDesignData (Game, Genre, Players) VALUES ('Fortnite', 'Battle Royale', 50000), ('Call of Duty', 'FPS', 30000), ('Minecraft', 'Sandbox', 12000); | List the unique game genres for games that have more than 10000 players | SELECT DISTINCT Genre FROM GameDesignData WHERE Players > 10000 | gretelai_synthetic_text_to_sql |
CREATE TABLE Textiles (brand VARCHAR(20), fabric_type VARCHAR(20), quantity INT); INSERT INTO Textiles (brand, fabric_type, quantity) VALUES ('Eco-friendly Fashions', 'Organic Cotton', 1500), ('Eco-friendly Fashions', 'Recycled Polyester', 2000), ('Fab Fashions', 'Viscose', 1200), ('Fab Fashions', 'Recycled Polyester',... | Display the top three most common fabric types in the 'Textiles' table, across all brands. | SELECT fabric_type, SUM(quantity) AS total_quantity FROM Textiles GROUP BY fabric_type ORDER BY total_quantity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris_data (debris_id INT, name VARCHAR(255), removal_date DATE); INSERT INTO space_debris_data (debris_id, name, removal_date) VALUES (1, 'Debris 1', '2005-05-01'), (2, 'Debris 2', '2012-02-25'), (3, 'Debris 3', '2008-09-10'); | Insert a new space debris record named 'Debris 4' removed on 2022-12-31 into the space_debris_data table | INSERT INTO space_debris_data (name, removal_date) VALUES ('Debris 4', '2022-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_financing (transaction_id INT, client_id INT, transaction_date DATE, principal DECIMAL(10,2)); INSERT INTO shariah_financing (transaction_id, client_id, transaction_date, principal) VALUES (1, 201, '2022-01-05', 100.00), (2, 202, '2022-02-15', 200.00), (3, 203, '2022-03-30', 50.00); | Find the total amount of principal paid by clients in the Shariah-compliant financing program in Q1 2022. | SELECT SUM(principal) FROM shariah_financing WHERE transaction_date BETWEEN '2022-01-01' AND '2022-03-31' AND client_id IN (SELECT client_id FROM microfinance_program WHERE program_name = 'Shariah-compliant financing'); | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterConsumption(id INT, mine_name VARCHAR(50), water_consumption_cubic_meters BIGINT, consumption_date DATE); | What is the total amount of water consumed, in cubic meters, by each mine, in the past 6 months, that has consumed more than 10,000 cubic meters of water? | SELECT mine_name, SUM(water_consumption_cubic_meters) as total_water_consumption FROM WaterConsumption WHERE consumption_date >= DATE(NOW()) - INTERVAL 6 MONTH GROUP BY mine_name HAVING total_water_consumption > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(255)); INSERT INTO Events (event_id, event_name) VALUES (1, 'Family Day'), (2, 'Community Fair'); CREATE TABLE Audience (audience_id INT, event_id INT, age_group VARCHAR(50), total_attendees INT); INSERT INTO Audience (audience_id, event_id, age_group, total_attende... | What is the percentage of attendees in each age group for the 'Family Day' event? | SELECT e.event_name, a.age_group, (COUNT(a.audience_id) * 100.0 / SUM(a.total_attendees)) AS percentage FROM Events e JOIN Audience a ON e.event_id = a.event_id GROUP BY e.event_name, a.age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, Name TEXT, City TEXT, DonationAmount DECIMAL); INSERT INTO Donors (DonorID, Name, City, DonationAmount) VALUES (1, 'John Doe', 'Los Angeles', 100.00), (2, 'Jane Smith', 'Houston', 200.00); CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, City TEXT, LastContactDate DATE); INSERT INT... | What is the total number of volunteers, total donation amount, and average donation per volunteer for the city of Los Angeles? | SELECT Volunteers.City, COUNT(DISTINCT Donors.DonorID) AS TotalVolunteers, SUM(Donors.DonationAmount) AS TotalDonations, AVG(Donors.DonationAmount) AS AverageDonationPerVolunteer FROM Donors INNER JOIN Volunteers ON Donors.City = Volunteers.City WHERE Volunteers.City = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtGalleries (gallery_name VARCHAR(255), country VARCHAR(255)); INSERT INTO ArtGalleries (gallery_name, country) VALUES ('Gallery A', 'USA'), ('Gallery B', 'USA'), ('Gallery C', 'Canada'), ('Gallery D', 'Canada'), ('Gallery E', 'Mexico'), ('Gallery F', 'France'); | Identify the top 2 countries with the most art galleries. | SELECT country, COUNT(*) as gallery_count FROM ArtGalleries GROUP BY country ORDER BY gallery_count DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50)); | Update the 'age' of athlete 'Samantha Green' in the 'players' table | UPDATE players SET age = 25 WHERE first_name = 'Samantha' AND last_name = 'Green'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_energy_projects ( id INT PRIMARY KEY, project_name VARCHAR(255), project_type VARCHAR(255), state VARCHAR(255), capacity FLOAT ); | What is the average installed capacity of solar energy projects in the state of New York, grouped by project type? | SELECT project_type, AVG(capacity) FROM solar_energy_projects WHERE state = 'New York' GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE rider_counts (count_id INT, count_date DATE, route_id INT, num_riders INT); INSERT INTO rider_counts (count_id, count_date, route_id, num_riders) VALUES (1, '2023-03-01', 1, 500), (2, '2023-03-01', 2, 700), (3, '2023-03-02', 1, 600), (4, '2023-03-02', 2, 800); | How many riders used public transportation on a given day? | SELECT count_date, SUM(num_riders) AS total_riders FROM rider_counts GROUP BY count_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT PRIMARY KEY, mission_year INT, num_of_medical_incidents INT); | How many medical incidents occurred in each year of space missions? | SELECT mission_year, SUM(num_of_medical_incidents) as total_incidents FROM space_missions GROUP BY mission_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stadium_C (match_id INT, attendance INT); INSERT INTO Stadium_C (match_id, attendance) VALUES (1, 5000), (2, 6000), (3, 4000); | What was the lowest attendance in Stadium C? | SELECT MIN(attendance) FROM Stadium_C; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, name VARCHAR(50), yield INT, acrate DECIMAL(5,2), region VARCHAR(50), year INT); INSERT INTO crops (id, name, yield, acrate, region, year) VALUES (1, 'Corn', 180, 2.3, 'Plains', 2021), (2, 'Soybeans', 160, 2.2, 'Plains', 2021), (3, 'Wheat', 150, 2.5, 'Plains', 2021); | Find the crop with the highest yield in the Plains region in 2021. | SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY yield DESC) AS rank FROM crops WHERE region = 'Plains' AND year = 2021) AS ranked_crops WHERE rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE developers (id INT, name VARCHAR(50), salary FLOAT, project VARCHAR(50)); INSERT INTO developers (id, name, salary, project) VALUES (1, 'Alice', 80000.0, 'Machine Learning'); INSERT INTO developers (id, name, salary, project) VALUES (2, 'Bob', 85000.0, 'Machine Learning'); | What is the minimum salary of developers who work on machine learning projects? | SELECT MIN(salary) FROM developers WHERE project = 'Machine Learning'; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_access (student_id INT, province VARCHAR(10), resource_id VARCHAR(5)); INSERT INTO student_access (student_id, province, resource_id) VALUES (1, 'Ontario', 'R101'), (2, 'British Columbia', 'R201'), (3, 'Ontario', 'R102'), (4, 'Quebec', 'R301'), (5, 'British Columbia', 'R202'), (6, 'Ontario', 'R103'... | What is the number of open pedagogy resources accessed by students in each province, grouped by resource type? | SELECT province, resource_type, COUNT(*) FROM student_access JOIN open_resources ON student_access.resource_id = open_resources.resource_id GROUP BY province, resource_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, industry TEXT, foundation_date DATE, founder_race TEXT); INSERT INTO startups(id, name, industry, foundation_date, founder_race) VALUES (1, 'TechCo', 'Tech', '2017-01-01', 'African American'); | How many startups were founded by people from underrepresented racial or ethnic backgrounds in the tech sector in the past 5 years? | SELECT COUNT(*) FROM startups WHERE industry = 'Tech' AND foundation_date >= '2016-01-01' AND founder_race IN ('African American', 'Hispanic', 'Native American', 'Pacific Islander'); | gretelai_synthetic_text_to_sql |
CREATE TABLE RecycledMaterialProducts (product_id INT, price DECIMAL, is_recycled_material BOOLEAN); INSERT INTO RecycledMaterialProducts (product_id, price, is_recycled_material) VALUES (1, 100.00, true), (2, 150.00, false), (3, 75.00, true); | What is the total revenue of products made with recycled materials? | SELECT SUM(price) FROM RecycledMaterialProducts WHERE is_recycled_material = true; | 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.