context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE cases (case_id INT, case_type VARCHAR(255)); INSERT INTO cases (case_id, case_type) VALUES (1, 'Civil'), (2, 'Criminal'), (3, 'Bankruptcy');
|
Delete all cases with a case type of 'Bankruptcy'.
|
DELETE FROM cases WHERE case_type = 'Bankruptcy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attacks (id INT, threat_actor VARCHAR(255), date DATE); INSERT INTO attacks (id, threat_actor, date) VALUES (1, 'APT28', '2022-01-01'); INSERT INTO attacks (id, threat_actor, date) VALUES (2, 'APT33', '2022-01-02');
|
Identify the top 5 threat actors with the highest number of attacks in the last quarter
|
SELECT threat_actor, COUNT(*) as num_attacks FROM attacks WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY threat_actor ORDER BY num_attacks DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (facility_id INT, condition VARCHAR(50));
|
List mental health conditions treated in a given facility.
|
SELECT condition FROM facilities WHERE facility_id = 123;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transaction_Types (id INT PRIMARY KEY, tx_type VARCHAR(50)); INSERT INTO Transaction_Types (id, tx_type) VALUES (1, 'deposit'); INSERT INTO Transaction_Types (id, tx_type) VALUES (2, 'withdrawal');
|
Who has conducted transactions with both deposit and withdrawal types?
|
SELECT u.name FROM Users u INNER JOIN Transactions t ON u.id = t.user_id INNER JOIN Transaction_Types tt1 ON t.tx_type = tt1.tx_type INNER JOIN Transaction_Types tt2 ON u.id = tt2.user_id WHERE tt1.id = 1 AND tt2.id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Advocacy (id INT, location VARCHAR(50), start_date DATE, sector VARCHAR(50));
|
How many advocacy projects were started in 'Africa' in each quarter of 2021?
|
SELECT DATEPART(YEAR, start_date) as year, DATEPART(QUARTER, start_date) as quarter, COUNT(id) as num_projects FROM Advocacy WHERE location = 'Africa' AND YEAR(start_date) = 2021 GROUP BY year, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE socially_responsible_loans (loan_id INT, loan_date DATE); INSERT INTO socially_responsible_loans (loan_id, loan_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-03-28'), (4, '2022-04-12');
|
Display the number of socially responsible loans issued per month in 2022, with months in ascending order.
|
SELECT DATE_FORMAT(loan_date, '%Y-%m') AS loan_month, COUNT(loan_id) AS loans_issued FROM socially_responsible_loans WHERE YEAR(loan_date) = 2022 GROUP BY loan_month ORDER BY loan_month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceLaunchs (LaunchID INT, Country VARCHAR(50), SatelliteID INT); INSERT INTO SpaceLaunchs (LaunchID, Country, SatelliteID) VALUES (1, 'USA', 101), (2, 'Russia', 201), (3, 'China', 301), (4, 'India', 401), (5, 'Japan', 501); CREATE TABLE SatelliteOrbits (SatelliteID INT, OrbitType VARCHAR(50), OrbitHeight INT); INSERT INTO SatelliteOrbits (SatelliteID, OrbitType, OrbitHeight) VALUES (101, 'LEO', 500), (201, 'MEO', 8000), (301, 'GEO', 36000), (401, 'LEO', 600), (501, 'MEO', 10000);
|
What is the total number of satellites for each country, based on the SpaceLaunchs and SatelliteOrbits tables?
|
SELECT s.Country, COUNT(so.SatelliteID) AS TotalSatellites FROM SpaceLaunchs s JOIN SatelliteOrbits so ON s.SatelliteID = so.SatelliteID GROUP BY s.Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy (initiative_id INT, initiative_name TEXT, initiative_status TEXT, country1 TEXT, country2 TEXT); INSERT INTO defense_diplomacy (initiative_id, initiative_name, initiative_status, country1, country2) VALUES (1, 'Joint Military Exercise', 'Planning', 'India', 'Pakistan'), (2, 'Defense Technology Exchange', 'Completed', 'India', 'Pakistan');
|
What is the current status of all defense diplomacy initiatives between India and Pakistan?
|
SELECT defense_diplomacy.initiative_status FROM defense_diplomacy WHERE defense_diplomacy.country1 = 'India' AND defense_diplomacy.country2 = 'Pakistan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE strains (id INT, name TEXT, dispensary_id INT, last_sale_date DATE); INSERT INTO strains (id, name, dispensary_id, last_sale_date) VALUES (1, 'Purple Haze', 1, '2022-02-15'), (2, 'Sour Diesel', 2, '2022-03-20'), (3, 'Bubba Kush', 3, NULL); CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Pure Meds', 'Colorado'), (2, 'Bud Depot', 'Colorado'), (3, 'Green Therapy', 'Colorado');
|
Delete strains from CO dispensaries that have not been sold in the last 6 months
|
DELETE s FROM strains s JOIN dispensaries d ON s.dispensary_id = d.id WHERE d.state = 'Colorado' AND s.last_sale_date < NOW() - INTERVAL 6 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT, price FLOAT, neighborhood VARCHAR(20));
|
What is the average property price in each neighborhood?
|
SELECT neighborhood, AVG(price) FROM property GROUP BY neighborhood;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50)); INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob'); CREATE TABLE posts (id INT, user_id INT, content TEXT, timestamp DATETIME); INSERT INTO posts (id, user_id, content, timestamp) VALUES (1, 1, 'I like this', '2022-01-01 10:00:00'), (2, 1, 'I dislike that', '2022-01-02 11:00:00'), (3, 2, 'I like it', '2022-01-03 12:00:00');
|
Find users who have more posts with 'like' in the content than posts with 'dislike' in the content, and the total number of such posts.
|
SELECT users.name, COUNT(*) as num_posts FROM users INNER JOIN posts ON users.id = posts.user_id WHERE posts.content LIKE '%like%' AND posts.id NOT IN (SELECT posts.id FROM posts WHERE posts.content LIKE '%dislike%') GROUP BY users.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indigenous_arts (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), market_value INT, PRIMARY KEY(id)); INSERT INTO indigenous_arts (id, name, location, type, market_value) VALUES (1, 'Navajo Rugs', 'USA', 'Textile', 1000), (2, 'Zapotec Weavings', 'Mexico', 'Textile', 800), (3, 'Inuit Sculptures', 'Canada', 'Sculpture', 1200), (4, 'Mapuche Silverwork', 'Chile', 'Metalwork', 1500);
|
Which indigenous arts and crafts from the Americas have the highest market value?
|
SELECT i.name, i.location, i.type, MAX(i.market_value) AS highest_market_value FROM indigenous_arts i WHERE i.location LIKE '%America%' GROUP BY i.name, i.location, i.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transit (id INT, goods_id INT, weight INT, origin_region VARCHAR(50), destination_country VARCHAR(50), transportation_mode VARCHAR(50)); INSERT INTO transit (id, goods_id, weight, origin_region, destination_country, transportation_mode) VALUES (1, 101, 25, 'East Asia', 'Kenya', 'Air'), (2, 102, 35, 'South Asia', 'Ghana', 'Sea'), (3, 103, 45, 'Central Asia', 'Morocco', 'Rail');
|
What is the total weight of goods in transit on each route, segmented by the destination country and the transportation mode?
|
SELECT origin_region, destination_country, transportation_mode, SUM(weight) as total_weight FROM transit GROUP BY origin_region, destination_country, transportation_mode;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_ethics_guidelines (company_name VARCHAR(50), guideline TEXT, last_reviewed DATETIME);
|
Add a new row to the 'ai_ethics_guidelines' table with the following data: 'Company A', 'Ensure data privacy and security', '2021-03-15'
|
INSERT INTO ai_ethics_guidelines (company_name, guideline, last_reviewed) VALUES ('Company A', 'Ensure data privacy and security', '2021-03-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourists(tourist_id INT, name TEXT, country_visited TEXT, stay_duration INT);CREATE TABLE stays(stay_id INT, tourist_id INT, hotel_id INT, check_in DATE, check_out DATE);CREATE TABLE hotels(hotel_id INT, name TEXT, star_rating INT);INSERT INTO tourists (tourist_id, name, country_visited, stay_duration) VALUES (1, 'John Doe', 'New Zealand', 5), (2, 'Jane Doe', 'Australia', 7); INSERT INTO stays (stay_id, tourist_id, hotel_id, check_in, check_out) VALUES (1, 1, 1, '2020-01-01', '2020-01-05'), (2, 1, 2, '2020-01-06', '2020-01-08'), (3, 2, 3, '2020-01-01', '2020-01-03'); INSERT INTO hotels (hotel_id, name, star_rating) VALUES (1, 'Hotel X', 5), (2, 'Hotel Y', 4), (3, 'Hotel Z', 5);
|
How many tourists visited New Zealand in 2020 who stayed in 5-star hotels?
|
SELECT COUNT(*) FROM tourists INNER JOIN stays ON tourists.tourist_id = stays.tourist_id INNER JOIN hotels ON stays.hotel_id = hotels.hotel_id WHERE hotels.star_rating = 5 AND tourists.country_visited = 'New Zealand' AND stays.check_out <= '2020-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, age INT, gender TEXT); INSERT INTO users (id, age, gender) VALUES ('1', '25', 'Female'), ('2', '35', 'Male'), ('3', '45', 'Non-binary');
|
How many users are there in each gender category?
|
SELECT gender, COUNT(*) as count FROM users GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ticket_sales (ticket_id INT, game_id INT, home_team VARCHAR(20), away_team VARCHAR(20), price DECIMAL(5,2), quantity INT);
|
Find the number of tickets sold per game for the home_team in the ticket_sales table.
|
SELECT home_team, COUNT(*) as num_tickets_sold FROM ticket_sales GROUP BY home_team;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, patient_name TEXT, age INT, diagnosis TEXT, state TEXT); INSERT INTO patients (patient_id, patient_name, age, diagnosis, state) VALUES (1, 'John Doe', 65, 'Diabetes', 'Texas');
|
What is the average age of patients who have been diagnosed with diabetes in the rural areas of Texas?
|
SELECT AVG(age) FROM patients WHERE diagnosis = 'Diabetes' AND state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers_professional_development (teacher_id INT, subject_area VARCHAR(255), hours_per_week_pd INT);
|
What is the average number of hours teachers spent on professional development per week, grouped by subject area, from the "teachers_professional_development" table?
|
SELECT subject_area, AVG(hours_per_week_pd) as avg_hours_pd FROM teachers_professional_development GROUP BY subject_area;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OpenPedagogyCourses (CourseID INT PRIMARY KEY, CourseName VARCHAR(100), StartDate DATE, EndDate DATE, Enrollment INT);
|
Create a table for storing information about open pedagogy courses
|
CREATE TABLE OpenPedagogyCourses (CourseID INT PRIMARY KEY, CourseName VARCHAR(100), StartDate DATE, EndDate DATE, Enrollment INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE communitydev.initiatives (id INT, initiative_name VARCHAR(50), community_type VARCHAR(50), start_year INT); INSERT INTO communitydev.initiatives (id, initiative_name, community_type, start_year) VALUES (1, 'Cultural Center', 'Indigenous', 2005), (2, 'Health Clinic', 'Urban', 2017), (3, 'Agricultural Training', 'Rural', 2012), (4, 'Language School', 'Indigenous', 2008), (5, 'Community Kitchen', 'Urban', 2015);
|
How many community development initiatives were implemented in the 'communitydev' schema in indigenous communities before 2010?
|
SELECT COUNT(*) FROM communitydev.initiatives WHERE community_type = 'Indigenous' AND start_year < 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE yoga_classes (id INT, user_id INT, heart_rate INT); INSERT INTO yoga_classes (id, user_id, heart_rate) VALUES (1, 1, 85), (2, 1, 80), (3, 2, 90), (4, 2, 95), (5, 3, 75); CREATE TABLE users (id INT, experience INT); INSERT INTO users (id, experience) VALUES (1, 6), (2, 7), (3, 4);
|
What is the maximum heart rate recorded during yoga sessions, for users with more than 5 years of experience?
|
SELECT MAX(heart_rate) FROM yoga_classes INNER JOIN users ON yoga_classes.user_id = users.id WHERE users.experience > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE match_stats (id INT, team TEXT, spectators INT, home INT); INSERT INTO match_stats (id, team, spectators, home) VALUES (1, 'Real Madrid', 75000, 1), (2, 'Barcelona', 65000, 1), (3, 'Atletico Madrid', 55000, 1), (4, 'Real Madrid', 76000, 0), (5, 'Barcelona', 64000, 0), (6, 'Atletico Madrid', 56000, 0);
|
What is the average number of spectators in the last 2 home games for each team?
|
SELECT team, AVG(spectators) FROM match_stats WHERE home = 1 GROUP BY team HAVING season >= 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE all_departments (dept_name TEXT, record_count INTEGER); INSERT INTO all_departments (dept_name, record_count) VALUES ('Human Services Department', 60), ('Education Department', 45), ('Health Department', 52), ('Library Department', 40), ('Transportation Department', 65);
|
Which departments have more than 50 records?
|
SELECT dept_name FROM all_departments WHERE record_count > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT PRIMARY KEY, company_id INT, round_type VARCHAR(255), amount FLOAT, year INT, FOREIGN KEY (company_id) REFERENCES companies(id));
|
Add an investment round for 'Ada Ventures' with 'Series A', '$10M', and '2021'
|
INSERT INTO investments (id, company_id, round_type, amount, year) VALUES (1, 1, 'Series A', 10000000.0, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), conservation_status VARCHAR(100)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1, 'Clownfish', 'Least Concern'), (2, 'Green Sea Turtle', 'Endangered'), (3, 'Whale Shark', 'Vulnerable'), (4, 'Manta Ray', 'Vulnerable'), (5, 'Sea Otter', 'Endangered');
|
What is the number of marine species with a conservation status of 'Vulnerable' or 'Endangered'?
|
SELECT COUNT(*) FROM marine_species WHERE conservation_status IN ('Vulnerable', 'Endangered');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genre_streams (genre VARCHAR(10), stream_count BIGINT);
|
Show the total number of streams for each genre, excluding classical music, in a single query.
|
SELECT genre, SUM(stream_count) FROM genre_streams WHERE genre != 'classical' GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cerium_Production (id INT, year INT, country VARCHAR(255), quantity FLOAT);
|
What is the total quantity of Cerium produced in Nigeria and South Africa in 2016?
|
SELECT SUM(quantity) FROM Cerium_Production WHERE year = 2016 AND country IN ('Nigeria', 'South Africa');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EquipmentSales (id INT, region VARCHAR(50), country VARCHAR(50), sale_year INT, equipment VARCHAR(50), amount INT);CREATE TABLE ProjectTimelines (id INT, equipment VARCHAR(50), start_year INT, end_year INT);
|
What are the military equipment sales and their corresponding project timelines for the Middle East region in the year 2022, and for which countries are these sales?
|
SELECT EquipmentSales.country, EquipmentSales.equipment, EquipmentSales.sale_year, EquipmentSales.amount, ProjectTimelines.start_year, ProjectTimelines.end_year FROM EquipmentSales INNER JOIN ProjectTimelines ON EquipmentSales.equipment = ProjectTimelines.equipment WHERE EquipmentSales.region = 'Middle East' AND EquipmentSales.sale_year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, EmploymentStatus VARCHAR(10), Salary INT, Gender VARCHAR(10)); INSERT INTO Employees (EmployeeID, EmploymentStatus, Salary, Gender) VALUES (1, 'Full-time', 50000, 'Male'), (2, 'Full-time', 55000, 'Female'), (3, 'Part-time', 30000, 'Male');
|
What is the average salary of full-time employees by gender?
|
SELECT Gender, AVG(Salary) FROM Employees WHERE EmploymentStatus = 'Full-time' GROUP BY Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cba(id INT, sector VARCHAR(50), country VARCHAR(14), signing_date DATE);INSERT INTO cba(id, sector, country, signing_date) VALUES (1, 'Technology', 'Canada', '2020-02-01'), (2, 'Technology', 'Mexico', '2019-08-15'), (3, 'Technology', 'United States', '2021-03-10'), (4, 'Technology', 'Brazil', '2018-11-28');
|
List the collective bargaining agreements in the technology sector that were signed in the last 3 years, excluding those from the United States.
|
SELECT * FROM cba WHERE sector = 'Technology' AND country != 'United States' AND signing_date >= (SELECT DATE_SUB(CURDATE(), INTERVAL 3 YEAR))
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(50), publish_date DATE); INSERT INTO articles (id, title, publish_date) VALUES (1, 'Article1', '2022-06-01'), (2, 'Article2', '2022-06-15'), (3, 'Article3', '2022-05-30');
|
How many articles were published per day in the month of June 2022?
|
SELECT DATE_FORMAT(publish_date, '%Y-%m-%d') as publish_date, COUNT(*) as articles_per_day FROM articles WHERE publish_date >= '2022-06-01' AND publish_date < '2022-07-01' GROUP BY publish_date
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_observations (id INT, species VARCHAR(255), year INT, month INT, region VARCHAR(255)); INSERT INTO marine_species_observations (id, species, year, month, region) VALUES (1, 'Sea otter', 2017, 1, 'Pacific'); INSERT INTO marine_species_observations (id, species, year, month, region) VALUES (2, 'California sea lion', 2018, 2, 'Pacific');
|
What is the total number of marine species observed in the Pacific Ocean in 2018, grouped by month?
|
SELECT month, COUNT(*) as total_observations FROM marine_species_observations WHERE region = 'Pacific' AND year = 2018 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), country VARCHAR(255), cost FLOAT, launch_status VARCHAR(10)); INSERT INTO space_missions (id, mission_name, country, cost, launch_status) VALUES (1, 'Apollo 11', 'USA', 25500000, 'Success'), (2, 'Mars Orbiter Mission', 'India', 73000000, 'Success'), (3, 'Chandrayaan-1', 'India', 79000000, 'Success'), (4, 'Grail', 'USA', 496000000, 'Success'), (5, 'Mars Express', 'Europe', 154000000, 'Success'), (6, 'Venus Express', 'Europe', 22000000, 'Failure'), (7, 'Hayabusa', 'Japan', 15000000, 'Success'), (8, 'Akatsuki', 'Japan', 17000000, 'Failure');
|
What was the cost of space missions that were not successful?
|
SELECT SUM(cost) FROM space_missions WHERE launch_status != 'Success';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE court_cases (case_id INT, court_date DATE); INSERT INTO court_cases (case_id, court_date) VALUES (1, '2022-01-01'), (2, '2021-12-20'), (3, '2022-02-15'); CREATE TABLE defendant_info (defendant_id INT, case_id INT, age INT, gender VARCHAR(50)); INSERT INTO defendant_info (defendant_id, case_id, age, gender) VALUES (1, 1, 35, 'Male'), (2, 2, 27, 'Female'), (3, 1, 42, 'Non-binary'), (4, 3, 19, 'Female'), (5, 3, 50, 'Male'), (6, 1, 32, 'Male'), (7, 2, 25, 'Male'), (8, 3, 45, 'Male');
|
What is the difference in age between the oldest and youngest defendant in each court case?
|
SELECT case_id, MAX(age) - MIN(age) as age_diff FROM defendant_info GROUP BY case_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_prices (id INT, country VARCHAR(50), price FLOAT); INSERT INTO carbon_prices (id, country, price) VALUES (1, 'Germany', 25), (2, 'France', 30), (3, 'Italy', 28), (4, 'Spain', 22);
|
Determine the average carbon price (€/t) in the European Union
|
SELECT AVG(price) FROM carbon_prices WHERE country IN ('Germany', 'France', 'Italy', 'Spain');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs_data (program_id INT, program_name VARCHAR(50), funding_source VARCHAR(50)); INSERT INTO programs_data (program_id, program_name, funding_source) VALUES (1, 'Green Jobs', 'Federal Government'), (2, 'Renewable Energy', 'Provincial Government'), (3, 'Sustainable Agriculture', 'Private Sector');
|
List the names of economic diversification programs in the 'programs_data' table and their respective funding sources.
|
SELECT program_name, funding_source FROM programs_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, exhibition_name TEXT, artist_id INT, num_works INT); INSERT INTO Exhibitions (exhibition_id, exhibition_name, artist_id, num_works) VALUES (1, 'Modern Art Museum', 101, 5), (2, 'Modern Art Museum', 102, 3), (3, 'Contemporary Art Gallery', 101, 4);
|
List all exhibitions with the total number of artworks and the number of artists who have exhibited more than 3 works in each exhibition.
|
SELECT e.exhibition_name, COUNT(DISTINCT e.artist_id) AS num_artists, COUNT(e.artwork_id) AS total_artworks, SUM(CASE WHEN e.num_works > 3 THEN 1 ELSE 0 END) AS num_prolific_artists FROM Exhibitions e GROUP BY e.exhibition_name
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (id INT, name TEXT, country TEXT, water_consumption DECIMAL(5,2)); INSERT INTO Factories (id, name, country, water_consumption) VALUES (1, 'Factory A', 'USA', 12000.00), (2, 'Factory B', 'Mexico', 15000.00), (3, 'Factory C', 'India', 8000.00), (4, 'Factory D', 'Bangladesh', 10000.00), (5, 'Factory E', 'China', 13000.00);
|
What is the average water consumption of factories in each country?
|
SELECT country, AVG(water_consumption) FROM Factories GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (incident_id INT, incident_date DATE, severity INT, department VARCHAR(50));
|
How many security incidents were reported in each department in the last 60 days, and what was the highest severity level recorded for each department?
|
SELECT department, COUNT(*) as incident_count, MAX(severity) as max_severity FROM incidents WHERE incident_date >= NOW() - INTERVAL 60 DAY GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), certification VARCHAR(255), CO2_emission DECIMAL(10,2));INSERT INTO products VALUES (1,'Product A','recycled',5),(2,'Product B','fair_trade',10),(3,'Product C','organic',15),(4,'Product D','recycled',20),(5,'Product E','fair_trade',25),(6,'Product F','recycled, fair_trade',30);
|
What is the average CO2 emission of products that are 'recycled' and 'fair_trade' certified?
|
SELECT AVG(CO2_emission) FROM products WHERE certification IN ('recycled', 'fair_trade') GROUP BY certification HAVING COUNT(DISTINCT certification) = 2
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity_reports (id INT, state VARCHAR(20), violation_count INT); INSERT INTO mental_health_parity_reports (id, state, violation_count) VALUES (1, 'California', 100), (2, 'New York', 150), (3, 'Texas', 120);
|
How many mental health parity violations were reported in each state?
|
SELECT state, SUM(violation_count) as total_violations FROM mental_health_parity_reports GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), country VARCHAR(255), certification_level VARCHAR(255), carbon_offset_tons INT); CREATE TABLE eu_countries (country_code VARCHAR(255), country_name VARCHAR(255));
|
What is the average carbon offset for green building certifications in each country in the European Union?
|
SELECT e.country_name, AVG(g.carbon_offset_tons) FROM green_buildings g INNER JOIN eu_countries e ON g.country = e.country_code GROUP BY e.country_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (EventID int, EventLocation varchar(50), Attendance int, EventDate date); INSERT INTO Events VALUES (1, 'CA Museum', 500, '2022-03-15'), (2, 'NY Theater', 300, '2022-02-01'), (3, 'CA Art Gallery', 200, '2022-03-01');
|
How many events in CA had more than 300 attendees in the last 3 months?
|
SELECT COUNT(*) FROM Events WHERE EventLocation LIKE '%CA%' AND Attendance > 300 AND EventDate >= (CURRENT_DATE - INTERVAL '3 months');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tours(id INT, name TEXT, eco_friendly BOOLEAN, revenue FLOAT); INSERT INTO tours (id, name, eco_friendly, revenue) VALUES (1, 'Amazon Rainforest Tour', TRUE, 5000), (2, 'City Bus Tour', FALSE, 2000);
|
What is the total revenue generated by eco-friendly tours?
|
SELECT SUM(revenue) FROM tours WHERE eco_friendly = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo_operations (id INT PRIMARY KEY, vessel_id INT, port_id INT, operation_type VARCHAR(255), amount INT, timestamp TIMESTAMP);
|
Update the amount of cargo in a cargo handling operation in the "cargo_operations" table
|
UPDATE cargo_operations SET amount = 12000 WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (name TEXT, affected_by_ocean_acidification BOOLEAN); INSERT INTO marine_species (name, affected_by_ocean_acidification) VALUES ('Coral', TRUE), ('Clownfish', FALSE), ('Sea Star', TRUE), ('Tuna', FALSE);
|
Which marine species are affected by ocean acidification?
|
SELECT name FROM marine_species WHERE affected_by_ocean_acidification = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co_ownership (price INT, city VARCHAR(20));
|
What is the average co-ownership price in Seattle?
|
SELECT AVG(price) FROM co_ownership WHERE city = 'Seattle';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country (id INT, name VARCHAR(50)); CREATE TABLE mca (id INT, country_id INT, name VARCHAR(50), size_sqkm FLOAT); INSERT INTO country (id, name) VALUES (1, 'Australia'), (2, 'Canada'); INSERT INTO mca (id, country_id, name, size_sqkm) VALUES (1, 1, 'Great Barrier Reef', 344400), (2, 2, 'Pacific Rim National Park', 51800);
|
List all countries and their total marine conservation area ('mca') size in square kilometers.
|
SELECT country.name, SUM(mca.size_sqkm) FROM country INNER JOIN mca ON country.id = mca.country_id GROUP BY country.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_wellbeing (id INT, person_id INT, gender VARCHAR(10), country VARCHAR(255), score FLOAT); INSERT INTO financial_wellbeing (id, person_id, gender, country, score) VALUES (1, 123, 'Female', 'Indonesia', 75.3), (2, 456, 'Male', 'Thailand', 82.1), (3, 789, 'Female', 'Vietnam', 70.9);
|
Calculate the average financial wellbeing score for women in Southeast Asia.
|
SELECT AVG(score) FROM financial_wellbeing WHERE country LIKE 'Southeast%' AND gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Atlanta Warehouse', 'southeast'), (2, 'Miami Warehouse', 'southeast'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, state TEXT); INSERT INTO packages (id, warehouse_id, weight, state) VALUES (1, 1, 100.5, 'Georgia'), (2, 1, 120.3, 'Florida'), (3, 2, 95.8, 'Florida');
|
What is the highest average weight of packages shipped to each state from the 'southeast' region?
|
SELECT state, MAX(avg_weight) FROM (SELECT state, AVG(weight) as avg_weight FROM packages p JOIN warehouses w ON p.warehouse_id = w.id WHERE w.region = 'southeast' GROUP BY state) sub GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members (member_id INT, gender VARCHAR(10), join_date DATE, country VARCHAR(50)); INSERT INTO members (member_id, gender, join_date, country) VALUES (1, 'Female', '2021-01-15', 'Canada'), (2, 'Male', '2022-03-28', 'USA');
|
How many new male members joined in Q1 2022 from the US?
|
SELECT COUNT(*) FROM members WHERE gender = 'Male' AND join_date >= '2022-01-01' AND join_date < '2022-04-01' AND country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ThreatIntel (indicator_id INT, indicator VARCHAR(50), type VARCHAR(20), timestamp TIMESTAMP); INSERT INTO ThreatIntel (indicator_id, indicator, type, timestamp) VALUES (1, '192.168.1.1', 'IP', '2022-01-01 10:00:00');
|
What is the total number of unique threat indicators in the 'ThreatIntel' table partitioned by type, ordered by the count in descending order?
|
SELECT type, COUNT(DISTINCT indicator) as unique_indicator_count FROM ThreatIntel GROUP BY type ORDER BY unique_indicator_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ad_impressions (id INT, country VARCHAR(255), ad_format VARCHAR(255), timestamp TIMESTAMP); INSERT INTO ad_impressions (id, country, ad_format, timestamp) VALUES (1, 'France', 'Video', '2022-06-01 12:00:00'), (2, 'France', 'Image', '2022-06-02 14:30:00');
|
Identify the number of ad impressions in France for the 'Video' ad format in the last week.
|
SELECT COUNT(*) FROM ad_impressions WHERE country = 'France' AND ad_format = 'Video' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (dish_id INT, dish_name TEXT, organic BOOLEAN, calories INT); INSERT INTO dishes (dish_id, dish_name, organic, calories) VALUES (1, 'Pizza', false, 1200), (2, 'Spaghetti', false, 1000), (3, 'Salad', true, 500), (4, 'Sushi', true, 800);
|
Calculate the average calories of all organic dishes
|
SELECT AVG(calories) FROM dishes WHERE organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, category VARCHAR(255), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, category, donation_amount, donation_date) VALUES (1, 1001, 'disaster_relief', 50.00, '2022-01-01'); INSERT INTO donations (id, donor_id, category, donation_amount, donation_date) VALUES (2, 1002, 'disaster_relief', 75.00, '2022-02-01');
|
What is the minimum amount donated to "disaster_relief" by a unique donor?
|
SELECT MIN(donation_amount) FROM donations WHERE category = 'disaster_relief' GROUP BY donor_id HAVING COUNT(donor_id) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lifelong_learning_events (id INT, name VARCHAR(50), location VARCHAR(50), start_time TIMESTAMP, end_time TIMESTAMP); INSERT INTO lifelong_learning_events (id, name, location, start_time, end_time) VALUES (1, 'Data Science Bootcamp', 'New York', '2023-03-01 09:00:00', '2023-03-01 17:00:00');
|
What is the duration of each lifelong learning event in hours, grouped by location?
|
SELECT location, TIMESTAMPDIFF(HOUR, start_time, end_time) as duration FROM lifelong_learning_events GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (project_id INT, project_name VARCHAR(100), year INT, region VARCHAR(50), category VARCHAR(50)); INSERT INTO projects (project_id, project_name, year, region, category) VALUES (1, 'Coastal Protection Program', 2021, 'Asia', 'Climate Adaptation'), (2, 'Urban Flood Resilience Project', 2021, 'Africa', 'Climate Adaptation'), (3, 'Forest Conservation Initiative', 2021, 'South America', 'Climate Mitigation'), (4, 'Clean Energy Transition Fund', 2021, 'Europe', 'Climate Mitigation'), (5, 'Drought Resilience Program', 2021, 'Asia', 'Climate Adaptation'), (6, 'Climate Communication Campaign', 2021, 'North America', 'Climate Communication'), (7, 'Sustainable Agriculture Project', 2021, 'Africa', 'Climate Adaptation'), (8, 'Green Building Incentive Program', 2021, 'Europe', 'Climate Mitigation'), (9, 'Disaster Risk Reduction Fund', 2021, 'South America', 'Climate Adaptation'), (10, 'Climate Change Education Program', 2021, 'North America', 'Climate Communication');
|
Determine the number of climate adaptation projects in the 'projects' table for each region in 2021
|
SELECT region, COUNT(*) as num_projects FROM projects WHERE year = 2021 AND category = 'Climate Adaptation' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity (id INT, regulation VARCHAR(100), state VARCHAR(20), implementation_date DATE); INSERT INTO mental_health_parity (id, regulation, state, implementation_date) VALUES (1, 'Regulation 1', 'New York', '2011-01-01'), (2, 'Regulation 2', 'Florida', '2012-01-01'), (3, 'Regulation 3', 'New York', NULL);
|
Delete mental health parity regulations that have not been implemented by 2013.
|
DELETE FROM mental_health_parity WHERE implementation_date IS NULL AND implementation_date < '2013-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (region VARCHAR(20), name VARCHAR(50), size FLOAT); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Southern Ocean', 'Ross Sea Marine Protected Area', 1500000); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Southern Ocean', 'Weddell Sea Marine Protected Area', 650000); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Indian Ocean', 'Maldives Exclusive Economic Zone', 90000);
|
How many marine protected areas are in the Southern Ocean?
|
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Southern Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE industrial_water_usage (state_name TEXT, year INTEGER, usage INTEGER); INSERT INTO industrial_water_usage (state_name, year, usage) VALUES ('California', 2020, 5000), ('California', 2021, 5200), ('Texas', 2020, 4000), ('Texas', 2021, 4100), ('Florida', 2020, 3500), ('Florida', 2021, 3650), ('New York', 2020, 2500), ('New York', 2021, 2600), ('Pennsylvania', 2020, 2000), ('Pennsylvania', 2021, 2100);
|
What is the change in industrial water usage from 2020 to 2021 for each state?
|
SELECT state_name, (LEAD(usage, 1) OVER (PARTITION BY state_name ORDER BY year) - usage) AS change_in_usage FROM industrial_water_usage WHERE year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE av_models (model_name VARCHAR(255), price DECIMAL(5,2));
|
Update the price of a specific autonomous vehicle model in the av_models table.
|
WITH updated_price AS (UPDATE av_models SET price = 95000 WHERE model_name = 'AutoMate X') SELECT * FROM updated_price;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Planting (id INT, year INT, tree_species_id INT); INSERT INTO Planting (id, year, tree_species_id) VALUES (1, 2000, 1), (2, 2000, 2), (3, 2005, 1), (4, 2005, 3), (5, 2010, 2), (6, 2010, 4); CREATE TABLE TreeSpecies (id INT, name VARCHAR(255)); INSERT INTO TreeSpecies (id, name) VALUES (1, 'Pine'), (2, 'Oak'), (3, 'Maple'), (4, 'Birch');
|
Which tree species were planted in the year 2005?
|
SELECT DISTINCT ts.name AS tree_species_name FROM Planting p JOIN TreeSpecies ts ON p.tree_species_id = ts.id WHERE p.year = 2005;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT, num_reviews INT); INSERT INTO hotels (hotel_id, hotel_name, country, rating, num_reviews) VALUES (1, 'Hotel A', 'USA', 4.2, 120), (2, 'Hotel B', 'USA', 4.5, 250), (3, 'Hotel C', 'Canada', 4.7, 80);
|
What is the average rating of hotels in the United States that have more than 100 reviews?
|
SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND num_reviews > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_health_metrics (site_id INT, certification VARCHAR(50), metric_name VARCHAR(50), value FLOAT); INSERT INTO ocean_health_metrics VALUES (1, 'Organic', 'pH', 7.8), (2, 'Non-organic', 'pH', 8.1), (3, 'Organic', 'Salinity', 1.2), (4, 'Non-organic', 'Salinity', 3.5), (5, 'Organic', 'Temperature', 15.5), (6, 'Non-organic', 'Temperature', 18.0);
|
What is the difference in ocean health metrics between aquaculture sites with organic and non-organic certifications?
|
SELECT certification, metric_name, AVG(value) AS avg_value FROM ocean_health_metrics GROUP BY certification, metric_name ORDER BY certification;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_land (id INT, location VARCHAR(50), size FLOAT); INSERT INTO agricultural_land (id, location, size) VALUES (1, 'Springfield', 500.0); INSERT INTO agricultural_land (id, location, size) VALUES (2, 'Shelbyville', 350.0); INSERT INTO agricultural_land (id, location, size) VALUES (3, 'Springfield', 750.0);
|
What is the total area of agricultural land in the 'agricultural_land' table, grouped by location?
|
SELECT location, SUM(size) FROM agricultural_land GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ships (id INT, name TEXT, sunk_date DATE, sunk_location TEXT); INSERT INTO ships (id, name, sunk_date, sunk_location) VALUES (1, 'Titanic', '1912-04-15', 'North Atlantic Ocean'); INSERT INTO ships (id, name, sunk_date, sunk_location) VALUES (2, 'Bismarck', '1941-05-27', 'Atlantic Ocean');
|
List all ships that sank in the Atlantic Ocean since 2000.
|
SELECT name FROM ships WHERE sunk_location = 'Atlantic Ocean' AND sunk_date >= '2000-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), payment_method VARCHAR(20));
|
Calculate the average donation amount for each payment method
|
SELECT payment_method, AVG(amount) as avg_donation_amount FROM donations GROUP BY payment_method;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medals (id INT, athlete VARCHAR(50), country VARCHAR(50), medal VARCHAR(50), year INT); INSERT INTO medals (id, athlete, country, medal, year) VALUES (1, 'Lindsey Vonn', 'USA', 'Gold', 2010); INSERT INTO medals (id, athlete, country, medal, year) VALUES (2, 'Shaun White', 'USA', 'Silver', 2018);
|
What is the total number of medals won by US athletes in the Winter Olympics?
|
SELECT COUNT(*) FROM medals WHERE country = 'USA' AND medal IN ('Gold', 'Silver', 'Bronze') AND year BETWEEN 1924 AND 2022 AND sport = 'Winter';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), missions_launched INT); INSERT INTO Spacecraft (id, name, manufacturer, missions_launched) VALUES (1, 'Spacecraft 1', 'SpaceX', 3), (2, 'Spacecraft 2', 'ULA', 2), (3, 'Spacecraft 3', 'SpaceX', 1);
|
List all missions launched from the Vandenberg Air Force Base along with the corresponding spacecraft.
|
SELECT m.mission_name, s.name as spacecraft_name FROM Mission m INNER JOIN Spacecraft s ON m.spacecraft_id = s.id WHERE m.launch_site = 'Vandenberg Air Force Base';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contracts (id INT, category VARCHAR(255), value DECIMAL(10,2));INSERT INTO contracts (id, category, value) VALUES (1, 'Aircraft', 5000000.00), (2, 'Missiles', 2000000.00), (3, 'Shipbuilding', 8000000.00), (4, 'Cybersecurity', 3000000.00), (5, 'Aircraft', 6000000.00), (6, 'Shipbuilding', 9000000.00);
|
What is the distribution of defense contracts by category?
|
SELECT category, SUM(value) as total_value FROM contracts GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workers (WorkerID INT, ProjectID INT, State CHAR(2), IsSustainable BOOLEAN);
|
What is the average number of workers employed in sustainable building projects in each state?
|
SELECT State, AVG(COUNT(*)) FROM Workers WHERE IsSustainable=TRUE GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE imports (country TEXT, import_value DECIMAL(10,2), import_date DATE); INSERT INTO imports VALUES ('Canada', 500000, '2021-01-01'), ('Mexico', 300000, '2021-02-01'), ('Brazil', 400000, '2021-03-01');
|
What are the top 3 countries with the most military equipment imports from the US?
|
SELECT country, import_value FROM (SELECT country, import_value, RANK() OVER (PARTITION BY country ORDER BY import_value DESC) AS ranking FROM imports WHERE import_country = 'US') subquery WHERE ranking <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE voyage_log (id INT, vessel_type VARCHAR(50), voyage_duration INT);
|
Determine the maximum voyage duration for each vessel type in the 'voyage_log' table
|
SELECT vessel_type, MAX(voyage_duration) FROM voyage_log GROUP BY vessel_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, disaster_id INT, hours FLOAT); CREATE TABLE disasters (id INT, name VARCHAR(255));
|
List the number of unique volunteers and total volunteer hours for each disaster response.
|
SELECT d.name, COUNT(DISTINCT volunteers.id) as volunteer_count, SUM(volunteers.hours) as total_volunteer_hours FROM disasters d LEFT JOIN volunteers ON d.id = volunteers.disaster_id GROUP BY d.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai_projects (country VARCHAR(2), project_count INT); INSERT INTO ethical_ai_projects (country, project_count) VALUES ('IN', 15), ('SG', 12), ('JP', 10), ('VN', 8), ('KR', 7);
|
What are the top 3 countries with the most ethical AI projects, and how many projects are in each?
|
SELECT country, project_count FROM ethical_ai_projects ORDER BY project_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_reviews (hotel_id INT, review_date DATE, review_score INT); CREATE VIEW hotel_review_summary AS SELECT hotel_id, COUNT(*), AVG(review_score) FROM hotel_reviews GROUP BY hotel_id;
|
Delete the "hotel_review_summary" view
|
DROP VIEW hotel_review_summary;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletics_events (event_id INT, athlete_name VARCHAR(100), race_count INT);
|
List the number of races each athlete has participated in the athletics_events table.
|
SELECT athlete_name, SUM(race_count) as total_races FROM athletics_events GROUP BY athlete_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, Gender TEXT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, Gender) VALUES (1, 'John Doe', 500.00, 'Male'), (2, 'Jane Smith', 350.00, 'Female'), (3, 'Alice Johnson', 700.00, 'Female');
|
What is the average donation amount by gender?
|
SELECT AVG(DonationAmount) as AverageDonation, Gender FROM Donors GROUP BY Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dams (DamID INT, Name TEXT, Province TEXT); INSERT INTO Dams (DamID, Name, Province) VALUES (1, 'Dam1', 'Ontario'); INSERT INTO Dams (DamID, Name, Province) VALUES (2, 'Dam2', 'Ontario'); INSERT INTO Dams (DamID, Name, Province) VALUES (3, 'Dam3', 'Quebec');
|
How many dams are there in the province of Ontario?
|
SELECT COUNT(*) FROM Dams WHERE Province = 'Ontario';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE content_creators (creator_id INT, username VARCHAR(50), join_date DATE, posts INT);
|
Get the top 5 content creators with the most posts in the content_creators table who joined after 2020-06-01.
|
SELECT username, posts FROM content_creators WHERE join_date > '2020-06-01' ORDER BY posts DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (id INT); CREATE TABLE facility_schedule (id INT, facility_id INT, start_time TIMESTAMP, end_time TIMESTAMP); INSERT INTO facilities (id) VALUES (1), (2);
|
Remove all records from the 'facility_schedule' table where the facility_id is not in the 'facilities' table
|
DELETE FROM facility_schedule WHERE facility_id NOT IN (SELECT id FROM facilities);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists urban; CREATE TABLE if not exists urban.crime_data (id INT, crime_severity_score INT); INSERT INTO urban.crime_data (id, crime_severity_score) VALUES (1, 6), (2, 8), (3, 10), (4, 12);
|
What is the maximum crime severity score in the 'urban' schema?
|
SELECT MAX(crime_severity_score) FROM urban.crime_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tweets (id INT, user_id INT, content TEXT, timestamp DATETIME); INSERT INTO tweets (id, user_id, content, timestamp) VALUES (1, 123, 'This is a tweet about climate change', '2022-01-01 10:00:00'), (2, 456, '#climatechange is real', '2022-01-15 14:30:00');
|
Identify the number of users who posted at least 5 tweets with the hashtag #climatechange in the month of January 2022, from the "social_media" schema.
|
SELECT COUNT(DISTINCT user_id) FROM tweets WHERE MONTH(timestamp) = 1 AND content LIKE '%#climatechange%' GROUP BY user_id HAVING COUNT(*) >= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salesperson (salesperson_id INT, name VARCHAR(50)); CREATE TABLE sales (sales_id INT, salesperson_id INT, sale_date DATE);
|
Which salesperson has sold the least garments in the last 30 days, ordered by the number of garments sold?
|
SELECT salesperson.name, COUNT(sales.sales_id) AS quantity_sold FROM salesperson INNER JOIN sales ON salesperson.salesperson_id = sales.salesperson_id WHERE sale_date >= CURRENT_DATE - INTERVAL '30 days' GROUP BY salesperson.name ORDER BY quantity_sold ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityTraining (id INT, training_name VARCHAR(50), location VARCHAR(50), attendees INT, training_date DATE); INSERT INTO CommunityTraining (id, training_name, location, attendees, training_date) VALUES (1, 'AgriTech Tools', 'Rural India', 50, '2021-10-01'); INSERT INTO CommunityTraining (id, training_name, location, attendees, training_date) VALUES (2, 'Sustainable Farming', 'Urban Japan', 30, '2022-02-20'); INSERT INTO CommunityTraining (id, training_name, location, attendees, training_date) VALUES (3, 'Community Agriculture', 'Rural Africa', 60, '2022-05-01'); INSERT INTO CommunityTraining (id, training_name, location, attendees, training_date) VALUES (4, 'Urban Farming', 'Urban Asia', 40, '2022-03-15');
|
What is the number of attendees for community training events in 'Rural Africa' and 'Urban Asia'?
|
SELECT location, SUM(attendees) FROM CommunityTraining WHERE location IN ('Rural Africa', 'Urban Asia') GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (company_id INT, recycled_qty INT, total_qty INT);
|
What is the total quantity of materials used in production that are not recycled, and what percentage does it represent of the total production quantity?
|
SELECT SUM(total_qty - recycled_qty) AS total_non_recycled, (SUM(total_qty - recycled_qty) / SUM(total_qty)) * 100 AS pct_non_recycled FROM production;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE canada_tourists (year INT, tourists INT);CREATE TABLE australia_tourists (year INT, tourists INT);
|
What is the average number of tourists visiting Canada and Australia per year?
|
SELECT AVG(tourists) FROM (SELECT year, AVG(tourists) AS tourists FROM canada_tourists GROUP BY year UNION ALL SELECT year, AVG(tourists) AS tourists FROM australia_tourists GROUP BY year) AS avg_tourists;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MumbaiFeedback (service VARCHAR(30), score INT, year INT); INSERT INTO MumbaiFeedback (service, score, year) VALUES ('Healthcare Services', 80, 2022), ('Healthcare Services', 85, 2022), ('Healthcare Services', 75, 2022);
|
What is the average citizen feedback score for healthcare services in Mumbai in 2022?
|
SELECT AVG(score) FROM MumbaiFeedback WHERE service = 'Healthcare Services' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hiv_cases (id INT, patient_id INT, report_date DATE, state VARCHAR(255), age_group VARCHAR(255));
|
What is the number of new HIV cases reported in each state of the US, by age group?
|
SELECT state, age_group, COUNT(*) AS num_new_hiv_cases FROM hiv_cases WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY state, age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID INT, LastName VARCHAR(20)); INSERT INTO Attorneys (AttorneyID, LastName) VALUES (1, 'Smith'), (2, 'Johnson'), (3, 'Williams'); CREATE TABLE Cases (CaseID INT, AttorneyID INT); INSERT INTO Cases (CaseID, AttorneyID) VALUES (1, 1), (2, 2), (3, 3), (4, 1);
|
How many cases were handled by attorneys with 'Smith' as their last name?
|
SELECT COUNT(*) FROM Cases INNER JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.LastName = 'Smith';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders(order_id INT, order_date DATE, menu_item_id INT, quantity INT); CREATE TABLE menu_items(menu_item_id INT, name TEXT, cuisine TEXT, type TEXT, is_vegan BOOLEAN, price DECIMAL);
|
Identify the top 5 most sold vegan dishes by cuisine type.
|
SELECT cuisine, name, SUM(quantity) as total_sold FROM orders JOIN menu_items ON orders.menu_item_id = menu_items.menu_item_id WHERE is_vegan = TRUE GROUP BY cuisine, name ORDER BY total_sold DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), rating DECIMAL(3,2), production_country VARCHAR(64)); INSERT INTO movies (id, title, rating, production_country) VALUES (1, 'MovieA', 7.5, 'Spain'), (2, 'MovieB', 8.2, 'Italy'), (3, 'MovieC', 6.8, 'France');
|
Update the rating of all movies produced in France to 7.0.
|
UPDATE movies SET rating = 7.0 WHERE production_country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA intelligence_schema; CREATE TABLE report (report_id INT PRIMARY KEY, report_date DATE); INSERT INTO report (report_id, report_date) VALUES (1, '2022-01-01');
|
Show the number of threat intelligence reports generated in the last 30 days
|
SELECT COUNT(*) FROM report WHERE report_date >= CURDATE() - INTERVAL 30 DAY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinics (state VARCHAR(2), num_clinics INT); INSERT INTO clinics (state, num_clinics) VALUES ('NY', 250), ('NJ', 180), ('CA', 400), ('FL', 320), ('TX', 360);
|
What is the total number of clinics providing mental health services, by state?
|
SELECT state, SUM(num_clinics) as total_clinics FROM clinics WHERE service_type = 'mental health' GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_hospitals (hospital_id INT, name VARCHAR(50), beds INT);
|
Delete the "rural_hospitals" table
|
DROP TABLE rural_hospitals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50));CREATE TABLE coal_mine (mine_id INT, amount INT);CREATE TABLE iron_mine (mine_id INT, amount INT);CREATE TABLE gold_mine (mine_id INT, amount INT);CREATE TABLE silver_mine (mine_id INT, amount INT);
|
Display the total amount of resources (coal, iron, gold, silver) mined by each mine.
|
SELECT m.name, m.location, SUM(COALESCE(c.amount, 0) + COALESCE(i.amount, 0) + COALESCE(g.amount, 0) + COALESCE(s.amount, 0)) AS total_amount FROM mine m LEFT JOIN coal_mine c ON m.id = c.mine_id LEFT JOIN iron_mine i ON m.id = i.mine_id LEFT JOIN gold_mine g ON m.id = g.mine_id LEFT JOIN silver_mine s ON m.id = s.mine_id GROUP BY m.id, m.name, m.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing_process (process_id INT, process_name VARCHAR(255), material_type VARCHAR(255), material_quantity INT); INSERT INTO manufacturing_process (process_id, process_name, material_type, material_quantity) VALUES (1, 'Plastic Molding', 'Plastic Recyclate', 500), (2, 'Metal Stamping', 'Scrap Metal', 300), (3, 'Woodworking', 'Wood Recyclate', 700);
|
What is the total quantity of recycled materials used in the company's manufacturing process in Q1 2022?
|
SELECT SUM(material_quantity) as total_quantity FROM manufacturing_process WHERE material_type LIKE '%Recycled%' AND process_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teacher_pd (teacher_id INT, location VARCHAR(50), program VARCHAR(50)); INSERT INTO teacher_pd (teacher_id, location, program) VALUES (1, 'Urban', 'Cross-Cultural Pedagogy 101'), (2, 'Rural', 'Cross-Cultural Pedagogy 101'), (3, 'Suburban', 'Cross-Cultural Pedagogy 101');
|
What is the number of teachers who have participated in cross-cultural professional development programs in urban and rural areas?
|
SELECT location, COUNT(DISTINCT teacher_id) as num_teachers FROM teacher_pd WHERE program = 'Cross-Cultural Pedagogy 101' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE la_fire_stations (id INT, station_name VARCHAR(20), location VARCHAR(20)); INSERT INTO la_fire_stations (id, station_name, location) VALUES (1, 'Station 1', 'Los Angeles'), (2, 'Station 2', 'Los Angeles');
|
What is the total number of fire stations in Los Angeles?
|
SELECT COUNT(*) FROM la_fire_stations;
|
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.