context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Spacecraft (name VARCHAR(30), max_altitude FLOAT); INSERT INTO Spacecraft (name, max_altitude) VALUES ('Apollo 13', 400040), ('Apollo 11', 363390);
|
What is the maximum altitude reached by any spacecraft?
|
SELECT MAX(max_altitude) FROM Spacecraft;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, name VARCHAR(50), region VARCHAR(50), ocean_depth DECIMAL(5,2)); INSERT INTO marine_species (id, name, region, ocean_depth) VALUES (1, 'Polar Bear', 'Arctic Ocean', 100.00); CREATE TABLE ocean_depth_scale (id INT, name VARCHAR(50), value DECIMAL(5,2));
|
What are the unique depths of the ocean habitats for marine species in the Arctic Ocean?
|
SELECT DISTINCT marine_species.ocean_depth FROM marine_species INNER JOIN ocean_depth_scale ON marine_species.ocean_depth = ocean_depth_scale.value WHERE ocean_depth_scale.name = 'Meters';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT, sector VARCHAR(20), amount FLOAT); INSERT INTO investments (id, sector, amount) VALUES (1, 'Education', 150000.00), (2, 'Healthcare', 120000.00);
|
Delete the investment with the given id.
|
DELETE FROM investments WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE); INSERT INTO project (id, name, location, start_date) VALUES (1, 'Green Build', 'NYC', '2020-01-01'), (2, 'Solar Tower', 'LA', '2019-12-15'), (3, 'Eco House', 'Austin', '2020-03-01'); CREATE TABLE permit (id INT, project_id INT, type VARCHAR(50), issued_date DATE); INSERT INTO permit (id, project_id, type, issued_date) VALUES (1, 1, 'Building', '2019-12-01'), (2, 1, 'Electrical', '2020-01-05'), (3, 2, 'Building', '2019-11-30'), (4, 2, 'Plumbing', '2019-12-10'), (5, 3, 'Building', '2020-02-15');
|
What is the earliest issued permit date for projects in 'LA'?
|
SELECT MIN(issued_date) AS earliest_date FROM permit WHERE project_id IN (SELECT id FROM project WHERE location = 'LA');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, dish_id INT, order_date DATE); INSERT INTO orders (order_id, dish_id, order_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-01'), (3, 3, '2022-01-01'), (4, 1, '2022-01-02'), (5, 3, '2022-01-02'), (6, 1, '2022-01-03');
|
Display the number of times each dish has been ordered, sorted by the most ordered dish
|
SELECT dish_id, COUNT(*) as order_count FROM orders GROUP BY dish_id ORDER BY order_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(100), Age INT, Genre VARCHAR(50), TicketsSold INT); INSERT INTO Artists (ArtistID, ArtistName, Age, Genre, TicketsSold) VALUES (1, 'Artist A', 35, 'Blues', 3000), (2, 'Artist B', 45, 'Jazz', 4000), (3, 'Artist C', 28, 'Pop', 5000), (4, 'Artist D', 50, 'Blues', 2500), (5, 'Artist E', 42, 'Blues', 1500), (6, 'Artist F', 48, 'Jazz', 6000);
|
What is the average age of blues artists who have sold more than 2000 tickets?
|
SELECT AVG(Age) FROM Artists WHERE Genre = 'Blues' AND TicketsSold > 2000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ProjectTimelines (id INT, project_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE, status VARCHAR(255)); INSERT INTO ProjectTimelines (id, project_name, region, start_date, end_date, status) VALUES (1, 'Project A', 'Europe', '2017-01-01', '2019-12-31', 'Completed'), (2, 'Project B', 'Europe', '2018-01-01', '2020-12-31', 'Cancelled'), (3, 'Project C', 'Africa', '2019-01-01', '2021-06-30', 'In Progress');
|
What is the average duration of unsuccessful defense projects in Europe?
|
SELECT AVG(DATEDIFF(end_date, start_date)) as avg_duration FROM ProjectTimelines WHERE region = 'Europe' AND status != 'Completed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, condition TEXT, therapy_sessions INT);
|
What is the minimum number of therapy sessions attended by patients with a primary diagnosis of bipolar disorder?
|
SELECT MIN(therapy_sessions) FROM patients WHERE condition = 'bipolar_disorder';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, city VARCHAR(20), capacity INT); CREATE TABLE country (id INT, name VARCHAR(20)); INSERT INTO country (id, name) VALUES (1, 'India'), (2, 'USA'), (3, 'Germany'); CREATE VIEW warehouse_country AS SELECT * FROM warehouse INNER JOIN country ON warehouse.id = country.id; INSERT INTO warehouse (id, city, capacity) VALUES (13, 'New York', 1500), (14, 'Los Angeles', 2000), (15, 'Chicago', 2500); INSERT INTO country (id, name) VALUES (5, 'USA'); INSERT INTO warehouse_country (id, city, capacity, name) VALUES (13, 'New York', 1500, 'USA'), (14, 'Los Angeles', 2000, 'USA'), (15, 'Chicago', 2500, 'USA');
|
Update the capacities of all warehouses in the USA to 5000
|
UPDATE warehouse_country SET capacity = 5000 WHERE name = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Investments (InvestmentID INT, InvestorID INT, Amount INT); INSERT INTO Investments (InvestmentID, InvestorID, Amount) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000), (4, 2, 8000), (5, 3, 4000), (6, 3, 6000); CREATE TABLE Investors (InvestorID INT, Name VARCHAR(20), Gender VARCHAR(10)); INSERT INTO Investors (InvestorID, Name, Gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'), (3, 'Jim Brown', 'Male');
|
What is the average investment amount for each investor?
|
SELECT Investors.Name, AVG(Investments.Amount) as AverageInvestment FROM Investments JOIN Investors ON Investments.InvestorID = Investors.InvestorID GROUP BY Investors.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE OR REPLACE VIEW health_equity_view AS SELECT * FROM health_equity;
|
Select all data from the view for health equity metrics
|
SELECT * FROM health_equity_view;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE communities (id INT, name TEXT, location TEXT); INSERT INTO communities (id, name, location) VALUES (1, 'Community A', 'Rural Area 1'), (2, 'Community B', 'Rural Area 2'); CREATE TABLE infrastructure_projects (id INT, community_id INT, name TEXT, cost INT, year INT, PRIMARY KEY (id, year)); INSERT INTO infrastructure_projects (id, community_id, name, cost, year) VALUES (1, 1, 'Project 1', 5000, 2022), (2, 1, 'Project 2', 3000, 2022), (3, 2, 'Project 3', 4000, 2022);
|
What is the total cost of infrastructure projects for each community in 2022, sorted by the highest total cost?
|
SELECT community_id, SUM(cost) as total_cost FROM infrastructure_projects WHERE year = 2022 GROUP BY community_id ORDER BY total_cost DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_productivity (record_id INT PRIMARY KEY, mine_name VARCHAR(20), region VARCHAR(20), productivity_score INT);
|
Insert a new record into the "labor_productivity" table with the following data: 'Ruby Ranch', 'South Coast', 91
|
INSERT INTO labor_productivity (mine_name, region, productivity_score) VALUES ('Ruby Ranch', 'South Coast', 91);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_unions (id INT, union_name VARCHAR(50), members INT); CREATE TABLE employees (id INT, union_id INT, name VARCHAR(50), position VARCHAR(50));
|
Find the number of employees and unions in the 'labor_unions' and 'employees' tables
|
SELECT COUNT(DISTINCT e.id) AS employee_count, COUNT(DISTINCT l.id) AS union_count FROM employees e JOIN labor_unions l ON e.union_id = l.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (school_id INT, program_name VARCHAR(50), program_type VARCHAR(20));
|
List all unique mental health programs offered by schools in the 'programs' table, without sorting the results.
|
SELECT DISTINCT program_name FROM programs WHERE program_type = 'mental_health';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE training_sessions (session_id INT, session_name VARCHAR(50), completed_by_worker INT); INSERT INTO training_sessions (session_id, session_name, completed_by_worker) VALUES (1, 'Cultural Competency 101', 120), (2, 'Advanced Cultural Competency', 80);
|
What is the cultural competency training completion rate for community health workers in each region?
|
SELECT r.region_name, COUNT(chw.worker_id) as total_workers, COUNT(ts.completed_by_worker) as completed_trainings, 100.0 * COUNT(ts.completed_by_worker) / COUNT(chw.worker_id) as completion_rate FROM regions r INNER JOIN community_health_workers chw ON r.region_id = chw.region_id LEFT JOIN (training_sessions ts INNER JOIN (SELECT worker_id, MAX(session_id) as max_session_id FROM training_sessions GROUP BY worker_id) ts_max ON ts.session_id = ts_max.max_session_id AND ts.completed_by_worker = ts_max.worker_id) ON chw.worker_id = ts_max.worker_id GROUP BY r.region_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE language_count (id INT, country VARCHAR(50), language VARCHAR(50)); INSERT INTO language_count (id, country, language) VALUES (1, 'Canada', 'Navajo'); INSERT INTO language_count (id, country, language) VALUES (2, 'New Zealand', 'Quechua');
|
What is the total number of languages preserved in each country?
|
SELECT country, COUNT(language) FROM language_count GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destinations (id INT, country TEXT, continent TEXT); INSERT INTO destinations (id, country, continent) VALUES (1, 'Colombia', 'South America'), (2, 'Argentina', 'South America'), (3, 'Canada', 'North America'); CREATE TABLE visits (id INT, visitor_origin TEXT, destination_id INT); INSERT INTO visits (id, visitor_origin, destination_id) VALUES (1, 'Mexico', 3), (2, 'Brazil', 3), (3, 'Colombia', 1);
|
What is the percentage of total visitors that went to Colombia from each continent?
|
SELECT d.continent, 100.0 * COUNT(v.id) / (SELECT COUNT(*) FROM visits) AS percentage FROM visits v JOIN destinations d ON v.destination_id = d.id WHERE d.country = 'Colombia' GROUP BY d.continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(50), certification VARCHAR(50), country VARCHAR(50), sustainable_practices BOOLEAN); CREATE TABLE products (product_id INT, supplier_id INT, name VARCHAR(50)); CREATE VIEW product_supplier_view AS SELECT products.product_id, products.name, suppliers.supplier_id, suppliers.name as supplier_name, suppliers.certification, suppliers.country FROM products INNER JOIN suppliers ON products.supplier_id = suppliers.supplier_id;
|
List all products supplied by Fair Trade certified suppliers in Kenya.
|
SELECT product_id, name FROM product_supplier_view WHERE certification = 'Fair Trade' AND country = 'Kenya';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name VARCHAR(50), email VARCHAR(50)); INSERT INTO students (id, name, email) VALUES (10, 'John Doe', 'johndoe@example.com');
|
Update the email address for student with ID 10 in the students table
|
UPDATE students SET email = 'johndoe_new@example.com' WHERE id = 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE concert_tickets (ticket_id int, artist_id int, venue_id int, ticket_price decimal, timestamp datetime); INSERT INTO concert_tickets (ticket_id, artist_id, venue_id, ticket_price, timestamp) VALUES (1, 456, 789, 50.00, '2022-06-01 12:00:00');
|
What are the average ticket prices for each artist's concert in the United Kingdom?
|
SELECT artist_id, AVG(ticket_price) as avg_ticket_price FROM concert_tickets WHERE timestamp BETWEEN '2022-01-01' AND '2022-12-31' AND venue_id IN (SELECT venue_id FROM venues WHERE country = 'United Kingdom') GROUP BY artist_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donation_date DATE, campaign TEXT, amount INT); INSERT INTO donations (id, donation_date, campaign, amount) VALUES (1, '2021-01-01', 'Feeding America', 50); INSERT INTO donations (id, donation_date, campaign, amount) VALUES (2, '2020-05-15', 'Feeding America', 100); INSERT INTO donations (id, donation_date, campaign, amount) VALUES (3, '2020-12-31', 'Feeding America', 25);
|
Find the average donation amount for the 'Feeding America' campaign in '2020'.
|
SELECT AVG(amount) FROM donations WHERE campaign = 'Feeding America' AND YEAR(donation_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mexico_tours (id INT, type VARCHAR(255), revenue FLOAT); INSERT INTO mexico_tours (id, type, revenue) VALUES (1, 'Eco-friendly', 600.00), (2, 'Eco-friendly', 700.00);
|
What is the minimum revenue generated from any eco-friendly tour in Mexico?
|
SELECT MIN(revenue) FROM mexico_tours WHERE type = 'Eco-friendly';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_scores (player_id INT, game_id INT, score INT, date DATE);
|
Delete records in the 'player_scores' table where the player's score is below 500
|
DELETE FROM player_scores WHERE score < 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_sources (funding_source_name VARCHAR(50), program_name VARCHAR(50), funding_amount DECIMAL(10,2), funding_year INT); INSERT INTO funding_sources (funding_source_name, program_name, funding_amount, funding_year) VALUES ('Government Grant', 'Theatre', 25000, 2022), ('Private Donation', 'Theatre', 50000, 2022), ('Corporate Sponsorship', 'Music', 30000, 2022);
|
What is the total funding received for 'Theatre' programs in 2022?
|
SELECT SUM(funding_amount) FROM funding_sources WHERE program_name = 'Theatre' AND funding_year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE charging_stations (station_id INT, city VARCHAR(50), station_type VARCHAR(50), is_ev_charging BOOLEAN);
|
What is the number of electric vehicle charging stations per city and per type?
|
SELECT city, station_type, COUNT(*) as num_stations FROM charging_stations WHERE is_ev_charging = true GROUP BY city, station_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE adherence (id INT PRIMARY KEY, patient_id INT, drug_id INT, region VARCHAR(255), adherence DECIMAL(4,2), adherence_date DATE);
|
What is the average adherence rate for drugs in the Southeast region, excluding those with adherence rates below 50%?
|
SELECT AVG(a.adherence) as average_adherence FROM adherence a WHERE a.region = 'Southeast' AND a.adherence >= 0.5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, gender TEXT, age INT, diagnosis TEXT); INSERT INTO patients (id, gender, age, diagnosis) VALUES (1, 'Male', 65, 'Diabetes');
|
What is the average age of male patients diagnosed with diabetes?
|
SELECT AVG(age) FROM patients WHERE gender = 'Male' AND diagnosis = 'Diabetes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pipelines (pipeline_id INT, pipeline_name TEXT, start_location TEXT, end_location TEXT, country_start TEXT, country_end TEXT); INSERT INTO pipelines (pipeline_id, pipeline_name, start_location, end_location, country_start, country_end) VALUES (1, 'Pipeline C', 'Canada', 'US', 'Canada', 'US'), (2, 'Pipeline D', 'Mexico', 'US', 'Mexico', 'US'), (3, 'Pipeline E', 'Norway', 'Sweden', 'Norway', 'Sweden');
|
List all pipelines that cross international borders
|
SELECT pipeline_name FROM pipelines WHERE country_start <> country_end;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, region VARCHAR(10)); CREATE TABLE game_sessions (session_id INT, player_id INT, duration FLOAT, PRIMARY KEY (session_id), FOREIGN KEY (player_id) REFERENCES players(player_id)); INSERT INTO players (player_id, region) VALUES (1, 'EU_West'), (2, 'NA_East'); INSERT INTO game_sessions (session_id, player_id, duration) VALUES (1, 1, 60.5), (2, 1, 45.3), (3, 2, 30.7), (4, 2, 75.2);
|
Find the average gameplay duration for players in the 'EU_West' region
|
SELECT AVG(duration) FROM game_sessions WHERE player_id IN (SELECT player_id FROM players WHERE region = 'EU_West');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(50), data_plan VARCHAR(20), state VARCHAR(50)); INSERT INTO mobile_subscribers (id, name, data_plan, state) VALUES (11, 'Gina Adams', 'Limited', 'IL'); INSERT INTO mobile_subscribers (id, name, data_plan, state) VALUES (12, 'Henry Brown', 'Limited', 'IL');
|
How many mobile subscribers are there in Illinois with a data plan that is not unlimited?
|
SELECT COUNT(*) FROM mobile_subscribers WHERE data_plan != 'Unlimited' AND state = 'IL';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, name TEXT, region TEXT); INSERT INTO community_health_workers (worker_id, name, region) VALUES (1, 'John Doe', 'Los Angeles'), (2, 'Jane Smith', 'New York'); CREATE TABLE mental_health_parity_violations (id INT, worker_id INT, violation_count INT); INSERT INTO mental_health_parity_violations (id, worker_id, violation_count) VALUES (1, 1, 5), (2, 1, 3), (3, 2, 1);
|
What is the number of mental health parity violations for each community health worker in the Los Angeles region?
|
SELECT c.name, m.violation_count FROM community_health_workers c JOIN mental_health_parity_violations m ON c.worker_id = m.worker_id WHERE c.region = 'Los Angeles'
|
gretelai_synthetic_text_to_sql
|
SELECT name, address FROM policyholders WHERE age >= 30;
|
Write a SQL query to retrieve the names and addresses of policyholders aged 30 or older
|
SELECT name, address FROM policyholders WHERE age >= 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name TEXT, last_port TEXT, last_port_date DATE); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (1, 'VesselC', 'Singapore', '2021-12-15'); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (2, 'VesselD', 'Hong Kong', '2021-11-30'); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (3, 'VesselE', 'Dar es Salaam', '2022-03-05');
|
List the names of vessels that have traveled to the port of Dar es Salaam, Tanzania in the last 3 months.
|
SELECT DISTINCT name FROM vessels WHERE last_port = 'Dar es Salaam' AND last_port_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Concerts (id INT, artist_id INT, city VARCHAR(50), revenue DECIMAL(10,2));
|
What is the total revenue from concert ticket sales for a specific artist?
|
SELECT SUM(revenue) AS total_revenue FROM Concerts WHERE artist_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species_distribution (species_id INT, ocean_basin VARCHAR(20));
|
Show the number of unique species found in each ocean basin in the 'species_distribution' table.
|
SELECT ocean_basin, COUNT(DISTINCT species_id) FROM species_distribution GROUP BY ocean_basin;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports ( id INT, name VARCHAR(255), location VARCHAR(255), operated_by VARCHAR(255)); CREATE TABLE cargo ( id INT, port_id INT, weight INT); INSERT INTO ports (id, name, location, operated_by) VALUES (1, 'Port A', 'New York', 'Company A'), (2, 'Port B', 'Los Angeles', 'Company B'); INSERT INTO cargo (id, port_id, weight) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 3000);
|
Which ports have not handled any cargo with a weight above a certain threshold?
|
SELECT ports.name FROM ports LEFT JOIN cargo ON ports.id = cargo.port_id WHERE cargo.weight IS NULL OR cargo.weight <= 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE music_streaming (artist_id INT, artist_name VARCHAR(100), genre VARCHAR(50), country VARCHAR(50)); CREATE TABLE concert_ticket_sales (concert_id INT, artist_id INT, concert_date DATE, venue VARCHAR(100), country VARCHAR(50));
|
List all artists who have streamed in the USA and held concerts in Canada.
|
SELECT DISTINCT artist_name FROM music_streaming WHERE country = 'USA' INTERSECT SELECT DISTINCT artist_name FROM concert_ticket_sales WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, has_ethical_labor BOOLEAN); INSERT INTO products (product_id, has_ethical_labor) VALUES (1, true), (2, false), (3, true), (4, false), (5, true);
|
What is the count of products with ethical labor practices?
|
SELECT COUNT(*) FROM products WHERE has_ethical_labor = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE blockchains (blockchain_id INT, blockchain_name VARCHAR(50), daily_transactions INT); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (1, 'Ethereum', 50000); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (2, 'Solana', 100000); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (3, 'Cardano', 20000); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (4, 'Polkadot', 30000);
|
What are the names and daily transaction counts of the top 3 blockchain networks with the highest daily transaction volumes?
|
SELECT blockchain_name, daily_transactions FROM blockchains ORDER BY daily_transactions DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cricket_teams (team_id INT, team_name VARCHAR(50), region VARCHAR(50));CREATE TABLE cricket_players (player_id INT, player_name VARCHAR(50), position VARCHAR(50), team_id INT);CREATE TABLE cricket_matches (match_id INT, home_team_id INT, away_team_id INT, home_team_innings INT, away_team_innings INT, bowler_id INT);
|
What is the maximum number of innings bowled by a bowler from the north_team in cricket_matches?
|
SELECT MAX(home_team_innings + away_team_innings) AS max_innings FROM cricket_matches JOIN cricket_players ON cricket_matches.bowler_id = cricket_players.player_id JOIN cricket_teams ON cricket_players.team_id = cricket_teams.team_id WHERE cricket_teams.region = 'north_team';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tour_attendees (id INT, exhibition_name VARCHAR(50), participants INT, tour_date DATE); INSERT INTO virtual_tour_attendees (id, exhibition_name, participants, tour_date) VALUES (1, 'African Art: Ancient to Modern', 120, '2022-03-01'); INSERT INTO virtual_tour_attendees (id, exhibition_name, participants, tour_date) VALUES (2, 'African Art: Ancient to Modern', 150, '2023-02-15');
|
What is the maximum number of virtual tour participants for the exhibition 'African Art: Ancient to Modern' in the last year?
|
SELECT MAX(participants) FROM virtual_tour_attendees WHERE exhibition_name = 'African Art: Ancient to Modern' AND tour_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (id INT, name TEXT, area TEXT, revenue FLOAT); INSERT INTO restaurants (id, name, area, revenue) VALUES (1, 'Restaurant A', 'downtown', 50000.00), (2, 'Restaurant B', 'uptown', 45000.00), (3, 'Restaurant C', 'downtown', 60000.00), (4, 'Restaurant D', 'downtown', 75000.00);
|
What is the average revenue of restaurants in the "downtown" area?
|
SELECT AVG(revenue) FROM restaurants WHERE area = 'downtown';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Gender VARCHAR(255), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'IT', 'Male', 75000.00), (2, 'Diversity and Inclusion', 'Female', 68000.00), (3, 'HR', 'Male', 65000.00);
|
What is the maximum salary in the 'HR' department?
|
SELECT MAX(Salary) FROM Employees WHERE Department = 'HR';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Crops(state VARCHAR(255), name VARCHAR(255)); INSERT INTO Crops(state, name) VALUES('California', 'Corn'), ('California', 'Soybean'), ('California', 'Wheat'), ('Texas', 'Cotton'), ('Texas', 'Rice'), ('Texas', 'Corn');
|
List the precision farming crops that are grown in both California and Texas.
|
SELECT name FROM Crops WHERE state = 'California' INTERSECT SELECT name FROM Crops WHERE state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (area_id INT, name VARCHAR(255), depth FLOAT);
|
What is the average depth of marine protected areas?
|
SELECT AVG(depth) FROM marine_protected_areas;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, volunteer_name VARCHAR, country VARCHAR, program VARCHAR); INSERT INTO volunteers (id, volunteer_name, country, program) VALUES (1, 'Alice', 'USA', 'Youth Mentoring'), (2, 'Bob', 'Canada', 'Women Empowerment'), (3, 'Charlie', 'Mexico', 'Community Service'); CREATE TABLE programs (id INT, program VARCHAR, community VARCHAR); INSERT INTO programs (id, program, community) VALUES (1, 'Youth Mentoring', 'Underrepresented'), (2, 'Women Empowerment', 'Underrepresented'), (3, 'Community Service', 'Underrepresented');
|
What is the number of volunteers who have participated in programs in each country?
|
SELECT country, COUNT(*) FROM volunteers v INNER JOIN programs p ON v.program = p.program GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE endangered_species(id INT, animal_name VARCHAR(50), conservation_status VARCHAR(50)); INSERT INTO endangered_species(id, animal_name, conservation_status) VALUES (1, 'Amur Leopard', 'Critically Endangered'), (2, 'Black Rhino', 'Critically Endangered'), (3, 'Bengal Tiger', 'Endangered');
|
What is the total number of animals in the 'endangered_species' table, grouped by their 'conservation_status'?
|
SELECT conservation_status, COUNT(animal_name) FROM endangered_species GROUP BY conservation_status;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seoul.vehicle_types (id INT, type VARCHAR); CREATE TABLE seoul.vehicles (id INT, type_id INT, is_active BOOLEAN);
|
How many vehicles are currently in service for each type in the 'seoul' schema?
|
SELECT seoul.vehicle_types.type, COUNT(*) FROM seoul.vehicle_types INNER JOIN seoul.vehicles ON seoul.vehicle_types.id = seoul.vehicles.type_id WHERE seoul.vehicles.is_active = TRUE GROUP BY seoul.vehicle_types.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales(sale_id INT, equipment_name VARCHAR(50), sale_country VARCHAR(50)); INSERT INTO military_sales VALUES (1, 'Tank', 'Canada'), (2, 'Helicopter', 'Canada'), (3, 'Airplane', 'Mexico');
|
How many military equipment sales were made to Mexico?
|
SELECT COUNT(*) FROM military_sales WHERE sale_country = 'Mexico';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_facilities (city TEXT, facility_type TEXT, facility_count INTEGER); INSERT INTO city_facilities (city, facility_type, facility_count) VALUES ('CityA', 'hospitals', 2), ('CityB', 'hospitals', 1), ('CityC', 'hospitals', 1), ('CityA', 'schools', 3), ('CityB', 'schools', 3), ('CityC', 'schools', 2);
|
Find the number of hospitals and schools in each city.
|
SELECT city, facility_type, SUM(facility_count) FROM city_facilities GROUP BY city, facility_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cotton_farming (country VARCHAR(50), region VARCHAR(50), total_production INT, water_usage INT); CREATE VIEW cotton_farming_view AS SELECT * FROM cotton_farming;
|
Create a view to display all data related to the 'cotton_farming' sector
|
CREATE VIEW cotton_farming_view AS SELECT * FROM cotton_farming;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255)); CREATE TABLE meals (id INT, customer_id INT, name VARCHAR(255), calories INT); INSERT INTO customers (id, name) VALUES (1001, 'John Doe'), (1002, 'Jane Doe'), (1003, 'Mary Smith'); INSERT INTO meals (id, customer_id, name, calories) VALUES (1, 1001, 'Steak', 800), (2, 1002, 'Poutine', 700), (3, 1001, 'Burger', 600), (4, 1003, 'Salad', 400);
|
Who are the top 5 customers with the highest calorie intake and their total calorie intake?
|
SELECT c.name, SUM(m.calories) as total_calories FROM customers c INNER JOIN meals m ON c.id = m.customer_id GROUP BY c.name ORDER BY total_calories DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteer_programs (id INT, volunteer INT, program TEXT, volunteer_date DATE); INSERT INTO volunteer_programs (id, volunteer, program, volunteer_date) VALUES (1, 1, 'Education', '2021-01-01'), (2, 1, 'Health', '2021-02-01'), (3, 2, 'Education', '2021-01-01'), (4, 3, 'Arts', '2021-03-01');
|
How many unique volunteers have participated in each program in 2021?
|
SELECT program, COUNT(DISTINCT volunteer) AS num_volunteers FROM volunteer_programs WHERE EXTRACT(YEAR FROM volunteer_date) = 2021 GROUP BY program ORDER BY num_volunteers DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE finance_training (id INT, name VARCHAR(50), department VARCHAR(50), program VARCHAR(50), training_year INT);
|
Add a new employee from the 'Finance' department who joined the 'Diversity and Inclusion' training program in 2022.
|
INSERT INTO finance_training (id, name, department, program, training_year) VALUES (3, 'Tariq Ahmed', 'Finance', 'Diversity and Inclusion', 2022);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA oceans; CREATE TABLE fish_farms (id INT, size FLOAT, location VARCHAR(20)); INSERT INTO fish_farms (id, size, location) VALUES (1, 55.2, 'ocean'), (2, 62.5, 'ocean'), (3, 70.3, 'ocean');
|
Find the total size of fish farms in 'oceans' schema where the size is greater than 50.
|
SELECT SUM(size) FROM oceans.fish_farms WHERE size > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (4, 'Uptown'); CREATE TABLE neighborhoods (id INT, district_id INT, name VARCHAR(255)); INSERT INTO neighborhoods (id, district_id, name) VALUES (201, 4, 'Northside'); INSERT INTO neighborhoods (id, district_id, name) VALUES (202, 4, 'Southside'); CREATE TABLE emergency_incidents (id INT, neighborhood_id INT, reported_date DATE); INSERT INTO emergency_incidents (id, neighborhood_id, reported_date) VALUES (2001, 201, '2020-12-31'); INSERT INTO emergency_incidents (id, neighborhood_id, reported_date) VALUES (2002, 201, '2021-01-02'); INSERT INTO emergency_incidents (id, neighborhood_id, reported_date) VALUES (2003, 202, '2021-01-01');
|
Delete all emergency incidents reported before '2021-01-01' in district 4 neighborhoods
|
DELETE FROM emergency_incidents WHERE reported_date < '2021-01-01' AND neighborhood_id IN (SELECT id FROM neighborhoods WHERE district_id = 4);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_voice_assistant BOOLEAN);CREATE TABLE countries (country_id INT, country TEXT, continent TEXT); INSERT INTO hotels VALUES (3, 'Hotel D', 'Canada', true); INSERT INTO countries VALUES (1, 'Canada', 'North America');
|
What is the number of hotels that have adopted AI voice assistants, grouped by continent?
|
SELECT countries.continent, COUNT(*) FROM hotels INNER JOIN countries ON hotels.country = countries.country WHERE hotels.ai_voice_assistant = true GROUP BY countries.continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_financing(client_id INT, country VARCHAR(25), amount FLOAT);INSERT INTO shariah_financing(client_id, country, amount) VALUES (1, 'Malaysia', 5000), (2, 'UAE', 7000), (3, 'Indonesia', 6000), (4, 'Saudi Arabia', 8000);
|
Find the total amount of Shariah-compliant financing for each country?
|
SELECT country, SUM(amount) as total_financing FROM shariah_financing GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_energy_efficiency (city_name TEXT, year INTEGER, efficiency FLOAT); INSERT INTO city_energy_efficiency VALUES ('CityA', 2020, 0.5), ('CityA', 2021, 0.55), ('CityB', 2020, 0.7), ('CityB', 2021, 0.73);
|
What is the change in energy efficiency for each smart city compared to the previous year?
|
SELECT a.city_name, a.year, a.efficiency, b.efficiency, a.efficiency - b.efficiency AS difference FROM city_energy_efficiency a INNER JOIN city_energy_efficiency b ON a.city_name = b.city_name AND a.year - 1 = b.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinic_vaccines (clinic_id INT, vaccine_name VARCHAR(255), state VARCHAR(255)); CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(255)); INSERT INTO clinic_vaccines (clinic_id, vaccine_name, state) VALUES (1, 'Pfizer', 'Texas'), (2, 'Moderna', 'Texas'); INSERT INTO clinics (clinic_id, clinic_name) VALUES (1, 'Clinic A'), (2, 'Clinic B');
|
How many clinics in Texas offer the Pfizer or Moderna vaccine?
|
SELECT COUNT(*) FROM clinic_vaccines v INNER JOIN clinics c ON v.clinic_id = c.clinic_id WHERE v.vaccine_name IN ('Pfizer', 'Moderna') AND v.state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW intelligence_budget AS SELECT agency_id, agency_name, budget FROM intelligence_agency_data WHERE category = 'budget'; CREATE TABLE intelligence_agency_data (agency_id INT PRIMARY KEY, agency_name VARCHAR(100), category VARCHAR(50), data_value FLOAT); INSERT INTO intelligence_agency_data (agency_id, agency_name, category, data_value) VALUES (1, 'CIA', 'budget', 15000000000), (2, 'NSA', 'budget', 12000000000);
|
What is the name and total budget of the intelligence agency with the highest budget in the 'intelligence_budget' view?
|
SELECT agency_name, SUM(data_value) FROM intelligence_budget WHERE category = 'budget' GROUP BY agency_name ORDER BY SUM(data_value) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, song_id INT, revenue FLOAT, sale_type VARCHAR(20), sale_date DATE, genre VARCHAR(20)); INSERT INTO sales (id, song_id, revenue, sale_type, sale_date, genre) VALUES (1, 1, 12.99, 'Digital', '2021-12-15', 'K-pop'), (2, 2, 6.99, 'Streaming', '2021-10-01', 'K-pop');
|
What is the total revenue generated by K-pop music from digital sales and streaming platforms in Q4 2021?
|
SELECT SUM(revenue) FROM sales WHERE sale_type IN ('Digital', 'Streaming') AND genre = 'K-pop' AND sale_date >= '2021-10-01' AND sale_date <= '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(100), age INT, country VARCHAR(50), income DECIMAL(10,2)); INSERT INTO clients (client_id, name, age, country, income) VALUES (4, 'Ali Baba', 32, 'Malaysia', 50000);
|
What is the total income of clients in Malaysia who are over 30 years old?
|
SELECT SUM(income) FROM clients WHERE country = 'Malaysia' AND age > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wearables (member_id INT, device_type VARCHAR(50), heart_rate INT);
|
Delete records with a heart rate below 60 bpm in the wearables table
|
DELETE FROM wearables WHERE heart_rate < 60;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name VARCHAR(50)); CREATE TABLE satellites (id INT, country_id INT, name VARCHAR(50));
|
List all countries and the number of satellites they have in orbit.
|
SELECT c.name, COUNT(s.id) FROM countries c JOIN satellites s ON c.id = s.country_id GROUP BY c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IndigenousCommunities (country varchar(50), community_name varchar(50), population int);
|
What is the number of indigenous communities in each Arctic country?
|
SELECT country, COUNT(DISTINCT community_name) AS num_communities FROM IndigenousCommunities GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE writers (id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(20)); CREATE TABLE salaries (id INT, writer_id INT, salary INT);
|
What is the maximum salary of sports columnists from the 'writers' and 'salaries' tables?
|
SELECT MAX(s.salary) FROM writers w JOIN salaries s ON w.id = s.writer_id WHERE w.department = 'sports_columnist';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE engagement_data (platform VARCHAR(20), engagement NUMERIC(10,2));
|
What is the distribution of post engagement for each platform?
|
SELECT platform, AVG(engagement) FROM engagement_data GROUP BY platform;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifact_Inventory (id INT, artifact_name VARCHAR(50), artifact_type VARCHAR(50)); INSERT INTO Artifact_Inventory (id, artifact_name, artifact_type) VALUES (1, 'Artifact 1', 'Pottery'), (2, 'Artifact 2', 'Stone Tool'), (3, 'Artifact 3', 'Pottery'), (4, 'Artifact 4', 'Bone Tool');
|
How many unique artifact types are present in the 'Artifact_Inventory' table?
|
SELECT COUNT(DISTINCT artifact_type) FROM Artifact_Inventory;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, content TEXT, created_at TIMESTAMP);
|
Get the top 3 countries with the most posts related to AI.
|
SELECT users.country, COUNT(posts.id) AS posts_count FROM users JOIN posts ON users.id = posts.user_id WHERE posts.content LIKE '%AI%' GROUP BY users.country ORDER BY posts_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chain_Sales (chain TEXT, revenue INT); INSERT INTO Chain_Sales (chain, revenue) VALUES ('ABC Hotels', 800000), ('XYZ Hotels', 900000), ('LMN Hotels', 700000);
|
Find the top 3 hotel chains with the highest revenue in the 'Chain_Sales' table.
|
SELECT chain, revenue FROM (SELECT chain, revenue, DENSE_RANK() OVER (ORDER BY revenue DESC) as rank FROM Chain_Sales) WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'Alexandre Oliveira'); INSERT INTO authors (id, name) VALUES (2, 'Nina Gupta'); INSERT INTO authors (id, name) VALUES (3, 'Park Soo-jin'); CREATE TABLE investigative_projects (id INT, title VARCHAR(100), lead_investigator_id INT, author_id INT); INSERT INTO investigative_projects (id, title, lead_investigator_id, author_id) VALUES (1, 'Corruption in Local Government', 4, 1); INSERT INTO investigative_projects (id, title, lead_investigator_id, author_id) VALUES (2, 'Impact of Climate Change on Agriculture', 5, 3);
|
Identify the unique authors who have not contributed to any investigative projects.
|
SELECT name FROM authors WHERE id NOT IN (SELECT author_id FROM investigative_projects);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LaborHours (State VARCHAR(2), Job VARCHAR(50), HoursWorked DATE);
|
What is the total number of construction labor hours worked, by job type, in each state, in the past month, ordered from highest to lowest?
|
SELECT State, Job, SUM(HoursWorked) as TotalHours FROM LaborHours WHERE HoursWorked >= DATEADD(MONTH, -1, GETDATE()) GROUP BY State, Job ORDER BY TotalHours DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, project_id INT, name TEXT); INSERT INTO volunteers (id, project_id, name) VALUES (1, 1, 'Alice'), (2, 1, 'Bob'), (3, 2, 'Charlie'); CREATE TABLE projects (id INT, funder TEXT, total_funding DECIMAL); INSERT INTO projects (id, funder, total_funding) VALUES (1, 'European Union', 20000.00), (2, 'World Bank', 30000.00);
|
How many total volunteers have there been in projects funded by the World Bank?
|
SELECT COUNT(*) FROM volunteers INNER JOIN projects ON volunteers.project_id = projects.id WHERE projects.funder = 'World Bank';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City (CityName VARCHAR(50), Country VARCHAR(50), Population INT); INSERT INTO City (CityName, Country, Population) VALUES ('Tokyo', 'Japan', 9000000), ('Yokohama', 'Japan', 3700000), ('Osaka', 'Japan', 2700000), ('Nagoya', 'Japan', 2300000), ('Sapporo', 'Japan', 1900000);
|
What is the population rank of Tokyo in Japan?
|
SELECT ROW_NUMBER() OVER (PARTITION BY Country ORDER BY Population DESC) AS PopulationRank, CityName, Population FROM City WHERE Country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WeatherStation (id INT, name TEXT, location TEXT, temperature REAL); INSERT INTO WeatherStation (id, name, location, temperature) VALUES (1, 'Station1', 'Location1', 20.5), (2, 'Station2', 'Location2', 22.3), (3, 'Station3', 'Location3', 19.8);
|
What is the average temperature in degree Celsius for each month in 2020 across all weather stations?
|
SELECT AVG(temperature) as avg_temperature, EXTRACT(MONTH FROM timestamp) as month FROM WeatherData WHERE EXTRACT(YEAR FROM timestamp) = 2020 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (artwork_id INT, artist_id INT, artwork_name TEXT, rating INT, num_reviews INT); INSERT INTO Artworks (artwork_id, artist_id, artwork_name, rating, num_reviews) VALUES (1, 101, 'Painting 1', 8, 30), (2, 101, 'Painting 2', 9, 50), (3, 102, 'Sculpture 1', 7, 25); CREATE TABLE ArtistDetails (artist_id INT, artist_name TEXT); INSERT INTO ArtistDetails (artist_id, artist_name) VALUES (101, 'John Doe'), (102, 'Jane Smith');
|
Find the average rating and total number of reviews for artworks by artist 101, and the name and rating of the artwork with the highest rating among artist 101's works.
|
SELECT AVG(a.rating) AS avg_rating, AVG(a.num_reviews) AS avg_reviews, ad.artist_name, (SELECT rating FROM Artworks WHERE artist_id = 101 ORDER BY rating DESC LIMIT 1) AS max_rating FROM Artworks a JOIN ArtistDetails ad ON a.artist_id = ad.artist_id WHERE a.artist_id = 101
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (id INT, name VARCHAR(255), department VARCHAR(255)); INSERT INTO Employees (id, name, department) VALUES (1, 'John Doe', 'DeptA'), (2, 'Jane Smith', NULL);
|
List all employees who have not been assigned to a department.
|
SELECT name FROM Employees WHERE department IS NULL
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles (article_id INT, author VARCHAR(50), title VARCHAR(100), publication_date DATE, category VARCHAR(20)); INSERT INTO news_articles (article_id, author, title, publication_date, category) VALUES (1, 'John Doe', 'Article 1', '2022-01-01', 'Politics'), (2, 'Jane Smith', 'Article 2', '2022-01-02', 'Sports');
|
How many articles were published in each category on weekdays (Monday to Friday) and weekends (Saturday and Sunday) from the 'news_articles' table?
|
SELECT category, CASE WHEN DATEPART(dw, publication_date) IN (1, 7) THEN 'Weekend' ELSE 'Weekday' END as day_type, COUNT(*) as article_count FROM news_articles GROUP BY category, CASE WHEN DATEPART(dw, publication_date) IN (1, 7) THEN 'Weekend' ELSE 'Weekday' END;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TVShows (show_id INT, title VARCHAR(255), release_date DATE, genre VARCHAR(255), marketing_cost DECIMAL(5,2)); INSERT INTO TVShows (show_id, title, release_date, genre, marketing_cost) VALUES (1, 'Show1', '2019-10-01', 'Sci-Fi', 500000.00), (2, 'Show2', '2018-04-15', 'Comedy', 350000.00), (3, 'Show3', '2020-02-20', 'Action', 750000.00);
|
What are the total marketing costs for each TV show genre in Q1 2020?
|
SELECT genre, SUM(marketing_cost) FROM TVShows WHERE release_date >= '2020-01-01' AND release_date < '2020-04-01' GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.boats (id SERIAL PRIMARY KEY, name TEXT, speed FLOAT, city TEXT); INSERT INTO public.boats (name, speed, city) VALUES ('Electric Boat 1', 12.5, 'Vancouver'), ('Electric Boat 2', 13.6, 'Vancouver');
|
Update the name of all electric boats in Vancouver to reflect the new naming convention.
|
UPDATE public.boats SET name = REPLACE(name, 'Electric Boat', 'Vancouver Electric Boat') WHERE city = 'Vancouver';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE unions (id INT, name TEXT, industry TEXT, workers_represented INT); INSERT INTO unions (id, name, industry, workers_represented) VALUES (1, 'Unite Here', 'Service', 300000);
|
What is the total number of workers represented by labor unions in the service sector?
|
SELECT SUM(workers_represented) FROM unions WHERE industry = 'Service';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerActivity (player_id INT, game VARCHAR(100), hours INT, week INT); INSERT INTO PlayerActivity (player_id, game, hours, week) VALUES (1, 'Fortnite', 15, 1), (2, 'Fortnite', 20, 2), (3, 'Minecraft', 10, 1);
|
What is the maximum number of hours played in a week for players who have played "Fortnite" and are from Germany?
|
SELECT MAX(hours) FROM PlayerActivity pa WHERE pa.game = 'Fortnite' AND pa.week IN (1, 2) AND EXISTS (SELECT 1 FROM Players p WHERE p.player_id = pa.player_id AND p.country = 'Germany');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnvironmentalImpact(id INT, country VARCHAR(50), year INT, score FLOAT); CREATE TABLE CountryPopulation(id INT, country VARCHAR(50), population INT);
|
List of countries with the highest environmental impact score in the past year.
|
SELECT country, score FROM (SELECT country, score, ROW_NUMBER() OVER (ORDER BY score DESC) as rank FROM EnvironmentalImpact WHERE year = YEAR(CURRENT_DATE) - 1) AS subquery WHERE rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE urban_area_1 (farmer_id INTEGER, crops_organic BOOLEAN); INSERT INTO urban_area_1 (farmer_id, crops_organic) VALUES (1, true), (2, false), (3, true), (4, true), (5, false);
|
How many farmers in 'urban_area_1' produce organic crops?
|
SELECT COUNT(*) FROM urban_area_1 WHERE crops_organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (ArtworkID INT, Name VARCHAR(100), Artist VARCHAR(100), Year INT);
|
Which artists have works in the Met and MoMA?
|
SELECT Artworks.Artist FROM Artworks
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (ID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), City VARCHAR(50), State VARCHAR(20), ZipCode VARCHAR(10), RiskCategory VARCHAR(10)); CREATE TABLE Claims (ID INT, PolicyholderID INT, ClaimAmount DECIMAL(10,2), ClaimDate DATE);
|
Update the risk category of policyholders with a high claim amount to 'High Risk'.
|
UPDATE Policyholders SET RiskCategory = 'High Risk' WHERE ID IN (SELECT PolicyholderID FROM Claims WHERE ClaimAmount > (SELECT AVG(ClaimAmount) FROM Claims));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE alabama_rural_hospitals (hospital_id INT, hospital_name VARCHAR(255), rural BOOLEAN, num_beds INT); INSERT INTO alabama_rural_hospitals VALUES (1, 'Hospital A', true, 50), (2, 'Hospital B', false, 100);
|
What is the maximum number of hospital beds in rural hospitals in Alabama?
|
SELECT MAX(num_beds) FROM alabama_rural_hospitals WHERE rural = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug_name TEXT, approval_date DATE, therapy_area TEXT); INSERT INTO drug_approval (drug_name, approval_date, therapy_area) VALUES ('DrugE', '2018-01-01', 'Oncology'), ('DrugF', '2019-01-01', 'Oncology'), ('DrugG', '2020-01-01', 'Cardiology');
|
What is the average drug approval time for oncology drugs in the US?
|
SELECT AVG(DATEDIFF('2022-01-01', approval_date)) AS avg_approval_time FROM drug_approval WHERE therapy_area = 'Oncology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diagrams (id INT, name TEXT, process TEXT, engineer TEXT); INSERT INTO diagrams (id, name, process, engineer) VALUES (1, 'Diagram X', 'Fermentation', 'John Doe'); INSERT INTO diagrams (id, name, process, engineer) VALUES (2, 'Diagram Y', NULL, 'Jane Smith');
|
List all bioprocess engineering diagrams that do not have a process associated with them.
|
SELECT * FROM diagrams WHERE process IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (customer_id INT, gender VARCHAR(10), registration_date DATE); CREATE TABLE Orders (order_id INT, customer_id INT, order_date DATE); CREATE TABLE Order_Items (item_id INT, order_id INT, product_size VARCHAR(10)); INSERT INTO Customers (customer_id, gender, registration_date) VALUES (1, 'Female', '2020-01-01');
|
How many unique customers have purchased plus size clothing in the last year, by gender?
|
SELECT gender, COUNT(DISTINCT customer_id) as num_customers FROM Customers JOIN Orders ON Customers.customer_id = Orders.customer_id JOIN Order_Items ON Orders.order_id = Order_Items.order_id WHERE product_size = 'Plus' AND Orders.order_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE borough_crimes (borough VARCHAR(255), month VARCHAR(255), count INT); INSERT INTO borough_crimes (borough, month, count) VALUES ('Manhattan', 'Jan', 30), ('Manhattan', 'Feb', 40), ('Brooklyn', 'Jan', 35), ('Brooklyn', 'Feb', 45);
|
What is the total number of crimes committed in each borough per month?
|
SELECT borough, month, SUM(count) OVER (PARTITION BY borough, month) FROM borough_crimes;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE volunteers (id INT, name VARCHAR(50), program_id INT); INSERT INTO programs (id, name, location) VALUES (1, 'Education', 'Michigan'), (2, 'Environment', 'Illinois'); INSERT INTO volunteers (id, name, program_id) VALUES (1, 'Alice', 1), (2, 'Bob', 1), (3, 'Charlie', 2);
|
How many volunteers are needed for each program in the Midwest region?
|
SELECT p.name, COUNT(v.id) FROM programs p INNER JOIN volunteers v ON p.id = v.program_id WHERE p.location = 'Michigan' OR p.location = 'Illinois' GROUP BY p.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, financial_capability_score INT); INSERT INTO clients (client_id, financial_capability_score) VALUES (1, 8), (2, 5), (3, 10), (4, 7), (5, 3); CREATE TABLE investments (investment_id INT, client_id INT, is_shariah_compliant BOOLEAN, profit DECIMAL(10,2)); INSERT INTO investments (investment_id, client_id, is_shariah_compliant, profit) VALUES (1001, 1, true, 250), (1002, 1, false, 300), (1003, 2, true, 150), (1004, 3, true, 200), (1005, 3, false, 50), (1006, 4, true, 900), (1007, 5, true, 250);
|
Find the total profit from Shariah-compliant investments for clients with a high financial capability score?
|
SELECT SUM(investments.profit) FROM investments INNER JOIN clients ON investments.client_id = clients.client_id WHERE investments.is_shariah_compliant = true AND clients.financial_capability_score > 7;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates_china(location VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates_china(location, year, recycling_rate) VALUES ('Beijing', 2021, 0.78), ('Beijing', 2021, 0.79), ('Beijing', 2021, 0.80), ('Shanghai', 2021, 0.85), ('Shanghai', 2021, 0.86), ('Shanghai', 2021, 0.87);
|
What is the total recycling rate in percentage for industrial areas in Beijing for the year 2021?
|
SELECT AVG(recycling_rate) FROM recycling_rates_china WHERE location = 'Beijing' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_data (field VARCHAR(255), temperature FLOAT, timestamp TIMESTAMP);
|
Calculate the maximum temperature difference between consecutive days for 'Field_8' in the 'temperature_data' table.
|
SELECT field, MAX(temperature - LAG(temperature) OVER (PARTITION BY field ORDER BY timestamp)) as max_diff FROM temperature_data WHERE field = 'Field_8';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Autonomous_Vehicles (id INT, make VARCHAR(50), model VARCHAR(50), year INT, type VARCHAR(50), city VARCHAR(50));
|
How many autonomous buses are there in New York City?
|
SELECT COUNT(*) FROM Autonomous_Vehicles WHERE type = 'bus' AND city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_initiatives (initiative_id INT, site_id INT, initiative_date DATE, initiative_description TEXT); INSERT INTO pollution_initiatives (initiative_id, site_id, initiative_date, initiative_description) VALUES (1, 1, '2022-08-01', 'Installed new filters'), (2, 3, '2022-07-15', 'Regular cleaning schedule established');
|
Delete all pollution control initiatives before 2022.
|
DELETE FROM pollution_initiatives WHERE initiative_date < '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (name TEXT, agency TEXT, cost INTEGER);INSERT INTO SpaceMissions (name, agency, cost) VALUES ('Herschel Space Observatory', 'ESA', 1400000000); INSERT INTO SpaceMissions (name, agency, cost) VALUES ('Gaia Mission', 'ESA', 900000000);
|
What is the total cost of space missions by ESA?
|
SELECT SUM(cost) FROM SpaceMissions WHERE agency = 'ESA';
|
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.