context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE ethereum_network (network_name TEXT, smart_contract_count INTEGER, smart_contract_hash TEXT);
|
What is the total number of smart contracts and their unique hashes for the 'Ethereum' network?
|
SELECT network_name, COUNT(DISTINCT smart_contract_hash) as total_smart_contracts, COUNT(*) as total_count FROM ethereum_network GROUP BY network_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (innovation_id INT, innovation_name VARCHAR(255), category VARCHAR(255), date DATE); INSERT INTO military_innovation (innovation_id, innovation_name, category, date) VALUES (1, 'Innovation A', 'Unmanned Aerial Vehicles', '2018-01-01'), (2, 'Innovation B', 'Cybersecurity', '2019-01-01'), (3, 'Innovation C', 'Unmanned Aerial Vehicles', '2020-01-01'); CREATE TABLE categories (category VARCHAR(255));
|
What is the name of the most recent military innovation in the area of cybersecurity?
|
SELECT innovation_name FROM military_innovation INNER JOIN categories ON military_innovation.category = categories.category WHERE category = 'Cybersecurity' AND date = (SELECT MAX(date) FROM military_innovation);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu(id INT, item VARCHAR(255), cuisine VARCHAR(255), popularity INT); INSERT INTO menu(id, item, cuisine, popularity) VALUES (1, 'Pizza', 'Italian', 50), (2, 'Spaghetti', 'Italian', 30), (3, 'Tacos', 'Mexican', 70), (4, 'Burritos', 'Mexican', 40);
|
What is the most popular menu item for each cuisine type?
|
SELECT cuisine, item, popularity FROM (SELECT cuisine, item, popularity, RANK() OVER (PARTITION BY cuisine ORDER BY popularity DESC) as rank FROM menu) subquery WHERE rank = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists cultural_competency_scores (score INT, race VARCHAR(255)); INSERT INTO cultural_competency_scores (score, race) VALUES (90, 'Hispanic'), (85, 'African American'), (95, 'Asian');
|
What is the maximum cultural competency score by race?
|
SELECT MAX(score), race FROM cultural_competency_scores GROUP BY race;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (route_id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); CREATE TABLE route_stops (route_id INT, station_id INT);
|
List all routes with their corresponding stops
|
SELECT r.name AS route_name, s.name AS station_name FROM routes r JOIN route_stops rs ON r.route_id = rs.route_id JOIN stations s ON rs.station_id = s.station_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artist_streams (artist_id INT, streams INT, stream_date DATE); CREATE TABLE festival_performances (artist_id INT, festival_id INT, performance_date DATE);
|
How many streams did each artist have in the last month, for artists who performed at music festivals in the last year?
|
SELECT a.artist_id, SUM(s.streams) as total_streams FROM artist_streams s JOIN festival_performances f ON s.artist_id = f.artist_id WHERE s.stream_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND f.performance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY a.artist_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seals (id INT, name VARCHAR(255), location VARCHAR(255));
|
How many seals are there in the 'seals' table?
|
SELECT COUNT(*) FROM seals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (1, 'TechFem', 'Technology', 2015, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (2, 'GreenInno', 'GreenTech', 2018, 'Male');
|
What is the number of startups founded by women in the technology sector with no funding records?
|
SELECT COUNT(*) FROM companies WHERE founder_gender = 'Female' AND industry = 'Technology' AND id NOT IN (SELECT company_id FROM funding_records);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product VARCHAR(20), region VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO sales (sale_id, product, region, revenue) VALUES (1, 'Software', 'North', 5000.00), (2, 'Hardware', 'South', 3000.00), (3, 'Consulting', 'East', 7000.00);
|
What is the total revenue generated per region?
|
SELECT region, SUM(revenue) as total_revenue FROM sales GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE art_workshops (id INT, age INT, city VARCHAR(50)); INSERT INTO art_workshops (id, age, city) VALUES (1, 27, 'New York'), (2, 32, 'Los Angeles');
|
What was the total number of art workshops attended by adults aged 25-34 in New York?
|
SELECT SUM(1) FROM art_workshops WHERE age BETWEEN 25 AND 34 AND city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (restaurant_id INT, revenue_date DATE, total_revenue DECIMAL(10, 2));
|
Delete records in the restaurant_revenue table with a total_revenue less than 2500
|
DELETE FROM restaurant_revenue WHERE total_revenue < 2500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE economic_impact (id INT, country VARCHAR(50), impact FLOAT); INSERT INTO economic_impact (id, country, impact) VALUES (1, 'India', 5000), (2, 'Japan', 6000), (3, 'Italy', 7000);
|
List the top 3 countries with the highest local economic impact from tourism?
|
SELECT country, impact FROM economic_impact WHERE row_number() OVER (ORDER BY impact DESC) <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitats (id INT, name VARCHAR(255));CREATE TABLE animals (id INT, species_id INT, habitat_id INT);CREATE TABLE species (id INT, name VARCHAR(255));CREATE TABLE community_outreach (id INT, habitat_id INT, animal_id INT); INSERT INTO habitats (id, name) VALUES (1, 'Forest'), (2, 'Savannah'); INSERT INTO animals (id, species_id, habitat_id) VALUES (1, 1, 2), (2, 2, 1), (3, 3, 2), (4, 1, 2), (5, 4, 1); INSERT INTO species (id, name) VALUES (1, 'Lion'), (2, 'Elephant'), (3, 'Giraffe'), (4, 'Zebra'); INSERT INTO community_outreach (id, habitat_id, animal_id) VALUES (1, 1, 2), (2, 1, 3), (3, 2, 1), (4, 2, 4), (5, 2, 5);
|
List habitats, the number of species in each, and the number of animals they protect
|
SELECT h.name AS habitat_name, COUNT(DISTINCT s.id) AS species_count, COUNT(co.animal_id) AS animals_protected FROM community_outreach co INNER JOIN animals a ON co.animal_id = a.id INNER JOIN species s ON a.species_id = s.id INNER JOIN habitats h ON a.habitat_id = h.id GROUP BY h.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(255), country VARCHAR(255), donation DECIMAL(10,2));
|
What is the average amount of donations made by individuals from the United States?
|
SELECT AVG(donation) FROM donors WHERE country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (team VARCHAR(50), location VARCHAR(50), date DATE); INSERT INTO games (team, location, date) VALUES ('Los Angeles Dodgers', 'Home', '2022-06-01'), ('Los Angeles Dodgers', 'Away', '2022-06-03'), ('New York Yankees', 'Home', '2022-06-02'), ('Los Angeles Dodgers', 'Home', '2022-06-04');
|
How many home games did the 'los_angeles_dodgers' play in the 'games' table?
|
SELECT COUNT(*) FROM games WHERE team = 'Los Angeles Dodgers' AND location = 'Home';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oil_production (production_id INT PRIMARY KEY, company_name VARCHAR(255), year INT, yearly_production BIGINT);
|
Update the 'oil_production' table to set the yearly_production to 1000000 for all records where the company_name = 'Green Oil Inc.'
|
UPDATE oil_production SET yearly_production = 1000000 WHERE company_name = 'Green Oil Inc.';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_teams (id INT, team VARCHAR(50), wins INT, losses INT, season VARCHAR(10)); INSERT INTO nba_teams (id, team, wins, losses, season) VALUES (1, 'Boston Celtics', 60, 20, '2023'), (2, 'LA Lakers', 45, 35, '2023');
|
Show the total number of wins for each team in the 2023 NBA season.
|
SELECT team, SUM(wins) FROM nba_teams WHERE season = '2023';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_life_biomass (id INT, location TEXT, biomass FLOAT); INSERT INTO marine_life_biomass (id, location, biomass) VALUES (1, 'Atlantic Ocean', 1500000.0), (2, 'Pacific Ocean', 1200000.0);
|
What is the total biomass of all marine life in the Atlantic Ocean?
|
SELECT SUM(biomass) FROM marine_life_biomass WHERE location = 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OrganicWasteData (country VARCHAR(50), population INT, organic_waste_kg FLOAT); INSERT INTO OrganicWasteData (country, population, organic_waste_kg) VALUES ('Spain', 47351247, 3.8);
|
What is the average organic waste generation per capita in Spain?
|
SELECT AVG(organic_waste_kg/population) FROM OrganicWasteData WHERE country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, exit_date DATE); CREATE TABLE exits (id INT, startup_id INT, exit_date DATE);
|
List all startups that have not exited
|
SELECT startups.name FROM startups LEFT JOIN exits ON startups.id = exits.startup_id WHERE exits.exit_date IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE content_creators (id INT, name TEXT, country TEXT, media_literacy_score INT); INSERT INTO content_creators (id, name, country, media_literacy_score) VALUES (1, 'Alice', 'USA', 80), (2, 'Bob', 'USA', 85);
|
What is the average media literacy score for content creators in the United States?
|
SELECT AVG(media_literacy_score) FROM content_creators WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE extreme_weather_data (region VARCHAR(255), year INT, days_with_extreme_weather INT);
|
What is the number of days with extreme weather events in each region over the last 5 years?
|
SELECT region, SUM(days_with_extreme_weather) OVER (PARTITION BY region) FROM extreme_weather_data WHERE year BETWEEN 2018 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InternationalDonations (DonationID INT, DonorID INT, Country VARCHAR(50), DonationAmount DECIMAL(10, 2), DonationDate DATE);
|
Identify the top 3 countries with the highest total donation amounts in the 'InternationalDonations' table.
|
SELECT Country, SUM(DonationAmount) AS TotalDonations FROM InternationalDonations GROUP BY Country ORDER BY TotalDonations DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name TEXT, recycling_rate DECIMAL(5,4)); INSERT INTO districts (district_id, district_name, recycling_rate) VALUES (1, 'District A', 0.35), (2, 'District B', 0.45), (3, 'District C', 0.55);
|
Which district had the highest recycling rate in 2019?
|
SELECT district_name, MAX(recycling_rate) FROM districts WHERE YEAR(districts.date) = 2019 GROUP BY district_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE steps (user_id INT, steps INT, step_date DATE); INSERT INTO steps (user_id, steps, step_date) VALUES (1, 5000, '2022-01-01'), (2, 7000, '2022-01-01'), (3, 8000, '2022-01-02'), (4, 9000, '2022-01-02');
|
What is the total number of steps taken by users in a day?
|
SELECT SUM(steps) FROM steps GROUP BY step_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genres (genre VARCHAR(10), song_id INT, song_length FLOAT); INSERT INTO genres (genre, song_id, song_length) VALUES ('metal', 22, 175.2), ('metal', 23, 160.8), ('metal', 24, 205.9);
|
What is the maximum song_length in the metal genre?
|
SELECT MAX(song_length) FROM genres WHERE genre = 'metal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50), favorite_genre VARCHAR(50)); INSERT INTO users (id, name, country, favorite_genre) VALUES (1, 'Alice', 'USA', 'Pop'), (2, 'Bob', 'Canada', 'Rock'), (3, 'Charlie', 'Canada', 'Rock'), (4, 'David', 'USA', 'Jazz'), (5, 'Eve', 'USA', 'Pop'), (6, 'Frank', 'Canada', 'Country'), (7, 'Grace', 'Canada', 'Country'), (8, 'Harry', 'USA', 'R&B'), (9, 'Ivy', 'USA', 'Pop'), (10, 'Jack', 'USA', 'Jazz');
|
What is the most popular genre among users in 'Canada'?
|
SELECT favorite_genre, COUNT(*) as genre_count FROM users WHERE country = 'Canada' GROUP BY favorite_genre ORDER BY genre_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmers (FarmerID int, FarmerName text, Location text); INSERT INTO Farmers (FarmerID, FarmerName, Location) VALUES (1, 'John Doe', 'California'); CREATE TABLE Production (Product text, FarmerID int, Quantity int); INSERT INTO Production (Product, FarmerID, Quantity) VALUES ('Broccoli', 1, 500);
|
What is the total production of 'Broccoli' by all farmers in 'California'?
|
SELECT SUM(Quantity) FROM Production JOIN Farmers ON Production.FarmerID = Farmers.FarmerID WHERE Product = 'Broccoli' AND Location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Bikes (bike_id INT, bike_type VARCHAR(20)); INSERT INTO Bikes (bike_id, bike_type) VALUES (1, 'Mountain Bike'), (2, 'Road Bike'), (3, 'Hybrid Bike');
|
Delete all records from the 'Bikes' table where 'bike_type' is 'Hybrid Bike'
|
DELETE FROM Bikes WHERE bike_type = 'Hybrid Bike';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE whale_sightings_2021 (ocean VARCHAR(255), num_whales INT); INSERT INTO whale_sightings_2021 (ocean, num_whales) VALUES ('Atlantic', 150), ('Pacific', 210), ('Indian', 180), ('Arctic', 120);
|
What is the total number of whales spotted in all oceans in 2021?
|
SELECT SUM(num_whales) FROM whale_sightings_2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE NetworkDevices (id INT, device_name VARCHAR(50), severity VARCHAR(10), discovered_date DATE); INSERT INTO NetworkDevices (id, device_name, severity, discovered_date) VALUES (1, 'Router1', 'High', '2021-08-01'), (2, 'Switch1', 'Medium', '2021-07-15'), (3, 'Firewall1', 'Low', '2021-06-01'), (4, 'Router2', 'High', '2021-09-01'), (5, 'Switch2', 'Low', '2021-07-15');
|
What are the top 5 most vulnerable devices in the 'NetworkDevices' table, based on the number of vulnerabilities?
|
SELECT device_name, COUNT(*) as number_of_vulnerabilities FROM NetworkDevices GROUP BY device_name ORDER BY number_of_vulnerabilities DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ROUTE_SEGMENTS (route_id TEXT, segment_start TEXT, segment_end TEXT, fare REAL, collection_date DATE); INSERT INTO ROUTE_SEGMENTS (route_id, segment_start, segment_end, fare, collection_date) VALUES ('1', 'Start1', 'End1', 2.5, '2022-03-01'), ('2', 'Start2', 'End2', 3.0, '2022-03-02'), ('1', 'Start3', 'End3', 2.3, '2022-03-03');
|
What is the total fare collected for each route segment in the past month?
|
SELECT route_id, SUM(fare) FROM ROUTE_SEGMENTS WHERE collection_date >= (CURRENT_DATE - INTERVAL '30 days') GROUP BY route_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Salmon_farms (id INT, name TEXT, country TEXT, water_temp FLOAT); INSERT INTO Salmon_farms (id, name, country, water_temp) VALUES (1, 'Farm A', 'Norway', 8.5), (2, 'Farm B', 'Canada', 2.0);
|
What is the average water temperature in January for all Salmon farms?
|
SELECT AVG(water_temp) FROM Salmon_farms WHERE MONTH(created_at) = 1 AND species = 'Salmon';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (donation_id INT, donor_city VARCHAR(50), donation_amount DECIMAL(10,2)); INSERT INTO donations VALUES (1, 'NYC', 100.00), (2, 'LA', 200.00), (3, 'SF', 150.00), (4, 'Seattle', 250.00);
|
What is the total donation amount by city for cities that start with 'S'?
|
SELECT SUM(donation_amount) FROM donations WHERE donor_city LIKE 'S%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Service (id INT, department_id INT, name VARCHAR(50), cost DECIMAL(10,2)); INSERT INTO Service (id, department_id, name, cost) VALUES (1, 1, 'Service1', 10000.00); INSERT INTO Service (id, department_id, name, cost) VALUES (2, 1, 'Service2', 15000.00); INSERT INTO Service (id, department_id, name, cost) VALUES (3, 2, 'Service3', 20000.00); CREATE TABLE Department (id INT, city_id INT, name VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Department (id, city_id, name, budget) VALUES (1, 1, 'DeptX', 500000.00); INSERT INTO Department (id, city_id, name, budget) VALUES (2, 1, 'DeptY', 750000.00); INSERT INTO Department (id, city_id, name, budget) VALUES (3, 2, 'DeptZ', 1000000.00);
|
What is the total budget for services in a department with a name starting with 'D'?
|
SELECT SUM(Service.cost) FROM Service INNER JOIN Department ON Service.department_id = Department.id WHERE Department.name LIKE 'D%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm (id INT, name VARCHAR(50)); CREATE TABLE IotDevice (id INT, name VARCHAR(50), farm_id INT); INSERT INTO Farm (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'); INSERT INTO IotDevice (id, name, farm_id) VALUES (1, 'Device 1', 3), (2, 'Device 2', 3);
|
What is the number of IoT devices in farm C?
|
SELECT COUNT(*) FROM IotDevice WHERE farm_id = (SELECT id FROM Farm WHERE name = 'Farm C');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data_2 (year INT, company_name TEXT, element TEXT, quantity INT); INSERT INTO production_data_2 (year, company_name, element, quantity) VALUES (2018, 'RST Mining', 'Gadolinium', 1200), (2019, 'STW Mining', 'Gadolinium', 1500), (2020, 'TUV Mining', 'Gadolinium', 1800);
|
Update all records related to Gadolinium production in the production_data_2 table to 1000 metric tons?
|
UPDATE production_data_2 SET quantity = 1000 WHERE element = 'Gadolinium';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Bridge_Inspections (inspection_id INT, bridge_name VARCHAR(50), bridge_type VARCHAR(50), inspection_date DATE);
|
Calculate the average inspection frequency for all bridges in the Bridge_Inspections table
|
SELECT AVG(DATEDIFF(inspection_date, LAG(inspection_date) OVER (PARTITION BY bridge_name ORDER BY inspection_date))) FROM Bridge_Inspections WHERE bridge_type = 'Bridge';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT, name VARCHAR(255), system_type VARCHAR(255)); INSERT INTO farmers (id, name, system_type) VALUES (1, 'Jane Doe', 'Urban Agriculture'); INSERT INTO farmers (id, name, system_type) VALUES (2, 'John Smith', 'Agroecology'); INSERT INTO farmers (id, name, system_type) VALUES (3, 'Maria Garcia', 'Indigenous Food Systems'); INSERT INTO farmers (id, name, system_type) VALUES (4, 'Ali Ahmed', 'Urban Agriculture'); CREATE TABLE farmer_revenue (farmer_id INT, revenue FLOAT); INSERT INTO farmer_revenue (farmer_id, revenue) VALUES (1, 12000.00); INSERT INTO farmer_revenue (farmer_id, revenue) VALUES (2, 9000.00); INSERT INTO farmer_revenue (farmer_id, revenue) VALUES (3, 8500.00); INSERT INTO farmer_revenue (farmer_id, revenue) VALUES (4, 15000.00);
|
Which farmers have the highest revenue from urban agriculture?
|
SELECT farmers.name, MAX(farmer_revenue.revenue) as highest_revenue FROM farmers JOIN farmer_revenue ON farmers.id = farmer_revenue.farmer_id WHERE farmers.system_type = 'Urban Agriculture' GROUP BY farmers.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, school_district VARCHAR(255), date DATE); INSERT INTO student_mental_health (student_id, mental_health_score, school_district, date) VALUES (1, 75, 'ABC School District', '2022-02-01'); CREATE VIEW winter_2022_smh AS SELECT * FROM student_mental_health WHERE date BETWEEN '2022-01-01' AND '2022-03-31';
|
What is the minimum mental health score of students in 'Winter 2022' by school district?
|
SELECT MIN(mental_health_score) as min_mental_health, school_district FROM winter_2022_smh GROUP BY school_district;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AdvocacyEvents (EventID INT, EventName VARCHAR(50), EventDate DATETIME); INSERT INTO AdvocacyEvents (EventID, EventName, EventDate) VALUES (1, 'Event A', '2021-01-01'), (2, 'Event B', '2021-02-01'), (3, 'Event C', '2021-07-01'), (4, 'Event D', '2021-08-01');
|
Delete the record of the disability policy advocacy event that took place on 2021-07-01.
|
DELETE FROM AdvocacyEvents WHERE EventDate = '2021-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MusicEvents (id INT, name VARCHAR(255), country VARCHAR(255), UNIQUE (id)); CREATE TABLE Performers (id INT, name VARCHAR(255), music_event_id INT, UNIQUE (id), FOREIGN KEY (music_event_id) REFERENCES MusicEvents(id)); CREATE TABLE Attendance (id INT, music_event_id INT, year INT, attendees INT, UNIQUE (id), FOREIGN KEY (music_event_id) REFERENCES MusicEvents(id));
|
Identify traditional music events in Mexico with more than 3 performers and an average attendance greater than 50 in the last 3 years.
|
SELECT me.name FROM MusicEvents me JOIN Performers p ON me.id = p.music_event_id JOIN Attendance a ON me.id = a.music_event_id WHERE me.country = 'Mexico' GROUP BY me.name HAVING COUNT(DISTINCT p.id) > 3 AND AVG(a.attendees) > 50 AND a.year BETWEEN 2020 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, technology VARCHAR(20), region VARCHAR(50), daily_data_usage INT); INSERT INTO mobile_subscribers (subscriber_id, technology, region, daily_data_usage) VALUES (1, '4G', 'North', 1000), (2, '5G', 'North', 2000), (3, '3G', 'South', 1500), (4, '5G', 'East', 2500), (5, '5G', 'North', 3000), (6, '3G', 'South', 1800), (7, '4G', 'West', 2200);
|
What is the average daily data usage by mobile subscribers for each technology in the Southern region?
|
SELECT technology, region, AVG(daily_data_usage) AS avg_daily_data_usage FROM mobile_subscribers WHERE region = 'South' GROUP BY technology, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, drug_name TEXT, sale_region TEXT, sale_amount INT, sale_date DATE); INSERT INTO sales (sale_id, drug_name, sale_region, sale_amount, sale_date) VALUES (1, 'DrugA', 'Europe', 1500000, '2020-01-01'), (2, 'DrugA', 'US', 2000000, '2020-12-31'), (3, 'DrugB', 'Europe', 1200000, '2020-07-04');
|
What is the total sales amount for a specific drug in a given region for the year 2020?
|
SELECT SUM(sale_amount) FROM sales WHERE drug_name = 'DrugA' AND sale_region = 'Europe' AND sale_date >= '2020-01-01' AND sale_date <= '2020-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if NOT EXISTS iot_sensors_2 (id int, location varchar(50), temperature float, timestamp datetime); INSERT INTO iot_sensors_2 (id, location, temperature, timestamp) VALUES (1, 'Australia', 18.2, '2022-03-15 10:00:00');
|
What is the minimum temperature recorded by IoT sensors in Australia in the last week?
|
SELECT MIN(temperature) FROM iot_sensors_2 WHERE location = 'Australia' AND timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region_waste (region VARCHAR(50), year INT, waste_amount FLOAT); INSERT INTO region_waste (region, year, waste_amount) VALUES ('Asia', 2021, 500.5), ('Europe', 2021, 450.2), ('Africa', 2021, 300.1), ('Australia', 2021, 250.6), ('North America', 2021, 200.9), ('Asia', 2021, 550.7), ('Europe', 2021, 475.3), ('Africa', 2021, 320.5), ('Australia', 2021, 260.8), ('North America', 2021, 220.4);
|
Get the top three regions with the highest chemical waste production in 2021 and the total waste produced.
|
SELECT region, SUM(waste_amount) as total_waste FROM region_waste WHERE year = 2021 GROUP BY region ORDER BY total_waste DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie (id INT, title VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); INSERT INTO movie (id, title, genre, country) VALUES (1, 'Movie1', 'Comedy', 'Spain'), (2, 'Movie2', 'Drama', 'France'), (3, 'Movie3', 'Action', 'Germany'), (4, 'Movie4', 'Adventure', 'Germany');
|
What are the names of the movies and their genres for movies produced in Germany?
|
SELECT title, genre FROM movie WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_info (animal_id INT, conservation_status VARCHAR(20)); INSERT INTO animal_info (animal_id, conservation_status) VALUES (1, 'endangered'), (2, 'vulnerable'), (3, 'threatened'), (4, 'endangered'), (5, 'vulnerable');
|
List all unique conservation statuses in the 'animal_info' table
|
SELECT DISTINCT conservation_status FROM animal_info;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists_nma (id INT, name VARCHAR(50), country VARCHAR(30)); INSERT INTO artists_nma (id, name, country) VALUES (1, 'Artist1', 'USA'), (2, 'Artist2', 'Canada'), (3, 'Artist3', 'Mexico'); CREATE TABLE countries (id INT, country VARCHAR(30), capital VARCHAR(30)); INSERT INTO countries (id, country, capital) VALUES (1, 'USA', 'Washington DC'), (2, 'Canada', 'Ottawa'), (3, 'Mexico', 'Mexico City');
|
Find the number of artists from each country, who have been awarded the National Medal of Arts, and the name of the country's capital.
|
SELECT c.capital, a.country, COUNT(a.id) as artist_count FROM artists_nma a JOIN countries c ON a.country = c.country GROUP BY a.country, c.capital;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cause_average (cause VARCHAR(50), country VARCHAR(50), donation DECIMAL(10,2)); INSERT INTO cause_average (cause, country, donation) VALUES ('Global Health', 'Nigeria', 500.00), ('Education', 'South Africa', 600.00), ('Environment', 'Kenya', 700.00), ('Animal Welfare', 'Tanzania', 800.00);
|
What is the average donation amount for each cause in Sub-Saharan Africa?
|
SELECT cause, AVG(donation) FROM cause_average WHERE country IN ('Nigeria', 'South Africa', 'Kenya', 'Tanzania') GROUP BY cause;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(100), publication_date DATE);
|
What is the total number of news articles published in the "articles" table by year?
|
SELECT EXTRACT(YEAR FROM publication_date) AS year, COUNT(*) AS num_articles FROM articles GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cyber_strategies (id INT, strategy VARCHAR(255), implementation_date DATE); INSERT INTO cyber_strategies (id, strategy, implementation_date) VALUES (1, 'Next-gen firewalls', '2020-01-01'), (2, 'AI-driven threat hunting', '2021-04-15'), (3, 'Zero Trust framework', '2019-07-22'), (4, 'Encrypted communications', '2020-12-03'), (5, 'Multi-factor authentication', '2021-06-08');
|
Which cybersecurity strategies were implemented in the last 3 years?
|
SELECT strategy, YEAR(implementation_date) as year FROM cyber_strategies WHERE implementation_date >= DATE(NOW()) - INTERVAL 3 YEAR;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE olympics (athlete TEXT, country TEXT, medal TEXT);
|
What is the total number of medals won by athletes from Japan in the Olympics?
|
SELECT SUM(CASE WHEN medal = 'Gold' THEN 1 WHEN medal = 'Silver' THEN 0.5 WHEN medal = 'Bronze' THEN 0.25 ELSE 0 END) as total_medals FROM olympics WHERE country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Region_Sales (region TEXT, revenue FLOAT); INSERT INTO Region_Sales (region, revenue) VALUES ('North', 50000), ('South', 60000);
|
What is the total revenue for each region in the 'Region_Sales' table?
|
SELECT region, SUM(revenue) FROM Region_Sales GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (country TEXT, category TEXT, mass FLOAT); INSERT INTO space_debris (country, category, mass) VALUES ('USA', 'Aluminum', 120.5), ('USA', 'Titanium', 170.1), ('Russia', 'Aluminum', 150.2), ('Russia', 'Titanium', 180.1), ('China', 'Copper', 100.1), ('China', 'Steel', 250.7);
|
What is the average mass of space debris by country?
|
SELECT country, AVG(mass) AS avg_mass FROM space_debris GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (id INT, attorney_firm VARCHAR(255), date DATE, revenue FLOAT); INSERT INTO cases (id, attorney_firm, date, revenue) VALUES (1, 'Smith & Johnson', '2021-01-01', 5000.00), (2, 'Smith & Johnson', '2021-02-01', 7000.00), (3, 'Smith & Johnson', '2021-03-01', 6000.00);
|
What is the total revenue for cases handled by Smith & Johnson in the last quarter?
|
SELECT SUM(revenue) FROM cases WHERE attorney_firm = 'Smith & Johnson' AND date >= DATE_SUB('2021-04-01', INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CulturalCompetency (WorkerID INT, WorkerName VARCHAR(100), State VARCHAR(2), Score INT); INSERT INTO CulturalCompetency (WorkerID, WorkerName, State, Score) VALUES (1, 'Michael Johnson', 'California', 85);
|
What is the total cultural competency score for health workers in California?
|
SELECT SUM(Score) FROM CulturalCompetency WHERE State = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (title VARCHAR(255), publication_date DATE, topic VARCHAR(50), channel VARCHAR(50)); INSERT INTO articles (title, publication_date, topic, channel) VALUES ('Immigration policies in the EU', '2022-01-05', 'immigration', 'Al Jazeera'), ('Immigration trends in the US', '2022-01-10', 'immigration', 'Al Jazeera'), ('Immigration and human rights', '2022-01-15', 'immigration', 'Al Jazeera'), ('Immigration and economy', '2022-01-20', 'immigration', 'Al Jazeera'), ('Immigration and technology', '2022-01-25', 'immigration', 'Al Jazeera');
|
What is the earliest publication date of articles about 'immigration' published by 'Al Jazeera' in 2022?
|
SELECT MIN(publication_date) FROM articles WHERE channel = 'Al Jazeera' AND topic = 'immigration' AND publication_date BETWEEN '2022-01-01' AND '2022-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_ocean (id INT, marine_species_count INT); INSERT INTO arctic_ocean (id, marine_species_count) VALUES (1, 2000);
|
How many marine species are there in the Arctic Ocean?
|
SELECT marine_species_count FROM arctic_ocean WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Genres (GenreID INT, Genre VARCHAR(20)); CREATE TABLE Games (GameID INT, GameName VARCHAR(50), GenreID INT); CREATE TABLE GamePlayer (PlayerID INT, GameID INT); CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10));
|
List the top 5 most popular game genres based on the number of unique players who have played games in each genre, and the average age of these players.
|
SELECT Genres.Genre, COUNT(DISTINCT GamePlayer.PlayerID) AS NumPlayers, AVG(Players.Age) AS AvgAge FROM Genres INNER JOIN Games ON Genres.GenreID = Games.GenreID INNER JOIN GamePlayer ON Games.GameID = GamePlayer.GameID INNER JOIN Players ON GamePlayer.PlayerID = Players.PlayerID GROUP BY Genres.Genre ORDER BY NumPlayers DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE monitoring_stations (id INT, name TEXT, location TEXT); INSERT INTO monitoring_stations (id, name, location) VALUES (1, 'Station A', 'Coast of California'), (2, 'Station B', 'Seattle Coast'), (3, 'Station C', 'Florida Keys'); CREATE TABLE oxygen_readings (id INT, station_id INT, reading DATE, level DECIMAL(5,2)); INSERT INTO oxygen_readings (id, station_id, reading, level) VALUES (1, 1, '2022-06-01', 7.5), (2, 1, '2022-06-15', 7.3), (3, 2, '2022-06-05', 7.8), (4, 2, '2022-06-20', 7.6), (5, 3, '2022-06-02', 8.2), (6, 3, '2022-06-17', 8.0);
|
List the top 2 oxygen monitoring stations with the lowest average dissolved oxygen levels in the last 6 months?
|
SELECT station_id, AVG(level) avg_oxygen FROM oxygen_readings WHERE reading >= DATEADD(month, -6, CURRENT_DATE) GROUP BY station_id ORDER BY avg_oxygen ASC FETCH FIRST 2 ROWS ONLY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_maintenance (equipment_type VARCHAR(50), maintenance_date DATE, maintenance_cost DECIMAL(10,2));
|
Delete records of military equipment maintenance for 'Type E-7' helicopters
|
DELETE FROM equipment_maintenance WHERE equipment_type = 'Type E-7';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemicals (chemical_id INT, chemical_name VARCHAR(50)); CREATE TABLE safety_incidents (incident_id INT, chemical_id INT, incident_date DATE); INSERT INTO chemicals (chemical_id, chemical_name) VALUES (1, 'Chemical A'), (2, 'Chemical B'); INSERT INTO safety_incidents (incident_id, chemical_id, incident_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-01');
|
How many safety incidents were recorded for each chemical in the past 6 months?
|
SELECT chemicals.chemical_name, COUNT(safety_incidents.incident_id) FROM chemicals LEFT JOIN safety_incidents ON chemicals.chemical_id = safety_incidents.chemical_id WHERE safety_incidents.incident_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY chemicals.chemical_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rfsa_missions (id INT, mission_name VARCHAR(255), launch_date DATE, destination VARCHAR(255)); INSERT INTO rfsa_missions (id, mission_name, launch_date, destination) VALUES (1, 'Luna 2', '1959-09-12', 'Moon');
|
How many missions has the Russian Federal Space Agency launched to the Moon?
|
SELECT COUNT(*) FROM rfsa_missions WHERE destination = 'Moon';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(50), incident_date DATE);
|
Determine the number of security incidents caused by insider threats in the past month
|
SELECT COUNT(*) as num_incidents FROM security_incidents WHERE incident_type = 'insider threat' AND incident_date >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy (initiative_id INT, initiative_name TEXT, initiative_description TEXT, country1 TEXT, country2 TEXT, status TEXT); INSERT INTO defense_diplomacy (initiative_id, initiative_name, initiative_description, country1, country2, status) VALUES (1, 'Joint Military Exercise', 'Annual military exercise between the USA and Canada', 'USA', 'Canada', 'In Progress'), (2, 'Defense Technology Exchange', 'Exchange of defense technology between the USA and Canada', 'USA', 'Canada', 'Completed');
|
What is the current status of defense diplomacy initiatives between the USA and Canada?
|
SELECT defense_diplomacy.status FROM defense_diplomacy WHERE defense_diplomacy.country1 = 'USA' AND defense_diplomacy.country2 = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salesperson (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO salesperson (id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE orders (id INT, salesperson_id INT, size INT); INSERT INTO orders (id, salesperson_id, size) VALUES (1, 1, 10), (2, 1, 15), (3, 2, 20), (4, 2, 25);
|
What is the average order size for each salesperson?
|
SELECT salesperson_id, AVG(size) as avg_order_size FROM orders GROUP BY salesperson_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (song_id INT, title TEXT, release_year INT, artist_id INT, popularity INT); CREATE TABLE artists (artist_id INT, name TEXT);
|
What is the average popularity of songs released in the 80s and 90s for each artist?
|
SELECT a.name, AVG(s.popularity) FROM songs s JOIN artists a ON s.artist_id = a.artist_id WHERE s.release_year BETWEEN 1980 AND 1999 GROUP BY a.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approvals (approval_id INT, drug_name TEXT, approval_time INT, region TEXT); INSERT INTO drug_approvals (approval_id, drug_name, approval_time, region) VALUES (1, 'DrugG', 180, 'Asia'), (2, 'DrugH', 210, 'Asia');
|
What is the minimum drug approval time for drugs in Asia?
|
SELECT region, MIN(approval_time) as min_approval_time FROM drug_approvals WHERE region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE categories (id INT, name TEXT); CREATE TABLE orders (id INT, category_id INT, order_date DATE);
|
List the top 3 categories with the highest number of orders in the past month.
|
SELECT c.name, COUNT(*) as num_orders FROM categories c JOIN orders o ON c.id = o.category_id WHERE order_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW() GROUP BY c.name ORDER BY num_orders DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Forests (Fid INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Area FLOAT); CREATE TABLE Carbon (Cid INT PRIMARY KEY, Fid INT, Year INT, Sequestration FLOAT, FOREIGN KEY (Fid) REFERENCES Forests(Fid));
|
What are the names of forests in India and their respective carbon sequestration amounts for each year?
|
SELECT Forests.Name, Carbon.Year, SUM(Carbon.Sequestration) FROM Forests FULL OUTER JOIN Carbon ON Forests.Fid = Carbon.Fid WHERE Forests.Country = 'India' GROUP BY Carbon.Year, Forests.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (rep_id INT, date DATE, sales FLOAT); INSERT INTO sales (rep_id, date, sales) VALUES (1, '2021-01-01', 500), (1, '2021-02-01', 600), (1, '2021-03-01', 700), (1, '2021-04-01', 800), (1, '2021-05-01', 900), (1, '2021-06-01', 1000), (2, '2021-01-01', 400), (2, '2021-02-01', 500), (2, '2021-03-01', 600), (2, '2021-04-01', 700), (2, '2021-05-01', 800), (2, '2021-06-01', 900);
|
What is the average monthly sales amount per sales representative for the first half of the year?
|
SELECT rep_id, AVG(sales) as avg_monthly_sales FROM sales WHERE date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY rep_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_support (customer_id INT, name VARCHAR(50), email VARCHAR(50), used_ai_chatbot BOOLEAN);
|
How many AI-powered chatbot users are there in the customer_support table?
|
SELECT COUNT(*) FROM customer_support WHERE used_ai_chatbot = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT, volunteer_name VARCHAR(50), program_id INT, volunteer_date DATE); CREATE TABLE programs (program_id INT, program_name VARCHAR(50));
|
How many volunteers engaged in programs in Q1 of 2022?
|
SELECT COUNT(DISTINCT volunteer_id) FROM volunteers WHERE QUARTER(volunteer_date) = 1 AND YEAR(volunteer_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tennis_gs (tournament VARCHAR(50), year INT, prize_money INT); INSERT INTO tennis_gs VALUES ('Australian Open', 2021, 62000000), ('French Open', 2021, 44000000), ('Wimbledon', 2021, 41900000), ('US Open', 2021, 57700000);
|
What was the total prize money awarded in the last three Men's Tennis Grand Slams?
|
SELECT SUM(prize_money) FROM tennis_gs WHERE tournament IN ('Australian Open', 'French Open', 'Wimbledon') AND year >= 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT); INSERT INTO products VALUES (1, 'Mascara', 5000), (2, 'Lipstick', 7000), (3, 'Foundation', 6000);
|
What are the total sales of cosmetic products in the database?
|
SELECT SUM(sales) FROM products;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PublicWorksB(id INT, project VARCHAR(30), budget DECIMAL(10,2)); INSERT INTO PublicWorksB(id, project, budget) VALUES (1, 'Highway Construction', 800000.00), (2, 'Airport Expansion', 3000000.00);
|
What is the maximum budget for any public works project?
|
SELECT MAX(budget) FROM PublicWorksB;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offset_programs (project_id INT, state VARCHAR(20), carbon_offsets FLOAT); INSERT INTO carbon_offset_programs (project_id, state, carbon_offsets) VALUES (1, 'Florida', 1200.5), (2, 'California', 1800.75), (3, 'Florida', 2500.33);
|
Find the total carbon offset by project in Florida
|
SELECT project_id, SUM(carbon_offsets) FROM carbon_offset_programs WHERE state = 'Florida' GROUP BY project_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.crime_statistics (id serial PRIMARY KEY, city varchar(255), year int, num_crimes int); INSERT INTO public.crime_statistics (city, year, num_crimes) VALUES ('Houston', 2019, 30000), ('Houston', 2020, 35000);
|
What is the total number of crimes reported in the city of Houston in the year 2019 and 2020?
|
SELECT SUM(num_crimes) FROM public.crime_statistics WHERE city = 'Houston' AND (year = 2019 OR year = 2020);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget (dept VARCHAR(50), program VARCHAR(50), amount INT);
|
Add a new record for 'Assistive Listening Devices' program with a budget of $60,000 in the 'Disability Services' department.
|
INSERT INTO budget (dept, program, amount) VALUES ('Disability Services', 'Assistive Listening Devices', 60000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(255), location VARCHAR(255), language VARCHAR(255), years_experience INT); INSERT INTO community_health_workers (worker_id, name, location, language, years_experience) VALUES (1, 'Ana Flores', 'Los Angeles, CA', 'Spanish', 10), (2, 'Han Kim', 'Seattle, WA', 'Korean', 7), (3, 'Leila Nguyen', 'Houston, TX', 'Vietnamese', 12);
|
What is the distribution of community health workers by their years of experience, partitioned by the languages they speak?
|
SELECT worker_id, language, years_experience, COUNT(*) OVER(PARTITION BY language, years_experience) as count FROM community_health_workers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentMaterials (id INT, garment_id INT, material VARCHAR(20));CREATE TABLE Garments (id INT, name VARCHAR(50)); INSERT INTO GarmentMaterials (id, garment_id, material) VALUES (1, 1001, 'organic_cotton'), (2, 1002, 'recycled_polyester'), (3, 1003, 'organic_cotton'), (4, 1004, 'hemp'), (5, 1005, 'organic_cotton'); INSERT INTO Garments (id, name) VALUES (1001, 'Eco T-Shirt'), (1002, 'Green Sweater'), (1003, 'Circular Hoodie'), (1004, 'Hemp Shirt'), (1005, 'Ethical Jacket');
|
How many garments are made of each material?
|
SELECT material, COUNT(DISTINCT garment_id) as garment_count FROM GarmentMaterials GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (id INT, name TEXT, region TEXT, billing_amount DECIMAL(10, 2)); INSERT INTO clients (id, name, region, billing_amount) VALUES (1, 'David', 'toronto', 500.00), (2, 'Ella', 'toronto', 600.00), (3, 'Fiona', 'toronto', 700.00);
|
What is the total billing amount for clients in the 'toronto' region?
|
SELECT SUM(billing_amount) FROM clients WHERE region = 'toronto';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artisans (ArtisanID INT PRIMARY KEY, Name VARCHAR(100), Specialty VARCHAR(50), Nation VARCHAR(50)); INSERT INTO Artisans (ArtisanID, Name, Specialty, Nation) VALUES (1, 'Fatu Koroma', 'Pottery', 'Sierra Leone'), (2, 'Ali Omar', 'Weaving', 'Somalia');
|
Who are the Indigenous artisans from Africa specializing in pottery?
|
SELECT Name FROM Artisans WHERE Specialty = 'Pottery' AND Nation = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (well_id VARCHAR(2), date DATE, quantity FLOAT); INSERT INTO production (well_id, date, quantity) VALUES ('W1', '2021-01-01', 100.0), ('W1', '2021-01-02', 120.0), ('W2', '2021-01-01', 150.0);
|
Find the total production quantity for well 'W2' in January 2021
|
SELECT SUM(quantity) FROM production WHERE well_id = 'W2' AND date >= '2021-01-01' AND date < '2021-02-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE road_sections (id INT, section_name VARCHAR(50), location VARCHAR(50)); INSERT INTO road_sections (id, section_name, location) VALUES (1, 'Section 1', 'Urban'), (2, 'Section 2', 'Rural'), (3, 'Section 3', 'Urban');
|
How many 'road_sections' are there in 'Rural' locations?
|
SELECT COUNT(*) FROM road_sections WHERE location = 'Rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incident_severity (id INT, incident_count INT, severity VARCHAR(50), incident_date DATE); INSERT INTO incident_severity (id, incident_count, severity, incident_date) VALUES (1, 12, 'Low', '2022-03-01'), (2, 20, 'Medium', '2022-03-02'), (3, 30, 'High', '2022-03-03');
|
Show the number of security incidents for each severity level in the last month.
|
SELECT severity, SUM(incident_count) as total_incidents FROM incident_severity WHERE incident_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY severity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_safety_records (id INT PRIMARY KEY, product_id INT, safety_rating INT, last_inspection_date DATE); INSERT INTO product_safety_records (id, product_id, safety_rating, last_inspection_date) VALUES (1, 1, 5, '2021-06-15'); CREATE TABLE products (id INT PRIMARY KEY, name TEXT, brand TEXT); INSERT INTO products (id, name, brand) VALUES (1, 'Aloe Vera Lotion', 'PureNature');
|
What is the safety rating of the product named "Aloe Vera Lotion" from the brand "PureNature"?
|
SELECT safety_rating FROM product_safety_records WHERE product_id = (SELECT id FROM products WHERE name = 'Aloe Vera Lotion' AND brand = 'PureNature')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE humanitarian_assistance_oceania (country VARCHAR(50), year INT, budget INT); INSERT INTO humanitarian_assistance_oceania (country, year, budget) VALUES ('Australia', 2021, 1200000), ('New Zealand', 2021, 1100000), ('Papua New Guinea', 2021, 900000);
|
What is the total humanitarian assistance budget for Oceania countries in 2021?
|
SELECT SUM(budget) total_budget FROM humanitarian_assistance_oceania WHERE country IN ('Australia', 'New Zealand', 'Papua New Guinea') AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA gov_schema;CREATE TABLE gov_schema.budget_allocation (year INT, service VARCHAR(20), amount INT);INSERT INTO gov_schema.budget_allocation (year, service, amount) VALUES (2020, 'Healthcare', 20000000), (2020, 'Education', 15000000);
|
What is the total budget allocated for healthcare and education services in 2020?
|
SELECT SUM(amount) FROM gov_schema.budget_allocation WHERE year = 2020 AND (service = 'Healthcare' OR service = 'Education');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50)); INSERT INTO customers VALUES (1, 'James Doe'), (2, 'Jane Smith'), (3, 'Alice Johnson'); CREATE TABLE orders (order_id INT, customer_id INT, menu_id INT, order_date DATE, total_cost DECIMAL(5,2)); INSERT INTO orders VALUES (1, 1, 1, '2022-01-01', 25.00), (2, 2, 3, '2022-01-02', 18.50), (3, 3, 2, '2022-01-03', 12.50), (4, 1, 4, '2022-01-04', 32.00); CREATE TABLE menu (menu_id INT, item_name VARCHAR(50), is_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO menu VALUES (1, 'Veggie Burger', true, 8.99), (2, 'Cheeseburger', false, 7.99), (3, 'Tofu Stir Fry', true, 11.99), (4, 'Quinoa Salad', true, 9.01);
|
Who is the customer with the highest spending on vegan dishes?
|
SELECT customers.customer_name, SUM(orders.total_cost) as total_spent FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id INNER JOIN menu ON orders.menu_id = menu.menu_id WHERE menu.is_vegan = true GROUP BY customers.customer_name ORDER BY total_spent DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Military_Equipment_Sales(id INT, sale_date DATE, country VARCHAR(50), equipment_type VARCHAR(50), sale_value FLOAT); INSERT INTO Military_Equipment_Sales(id, sale_date, country, equipment_type, sale_value) VALUES (1, '2020-01-01', 'USA', 'Naval', 70000000);
|
What is the average sale value per equipment type?
|
SELECT equipment_type, AVG(sale_value) FROM Military_Equipment_Sales GROUP BY equipment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bioprocess_engineering(id INT, project VARCHAR(50), country VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO bioprocess_engineering VALUES (1, 'ProjectA', 'USA', 3000000.00), (2, 'ProjectB', 'Canada', 5000000.00), (3, 'ProjectC', 'Mexico', 4000000.00);
|
What is the maximum budget for a bioprocess engineering project in each country?
|
SELECT country, MAX(budget) FROM bioprocess_engineering GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE well_prod (well_name VARCHAR(50), location VARCHAR(50), rate FLOAT); INSERT INTO well_prod (well_name, location, rate) VALUES ('Well A', 'Marcellus Shale', 1200), ('Well B', 'Marcellus Shale', 1800);
|
What is the minimum production rate for wells in the Marcellus Shale?
|
SELECT MIN(rate) FROM well_prod WHERE location = 'Marcellus Shale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, avg_depth REAL); INSERT INTO marine_protected_areas (name, location, avg_depth) VALUES ('Galapagos Islands Marine Reserve', 'Ecuador', '2500'), ('Great Barrier Reef Marine Park', 'Australia', '180');
|
Calculate the average depth of all marine protected areas.
|
SELECT AVG(avg_depth) FROM marine_protected_areas;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE access_tech (name TEXT, budget INTEGER, launch_year INTEGER, accessible TEXT); INSERT INTO access_tech (name, budget, launch_year, accessible) VALUES ('AccTech1', 500000, 2022, 'yes'), ('AccTech2', 600000, 2022, 'yes'), ('AccTech3', 400000, 2021, 'no');
|
What is the average budget for accessible technology projects launched in 2022?
|
SELECT AVG(budget) FROM access_tech WHERE launch_year = 2022 AND accessible = 'yes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_efficiency_asia (id INT, country VARCHAR(255), efficiency FLOAT); INSERT INTO energy_efficiency_asia (id, country, efficiency) VALUES (1, 'Japan', 0.35), (2, 'China', 0.32), (3, 'South Korea', 0.31), (4, 'India', 0.29);
|
What is the energy efficiency of the top 3 countries in Asia?
|
SELECT country, efficiency FROM energy_efficiency_asia ORDER BY efficiency DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE billing (attorney_id INT, client_id INT, hours_billed INT, billing_rate DECIMAL(5,2));
|
Show total hours billed and total billing amount for each attorney in 'billing' table
|
SELECT attorney_id, SUM(hours_billed), SUM(hours_billed * billing_rate) FROM billing GROUP BY attorney_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), start_date DATE); INSERT INTO attorneys (attorney_id, name, start_date) VALUES (1, 'John Doe', '2020-01-01'); INSERT INTO attorneys (attorney_id, name, start_date) VALUES (2, 'Jane Smith', '2019-06-15'); CREATE TABLE cases (case_id INT, attorney_id INT, open_date DATE); INSERT INTO cases (case_id, attorney_id, open_date) VALUES (1, 1, '2020-01-01'); INSERT INTO cases (case_id, attorney_id, open_date) VALUES (2, 2, '2020-02-15'); INSERT INTO cases (case_id, attorney_id, open_date) VALUES (3, 1, '2019-12-31');
|
How many cases were opened by each attorney in 2020?
|
SELECT attorney_id, COUNT(case_id) as cases_opened FROM cases WHERE YEAR(open_date) = 2020 GROUP BY attorney_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO farmers (id, name, age, location) VALUES (1, 'John Doe', 45, 'Ruralville'); INSERT INTO farmers (id, name, age, location) VALUES (2, 'Jane Smith', 50, 'Farmtown');
|
What is the average age of farmers in the 'farmers' table?
|
SELECT AVG(age) FROM farmers;
|
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.