context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE hotel_tech_adoption (adoption_id INT, adoption_rate FLOAT, country TEXT, quarter TEXT); INSERT INTO hotel_tech_adoption (adoption_id, adoption_rate, country, quarter) VALUES (1, 0.65, 'USA', 'Q1 2023'), (2, 0.72, 'Canada', 'Q1 2023');
|
What is the hotel tech adoption rate by country, in Q1 2023?
|
SELECT quarter, country, AVG(adoption_rate) FROM hotel_tech_adoption GROUP BY quarter, country;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW courier_performances AS SELECT courier_id, order_id, MAX(delivery_time) as slowest_delivery_time FROM orders GROUP BY courier_id, order_id;
|
What is the order ID and delivery time for the slowest delivery made by each courier in the 'courier_performances' view, ordered by the slowest delivery time?
|
SELECT courier_id, order_id, MAX(slowest_delivery_time) as slowest_delivery_time FROM courier_performances GROUP BY courier_id, order_id ORDER BY slowest_delivery_time;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shelters (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO shelters (id, name, location, capacity) VALUES (1, 'Shelter A', 'Nairobi', 50), (2, 'Shelter B', 'Mombasa', 75);
|
What is the total number of shelters in Kenya and the number of families they accommodate?
|
SELECT SUM(capacity) as total_capacity, (SELECT COUNT(DISTINCT id) FROM shelters WHERE location = 'Kenya') as family_count FROM shelters WHERE location = 'Kenya';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE models (id INT, name VARCHAR(255), region VARCHAR(255), is_fairness_test BOOLEAN); INSERT INTO models (id, name, region, is_fairness_test) VALUES (1, 'ModelA', 'US', true), (2, 'ModelB', 'EU', false), (3, 'ModelC', 'APAC', true), (4, 'ModelD', 'US', false), (5, 'ModelE', 'US', true);
|
What is the total number of models that have been trained and tested for fairness in the 'US' region?
|
SELECT COUNT(*) FROM models WHERE region = 'US' AND is_fairness_test = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), installed_capacity INT, commissioning_date DATE, energy_efficiency_rating INT); INSERT INTO solar_projects (project_id, project_name, location, installed_capacity, commissioning_date, energy_efficiency_rating) VALUES (1, 'Solar Farm A', 'California', 150, '2018-05-01', 80); INSERT INTO solar_projects (project_id, project_name, location, installed_capacity, commissioning_date, energy_efficiency_rating) VALUES (2, 'Solar Farm B', 'Texas', 200, '2019-11-15', 85); INSERT INTO solar_projects (project_id, project_name, location, installed_capacity, commissioning_date, energy_efficiency_rating) VALUES (3, 'Solar Farm C', 'New York', 120, '2020-07-20', 95);
|
Show the energy efficiency ratings for solar projects in New York, and the average energy efficiency rating for solar projects in New York
|
SELECT energy_efficiency_rating FROM solar_projects WHERE location = 'New York'; SELECT AVG(energy_efficiency_rating) FROM solar_projects WHERE location = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tennis_players (id INT, name VARCHAR(100), country VARCHAR(50)); CREATE TABLE tennis_tournaments (id INT, name VARCHAR(50), year INT, surface VARCHAR(50)); CREATE TABLE tennis_winners (player_id INT, tournament_id INT, year INT, result VARCHAR(50));
|
List the names of all tennis players who have won a Grand Slam tournament, along with the tournament name and the year they won it.
|
SELECT p.name, t.name as tournament, w.year FROM tennis_players p JOIN tennis_winners w ON p.id = w.player_id JOIN tennis_tournaments t ON w.tournament_id = t.id WHERE w.result = 'Winner';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title TEXT, release_year INT, rating FLOAT, director TEXT); INSERT INTO movies (id, title, release_year, rating, director) VALUES (1, 'Movie1', 2019, 7.5, 'Director1'); INSERT INTO movies (id, title, release_year, rating, director) VALUES (2, 'Movie2', 2021, 8.2, 'Director2');
|
What is the minimum rating for movies produced in the last 5 years by directors from underrepresented communities?
|
SELECT MIN(rating) FROM movies WHERE release_year >= YEAR(CURRENT_DATE) - 5 AND director IN (SELECT director FROM directors WHERE underrepresented = true);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (contract_name VARCHAR(20), associated_asset VARCHAR(10)); INSERT INTO smart_contracts (contract_name, associated_asset) VALUES ('Contract1', 'ETH'), ('Contract2', 'BTC'), ('Contract3', 'LTC');
|
List all smart contracts associated with the digital asset 'BTC'
|
SELECT contract_name FROM smart_contracts WHERE associated_asset = 'BTC';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, state VARCHAR(50), donor_type VARCHAR(50)); INSERT INTO donors (id, state, donor_type) VALUES (1, 'CA', 'foundation'), (2, 'NY', 'individual'), (3, 'CA', 'individual'); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 200), (4, 3, 1000);
|
How many total donations did we receive from foundations based in CA?
|
SELECT SUM(donations.amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.state = 'CA' AND donors.donor_type = 'foundation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE international_visitors (id INT, country VARCHAR(50), visit_month DATE); INSERT INTO international_visitors (id, country, visit_month) VALUES (1, 'New Zealand', '2022-01-01'), (2, 'New Zealand', '2022-02-01'), (3, 'New Zealand', '2022-02-15');
|
What is the maximum number of international visitors to New Zealand in a month?
|
SELECT MAX(MONTH(visit_month)) as max_month, COUNT(*) as max_visitors FROM international_visitors WHERE country = 'New Zealand' GROUP BY max_month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tech_accessibility_orgs (id INT PRIMARY KEY, name VARCHAR(255), website VARCHAR(255), city VARCHAR(255)); INSERT INTO tech_accessibility_orgs (id, name, website, city) VALUES (1, 'Open Inclusion', 'https://openinclusion.com', 'London'); INSERT INTO tech_accessibility_orgs (id, name, website, city) VALUES (2, 'Technability', 'https://technability.org', 'Tel Aviv'); INSERT INTO tech_accessibility_orgs (id, name, website, city) VALUES (3, 'BarrierBreak', 'https://barrierbreak.com', 'Mumbai'); CREATE TABLE papers (id INT PRIMARY KEY, title VARCHAR(255), org_id INT, publication_date DATE); INSERT INTO papers (id, title, org_id, publication_date) VALUES (1, 'Designing for Accessibility', 1, '2021-04-25'); INSERT INTO papers (id, title, org_id, publication_date) VALUES (2, 'Assistive Technology Trends', 2, '2021-10-12'); INSERT INTO papers (id, title, org_id, publication_date) VALUES (3, 'Accessibility in AI-powered Products', 3, '2022-02-15');
|
What organizations are dedicated to technology accessibility and have published at least one paper?
|
SELECT DISTINCT name FROM tech_accessibility_orgs WHERE id IN (SELECT org_id FROM papers);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_3pointers (player_id INT, name VARCHAR(50), team VARCHAR(50), threes INT); INSERT INTO nba_3pointers (player_id, name, team, threes) VALUES (1, 'Stephen Curry', 'Golden State Warriors', 300); INSERT INTO nba_3pointers (player_id, name, team, threes) VALUES (2, 'James Harden', 'Brooklyn Nets', 250);
|
What is the highest number of 3-pointers made by each basketball player in the NBA?
|
SELECT name, MAX(threes) FROM nba_3pointers GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (menu_item VARCHAR(255), category VARCHAR(255), sales_revenue DECIMAL(10, 2)); INSERT INTO sales (menu_item, category, sales_revenue) VALUES ('Burger', 'Main Dishes', 15.99); INSERT INTO sales (menu_item, category, sales_revenue) VALUES ('Caesar Salad', 'Salads', 12.50);
|
What is the total sales revenue for each category in the last month?
|
SELECT category, SUM(sales_revenue) as total_revenue FROM sales WHERE sales_revenue > 0 AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (vessel_id VARCHAR(10), name VARCHAR(20), type VARCHAR(20), max_speed FLOAT); INSERT INTO Vessels (vessel_id, name, type, max_speed) VALUES ('1', 'Vessel A', 'Cargo', 20.5), ('2', 'Vessel B', 'Tanker', 15.2), ('3', 'Vessel C', 'Tanker', 18.1), ('4', 'Vessel D', 'Cargo', 12.6);
|
Which vessels have a max speed greater than 18?
|
SELECT vessel_id, name FROM Vessels WHERE max_speed > 18;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteAltitude (satellite_id INT, company VARCHAR(255), altitude INT);
|
What is the maximum altitude reached by any satellite deployed by Orbital Inc.?
|
SELECT MAX(altitude) FROM SatelliteAltitude WHERE company = 'Orbital Inc.';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, material VARCHAR(20), price DECIMAL(5,2), market VARCHAR(20)); INSERT INTO products (product_id, material, price, market) VALUES (1, 'organic cotton', 50.00, 'Asia'), (2, 'sustainable wood', 60.00, 'Asia'), (3, 'recycled polyester', 70.00, 'Europe'), (4, 'organic linen', 80.00, 'Asia');
|
What is the average price of products made from sustainable materials in the Asian market?
|
SELECT AVG(price) FROM products WHERE market = 'Asia' AND material IN ('organic cotton', 'sustainable wood', 'recycled polyester', 'organic linen');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT PRIMARY KEY, name VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); CREATE TABLE songs (id INT PRIMARY KEY, title VARCHAR(255), artist_id INT, released DATE); CREATE TABLE streams (id INT PRIMARY KEY, song_id INT, user_id INT, stream_date DATE, FOREIGN KEY (song_id) REFERENCES songs(id)); CREATE TABLE users (id INT PRIMARY KEY, gender VARCHAR(50), age INT);
|
List the top 5 most streamed songs for users aged 18-24.
|
SELECT s.title, COUNT(s.id) AS total_streams FROM streams s JOIN users u ON s.user_id = u.id WHERE u.age BETWEEN 18 AND 24 GROUP BY s.title ORDER BY total_streams DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, autonomous_driving BOOLEAN); INSERT INTO research_papers (id, title, publication_year, autonomous_driving) VALUES (1, 'Autonomous Driving and AI', 2020, true), (2, 'Hybrid Vehicle Efficiency', 2021, false), (3, 'EV Charging Infrastructure', 2021, false), (4, 'Sensors in Autonomous Vehicles', 2022, true);
|
Find the total number of autonomous driving research papers published
|
SELECT COUNT(*) FROM research_papers WHERE autonomous_driving = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget DECIMAL, ProgramDate DATE, ImpactScore INT); INSERT INTO Programs (ProgramID, ProgramName, Budget, ProgramDate, ImpactScore) VALUES (1, 'Art Education', 125000.00, '2020-01-01', 85), (2, 'Theater Production', 75000.00, '2021-07-15', 90), (3, 'Music Recording', 150000.00, '2019-12-31', 88);
|
What is the average program impact score for programs with a budget over $100,000 in the past 2 years?
|
SELECT AVG(ImpactScore) FROM Programs WHERE Budget > 100000.00 AND ProgramDate >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (usage_id INT, city VARCHAR(20), usage FLOAT, date DATE); INSERT INTO water_usage (usage_id, city, usage, date) VALUES (1, 'Chicago', 500000.0, '2021-01-01'), (2, 'Chicago', 600000.0, '2021-02-01'), (3, 'New York', 700000.0, '2021-03-01');
|
What is the maximum water usage in a single day for the city of Chicago?
|
SELECT MAX(usage) FROM water_usage WHERE city = 'Chicago';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft_telemetry (id INT, spacecraft_model VARCHAR(255), altitude INT);
|
What is the maximum altitude reached by each spacecraft model?
|
SELECT spacecraft_model, MAX(altitude) as max_altitude FROM spacecraft_telemetry GROUP BY spacecraft_model;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farming_Sites (Site_ID INT, Site_Name TEXT, Hemisphere TEXT); INSERT INTO Farming_Sites (Site_ID, Site_Name, Hemisphere) VALUES (1, 'Site A', 'Northern'), (2, 'Site B', 'Southern'), (3, 'Site C', 'Southern'); CREATE TABLE Fish_Stock (Site_ID INT, Fish_Type TEXT, Biomass FLOAT); INSERT INTO Fish_Stock (Site_ID, Fish_Type, Biomass) VALUES (1, 'Salmon', 5000), (1, 'Tuna', 3000), (2, 'Salmon', 7000), (2, 'Tilapia', 4000), (3, 'Salmon', 6000), (3, 'Tuna', 2000);
|
What is the difference in biomass between farming sites in the Northern and Southern Hemispheres for each fish type?
|
SELECT Fish_Type, SUM(CASE WHEN Hemisphere = 'Northern' THEN Biomass ELSE 0 END) - SUM(CASE WHEN Hemisphere = 'Southern' THEN Biomass ELSE 0 END) FROM Fish_Stock INNER JOIN Farming_Sites ON Fish_Stock.Site_ID = Farming_Sites.Site_ID GROUP BY Fish_Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE traditional_dances (id INT, name VARCHAR(50), location VARCHAR(50), dance_type VARCHAR(50), PRIMARY KEY(id)); INSERT INTO traditional_dances (id, name, location, dance_type) VALUES (1, 'Bharatanatyam', 'India', 'Classical'), (2, 'Odissi', 'India', 'Classical'), (3, 'Kathak', 'India', 'Classical'), (4, 'Jingju', 'China', 'Opera'), (5, 'Bian Lian', 'China', 'Opera');
|
How many traditional dances are documented for each country in Asia?
|
SELECT t.location, COUNT(*) AS dance_count FROM traditional_dances t GROUP BY t.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_cars (make VARCHAR(50), model VARCHAR(50), year INT, horsepower INT);
|
What is the average horsepower for electric vehicles in the 'green_cars' table?
|
SELECT AVG(horsepower) FROM green_cars WHERE horsepower IS NOT NULL AND make = 'Tesla';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, HireYear INT, Department VARCHAR(20)); CREATE TABLE Trainings (TrainingID INT, EmployeeID INT, TrainingYear INT, Cost FLOAT); INSERT INTO Employees (EmployeeID, HireYear, Department) VALUES (1, 2019, 'IT'), (2, 2019, 'HR'), (3, 2018, 'IT'), (4, 2019, 'IT'); INSERT INTO Trainings (TrainingID, EmployeeID, TrainingYear, Cost) VALUES (1, 1, 2019, 500.00), (2, 2, 2019, 600.00), (3, 3, 2018, 700.00), (4, 4, 2019, 800.00);
|
What is the total training cost for employees who joined the company in 2019, grouped by their department?
|
SELECT Department, SUM(Cost) FROM Employees INNER JOIN Trainings ON Employees.EmployeeID = Trainings.EmployeeID WHERE Employees.HireYear = 2019 GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE total_renewable_projects (project_id INT, country VARCHAR(50)); INSERT INTO total_renewable_projects (project_id, country) VALUES (1, 'India'), (2, 'Brazil');
|
What is the total number of renewable energy projects in 'India'?
|
SELECT COUNT(*) FROM total_renewable_projects WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer (customer_id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE credit_card (transaction_id INT, customer_id INT, value DECIMAL(10,2), timestamp TIMESTAMP);
|
What is the maximum transaction value for each customer in the "credit_card" table, grouped by their country?
|
SELECT c.country, MAX(cc.value) as max_value FROM customer c JOIN credit_card cc ON c.customer_id = cc.customer_id GROUP BY c.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (ExhibitionID INT, ExhibitionType VARCHAR(255), ExhibitionDate DATE); INSERT INTO Exhibitions (ExhibitionID, ExhibitionType, ExhibitionDate) VALUES (1, 'Art', '2017-01-01'); INSERT INTO Exhibitions (ExhibitionID, ExhibitionType, ExhibitionDate) VALUES (2, 'Science', '2018-07-15'); INSERT INTO Exhibitions (ExhibitionID, ExhibitionType, ExhibitionDate) VALUES (3, 'History', '2019-03-25');
|
How many exhibitions were organized by the museum in the last 5 years, segmented by type?
|
SELECT ExhibitionType, COUNT(ExhibitionID) as Count FROM Exhibitions WHERE ExhibitionDate >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY ExhibitionType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10, 2), cause_id INT); INSERT INTO donations (id, donor_id, amount, cause_id) VALUES (1, 1, 500.00, 3), (2, 1, 300.00, 3), (3, 2, 250.00, 4), (4, 2, 400.00, 4), (5, 3, 100.00, 3), (6, 4, 700.00, 4), (7, 5, 1200.00, 3);
|
What is the maximum donation amount in each non-social cause category?
|
SELECT c.type, MAX(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id GROUP BY c.type HAVING c.type != 'Social';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, plant_id INT, generation_date DATE, waste_amount FLOAT); CREATE TABLE manufacturing_plants (id INT, plant_name VARCHAR(100), country VARCHAR(50)); INSERT INTO manufacturing_plants (id, plant_name, country) VALUES (1, 'Argentina Plant 1', 'Argentina'), (2, 'Argentina Plant 2', 'Argentina'); INSERT INTO waste_generation (id, plant_id, generation_date, waste_amount) VALUES (1, 1, '2020-01-01', 120.3), (2, 1, '2020-05-15', 150.6), (3, 2, '2020-12-28', 180.9);
|
What is the total amount of waste generated by the chemical manufacturing plants in Argentina in the year 2020?
|
SELECT SUM(waste_amount) FROM waste_generation JOIN manufacturing_plants ON waste_generation.plant_id = manufacturing_plants.id WHERE manufacturing_plants.country = 'Argentina' AND EXTRACT(YEAR FROM generation_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Chicago'), (2, 'Houston'); CREATE TABLE shipments (id INT, warehouse_id INT, country VARCHAR(255)); INSERT INTO shipments (id, warehouse_id, country) VALUES (1, 1, 'USA'), (2, 1, 'Canada'), (3, 2, 'Mexico'), (4, 2, 'USA');
|
How many shipments were sent to each country from warehouse 2?
|
SELECT warehouse_id, country, COUNT(*) as num_shipments FROM shipments GROUP BY warehouse_id, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Foods(id INT, name TEXT, type TEXT, calories INT, is_gmo BOOLEAN); INSERT INTO Foods(id, name, type, calories, is_gmo) VALUES (1, 'Scrambled Tofu', 'Breakfast', 450, FALSE), (2, 'Blueberry Oatmeal', 'Breakfast', 380, FALSE);
|
Which non-GMO breakfast items have more than 400 calories?
|
SELECT name, calories FROM Foods WHERE type = 'Breakfast' AND calories > 400 AND is_gmo = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmers (Farmer_ID INT, Farmer_Name TEXT, Location TEXT, Sustainable_Practices_Adopted INT, Year INT); INSERT INTO Farmers (Farmer_ID, Farmer_Name, Location, Sustainable_Practices_Adopted, Year) VALUES (1, 'Siti', 'Indonesia', 1, 2018), (2, 'Lee', 'Malaysia', 1, 2018);
|
How many farmers in Indonesia and Malaysia adopted sustainable agricultural practices in 2018?
|
SELECT SUM(Sustainable_Practices_Adopted) FROM Farmers WHERE Year = 2018 AND Location IN ('Indonesia', 'Malaysia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer (id INT, name VARCHAR(255), address VARCHAR(255), account_balance DECIMAL(10, 2)); INSERT INTO customer (id, name, address, account_balance) VALUES (1, 'Ravi Patel', 'Mumbai', 3000.00), (2, 'Priya Gupta', 'Mumbai', 4000.00);
|
What is the total account balance for customers in Mumbai?
|
SELECT SUM(account_balance) FROM customer WHERE address = 'Mumbai';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country_codes (country_code CHAR(2), country_name VARCHAR(100), offset_program_start_year INT); INSERT INTO country_codes (country_code, country_name, offset_program_start_year) VALUES ('US', 'United States', 2010), ('CA', 'Canada', 2015), ('MX', 'Mexico', 2018);
|
How many carbon offset programs were implemented in 'country_codes' table in the year 2020?
|
SELECT COUNT(*) FROM country_codes WHERE offset_program_start_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO readers (id, name, age, country) VALUES (1, 'John Doe', 45, 'USA'), (2, 'Jane Smith', 35, 'USA'); CREATE TABLE news_preferences (id INT, reader_id INT, preference VARCHAR(50)); INSERT INTO news_preferences (id, reader_id, preference) VALUES (1, 1, 'print'), (2, 2, 'digital');
|
What is the average age of readers who prefer print news in the United States?
|
SELECT AVG(readers.age) FROM readers INNER JOIN news_preferences ON readers.id = news_preferences.reader_id WHERE readers.country = 'USA' AND news_preferences.preference = 'print';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_institutions (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO financial_institutions (id, name, type, location) VALUES (1, 'ABC Bank', 'Islamic', 'India'); INSERT INTO financial_institutions (id, name, type, location) VALUES (2, 'Islamic Bank', 'Islamic', 'UAE'); CREATE TABLE loans (id INT, institution_id INT, type VARCHAR(255), amount DECIMAL(10,2), date DATE); INSERT INTO loans (id, institution_id, type, amount, date) VALUES (1, 1, 'Islamic', 5000.00, '2022-01-01'); INSERT INTO loans (id, institution_id, type, amount, date) VALUES (2, 2, 'Islamic', 6000.00, '2022-01-02');
|
What is the total amount of Shariah-compliant loans issued by financial institutions located in Asia?
|
SELECT SUM(amount) FROM loans WHERE type = 'Islamic' AND institution_id IN (SELECT id FROM financial_institutions WHERE location = 'Asia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VolunteerHours (Program VARCHAR(30), VolunteerHours INT, VolunteerDate DATE); INSERT INTO VolunteerHours (Program, VolunteerHours, VolunteerDate) VALUES ('Education', 150, '2022-01-05'), ('Health', 200, '2022-01-10'), ('Education', 120, '2022-02-03');
|
Which programs had the highest volunteer hours in Q1 2022?
|
SELECT Program, SUM(VolunteerHours) FROM VolunteerHours WHERE VolunteerDate BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY Program ORDER BY SUM(VolunteerHours) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (Region TEXT, PeopleWithHealthcare INTEGER); INSERT INTO Regions (Region, PeopleWithHealthcare) VALUES ('Africa', 600000000), ('Asia', 2000000000), ('Europe', 700000000);
|
How many people in Africa have access to healthcare?
|
SELECT PeopleWithHealthcare FROM Regions WHERE Region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE continent (continent_id INT, name VARCHAR(50)); INSERT INTO continent (continent_id, name) VALUES (1, 'Asia'), (2, 'Africa'); CREATE TABLE year (year_id INT, year INT); INSERT INTO year (year_id, year) VALUES (1, 2022), (2, 2021); CREATE TABLE supplies (supply_id INT, type VARCHAR(50), continent_id INT, year_id INT, quantity INT); INSERT INTO supplies (supply_id, type, continent_id, year_id, quantity) VALUES (1, 'Food', 2, 1, 800), (2, 'Water', 2, 1, 600), (3, 'Medical', 1, 1, 1000);
|
How many 'medical relief supplies' were sent to 'Africa' in the year 2022?
|
SELECT SUM(quantity) FROM supplies WHERE type = 'Medical' AND continent_id = 2 AND year_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AutonomousDrivingStudies (Country VARCHAR(50), Studies INT); INSERT INTO AutonomousDrivingStudies (Country, Studies) VALUES ('Germany', 30), ('USA', 50), ('China', 45);
|
What is the total number of autonomous driving research studies conducted in Germany?
|
SELECT SUM(Studies) FROM AutonomousDrivingStudies WHERE Country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attendees (id INT, event_id INT, name VARCHAR(255)); CREATE TABLE events (id INT, name VARCHAR(255), genre VARCHAR(255)); INSERT INTO attendees (id, event_id, name) VALUES (1, 1, 'John Doe'); INSERT INTO attendees (id, event_id, name) VALUES (2, 1, 'Jane Doe'); INSERT INTO events (id, name, genre) VALUES (1, 'Modern Art Exhibit', 'Modern Art');
|
How many unique attendees visited art exhibitions in the 'Modern Art' genre?
|
SELECT COUNT(DISTINCT a.name) FROM attendees a JOIN events e ON a.event_id = e.id WHERE e.genre = 'Modern Art';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Soldiers (SoldierID INT, Name VARCHAR(50), Rank VARCHAR(20), EntryYear INT); INSERT INTO Soldiers (SoldierID, Name, Rank, EntryYear) VALUES (1, 'John Doe', 'Captain', 1995), (2, 'Jane Smith', 'Lieutenant', 2002), (3, 'Mary Johnson', 'Lieutenant', 2000);
|
Select the Name, Rank, and EntryYear of the top 2 soldiers with the earliest EntryYear.
|
SELECT Name, Rank, EntryYear FROM (SELECT Name, Rank, EntryYear, ROW_NUMBER() OVER (ORDER BY EntryYear) as RowNum FROM Soldiers) AS SoldiersRanked WHERE RowNum <= 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (id INT, name VARCHAR(50), network VARCHAR(20)); INSERT INTO subscribers (id, name, network) VALUES (1, 'Jane Doe', '4G'), (2, 'Mike Smith', '5G'), (3, 'Sara Connor', '4G');
|
How many customers are there in each network type?
|
SELECT network, COUNT(*) FROM subscribers GROUP BY network;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE reporters (id INT, name VARCHAR(255), gender VARCHAR(10), age INT, country VARCHAR(100)); INSERT INTO reporters (id, name, gender, age, country) VALUES (4, 'Aisha Okeke', 'Female', 38, 'Nigeria'); INSERT INTO reporters (id, name, gender, age, country) VALUES (5, 'Kwame Boateng', 'Male', 45, 'Ghana');
|
Which reporters are based in African countries?
|
SELECT * FROM reporters WHERE country IN ('Nigeria', 'Ghana', 'Kenya', 'Egypt', 'South Africa');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE justice_data.juvenile_offenders (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(50), restorative_justice_program BOOLEAN);
|
What is the total number of offenders in the justice_data schema's juvenile_offenders table who have been referred to restorative justice programs, broken down by race?
|
SELECT race, COUNT(*) FROM justice_data.juvenile_offenders WHERE restorative_justice_program = TRUE GROUP BY race;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, campaign VARCHAR(50), amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (id, campaign, amount, donation_date) VALUES (1, 'Spring Campaign', 5000, '2022-04-01'), (2, 'Summer Campaign', 6000, '2022-06-01'), (3, 'Fall Campaign', 7000, '2022-08-01'), (4, 'Winter Campaign', 8000, '2022-10-01');
|
Which campaigns received the most donations in H1 2022?
|
SELECT campaign, SUM(amount) as total_donations FROM Donations WHERE donation_date >= '2022-01-01' AND donation_date <= '2022-06-30' GROUP BY campaign ORDER BY total_donations DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LaborStatsByQuarter (StatID int, Region varchar(20), Quarter int, WageIncrease decimal(10,2)); INSERT INTO LaborStatsByQuarter (StatID, Region, Quarter, WageIncrease) VALUES (1, 'Eastern', 3, 0.04), (2, 'Eastern', 4, 0.05), (3, 'Eastern', 4, 0.03);
|
Show the construction labor statistics for the last quarter, for the Eastern region, and rank the statistics by their wage increases in descending order.
|
SELECT Region, WageIncrease, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY WageIncrease DESC) as rn FROM LaborStatsByQuarter WHERE Region = 'Eastern' AND Quarter IN (3, 4);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication_projects (project_id INT, sector TEXT, investor_type TEXT, region TEXT); INSERT INTO climate_communication_projects (project_id, sector, investor_type, region) VALUES (1, 'Climate Communication', 'Private', 'Asia'); INSERT INTO climate_communication_projects (project_id, sector, investor_type, region) VALUES (2, 'Climate Communication', 'Public', 'Asia');
|
Identify the number of climate communication projects funded by private sectors in Asia.
|
SELECT COUNT(*) FROM climate_communication_projects WHERE sector = 'Climate Communication' AND investor_type = 'Private';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name TEXT);CREATE TABLE emergencies (emergency_id INT, district_id INT, response_time INT, emergency_date DATE);
|
What is the average response time for emergencies in the 'South' district in the last year?
|
SELECT AVG(response_time) FROM emergencies WHERE district_id = (SELECT district_id FROM districts WHERE district_name = 'South') AND emergency_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Production(garment_id INT, category VARCHAR(20), recycled_material_weight INT); INSERT INTO Production(garment_id, category, recycled_material_weight) VALUES (1, 'Vintage_Styles', 5), (2, 'Vintage_Styles', 3);
|
What is the total weight of recycled materials used in the production of garments in the 'Vintage_Styles' category?
|
SELECT SUM(recycled_material_weight) FROM Production WHERE category = 'Vintage_Styles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists user_profile (user_id int, age int, gender varchar(10), signup_date date);CREATE TABLE if not exists ad_impressions (impression_id int, user_id int, ad_id int, impression_date date);CREATE TABLE if not exists ad_clicks (click_id int, user_id int, ad_id int, click_date date);
|
Show the total number of ad impressions and clicks for users aged between 25 and 34 in the last week, along with the click-through rate (CTR).
|
SELECT u.age_range, COUNT(i.impression_id) as total_impressions, COUNT(c.click_id) as total_clicks, (COUNT(c.click_id) * 100.0 / COUNT(i.impression_id)) as ctr FROM (SELECT user_id, CASE WHEN age BETWEEN 25 AND 34 THEN '25-34' END as age_range FROM user_profile WHERE signup_date <= DATEADD(day, -7, GETDATE())) u INNER JOIN ad_impressions i ON u.user_id = i.user_id INNER JOIN ad_clicks c ON u.user_id = c.user_id WHERE i.impression_date = c.click_date AND u.age_range IS NOT NULL GROUP BY u.age_range;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_returns (return_id INT, customer_id INT, return_date DATE);
|
Identify the customers who returned the most items in reverse logistics in Q4 2020, with at least 3 returns.
|
SELECT customer_id, COUNT(*) as num_returns FROM customer_returns WHERE EXTRACT(MONTH FROM return_date) BETWEEN 10 AND 12 GROUP BY customer_id HAVING num_returns >= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (area_name TEXT, region TEXT, establishment_date DATE); CREATE TABLE pacific_region (region_name TEXT, region_description TEXT);
|
What is the total number of marine protected areas in the Pacific region that were established in the last decade?"
|
SELECT COUNT(mpa.area_name) FROM marine_protected_areas mpa INNER JOIN pacific_region pr ON mpa.region = pr.region_name AND mpa.establishment_date >= (CURRENT_DATE - INTERVAL '10 years');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, initiative_name VARCHAR(100), initiative_type VARCHAR(50), funding_source VARCHAR(50), funds_received FLOAT, start_date DATE, end_date DATE);
|
List the community development initiatives with their respective funding sources in 2019, ordered by the amount of funds received?
|
SELECT initiative_name, funding_source, funds_received FROM community_development WHERE YEAR(start_date) = 2019 ORDER BY funds_received DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_tanks (tank_id INT, species VARCHAR(255), water_temperature DECIMAL(5,2)); INSERT INTO fish_tanks (tank_id, species, water_temperature) VALUES (1, 'Tilapia', 26.5), (2, 'Salmon', 12.0), (3, 'Tilapia', 27.3), (4, 'Catfish', 24.6), (5, 'Salmon', 12.5);
|
What is the minimum and maximum water temperature for each tank in the 'fish_tanks' table?
|
SELECT tank_id, MIN(water_temperature) as min_temp, MAX(water_temperature) as max_temp FROM fish_tanks GROUP BY tank_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT, team_id INT, player_id INT, points INT, sport VARCHAR(50)); INSERT INTO games (id, team_id, player_id, points, sport) VALUES (1, 101, 1, 25, 'Basketball'); INSERT INTO games (id, team_id, player_id, points, sport) VALUES (2, 102, 2, 30, 'Basketball');
|
What is the average number of points scored by basketball players in the last 5 games they have played?
|
SELECT AVG(points) FROM games WHERE sport = 'Basketball' AND id IN (SELECT game_id FROM last_5_games);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, state VARCHAR(20), construction_year INT); INSERT INTO green_buildings (id, state, construction_year) VALUES (1, 'Texas', 2012), (2, 'Texas', 2005), (3, 'California', 2018), (4, 'Texas', 2014);
|
What is the total number of green buildings in the state of Texas that were constructed before 2015?
|
SELECT COUNT(*) FROM green_buildings WHERE state = 'Texas' AND construction_year < 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salesperson (id INT, name VARCHAR(50), team VARCHAR(50)); CREATE TABLE tickets (id INT, salesperson_id INT, quantity INT, city VARCHAR(50)); INSERT INTO salesperson (id, name, team) VALUES (1, 'John Doe', 'Knicks'), (2, 'Jane Smith', 'Giants'), (3, 'Mia Rodriguez', 'Lakers'), (4, 'Mason Green', 'United'); INSERT INTO tickets (id, salesperson_id, quantity, city) VALUES (1, 1, 50, 'New York'), (2, 1, 75, 'New York'), (3, 2, 30, 'Los Angeles'), (4, 2, 40, 'Los Angeles'), (5, 3, 25, 'Chicago'), (6, 3, 50, 'Chicago'), (7, 4, 10, 'London');
|
Find the total number of tickets sold by each salesperson, grouped by team.
|
SELECT s.team, s.name, SUM(t.quantity) as total_quantity FROM salesperson s JOIN tickets t ON s.id = t.salesperson_id GROUP BY s.team, s.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectronicWaste (Region VARCHAR(50), WasteQuantity INT); INSERT INTO ElectronicWaste (Region, WasteQuantity) VALUES ('World', 50000000), ('Europe', 5000000), ('North America', 15000000), ('Asia', 25000000);
|
What is the total amount of electronic waste generated in the world, and how does that compare to the amount of electronic waste generated in Europe?
|
SELECT Region, WasteQuantity FROM ElectronicWaste WHERE Region IN ('World', 'Europe');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (ingredient_id INT, ingredient_name VARCHAR(50), ingredient_category VARCHAR(50), quantity INT, cost DECIMAL(5,2)); INSERT INTO inventory VALUES (1, 'Quinoa', 'Grain', 50, 2.99), (2, 'Milk', 'Dairy', 30, 1.49), (3, 'Tofu', 'Protein', 40, 1.99), (4, 'Cheese', 'Dairy', 20, 3.99);
|
What is the total cost of dairy ingredients?
|
SELECT SUM(quantity * cost) FROM inventory WHERE ingredient_category = 'Dairy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatments (treatment_id INT, treatment VARCHAR(10), patient_id INT); INSERT INTO treatments (treatment_id, treatment, patient_id) VALUES (1, 'CBT', 1), (2, 'DBT', 2), (3, 'CBT', 3), (4, 'Group Therapy', 1), (5, 'CBT', 2);
|
List the number of unique patients who have completed each type of treatment.
|
SELECT treatment, COUNT(DISTINCT patient_id) FROM treatments GROUP BY treatment;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_salinity (location VARCHAR(255), salinity FLOAT, date DATE);
|
What is the minimum surface salinity recorded in the Pacific Ocean?
|
SELECT MIN(salinity) FROM ocean_salinity WHERE location = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_species (year INT, species_count INT);
|
What is the maximum number of species observed in the 'arctic_species' table, grouped by year?
|
SELECT year, MAX(species_count) FROM arctic_species GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_name VARCHAR(50), team_city VARCHAR(50), games_won INT); INSERT INTO teams (team_name, team_city, games_won) VALUES ('Red Sox', 'Boston', 93), ('Yankees', 'New York', 92);
|
What is the total number of games won by each team in the last season?
|
SELECT team_name, SUM(games_won) as total_games_won FROM teams WHERE game_date >= DATEADD(year, -1, GETDATE()) GROUP BY team_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country (id INT, name VARCHAR(255)); INSERT INTO country (id, name) VALUES (1, 'USA'), (2, 'China'), (3, 'Japan'); CREATE TABLE digital_assets (id INT, country_id INT, name VARCHAR(255), quantity INT); INSERT INTO digital_assets (id, country_id, name, quantity) VALUES (1, 1, 'AssetA', 500), (2, 1, 'AssetB', 300), (3, 2, 'AssetC', 200), (4, 3, 'AssetD', 400);
|
What is the total number of digital assets issued by each country?
|
SELECT country.name AS Country, SUM(digital_assets.quantity) AS Total_Assets FROM country JOIN digital_assets ON country.id = digital_assets.country_id GROUP BY country.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_stock (fish_id INT PRIMARY KEY, species VARCHAR(50), location VARCHAR(50), biomass FLOAT); INSERT INTO fish_stock (fish_id, species, location, biomass) VALUES (1, 'tuna', 'tropical', 250.5), (2, 'salmon', 'arctic', 180.3), (3, 'cod', 'temperate', 120.0);
|
How many fish species are there in the 'fish_stock' table?
|
SELECT COUNT(DISTINCT species) FROM fish_stock;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indigenous_communities ( id INT PRIMARY KEY, name VARCHAR(255), population INT, region VARCHAR(255), language VARCHAR(255)); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (1, 'Community A', 500, 'Arctic', 'Language A'); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (2, 'Community B', 700, 'Arctic', 'Language B');
|
How many indigenous communities exist in the Arctic with a population greater than 500?
|
SELECT COUNT(*) FROM indigenous_communities WHERE region = 'Arctic' AND population > 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City_Budget (City VARCHAR(20), Department VARCHAR(20), Budget INT); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityE', 'Education', 4000000); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityE', 'Healthcare', 3000000); INSERT INTO City_Budget (City, Department, Budget) VALUES ('CityE', 'Infrastructure', 5000000);
|
What is the percentage of the budget allocated to education, healthcare, and infrastructure in CityE?
|
SELECT City, ROUND(SUM(CASE WHEN Department = 'Education' THEN Budget ELSE 0 END) / SUM(Budget) * 100, 2) AS 'Education Budget %', ROUND(SUM(CASE WHEN Department = 'Healthcare' THEN Budget ELSE 0 END) / SUM(Budget) * 100, 2) AS 'Healthcare Budget %', ROUND(SUM(CASE WHEN Department = 'Infrastructure' THEN Budget ELSE 0 END) / SUM(Budget) * 100, 2) AS 'Infrastructure Budget %' FROM City_Budget WHERE City = 'CityE' GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE skincare_purchases (purchase_id INT, product_id INT, purchase_quantity INT, is_halal_certified BOOLEAN, purchase_date DATE, country VARCHAR(20)); INSERT INTO skincare_purchases VALUES (1, 40, 5, true, '2021-07-22', 'India'); INSERT INTO skincare_purchases VALUES (2, 41, 2, true, '2021-07-22', 'India');
|
What is the most frequently purchased halal certified skincare product in India?
|
SELECT product_id, MAX(purchase_quantity) FROM skincare_purchases WHERE is_halal_certified = true AND country = 'India' GROUP BY product_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment_maintenance (request_id INT, equipment_type TEXT, country TEXT, maintenance_date DATE); INSERT INTO military_equipment_maintenance (request_id, equipment_type, country, maintenance_date) VALUES (1, 'M1 Abrams', 'Canada', '2022-02-14');
|
List the number of military equipment maintenance requests in Canada, in ascending order.
|
SELECT COUNT(*) FROM military_equipment_maintenance WHERE country = 'Canada' ORDER BY COUNT(*) ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Missions(mission_name VARCHAR(30), duration INT, astronaut_id INT); CREATE TABLE Astronauts(astronaut_id INT, astronaut_name VARCHAR(30)); INSERT INTO Space_Missions(mission_name, duration, astronaut_id) VALUES ('Apollo 11', 240, 1), ('Apollo 11', 240, 2), ('Ares 1', 315, 3), ('Ares 1', 315, 4), ('Gemini 12', 198, 5), ('Gemini 12', 198, 6); INSERT INTO Astronauts(astronaut_id, astronaut_name) VALUES (1, 'Neil Armstrong'), (2, 'Buzz Aldrin'), (3, 'John Williams'), (4, 'Mary Jackson'), (5, 'Ellen Johnson'), (6, 'Mark Robinson');
|
List the names of astronauts who participated in missions with duration greater than 300 days
|
SELECT Astronauts.astronaut_name FROM Space_Missions INNER JOIN Astronauts ON Space_Missions.astronaut_id = Astronauts.astronaut_id WHERE Space_Missions.duration > 300;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(255)); INSERT INTO Customers (CustomerID, Name) VALUES (1, 'John Doe'); INSERT INTO Customers (CustomerID, Name) VALUES (2, 'Jane Doe'); CREATE TABLE Loans (LoanID INT, CustomerID INT, Date DATE); INSERT INTO Loans (LoanID, CustomerID, Date) VALUES (1, 1, '2022-05-01'); INSERT INTO Loans (LoanID, CustomerID, Date) VALUES (2, 1, '2022-04-01'); INSERT INTO Loans (LoanID, CustomerID, Date) VALUES (3, 2, '2022-05-01'); CREATE TABLE Workshops (WorkshopID INT, CustomerID INT, Date DATE); INSERT INTO Workshops (WorkshopID, CustomerID, Date) VALUES (1, 1, '2022-06-01');
|
List all the customers who have taken out a loan in the last month and have a financial wellbeing workshop coming up in the next month
|
SELECT L.CustomerID, C.Name FROM Loans L INNER JOIN Customers C ON L.CustomerID = C.CustomerID WHERE L.Date >= DATEADD(month, -1, GETDATE()) AND C.CustomerID IN (SELECT W.CustomerID FROM Workshops W WHERE W.Date >= DATEADD(month, 1, GETDATE()));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists satellite_analysis (id INT, location VARCHAR(255), irrigated_area INT, image_date DATETIME); INSERT INTO satellite_analysis (id, location, irrigated_area, image_date) VALUES (1, 'Brazil', 50000, '2022-01-01 00:00:00'), (2, 'Argentina', 40000, '2022-01-01 00:00:00');
|
What is the total irrigated area in South America for the past year from satellite imagery analysis?
|
SELECT SUM(irrigated_area) FROM satellite_analysis WHERE location LIKE 'South%' AND image_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Female', 'HR'), (2, 'Male', 'IT'), (3, 'Female', 'HR'), (4, 'Male', 'IT'), (5, 'Female', 'Engineering'), (6, 'Male', 'Engineering');
|
What is the ratio of male to female employees in the Engineering department?
|
SELECT COUNT(*) * 1.0 / SUM(CASE WHEN Gender = 'Female' THEN 1 ELSE 0 END) FROM Employees WHERE Department = 'Engineering';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE beauty_ingredients (product_id INT, country VARCHAR(255), transparency_score INT); CREATE TABLE products (product_id INT, product_name VARCHAR(255)); INSERT INTO beauty_ingredients (product_id, country, transparency_score) VALUES (1, 'Mexico', 60), (2, 'Brazil', 70), (3, 'Argentina', 80); INSERT INTO products (product_id, product_name) VALUES (1, 'Lipstick'), (2, 'Eyeshadow'), (3, 'Blush');
|
Which countries have the lowest transparency score in beauty product ingredient disclosure?
|
SELECT country, AVG(transparency_score) AS avg_transparency_score FROM beauty_ingredients INNER JOIN products ON beauty_ingredients.product_id = products.product_id GROUP BY country ORDER BY avg_transparency_score ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species (species_name VARCHAR(50), ocean_name VARCHAR(50)); INSERT INTO Species (species_name, ocean_name) VALUES ('Species A', 'Arctic Ocean'), ('Species B', 'Mediterranean Sea');
|
How many marine species have been discovered in the Arctic Ocean and the Mediterranean Sea?
|
SELECT COUNT(DISTINCT species_name) FROM Species WHERE ocean_name IN ('Arctic Ocean', 'Mediterranean Sea');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_floor_mapping (name VARCHAR(255), location VARCHAR(255), min_depth FLOAT); INSERT INTO ocean_floor_mapping (name, location, min_depth) VALUES ('Puerto Rico Trench', 'Atlantic Ocean', 8605.0);
|
What is the minimum depth of the Puerto Rico Trench?
|
SELECT min_depth FROM ocean_floor_mapping WHERE name = 'Puerto Rico Trench';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, country VARCHAR(50), stream_count INT); INSERT INTO users (id, country, stream_count) VALUES (1, 'USA', 100), (2, 'Canada', 120), (3, 'USA', 150), (4, 'Mexico', 80), (5, 'Brazil', 200);
|
List the top 3 countries with the highest stream counts, along with their total stream counts.
|
SELECT country, SUM(stream_count) AS total_streams, ROW_NUMBER() OVER(ORDER BY SUM(stream_count) DESC) AS rank FROM users GROUP BY country ORDER BY rank ASC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE environmental_impact (resource_type VARCHAR(50), year INT, quantity INT);
|
What is the total quantity of resources depleted for each resource type, for the year 2022, in the 'environmental_impact' table?
|
SELECT resource_type, SUM(quantity) FROM environmental_impact WHERE year = 2022 GROUP BY resource_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_inspections (id INT PRIMARY KEY, location VARCHAR(255), inspection_date DATE); INSERT INTO safety_inspections (id, location, inspection_date) VALUES ('Lab A', '2022-01-01'); INSERT INTO safety_inspections (id, location, inspection_date) VALUES ('Lab B', '2022-02-01');
|
Which locations have had the most safety inspections in the past 2 years?
|
SELECT location, COUNT(*) as num_inspections, RANK() OVER(ORDER BY COUNT(*) DESC) as inspection_rank FROM safety_inspections WHERE inspection_date >= DATEADD(year, -2, GETDATE()) GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id int, product_name varchar(255), manufacturer_id int, CO2_emissions float); INSERT INTO products (product_id, product_name, manufacturer_id, CO2_emissions) VALUES (1, 'Product A', 1, 100), (2, 'Product B', 1, 150), (3, 'Product C', 2, 75); CREATE TABLE manufacturers (manufacturer_id int, manufacturer_name varchar(255)); INSERT INTO manufacturers (manufacturer_id, manufacturer_name) VALUES (1, 'Manufacturer X'), (2, 'Manufacturer Y');
|
What is the total CO2 emissions of products from a specific manufacturer?
|
SELECT SUM(CO2_emissions) FROM products WHERE manufacturer_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation_southeast_asia (country VARCHAR(50), project VARCHAR(50)); INSERT INTO climate_mitigation_southeast_asia (country, project) VALUES ('Indonesia', 'Forest Conservation Project'), ('Thailand', 'Energy Efficiency Project'), ('Malaysia', 'Renewable Energy Project'), ('Vietnam', 'Sustainable Agriculture Project');
|
Identify the top 2 countries with the highest number of climate mitigation projects in Southeast Asia.
|
SELECT country, COUNT(project) AS project_count FROM climate_mitigation_southeast_asia WHERE country IN ('Indonesia', 'Thailand', 'Malaysia', 'Vietnam', 'Philippines') GROUP BY country ORDER BY project_count DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biotech_startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO biotech_startups (id, name, location, funding) VALUES (1, 'Startup A', 'Africa', 8000000); INSERT INTO biotech_startups (id, name, location, funding) VALUES (2, 'Startup B', 'Africa', 10000000);
|
Update the funding amount for 'Startup A' to 10000000.
|
UPDATE biotech_startups SET funding = 10000000 WHERE name = 'Startup A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(50), cuisine VARCHAR(50), revenue INT); INSERT INTO restaurants VALUES (1, 'Asian Fusion', 'Asian', 5000), (2, 'Tuscan Bistro', 'Italian', 7000), (3, 'Baja Coast', 'Mexican', 4000);
|
Which restaurant categories have an average revenue over $5000?
|
SELECT cuisine, AVG(revenue) FROM restaurants GROUP BY cuisine HAVING AVG(revenue) > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Outcomes (Id INT, ProgramId INT, Outcome VARCHAR(50), OutcomeDate DATE); INSERT INTO Outcomes (Id, ProgramId, Outcome, OutcomeDate) VALUES (1, 1, 'Graduated', '2021-01-01'), (2, 2, 'Fed 50 people', '2021-01-02'), (3, 1, 'Graduated', '2021-01-02'), (4, 2, 'Fed 75 people', '2021-01-03');
|
Rank outcomes by outcome type
|
SELECT ProgramId, Outcome, COUNT(*) AS OutcomeCount, RANK() OVER(PARTITION BY ProgramId ORDER BY COUNT(*) DESC) AS OutcomeRank FROM Outcomes GROUP BY ProgramId, Outcome;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Tech_Accessibility (continent VARCHAR(255), budget INT); INSERT INTO Tech_Accessibility (continent, budget) VALUES ('Asia', 2500000), ('Africa', 1800000), ('South America', 1200000), ('Europe', 900000), ('Oceania', 700000);
|
What is the total budget allocated for technology accessibility programs in each continent?
|
SELECT continent, SUM(budget) as total_budget FROM Tech_Accessibility GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE voting (id INT, county VARCHAR(50), registration_date DATE, voter_count INT); INSERT INTO voting (id, county, registration_date, voter_count) VALUES (1, 'Los Angeles', '2022-01-01', 2000000), (2, 'New York', '2022-01-01', 1500000), (3, 'Harris', '2022-01-01', 1200000);
|
What is the total number of citizens registered to vote in each county in the 'voting' table?
|
SELECT county, SUM(voter_count) as total_voters FROM voting GROUP BY county;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturer_chemicals (manufacturer_id INT, manufacturer_name VARCHAR(50), chemical_type VARCHAR(50)); INSERT INTO manufacturer_chemicals (manufacturer_id, manufacturer_name, chemical_type) VALUES (1, 'AusChem', 'Acid'), (1, 'AusChem', 'Alkali'), (2, 'British Biotech', 'Solvent'), (2, 'British Biotech', 'Solute'), (3, 'ChemCorp', 'Acid'), (3, 'ChemCorp', 'Alkali'), (3, 'ChemCorp', 'Solvent');
|
Find the number of unique chemical types produced by each manufacturer, ordered from most to least diverse
|
SELECT manufacturer_id, manufacturer_name, COUNT(DISTINCT chemical_type) as unique_chemical_types FROM manufacturer_chemicals GROUP BY manufacturer_id, manufacturer_name ORDER BY unique_chemical_types DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CityTransport (city VARCHAR(30), users INT, year INT); INSERT INTO CityTransport (city, users, year) VALUES ('New York', 1000000, 2020), ('London', 1200000, 2020), ('Paris', 1100000, 2020);
|
What is the total number of public transportation users in New York, London, and Paris in 2020?
|
SELECT SUM(users) FROM CityTransport WHERE city IN ('New York', 'London', 'Paris') AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE route_segments (route_id INT, segment_id INT, start_station VARCHAR(255), end_station VARCHAR(255), fare FLOAT);
|
What is the minimum fare for each route segment in the 'route_segments' table?
|
SELECT route_id, segment_id, MIN(fare) as min_fare FROM route_segments GROUP BY route_id, segment_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier_ethics (supplier_id INT, name TEXT, sustainability_score INT, compliance_score INT);
|
Insert new records for two suppliers that provide sustainable materials and comply with fair labor practices.
|
INSERT INTO supplier_ethics (supplier_id, name, sustainability_score, compliance_score) VALUES (6, 'Supplier E', 85, 90), (7, 'Supplier F', 95, 95);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_employment (state VARCHAR(255), employed INT, unemployed INT, total_veterans INT); INSERT INTO veteran_employment (state, employed, unemployed, total_veterans) VALUES ('California', 50000, 3000, 55000), ('New York', 45000, 4000, 50000);
|
Show veteran employment statistics for the state of 'California'
|
SELECT employed, unemployed, total_veterans FROM veteran_employment WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy_projects (project_name TEXT, location TEXT, funding_year INTEGER); INSERT INTO renewable_energy_projects (project_name, location, funding_year) VALUES ('Solar Farm A', 'California', 2020), ('Wind Farm B', 'Texas', 2019), ('Hydro Plant C', 'Oregon', 2020);
|
What are the names and locations of all renewable energy projects that received funding in 2020?
|
SELECT project_name, location FROM renewable_energy_projects WHERE funding_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE electric_vehicles (model VARCHAR(30), autonomous BOOLEAN, manufacture_year INT); INSERT INTO electric_vehicles VALUES ('Tesla Model S', true, 2012);
|
List all electric vehicle models with autonomous capabilities in California, ordered by the year they were first manufactured.
|
SELECT model FROM electric_vehicles WHERE autonomous = true AND state = 'California' ORDER BY manufacture_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Streams (country TEXT, genre TEXT); INSERT INTO Streams (country, genre) VALUES ('USA', 'Pop'), ('USA', 'Rock'), ('Brazil', 'Samba'), ('France', 'Jazz'), ('Japan', 'Pop'), ('Kenya', 'Reggae'), ('Australia', 'Pop');
|
Identify the unique genres of music that have been streamed in at least one country in each continent (North America, South America, Europe, Asia, Africa, and Australia).
|
SELECT genre FROM Streams WHERE country IN (SELECT DISTINCT country FROM (SELECT 'North America' as continent UNION ALL SELECT 'South America' UNION ALL SELECT 'Europe' UNION ALL SELECT 'Asia' UNION ALL SELECT 'Africa' UNION ALL SELECT 'Australia') as Continents) GROUP BY genre HAVING COUNT(DISTINCT country) >= 6;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, industry TEXT, funding_source TEXT, funding_date DATE); INSERT INTO startups (id, name, industry, funding_source, funding_date) VALUES (1, 'BiotecHive', 'Biotech', 'VC', '2019-04-01');
|
List all biotech startups that received funding from VCs in the US after 2018?
|
SELECT name FROM startups WHERE industry = 'Biotech' AND funding_source = 'VC' AND funding_date > '2018-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Citizens (CitizenID INT, FirstName TEXT, LastName TEXT, District TEXT, ParticipatedInPublicHearings INT); INSERT INTO Citizens (CitizenID, FirstName, LastName, District, ParticipatedInPublicHearings) VALUES (1, 'John', 'Doe', 'District1', 1), (2, 'Jane', 'Doe', 'District2', 1), (3, 'Bob', 'Smith', 'District1', 1);
|
Calculate the total number of citizens who have participated in public hearings in each district
|
SELECT District, SUM(ParticipatedInPublicHearings) FROM Citizens GROUP BY District;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SustainableCosts (ProjectID int, State varchar(25), Sustainable bit, Cost decimal(10,2)); INSERT INTO SustainableCosts (ProjectID, State, Sustainable, Cost) VALUES (1, 'WA', 1, 100000.00), (2, 'WA', 0, 200000.00), (4, 'WA', 1, 125000.00);
|
What is the average cost of sustainable building projects in WA?
|
SELECT State, AVG(Cost) AS AvgCost FROM SustainableCosts WHERE State = 'WA' AND Sustainable = 1 GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels(id INT, name VARCHAR(100), region VARCHAR(50));CREATE TABLE fuel_consumption(id INT, vessel_id INT, consumption FLOAT, consumption_date DATE);
|
What is the total fuel consumption by vessels in the Caribbean in Q3 2020?
|
SELECT SUM(consumption) FROM fuel_consumption fc JOIN vessels v ON fc.vessel_id = v.id WHERE v.region = 'Caribbean' AND consumption_date BETWEEN '2020-07-01' AND '2020-09-30';
|
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.