context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE offenders (id INT PRIMARY KEY, name VARCHAR(255), age INT, state VARCHAR(2));
|
Delete the record of offender with id 2
|
DELETE FROM offenders WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE urban_farms (farmer_id INT, farmer_gender TEXT, area FLOAT); INSERT INTO urban_farms (farmer_id, farmer_gender, area) VALUES (1, 'Female', 12.3), (2, 'Male', 18.5), (3, 'Female', 21.7), (4, 'Male', 15.6);
|
What is the total number of urban farms operated by men and women in hectares?
|
SELECT SUM(area) FROM urban_farms;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatments (id INT PRIMARY KEY, patient_id INT, name VARCHAR(255), duration INT); INSERT INTO treatments (id, patient_id, name, duration) VALUES (9, 8, 'Exposure Therapy', 12);
|
Delete the treatment with ID 9.
|
DELETE FROM treatments WHERE id = 9;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (id INT, name VARCHAR(255), start_date DATE);
|
Add a new peacekeeping operation record for 'Operation Peace' in 'Country A' in 2022
|
INSERT INTO peacekeeping_operations (id, name, start_date) VALUES (1, 'Operation Peace', '2022-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policy_Advocacy (Fiscal_Year INT, Region VARCHAR(10), Expenditure DECIMAL(7,2)); INSERT INTO Policy_Advocacy VALUES (2022, 'Northeast', 50000.00), (2022, 'Southeast', 40000.00), (2023, 'Northeast', 55000.00), (2023, 'Southeast', 45000.00);
|
What is the policy advocacy effort rank by total expenditure per region, partitioned by fiscal year?
|
SELECT Fiscal_Year, Region, Expenditure, RANK() OVER (PARTITION BY Fiscal_Year ORDER BY Expenditure DESC) as Expenditure_Rank FROM Policy_Advocacy;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (WarehouseID INT, WarehouseName TEXT, Country TEXT); INSERT INTO Warehouse (WarehouseID, WarehouseName, Country) VALUES (1, 'Central Warehouse', 'USA'), (2, 'East Coast Warehouse', 'USA'), (3, 'Toronto Warehouse', 'Canada'), (4, 'Brisbane Warehouse', 'Australia'); CREATE TABLE FreightForwarder (FFID INT, FFName TEXT, Country TEXT); INSERT INTO FreightForwarder (FFID, FFName, Country) VALUES (1, 'Global Freight', 'USA'), (2, 'Northern Shipping', 'Canada'), (3, 'Pacific Logistics', 'Australia');
|
Identify countries having at least 2 warehouses and 1 freight forwarder?
|
SELECT Country FROM (SELECT Country, COUNT(DISTINCT WarehouseID) AS WarehouseCount, COUNT(DISTINCT FFID) AS FFCount FROM Warehouse GROUP BY Country) Subquery WHERE WarehouseCount > 1 AND FFCount > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE buses (id INT, city VARCHAR(20)); INSERT INTO buses (id, city) VALUES (1, 'Madrid'), (2, 'Barcelona'); CREATE TABLE bus_fares (id INT, bus_id INT, fare DECIMAL(5,2), fare_date DATE); INSERT INTO bus_fares (id, bus_id, fare, fare_date) VALUES (1, 1, 2.00, '2022-02-01'), (2, 1, 2.50, '2022-02-05'), (3, 2, 1.50, '2022-02-07');
|
What is the total fare collected for buses in the city of Madrid in the past month?
|
SELECT SUM(bf.fare) FROM bus_fares bf JOIN buses b ON bf.bus_id = b.id WHERE b.city = 'Madrid' AND bf.fare_date >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(255), rating FLOAT); INSERT INTO movies (id, title, genre, rating) VALUES (1, 'Movie1', 'Action', 7.5), (2, 'Movie2', 'Comedy', 8.2), (3, 'Movie3', 'Drama', 8.8);
|
What are the average ratings for movies by genre?
|
SELECT genre, AVG(rating) as avg_rating FROM movies GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_altitude (id INT, name VARCHAR(255), orbit_type VARCHAR(255), perigee_altitude FLOAT); CREATE VIEW highly_eccentric_orbits AS SELECT * FROM satellite_altitude WHERE orbit_type IN ('highly eccentric', 'highly elliptical');
|
What is the minimum perigee altitude of satellites in highly eccentric orbits?
|
SELECT MIN(perigee_altitude) FROM highly_eccentric_orbits;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE concert_sales (id INT, name VARCHAR, revenue DECIMAL);
|
Insert a new concert record with name 'Coachella' and revenue 1000000 into the concert_sales table.
|
INSERT INTO concert_sales (name, revenue) VALUES ('Coachella', 1000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (line VARCHAR(10), station VARCHAR(20)); INSERT INTO routes (line, station) VALUES ('Green', 'Station A'), ('Green', 'Station B'), ('Green', 'Station C'); CREATE TABLE fares (station VARCHAR(20), revenue DECIMAL(10, 2)); INSERT INTO fares (station, revenue) VALUES ('Station A', 2000), ('Station A', 2500), ('Station B', 3000), ('Station C', 1500), ('Station C', 1800);
|
Which station on the 'Green' line has the highest fare collection?
|
SELECT station, MAX(revenue) FROM fares WHERE station IN (SELECT station FROM routes WHERE line = 'Green') GROUP BY station;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT, social_equity_program BOOLEAN); INSERT INTO Dispensaries (id, name, state, social_equity_program) VALUES (1, 'Dispensary E', 'Arizona', true); INSERT INTO Dispensaries (id, name, state, social_equity_program) VALUES (2, 'Dispensary F', 'Arizona', true); CREATE TABLE Sales (sale_id INT, dispid INT, customer_id INT, total DECIMAL(10,2)); INSERT INTO Sales (sale_id, dispid, customer_id, total) VALUES (1, 1, 1001, 200); INSERT INTO Sales (sale_id, dispid, customer_id, total) VALUES (2, 1, 1001, 250); INSERT INTO Sales (sale_id, dispid, customer_id, total) VALUES (3, 2, 1002, 150);
|
Identify the number of unique customers and their total spending at each dispensary in Arizona with social equity programs.
|
SELECT d.name, COUNT(DISTINCT s.customer_id) as num_customers, SUM(s.total) as total_spending FROM Dispensaries d JOIN Sales s ON d.id = s.dispid WHERE d.state = 'Arizona' AND d.social_equity_program = true GROUP BY d.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), age INT, country VARCHAR(50), created_at TIMESTAMP); INSERT INTO users (id, name, age, country, created_at) VALUES (3, 'Charlie', 35, 'Mexico', '2021-01-03 12:00:00'), (4, 'Diana', 28, 'Brazil', '2021-01-04 13:00:00');
|
Calculate the average age of users from each country.
|
SELECT country, AVG(age) OVER (PARTITION BY country) as avg_age FROM users;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_data (location VARCHAR(50), region VARCHAR(20), pollution_level FLOAT, inspection_date DATE); INSERT INTO pollution_data (location, region, pollution_level, inspection_date) VALUES ('Location A', 'Arctic', 50.2, '2022-01-01'), ('Location B', 'Arctic', 70.1, '2022-02-15'), ('Location C', 'Antarctic', 30.9, '2022-03-01');
|
What is the maximum pollution level in the 'Arctic' region in the last year?'
|
SELECT MAX(pollution_level) FROM pollution_data WHERE region = 'Arctic' AND inspection_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cricket_world_cups (winner VARCHAR(255), year INT); INSERT INTO cricket_world_cups (winner, year) VALUES ('India', 2011);
|
Who won the ICC Cricket World Cup in 2011?
|
SELECT winner FROM cricket_world_cups WHERE year = 2011;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ethical_AI_Scores (country VARCHAR(255), score INT); INSERT INTO Ethical_AI_Scores (country, score) VALUES ('Sweden', 90), ('Norway', 85), ('Finland', 80), ('Denmark', 75), ('Germany', 70);
|
Which countries have the highest and lowest ethical AI scores?
|
SELECT country, score FROM Ethical_AI_Scores ORDER BY score DESC LIMIT 1; SELECT country, score FROM Ethical_AI_Scores ORDER BY score ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FlightRecords (ID INT, AircraftModel VARCHAR(50), FlightDate DATE, FlightHours INT); INSERT INTO FlightRecords (ID, AircraftModel, FlightDate, FlightHours) VALUES (1, 'B747', '2021-06-15', 10000), (2, 'B747', '2021-06-14', 9500), (3, 'B747', '2021-06-13', 9000), (4, 'A320', '2021-06-15', 7000), (5, 'A320', '2021-06-14', 6500), (6, 'A320', '2021-06-13', 6000), (7, 'A380', '2021-06-15', 12000), (8, 'A380', '2021-06-14', 11500), (9, 'A380', '2021-06-13', 11000);
|
Retrieve the latest 3 flight records for each aircraft model
|
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY AircraftModel ORDER BY FlightDate DESC) as RowNumber FROM FlightRecords) as FlightRecords WHERE RowNumber <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), country VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, country) VALUES (9, 'Toronto Union Station', 'Railway Station', 'Canada'), (10, 'Vancouver Pacific Central Station', 'Railway Station', 'Canada');
|
Show the railway stations in Canada
|
SELECT name FROM Infrastructure WHERE type = 'Railway Station' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup_funding (company_name VARCHAR(100), company_location VARCHAR(50), funding_amount DECIMAL(10,2), funding_date DATE, ceo_gender VARCHAR(10)); INSERT INTO startup_funding VALUES ('GenEase', 'CA', 500000.00, '2021-03-15', 'Female'); INSERT INTO startup_funding VALUES ('BioSynthetica', 'NY', 750000.00, '2020-12-28', 'Male'); INSERT INTO startup_funding VALUES ('NeuroNexus', 'TX', 300000.00, '2021-04-01', 'Female');
|
What is the total funding received by female-led biotech startups in the last 5 years?
|
SELECT SUM(funding_amount) FROM startup_funding WHERE ceo_gender = 'Female' AND funding_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 5 YEAR) AND CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists genetics; USE genetics; CREATE TABLE if not exists research_projects (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO research_projects (id, name, country) VALUES (1, 'Project X', 'UK'), (2, 'Project Y', 'UK'), (3, 'Project Z', 'USA');
|
List all genetic research projects in the UK.
|
SELECT * FROM genetics.research_projects WHERE country = 'UK';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, unpaid_balance DECIMAL(10, 2)); INSERT INTO mobile_subscribers (subscriber_id, unpaid_balance) VALUES (1, 45.20), (2, 0), (3, 75.00), (4, 30.50), (5, 120.75), (6, 25.33);
|
How many mobile subscribers have an unpaid balance greater than $50?
|
SELECT COUNT(*) FROM mobile_subscribers WHERE unpaid_balance > 50.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fairness_ai.ai_applications (ai_application_id INT PRIMARY KEY, ai_algorithm_id INT, application_name VARCHAR(255), fairness_score FLOAT); INSERT INTO fairness_ai.ai_applications (ai_application_id, ai_algorithm_id, application_name, fairness_score) VALUES (1, 1, 'AI-generated art', 0.8), (2, 1, 'AI-generated music', 0.75), (3, 2, 'AI-powered chatbot', 0.9), (4, 3, 'AI-powered self-driving car', 0.6); CREATE TABLE fairness_ai.ai_algorithms (ai_algorithm_id INT PRIMARY KEY, ai_algorithm VARCHAR(255)); INSERT INTO fairness_ai.ai_algorithms (ai_algorithm_id, ai_algorithm) VALUES (1, 'Generative Adversarial Networks'), (2, 'Transformers'), (3, 'Deep Reinforcement Learning');
|
How many AI applications are there in the 'fairness_ai' database, segmented by algorithm type?
|
SELECT f.ai_algorithm, COUNT(a.ai_application_id) as num_applications FROM fairness_ai.ai_applications a JOIN fairness_ai.ai_algorithms f ON a.ai_algorithm_id = f.ai_algorithm_id GROUP BY f.ai_algorithm;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'Biology'), (2, 'Mathematics'), (3, 'Sociology'); CREATE TABLE graduate_students (id INT, department_id INT, gender VARCHAR(10), num_publications INT); INSERT INTO graduate_students (id, department_id, gender, num_publications) VALUES (1, 1, 'Female', 10), (2, 1, 'Male', 15), (3, 2, 'Female', 20), (4, 2, 'Non-binary', 5), (5, 3, 'Male', 25), (6, 3, 'Female', 30);
|
What is the average number of publications per department?
|
SELECT d.name, AVG(gs.num_publications) FROM departments d JOIN graduate_students gs ON d.id = gs.department_id GROUP BY d.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_investments (investment_id INT, investment_type VARCHAR(20), investment_date DATE, state VARCHAR(20)); INSERT INTO infrastructure_investments (investment_id, investment_type, investment_date, state) VALUES (1, '5G tower', '2022-06-01', 'Florida');
|
Which network infrastructure investments were made in the last 6 months in Florida?
|
SELECT * FROM infrastructure_investments WHERE state = 'Florida' AND investment_date > DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_species (id, species, region) VALUES (1, 'Queen Angelfish', 'Caribbean'); INSERT INTO marine_species (id, species, region) VALUES (2, 'Elkhorn Coral', 'Caribbean');
|
What is the total number of marine species recorded in the Caribbean Sea?
|
SELECT COUNT(DISTINCT species) FROM marine_species WHERE region = 'Caribbean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE state_recycling (state VARCHAR(255), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO state_recycling (state, year, recycling_rate) VALUES ('California', 2021, 0.50);
|
What is the annual recycling rate for the state of California?
|
SELECT recycling_rate*100 FROM state_recycling WHERE state='California' AND year=2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, title VARCHAR(50), artist VARCHAR(50), movement VARCHAR(50), price DECIMAL(10,2)); INSERT INTO artworks (id, title, artist, movement, price) VALUES (1, 'Water Lilies', 'Claude Monet', 'impressionist', 84000000.00); INSERT INTO artworks (id, title, artist, movement, price) VALUES (2, 'The Starry Night', 'Vincent van Gogh', 'post-impressionist', 142000000.00); INSERT INTO artworks (id, title, artist, movement, price) VALUES (3, 'The Scream', 'Edvard Munch', 'expressionist', 119000000.00);
|
Who are the top 3 artists with the highest revenue from artwork sales in the impressionist movement?
|
SELECT artist, SUM(price) AS total_revenue FROM artworks WHERE movement = 'impressionist' GROUP BY artist ORDER BY total_revenue DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE social_good_organizations (org_id INT, region VARCHAR(20)); INSERT INTO social_good_organizations (org_id, region) VALUES (1, 'Asia'), (2, 'Africa'), (3, 'Asia'), (4, 'Europe');
|
What is the total number of organizations that have implemented technology for social good initiatives in Asia?
|
SELECT COUNT(*) FROM social_good_organizations WHERE region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_hospitals (hospital_id INT, beds INT, location VARCHAR(20));
|
What is the average number of beds in rural_hospitals for hospitals in the United States?
|
SELECT AVG(beds) FROM rural_hospitals WHERE location = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE buses (id INT, route_id INT, fare FLOAT); INSERT INTO buses (id, route_id, fare) VALUES (1, 101, 2.50), (2, 102, 3.25), (3, 103, 4.00);
|
What is the total fare collected from passengers on buses for the month of January 2022?
|
SELECT SUM(fare) FROM buses WHERE EXTRACT(MONTH FROM timestamp) = 1 AND EXTRACT(YEAR FROM timestamp) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (user_id INT, name VARCHAR(255)); CREATE TABLE planting_records (record_id INT, user_id INT, crop_type VARCHAR(255), planting_date DATE);
|
Find the top 5 users with the highest number of planting records in the past month.
|
SELECT u.name, COUNT(pr.record_id) as num_records FROM users u INNER JOIN planting_records pr ON u.user_id = pr.user_id WHERE pr.planting_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY u.name ORDER BY num_records DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE coal_production (country VARCHAR(20), quantity INT); INSERT INTO coal_production (country, quantity) VALUES ('Russia', 1200), ('Germany', 700), ('Poland', 900);
|
What is the total quantity of coal mined in Russia, Germany, and Poland?
|
SELECT country, SUM(quantity) FROM coal_production WHERE country IN ('Russia', 'Germany', 'Poland') GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (name TEXT, region TEXT); INSERT INTO marine_species (name, region) VALUES ('Species1', 'Arctic'); INSERT INTO marine_species (name, region) VALUES ('Species2', 'Atlantic');
|
Find all marine species that have been observed in both the Arctic and Atlantic regions
|
SELECT m1.name FROM marine_species m1 INNER JOIN marine_species m2 ON m1.name = m2.name WHERE m1.region = 'Arctic' AND m2.region = 'Atlantic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE weather (location VARCHAR(50), temperature INT, record_date DATE); INSERT INTO weather VALUES ('Seattle', 45, '2022-01-01'); INSERT INTO weather VALUES ('Seattle', 50, '2022-02-01'); INSERT INTO weather VALUES ('Seattle', 55, '2022-03-01'); INSERT INTO weather VALUES ('New York', 30, '2022-01-01'); INSERT INTO weather VALUES ('New York', 35, '2022-02-01'); INSERT INTO weather VALUES ('New York', 40, '2022-03-01');
|
What is the latest temperature recorded for each location in the 'weather' table?
|
SELECT location, MAX(temperature) AS latest_temp FROM weather GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, dish_id INT, order_date DATE, quantity INT, price FLOAT); INSERT INTO sales (id, dish_id, order_date, quantity, price) VALUES (1, 1, '2022-01-02', 2, 10.00), (2, 2, '2022-01-03', 1, 9.25), (3, 3, '2022-01-04', 3, 12.00), (4, 1, '2022-01-05', 1, 7.50), (5, 2, '2022-01-06', 4, 9.25), (6, 3, '2022-01-07', 2, 12.00);
|
Get the total revenue and profit for the month of January in the year 2022?
|
SELECT SUM(quantity * price) as revenue, SUM((quantity * price) - (quantity * (SELECT cost FROM ingredients WHERE dish_id = sales.dish_id LIMIT 1))) as profit FROM sales WHERE order_date BETWEEN '2022-01-01' AND '2022-01-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africa_attractions (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO africa_attractions VALUES (1, 'Victoria Falls', 'Zimbabwe', 2000000), (2, 'Mount Kilimanjaro', 'Tanzania', 50000), (3, 'Ngorongoro Crater', 'Tanzania', 300000);
|
Identify the top 3 most visited natural attractions in Africa and their respective visitor counts.
|
SELECT name, visitors FROM africa_attractions WHERE country = 'Tanzania' OR country = 'Zimbabwe' ORDER BY visitors DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eu_compounds (compound_id INT, compound_name TEXT, country TEXT, production_quantity INT); INSERT INTO eu_compounds (compound_id, compound_name, country, production_quantity) VALUES (1, 'Compound A', 'Germany', 8000), (2, 'Compound B', 'France', 9000), (3, 'Compound C', 'Italy', 7000), (4, 'Compound D', 'Spain', 6000);
|
What are the maximum and minimum production quantities (in kg) for chemical compounds in the European Union, grouped by country?
|
SELECT country, MAX(production_quantity) as max_production, MIN(production_quantity) as min_production FROM eu_compounds GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Field3_Temp (sensor_id INT, sensor_reading DATE); INSERT INTO Field3_Temp (sensor_id, sensor_reading) VALUES (1, '2022-06-15'), (2, '2022-06-15'), (3, '2022-06-15'), (4, '2022-06-14');
|
How many IoT sensors recorded data in "Field3" on June 15, 2022?
|
SELECT COUNT(DISTINCT sensor_id) FROM Field3_Temp WHERE sensor_reading = '2022-06-15';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data ( id INT PRIMARY KEY, year INT, refined_rare_earth_element TEXT, quantity INT );
|
Add the following new rare earth element to the production_data table: Gadolinium with a quantity of 450 from 2020
|
INSERT INTO production_data (id, year, refined_rare_earth_element, quantity) VALUES (5, 2020, 'Gadolinium', 450);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects (id INT, name TEXT, location TEXT, construction_cost FLOAT); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (1, 'Brooklyn Bridge', 'USA', 15000000); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (2, 'Chunnel', 'UK', 21000000); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (3, 'Tokyo Tower', 'Japan', 33000000); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (4, 'Millau Viaduct', 'France', 4000000); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (5, 'Seine Bridge', 'Canada', 7000000); INSERT INTO infrastructure_projects (id, name, location, construction_cost) VALUES (6, 'St. Lawrence Seaway', 'Canada', 4500000);
|
Delete projects in Canada with a construction cost less than 5 million
|
DELETE FROM infrastructure_projects WHERE location = 'Canada' AND construction_cost < 5000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue (id INT, category VARCHAR(20), revenue FLOAT, revenue_date DATE); INSERT INTO revenue (id, category, revenue, revenue_date) VALUES (1, 'Ecotourism', 50000, '2022-01-01'), (2, 'Ecotourism', 60000, '2022-01-02'), (3, 'Ecotourism', 55000, '2022-01-03');
|
What is the total revenue generated from ecotourism in Indonesia in Q1 2022?
|
SELECT SUM(revenue) FROM revenue WHERE category = 'Ecotourism' AND revenue_date BETWEEN '2022-01-01' AND DATE_ADD('2022-03-31', INTERVAL 1 DAY);
|
gretelai_synthetic_text_to_sql
|
INSERT INTO Community_Engagement (id, location, event_name, date, attendees) VALUES (1, 'New York', 'Art Exhibition', '2022-06-01', 600); INSERT INTO Community_Engagement (id, location, event_name, date, attendees) VALUES (2, 'Los Angeles', 'Music Festival', '2022-07-01', 400);
|
List all events with over 500 attendees, sorted by date.
|
SELECT * FROM Community_Engagement WHERE attendees > 500 ORDER BY date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_stats (visitor_country VARCHAR(255), continent VARCHAR(255)); INSERT INTO tourism_stats (visitor_country, continent) VALUES ('France', 'Europe');
|
Which continent has the most tourists visiting France?
|
SELECT continent, COUNT(*) FROM tourism_stats WHERE visitor_country = 'France' GROUP BY continent ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.buses (id SERIAL PRIMARY KEY, name TEXT, speed FLOAT, city TEXT); INSERT INTO public.buses (name, speed, city) VALUES ('Electric Bus 1', 35.5, 'Seattle'), ('Electric Bus 2', 36.7, 'Seattle');
|
What is the average speed of electric buses in Seattle?
|
SELECT AVG(speed) FROM public.buses WHERE city = 'Seattle' AND name LIKE 'Electric Bus%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_acidification (measurement_date DATE, location TEXT, level FLOAT); INSERT INTO ocean_acidification (measurement_date, location, level) VALUES ('2021-01-01', 'Australian Antarctic Division', 7.5); INSERT INTO ocean_acidification (measurement_date, location, level) VALUES ('2021-01-02', 'British Antarctic Survey', 7.6);
|
What is the maximum ocean acidification level recorded in the Southern Ocean, and which research station had this level?
|
SELECT research_station.station_name, oa.level AS max_level FROM ocean_acidification oa JOIN (SELECT location, MAX(level) AS max_level FROM ocean_acidification WHERE region = 'Southern Ocean' GROUP BY location) oa_max ON oa.level = oa_max.max_level JOIN research_stations research_station ON oa.location = research_station.station_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region (id INT, name VARCHAR(50)); CREATE TABLE expedition (id INT, name VARCHAR(50), region_id INT); INSERT INTO region (id, name) VALUES (1, 'Arctic'), (2, 'Antarctic'); INSERT INTO expedition (id, name, region_id) VALUES (1, 'Aurora Expedition', 1), (2, 'Antarctic Adventure', 2);
|
How many deep-sea expeditions ('expedition') have been conducted in the Arctic region ('region')?
|
SELECT COUNT(expedition.id) FROM expedition INNER JOIN region ON expedition.region_id = region.id WHERE region.name = 'Arctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE login_attempts (attempt_id INT, attempt_date DATE, user_account VARCHAR(100), source_ip VARCHAR(50));
|
What are the details of the 10 most recent unsuccessful login attempts, including the user account and the source IP address?
|
SELECT * FROM login_attempts WHERE attempt_result = 'unsuccessful' ORDER BY attempt_date DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grant (id INT, department VARCHAR(30), amount FLOAT, date DATE); INSERT INTO grant (id, department, amount, date) VALUES (1, 'Physics', 200000.00, '2021-01-01'), (2, 'Chemistry', 150000.00, '2020-07-14');
|
Show the total number of research grants awarded to each department, sorted by the total amount.
|
SELECT department, SUM(amount) as total_amount FROM grant GROUP BY department ORDER BY total_amount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtCollections (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE ArtPieces (id INT, collection_id INT, artist VARCHAR(255), title VARCHAR(255));
|
What is the number of art pieces in each collection by artist?
|
SELECT c.name, p.artist, COUNT(p.id) FROM ArtCollections c JOIN ArtPieces p ON c.id = p.collection_id GROUP BY c.name, p.artist;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Music_Albums (artist VARCHAR(255), release_year INT, gender VARCHAR(6)); INSERT INTO Music_Albums (artist, release_year, gender) VALUES ('Artist1', 2015, 'Female'), ('Artist2', 2016, 'Male'), ('Artist3', 2017, 'Female'), ('Artist4', 2018, 'Male'), ('Artist5', 2019, 'Female');
|
What is the release year of the first music album by a female artist?
|
SELECT release_year FROM Music_Albums WHERE gender = 'Female' ORDER BY release_year ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (state_id INT, state_name VARCHAR(255)); INSERT INTO states (state_id, state_name) VALUES (1, 'California'), (2, 'Texas'), (3, 'Florida'), (4, 'New York'); CREATE TABLE libraries (library_id INT, state_id INT); INSERT INTO libraries (library_id, state_id) VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 4);
|
How many public libraries are there in each state?
|
SELECT state_name, COUNT(*) FROM libraries JOIN states ON libraries.state_id = states.state_id GROUP BY state_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 70000.00), (2, 'Marketing', 55000.00), (3, 'Marketing', 58000.00), (4, 'HR', 60000.00), (5, 'HR', 62000.00);
|
Insert a new employee record with ID 6, department 'Diversity & Inclusion', and salary 75000.
|
INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (6, 'Diversity & Inclusion', 75000.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Developers (DeveloperId INT, DeveloperName VARCHAR(50), Country VARCHAR(50)); CREATE TABLE DigitalAssets (AssetId INT, AssetName VARCHAR(50), DeveloperId INT, MarketCap INT); INSERT INTO Developers (DeveloperId, DeveloperName, Country) VALUES (1, 'Carla', 'Mexico'); INSERT INTO Developers (DeveloperId, DeveloperName, Country) VALUES (2, 'Deepak', 'India'); INSERT INTO DigitalAssets (AssetId, AssetName, DeveloperId, MarketCap) VALUES (1, 'AssetA', 1, 2000000000); INSERT INTO DigitalAssets (AssetId, AssetName, DeveloperId, MarketCap) VALUES (2, 'AssetB', 2, 500000000); INSERT INTO DigitalAssets (AssetId, AssetName, DeveloperId, MarketCap) VALUES (3, 'AssetC', 1, 2500000000);
|
What are the countries of origin for developers who have created digital assets with a market cap greater than $1 billion?
|
SELECT d.Country FROM Developers d INNER JOIN DigitalAssets da ON d.DeveloperId = da.DeveloperId WHERE da.MarketCap > 1000000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name VARCHAR(100), maritime_law_code VARCHAR(100)); CREATE TABLE law_articles (id INT, country_id INT, article_number INT, text VARCHAR(1000));
|
Which countries have the most extensive maritime law coverage, as measured by the number of articles in their maritime law codes? Provide the top 5 countries and their corresponding law codes.
|
SELECT c.name, COUNT(la.article_number) as num_articles FROM countries c INNER JOIN law_articles la ON c.id = la.country_id GROUP BY c.name ORDER BY num_articles DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dams (ID INT, Name VARCHAR(50), Location VARCHAR(50), Length FLOAT, YearBuilt INT); INSERT INTO Dams (ID, Name, Location, Length, YearBuilt) VALUES (1, 'Hoover Dam', 'Nevada/Arizona border', 247.0, 1936); INSERT INTO Dams (ID, Name, Location, Length, YearBuilt) VALUES (2, 'Oroville Dam', 'Butte County, CA', 2302.0, 1968);
|
What is the name and ID of the dam in the 'Dams' table with the oldest construction date?
|
SELECT Name, ID FROM Dams WHERE YearBuilt = (SELECT MIN(YearBuilt) FROM Dams);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment_rounds (startup_id INT PRIMARY KEY, round_type VARCHAR(255), funding_amount FLOAT);
|
What is the average funding per round for series A rounds?
|
SELECT AVG(funding_amount) FROM investment_rounds WHERE round_type = 'series A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, name VARCHAR(50), artist_id INT, category VARCHAR(20)); CREATE TABLE artists (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO artworks (id, name, artist_id, category) VALUES (1, 'Painting', 1, 'painting'), (2, 'Sculpture', 2, 'sculpture'), (3, 'Drawing', 3, 'drawing'), (4, 'Painting', 1, 'painting'), (5, 'Painting', 2, 'painting'); INSERT INTO artists (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Bob Johnson');
|
Who is the most prolific artist in the 'painting' category?
|
SELECT artists.name, COUNT(*) AS num_artworks FROM artworks JOIN artists ON artworks.artist_id = artists.id WHERE artworks.category = 'painting' GROUP BY artists.name ORDER BY num_artworks DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinic_TX (patient_id INT, name VARCHAR(50), primary_diagnosis VARCHAR(50), treatment_type VARCHAR(50)); INSERT INTO clinic_TX (patient_id, name, primary_diagnosis, treatment_type) VALUES (1, 'John Doe', 'PTSD', 'EMDR'), (2, 'Jane Smith', 'PTSD', 'CBT'), (3, 'Alice Johnson', 'PTSD', 'EMDR');
|
What is the most common treatment type for patients with 'PTSD' in 'clinic_TX'?
|
SELECT treatment_type, COUNT(*) as count FROM clinic_TX WHERE primary_diagnosis = 'PTSD' GROUP BY treatment_type ORDER BY count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmos_hub_accounts (account_address VARCHAR(42), balance INTEGER);
|
Find the account address and balance for accounts with a balance greater than 500,000 on the Cosmos Hub blockchain.
|
SELECT account_address, balance FROM cosmos_hub_accounts WHERE balance > 500000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (id INT PRIMARY KEY, name VARCHAR(50), launch_year INT, country VARCHAR(50));
|
Insert a new satellite 'Tanpopo' launched by Japan in 2013 into the 'satellites' table
|
INSERT INTO satellites (id, name, launch_year, country) VALUES (6, 'Tanpopo', 2013, 'Japan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GadoliniumProduction (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO GadoliniumProduction (country, price, year) VALUES ('Japan', 150.00, 2019), ('Japan', 140.00, 2018);
|
What is the minimum price of gadolinium produced in Japan?
|
SELECT MIN(price) FROM GadoliniumProduction WHERE country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE industry_4_0_technologies (id INT PRIMARY KEY, region VARCHAR(255), technology_count INT, implementation_cost DECIMAL(6,2)); INSERT INTO industry_4_0_technologies (id, region, technology_count, implementation_cost) VALUES (1, 'Region A', 10, 5000), (2, 'Region B', 12, 4500), (3, 'Region C', 8, 5500), (4, 'Region D', 15, 4000), (5, 'Region E', 11, 4800);
|
Find the number of industry 4.0 technologies implemented in each region and the average implementation cost, sorted by the average cost in ascending order.
|
SELECT region, AVG(implementation_cost) as avg_cost FROM industry_4_0_technologies GROUP BY region ORDER BY avg_cost ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Trees (id INT, species VARCHAR(255), age INT); INSERT INTO Trees (id, species, age) VALUES (1, 'Oak', 50), (2, 'Pine', 30), (3, 'Maple', 40);
|
What is the average age of all the trees in the Trees table?
|
SELECT AVG(age) FROM Trees;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (attorney_id INT, name TEXT, region TEXT); INSERT INTO Attorneys (attorney_id, name, region) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'California'); CREATE TABLE Cases (case_id INT, attorney_id INT, billing_amount INT); INSERT INTO Cases (case_id, attorney_id, billing_amount) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000);
|
What is the maximum billing amount for cases handled by attorneys with the name 'John'?
|
SELECT MAX(Cases.billing_amount) FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.attorney_id WHERE Attorneys.name = 'John';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ads (ad_id INT, user_id INT, platform VARCHAR(255), ad_revenue DECIMAL(10,2)); INSERT INTO ads (ad_id, user_id, platform, ad_revenue) VALUES (1, 1, 'Facebook', 1500.50), (2, 2, 'Twitter', 800.00), (3, 3, 'Facebook', 1200.75);
|
What is the total revenue generated from ads on Facebook in Q2 2021, for users in the 'celebrity' category?
|
SELECT SUM(ad_revenue) FROM ads WHERE platform = 'Facebook' AND MONTH(ad_date) BETWEEN 4 AND 6 AND YEAR(ad_date) = 2021 AND user_id IN (SELECT user_id FROM users WHERE category = 'celebrity');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales (id INT PRIMARY KEY, region VARCHAR(20), year INT, equipment_name VARCHAR(30), quantity INT, value FLOAT); INSERT INTO military_sales (id, region, year, equipment_name, quantity, value) VALUES (1, 'Asia', 2022, 'Tank', 20, 10000000), (2, 'Asia', 2022, 'Helicopter', 15, 11000000), (3, 'Asia', 2022, 'Fighter Jet', 22, 16000000);
|
Update the value of all 'Tank' equipment sales records in 'Asia' to 15000000 for the year '2022'
|
UPDATE military_sales SET value = 15000000 WHERE region = 'Asia' AND equipment_name = 'Tank' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Investments (InvestmentID INT, Country VARCHAR(20), Amount INT); INSERT INTO Investments (InvestmentID, Country, Amount) VALUES (1, 'USA', 4000), (2, 'Canada', 3000), (3, 'Mexico', 5000), (4, 'Brazil', 6000), (5, 'USA', 7000), (6, 'Canada', 8000);
|
How many investments were made in each country?
|
SELECT Country, COUNT(*) as NumberOfInvestments FROM Investments GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_status (id INT, equipment_type VARCHAR(50), status VARCHAR(50), decommission_date DATE);
|
Which military equipment types have been decommissioned since 2010?
|
SELECT equipment_type FROM equipment_status WHERE status = 'Decommissioned' AND YEAR(decommission_date) >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), state VARCHAR(255), certification_level VARCHAR(255), carbon_offset_tons INT);
|
List the green building certifications and their corresponding carbon offset values for all buildings in the state of California.
|
SELECT certification_level, carbon_offset_tons FROM green_buildings WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FoodInspections (id INT PRIMARY KEY, facility_name VARCHAR(255), inspection_date DATE); INSERT INTO FoodInspections (id, facility_name, inspection_date) VALUES (1, 'Tasty Burgers', '2021-03-15'), (2, 'Fresh Greens', '2021-03-17'), (3, 'Pizza Palace', '2021-03-18'), (4, 'Tasty Burgers', '2021-03-19');
|
How many inspections were conducted at each facility?
|
SELECT facility_name, COUNT(*) FROM FoodInspections GROUP BY facility_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IF NOT EXISTS carbon_offset_initiatives ( initiative_id INT, initiative_name VARCHAR(255), co2_offset FLOAT, country VARCHAR(255), PRIMARY KEY (initiative_id)); INSERT INTO carbon_offset_initiatives (initiative_id, initiative_name, co2_offset, country) VALUES (1, 'Tree Planting', 50, 'USA'), (2, 'Solar Power Installation', 100, 'Canada'), (3, 'Wind Farm Development', 150, 'Mexico');
|
Which country has the maximum CO2 offset for carbon offset initiatives?
|
SELECT country, MAX(co2_offset) FROM carbon_offset_initiatives GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patient (patient_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patient (patient_id, name, age, gender, condition) VALUES (1, 'John Doe', 45, 'Male', 'Anxiety'), (2, 'Jane Smith', 35, 'Female', 'Depression'); CREATE TABLE treatment (treatment_id INT, patient_id INT, treatment_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO treatment (treatment_id, patient_id, treatment_name, start_date, end_date) VALUES (1, 1, 'Cognitive Behavioral Therapy', '2021-01-01', '2021-03-31'), (2, 2, 'Cognitive Behavioral Therapy', '2021-04-01', '2021-06-30');
|
How many patients have participated in the Cognitive Behavioral Therapy program in each year?
|
SELECT YEAR(start_date) AS year, COUNT(patient_id) AS num_patients FROM treatment WHERE treatment_name = 'Cognitive Behavioral Therapy' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (user_id INT, user_country VARCHAR(255)); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, stream_date DATE);
|
Find the number of unique users who have streamed a song on each day.
|
SELECT stream_date, COUNT(DISTINCT user_id) as unique_users FROM streams GROUP BY stream_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier (supplier_id INT, name VARCHAR(255), ethical_score INT); INSERT INTO supplier (supplier_id, name, ethical_score) VALUES (1, 'Green Supplies', 90), (2, 'Eco Distributors', 85), (3, 'Fair Trade Corp', 95);
|
Find the top 3 suppliers with the highest ethical labor score.
|
SELECT supplier_id, name, ethical_score FROM (SELECT supplier_id, name, ethical_score, RANK() OVER (ORDER BY ethical_score DESC) as rank FROM supplier) AS supplier_ranks WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, category VARCHAR(50), billing_amount INT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Civil Litigation', 7000);
|
Show the average billing amount for cases in the 'Personal Injury' category
|
SELECT AVG(billing_amount) FROM cases WHERE category = 'Personal Injury';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(30), is_aquaculture BOOLEAN); INSERT INTO species (id, name, is_aquaculture) VALUES (1, 'Salmon', true), (2, 'Shrimp', true), (3, 'Tuna', false), (4, 'Tilapia', true);
|
Count the number of seafood species in the aquaculture database.
|
SELECT COUNT(*) FROM species WHERE is_aquaculture = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, donor_name VARCHAR(255), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (id, donor_name, donation_amount, donation_date) VALUES (1, 'ABC Corporation', 300.00, '2021-07-10'), (2, 'XYZ Foundation', 400.00, '2021-10-01');
|
What was the total donation amount by organizations in India in Q3 2021?
|
SELECT SUM(donation_amount) FROM Donations WHERE donor_name LIKE '%India%' AND donation_date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE online_customers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), city VARCHAR(50)); INSERT INTO online_customers (id, name, age, gender, city) VALUES (1, 'Aisha Williams', 32, 'Female', 'Chicago'); INSERT INTO online_customers (id, name, age, gender, city) VALUES (2, 'Hiroshi Tanaka', 45, 'Male', 'Tokyo'); INSERT INTO online_customers (id, name, age, gender, city) VALUES (3, 'Clara Rodriguez', 29, 'Female', 'Madrid'); CREATE TABLE online_transactions (id INT, customer_id INT, type VARCHAR(50), amount DECIMAL(10,2), date DATE); INSERT INTO online_transactions (id, customer_id, type, amount, date) VALUES (1, 1, 'purchase', 50.00, '2021-01-01'); INSERT INTO online_transactions (id, customer_id, type, amount, date) VALUES (2, 1, 'refund', 10.00, '2021-01-05'); INSERT INTO online_transactions (id, customer_id, type, amount, date) VALUES (3, 2, 'purchase', 100.00, '2021-01-02');
|
What is the total number of transactions and their sum for each customer in the "online_customers" table?
|
SELECT o.customer_id, o.name, COUNT(ot.id) as total_transactions, SUM(ot.amount) as total_amount FROM online_customers o JOIN online_transactions ot ON o.id = ot.customer_id GROUP BY o.customer_id, o.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_heritage_sites (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), status VARCHAR(255));
|
Delete a cultural heritage site that no longer exists
|
DELETE FROM cultural_heritage_sites WHERE name = 'Temple of Bel' AND country = 'Iraq';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceans (ocean_name VARCHAR(50), avg_depth NUMERIC(10,2));
|
Add a new ocean 'Southern Pacific Ocean' with an average depth of 4000 meters.
|
INSERT INTO oceans (ocean_name, avg_depth) VALUES ('Southern Pacific Ocean', 4000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT NOT NULL, published_at DATE);
|
Get the total number of articles published per month, for the last 2 years
|
SELECT YEAR(published_at) as year, MONTH(published_at) as month, COUNT(id) as total_articles FROM articles WHERE published_at >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR) GROUP BY year, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_scooters (scooter_id INT, speed FLOAT, city VARCHAR(50));
|
What is the average speed of shared electric scooters in New York city?
|
SELECT AVG(speed) FROM shared_scooters WHERE city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geothermal_power_plants (name VARCHAR(50), location VARCHAR(50), capacity FLOAT, continent VARCHAR(50)); INSERT INTO geothermal_power_plants (name, location, capacity, continent) VALUES ('Plant E', 'USA', 1200, 'North America'), ('Plant F', 'Indonesia', 1500, 'Asia'), ('Plant G', 'Philippines', 900, 'Asia'), ('Plant H', 'Kenya', 700, 'Africa');
|
What is the average daily energy storage capacity (in MWh) for geothermal power plants, grouped by continent?
|
SELECT continent, AVG(capacity) as avg_capacity FROM geothermal_power_plants GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BrazilianReforestation (ID INT, Year INT, TreesPlanted INT); INSERT INTO BrazilianReforestation (ID, Year, TreesPlanted) VALUES (1, 2017, 10000), (2, 2018, 12000), (3, 2019, 15000), (4, 2020, 18000), (5, 2021, 20000);
|
What is the minimum number of trees planted in the Brazilian Amazon as part of reforestation projects in the last 5 years?
|
SELECT MIN(TreesPlanted) FROM BrazilianReforestation WHERE Year BETWEEN (SELECT YEAR(CURDATE()) - 5) AND YEAR(CURDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, worker_name TEXT, state TEXT, mental_health_score INT); INSERT INTO community_health_workers (worker_id, worker_name, state, mental_health_score) VALUES (1, 'John Doe', 'NY', 75), (2, 'Jane Smith', 'CA', 82), (3, 'Alice Johnson', 'TX', 68);
|
Identify the top 3 community health workers with the highest mental health scores in California.
|
SELECT * FROM community_health_workers WHERE state = 'CA' ORDER BY mental_health_score DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_vessels (vessel_id INTEGER, vessel_name TEXT, vessel_type TEXT, vessel_flag TEXT, coastline_length FLOAT);
|
What is the total number of research vessels registered in countries with a coastline of over 5000 kilometers, grouped by vessel type?
|
SELECT vessel_type, COUNT(vessel_id) FROM research_vessels WHERE coastline_length > 5000 GROUP BY vessel_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE areas (area_id INT, area_type TEXT);CREATE TABLE libraries (library_id INT, area_id INT, library_name TEXT);
|
Identify the total number of public libraries in urban areas
|
SELECT COUNT(*) FROM libraries l INNER JOIN areas a ON l.area_id = a.area_id WHERE a.area_type = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(255), inclusive BOOLEAN); INSERT INTO properties (id, city, inclusive) VALUES (1, 'Seattle', TRUE), (2, 'Seattle', FALSE), (3, 'Portland', TRUE), (4, 'Seattle', TRUE);
|
What is the total number of properties with inclusive housing units in the city of Seattle?
|
SELECT COUNT(*) FROM properties WHERE city = 'Seattle' AND inclusive = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, product VARCHAR(50), severity VARCHAR(10), quarter_year VARCHAR(10));
|
What is the distribution of vulnerabilities by severity for each product in the last quarter?
|
SELECT product, severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE quarter_year = DATEADD(quarter, -1, GETDATE()) GROUP BY product, severity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_power (country text, year integer, capacity integer);CREATE TABLE solar_power (country text, year integer, capacity integer);
|
What is the total installed capacity of wind and solar power plants in Germany and France, by year?
|
SELECT w.year, SUM(w.capacity + s.capacity) FROM wind_power w INNER JOIN solar_power s ON w.country = s.country AND w.year = s.year WHERE w.country IN ('Germany', 'France') GROUP BY w.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, dispensary_name VARCHAR(255), state VARCHAR(255), income DECIMAL(10, 2)); INSERT INTO Dispensaries (id, dispensary_name, state, income) VALUES (1, 'Sunshine State Dispensary', 'California', 150000.00); CREATE TABLE Cannabis_Inventory (id INT, dispensary_id INT, inventory_type VARCHAR(255), weight DECIMAL(10, 2), price DECIMAL(10, 2)); INSERT INTO Cannabis_Inventory (id, dispensary_id, inventory_type, weight, price) VALUES (1, 1, 'Outdoor', 10.00, 2500.00);
|
What is the average price of outdoor grown cannabis per pound in California dispensaries?
|
SELECT AVG(price / 16) as avg_price FROM Dispensaries d JOIN Cannabis_Inventory i ON d.id = i.dispensary_id WHERE d.state = 'California' AND i.inventory_type = 'Outdoor';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (drug_id VARCHAR(10), trial_status VARCHAR(10));
|
How many clinical trials were 'ONGOING' for drug 'D003'?
|
SELECT COUNT(*) FROM clinical_trials WHERE drug_id = 'D003' AND trial_status = 'ONGOING';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredient_sourcing (ingredient_name VARCHAR(255), sourcing_location VARCHAR(255), last_updated DATE); INSERT INTO ingredient_sourcing (ingredient_name, sourcing_location, last_updated) VALUES ('Neem', 'India', '2022-03-01'), ('Turmeric', 'India', '2022-02-15'), ('Sandalwood', 'India', '2022-04-05');
|
Which ingredients have been sourced from India for cosmetic products in the past year?
|
SELECT ingredient_name FROM ingredient_sourcing WHERE sourcing_location = 'India' AND last_updated >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Threat_Detection (ID INT, Month VARCHAR(50), Year INT, Threats INT); INSERT INTO Threat_Detection (ID, Month, Year, Threats) VALUES (1, 'January', 2020, 500), (2, 'February', 2020, 600), (3, 'March', 2020, 700);
|
What is the total number of cyber threats detected in the last 6 months?
|
SELECT Year, Month, SUM(Threats) FROM Threat_Detection WHERE Year = 2020 AND Month IN ('January', 'February', 'March', 'April', 'May', 'June') GROUP BY Year, Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonorNationality varchar(50), AmountDonated numeric(10,2), DonationYear int); INSERT INTO Donors (DonorID, DonorName, DonorNationality, AmountDonated, DonationYear) VALUES (1, 'James Smith', 'American', 600, 2021), (2, 'Aisha Khan', 'Pakistani', 400, 2021), (3, 'Park Ji-min', 'Indian', 500, 2021);
|
What is the average donation amount for donors from India?
|
SELECT AVG(AmountDonated) as AverageDonation FROM Donors WHERE DonorNationality = 'Indian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Atlanta Hawks'), (2, 'Boston Celtics'); CREATE TABLE fan_demographics (fan_id INT, team_id INT, gender VARCHAR(10)); INSERT INTO fan_demographics (fan_id, team_id, gender) VALUES (1, 1, 'Female'), (2, 1, 'Male'), (3, 2, 'Female'), (4, 2, 'Female');
|
Which team has the highest percentage of female fans?
|
SELECT t.team_name, 100.0 * COUNT(CASE WHEN fd.gender = 'Female' THEN 1 END) / COUNT(*) as pct_female_fans FROM teams t INNER JOIN fan_demographics fd ON t.team_id = fd.team_id GROUP BY t.team_name ORDER BY pct_female_fans DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (program_id INT, program_name VARCHAR(50), category VARCHAR(20)); CREATE TABLE Volunteer_Hours (volunteer_id INT, program_id INT, hours DECIMAL(5,2), volunteer_date DATE);
|
What was the total number of volunteer hours in environmental programs in Q1 2022?
|
SELECT SUM(hours) FROM Volunteer_Hours v JOIN Programs p ON v.program_id = p.program_id WHERE p.category = 'environmental' AND v.volunteer_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE maintenance (record_id INT, bus_id INT, year INT); INSERT INTO maintenance (record_id, bus_id, year) VALUES (1, 101, 2015), (2, 102, 2017), (3, 101, 2018), (4, 103, 2019);
|
Delete all maintenance records for buses older than 2018
|
DELETE FROM maintenance WHERE year < 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genetech', 'California', 12000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'Zymergen', 'California', 25000000);
|
Which biotech startups have the word 'gene' in their name?
|
SELECT name FROM startups WHERE name LIKE '%gene%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity_utilization(region VARCHAR(255), capacity_cu_m FLOAT, current_utilization FLOAT, current_date DATE);
|
What is the current landfill capacity utilization in percentage for each region?
|
SELECT region, current_utilization FROM landfill_capacity_utilization WHERE current_date = GETDATE();
|
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.