instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the maximum altitude reached by a human in space? | CREATE TABLE human_spaceflight (name TEXT,max_altitude_km INTEGER); INSERT INTO human_spaceflight (name,max_altitude_km) VALUES ('Gagarin',327),('Nechaev',330),('Shepard',187),('Glenn',282); | SELECT MAX(max_altitude_km) FROM human_spaceflight; |
How many unique clients does each attorney have? | CREATE TABLE clients (client_id INT,client_name VARCHAR(50)); CREATE TABLE cases (case_id INT,client_id INT,attorney_id INT); | SELECT attorney_id, COUNT(DISTINCT clients.client_id) AS unique_clients FROM cases INNER JOIN clients ON cases.client_id = clients.client_id GROUP BY attorney_id; |
List the names of all cities in the state of New York that have a population greater than 1 million people? | CREATE TABLE cities (id INT,name TEXT,state TEXT,population INT); INSERT INTO cities (id,name,state,population) VALUES (1,'New York City','New York',8500000),(2,'Buffalo','New York',258000),(3,'Rochester','New York',211000); | SELECT name FROM cities WHERE state = 'New York' AND population > 1000000; |
What is the average depth of all marine protected areas in the Pacific and Atlantic regions? | CREATE TABLE marine_protected_areas (name VARCHAR(255),location VARCHAR(255),depth FLOAT); INSERT INTO marine_protected_areas (name,location,depth) VALUES ('MPA 1','Pacific',120.5); INSERT INTO marine_protected_areas (name,location,depth) VALUES ('MPA 2','Atlantic',200.3); | SELECT AVG(depth) FROM marine_protected_areas WHERE location IN ('Pacific', 'Atlantic'); |
What is the highest rated eco-friendly hotel in Tokyo? | CREATE TABLE eco_hotels (hotel_id INT,hotel_name VARCHAR(100),city VARCHAR(100),rating FLOAT); INSERT INTO eco_hotels (hotel_id,hotel_name,city,rating) VALUES (1,'Eco Hotel Tokyo','Tokyo',4.7); INSERT INTO eco_hotels (hotel_id,hotel_name,city,rating) VALUES (2,'Green Hotel Tokyo','Tokyo',4.6); | SELECT hotel_name, MAX(rating) FROM eco_hotels WHERE city = 'Tokyo'; |
List all autonomous vehicle testing data for San Francisco | CREATE TABLE autonomous_testing (id INT PRIMARY KEY,location VARCHAR(100),company VARCHAR(100),date DATE,miles_driven INT); | SELECT * FROM autonomous_testing WHERE location = 'San Francisco'; |
Insert new mobile subscribers who have joined in the last month. | CREATE TABLE new_mobile_subscribers (subscriber_id INT,name VARCHAR(50),registration_date DATE); INSERT INTO new_mobile_subscribers (subscriber_id,name,registration_date) VALUES (3,'Alice Davis','2022-01-10'); INSERT INTO new_mobile_subscribers (subscriber_id,name,registration_date) VALUES (4,'Bob Johnson','2022-01-25'); | INSERT INTO mobile_subscribers (subscriber_id, name, billing_updated_date) SELECT subscriber_id, name, registration_date FROM new_mobile_subscribers WHERE registration_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
What is the maximum account balance for customers in each region? | CREATE TABLE customer_data_2 (customer_id INT,account_balance DECIMAL(10,2),region VARCHAR(20)); INSERT INTO customer_data_2 (customer_id,account_balance,region) VALUES (1,5000,'Latin America'),(2,7000,'North America'),(3,6000,'Latin America'),(4,8000,'Europe'),(5,9000,'Asia'); CREATE VIEW customer_data_view AS SELECT region,MAX(account_balance) as max_balance FROM customer_data_2 GROUP BY region; | SELECT region, max_balance FROM customer_data_view; |
What is the total playtime for each game in the 'gaming_hours' schema? | CREATE TABLE gaming_hours (game_id INT,total_playtime FLOAT); INSERT INTO gaming_hours VALUES (1,5000.5),(2,3500.2),(3,4200.8); | SELECT gh.game_id, gh.total_playtime, g.game_name FROM gaming_hours gh JOIN game g ON gh.game_id = g.game_id; |
Identify the top 3 games with the longest average playtime for players from Asia. | CREATE TABLE GamePlay (PlayerID INT,GameName VARCHAR(255),Playtime INT); INSERT INTO GamePlay (PlayerID,GameName,Playtime) VALUES (1,'Cosmic Racers',120); INSERT INTO GamePlay (PlayerID,GameName,Playtime) VALUES (2,'Cosmic Racers',180); CREATE TABLE Continents (ContinentID INT,Continent VARCHAR(255)); INSERT INTO Continents (ContinentID,Continent) VALUES (1,'Asia'); INSERT INTO Players (PlayerID,ContinentID) VALUES (1,1); INSERT INTO Players (PlayerID,ContinentID) VALUES (2,1); | SELECT GameName, AVG(Playtime) as AvgPlaytime, RANK() OVER (ORDER BY AVG(Playtime) DESC) as Rank FROM GamePlay JOIN Players ON GamePlay.PlayerID = Players.PlayerID JOIN Continents ON Players.ContinentID = Continents.ContinentID WHERE Continents.Continent = 'Asia' GROUP BY GameName HAVING COUNT(DISTINCT Players.PlayerID) > 1 ORDER BY AvgPlaytime DESC; |
How many renewable energy projects are in Texas? | CREATE TABLE renewable_energy_projects (project_id INT,state VARCHAR(20)); INSERT INTO renewable_energy_projects (project_id,state) VALUES (1,'Texas'),(2,'California'),(3,'Florida'); | SELECT COUNT(*) FROM renewable_energy_projects WHERE state = 'Texas'; |
What is the total amount donated by individual donors based in Canada in the year 2021? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,Country TEXT,DonationAmount DECIMAL); INSERT INTO Donors (DonorID,DonorName,Country,DonationAmount) VALUES (1,'John Doe','Canada',100.00),(2,'Jane Smith','USA',200.00); | SELECT SUM(DonationAmount) FROM Donors WHERE Country = 'Canada' AND YEAR(DonationDate) = 2021; |
What is the minimum number of technology for social good projects completed by organizations in Oceania? | CREATE TABLE Social_Good_Projects_Count (Org_Name VARCHAR(50),Projects INT); | SELECT MIN(Projects) FROM Social_Good_Projects_Count WHERE Org_Name IN (SELECT Org_Name FROM Social_Good_Projects_Count WHERE Country IN ('Australia', 'New Zealand') GROUP BY Org_Name HAVING COUNT(*) >= 2); |
Insert new records into the 'satellite_deployment' table for the 'Juno' satellite, launched in 2011, and the 'Perseverance' rover, landed on Mars in 2021 | CREATE TABLE satellite_deployment (id INT PRIMARY KEY,name VARCHAR(50),launch_year INT,location VARCHAR(50)); | INSERT INTO satellite_deployment (id, name, launch_year, location) VALUES (1, 'Juno', 2011, 'Space'), (2, 'Perseverance', 2021, 'Mars'); |
Show the number of safety tests passed by vehicles grouped by make and model in the 'safety_testing' table | CREATE TABLE safety_testing (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),tests_passed INT); | SELECT make, model, SUM(tests_passed) FROM safety_testing GROUP BY make, model; |
What is the average well depth for wells in the Haynesville Shale? | CREATE TABLE Haynesville_Shale (well_id INT,well_depth FLOAT); INSERT INTO Haynesville_Shale (well_id,well_depth) VALUES (1,12000),(2,13000),(3,11000),(4,14000); | SELECT AVG(well_depth) FROM Haynesville_Shale WHERE well_id IS NOT NULL; |
How many cruelty-free certified products are there? | CREATE TABLE certifications (id INT,product_id INT,is_cruelty_free BOOLEAN); INSERT INTO certifications (id,product_id,is_cruelty_free) VALUES (1,1,true),(2,2,false),(3,3,true); | SELECT COUNT(*) FROM certifications WHERE is_cruelty_free = true; |
What is the average length of ocean currents in the Pacific Ocean? | CREATE TABLE ocean_currents (current_name TEXT,length REAL,ocean TEXT); INSERT INTO ocean_currents (current_name,length,ocean) VALUES ('Current_A',1000.0,'Pacific'),('Current_B',1200.0,'Pacific'),('Current_C',1500.0,'Atlantic'); | SELECT AVG(length) FROM ocean_currents WHERE ocean = 'Pacific'; |
What is the total donation amount for each program and the number of volunteers who participated in each program? | CREATE TABLE donations (id INT,program VARCHAR(255),amount DECIMAL(10,2)); INSERT INTO donations (id,program,amount) VALUES (1,'Animal Welfare',500.00),(2,'Education',1000.00); CREATE TABLE volunteers (id INT,program VARCHAR(255),hours INT); INSERT INTO volunteers (id,program,hours) VALUES (1,'Animal Welfare',20),(2,'Education',30); | SELECT d.program, SUM(d.amount), COUNT(v.id) FROM donations d JOIN volunteers v ON d.program = v.program GROUP BY d.program; |
What is the total revenue per sustainable tour package for vendors with 'Green' in their name? | CREATE TABLE Vendors (VendorID INT,VendorName VARCHAR(50)); INSERT INTO Vendors (VendorID,VendorName) VALUES (1,'GreenVacations'),(2,'EcoTours'),(3,'SustainableJourneys'),(4,'BluePlanetTours'); CREATE TABLE Packages (PackageID INT,VendorID INT,PackageType VARCHAR(20),Revenue DECIMAL(10,2)); INSERT INTO Packages (PackageID,VendorID,PackageType,Revenue) VALUES (1,1,'Sustainable',800),(2,1,'Virtual',600),(3,2,'Sustainable',1000),(4,2,'Virtual',900),(5,3,'Sustainable',1200),(6,3,'Virtual',700),(7,4,'Sustainable',500),(8,4,'Virtual',800); | SELECT V.VendorName, SUM(P.Revenue) as TotalRevenue FROM Vendors V INNER JOIN Packages P ON V.VendorID = P.VendorID WHERE V.VendorName LIKE '%Green%' AND P.PackageType = 'Sustainable' GROUP BY V.VendorName; |
Find the indigenous languages in the South American culture domain with more than 1,000,000 speakers. | CREATE TABLE SouthAmericanLanguages (LanguageID int,LanguageName varchar(255),SpeakersCount int,CultureDomain varchar(255)); INSERT INTO SouthAmericanLanguages (LanguageID,LanguageName,SpeakersCount,CultureDomain) VALUES (1,'Quechua',12000000,'South American'); | SELECT LanguageName, SpeakersCount FROM SouthAmericanLanguages WHERE SpeakersCount > 1000000; |
Which satellites were deployed before their manufacturers' first satellite delivery? | CREATE TABLE SatelliteManufacturing (id INT,manufacturer VARCHAR(255),delivery_time DATE); INSERT INTO SatelliteManufacturing (id,manufacturer,delivery_time) VALUES (1,'SpaceTech Inc.','2020-01-15'),(2,'Galactic Systems','2019-06-28'),(3,'SpaceTech Inc.','2021-03-02'); CREATE TABLE SatelliteDeployment (id INT,satellite_name VARCHAR(255),deployment_date DATE); INSERT INTO SatelliteDeployment (id,satellite_name,deployment_date) VALUES (1,'Sat1','2018-12-12'),(2,'Sat2','2020-04-05'),(3,'Sat3','2021-02-20'); | SELECT sd.satellite_name FROM SatelliteDeployment sd JOIN (SELECT manufacturer, MIN(delivery_time) AS first_delivery FROM SatelliteManufacturing GROUP BY manufacturer) sm ON sm.min_delivery > sd.deployment_date; |
Update the hospital bed count for Hospital A to 500 in the hospitals table. | CREATE TABLE hospitals (hospital_id INT,hospital_name VARCHAR(255),num_beds INT); INSERT INTO hospitals (hospital_id,hospital_name,num_beds) VALUES (1,'Hospital A',400),(2,'Hospital B',600),(3,'Hospital C',700); | UPDATE hospitals SET num_beds = 500 WHERE hospital_name = 'Hospital A'; |
What is the total number of cultural competency trainings conducted in the cultural_competency schema? | CREATE TABLE cultural_competency_trainings (training_id INT,year INT,location VARCHAR(50)); INSERT INTO cultural_competency_trainings (training_id,year,location) VALUES (1,2022,'NYC'); INSERT INTO cultural_competency_trainings (training_id,year,location) VALUES (2,2021,'LA'); | SELECT COUNT(*) FROM cultural_competency.cultural_competency_trainings; |
Create a table to store training program data | CREATE TABLE training_programs (id INT PRIMARY KEY,program_name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE,capacity INT); | CREATE TABLE training_programs (id INT PRIMARY KEY, program_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, capacity INT); |
What is the average yield of corn grown by farmers in Brazil? | CREATE TABLE Farmers (id INT PRIMARY KEY,name VARCHAR(50),age INT,location VARCHAR(50)); INSERT INTO Farmers (id,name,age,location) VALUES (1,'Joao Silva',35,'Brazil'); INSERT INTO Farmers (id,name,age,location) VALUES (2,'Maria Soares',40,'Brazil'); CREATE TABLE Crops (id INT PRIMARY KEY,farmer_id INT,crop_name VARCHAR(50),yield INT,year INT); INSERT INTO Crops (id,farmer_id,crop_name,yield,year) VALUES (1,1,'Corn',1200,2021); INSERT INTO Crops (id,farmer_id,crop_name,yield,year) VALUES (2,1,'Soybeans',800,2021); INSERT INTO Crops (id,farmer_id,crop_name,yield,year) VALUES (3,2,'Corn',1000,2021); | SELECT AVG(yield) FROM Crops JOIN Farmers ON Crops.farmer_id = Farmers.id WHERE Farmers.location = 'Brazil' AND crop_name = 'Corn'; |
Which salesperson has sold the most garments in the last 30 days, ordered by the number of garments sold? | CREATE TABLE salesperson (salesperson_id INT,name VARCHAR(50)); CREATE TABLE sales (sales_id INT,salesperson_id INT,sale_date DATE); | SELECT salesperson.name, COUNT(sales.sales_id) AS quantity_sold FROM salesperson INNER JOIN sales ON salesperson.salesperson_id = sales.salesperson_id WHERE sale_date >= CURRENT_DATE - INTERVAL '30 days' GROUP BY salesperson.name ORDER BY quantity_sold DESC; |
What is the total quantity of organic cotton used in production? | CREATE TABLE OrganicCotton (id INT,quantity INT); INSERT INTO OrganicCotton (id,quantity) VALUES (1,1200),(2,1800),(3,2000); | SELECT SUM(quantity) FROM OrganicCotton; |
What is the minimum number of soldiers in the 'army_table' for 'germany'? | CREATE TABLE army_table (id INT,name VARCHAR(100),country VARCHAR(50),num_soldiers INT); INSERT INTO army_table (id,name,country,num_soldiers) VALUES (1,'Bundeswehr','Germany',60000); | SELECT MIN(num_soldiers) FROM army_table WHERE country = 'Germany'; |
What is the average depth of all marine species habitats? | CREATE TABLE marine_species (id INT,name VARCHAR(255),habitat_type VARCHAR(255),average_depth FLOAT); INSERT INTO marine_species (id,name,habitat_type,average_depth) VALUES (1,'Clownfish','Coral Reef',20.0); INSERT INTO marine_species (id,name,habitat_type,average_depth) VALUES (2,'Blue Whale','Open Ocean',200.0); CREATE TABLE ocean_depths (location VARCHAR(255),depth FLOAT); INSERT INTO ocean_depths (location,depth) VALUES ('Mariana Trench',10994.0); INSERT INTO ocean_depths (location,depth) VALUES ('Sierra Leone Rise',5791.0); | SELECT AVG(ms.average_depth) as avg_depth FROM marine_species ms; |
What is the total waste generated by all departments in the last month? | CREATE TABLE Waste (waste_id INT,department VARCHAR(20),waste_amount DECIMAL(5,2),waste_date DATE); | SELECT SUM(waste_amount) FROM Waste WHERE waste_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
Display the names and yield per acre for the top 3 crops with the highest yield per acre, across all farms and regions. | CREATE TABLE Farm (id INT,name TEXT,crop TEXT,yield_per_acre FLOAT,region TEXT); INSERT INTO Farm (id,name,crop,yield_per_acre,region) VALUES (1,'Smith Farm','Corn',150,'Northern'),(2,'Jones Farm','Soybeans',180,'Northern'),(3,'Brown Farm','Cotton',200,'Southern'); | SELECT crop, yield_per_acre, RANK() OVER (ORDER BY yield_per_acre DESC) as rn FROM Farm WHERE rn <= 3; |
What is the percentage of repeat attendees at Latin music events in Los Angeles? | CREATE TABLE Visitors (visitor_id INT,event_name TEXT,city TEXT); INSERT INTO Visitors (visitor_id,event_name,city) VALUES (1,'Latin Music Festival','Los Angeles'),(2,'Latin Music Festival','Los Angeles'),(3,'Salsa Night','Los Angeles'); | SELECT COUNT(DISTINCT visitor_id) * 100.0 / (SELECT COUNT(DISTINCT visitor_id) FROM Visitors WHERE city = 'Los Angeles' AND event_name LIKE '%Latin%') FROM Visitors WHERE city = 'Los Angeles' AND event_name LIKE '%Latin%'; |
Update the genre of an artist named 'Dua Lipa' to 'Electronic'. | CREATE TABLE artists (id INT,name VARCHAR(255),genre VARCHAR(255)); | WITH updated_genre AS (UPDATE artists SET genre = 'Electronic' WHERE name = 'Dua Lipa' RETURNING *) SELECT * FROM updated_genre; |
What is the average number of professional development programs completed by teachers in 'SchoolB'? | CREATE TABLE teacher_development (teacher_id INT,school VARCHAR(50),program_completed INT); INSERT INTO teacher_development (teacher_id,school,program_completed) VALUES (101,'SchoolA',3),(102,'SchoolA',1),(103,'SchoolB',2),(104,'SchoolB',0); | SELECT AVG(program_completed) FROM teacher_development WHERE school = 'SchoolB'; |
What is the number of streams for the top 10 most streamed artists in Brazil in 2021? | CREATE TABLE music_streaming (id INT,user_id INT,artist VARCHAR(50),song VARCHAR(50),genre VARCHAR(20),streamed_on DATE,streams INT); CREATE VIEW artist_streams AS SELECT artist,SUM(streams) AS total_streams FROM music_streaming GROUP BY artist; | SELECT artist, total_streams FROM artist_streams WHERE user_id IN (SELECT id FROM users WHERE country = 'Brazil') ORDER BY total_streams DESC LIMIT 10; |
Show the distribution of defense contracts by contract value range | CREATE TABLE defense_contracts (contract_id INT,value FLOAT); INSERT INTO defense_contracts (contract_id,value) VALUES (1,100000),(2,200000),(3,500000),(4,800000),(5,1000000),(6,2000000); | SELECT CASE WHEN value <= 100000 THEN '0-100000' WHEN value <= 500000 THEN '100001-500000' WHEN value <= 1000000 THEN '500001-1000000' ELSE '1000001+' END as value_range, COUNT(*) as contract_count FROM defense_contracts GROUP BY value_range; |
How many customers prefer gluten-free options in the San Francisco region? | CREATE TABLE Customer_Preferences (customer_id INT,is_gluten_free BOOLEAN,region VARCHAR(50)); INSERT INTO Customer_Preferences (customer_id,is_gluten_free,region) VALUES (1,true,'San Francisco'),(2,false,'NY'),(3,false,'LA'),(4,true,'San Francisco'),(5,false,'Chicago'); | SELECT COUNT(*) FROM Customer_Preferences WHERE is_gluten_free = true AND region = 'San Francisco'; |
Delete obsolete records from the equipment_maintenance table that are more than 15 years old | CREATE TABLE equipment_maintenance (equipment_id INT,last_maintenance_date DATE); INSERT INTO equipment_maintenance (equipment_id,last_maintenance_date) VALUES (1,'2006-01-01'),(2,'2010-05-01'),(3,'2002-08-15'); | DELETE FROM equipment_maintenance WHERE last_maintenance_date < DATE_SUB(CURDATE(), INTERVAL 15 YEAR); |
What is the total revenue generated from ticket sales for each team in 2022? | CREATE TABLE teams (id INT,name VARCHAR(255)); INSERT INTO teams (id,name) VALUES (1,'Team A'),(2,'Team B'),(3,'Team C'),(4,'Team D'); CREATE TABLE tickets (id INT,team_id INT,sale_date DATE,revenue INT); INSERT INTO tickets (id,team_id,sale_date,revenue) VALUES (1,1,'2022-01-01',5000),(2,2,'2022-02-01',7000),(3,3,'2022-03-01',8000); | SELECT t.name, SUM(ti.revenue) as total_revenue FROM teams t JOIN tickets ti ON t.id = ti.team_id WHERE ti.sale_date >= '2022-01-01' AND ti.sale_date < '2023-01-01' GROUP BY t.name; |
Insert new records for 2 AVs sold in 2022 into the 'vehicle_sales' table | CREATE TABLE vehicle_sales (id INT,vehicle_type VARCHAR(255),sale_year INT,price FLOAT); | INSERT INTO vehicle_sales (id, vehicle_type, sale_year, price) VALUES (3, 'AV', 2022, 55000), (4, 'AV', 2022, 58000); |
How many satellites were launched by China in 2020? | CREATE TABLE satellites (id INT,name VARCHAR(255),country VARCHAR(255),launch_date DATE); CREATE VIEW launched_satellites AS SELECT * FROM satellites WHERE launch_date >= '2020-01-01' AND launch_date < '2021-01-01'; | SELECT COUNT(*) FROM launched_satellites WHERE country = 'China'; |
What is the average income of residents in the "East" district? | CREATE TABLE district (name VARCHAR(20),income FLOAT); INSERT INTO district (name,income) VALUES ('North',45000.0),('East',50000.0),('West',40000.0),('South',55000.0); | SELECT AVG(income) FROM district WHERE name = 'East'; |
Find the total billing amount for each attorney, partitioned by attorney's last name and ordered by the total billing amount in descending order. | CREATE TABLE Attorneys (AttorneyID INT,FirstName VARCHAR(50),LastName VARCHAR(50),TotalBilling FLOAT); INSERT INTO Attorneys (AttorneyID,FirstName,LastName,TotalBilling) VALUES (1,'John','Doe',5000.00),(2,'Jane','Smith',7000.00),(3,'Mike','Doe',6000.00); | SELECT LastName, SUM(TotalBilling) OVER (PARTITION BY LastName) AS TotalBilling FROM Attorneys ORDER BY TotalBilling DESC; |
Update the lifelong learning score for student with ID 910 in subject 'Mathematics' to 95. | CREATE TABLE student_lifelong_learning (student_id INT,subject VARCHAR(255),lifelong_learning_score INT); | UPDATE student_lifelong_learning SET lifelong_learning_score = 95 WHERE student_id = 910 AND subject = 'Mathematics'; |
What is the average word count of articles about 'climate change' that were published in the last month? | CREATE TABLE articles (id INT,title TEXT,category TEXT,word_count INT,published_at DATETIME); | SELECT AVG(word_count) FROM articles WHERE articles.category = 'climate change' AND articles.published_at > DATE_SUB(NOW(), INTERVAL 1 MONTH); |
Delete the 'Marketing' department's training program that starts on '2023-04-01' | CREATE TABLE trainings (id SERIAL PRIMARY KEY,department VARCHAR(50),title VARCHAR(100),description TEXT,start_date DATE,end_date DATE); INSERT INTO trainings (department,title,description,start_date,end_date) VALUES ('Marketing','Social Media Mastery','Maximizing social media presence','2023-04-01','2023-04-07'); | DELETE FROM trainings WHERE department = 'Marketing' AND start_date = '2023-04-01'; |
What is the minimum age of offenders who have been released from prison? | CREATE TABLE prison_releases (offender_id INT,age INT); | SELECT MIN(age) FROM prison_releases; |
Find the number of unique countries represented in the 'Visitor Interactions' table. | CREATE TABLE Visitor_Interactions (ID INT,Visitor_ID INT,Country VARCHAR(255)); INSERT INTO Visitor_Interactions (ID,Visitor_ID,Country) VALUES (1,1001,'USA'),(2,1002,'Canada'),(3,1003,'Mexico'),(4,1004,'USA'); | SELECT COUNT(DISTINCT Country) FROM Visitor_Interactions; |
How many explainable AI models have been developed in Canada? | CREATE TABLE ai_models (model_id INT,name TEXT,country TEXT,model_type TEXT); INSERT INTO ai_models (model_id,name,country,model_type) VALUES (1,'ModelA','Canada','Explainable'),(2,'ModelB','US','Black Box'),(3,'ModelC','Canada','Black Box'),(4,'ModelD','Germany','Explainable'),(5,'ModelE','France','Explainable'),(6,'ModelF','UK','Black Box'); | SELECT COUNT(*) FROM ai_models WHERE country = 'Canada' AND model_type = 'Explainable'; |
What is the total number of art pieces in 'New York' and 'Los Angeles'? | CREATE TABLE museums (id INT,city VARCHAR(20),art_pieces INT); INSERT INTO museums (id,city,art_pieces) VALUES (1,'New York',5000),(2,'Los Angeles',7000),(3,'Paris',8000),(4,'New York',6000),(5,'Los Angeles',8000); | SELECT city, SUM(art_pieces) FROM museums GROUP BY city HAVING city IN ('New York', 'Los Angeles'); |
What is the maximum length of a road in each city? | CREATE TABLE city_roads_2 (id INT,name VARCHAR(50),city VARCHAR(50),length FLOAT); INSERT INTO city_roads_2 VALUES (1,'Highway 401','Toronto',828),(2,'Highway 405','Los Angeles',35),(3,'Autobahn A3','Berlin',165); | SELECT city, MAX(length) FROM city_roads_2 GROUP BY city; |
How many community development projects were completed in South America between 2018 and 2020? | CREATE TABLE projects (project_id INT,project_name TEXT,project_type TEXT,start_date DATE,end_date DATE,region TEXT); INSERT INTO projects (project_id,project_name,project_type,start_date,end_date,region) VALUES (1,'Building Schools','community development','2018-01-01','2018-12-31','South America'); | SELECT COUNT(*) as total_projects FROM projects WHERE project_type = 'community development' AND region = 'South America' AND start_date <= '2020-12-31' AND end_date >= '2018-01-01'; |
Exhibit the minimum and maximum temperature in the Atlantic ocean during 2022 | CREATE TABLE ocean_temperature (ocean_name TEXT,temperature REAL,measurement_date DATE); | SELECT MIN(temperature), MAX(temperature) FROM ocean_temperature WHERE ocean_name = 'Atlantic' AND measurement_date BETWEEN '2022-01-01' AND '2022-12-31'; |
Find the difference in transaction amounts between the maximum and minimum transactions for each customer in the past year? | CREATE TABLE transactions (transaction_date DATE,customer_id INT,amount DECIMAL(10,2)); INSERT INTO transactions (transaction_date,customer_id,amount) VALUES ('2022-01-01',1,100),('2022-01-05',1,200),('2022-01-02',2,150),('2022-01-03',2,50),('2022-01-04',3,300),('2022-01-05',3,250),('2021-01-01',1,50),('2021-01-05',1,250),('2021-01-02',2,350),('2021-01-03',2,100),('2021-01-04',3,400),('2021-01-05',3,500); | SELECT customer_id, MAX(amount) - MIN(amount) AS amount_difference FROM transactions WHERE transaction_date >= CURRENT_DATE - INTERVAL '1 year' GROUP BY customer_id; |
What is the average weight of all shipments to Mexico? | CREATE TABLE Shipment (id INT,weight INT,destination_country VARCHAR(50)); INSERT INTO Shipment (id,weight,destination_country) VALUES (1,100,'Mexico'),(2,200,'Mexico'),(3,150,'Mexico'); | SELECT AVG(weight) FROM Shipment WHERE destination_country = 'Mexico'; |
Show the total monthly sales for sustainable seafood | CREATE TABLE orders(order_id INT,order_date DATE,menu_item_id INT,quantity INT); CREATE TABLE menu_items(menu_item_id INT,name TEXT,type TEXT,is_sustainable BOOLEAN,price DECIMAL); | SELECT SUM(menu_items.price * orders.quantity) FROM menu_items JOIN orders ON menu_items.menu_item_id = orders.menu_item_id JOIN (SELECT EXTRACT(MONTH FROM order_date) as month, EXTRACT(YEAR FROM order_date) as year, menu_item_id FROM orders WHERE is_sustainable = TRUE GROUP BY month, year, menu_item_id) as sustainable_orders ON orders.menu_item_id = sustainable_orders.menu_item_id AND EXTRACT(MONTH FROM orders.order_date) = sustainable_orders.month AND EXTRACT(YEAR FROM orders.order_date) = sustainable_orders.year WHERE menu_items.is_sustainable = TRUE; |
What is the average price of Europium and Gadolinium for the years 2017-2020? | CREATE TABLE prices (id INT PRIMARY KEY,element VARCHAR(10),price DECIMAL(5,2),year INT); INSERT INTO prices (id,element,price,year) VALUES (1,'Europium',70.00,2017); INSERT INTO prices (id,element,price,year) VALUES (2,'Gadolinium',60.00,2018); INSERT INTO prices (id,element,price,year) VALUES (3,'Europium',75.00,2019); INSERT INTO prices (id,element,price,year) VALUES (4,'Gadolinium',65.00,2020); | SELECT p.element, AVG(p.price) AS average_price FROM prices p WHERE p.year BETWEEN 2017 AND 2020 AND (p.element = 'Europium' OR p.element = 'Gadolinium') GROUP BY p.element; |
What is the minimum temperature in 'Field G' for the month of March 2022? | CREATE TABLE sensors (sensor_id INT,location VARCHAR(50)); INSERT INTO sensors (sensor_id,location) VALUES (007,'Field G'); CREATE TABLE temps (sensor_id INT,temp FLOAT,timestamp TIMESTAMP); INSERT INTO temps (sensor_id,temp,timestamp) VALUES (007,28.2,'2022-03-01 10:00:00'); INSERT INTO temps (sensor_id,temp,timestamp) VALUES (007,25.1,'2022-03-02 11:00:00'); | SELECT MIN(temp) FROM temps WHERE sensor_id = 007 AND timestamp BETWEEN '2022-03-01 00:00:00' AND '2022-03-31 23:59:59'; |
Delete the artworks of an artist. | CREATE TABLE artists (id INT,name VARCHAR(50));CREATE TABLE artworks (id INT,title VARCHAR(50),artist_id INT); INSERT INTO artists (id,name) VALUES (1,'Francisco Goya'); INSERT INTO artworks (id,title,artist_id) VALUES (1,'The Third of May 1808',1); | DELETE FROM artworks WHERE artist_id = 1; |
Delete all warehouse management records for Aisle 8 | CREATE TABLE warehouse_management (id INT,aisle VARCHAR(255),item_name VARCHAR(255)); INSERT INTO warehouse_management (id,aisle,item_name) VALUES (1,'Aisle 3','Widget'),(2,'Aisle 8','Thingamajig'),(3,'Aisle 8','Gizmo'); | DELETE FROM warehouse_management WHERE aisle = 'Aisle 8'; |
What is the average donation amount by country? | CREATE TABLE Donors (donor_id INT,donation_amount INT,country VARCHAR(50)); INSERT INTO Donors (donor_id,donation_amount,country) VALUES (7,25,'Canada'),(8,75,'Mexico'),(9,60,'Brazil'); | SELECT country, AVG(donation_amount) FROM Donors GROUP BY country; |
What are the top 5 most vulnerable systems in the last month, based on CVE scores, for the finance department? | CREATE TABLE systems (system_id INT,system_name VARCHAR(255),department VARCHAR(255));CREATE TABLE cve_scores (system_id INT,score INT,scan_date DATE); | SELECT s.system_name, AVG(c.score) as avg_score FROM systems s INNER JOIN cve_scores c ON s.system_id = c.system_id WHERE s.department = 'finance' AND c.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY s.system_name ORDER BY avg_score DESC LIMIT 5; |
Show the total budget for defense contracts in Q3 2022 | CREATE TABLE defense_contracts (contract_id int,contract_date date,contract_budget int); | SELECT SUM(contract_budget) FROM defense_contracts WHERE QUARTER(contract_date) = 3 AND YEAR(contract_date) = 2022; |
How many employees of each gender and ethnicity work in the mining industry in California? | CREATE TABLE employees (employee_id INT,first_name TEXT,last_name TEXT,gender TEXT,ethnicity TEXT,department TEXT); INSERT INTO employees (employee_id,first_name,last_name,gender,ethnicity,department) VALUES (1,'John','Doe','Male','Caucasian','Mining'),(2,'Jane','Smith','Female','Hispanic','Mining'); | SELECT ethnicity, gender, COUNT(*) as employee_count FROM employees WHERE department = 'Mining' AND state = 'California' GROUP BY ethnicity, gender; |
Find the number of artworks created by female artists in the modern art category. | CREATE TABLE artworks (id INT,artist_name VARCHAR(255),category VARCHAR(255)); INSERT INTO artworks (id,artist_name,category) VALUES (1,'Alice Neel','Modern Art'),(2,'Francis Bacon','Modern Art'),(3,'Yayoi Kusama','Modern Art'); | SELECT COUNT(*) FROM artworks WHERE artist_name IN (SELECT artist_name FROM artists WHERE gender = 'Female') AND category = 'Modern Art'; |
Delete records of clients with no financial capability data | CREATE TABLE financial_capability_client (client_id INT PRIMARY KEY,name VARCHAR(100),age INT,education_level VARCHAR(20));CREATE TABLE financial_capability_loan (loan_id INT PRIMARY KEY,client_id INT,loan_amount DECIMAL(10,2),loan_date DATE);INSERT INTO financial_capability_client (client_id,name,age,education_level) VALUES (10,'Mohammed',45,'Bachelor'),(11,'Sophia',35,'High School'); INSERT INTO financial_capability_loan (loan_id,client_id,loan_amount,loan_date) VALUES (10,10,5000.00,'2022-03-01'),(11,11,3000.00,'2022-03-01'); | DELETE c FROM financial_capability_client c LEFT JOIN financial_capability_loan l ON c.client_id = l.client_id WHERE l.client_id IS NULL; |
What is the total number of aquaculture farms in India, Indonesia, and Malaysia, that have dissolved oxygen levels above 7.5 mg/L? | CREATE TABLE FarmStats (id INT,country VARCHAR(50),dissolved_oxygen FLOAT); INSERT INTO FarmStats (id,country,dissolved_oxygen) VALUES (1,'India',7.2),(2,'Indonesia',8.0),(3,'Malaysia',6.9),(4,'India',7.7),(5,'Indonesia',7.9),(6,'Malaysia',7.6); | SELECT COUNT(*) FROM FarmStats WHERE country IN ('India', 'Indonesia', 'Malaysia') AND dissolved_oxygen > 7.5; |
How many schools were built in 2021 in the 'development' sector? | CREATE TABLE schools (id INT,name TEXT,year INT,sector TEXT); INSERT INTO schools (id,name,year,sector) VALUES (1,'School A',2019,'education'); INSERT INTO schools (id,name,year,sector) VALUES (2,'School B',2021,'development'); INSERT INTO schools (id,name,year,sector) VALUES (3,'School C',2020,'health'); | SELECT COUNT(*) FROM schools WHERE sector = 'development' AND year = 2021; |
What is the carbon sequestration potential of each tree species in the 'carbon_sequestration' table? | CREATE TABLE carbon_sequestration (id INT,species VARCHAR(255),sequestration_rate FLOAT); INSERT INTO carbon_sequestration (id,species,sequestration_rate) VALUES (1,'Oak',25.2),(2,'Maple',22.1),(3,'Pine',18.9); | SELECT species, sequestration_rate FROM carbon_sequestration; |
How many threat intelligence reports were published by CyberSec Inc. in Q1 2022? | CREATE TABLE ThreatIntel (report_name TEXT,company TEXT,date DATE); INSERT INTO ThreatIntel (report_name,company,date) VALUES ('Report 1','CyberSec Inc.','2022-01-01'),('Report 2','CyberSec Inc.','2022-01-15'),('Report 3','CyberSec Inc.','2022-03-30'); | SELECT COUNT(*) FROM ThreatIntel WHERE company = 'CyberSec Inc.' AND date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the total number of military technologies developed by each country? | CREATE TABLE military_tech (id INT,country VARCHAR,tech VARCHAR); INSERT INTO military_tech (id,country,tech) VALUES (1,'USA','Laser Technology'),(2,'China','Quantum Radar'),(3,'Russia','Hypersonic Missile'); | SELECT country, COUNT(*) OVER (PARTITION BY country) as total_tech FROM military_tech; |
What is the average donation amount per month in the year 2020? | CREATE TABLE donations (donation_date DATE,donation_amount FLOAT); INSERT INTO donations (donation_date,donation_amount) VALUES ('2020-01-01',50.00),('2020-01-15',100.00),('2020-02-20',25.00),('2020-03-10',75.00),('2020-03-25',150.00); | SELECT AVG(donation_amount) FROM donations WHERE YEAR(donation_date) = 2020 GROUP BY MONTH(donation_date); |
What is the average number of peacekeeping operations participated in by each country in the 'peacekeeping' table, excluding those with less than 3 operations? | CREATE TABLE peacekeeping (id INT,country VARCHAR(50),num_operations INT); | SELECT AVG(num_operations) FROM peacekeeping GROUP BY country HAVING COUNT(*) >= 3; |
What is the average healthcare expenditure per patient in 'rural_region_5' in 2022? | CREATE TABLE rural_region_5 (id INT,clinic_id INT,patient_id INT,year INT,expenditure INT); INSERT INTO rural_region_5 VALUES (1,1,1,2022,500); | SELECT AVG(expenditure / total_patients) FROM (SELECT patient_id, COUNT(*) OVER (PARTITION BY clinic_id) AS total_patients FROM rural_region_5 WHERE year = 2022) rural_region_5_summary; |
Delete records in the 'threat_intelligence' table where the 'threat_type' is 'cyber' and 'threat_details' is 'malware' | CREATE TABLE threat_intelligence (threat_id INT,threat_type VARCHAR(20),threat_details TEXT); | DELETE FROM threat_intelligence WHERE threat_type = 'cyber' AND threat_details = 'malware'; |
Identify fans who have attended both football and basketball games in the last month. | CREATE TABLE fan_attendance(fan_id INT,game_type VARCHAR(10),attendance_date DATE); INSERT INTO fan_attendance(fan_id,game_type,attendance_date) VALUES (1,'football','2022-01-05'),(2,'basketball','2022-01-07'),(3,'football','2022-01-10'),(1,'basketball','2022-01-12'),(4,'football','2022-01-15'),(3,'basketball','2022-01-17'); | SELECT fan_id FROM fan_attendance WHERE game_type = 'football' AND attendance_date >= DATEADD(month, -1, GETDATE()) INTERSECT SELECT fan_id FROM fan_attendance WHERE game_type = 'basketball' AND attendance_date >= DATEADD(month, -1, GETDATE()); |
Identify the top 5 most common attack types in the last month. | CREATE TABLE attack_logs (id INT,attack_type VARCHAR(50),timestamp TIMESTAMP); INSERT INTO attack_logs (id,attack_type,timestamp) VALUES (1,'SQL Injection','2022-01-01 10:00:00'),(2,'Brute Force','2022-01-02 12:00:00'); | SELECT attack_type, COUNT(*) as num_attacks FROM attack_logs WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY attack_type ORDER BY num_attacks DESC LIMIT 5; |
What is the max speed of Vessel B? | CREATE TABLE Vessels (vessel_id VARCHAR(10),name VARCHAR(20),type VARCHAR(20),max_speed FLOAT); INSERT INTO Vessels (vessel_id,name,type,max_speed) VALUES ('1','Vessel A','Cargo',20.5),('2','Vessel B','Tanker',15.2); | SELECT max_speed FROM Vessels WHERE name = 'Vessel B'; |
How many employees have been hired each month? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE); INSERT INTO Employees (EmployeeID,HireDate) VALUES (1,'2021-01-01'),(2,'2021-02-15'),(3,'2021-03-20'),(4,'2022-04-01'); | SELECT EXTRACT(MONTH FROM HireDate) as HireMonth, COUNT(*) as NumHired FROM Employees GROUP BY HireMonth ORDER BY HireMonth; |
Insert new records in the satellite_image_analysis table for field 8 with image_quality score 90, taken on 2023-04-01 | CREATE TABLE satellite_image_analysis (field_id INT,image_quality INT,image_timestamp DATETIME); | INSERT INTO satellite_image_analysis (field_id, image_quality, image_timestamp) VALUES (8, 90, '2023-04-01'); |
What is the average salary of employees who identify as male, hired in 2019, and work in the HR department? | CREATE TABLE Employees (EmployeeID int,Gender varchar(10),HireYear int,Department varchar(20),Salary decimal(10,2)); INSERT INTO Employees (EmployeeID,Gender,HireYear,Department,Salary) VALUES (1,'Female',2020,'IT',75000.00),(2,'Male',2019,'HR',60000.00),(3,'Non-binary',2018,'IT',80000.00),(4,'Male',2019,'IT',85000.00); | SELECT AVG(Salary) FROM Employees WHERE Gender = 'Male' AND HireYear = 2019 AND Department = 'HR'; |
Which green building projects in France have the highest water conservation ratings? | CREATE TABLE GreenBuildings (building_id INT,building_name VARCHAR(255),country VARCHAR(255),emissions_reduction FLOAT,water_conservation_rating FLOAT); | SELECT building_name, water_conservation_rating FROM GreenBuildings WHERE country = 'France' ORDER BY water_conservation_rating DESC; |
What is the total amount of research grants awarded to the Engineering department in the year 2020? | CREATE TABLE ResearchGrants(GranteeID INT,Department VARCHAR(20),Amount FLOAT,GrantDate DATE); INSERT INTO ResearchGrants(GranteeID,Department,Amount,GrantDate) VALUES (1,'Engineering',50000,'2020-01-01'),(2,'Computer Science',75000,'2021-01-01'); | SELECT SUM(rg.Amount) FROM ResearchGrants rg WHERE rg.Department = 'Engineering' AND YEAR(rg.GrantDate) = 2020; |
What is the total value of investments in the technology sector for customers with a savings account? | CREATE TABLE Investments (CustomerID INT,Sector VARCHAR(50),Value DECIMAL(10,2)); CREATE TABLE Accounts (CustomerID INT,AccountType VARCHAR(50)); INSERT INTO Investments (CustomerID,Sector,Value) VALUES (1,'Technology',5000),(2,'Finance',3000); INSERT INTO Accounts (CustomerID,AccountType) VALUES (1,'Savings'),(2,'Checking'); | SELECT SUM(Value) FROM Investments INNER JOIN Accounts ON Investments.CustomerID = Accounts.CustomerID WHERE Sector = 'Technology' AND AccountType = 'Savings' |
List the names of all teachers who have completed more than 30 hours of professional development and their respective professional development hours. | CREATE TABLE teachers (id INT,name VARCHAR(255),professional_development_hours INT); INSERT INTO teachers (id,name,professional_development_hours) VALUES (1,'James Smith',35); | SELECT name, professional_development_hours FROM teachers WHERE professional_development_hours > 30; |
What was the total amount donated by individuals in the technology industry in Q1 2022? | CREATE TABLE donors (id INT,name TEXT,industry TEXT,amount FLOAT,donation_date DATE); INSERT INTO donors (id,name,industry,amount,donation_date) VALUES (1,'John Doe','Technology',500,'2022-01-05'); INSERT INTO donors (id,name,industry,amount,donation_date) VALUES (2,'Jane Smith','Finance',300,'2022-03-10'); | SELECT SUM(amount) FROM donors WHERE industry = 'Technology' AND donation_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the average water consumption per textile type? | CREATE TABLE textiles (textile_id INT,textile_name VARCHAR(50),country VARCHAR(50),water_consumption INT); INSERT INTO textiles (textile_id,textile_name,country,water_consumption) VALUES (1,'Cotton','India',2000); | SELECT textile_name, AVG(water_consumption) as avg_water_consumption FROM textiles GROUP BY textile_name; |
What is the total number of transactions and their value for all NFTs on the Ethereum blockchain in Q1 2022? | CREATE TABLE eth_nfts (nft_id INT,transaction_time TIMESTAMP,value FLOAT); | SELECT SUM(value) as total_value, COUNT(nft_id) as total_transactions FROM eth_nfts WHERE transaction_time BETWEEN '2022-01-01 00:00:00' AND '2022-03-31 23:59:59'; |
What's the number of unique roles and their count for mining operations in Indonesia and Kazakhstan? | CREATE TABLE indonesian_provinces (id INT,name VARCHAR(50)); CREATE TABLE kazakhstani_regions (id INT,name VARCHAR(50)); CREATE TABLE mining_operations (id INT,country_id INT,region VARCHAR(20)); CREATE TABLE employees (id INT,operation_id INT,role VARCHAR(20)); INSERT INTO indonesian_provinces (id,name) VALUES (1,'East Kalimantan'),(2,'Papua'); INSERT INTO kazakhstani_regions (id,name) VALUES (1,'Karaganda'),(2,'Ekibastuz'); INSERT INTO mining_operations (id,country_id,region) VALUES (1,1,'Indonesia'),(2,1,'Indonesia'),(3,2,'Kazakhstan'),(4,2,'Kazakhstan'); INSERT INTO employees (id,operation_id,role) VALUES (1,1,'Operator'),(2,1,'Technician'),(3,2,'Engineer'),(4,3,'Manager'),(5,3,'Supervisor'),(6,4,'Operator'); | SELECT e.role, COUNT(DISTINCT e.id) as role_count FROM employees e INNER JOIN mining_operations m ON e.operation_id = m.id INNER JOIN (SELECT * FROM indonesian_provinces WHERE name IN ('East Kalimantan', 'Papua') UNION ALL SELECT * FROM kazakhstani_regions WHERE name IN ('Karaganda', 'Ekibastuz')) c ON m.country_id = c.id GROUP BY e.role; |
Calculate the total number of crimes reported in each month in the "CrimeData" table, where the crime type is 'Violence'. | CREATE TABLE CrimeData (id INT,reported_date DATE,crime_type VARCHAR(50)); INSERT INTO CrimeData (id,reported_date,crime_type) VALUES (1,'2022-01-01','Theft'),(2,'2022-01-02','Burglary'),(3,'2022-01-03','Vandalism'),(4,'2022-02-04','Violence'),(5,'2022-03-05','Violence'),(6,'2022-03-06','Theft'); | SELECT MONTH(reported_date) as month, COUNT(*) as num_crimes FROM CrimeData WHERE crime_type = 'Violence' GROUP BY month; |
What is the average length of descriptions for content from India? | CREATE TABLE media_content (id INT PRIMARY KEY,title VARCHAR(255),description TEXT,country VARCHAR(64),media_type VARCHAR(64)); INSERT INTO media_content (id,title,description,country,media_type) VALUES (1,'Movie A','Short description','India','Movie'),(2,'Show B','Long description','India','Show'); | SELECT AVG(LENGTH(description)) AS avg_description_length FROM media_content WHERE country = 'India'; |
Identify the top 5 customers by total assets in the Wealth Management division. | CREATE TABLE customers (customer_id INT,division VARCHAR(50),total_assets DECIMAL(10,2)); INSERT INTO customers (customer_id,division,total_assets) VALUES (1,'Wealth Management',500000.00),(2,'Retail Banking',25000.00),(3,'Wealth Management',750000.00),(4,'Private Banking',1000000.00); | SELECT customer_id, total_assets FROM customers WHERE division = 'Wealth Management' ORDER BY total_assets DESC LIMIT 5; |
What is the total installed capacity (in MW) of wind power projects in the 'europe' region, grouped by country? | CREATE TABLE wind_projects (id INT,country VARCHAR(50),region VARCHAR(50),capacity FLOAT); INSERT INTO wind_projects (id,country,region,capacity) VALUES (1,'Germany','europe',2345.67),(2,'France','europe',1234.56),(3,'Spain','europe',3456.78); | SELECT region, country, SUM(capacity) as total_capacity FROM wind_projects WHERE region = 'europe' GROUP BY country, region; |
What is the average speed of all vessels in the 'cargo' table? | CREATE TABLE IF NOT EXISTS cargo (id INT PRIMARY KEY,vessel_name VARCHAR(255),average_speed DECIMAL(5,2)); | SELECT AVG(average_speed) FROM cargo; |
Delete all intelligence operations related to a specific region in the last year. | CREATE TABLE RegionalIntelligenceOps (OpID INT,OpName VARCHAR(50),OpRegion VARCHAR(50),OpDate DATE); INSERT INTO RegionalIntelligenceOps (OpID,OpName,OpRegion,OpDate) VALUES (1,'Operation Red','Europe','2021-01-01'),(2,'Operation Blue','Asia','2021-02-15'),(3,'Operation Green','Middle East','2021-03-30'),(4,'Operation Yellow','Africa','2021-04-15'),(5,'Operation Purple','South America','2021-05-31'),(6,'Operation Orange','North America','2021-06-15'); | DELETE FROM RegionalIntelligenceOps WHERE OpDate >= DATEADD(year, -1, GETDATE()) AND OpRegion = 'Asia'; |
What is the average word count for news articles in each category, sorted by average word count? | CREATE TABLE News (news_id INT,title TEXT,category TEXT,word_count INT); INSERT INTO News (news_id,title,category,word_count) VALUES (1,'Article1','Politics',500),(2,'Article2','Sports',300),(3,'Article3','Politics',600); | SELECT category, AVG(word_count) as avg_word_count FROM News GROUP BY category ORDER BY avg_word_count DESC; |
Show biosensor technology development costs for each project in descending order. | CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.projects (id INT PRIMARY KEY,project_name VARCHAR(100),development_cost DECIMAL(10,2)); INSERT INTO biosensors.projects (id,project_name,development_cost) VALUES (1,'BioA',3000000.00),(2,'BioB',2500000.00),(3,'BioC',3500000.00); | SELECT project_name, development_cost FROM biosensors.projects ORDER BY development_cost DESC; |
How many vessels were inspected for maritime law compliance in the Indian Ocean in 2020? | CREATE TABLE vessel_inspections (vessel_name VARCHAR(255),inspection_year INT,inspection_location VARCHAR(255)); INSERT INTO vessel_inspections (vessel_name,inspection_year,inspection_location) VALUES ('MV Nisha',2020,'Indian Ocean'),('MV Ravi',2019,'Indian Ocean'); | SELECT COUNT(*) FROM vessel_inspections WHERE inspection_year = 2020 AND inspection_location = 'Indian Ocean'; |
What is the number of juvenile offenders in the 'juvenile_justice' table? | CREATE TABLE juvenile_justice (offender_id INT,age INT,offense VARCHAR(50),disposition VARCHAR(30),processing_date DATE); | SELECT COUNT(*) FROM juvenile_justice WHERE age < 18; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.