context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE employees (id INT, salary FLOAT, organization_type VARCHAR(255), location VARCHAR(255)); INSERT INTO employees (id, salary, organization_type, location) VALUES (1, 70000.00, 'social good', 'Africa'), (2, 80000.00, 'tech company', 'Europe'), (3, 60000.00, 'social good', 'Asia'), (4, 90000.00, 'tech company', 'North America'), (5, 85000.00, 'social good', 'Africa');
What is the minimum salary of employees working in technology for social good organizations in Africa?
SELECT MIN(salary) FROM employees WHERE organization_type = 'social good' AND location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID INT, Name VARCHAR(100), Grade INT); CREATE VIEW TopStudents AS SELECT Name, Grade FROM Students WHERE Grade >= 12;
Select 'Name' from 'TopStudents' view
SELECT Name FROM TopStudents;
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (id INT, name VARCHAR(255), category VARCHAR(255), co2_emissions FLOAT, region VARCHAR(255));
What is the maximum CO2 emission level for each chemical category, for chemical manufacturing in Europe?
SELECT category, MAX(co2_emissions) as max_emissions FROM chemicals WHERE region = 'Europe' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_database (id INT, name VARCHAR(50), type VARCHAR(50), orbit_type VARCHAR(50), country VARCHAR(50), launch_date DATE);
Show the number of satellites in the satellite_database table, grouped by their country, and order by the count in ascending order, only showing the bottom 5 countries
SELECT country, COUNT(*) as satellite_count FROM satellite_database GROUP BY country ORDER BY satellite_count ASC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_lifetimes(id INT, name VARCHAR(255), launch_date DATE, launch_site VARCHAR(255), orbit VARCHAR(255), decommission_date DATE); INSERT INTO satellite_lifetimes VALUES (1, 'Intelsat 507', '1983-03-16', 'Cape Canaveral', 'GEO', '1997-05-22'); INSERT INTO satellite_lifetimes VALUES (2, 'Intelsat 603', '1991-03-05', 'Cape Canaveral', 'GEO', '2002-06-14'); INSERT INTO satellite_lifetimes VALUES (3, 'Intelsat 708', '1995-04-25', 'Baikonur Cosmodrome', 'GEO', '2011-02-02');
What is the average lifespan of satellites in Geostationary Orbit (GEO)?
SELECT AVG(DATEDIFF(decommission_date, launch_date)) FROM satellite_lifetimes WHERE orbit = 'GEO';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ratings (hotel_id INT, sustainability_rating FLOAT); INSERT INTO hotel_ratings (hotel_id, sustainability_rating) VALUES (1, 4.2), (2, 4.5), (3, 4.7), (4, 4.3);
What is the maximum sustainability score for hotels in each city?
SELECT hi.city, MAX(st.sustainability_score) FROM sustainable_tourism st INNER JOIN hotel_info hi ON st.hotel_id = hi.hotel_id GROUP BY hi.city;
gretelai_synthetic_text_to_sql
CREATE TABLE appliances (id INT, country VARCHAR(255), name VARCHAR(255), energy_efficiency_rating FLOAT); INSERT INTO appliances (id, country, name, energy_efficiency_rating) VALUES (1, 'Japan', 'Appliance A', 3.5), (2, 'Japan', 'Appliance B', 4.2);
What is the maximum energy efficiency rating for appliances in Japan?
SELECT MAX(energy_efficiency_rating) FROM appliances WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE microfinance_loans (region VARCHAR(50), loan_count INT); INSERT INTO microfinance_loans (region, loan_count) VALUES ('Region 1', 300), ('Region 2', 350), ('Region 3', 400);
What is the number of microfinance loans disbursed for agricultural activities in each region?
SELECT region, loan_count FROM microfinance_loans;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name TEXT, location TEXT, installed_capacity FLOAT); INSERT INTO renewable_energy (id, project_name, location, installed_capacity) VALUES (1, 'Solar Farm 1', 'Spain', 20.5), (2, 'Wind Farm 2', 'Germany', 60.3), (3, 'Solar Farm 2', 'Australia', 30.7);
What is the maximum installed capacity for a solar project in the 'renewable_energy' table?
SELECT MAX(installed_capacity) FROM renewable_energy WHERE project_name LIKE '%solar%';
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, team_id INT, num_fans INT);
What is the maximum number of fans for each team in the 'events' table?
SELECT team_id, MAX(num_fans) FROM events GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE hydro_plants (id INT, name TEXT, location TEXT, country TEXT, capacity INT, online_date DATE); INSERT INTO hydro_plants (id, name, location, country, capacity, online_date) VALUES (1, 'Grand Coulee Dam', 'Washington, USA', 'USA', 6809, '1942-01-01'), (2, 'Itaipu Dam', 'Parana, Brazil', 'Brazil', 14000, '1984-09-05'), (3, 'Three Gorges Dam', 'Hubei, China', 'China', 22500, '2003-07-04');
Identify the oldest hydroelectric power plant in each country.
SELECT location, name FROM hydro_plants WHERE online_date = (SELECT MIN(online_date) FROM hydro_plants AS h2 WHERE h2.country = hydro_plants.country) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (restaurant VARCHAR(255), item VARCHAR(255), veg BOOLEAN); INSERT INTO menus (restaurant, item, veg) VALUES ('Green Garden', 'salad', 1), ('Green Garden', 'beef burger', 0);
How many vegetarian options exist on the menu at 'Green Garden'?
SELECT COUNT(*) FROM menus WHERE restaurant = 'Green Garden' AND veg = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO farmers (id, name, age, location) VALUES (1, 'Jane Smith', 40, 'Chicago'); INSERT INTO farmers (id, name, age, location) VALUES (2, 'Joe Johnson', 50, 'New York'); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT, farmer_id INT, PRIMARY KEY (id), FOREIGN KEY (farmer_id) REFERENCES farmers(id)); INSERT INTO crops (id, name, yield, farmer_id) VALUES (1, 'Corn', 200, 1); INSERT INTO crops (id, name, yield, farmer_id) VALUES (2, 'Wheat', 150, 2);
What is the total yield of crops for farmers in urban areas?
SELECT SUM(crops.yield) as total_yield FROM crops INNER JOIN farmers ON crops.farmer_id = farmers.id WHERE farmers.location = 'New York' OR farmers.location = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name VARCHAR(255), budget INT);
Delete all records in the 'community_development' table where the budget is greater than or equal to 100000.
DELETE FROM community_development WHERE budget >= 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, country VARCHAR(50), treatment VARCHAR(50)); INSERT INTO patients (patient_id, age, country, treatment) VALUES (1, 35, 'Canada', 'CBT'), (2, 42, 'Canada', 'Pharmacotherapy');
What is the average age of patients who have received cognitive behavioral therapy (CBT) treatment in Canada?
SELECT AVG(age) FROM patients WHERE country = 'Canada' AND treatment = 'CBT';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_tax (id INT PRIMARY KEY, region VARCHAR(50), tax_per_ton FLOAT); INSERT INTO carbon_tax (id, region, tax_per_ton) VALUES (1, 'South Africa', 5.0), (2, 'Morocco', 4.5), (3, 'Egypt', 6.0);
What is the maximum carbon tax per ton in African countries?
SELECT region, MAX(tax_per_ton) FROM carbon_tax WHERE region IN ('South Africa', 'Morocco', 'Egypt');
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT, date DATE); INSERT INTO student_mental_health (student_id, school_id, mental_health_score, date) VALUES (1, 101, 75, '2022-01-01');
What is the average mental health score of students per school in the last month?
SELECT school_id, AVG(mental_health_score) as avg_mental_health_score FROM student_mental_health WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) GROUP BY school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales(equipment_id INT, manufacturer VARCHAR(255), purchaser VARCHAR(255), sale_date DATE, quantity INT);INSERT INTO Military_Equipment_Sales(equipment_id, manufacturer, purchaser, sale_date, quantity) VALUES (1, 'Northrop Grumman', 'Saudi Arabia', '2019-11-01', 15), (2, 'Northrop Grumman', 'UAE', '2019-12-15', 20);
What is the minimum quantity of military equipment sold by Northrop Grumman to Middle Eastern countries in Q4 2019?
SELECT MIN(quantity) FROM Military_Equipment_Sales WHERE manufacturer = 'Northrop Grumman' AND purchaser LIKE 'Middle East%' AND sale_date BETWEEN '2019-10-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (incident_id INT, agency TEXT, region TEXT, incident_date DATE); INSERT INTO cybersecurity_incidents (incident_id, agency, region, incident_date) VALUES (1, 'Ministry of Defense, Singapore', 'Asia-Pacific', '2022-01-01');
List the number of cybersecurity incidents reported by government agencies in the Asia-Pacific region in the last 12 months, in ascending order.
SELECT COUNT(*) FROM cybersecurity_incidents WHERE region = 'Asia-Pacific' AND incident_date >= DATEADD(year, -1, CURRENT_DATE) ORDER BY COUNT(*) ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Meals (MealID INT, MealName VARCHAR(50), Region VARCHAR(50), Calories INT); INSERT INTO Meals (MealID, MealName, Region, Calories) VALUES (1, 'Spaghetti Bolognese', 'Europe', 650), (2, 'Chicken Tikka Masala', 'Asia', 850);
What is the total calorie count for meals served in each region?
SELECT Region, SUM(Calories) as TotalCalories FROM Meals GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE movement (movement_id INT, warehouse_id VARCHAR(5), arrival_date DATE, departure_date DATE); INSERT INTO movement (movement_id, warehouse_id, arrival_date, departure_date) VALUES (1, 'W001', '2021-01-01', '2021-01-03'), (2, 'W002', '2021-02-10', '2021-02-12');
What is the earliest arrival date for each warehouse and what is the latest departure date for each warehouse?
SELECT w.name, MIN(m.arrival_date) AS earliest_arrival, MAX(m.departure_date) AS latest_departure FROM movement m INNER JOIN warehouse w ON m.warehouse_id = w.warehouse_id GROUP BY w.name;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255), city VARCHAR(100)); INSERT INTO teams (team_id, team_name, city) VALUES (1, 'Golden State Warriors', 'San Francisco'), (2, 'Los Angeles Lakers', 'Los Angeles'); CREATE TABLE game_attendance (game_id INT, team_id INT, num_fans INT); INSERT INTO game_attendance (game_id, team_id, num_fans) VALUES (1, 1, 15000), (2, 1, 20000), (3, 2, 10000);
What is the total number of fans who attended games in each city?
SELECT t.city, SUM(ga.num_fans) as total_fans_attended FROM teams t INNER JOIN game_attendance ga ON t.team_id = ga.team_id GROUP BY t.city;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment VARCHAR(255), sale_value FLOAT, sale_date DATE); INSERT INTO MilitaryEquipmentSales (seller, buyer, equipment, sale_value, sale_date) VALUES ('BAE Systems', 'India', 'Hawk Jet Trainer', 18000000, '2021-08-15');
Delete all military equipment sales records from the table that do not have a sale value greater than 50,000,000.
DELETE FROM MilitaryEquipmentSales WHERE sale_value < 50000000;
gretelai_synthetic_text_to_sql
CREATE TABLE utilities (id INT, company_name VARCHAR(50), carbon_offset_tonnes INT, year INT); INSERT INTO utilities (id, company_name, carbon_offset_tonnes, year) VALUES (1, 'Green Power Inc.', 120000, 2020), (2, 'EcoEnergy Ltd.', 150000, 2019), (3, 'Clean Energy Co.', 180000, 2020), (4, 'Renewable Resources Inc.', 90000, 2020);
What is the maximum carbon offsetting achieved by any utility company in 2020?
SELECT MAX(carbon_offset_tonnes) FROM utilities WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INTEGER, title TEXT, artist_name TEXT, artist_origin TEXT, price FLOAT); INSERT INTO Artworks (artwork_id, title, artist_name, artist_origin, price) VALUES (1, 'Artwork 1', 'Hiroshi', 'Japan', 10000.0), (2, 'Artwork 2', 'Mei', 'China', 12000.0), (3, 'Artwork 3', 'Aamir', 'Pakistan', 8000.0);
What is the most expensive artwork created by an artist from 'Asia'?
SELECT title, price FROM Artworks WHERE artist_origin = 'Asia' AND price = (SELECT MAX(price) FROM Artworks WHERE artist_origin = 'Asia')
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, group_name VARCHAR(255), indicator VARCHAR(255)); INSERT INTO threat_intelligence (id, group_name, indicator) VALUES (1, 'APT28', '192.168.0.1'), (2, 'APT28', 'example.com');
How many threat intelligence indicators are associated with the 'APT28' group?
SELECT COUNT(*) FROM threat_intelligence WHERE group_name = 'APT28';
gretelai_synthetic_text_to_sql
CREATE TABLE REVENUE(city VARCHAR(20), revenue DECIMAL(5,2)); INSERT INTO REVENUE(city, revenue) VALUES('Berlin', 1500.00), ('Berlin', 1200.00), ('Rome', 1800.00), ('Rome', 2000.00);
What is the total revenue of sustainable fashion sales in Berlin and Rome?
SELECT SUM(revenue) FROM REVENUE WHERE city IN ('Berlin', 'Rome') AND revenue > 1000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (name VARCHAR(255), state VARCHAR(255), population DECIMAL(10,2), recycling_rate DECIMAL(5,2)); INSERT INTO cities (name, state, population, recycling_rate) VALUES ('Los Angeles', 'California', 3971883, 76.9), ('New York', 'New York', 8550405, 21.1), ('Chicago', 'Illinois', 2693976, 9.5);
List all cities with a population over 500,000 that have a recycling rate above the national average.
SELECT name FROM cities WHERE population > 500000 AND recycling_rate > (SELECT AVG(recycling_rate) FROM cities);
gretelai_synthetic_text_to_sql
CREATE TABLE utica_production (well text, date text, production real); INSERT INTO utica_production VALUES ('Well1', '2021-01-01', 1000), ('Well1', '2021-01-02', 1200), ('Well2', '2021-01-01', 2100), ('Well2', '2021-01-02', 1300);
List all the wells in the 'Utica' shale play that produced more than 1500 barrels in a day.
SELECT well FROM utica_production WHERE production > 1500;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT);CREATE TABLE fares (fare_id INT, route_id INT, fare_amount DECIMAL, fare_collection_date DATE); INSERT INTO routes (route_id, route_name) VALUES (1, 'Route A'), (2, 'Route B'); INSERT INTO fares (fare_id, route_id, fare_amount, fare_collection_date) VALUES (1, 1, 5.00, '2022-01-01'), (2, 1, 5.00, '2022-01-01'), (3, 2, 3.50, '2022-01-01');
What is the total fare collected from passengers for each route on January 1, 2022?
SELECT r.route_name, SUM(f.fare_amount) as total_fare FROM routes r JOIN fares f ON r.route_id = f.route_id WHERE f.fare_collection_date = '2022-01-01' GROUP BY r.route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_statements (statement_length INTEGER); INSERT INTO artist_statements (statement_length) VALUES (50), (100), (150);
What is the sum of all statement lengths in the database?
SELECT SUM(statement_length) FROM artist_statements;
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, country VARCHAR(50), num_employees INT, has_lrv BOOLEAN); INSERT INTO workplaces (id, country, num_employees, has_lrv) VALUES (1, 'Germany', 200, true), (2, 'Germany', 150, false), (3, 'Germany', 250, true);
What is the minimum number of employees in a workplace with labor rights violations in Germany?
SELECT MIN(num_employees) FROM workplaces WHERE country = 'Germany' AND has_lrv = true;
gretelai_synthetic_text_to_sql
CREATE TABLE advertising (campaign_id INT, spend DECIMAL(10,2), impressions INT, start_date DATE, end_date DATE);
Calculate the total ad spend for the advertising table for the last month.
SELECT SUM(spend) as total_spend FROM advertising WHERE start_date <= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND end_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_name TEXT, company TEXT, continent TEXT, sales_amount INT, sale_date DATE); INSERT INTO sales (drug_name, company, continent, sales_amount, sale_date) VALUES ('Paracetamol', 'Medichem', 'Europe', 4000, '2021-01-01');
Identify the drug with the highest sales amount in 'Europe' for 'Medichem' in 2021.
SELECT drug_name, MAX(sales_amount) FROM sales WHERE company = 'Medichem' AND continent = 'Europe' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_courts (id INT, court_name VARCHAR(255), state VARCHAR(255), year INT, cases_heard INT); INSERT INTO community_courts (id, court_name, state, year, cases_heard) VALUES (1, 'East Los Angeles Community Court', 'California', 2018, 850), (2, 'Midtown Community Court', 'New York', 2019, 905), (3, 'Red Hook Community Justice Center', 'New York', 2017, 760);
What is the total number of cases heard by community courts in New York and the corresponding year?
SELECT community_courts.year, SUM(community_courts.cases_heard) AS total_cases_heard FROM community_courts WHERE community_courts.state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_certifications (product_id INT, brand TEXT, is_cruelty_free BOOLEAN, is_vegan BOOLEAN, country TEXT);
What are the top 3 cosmetic brands in the Australian market with the most products certified as cruelty-free and vegan?
SELECT brand, COUNT(*) as num_certified_products FROM cosmetics_certifications WHERE is_cruelty_free = TRUE AND is_vegan = TRUE AND country = 'Australia' GROUP BY brand ORDER BY num_certified_products DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255), voter_turnout INT); INSERT INTO states (id, name, voter_turnout) VALUES (1, 'California', 70), (2, 'Texas', 60), (3, 'Minnesota', 80);
Which states in the United States have the highest voter turnout?
SELECT name FROM states WHERE voter_turnout = (SELECT MAX(voter_turnout) FROM states);
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR, region VARCHAR, financial_wellbeing_score INT); INSERT INTO clients (id, name, region, financial_wellbeing_score) VALUES (1, 'Ahmed', 'Southeast', 75), (2, 'Fatima', 'Northeast', 65), (3, 'Zainab', 'Southeast', 85), (4, 'Hassan', 'Midwest', 55);
What is the count of clients with a financial wellbeing score greater than 70, in the Southeast region?
SELECT COUNT(*) FROM clients WHERE region = 'Southeast' AND financial_wellbeing_score > 70;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (farm_id INT, name VARCHAR(50), location VARCHAR(50));
Delete the farm with ID 502
DELETE FROM farms WHERE farm_id = 502;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_traffic (id INTEGER, vessel_size INTEGER, year INTEGER, location TEXT); INSERT INTO vessel_traffic (id, vessel_size, year, location) VALUES (1, 150, 2020, 'Indian Ocean'), (2, 250, 2021, 'Indian Ocean'), (3, 350, 2020, 'Pacific Ocean');
What is the average size of vessels that entered the Indian Ocean in 2020?
SELECT AVG(vessel_size) FROM vessel_traffic WHERE year = 2020 AND location = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, program_id INT, volunteer_name VARCHAR(255), country VARCHAR(255), volunteer_start_date DATE, volunteer_end_date DATE); INSERT INTO volunteers (volunteer_id, program_id, volunteer_name, country, volunteer_start_date, volunteer_end_date) VALUES (1, 1, 'Volunteer1', 'Egypt', '2018-01-01', '2018-12-31'), (2, 2, 'Volunteer2', 'Egypt', '2018-01-01', '2018-06-30'), (3, 3, 'Volunteer3', 'Egypt', '2018-07-01', '2018-12-31');
What was the total number of volunteers who participated in community development programs in Egypt in 2018?
SELECT COUNT(*) FROM volunteers WHERE country = 'Egypt' AND YEAR(volunteer_start_date) = 2018 AND YEAR(volunteer_end_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, name TEXT, city TEXT, attendance INT); INSERT INTO Events (id, name, city, attendance) VALUES (1, 'Art Exhibition', 'New York', 500), (2, 'Theater Performance', 'Los Angeles', 300), (3, 'Music Concert', 'Chicago', 700);
Calculate total attendance at all events
SELECT SUM(attendance) FROM Events;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (id INT PRIMARY KEY, game_id INT, number_of_tickets INT, date DATE);
update the ticket sales records for a specific game
UPDATE ticket_sales SET number_of_tickets = 600 WHERE game_id = 123 AND date = '2022-05-01';
gretelai_synthetic_text_to_sql
CREATE TABLE agencies (id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(255));CREATE TABLE parks (id INT PRIMARY KEY, name VARCHAR(255), agency_id INT, FOREIGN KEY (agency_id) REFERENCES agencies(id)); INSERT INTO agencies (id, name, state) VALUES (1, 'California Department of Parks and Recreation', 'California'); INSERT INTO agencies (id, name, state) VALUES (2, 'National Park Service', 'California');
List all the parks and their respective agencies in the state of California from the 'parks_database'
SELECT parks.name as park_name, agencies.name as agency_name FROM parks INNER JOIN agencies ON parks.agency_id = agencies.id WHERE agencies.state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Shipment (id INT, source_country VARCHAR(255), destination_country VARCHAR(255), items_quantity INT, shipment_date DATE); INSERT INTO Shipment (id, source_country, destination_country, items_quantity, shipment_date) VALUES (1, 'Egypt', 'Nigeria', 100, '2021-06-01'), (2, 'Egypt', 'Nigeria', 200, '2021-05-01');
What are the total items shipped between Egypt and Nigeria, excluding items shipped in June 2021?
SELECT SUM(items_quantity) FROM Shipment WHERE (source_country = 'Egypt' AND destination_country = 'Nigeria') OR (source_country = 'Nigeria' AND destination_country = 'Egypt') AND shipment_date NOT BETWEEN '2021-06-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales (id INT PRIMARY KEY, drug_name VARCHAR(50), manufacturer VARCHAR(50), sales_qty INT, sales_amount DECIMAL(10,2), sale_year INT);
What are the top 5 manufacturers with the highest sales amounts in 2020?
SELECT manufacturer, SUM(sales_amount) as total_sales FROM drug_sales WHERE sale_year = 2020 GROUP BY manufacturer ORDER BY total_sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (mission_id INT, name VARCHAR(100), agency VARCHAR(100), launch_date DATE); INSERT INTO missions (mission_id, name, agency, launch_date) VALUES (1, 'Apollo 11', 'NASA', '1969-07-16'), (2, 'STS-1', 'NASA', '1981-04-12');
How many space missions has NASA conducted?
SELECT COUNT(*) FROM missions WHERE agency = 'NASA';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE biosensors.development_costs (id INT, company_name VARCHAR(50), country VARCHAR(50), development_cost DECIMAL(10,2));INSERT INTO biosensors.development_costs (id, company_name, country, development_cost) VALUES (1, 'CompanyA', 'UK', 5000000.00), (2, 'CompanyB', 'Canada', 3500000.00), (3, 'CompanyC', 'USA', 8000000.00);
What is the average biosensor technology development cost for companies in the UK?
SELECT AVG(development_cost) FROM biosensors.development_costs WHERE country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50));CREATE TABLE Paintings (PaintingID INT, PaintingName VARCHAR(50), ArtistID INT);CREATE TABLE Exhibitions (ExhibitionID INT, ExhibitionCountry VARCHAR(50), PaintingID INT); INSERT INTO Artists VALUES (1, 'Vincent Van Gogh'); INSERT INTO Paintings VALUES (1, 'Starry Night', 1); INSERT INTO Exhibitions VALUES (1, 'Germany', 1);
Which artist's paintings were exhibited the most in Germany?
SELECT ArtistName, COUNT(*) as ExhibitionCount FROM Artists a JOIN Paintings p ON a.ArtistID = p.ArtistID JOIN Exhibitions e ON p.PaintingID = e.PaintingID WHERE e.ExhibitionCountry = 'Germany' GROUP BY ArtistName ORDER BY ExhibitionCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Sourcing (id INT, material VARCHAR(20), country VARCHAR(20), quantity INT, year INT); INSERT INTO Sourcing (id, material, country, quantity, year) VALUES (1, 'Organic Cotton', 'Bangladesh', 4000, 2021), (2, 'Recycled Polyester', 'Vietnam', 3000, 2021), (3, 'Bamboo Fabric', 'Africa', 2000, 2023), (4, 'Bamboo Fabric', 'South America', 2500, 2023);
What is the total quantity of 'Bamboo Fabric' sourced in 'Africa' and 'South America' in 2023?
SELECT SUM(quantity) FROM Sourcing WHERE material = 'Bamboo Fabric' AND (country = 'Africa' OR country = 'South America') AND year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mine_name TEXT, location TEXT, material TEXT, quantity INT, date DATE); INSERT INTO mining_operations (id, mine_name, location, material, quantity, date) VALUES (6, 'Coal Haven', 'United States', 'coal', 7000, '2019-01-01');
Calculate the total amount of coal mined in the United States in 2019
SELECT SUM(quantity) FROM mining_operations WHERE material = 'coal' AND location = 'United States' AND date = '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_project_timelines (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO defense_project_timelines (id, project_name, start_date, end_date) VALUES (1, 'Project A', '2023-01-01', '2023-12-31'), (2, 'Project B', '2022-01-01', '2022-12-31'), (3, 'Project C', '2021-01-01', '2021-12-31');
What is the total number of defense project timelines in the year 2023?
SELECT COUNT(*) FROM defense_project_timelines WHERE YEAR(start_date) = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE product_sales (product VARCHAR(20), sales_count INT); INSERT INTO product_sales (product, sales_count) VALUES ('Software', 10), ('Hardware', 5), ('Consulting', 15);
Which products have a higher sales count than the average sales count?
SELECT product FROM product_sales WHERE sales_count > (SELECT AVG(sales_count) FROM product_sales);
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, language VARCHAR(10), cultural_competency_training VARCHAR(10)); INSERT INTO community_health_workers (worker_id, language, cultural_competency_training) VALUES (1, 'English', 'Yes'), (2, 'Spanish', 'No'), (3, 'French', 'Yes'), (4, 'English', 'Yes'), (5, 'Spanish', 'Yes');
What is the total number of community health workers trained in cultural competency by language spoken?
SELECT language, COUNT(*) FROM community_health_workers WHERE cultural_competency_training = 'Yes' GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT); INSERT INTO Volunteers (VolunteerID, Name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT); INSERT INTO VolunteerPrograms (VolunteerID, ProgramID) VALUES (1, 1), (2, 1), (3, 2);
How many volunteers have signed up for each program?
SELECT Programs.ProgramName, COUNT(VolunteerPrograms.VolunteerID) FROM VolunteerPrograms INNER JOIN Volunteers ON VolunteerPrograms.VolunteerID = Volunteers.VolunteerID INNER JOIN Programs ON VolunteerPrograms.ProgramID = Programs.ProgramID GROUP BY Programs.ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, state VARCHAR(255), num_employees INT); INSERT INTO mining_operations (id, state, num_employees) VALUES (1, 'California', 200), (2, 'Texas', 300), (3, 'New York', 100), (4, 'Florida', 400), (5, 'Illinois', 250), (6, 'Pennsylvania', 350);
What is the total number of employees in mining operations in each state of the USA?
SELECT state, SUM(num_employees) FROM mining_operations GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID int, Age int, Region varchar(10)); INSERT INTO Policyholders (PolicyholderID, Age, Region) VALUES (1, 35, 'West'); INSERT INTO Policyholders (PolicyholderID, Age, Region) VALUES (2, 45, 'East');
What is the average age of policyholders who have a car insurance policy in the 'West' region?
SELECT AVG(Age) FROM Policyholders WHERE Region = 'West';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, name TEXT); INSERT INTO volunteers (volunteer_id, name) VALUES (1, 'Aarav'), (2, 'Bella'), (3, 'Charlie'); CREATE TABLE cases (case_id INT, volunteer_id INT, date TEXT, resolved_date TEXT); INSERT INTO cases (case_id, volunteer_id, date, resolved_date) VALUES (1, 1, '2022-01-01', '2022-01-15'), (2, 1, '2022-02-01', '2022-02-28'), (3, 2, '2022-03-01', '2022-03-15'), (4, 3, '2022-04-01', '2022-04-30');
What is the number of cases resolved by each volunteer in each month?
SELECT volunteers.name, EXTRACT(MONTH FROM cases.date) as month, COUNT(cases.case_id) as cases_per_month FROM volunteers INNER JOIN cases ON volunteers.volunteer_id = cases.volunteer_id WHERE cases.date <= cases.resolved_date GROUP BY volunteers.name, month;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, state TEXT, policy_type TEXT, premium FLOAT); INSERT INTO policyholders (id, name, state, policy_type, premium) VALUES (1, 'John Doe', 'Texas', 'Auto', 1200.00), (2, 'Jane Smith', 'California', 'Home', 2500.00); CREATE TABLE claims (id INT, policyholder_id INT, claim_amount FLOAT, claim_date DATE); INSERT INTO claims (id, policyholder_id, claim_amount, claim_date) VALUES (1, 1, 800.00, '2021-01-01'), (2, 1, 300.00, '2021-02-01'), (3, 2, 1500.00, '2021-03-01');
What is the total claim amount for policyholders from Texas?
SELECT SUM(claims.claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE collective_bargaining (cb_id SERIAL PRIMARY KEY, union_id VARCHAR(5), topic TEXT, outcome TEXT, date DATE, wages TEXT);
Update the wages column in the collective_bargaining table to 'Hourly' for all records with a union_id of 002
UPDATE collective_bargaining SET wages = 'Hourly' WHERE union_id = '002';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_garment_production (id INT, country VARCHAR(50), water_usage INT); INSERT INTO water_usage_garment_production (id, country, water_usage) VALUES (1, 'China', 5000); INSERT INTO water_usage_garment_production (id, country, water_usage) VALUES (2, 'India', 4000); INSERT INTO water_usage_garment_production (id, country, water_usage) VALUES (3, 'Bangladesh', 3000); INSERT INTO water_usage_garment_production (id, country, water_usage) VALUES (4, 'Pakistan', 2000);
List the top 5 countries with the highest water usage in garment production.
SELECT country, water_usage FROM water_usage_garment_production ORDER BY water_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_services (hotel_id INT, hotel_name TEXT, country TEXT, revenue FLOAT, ai_concierge INT); INSERT INTO hotel_services (hotel_id, hotel_name, country, revenue, ai_concierge) VALUES (1, 'Hotel F', 'USA', 500000, 1), (2, 'Hotel G', 'Brazil', 600000, 1), (3, 'Hotel H', 'Mexico', 400000, 0), (4, 'Hotel I', 'Canada', 700000, 1), (5, 'Hotel J', 'USA', 800000, 0);
What is the total revenue generated by hotels in the Americas that have adopted AI concierge services in Q3 2022?
SELECT SUM(revenue) FROM hotel_services WHERE country IN ('USA', 'Canada', 'Brazil', 'Mexico') AND ai_concierge = 1 AND quarter = 3 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT, cargo_weight_capacity FLOAT);
What is the maximum cargo weight capacity for each vessel type?
SELECT type, MAX(cargo_weight_capacity) FROM vessels GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID int, EventDate date, Attendees int, Country varchar(50)); INSERT INTO Events (EventID, EventDate, Attendees, Country) VALUES (1, '2021-01-01', 100, 'Spain'), (2, '2021-02-01', 150, 'Spain'), (3, '2021-03-01', 250, 'Spain');
What is the number of events held in Spain that had an attendance of over 200 people?
SELECT COUNT(*) FROM Events WHERE Country = 'Spain' AND Attendees > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE alert_rules (id INT, rule_name VARCHAR(255)); INSERT INTO alert_rules (id, rule_name) VALUES (1, 'Unusual outbound traffic'), (2, 'Suspicious login'), (3, 'Suspicious user behavior'), (4, 'Malware detection'); CREATE TABLE alerts (id INT, rule_id INT, timestamp DATETIME); INSERT INTO alerts (id, rule_id, timestamp) VALUES (1, 1, '2022-05-01 12:34:56'), (2, 2, '2022-06-02 09:10:11'), (3, 3, '2022-07-03 17:22:33'), (4, 4, '2022-08-04 04:44:44');
How many times has the rule "Suspicious user behavior" been triggered in the last month?
SELECT COUNT(*) FROM alerts WHERE rule_id IN (SELECT id FROM alert_rules WHERE rule_name = 'Suspicious user behavior') AND timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(50), budget INT); INSERT INTO departments (id, name, budget) VALUES (1, 'Education', 15000000), (2, 'Transportation', 20000000); CREATE TABLE policies (id INT, department_id INT, title VARCHAR(50), evidence_based BOOLEAN); INSERT INTO policies (id, department_id, title, evidence_based) VALUES (1, 1, 'Safe Routes to School', true), (2, 2, 'Mass Transit Expansion', true);
What is the total number of evidence-based policies created by each department, having a budget greater than $10 million?
SELECT d.name, COUNT(p.id) as total_policies FROM departments d JOIN policies p ON d.id = p.department_id WHERE d.budget > 10000000 AND p.evidence_based = true GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE state_employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO state_employees (id, first_name, last_name, salary) VALUES (1, 'Mike', 'Johnson', 50000.00); INSERT INTO state_employees (id, first_name, last_name, salary) VALUES (2, 'Sara', 'Williams', 55000.00);
List the names and salaries of state employees with salaries above the average state employee salary in the 'state_employees' table?
SELECT first_name, last_name, salary FROM state_employees WHERE salary > (SELECT AVG(salary) FROM state_employees);
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, joined_date DATE);CREATE TABLE broadband_subscribers (subscriber_id INT, joined_date DATE);
Identify the overlap between customers who subscribed to both mobile and broadband services in the last year.
SELECT m.subscriber_id FROM mobile_subscribers m WHERE joined_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) INTERSECT SELECT b.subscriber_id FROM broadband_subscribers b WHERE joined_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE port_operations (id INT PRIMARY KEY, cargo_id INT, operation VARCHAR(20)); INSERT INTO port_operations (id, cargo_id, operation) VALUES (1, 101, 'loading'), (2, 102, 'unloading');
Delete all records from table port_operations with operation as 'unloading'
DELETE FROM port_operations WHERE operation = 'unloading';
gretelai_synthetic_text_to_sql
CREATE TABLE AgeGroups (AgeGroupID INT, AgeGroup VARCHAR(10)); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (1, '0-10'); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (2, '11-20'); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (3, '21-30'); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (4, '31-40'); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (5, '41-50'); CREATE TABLE Players (PlayerID INT, Age INT, VR INT); INSERT INTO Players (PlayerID, Age, VR) VALUES (1, 15, 1); INSERT INTO Players (PlayerID, Age, VR) VALUES (2, 25, 1); INSERT INTO Players (PlayerID, Age, VR) VALUES (3, 30, 0); INSERT INTO Players (PlayerID, Age, VR) VALUES (4, 40, 0); INSERT INTO Players (PlayerID, Age, VR) VALUES (5, 50, 1);
What is the distribution of players by age group and VR adoption?
SELECT AgeGroups.AgeGroup, AVG(Players.Age), SUM(Players.VR) FROM AgeGroups INNER JOIN Players ON Players.Age BETWEEN AgeGroups.AgeGroupID*10 AND AgeGroups.AgeGroupID*10+9 GROUP BY AgeGroups.AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation (accommodation_id INT, accommodation_name TEXT, disability_type TEXT); INSERT INTO accommodation (accommodation_id, accommodation_name, disability_type) VALUES (1, 'Wheelchair Ramp', 'Mobility'); INSERT INTO accommodation (accommodation_id, accommodation_name, disability_type) VALUES (2, 'Braille Materials', 'Visual Impairment');
Insert a new record for a disability accommodation named 'Hearing Loops' for 'Visual Impairment' type.
INSERT INTO accommodation (accommodation_name, disability_type) VALUES ('Hearing Loops', 'Visual Impairment');
gretelai_synthetic_text_to_sql
CREATE TABLE sectors (sid INT, sector_name VARCHAR(255)); CREATE TABLE criminal_incidents (iid INT, sid INT, incident_type VARCHAR(255));
How many criminal incidents were reported in each community policing sector?
SELECT s.sector_name, COUNT(i.iid) FROM sectors s INNER JOIN criminal_incidents i ON s.sid = i.sid GROUP BY s.sector_name;
gretelai_synthetic_text_to_sql
CREATE TABLE EvidenceBasedPolicy (id INT, project_name VARCHAR(50), country VARCHAR(50), start_date DATE, end_date DATE);
How many evidence-based policy making projects were completed in India since 2010?
SELECT COUNT(*) FROM EvidenceBasedPolicy WHERE country = 'India' AND start_date <= '2010-01-01' AND end_date >= '2010-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (well_name VARCHAR(50), location VARCHAR(50), oil_production NUMERIC(10,2), gas_production NUMERIC(10,2), production_date DATE); INSERT INTO production_data (well_name, location, oil_production, gas_production, production_date) VALUES ('Well P', 'North Sea', 1000, 400, '2023-04-01'), ('Well P', 'North Sea', 1050, 425, '2023-03-31'), ('Well P', 'North Sea', 1100, 450, '2023-02-28');
Calculate the percentage change in gas production for Well P in the North Sea between the current month and the previous month.
SELECT ((gas_production - LAG(gas_production, 1) OVER (PARTITION BY well_name ORDER BY production_date)) / LAG(gas_production, 1) OVER (PARTITION BY well_name ORDER BY production_date)) * 100 as percentage_change FROM production_data WHERE well_name = 'Well P' AND production_date IN (DATEADD(month, -1, '2023-04-01'), '2023-04-01');
gretelai_synthetic_text_to_sql
CREATE TABLE project (project_id INT, name VARCHAR(50), location VARCHAR(50), success_rate FLOAT); CREATE TABLE country (country_id INT, name VARCHAR(50), description TEXT); CREATE TABLE location (location_id INT, name VARCHAR(50), country_id INT);
What is the success rate of agricultural innovation projects in each country?
SELECT l.name, AVG(p.success_rate) FROM project p JOIN location l ON p.location = l.name JOIN country c ON l.country_id = c.country_id GROUP BY l.name;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_operations (id INT PRIMARY KEY, vessel_id INT, port_id INT, cargo_type VARCHAR(255), quantity INT, time_stamp DATETIME);
Delete a specific cargo handling operation from the "cargo_operations" table
DELETE FROM cargo_operations WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VoyageID INT, AvgSpeed DECIMAL(5,2));CREATE TABLE Voyages (VoyageID INT, Destination VARCHAR(50), TravelDate DATE); INSERT INTO Vessels VALUES (1, 101, 14.5), (2, 102, 16.2), (3, 103, 15.6); INSERT INTO Voyages VALUES (101, 'Port of Oakland', '2022-01-05'), (102, 'Port of Los Angeles', '2022-01-07'), (103, 'Port of Oakland', '2022-01-10');
What is the average speed of all vessels that traveled to the Port of Oakland in the past month?
SELECT AVG(AvgSpeed) FROM Vessels JOIN Voyages ON Vessels.VoyageID = Voyages.VoyageID WHERE Destination = 'Port of Oakland' AND TravelDate >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE InterpretationServices (service_id INT, hours_per_week INT, accommodation_type VARCHAR(255));
What is the minimum number of hours of sign language interpretation provided in a week?
SELECT MIN(hours_per_week) FROM InterpretationServices WHERE accommodation_type = 'Sign Language';
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(50), city VARCHAR(50)); CREATE TABLE VirtualTours (tour_id INT, hotel_id INT, tour_name VARCHAR(50)); INSERT INTO Hotels (hotel_id, hotel_name, city) VALUES (1, 'Hotel1', 'CityA'), (2, 'Hotel2', 'CityB'); INSERT INTO VirtualTours (tour_id, hotel_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2);
Which cities have the most virtual tours in their hotels?
SELECT h.city, COUNT(DISTINCT vt.hotel_id) as num_tours FROM Hotels h JOIN VirtualTours vt ON h.hotel_id = vt.hotel_id GROUP BY h.city;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID int, Name varchar(50), Location varchar(50)); CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), ProgramID int, VolunteerDate date, Hours decimal(10,2)); INSERT INTO Programs (ProgramID, Name, Location) VALUES (1, 'Feeding America', 'USA'), (2, 'Habitat for Humanity', 'Canada'); INSERT INTO Volunteers (VolunteerID, Name, ProgramID, VolunteerDate, Hours) VALUES (1, 'Bob', 1, '2022-01-01', 10.00), (2, 'Sally', 1, '2022-02-01', 15.00), (3, 'John', 2, '2022-03-01', 20.00);
List the total number of volunteer hours for each program, broken down by month and year.
SELECT P.Name, DATE_FORMAT(V.VolunteerDate, '%Y-%m') as Date, SUM(V.Hours) as TotalHours FROM Programs P JOIN Volunteers V ON P.ProgramID = V.ProgramID GROUP BY P.ProgramID, Date;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_safety ( vessel_name VARCHAR(255), last_inspection_date DATE, last_inspection_grade CHAR(1));
Update the vessel_safety table and set the last_inspection_grade as 'B' for vessel "Freedom's Sail" if it's not already set
UPDATE vessel_safety SET last_inspection_grade = 'B' WHERE vessel_name = 'Freedom''s Sail' AND last_inspection_grade IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE VaccinationData (Country VARCHAR(50), Population INT, MeaslesVaccinated INT); INSERT INTO VaccinationData (Country, Population, MeaslesVaccinated) VALUES ('Canada', 38000000, 34560000), ('USA', 331000000, 301200000);
What is the percentage of the population that is vaccinated against measles in each country?
SELECT Country, (MeaslesVaccinated / Population) * 100 AS PercentVaccinated FROM VaccinationData;
gretelai_synthetic_text_to_sql
CREATE TABLE album_release (id INT, title TEXT, release_month INT, release_year INT, artist TEXT); INSERT INTO album_release (id, title, release_month, release_year, artist) VALUES (1, 'Album1', 1, 2021, 'Artist1'); INSERT INTO album_release (id, title, release_month, release_year, artist) VALUES (2, 'Album2', 3, 2021, 'Artist2'); INSERT INTO album_release (id, title, release_month, release_year, artist) VALUES (3, 'Album3', 12, 2021, 'Artist3');
How many albums were released per month in 2021?
SELECT release_month, COUNT(*) as albums_released FROM album_release WHERE release_year = 2021 GROUP BY release_month;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, Name VARCHAR(50)); CREATE TABLE Claims (ClaimID INT, PolicyID INT, State VARCHAR(20)); INSERT INTO Policyholders VALUES (1, 'John Smith'), (2, 'Jane Doe'), (3, 'Mike Brown'); INSERT INTO Claims VALUES (1, 1, 'California'), (2, 2, 'Texas');
Which policyholders have no claims in Florida?
SELECT p.Name FROM Policyholders p LEFT JOIN Claims c ON p.PolicyID = c.PolicyID WHERE c.PolicyID IS NULL AND State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_comparison (farmer VARCHAR(50), crop VARCHAR(50), yield INT); INSERT INTO crop_comparison (farmer, crop, yield) VALUES ('FarmerA', 'corn', 100), ('FarmerA', 'wheat', 80), ('FarmerB', 'corn', 110), ('FarmerB', 'wheat', 90), ('FarmerC', 'corn', 95), ('FarmerC', 'wheat', 75);
Which crop has the highest yield in 'crop_comparison' table?
SELECT crop, MAX(yield) as highest_yield FROM crop_comparison GROUP BY crop;
gretelai_synthetic_text_to_sql
CREATE TABLE portfolios (portfolio_id INT, customer_id INT, num_investments INT, num_shariah_compliant_investments INT);CREATE VIEW shariah_compliant_portfolios AS SELECT * FROM portfolios WHERE num_shariah_compliant_investments > 0;
What is the percentage of Shariah-compliant investments in each investment portfolio?
SELECT p.portfolio_id, (COUNT(scp.portfolio_id) * 100.0 / (SELECT COUNT(*) FROM shariah_compliant_portfolios)) as pct_shariah_compliant_investments FROM portfolios p LEFT JOIN shariah_compliant_portfolios scp ON p.portfolio_id = scp.portfolio_id GROUP BY p.portfolio_id;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(255), industry VARCHAR(255), salary DECIMAL(10,2)); CREATE TABLE unions (id INT, worker_id INT, union VARCHAR(255)); INSERT INTO workers (id, name, industry, salary) VALUES (1, 'Isabella Rodriguez', 'manufacturing', 90000.00);
What is the maximum salary of workers in the 'manufacturing' industry who are not part of a union?
SELECT MAX(workers.salary) FROM workers LEFT OUTER JOIN unions ON workers.id = unions.worker_id WHERE workers.industry = 'manufacturing' AND unions.union IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE products_ingredients(product_id INT, ingredient_id INT, natural_ingredient BOOLEAN, price DECIMAL); INSERT INTO products_ingredients(product_id, ingredient_id, natural_ingredient, price) VALUES (1, 1, true, 1.25), (2, 2, true, 3.00), (3, 3, false, 1.50), (4, 4, true, 2.00), (5, 5, true, 2.50); CREATE TABLE products(id INT, name TEXT, launch_year INT); INSERT INTO products(id, name, launch_year) VALUES (1, 'Cleanser X', 2022), (2, 'Lotion Y', 2021), (3, 'Shampoo Z', 2022), (4, 'Conditioner W', 2020), (5, 'Moisturizer V', 2022);
What is the total price of natural ingredients for products launched in 2022?
SELECT SUM(price) FROM products_ingredients p_i JOIN products p ON p_i.product_id = p.id WHERE natural_ingredient = true AND p.launch_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_institutions (institution_id INT, institution_name TEXT); INSERT INTO financial_institutions (institution_id, institution_name) VALUES (1, 'Islamic Bank'), (2, 'Al Baraka Bank'), (3, 'Islamic Finance House'); CREATE TABLE loans (loan_id INT, institution_id INT, loan_type TEXT, amount FLOAT); INSERT INTO loans (loan_id, institution_id, loan_type, amount) VALUES (1, 1, 'Shariah-compliant', 5000), (2, 1, 'conventional', 7000), (3, 2, 'Shariah-compliant', 4000), (4, 2, 'Shariah-compliant', 6000), (5, 3, 'conventional', 8000);
What is the total amount of Shariah-compliant loans issued by each financial institution?
SELECT institution_id, SUM(amount) FROM loans WHERE loan_type = 'Shariah-compliant' GROUP BY institution_id;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (country TEXT, year INT); INSERT INTO space_missions (country, year) VALUES ('USA', 2015), ('USA', 2015), ('USA', 2016), ('Russia', 2015), ('Russia', 2016), ('China', 2016), ('China', 2017), ('India', 2017), ('India', 2018);
What is the total number of space missions launched by each country and year?
SELECT country, year, COUNT(*) FROM space_missions GROUP BY country, year;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, region VARCHAR(10), claim_amount INT); INSERT INTO policyholders (id, region, claim_amount) VALUES (1, 'east', 5000), (2, 'west', 3000), (3, 'east', 1000);
What is the average claim amount for policyholders living in the 'east' region?
SELECT AVG(claim_amount) FROM policyholders WHERE region = 'east';
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, JoinDate DATE); INSERT INTO Members (MemberID, JoinDate) VALUES (1, '2022-04-05'), (2, '2022-03-12'), (3, '2022-06-20'), (4, '2022-05-01');
How many members joined in Q2 2022?
SELECT COUNT(*) FROM Members WHERE JoinDate BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, name TEXT, state TEXT, capacity_mw FLOAT); INSERT INTO renewable_energy_projects (id, name, state, capacity_mw) VALUES (1, 'Solar Star', 'California', 579.0), (2, 'Desert Sunlight Solar Farm', 'California', 550.0);
What is the total installed capacity (in MW) of all renewable energy projects in the state 'California'?
SELECT SUM(capacity_mw) FROM renewable_energy_projects WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_resources (id INT, resource VARCHAR(50), type VARCHAR(20)); INSERT INTO arctic_resources (id, resource, type) VALUES (1, 'oil', 'drilling'), (2, 'whale', 'hunting'), (3, 'seal', 'hunting');
Delete the arctic_resources table.
DROP TABLE arctic_resources;
gretelai_synthetic_text_to_sql
CREATE TABLE cases_by_state (state VARCHAR(20), year INT, num_cases INT); INSERT INTO cases_by_state (state, year, num_cases) VALUES ('California', 2021, 1200), ('New York', 2021, 2500), ('Texas', 2021, 1800);
How many cases were heard in each state last year?
SELECT state, SUM(num_cases) as total_cases FROM cases_by_state WHERE year = 2021 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (id INT, country VARCHAR(50), spending DECIMAL(10,2), year INT); INSERT INTO military_innovation (id, country, spending, year) VALUES (1, 'USA', 15000000.00, 2020); INSERT INTO military_innovation (id, country, spending, year) VALUES (2, 'China', 12000000.00, 2020); INSERT INTO military_innovation (id, country, spending, year) VALUES (3, 'Russia', 9000000.00, 2020);
What is the average spending on military innovation by the top 3 countries in 2020?
SELECT AVG(spending) as avg_spending FROM (SELECT spending FROM military_innovation WHERE country IN ('USA', 'China', 'Russia') AND year = 2020 ORDER BY spending DESC LIMIT 3) as top_three;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_map (map_id INT, map_name VARCHAR(50), region VARCHAR(50), site_depth INT);
What is the minimum depth of the ocean floor in the Atlantic region?
SELECT MIN(site_depth) FROM ocean_floor_map WHERE region = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE projects_by_quarter (id INT, project_name VARCHAR(255), completion_quarter INT, completion_year INT); INSERT INTO projects_by_quarter (id, project_name, completion_quarter, completion_year) VALUES (1, 'Highway Expansion', 3, 2021), (2, 'Water Treatment Plant Upgrade', 4, 2021);
How many public works projects were completed in each quarter of the last 2 years?
SELECT completion_quarter, completion_year, COUNT(*) as num_projects FROM projects_by_quarter WHERE completion_year >= YEAR(DATEADD(year, -2, GETDATE())) GROUP BY completion_quarter, completion_year;
gretelai_synthetic_text_to_sql
CREATE TABLE attacks (id INT, type VARCHAR(255), result VARCHAR(255), sector VARCHAR(255), date DATE); INSERT INTO attacks (id, type, result, sector, date) VALUES (1, 'phishing', 'unsuccessful', 'financial', '2022-01-01'); INSERT INTO attacks (id, type, result, sector, date) VALUES (2, 'ransomware', 'successful', 'healthcare', '2022-02-01');
Determine the number of successful ransomware attacks in the healthcare sector in the first quarter of 2022.
SELECT COUNT(*) FROM attacks WHERE type = 'ransomware' AND result = 'successful' AND sector = 'healthcare' AND date >= '2022-01-01' AND date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE region_sales (id INT, region VARCHAR(20), vehicle_type VARCHAR(20), year INT, quantity INT); INSERT INTO region_sales (id, region, vehicle_type, year, quantity) VALUES (1, 'North', 'ev', 2018, 1500), (2, 'North', 'ev', 2019, 2500), (3, 'North', 'autonomous', 2018, 800), (4, 'North', 'autonomous', 2019, 1500), (5, 'South', 'ev', 2018, 1000), (6, 'South', 'ev', 2019, 2000), (7, 'South', 'autonomous', 2018, 600), (8, 'South', 'autonomous', 2019, 1200), (9, 'East', 'ev', 2018, 800), (10, 'East', 'ev', 2019, 3000), (11, 'East', 'autonomous', 2018, 700), (12, 'East', 'autonomous', 2019, 1400), (13, 'West', 'ev', 2018, 2000), (14, 'West', 'ev', 2019, 4000), (15, 'West', 'autonomous', 2018, 900), (16, 'West', 'autonomous', 2019, 1800);
Show the number of electric and autonomous vehicles sold in each region in 2019
SELECT region, year, SUM(quantity) FROM region_sales WHERE vehicle_type IN ('ev', 'autonomous') AND year = 2019 GROUP BY region, year;
gretelai_synthetic_text_to_sql