context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE ResearchExpeditions(expedition_id INT, country VARCHAR(255));
|
What is the total number of research expeditions to the Arctic by country?
|
SELECT country, COUNT(*) FROM ResearchExpeditions GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID serial, Name text, Nationality text);
|
Add a new artist 'Yayoi Kusama' from Japan?
|
INSERT INTO Artists (Name, Nationality) VALUES ('Yayoi Kusama', 'Japanese');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, department_id INT, teacher_name VARCHAR(255)); INSERT INTO teachers VALUES (1, 1, 'Ms. Garcia'); INSERT INTO teachers VALUES (2, 2, 'Mr. Patel'); CREATE TABLE departments (department_id INT, department_name VARCHAR(255)); INSERT INTO departments VALUES (1, 'Math'); INSERT INTO departments VALUES (2, 'Science'); CREATE TABLE course_enrollment (enrollment_id INT, teacher_id INT, course_id INT);
|
How many professional development courses were completed by teachers in the Math department?
|
SELECT d.department_name, COUNT(c.course_id) FROM course_enrollment ce INNER JOIN teachers t ON ce.teacher_id = t.teacher_id INNER JOIN departments d ON t.department_id = d.department_id WHERE d.department_name = 'Math';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (date DATE, menu_category VARCHAR(255), revenue INT); INSERT INTO sales (date, menu_category, revenue) VALUES ('2022-01-01', 'Appetizers', 1000), ('2022-01-01', 'Entrees', 2500), ('2022-01-01', 'Desserts', 1500);
|
Which menu categories have no sales?
|
SELECT menu_category FROM sales WHERE revenue IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT, name TEXT); CREATE TABLE matches (id INT, home_team INT, visiting_team INT, attendance INT);
|
Display the total number of matches played by each team, along with the average attendance.
|
SELECT t.name, COUNT(m.id), AVG(m.attendance) FROM teams t LEFT JOIN matches m ON t.id IN (m.home_team, m.visiting_team) GROUP BY t.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, name VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO organizations (id, name, budget) VALUES (1, 'AI Research Institute', 7000000.00), (2, 'Tech for Good Foundation', 5000000.00), (3, 'Global Accessibility Initiative', 9000000.00);
|
What is the name of the organization that has the minimum budget allocated for ethical AI research?
|
SELECT name FROM organizations WHERE budget = (SELECT MIN(budget) FROM organizations);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_outreach_coordinators (id INT, name VARCHAR(255));CREATE TABLE community_outreach (id INT, coordinator_id INT, location_id INT, program_name VARCHAR(255));CREATE TABLE locations (id INT, name VARCHAR(255), is_protected BOOLEAN); INSERT INTO community_outreach_coordinators (id, name) VALUES (1, 'Grace'), (2, 'Heidi'), (3, 'Ivy'); INSERT INTO community_outreach (id, coordinator_id, location_id, program_name) VALUES (1, 1, 1, 'Nature Photography'), (2, 1, 2, 'Plant a Tree'), (3, 2, 2, 'Bird Watching'), (4, 2, 3, 'Hiking'), (5, 3, 1, 'Climate Change Awareness'), (6, 3, 3, 'Wildlife Rescue'); INSERT INTO locations (id, name, is_protected) VALUES (1, 'Park', TRUE), (2, 'Forest', TRUE), (3, 'Reserve', FALSE);
|
Identify the community outreach coordinators and the number of educational programs they have conducted in protected areas
|
SELECT co.name AS coordinator_name, COUNT(c.id) AS program_count FROM community_outreach_coordinators co INNER JOIN community_outreach c ON co.id = c.coordinator_id INNER JOIN locations l ON c.location_id = l.id WHERE l.is_protected = TRUE GROUP BY co.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LutetiumProduction (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO LutetiumProduction (country, price, year) VALUES ('South Africa', 350.00, 2019), ('South Africa', 360.00, 2018);
|
What is the average price of lutetium produced in South Africa?
|
SELECT AVG(price) FROM LutetiumProduction WHERE country = 'South Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (song_id INT, release_date DATE); INSERT INTO songs VALUES (1, '2010-01-03'), (2, '2011-02-14'), (3, '2009-05-23'), (4, '2011-12-31'), (5, '2008-06-20');
|
Show the release dates of all songs released before 2011.
|
SELECT release_date FROM songs WHERE YEAR(release_date) < 2011;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(50)); CREATE TABLE products (product_id INT, brand_id INT);
|
List the top 5 cosmetic brands with the highest number of products, in descending order.
|
SELECT b.brand_name, COUNT(p.product_id) as product_count FROM brands b JOIN products p ON b.brand_id = p.brand_id GROUP BY b.brand_name ORDER BY product_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE local_businesses (business_id INT, name TEXT, city TEXT, daily_revenue FLOAT, benefited_from_sustainable_tourism BOOLEAN); INSERT INTO local_businesses (business_id, name, city, daily_revenue, benefited_from_sustainable_tourism) VALUES (1, 'La Boqueria Market Stall', 'Barcelona', 500, true), (2, 'Barcelona Gift Shop', 'Barcelona', 300, false), (3, 'Lisbon Handicraft Store', 'Lisbon', 150, false);
|
Delete local businesses in Lisbon that have not benefited from sustainable tourism
|
DELETE FROM local_businesses WHERE city = 'Lisbon' AND benefited_from_sustainable_tourism = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE imports (id INT, element TEXT, source TEXT, quantity INT, import_date DATE);
|
What is the total amount of Gadolinium imported to China from countries in the Asia Pacific region in 2018?
|
SELECT SUM(quantity) FROM imports WHERE element = 'Gadolinium' AND source IN (SELECT name FROM countries WHERE region = 'Asia Pacific') AND YEAR(import_date) = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE activity_time (member_id INT, activity VARCHAR(20), time_spent INT); INSERT INTO activity_time (member_id, activity, time_spent) VALUES (1, 'Running', 60), (1, 'Cycling', 45), (2, 'Cycling', 90), (2, 'Yoga', 30), (3, 'Yoga', 60), (3, 'Swimming', 45), (4, 'Yoga', 45), (4, 'Swimming', 60), (5, 'Swimming', 75);
|
What is the total time spent on yoga and swimming activities for each member?
|
SELECT member_id, SUM(time_spent) AS total_time_spent FROM activity_time WHERE activity IN ('Yoga', 'Swimming') GROUP BY member_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id varchar(10), field varchar(10), production int, datetime date); INSERT INTO wells (well_id, field, production, datetime) VALUES ('W005', 'FieldF', 1200, '2020-07-01'), ('W006', 'FieldF', 1400, '2020-08-01');
|
What is the average production of wells in 'FieldF' for the third quarter of 2020?
|
SELECT AVG(production) FROM wells WHERE field = 'FieldF' AND datetime BETWEEN DATE_SUB(LAST_DAY('2020-09-01'), INTERVAL 2 MONTH) AND LAST_DAY('2020-09-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_fish_farms (id INT, name VARCHAR(50), country VARCHAR(50), dissolved_oxygen FLOAT); INSERT INTO arctic_fish_farms (id, name, country, dissolved_oxygen) VALUES (1, 'Farm S', 'Norway', 9.1), (2, 'Farm T', 'Russia', 8.9), (3, 'Farm U', 'Canada', 8.7), (4, 'Farm V', 'Greenland', 8.5);
|
What is the maximum dissolved oxygen level for fish farms in the Arctic ocean?
|
SELECT MAX(dissolved_oxygen) FROM arctic_fish_farms;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE points (player_id INT, name TEXT, team TEXT, position TEXT, points_per_game FLOAT); INSERT INTO points (player_id, name, team, position, points_per_game) VALUES (1, 'Mike Johnson', 'Golden State Warriors', 'Guard', 25.6), (2, 'Lisa Brown', 'Los Angeles Lakers', 'Forward', 22.8);
|
What is the average number of points scored per game in the Western Conference?
|
SELECT AVG(p.points_per_game) FROM points p WHERE p.team IN (SELECT t.team FROM teams t WHERE t.conference = 'Western');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu (menu_name VARCHAR(20), item_name VARCHAR(30), price DECIMAL(5,2));
|
Insert a new menu item 'Veggie Burger' into the 'Dinner' menu with a price of 13.99
|
INSERT INTO Menu (menu_name, item_name, price) VALUES ('Dinner', 'Veggie Burger', 13.99);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emissions_yearly (year INT, country VARCHAR(50), emissions INT); INSERT INTO emissions_yearly (year, country, emissions) VALUES (2018, 'China', 4000), (2018, 'USA', 1500), (2018, 'Australia', 800), (2019, 'China', 5000), (2019, 'USA', 2000), (2019, 'Australia', 1200), (2020, 'China', 12000), (2020, 'USA', 3500), (2020, 'Australia', 1800);
|
What is the total greenhouse gas emissions from rare earth element production for the year 2020?
|
SELECT SUM(emissions) FROM emissions_yearly WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL, donation_date DATE); INSERT INTO donations (id, donor_id, amount, donation_date) VALUES (1, 1, 250.00, '2020-01-15'), (2, 2, 100.00, '2019-12-31');
|
What is the total donation amount received from Spain in Q1 of 2020?
|
SELECT SUM(amount) FROM donations WHERE country = 'Spain' AND QUARTER(donation_date) = 1 AND YEAR(donation_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (item VARCHAR(10), quantity INT); INSERT INTO Warehouse (item, quantity) VALUES ('A101', 50), ('B202', 75);
|
Delete all records related to item 'B202' from the Warehouse table
|
DELETE FROM Warehouse WHERE item = 'B202';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InfrastructureProjects (id INT, category VARCHAR(20), cost FLOAT); INSERT INTO InfrastructureProjects (id, category, cost) VALUES (1, 'Roads', 500000), (2, 'Bridges', 750000), (3, 'Buildings', 900000), (4, 'Roads', 600000);
|
List all projects with their respective costs in the 'Roads' category.
|
SELECT * FROM InfrastructureProjects WHERE category = 'Roads';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, name TEXT, country TEXT, rating INT); INSERT INTO hotels (id, name, country, rating) VALUES (1, 'Park Hyatt Tokyo', 'Japan', 5), (2, 'The Ritz-Carlton, Tokyo', 'Japan', 5), (3, 'Mandarin Oriental, Tokyo', 'Japan', 5);
|
How many 5-star hotels are there in Japan?
|
SELECT COUNT(*) FROM hotels WHERE country = 'Japan' AND rating = 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, material VARCHAR(255), quantity INT, price DECIMAL(10, 2)); INSERT INTO production (id, material, quantity, price) VALUES (1, 'organic cotton', 100, 2.50), (2, 'recycled polyester', 50, 3.25), (3, 'hemp', 75, 4.00), (4, 'organic cotton', 200, 2.50), (5, 'recycled polyester', 75, 3.25);
|
What is the total quantity of sustainable materials used in production, by material type?
|
SELECT material, SUM(quantity) FROM production GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name VARCHAR(255)); CREATE TABLE shelters (id INT, city_id INT, name VARCHAR(255), capacity INT);
|
What is the total number of shelters and their capacities by city?
|
SELECT cities.name, SUM(shelters.capacity) FROM shelters JOIN cities ON shelters.city_id = cities.id GROUP BY shelters.city_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE primary_care_physicians (id INT, region TEXT, specialty TEXT); INSERT INTO primary_care_physicians (id, region, specialty) VALUES (1, 'Northeast', 'Internal Medicine'), (2, 'Midwest', 'Family Medicine');
|
What is the total number of primary care physicians in the Midwest?
|
SELECT COUNT(*) FROM primary_care_physicians WHERE region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE coffee_farms (id INT, farm_name TEXT, region TEXT, fair_trade BOOLEAN); INSERT INTO coffee_farms (id, farm_name, region, fair_trade) VALUES (1, 'Colombia Coffee Co.', 'South America', true), (2, 'French Roast Farms', 'Europe', false);
|
Which region has the most fair trade coffee farms?
|
SELECT region, COUNT(*) FROM coffee_farms WHERE fair_trade = true GROUP BY region ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_data (user_id INT, gender VARCHAR(10)); INSERT INTO user_data (user_id, gender) VALUES (101, 'Female'), (102, 'Male'), (103, 'Female'), (104, 'Male'), (105, 'Female'); CREATE TABLE workout_data (user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO workout_data (user_id, workout_type, duration) VALUES (101, 'Strength Training', 60), (101, 'Strength Training', 90), (102, 'Strength Training', 45), (103, 'Yoga', 30), (104, 'Strength Training', 120);
|
What is the total duration of strength training workouts for female users?
|
SELECT SUM(duration) as total_duration FROM workout_data JOIN user_data ON workout_data.user_id = user_data.user_id WHERE user_data.gender = 'Female' AND workout_type = 'Strength Training';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE risk_assessments (id INT, region VARCHAR(255), risk_score INT); INSERT INTO risk_assessments (id, region, risk_score) VALUES (1, 'Middle East', 75); INSERT INTO risk_assessments (id, region, risk_score) VALUES (2, 'Asia', 50);
|
Get the geopolitical risk scores for the 'Middle East' region from the 'risk_assessments' table
|
SELECT risk_score FROM risk_assessments WHERE region = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wildlife_habitats (id INT, region VARCHAR(255), habitat_type VARCHAR(255), area FLOAT); INSERT INTO wildlife_habitats (id, region, habitat_type, area) VALUES (1, 'North America', 'Boreal Forest', 347643.12), (2, 'South America', 'Atlantic Forest', 123456.78);
|
What is the total area of all wildlife habitats in square kilometers, grouped by region?
|
SELECT region, SUM(area) FROM wildlife_habitats WHERE habitat_type = 'Wildlife Habitat' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hydropower_projects (project_id INT PRIMARY KEY, project_name VARCHAR(100), construction_cost FLOAT, country VARCHAR(50));
|
Find the name and construction cost of the most expensive dam in the 'hydropower_projects' table
|
SELECT project_name, construction_cost FROM hydropower_projects ORDER BY construction_cost DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, city VARCHAR(255), data_usage_gb DECIMAL(5,2)); INSERT INTO mobile_subscribers (subscriber_id, city, data_usage_gb) VALUES (1, 'Chicago', 8.3), (2, 'Chicago', 10.5), (3, 'Houston', 9.7);
|
What is the minimum data usage for mobile subscribers in the city of Chicago?
|
SELECT MIN(data_usage_gb) FROM mobile_subscribers WHERE city = 'Chicago';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(50), rating DECIMAL(2,1), PRIMARY KEY (hotel_id));
|
Delete records in the "hotels" table where the "hotel_name" is 'Hotel del Luna' and the "rating" is less than 4.5
|
DELETE FROM hotels WHERE hotel_name = 'Hotel del Luna' AND rating < 4.5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE operations (id INT PRIMARY KEY, name VARCHAR(50), region VARCHAR(50), type VARCHAR(20));
|
Insert a new record into the 'operations' table for a peacekeeping mission in 'Congo'
|
INSERT INTO operations (id, name, region, type) VALUES (1, 'MONUSCO', 'Congo', 'peacekeeping');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthcareProfessional (ProfessionalID INT, Name VARCHAR(50), Age INT, Specialty VARCHAR(50), TrainingCompletion FLOAT); INSERT INTO HealthcareProfessional (ProfessionalID, Name, Age, Specialty, TrainingCompletion) VALUES (1, 'John Doe', 45, 'Psychiatrist', 0.9); INSERT INTO HealthcareProfessional (ProfessionalID, Name, Age, Specialty, TrainingCompletion) VALUES (2, 'Jane Smith', 35, 'Nurse', 0.8);
|
What is the percentage of cultural competency training completed by healthcare professionals in New York?
|
SELECT (SUM(TrainingCompletion) / COUNT(*)) * 100 FROM HealthcareProfessional WHERE State = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameReleaseDates (GameID int, GameName varchar(50), ReleaseDate date, PlayerCount int, PlayTime int); INSERT INTO GameReleaseDates (GameID, GameName, ReleaseDate, PlayerCount, PlayTime) VALUES (9, 'GameK', '2022-06-15', 150, 400); INSERT INTO GameReleaseDates (GameID, GameName, ReleaseDate, PlayerCount, PlayTime) VALUES (10, 'GameL', '2022-07-10', 200, 500);
|
What is the number of players and total play time for each game released in the last 6 months?
|
SELECT GameName, SUM(PlayerCount) as TotalPlayers, SUM(PlayTime) as TotalPlayTime FROM GameReleaseDates WHERE ReleaseDate >= DATEADD(month, -6, GETDATE()) GROUP BY GameName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (customer_id INT, district VARCHAR(20), transaction_value DECIMAL(10, 2)); INSERT INTO transactions (customer_id, district, transaction_value) VALUES (1, 'Tokyo', 5000.00), (2, 'Osaka', 3000.00), (3, 'Tokyo', 7000.00);
|
What is the average transaction value for customers in the Tokyo district?
|
SELECT AVG(transaction_value) FROM transactions WHERE district = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_sourcing (restaurant_id INT, sourcing_date DATE, spending DECIMAL(10,2)); INSERT INTO sustainable_sourcing (restaurant_id, sourcing_date, spending) VALUES (5, '2022-01-01', 5000), (5, '2022-02-01', 6000), (5, '2022-03-01', 7000); CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO restaurants (restaurant_id, name, location) VALUES (5, 'Green Organics', 'Seattle');
|
What was the total sustainable sourcing spending for 'Green Organics' in the first quarter of 2022?
|
SELECT SUM(spending) as total_spending FROM sustainable_sourcing INNER JOIN restaurants ON sustainable_sourcing.restaurant_id = restaurants.restaurant_id WHERE restaurants.name = 'Green Organics' AND sustainable_sourcing.sourcing_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RouteRevenue (RouteID int, RouteName varchar(50), TransportMode varchar(50), Revenue int); INSERT INTO RouteRevenue VALUES (1, 'Route 1', 'Bus', 2000); INSERT INTO RouteRevenue VALUES (2, 'Route 2', 'Bus', 5000); INSERT INTO RouteRevenue VALUES (3, 'Route 3', 'Bus', 7000); INSERT INTO RouteRevenue VALUES (4, 'Route 4', 'Subway', 3000); INSERT INTO RouteRevenue VALUES (5, 'Route 5', 'Subway', 4000); INSERT INTO RouteRevenue VALUES (6, 'Route 6', 'Tram', 5500);
|
Show the routes with the highest and lowest revenue for each transport mode.
|
SELECT RouteID, RouteName, TransportMode, Revenue FROM (SELECT RouteID, RouteName, TransportMode, Revenue, ROW_NUMBER() OVER (PARTITION BY TransportMode ORDER BY Revenue DESC, RouteID) rn1, ROW_NUMBER() OVER (PARTITION BY TransportMode ORDER BY Revenue ASC, RouteID) rn2 FROM RouteRevenue) t WHERE rn1 = 1 OR rn2 = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (game_id INT, game_name TEXT, game_category TEXT, game_purchase_price FLOAT, release_year INT, country TEXT); INSERT INTO games (game_id, game_name, game_category, game_purchase_price, release_year, country) VALUES (1, 'Game A', 'Action', 59.99, 2020, 'USA'), (2, 'Game B', 'Strategy', 45.99, 2019, 'Canada'), (3, 'Game C', 'RPG', 39.99, 2018, 'Germany');
|
What are the top 3 countries with the highest average game purchase price?
|
SELECT country, AVG(game_purchase_price) as avg_price FROM games GROUP BY country ORDER BY avg_price DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE technology_accessibility (region VARCHAR(255), accessibility FLOAT, updated_on DATE);
|
Update accessibility column to 90 in technology_accessibility table where region is 'Asia'
|
UPDATE technology_accessibility SET accessibility = 90 WHERE region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai (id INT, organization_name TEXT, country TEXT); INSERT INTO ethical_ai (id, organization_name, country) VALUES (1, 'AI Ethics Inc', 'USA'), (2, 'Ethical Tech Co', 'Canada'), (3, 'AI for Good Ltd', 'UK');
|
Which countries have the most ethical AI organizations?
|
SELECT country, COUNT(*) as organization_count FROM ethical_ai GROUP BY country ORDER BY organization_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crime_stats (id INT, year INT, month INT, type VARCHAR(255), PRIMARY KEY(id));
|
Delete all crime records for '2021' from 'crime_stats' table
|
DELETE FROM crime_stats WHERE year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policy (policy_id INT, policy_holder_id INT, policy_type VARCHAR(20), policy_start_date DATE);
|
Insert a new policy record for policy_holder_id 111 with policy_type 'Auto' and policy_start_date 2022-01-01 in the 'policy' table.
|
INSERT INTO policy (policy_holder_id, policy_type, policy_start_date) VALUES (111, 'Auto', '2022-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(30), donation_amount DECIMAL(5,2)); INSERT INTO donors (donor_id, donor_name, donation_amount) VALUES (1, 'Jane Doe', 300), (2, 'Mary Smith', 400), (3, 'Bob Johnson', 200);
|
Insert a new donor with ID '4', name 'John Doe', and donation amount '500'
|
INSERT INTO donors (donor_id, donor_name, donation_amount) VALUES (4, 'John Doe', 500);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (id INT, city TEXT, issue_date DATE); INSERT INTO building_permits (id, city, issue_date) VALUES (1, 'Springfield', '2021-05-12'), (2, 'Shelbyville', '2020-12-21');
|
How many building permits were issued in 'Springfield' last year?
|
SELECT COUNT(*) FROM building_permits WHERE city = 'Springfield' AND YEAR(issue_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE member_hr_categories (member_category VARCHAR(20), member_id INT, max_heart_rate INT); INSERT INTO member_hr_categories (member_category, member_id, max_heart_rate) VALUES ('Gold', 1, 170), ('Gold', 2, 180), ('Silver', 3, 165), ('Bronze', 4, 172), ('Bronze', 5, 175);
|
What is the maximum heart rate for each member category?
|
SELECT pivot_col, MAX(max_heart_rate) as max_heart_rate FROM (SELECT member_category AS pivot_col, max_heart_rate FROM member_hr_categories) GROUP BY pivot_col;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workouts (MemberID INT, Device VARCHAR(20), HeartRate INT); INSERT INTO Workouts (MemberID, Device, HeartRate) VALUES (1, 'Smartwatch', 120), (2, 'Fitness Band', 110), (3, 'Smartwatch', 130);
|
What is the average heart rate of members wearing a 'Smartwatch' device during their workouts?
|
SELECT AVG(HeartRate) FROM Workouts WHERE Device = 'Smartwatch';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE membership (user_id INT, name VARCHAR(50), status VARCHAR(20)); INSERT INTO membership (user_id, name, status) VALUES (1, 'John Doe', 'Active');
|
Update the membership status of user 'John Doe' to 'Inactive'
|
WITH updated_membership AS (UPDATE membership SET status = 'Inactive' WHERE name = 'John Doe' RETURNING *) SELECT * FROM updated_membership;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, plan_status VARCHAR(10), device_os VARCHAR(10)); INSERT INTO mobile_subscribers (subscriber_id, plan_status, device_os) VALUES (1, 'active', 'Android'), (2, 'inactive', 'iOS'), (3, 'active', 'Android'), (4, 'active', 'iOS');
|
List all the mobile subscribers who have an active plan and use iOS.
|
SELECT * FROM mobile_subscribers WHERE plan_status = 'active' AND device_os = 'iOS';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_condition_categories (id INT PRIMARY KEY, name VARCHAR(255), description TEXT);
|
Create a table for mental health condition categories
|
CREATE TABLE mental_health_condition_categories (id INT PRIMARY KEY, name VARCHAR(255), description TEXT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE provinces (province_id INT, province_name TEXT); INSERT INTO provinces VALUES (1, 'Quebec');
|
What are the total donations made to nonprofits in the arts sector in Canada by donors living in Montreal?
|
SELECT SUM(donation_amount) as total_donations FROM donors d JOIN donations don ON d.donor_id = don.donor_id JOIN nonprofits n ON don.nonprofit_id = n.nonprofit_id JOIN provinces p ON d.city = p.province_name WHERE n.sector = 'arts' AND p.province_name = 'Montreal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_usage (usage_id INT, customer_id INT, usage_date DATE, data_usage DECIMAL(5,2));
|
Insert a new record in the customer_usage table for a customer with id 1002, who used 750 MB of data on 2023-03-02
|
INSERT INTO customer_usage (usage_id, customer_id, usage_date, data_usage) VALUES ((SELECT MAX(usage_id) FROM customer_usage) + 1, 1002, '2023-03-02', 750.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE professional_development (student_id INT, teacher_id INT, subject VARCHAR(255), pd_date DATE); INSERT INTO professional_development (student_id, teacher_id, subject, pd_date) VALUES (1, 1, 'Mathematics', '2010-01-01'), (2, 2, 'Computer Science', '2015-01-01'), (3, 2, 'Computer Science', '2016-01-01'), (4, 3, 'English', '2005-01-01');
|
What is the number of students who have ever received professional development, grouped by subject?
|
SELECT subject, COUNT(DISTINCT student_id) as num_students FROM professional_development GROUP BY subject;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE member_data (member_id INT, gender VARCHAR(10), age INT); INSERT INTO member_data (member_id, gender, age) VALUES (1, 'Female', 27), (2, 'Male', 32), (3, 'Female', 26), (4, 'Male', 28), (5, 'Female', 31); CREATE TABLE activity_heart_rate (member_id INT, activity VARCHAR(20), heart_rate INT); INSERT INTO activity_heart_rate (member_id, activity, heart_rate) VALUES (1, 'Running', 160), (2, 'Cycling', 145), (3, 'Yoga', 120), (4, 'Swimming', 150), (5, 'Pilates', 135), (1, 'Running', 165), (3, 'Running', 170), (5, 'Running', 155);
|
What is the average heart rate for female members during running activities?
|
SELECT AVG(heart_rate) AS avg_heart_rate FROM activity_heart_rate ahr JOIN member_data mdata ON ahr.member_id = mdata.member_id WHERE ahr.activity = 'Running' AND mdata.gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE samarium_production (country VARCHAR(50), continent VARCHAR(50), quantity INT);
|
What is the total production of Samarium by continent?
|
SELECT continent, SUM(quantity) FROM samarium_production GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo (id INT, vessel_name VARCHAR(255), cargo_weight INT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), unload_date DATE); INSERT INTO cargo (id, vessel_name, cargo_weight, latitude, longitude, unload_date) VALUES (1, 'VesselA', 12000, 38.424744, -122.879444, '2022-01-15');
|
What is the total cargo weight transported by each vessel in the Pacific Ocean, sorted by the total weight?
|
SELECT vessel_name, SUM(cargo_weight) as total_weight FROM cargo WHERE latitude BETWEEN 0.0 AND 60.0 AND longitude BETWEEN -160.0 AND -100.0 GROUP BY vessel_name ORDER BY total_weight DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation_mumbai (business_type VARCHAR(50), waste_amount INT); INSERT INTO waste_generation_mumbai (business_type, waste_amount) VALUES ('Restaurant', 250), ('Retail', 200), ('Office', 170);
|
What is the total waste generation by business type in Mumbai?
|
SELECT business_type, SUM(waste_amount) FROM waste_generation_mumbai WHERE business_type IN ('Restaurant', 'Retail', 'Office') GROUP BY business_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exploration_projects (id INT, name TEXT, location TEXT, region TEXT); INSERT INTO exploration_projects (id, name, location, region) VALUES (1, 'Project A', 'Atlantic', 'Atlantic'); INSERT INTO exploration_projects (id, name, location, region) VALUES (2, 'Project B', 'Indian', 'Indian'); INSERT INTO exploration_projects (id, name, location, region) VALUES (3, 'Project C', 'Pacific', 'Pacific');
|
What is the total number of deep-sea exploration projects in the Atlantic and Indian Oceans?
|
SELECT region, COUNT(*) FROM exploration_projects GROUP BY region HAVING region IN ('Atlantic', 'Indian');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ads (ad_id INT, ad_type VARCHAR(50), ad_content TEXT, ad_date DATE);CREATE TABLE clicks (click_id INT, ad_id INT, user_id INT, click_date DATE);INSERT INTO ads (ad_id, ad_type, ad_content, ad_date) VALUES (1, 'electronics', 'new phone', '2021-06-01'), (2, 'fashion', 'summer dress', '2021-06-05'), (3, 'electronics', 'gaming laptop', '2021-06-10');
|
List the ad IDs and the number of clicks they received in the past month for ads related to electronics.
|
SELECT c.ad_id, COUNT(c.click_id) as click_count FROM clicks c JOIN ads a ON c.ad_id = a.ad_id WHERE a.ad_type = 'electronics' AND c.click_date >= DATEADD(month, -1, GETDATE()) GROUP BY c.ad_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, email TEXT, country TEXT);
|
What is the total number of donors from Africa registered in the 'donors' table?
|
SELECT COUNT(*) FROM donors WHERE country = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE olympics_history (edition INT, year INT, city VARCHAR(50), country VARCHAR(50), total_medals INT);
|
Calculate the total number of medals won by athletes from the USA in the 'olympics_history' table?
|
SELECT SUM(total_medals) FROM olympics_history WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50), account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region, account_balance) VALUES (1, 'John Doe', 'Midwest', 5000.00), (2, 'Jane Smith', 'Northeast', 7000.00);
|
What is the minimum account balance for customers in the Midwest region?
|
SELECT MIN(account_balance) FROM customers WHERE region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workouts (WorkoutID INT, WorkoutDate DATE, HeartRate INT); INSERT INTO Workouts (WorkoutID, WorkoutDate, HeartRate) VALUES (1,'2022-01-01',120),(2,'2022-02-01',130),(3,'2022-03-01',100);
|
What is the maximum heart rate recorded during workouts in each month?
|
SELECT MONTH(WorkoutDate), MAX(HeartRate) FROM Workouts GROUP BY MONTH(WorkoutDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (citizen_id INT, service_id INT, rating INT); INSERT INTO feedback (citizen_id, service_id, rating) VALUES (1, 123, 5), (2, 123, 4), (3, 123, 5), (4, 456, 3), (5, 456, 4), (6, 789, 5);
|
List all services with no feedback in the 'feedback' table
|
SELECT service_id FROM feedback GROUP BY service_id HAVING COUNT(*) = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OilWells (WellID VARCHAR(10), Production FLOAT, DrillYear INT, Location VARCHAR(50));
|
What is the total production of wells in 'Alberta' for the year 2019?
|
SELECT SUM(Production) FROM OilWells WHERE Location = 'Alberta' AND DrillYear = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT, name VARCHAR(255)); CREATE TABLE streams (id INT, artist_id INT, platform VARCHAR(255), streams BIGINT); INSERT INTO artists VALUES (1, 'Billie Eilish'); INSERT INTO streams VALUES (1, 1, 'Apple Music', 8000000);
|
Which artists have the most streams on the 'Apple Music' platform?
|
SELECT a.name, SUM(s.streams) as total_streams FROM streams s JOIN artists a ON s.artist_id = a.id WHERE s.platform = 'Apple Music' GROUP BY a.name ORDER BY total_streams DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stops( stop_id INT PRIMARY KEY, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6), wheelchair_accessible BOOLEAN);
|
Create a table named "stops" for storing public transit stop details.
|
CREATE TABLE stops( stop_id INT PRIMARY KEY, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6), wheelchair_accessible BOOLEAN);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT, game_date DATE, team VARCHAR(20)); CREATE TABLE points (id INT, game_id INT, player VARCHAR(20), points INT);
|
What is the maximum number of points scored in a single game by any player in the last year, and who scored it?
|
SELECT player, MAX(points) FROM points JOIN games ON points.game_id = games.id WHERE games.game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY player;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, drill_year INT); INSERT INTO wells VALUES (1, 'Well A', 1000, 2018); INSERT INTO wells VALUES (2, 'Well B', 1500, 2020); INSERT INTO wells VALUES (3, 'Well C', 1200, 2019); INSERT INTO wells VALUES (4, 'Well D', 800, 2020);
|
List all the wells that were drilled in the year 2020
|
SELECT well_name, drill_year FROM wells WHERE drill_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (vessel_id INT, vessel_name TEXT); INSERT INTO vessels VALUES (1, 'Vessel A'), (2, 'Vessel B'); CREATE TABLE shipments (shipment_id INT, vessel_id INT, port_id INT, cargo_tonnage INT, ship_date DATE); INSERT INTO shipments VALUES (1, 1, 4, 5000, '2021-01-01'), (2, 1, 4, 3000, '2021-02-01'), (3, 2, 4, 4000, '2021-03-01'); CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports VALUES (4, 'Port of Santos', 'Brazil'), (5, 'Port of New York', 'USA');
|
What is the average cargo tonnage shipped by each vessel from the Port of Santos to the United States in 2021?
|
SELECT vessels.vessel_name, AVG(shipments.cargo_tonnage) FROM vessels JOIN shipments ON vessels.vessel_id = shipments.vessel_id JOIN ports ON shipments.port_id = ports.port_id WHERE ports.port_name = 'Port of Santos' AND ports.country = 'USA' AND YEAR(shipments.ship_date) = 2021 GROUP BY vessels.vessel_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (id INT, volunteer_name TEXT, country TEXT); INSERT INTO Volunteers (id, volunteer_name, country) VALUES (1, 'James Smith', 'United States');
|
Identify the top 3 countries with the highest total number of volunteers.
|
SELECT country, COUNT(*) as num_volunteers FROM Volunteers GROUP BY country ORDER BY num_volunteers DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditures (drug_name TEXT, expenditure DECIMAL(10, 2), expenditure_date DATE); INSERT INTO rd_expenditures (drug_name, expenditure, expenditure_date) VALUES ('DrugD', 150000.00, '2021-07-01');
|
Increase R&D expenditures for 'DrugD' by 10% in Q3 2021.
|
UPDATE rd_expenditures SET expenditure = expenditure * 1.10 WHERE drug_name = 'DrugD' AND expenditure_date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE all_users (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO all_users (id, state, water_usage) VALUES (1, 'California', 12.5), (2, 'California', 15.6), (3, 'New York', 10.2), (4, 'New York', 11.3);
|
What is the total water usage by all users in the states of California and New York?
|
SELECT SUM(water_usage) FROM all_users WHERE state IN ('California', 'New York');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Garments (id INT, name VARCHAR(255), category VARCHAR(255), color VARCHAR(255), size VARCHAR(10), price DECIMAL(5, 2));
|
List all garments that are available in size 'L' and color 'Blue'
|
SELECT * FROM Garments WHERE size = 'L' AND color = 'Blue';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_ratings (vehicle_make VARCHAR(255), safety_score INT);
|
Delete records in the 'safety_ratings' table for the 'vehicle_make' 'Lucid'
|
DELETE FROM safety_ratings WHERE vehicle_make = 'Lucid';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy (factory_id INT, renewable BOOLEAN); INSERT INTO energy (factory_id, renewable) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, FALSE), (5, TRUE), (6, FALSE);
|
What percentage of factories use renewable energy sources?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM energy)) as percentage FROM energy WHERE renewable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_scores (user_id INT, game_name VARCHAR(10), score INT); INSERT INTO game_scores (user_id, game_name, score) VALUES (1, 'A', 50), (1, 'A', 75), (2, 'B', 100);
|
Calculate the average score of user 1 for game 'A'
|
SELECT AVG(score) FROM game_scores WHERE user_id = 1 AND game_name = 'A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE south_china_sea_platforms (year INT, region VARCHAR(20), num_platforms INT); INSERT INTO south_china_sea_platforms (year, region, num_platforms) VALUES (2015, 'South China Sea', 1500), (2016, 'South China Sea', 1550), (2017, 'South China Sea', 1600), (2018, 'South China Sea', 1650), (2019, 'South China Sea', 1700), (2020, 'South China Sea', 1750);
|
List the number of offshore drilling platforms in the South China Sea as of 2018.
|
SELECT num_platforms FROM south_china_sea_platforms WHERE year = 2018 AND region = 'South China Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forests (id INT, state VARCHAR(255), volume_ha INT, year INT); INSERT INTO forests (id, state, volume_ha, year) VALUES (1, 'Vermont', 1000, 2020), (2, 'California', 2000, 2020);
|
find the total volume of timber harvested in the state of Vermont in 2020
|
SELECT SUM(volume_ha) FROM forests WHERE state = 'Vermont' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers_usage (subscriber_id INT, usage_date DATE); INSERT INTO mobile_subscribers_usage (subscriber_id, usage_date) VALUES (1, '2021-01-01'); INSERT INTO mobile_subscribers_usage (subscriber_id, usage_date) VALUES (2, '2021-07-01');
|
Delete mobile subscribers who have not used their service in the last 12 months.
|
DELETE FROM mobile_subscribers WHERE subscriber_id NOT IN (SELECT subscriber_id FROM mobile_subscribers_usage WHERE usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE awards (id INT, artist_id INT, genre VARCHAR(255), year INT, awards INT); INSERT INTO awards (id, artist_id, genre, year, awards) VALUES (1, 1, 'Country', 2015, 3);
|
What is the minimum number of awards won by country music artists since 2015?
|
SELECT MIN(awards) FROM awards WHERE genre = 'Country' AND year >= 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (id INT, cases INT, billing_rate DECIMAL(5,2));
|
Find the average billing rate for attorneys who have handled more than 5 cases.
|
SELECT AVG(billing_rate) FROM Attorneys WHERE cases > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE JuvenileOffenders (OffenderID INT, OffenderName VARCHAR(50), State VARCHAR(20)); INSERT INTO JuvenileOffenders VALUES (1, 'JO 1', 'CA'); INSERT INTO JuvenileOffenders VALUES (2, 'JO 2', 'CA'); INSERT INTO JuvenileOffenders VALUES (3, 'JO 3', 'NY');
|
How many juvenile offenders are there in each state?
|
SELECT State, COUNT(*) FROM JuvenileOffenders GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AtmosphericMonitoringStation (id INT, year INT, month INT, co2_level FLOAT); INSERT INTO AtmosphericMonitoringStation (id, year, month, co2_level) VALUES (1, 2020, 1, 415.3), (2, 2020, 2, 417.8), (3, 2020, 3, 420.1);
|
What is the average CO2 level per month in the AtmosphericMonitoringStation?
|
SELECT month, AVG(co2_level) FROM AtmosphericMonitoringStation GROUP BY year, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment_acquisition (equipment_id INT, cost FLOAT, acquisition_date DATE); INSERT INTO military_equipment_acquisition (equipment_id, cost, acquisition_date) VALUES (1, 1000000, '2022-01-01'), (2, 2000000, '2022-04-01');
|
Determine the total cost of military equipment acquired in Q1 2022
|
SELECT SUM(cost) FROM military_equipment_acquisition WHERE acquisition_date >= '2022-01-01' AND acquisition_date < '2022-04-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50), FoodSafetyScore int); INSERT INTO Restaurants (RestaurantID, Name, Location, FoodSafetyScore) VALUES (1, 'Big Burger', 'Downtown', 95);
|
What is the average food safety score for restaurants in 'Downtown'?
|
SELECT AVG(FoodSafetyScore) as AvgFoodSafetyScore FROM Restaurants WHERE Location = 'Downtown';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VehicleSafetyTesting (VehicleID INT, TestName VARCHAR(20), Score INT, VehicleType VARCHAR(10)); CREATE TABLE ElectricVehicleAdoption (Location VARCHAR(10), Year INT, AdoptionRate FLOAT);
|
What is the average safety score for electric vehicles in each location?
|
SELECT E.Location, AVG(V.Score) FROM VehicleSafetyTesting V INNER JOIN ElectricVehicleAdoption E ON V.VehicleID = (SELECT VehicleID FROM VehicleTypes WHERE VehicleType = 'Electric') GROUP BY E.Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lenders (lender_id INT, name VARCHAR(255), address VARCHAR(255)); CREATE TABLE loans (loan_id INT, lender_id INT, date DATE, amount DECIMAL(10,2), socially_responsible BOOLEAN);
|
How many socially responsible loans were issued by each lender in the last month?
|
SELECT lenders.name, COUNT(loans.loan_id) as count FROM lenders INNER JOIN loans ON lenders.lender_id = loans.lender_id WHERE loans.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND loans.socially_responsible = TRUE GROUP BY lenders.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists metro_fares (id INT, city VARCHAR(20), fare DECIMAL(3,2));
|
Insert a new record for metro fares in Mumbai with a fare of 0.80
|
INSERT INTO metro_fares (city, fare) VALUES ('Mumbai', 0.80);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE high_blood_pressure(id INT, location TEXT, population INT, cases INT); INSERT INTO high_blood_pressure(id, location, population, cases) VALUES (1, 'Florida Rural Area', 3000, 500), (2, 'Florida Urban Area', 10000, 1500), (3, 'Georgia Rural Area', 6000, 900), (4, 'Georgia Urban Area', 12000, 1800);
|
What is the number of patients with high blood pressure in "Florida" rural areas
|
SELECT cases FROM high_blood_pressure WHERE location LIKE '%Florida Rural Area%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (name VARCHAR(255), avg_depth FLOAT); INSERT INTO marine_species (name, avg_depth) VALUES ('Anglerfish', 1000);
|
Which marine species has the smallest average depth?
|
SELECT name, MIN(avg_depth) as min_depth FROM marine_species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, plan_type VARCHAR(10), region VARCHAR(20), data_usage_date DATE); INSERT INTO mobile_subscribers (subscriber_id, data_usage, plan_type, region, data_usage_date) VALUES (1, 3.5, 'postpaid', 'Urban', '2022-04-01'), (2, 6.2, 'postpaid', 'Rural', '2022-04-05'), (3, 8.1, 'prepaid', 'Rural', '2022-04-10');
|
What is the total data usage in GB for each region in April 2022?
|
SELECT region, SUM(data_usage * 0.001024) as total_data_usage_gb FROM mobile_subscribers WHERE data_usage_date BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE commercial_permit_data (permit_id INT, permit_type TEXT, state TEXT, sqft INT); INSERT INTO commercial_permit_data (permit_id, permit_type, state, sqft) VALUES (1, 'General', 'Washington', 15000), (2, 'Tenant Improvement', 'Washington', 7000), (3, 'Change of Use', 'Washington', 22000);
|
What is the average square footage of commercial projects in the state of Washington, partitioned by permit type?
|
SELECT permit_type, AVG(sqft) FROM commercial_permit_data WHERE state = 'Washington' GROUP BY permit_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, program VARCHAR(50), country VARCHAR(50)); CREATE TABLE Programs (id INT, program VARCHAR(50), country VARCHAR(50)); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (1, 50.00, '2021-01-01', 'Education', 'India'); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (2, 100.00, '2021-01-02', 'Health', 'India'); INSERT INTO Programs (id, program, country) VALUES (1, 'Education', 'India'); INSERT INTO Programs (id, program, country) VALUES (2, 'Health', 'India');
|
What is the average donation amount per month for each program in India?
|
SELECT p.program, EXTRACT(MONTH FROM d.donation_date) as month, AVG(d.donation_amount) as avg_donation_per_month FROM Donations d INNER JOIN Programs p ON d.program = p.program WHERE d.country = 'India' GROUP BY p.program, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, customer_id INT, menu_id INT, order_date DATE, region TEXT); CREATE TABLE menus (menu_id INT, menu_name TEXT, category TEXT, price DECIMAL(5,2)); INSERT INTO orders (order_id, customer_id, menu_id, order_date, region) VALUES (1, 1, 1, '2022-01-01', 'North'), (2, 2, 2, '2022-01-02', 'South'), (3, 3, 3, '2022-01-03', 'West'); INSERT INTO menus (menu_id, menu_name, category, price) VALUES (1, 'Classic Burger', 'Beef', 7.99), (2, 'Veggie Burger', 'Vegetarian', 6.99), (3, 'Tofu Wrap', 'Vegan', 5.99);
|
Which menu items are not selling well in the West region?
|
SELECT m.menu_name, COUNT(o.menu_id) as count FROM menus m LEFT JOIN orders o ON m.menu_id = o.menu_id AND o.region = 'West' GROUP BY m.menu_name HAVING COUNT(o.menu_id) < 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members(member_id INT, name VARCHAR(50), member_type VARCHAR(50)); INSERT INTO members (member_id, name, member_type) VALUES (1, 'John Doe', 'Individual'), (2, 'Jane Smith', 'Family'), (3, 'Alice Johnson', 'Individual');
|
What is the total number of visitors who are members of the museum, broken down by member type?
|
SELECT member_type, COUNT(member_id) FROM members GROUP BY member_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, Size INT, Sustainable BOOLEAN);
|
What is the average size of sustainable properties in each neighborhood?
|
SELECT NeighborhoodName, AVG(Size) AS AvgSize FROM Properties JOIN Neighborhoods ON Properties.NeighborhoodID = Neighborhoods.NeighborhoodID WHERE Sustainable = TRUE GROUP BY NeighborhoodName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment (garment_id INT, country VARCHAR(50), co2_emission INT);
|
Which country has the highest average CO2 emission per garment?
|
SELECT country, AVG(co2_emission) AS avg_co2_emission FROM garment GROUP BY country ORDER BY avg_co2_emission DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (id INT, user_id INT, type VARCHAR(20), amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions (id, user_id, type, amount, transaction_date) VALUES (1, 1, 'credit', 100.00, '2022-01-01'), (2, 1, 'debit', 50.00, '2022-01-05'), (3, 2, 'credit', 200.00, '2022-01-03'), (4, 2, 'debit', 150.00, '2022-01-31'), (5, 3, 'credit', 300.00, '2022-02-01');
|
Identify the users who have made at least one transaction of type 'credit' but have no transactions of type 'debit' in the last 30 days.
|
SELECT user_id FROM transactions t1 WHERE type = 'credit' AND user_id NOT IN (SELECT user_id FROM transactions t2 WHERE type = 'debit' AND t2.transaction_date > t1.transaction_date - INTERVAL '30' DAY) GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (mine_id INT, emission_date DATE, co2_amount INT); INSERT INTO co2_emissions (mine_id, emission_date, co2_amount) VALUES (1, '2021-01-01', 30000), (1, '2021-02-01', 32000), (1, '2021-03-01', 35000), (2, '2021-01-01', 28000), (2, '2021-02-01', 30000), (2, '2021-03-01', 33000), (3, '2021-01-01', 25000), (3, '2021-02-01', 27000), (3, '2021-03-01', 29000), (4, '2021-01-01', 22000), (4, '2021-02-01', 24000), (4, '2021-03-01', 26000);
|
What is the total CO2 emission per quarter for each mine?
|
SELECT mine_id, DATE_TRUNC('quarter', emission_date) AS quarter, SUM(co2_amount) AS total_emission FROM co2_emissions GROUP BY mine_id, quarter ORDER BY mine_id, quarter;
|
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.