instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the total playtime of players who played PUBG in Japan?
CREATE TABLE Players (PlayerID INT,PlayerCountry VARCHAR(20),Game VARCHAR(20),Playtime INT); INSERT INTO Players (PlayerID,PlayerCountry,Game,Playtime) VALUES (1,'Japan','PUBG',50),(2,'Japan','Fortnite',60);
SELECT SUM(Playtime) FROM Players WHERE Game = 'PUBG' AND PlayerCountry = 'Japan';
Which countries have the highest and lowest average product quantities for sustainable materials?
CREATE TABLE PRODUCT (id INT PRIMARY KEY,name TEXT,material TEXT,quantity INT,country TEXT); INSERT INTO PRODUCT (id,name,material,quantity,country) VALUES (1,'Organic Cotton Shirt','Organic Cotton',30,'USA'); INSERT INTO PRODUCT (id,name,material,quantity,country) VALUES (2,'Recycled Poly Shoes','Recycled Polyester',25,'Germany'); INSERT INTO PRODUCT (id,name,material,quantity,country) VALUES (3,'Bamboo T-Shirt','Bamboo',15,'China');
SELECT country, AVG(quantity) as avg_quantity FROM PRODUCT WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Bamboo') GROUP BY country ORDER BY avg_quantity DESC, country ASC LIMIT 1; SELECT country, AVG(quantity) as avg_quantity FROM PRODUCT WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Bamboo') GROUP BY country ORDER BY avg_quantity ASC, country ASC LIMIT 1;
List unique workforce demographics and their respective departments in the 'staff_demographics' and 'staff_details' tables.
CREATE TABLE staff_demographics (id INT,name VARCHAR(50),gender VARCHAR(50),ethnicity VARCHAR(50)); INSERT INTO staff_demographics (id,name,gender,ethnicity) VALUES (1,'John Doe','Male','Caucasian'),(2,'Jane Smith','Female','African American'); CREATE TABLE staff_details (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO staff_details (id,name,department) VALUES (1,'John Doe','Mining Engineering'),(2,'Jane Smith','Human Resources');
SELECT staff_demographics.gender, staff_demographics.ethnicity, staff_details.department FROM staff_demographics INNER JOIN staff_details ON staff_demographics.name = staff_details.name;
What is the average drug approval time for drugs approved in each month, ranked by average approval time?
CREATE TABLE DrugApprovals (DrugName varchar(50),ApprovalDate date); INSERT INTO DrugApprovals (DrugName,ApprovalDate) VALUES ('DrugM','2022-01-05'),('DrugN','2022-02-12'),('DrugO','2022-03-19'),('DrugP','2022-04-23');
SELECT YEAR(ApprovalDate) as ApprovalYear, MONTH(ApprovalDate) as ApprovalMonth, AVG(DATEDIFF(day, ApprovalDate, LEAD(ApprovalDate, 1, GETDATE()) OVER (PARTITION BY YEAR(ApprovalDate), MONTH(ApprovalDate) ORDER BY ApprovalDate))), ROW_NUMBER() OVER (ORDER BY AVG(DATEDIFF(day, ApprovalDate, LEAD(ApprovalDate, 1, GETDATE()) OVER (PARTITION BY YEAR(ApprovalDate), MONTH(ApprovalDate) ORDER BY ApprovalDate))) DESC) as ApprovalRank FROM DrugApprovals GROUP BY YEAR(ApprovalDate), MONTH(ApprovalDate);
What is the percentage of police officers in Arizona who joined in 2021?
CREATE TABLE police_officers (id INT,name VARCHAR(255),joined_date DATE,state VARCHAR(255)); INSERT INTO police_officers (id,name,joined_date,state) VALUES (1,'John Doe','2021-01-02','Arizona');
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM police_officers WHERE state = 'Arizona')) as percentage FROM police_officers WHERE state = 'Arizona' AND joined_date >= '2021-01-01' AND joined_date < '2022-01-01';
List the number of mental health parity violations by state in Q1 2022.
CREATE TABLE mental_health_parity_violations (id INT,state VARCHAR(50),violation_date DATE); INSERT INTO mental_health_parity_violations (id,state,violation_date) VALUES (1,'California','2022-01-15'),(2,'Texas','2022-02-20'),(3,'New York','2022-03-05');
SELECT state, COUNT(*) as num_violations FROM mental_health_parity_violations WHERE violation_date >= '2022-01-01' AND violation_date < '2022-04-01' GROUP BY state;
Determine the number of unique consumers who have purchased products from suppliers with ethical labor practices.
CREATE TABLE Purchases (purchase_id INT,consumer_id INT,supplier_id INT,purchase_date DATE); INSERT INTO Purchases (purchase_id,consumer_id,supplier_id,purchase_date) VALUES (1,100,1,'2022-01-01'),(2,101,2,'2022-02-15'),(3,102,3,'2022-03-05'),(4,103,1,'2022-04-10'),(5,104,4,'2022-05-22'); CREATE TABLE Suppliers (supplier_id INT,ethical_practices BOOLEAN); INSERT INTO Suppliers (supplier_id,ethical_practices) VALUES (1,true),(2,false),(3,true),(4,false);
SELECT COUNT(DISTINCT consumer_id) as unique_ethical_consumers FROM Purchases INNER JOIN Suppliers ON Purchases.supplier_id = Suppliers.supplier_id WHERE Suppliers.ethical_practices = true;
What is the average number of flight hours for aircrafts manufactured by Airbus that have more than 15000 flight hours?
CREATE TABLE FlightSafety(id INT,aircraft_id INT,manufacturer VARCHAR(255),flight_hours INT); INSERT INTO FlightSafety(id,aircraft_id,manufacturer,flight_hours) VALUES (1,1001,'Boeing',12000),(2,1002,'Airbus',15500),(3,1003,'Boeing',18000),(4,1004,'Airbus',16000),(5,1005,'Airbus',15200);
SELECT AVG(flight_hours) FROM FlightSafety WHERE manufacturer = 'Airbus' AND flight_hours > 15000;
What is the average Union membership rate in the Retail sector?
CREATE TABLE UnionMembership (id INT,sector VARCHAR(255),membership DECIMAL(5,2)); INSERT INTO UnionMembership (id,sector,membership) VALUES (1,'Retail',0.25);
SELECT AVG(membership) FROM UnionMembership WHERE sector = 'Retail';
What is the net change in the population of each animal in the animal_population table?
CREATE TABLE animal_population (id INT,animal_name VARCHAR(50),population INT,birth_rate DECIMAL(4,2),death_rate DECIMAL(4,2));
SELECT animal_name, net_change FROM animal_population_summary;
What is the total number of articles published in each quarter?
CREATE TABLE articles (id INT,publication_date DATE,topic TEXT); INSERT INTO articles VALUES (1,'2022-01-01','Media Literacy'),(2,'2022-01-15','Content Diversity'),(3,'2022-02-01','Media Representation'),(4,'2022-02-15','Disinformation Detection'),(5,'2022-03-01','Media Literacy'),(6,'2022-03-15','Content Diversity'),(7,'2022-04-01','Media Literacy'),(8,'2022-04-15','Content Diversity'),(9,'2022-05-01','Media Representation'),(10,'2022-05-15','Disinformation Detection'),(11,'2022-06-01','Media Literacy'),(12,'2022-06-15','Content Diversity'),(13,'2022-07-01','Media Representation'),(14,'2022-07-15','Disinformation Detection'),(15,'2022-08-01','Media Literacy'),(16,'2022-08-15','Content Diversity'),(17,'2022-09-01','Media Representation'),(18,'2022-09-15','Disinformation Detection'),(19,'2022-10-01','Media Literacy'),(20,'2022-10-15','Content Diversity'),(21,'2022-11-01','Media Representation'),(22,'2022-11-15','Disinformation Detection'),(23,'2022-12-01','Media Literacy'),(24,'2022-12-15','Content Diversity');
SELECT EXTRACT(QUARTER FROM publication_date) as quarter, COUNT(*) as article_count FROM articles GROUP BY quarter;
List the names and CO2 emissions for projects in the 'disaster_recovery' schema, ordered by CO2 emissions in descending order
CREATE SCHEMA IF NOT EXISTS disaster_recovery; CREATE TABLE disaster_recovery.projects (id INT,name VARCHAR(100),co2_emissions FLOAT); INSERT INTO disaster_recovery.projects (id,name,co2_emissions) VALUES (1,'Hurricane Resilience',100),(2,'Flood Mitigation',80),(3,'Earthquake Preparedness',50);
SELECT name, co2_emissions FROM disaster_recovery.projects ORDER BY co2_emissions DESC;
Display the species and total population of fish in the 'FishPopulation' table with a population greater than 50000
CREATE TABLE FishPopulation (id INT,species VARCHAR(255),population INT); INSERT INTO FishPopulation (id,species,population) VALUES (1,'Salmon',50000); INSERT INTO FishPopulation (id,species,population) VALUES (2,'Trout',25000); INSERT INTO FishPopulation (id,species,population) VALUES (3,'Carp',40000); INSERT INTO FishPopulation (id,species,population) VALUES (4,'Tuna',30000); INSERT INTO FishPopulation (id,species,population) VALUES (5,'Shrimp',10000);
SELECT species, SUM(population) FROM FishPopulation WHERE population > 50000 GROUP BY species;
Identify the top 5 most active contributors in the investigative journalism projects, based on the number of articles they have published.
CREATE TABLE journalists (id INT,name VARCHAR(50),articles_published INT); INSERT INTO journalists (id,name,articles_published) VALUES (1,'Sasha Petrova',25),(2,'Chen Wei',18),(3,'Mariana Santos',22),(4,'Alessandro Alviani',15),(5,'Sana Saeed',30);
SELECT name, articles_published FROM journalists ORDER BY articles_published DESC LIMIT 5;
List the top 3 sources of threat intelligence that provided the most actionable intelligence in the past month, along with the number of actionable intelligence reports, broken down by organization size.
CREATE TABLE threat_intelligence (id INT PRIMARY KEY,source VARCHAR(50),actionable_report BOOLEAN,report_time TIMESTAMP,organization_size VARCHAR(50)); INSERT INTO threat_intelligence (id,source,actionable_report,report_time,organization_size) VALUES (1,'FireEye',TRUE,'2022-07-01 10:00:00','Large'),(2,'CrowdStrike',FALSE,'2022-07-02 12:30:00','Small'),(3,'Mandiant',TRUE,'2022-07-03 08:15:00','Medium');
SELECT source, COUNT(*) as actionable_reports, organization_size FROM threat_intelligence WHERE actionable_report = TRUE AND report_time >= NOW() - INTERVAL '1 month' GROUP BY source, organization_size ORDER BY actionable_reports DESC LIMIT 3;
List all the social good technology programs in Africa.
CREATE TABLE Social_Good_Tech (Program VARCHAR(255),Region VARCHAR(255)); INSERT INTO Social_Good_Tech (Program,Region) VALUES ('EduTech','Africa'),('HealthTech','Asia'),('AgriTech','Africa'),('FinTech','Europe');
SELECT Program FROM Social_Good_Tech WHERE Region = 'Africa';
Update the year of an artwork with the title 'The Persistence of Memory' to 1931, associated with the style 'Surrealism'.
CREATE TABLE art_styles (id INT,style VARCHAR(255),movement VARCHAR(255)); CREATE TABLE artworks (id INT,title VARCHAR(255),year INT,style_id INT);
UPDATE artworks SET year = 1931 WHERE title = 'The Persistence of Memory' AND style_id = (SELECT s.id FROM art_styles s WHERE s.style = 'Surrealism');
What is the size of the largest protected habitat in square kilometers?
CREATE TABLE habitats (id INT,name TEXT,size_km2 FLOAT); INSERT INTO habitats (id,name,size_km2) VALUES (1,'Forest',50.3),(2,'Wetlands',32.1),(3,'Grasslands',87.6);
SELECT MAX(size_km2) as max_size FROM habitats;
What is the latest launch date for each satellite model?
CREATE TABLE Satellites (id INT,name VARCHAR(100),model VARCHAR(100),launch_date DATE); INSERT INTO Satellites (id,name,model,launch_date) VALUES (6,'Sat6','Model1','2021-05-01'); INSERT INTO Satellites (id,name,model,launch_date) VALUES (7,'Sat7','Model2','2022-03-18'); INSERT INTO Satellites (id,name,model,launch_date) VALUES (8,'Sat8','Model1','2020-09-25');
SELECT model, MAX(launch_date) OVER (PARTITION BY model) as max_launch_date FROM Satellites;
Top 5 ingredients sourced from sustainable farms in the USA?
CREATE TABLE ingredients (product_name TEXT,ingredient TEXT,sourcing_country TEXT,sustainability_rating FLOAT); INSERT INTO ingredients (product_name,ingredient,sourcing_country,sustainability_rating) VALUES ('ProductA','IngredientX','USA',4.2),('ProductB','IngredientY','Canada',3.5),('ProductC','IngredientX','USA',4.8);
SELECT ingredient, AVG(sustainability_rating) as avg_sustainability_rating FROM ingredients WHERE sourcing_country = 'USA' GROUP BY ingredient ORDER BY avg_sustainability_rating DESC LIMIT 5;
List all unique AI safety research areas and corresponding lead researchers.
CREATE TABLE aisafety_research (area VARCHAR(255),lead_researcher VARCHAR(255)); INSERT INTO aisafety_research (area,lead_researcher) VALUES ('Robustness and Generalization','Gary Marcus'),('Interpretability','Cynthia Rudin'),('Value Alignment','Stuart Russell');
SELECT DISTINCT area, lead_researcher FROM aisafety_research
Generate a view 'threat_trends' to display the number of high, medium, and low threat intelligence metrics by year
CREATE TABLE threat_intelligence (id INT PRIMARY KEY,year INT,threat_level VARCHAR(10),description TEXT);INSERT INTO threat_intelligence (id,year,threat_level,description) VALUES (1,2018,'High','Cyber attack on defense networks'),(2,2018,'Medium','Espionage activities'),(3,2018,'Low','Propaganda campaigns'),(4,2019,'High','Physical attack on military bases'),(5,2019,'Medium','Cyber attack on defense networks'),(6,2019,'Low','Propaganda campaigns');
CREATE VIEW threat_trends AS SELECT year, SUM(CASE WHEN threat_level = 'High' THEN 1 ELSE 0 END) as high_threats, SUM(CASE WHEN threat_level = 'Medium' THEN 1 ELSE 0 END) as medium_threats, SUM(CASE WHEN threat_level = 'Low' THEN 1 ELSE 0 END) as low_threats FROM threat_intelligence GROUP BY year;
How many female attendees visited the theater in the past week?
CREATE TABLE TheaterAttendees (attendeeID INT,visitDate DATE,gender VARCHAR(10)); INSERT INTO TheaterAttendees (attendeeID,visitDate,gender) VALUES (1,'2022-02-05','Female'),(2,'2022-02-09','Male'),(3,'2022-02-14','Female');
SELECT COUNT(*) FROM TheaterAttendees WHERE visitDate >= '2022-02-01' AND visitDate <= '2022-02-07' AND gender = 'Female';
What is the name and creation date of the artifact with the third earliest creation date?
CREATE TABLE Artifacts (ArtifactID INT,Name VARCHAR(100),CreationDate DATETIME); INSERT INTO Artifacts (ArtifactID,Name,CreationDate) VALUES (1,'Ancient Dagger','1500-01-01'),(2,'Modern Artifact','2020-01-01'),(3,'Bronze Age Axe','3500-01-01'),(4,'Iron Age Helmet','2500-01-01');
SELECT Name, CreationDate FROM (SELECT Name, CreationDate, ROW_NUMBER() OVER (ORDER BY CreationDate) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 3;
Which cities have had a female mayor for the longest continuous period?
CREATE TABLE city (id INT,name VARCHAR(255)); INSERT INTO city (id,name) VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'),(4,'Houston'),(5,'Phoenix'); CREATE TABLE mayor (id INT,city_id INT,name VARCHAR(255),gender VARCHAR(10),start_year INT,end_year INT); INSERT INTO mayor (id,city_id,name,gender,start_year,end_year) VALUES (1,1,'John Smith','Male',2018,2021),(2,1,'Maria Rodriguez','Female',2005,2017),(3,2,'James Johnson','Male',2015,2020),(4,3,'William Lee','Male',2000,2005),(5,3,'Sarah Lee','Female',2006,2019),(6,4,'Robert Brown','Male',2010,2019),(7,5,'David Garcia','Male',2005,2011),(8,5,'Grace Kim','Female',2012,2021);
SELECT c.name, MAX(m.end_year - m.start_year) as max_tenure FROM city c JOIN mayor m ON c.id = m.city_id WHERE m.gender = 'Female' GROUP BY c.name HAVING MAX(m.end_year - m.start_year) >= ALL (SELECT MAX(m2.end_year - m2.start_year) FROM mayor m2 WHERE m2.gender = 'Female')
What is the total sales for each product type in Q3 of 2022?
CREATE TABLE sales (sale_id INT,product_id INT,sale_date DATE,revenue DECIMAL(10,2)); CREATE TABLE products (product_id INT,product_name VARCHAR(50),product_type VARCHAR(50));
SELECT p.product_type, SUM(s.revenue) as q3_sales FROM sales s JOIN products p ON s.product_id = p.product_id WHERE s.sale_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY p.product_type;
What are the top 3 energy-efficient countries in Africa in 2021?
CREATE TABLE EnergyEfficiency (Country TEXT,Year INT,Score NUMBER); INSERT INTO EnergyEfficiency (Country,Year,Score) VALUES ('South Africa',2021,60),('Egypt',2021,65),('Nigeria',2021,70),('Kenya',2021,75),('Morocco',2021,80);
SELECT Country, Score FROM EnergyEfficiency WHERE Year = 2021 ORDER BY Score DESC LIMIT 3;
What is the average project timeline for commercial buildings in Chicago?
CREATE TABLE project_timeline (timeline_id INT,project_id INT,building_type VARCHAR(20),city VARCHAR(20),days INT); INSERT INTO project_timeline (timeline_id,project_id,building_type,city,days) VALUES (1,301,'Commercial','Chicago',90),(2,302,'Residential','Chicago',60),(3,303,'Commercial','New York',120);
SELECT AVG(days) FROM project_timeline WHERE building_type = 'Commercial' AND city = 'Chicago';
Who are the top 5 users with the most followers from Brazil?
CREATE TABLE users (id INT,country VARCHAR(50),followers INT); INSERT INTO users (id,country,followers) VALUES (1,'Brazil',1000),(2,'Brazil',2000),(3,'Brazil',1500),(4,'Canada',2500),(5,'Canada',3000);
SELECT * FROM (SELECT users.id, users.country, users.followers, ROW_NUMBER() OVER (ORDER BY users.followers DESC) as row_num FROM users WHERE users.country = 'Brazil') sub WHERE row_num <= 5;
What is the percentage of sustainable sourcing practices for each cuisine type?
CREATE TABLE sustainable_sourcing_practices(cuisine VARCHAR(255),is_sustainable BOOLEAN); INSERT INTO sustainable_sourcing_practices VALUES ('Italian',true),('Mexican',false),('Chinese',true);
SELECT cuisine, 100.0 * AVG(CAST(is_sustainable AS DECIMAL)) AS percentage FROM sustainable_sourcing_practices GROUP BY cuisine;
What is the number of hospitals in New York state that offer free COVID-19 testing?
CREATE TABLE Hospitals (HospitalID INT,Name VARCHAR(50),State VARCHAR(20),FreeTesting BOOLEAN); INSERT INTO Hospitals (HospitalID,Name,State,FreeTesting) VALUES (1,'Mount Sinai','New York',TRUE); INSERT INTO Hospitals (HospitalID,Name,State,FreeTesting) VALUES (2,'NYU Langone','New York',TRUE);
SELECT COUNT(*) FROM Hospitals WHERE State = 'New York' AND FreeTesting = TRUE;
What is the total revenue of each category of dishes in January?
CREATE TABLE revenue_by_month (month VARCHAR(10),category VARCHAR(25),sales DECIMAL(10,2)); INSERT INTO revenue_by_month (month,category,sales) VALUES ('January','Italian',1500.00),('January','Vegan',1200.00); CREATE VIEW monthly_revenue_by_category AS SELECT month,category,SUM(sales) as total_sales FROM revenue_by_month GROUP BY month,category;
SELECT total_sales FROM monthly_revenue_by_category WHERE month = 'January';
Which art pieces were sold for the highest and lowest prices in the last 10 years?
CREATE TABLE art_sales (id INT,year INT,art_name VARCHAR(50),art_type VARCHAR(50),sale_price INT);
SELECT art_name, year, sale_price FROM (SELECT art_name, year, sale_price, DENSE_RANK() OVER (ORDER BY sale_price DESC) as rank FROM art_sales WHERE year >= 2012) a WHERE rank <= 1 OR rank >= 11;
What is the total humanitarian assistance provided by Japan in 2020?
CREATE TABLE humanitarian_assistance (assistance_id INT,provider TEXT,recipient TEXT,amount FLOAT,year INT); INSERT INTO humanitarian_assistance (assistance_id,provider,recipient,amount,year) VALUES (1,'Japan','Syria',1000000,2020),(2,'Japan','Afghanistan',500000,2020);
SELECT SUM(amount) FROM humanitarian_assistance WHERE provider = 'Japan' AND year = 2020
What is the average mass of operational spacecraft in the 'Spacecrafts' table?
CREATE TABLE Spacecrafts (Spacecraft_ID INT,Name VARCHAR(100),Manufacturer VARCHAR(100),Mass FLOAT,Operational BOOLEAN); INSERT INTO Spacecrafts (Spacecraft_ID,Name,Manufacturer,Mass,Operational) VALUES (1,'Crew Dragon','SpaceX',14000.0,TRUE);
SELECT AVG(Mass) FROM Spacecrafts WHERE Operational = TRUE;
What is the minimum stay required for volunteer tourism in Nepal?
CREATE TABLE volunteer_programs (id INT,location VARCHAR(20),min_stay INT); INSERT INTO volunteer_programs (id,location,min_stay) VALUES (1,'Nepal',14),(2,'Nepal',21),(3,'Nepal',10);
SELECT MIN(min_stay) FROM volunteer_programs WHERE location = 'Nepal';
List the name and material of all the building permits issued in the last 3 months, with the most recent permits first.
CREATE TABLE Permits (id INT,name TEXT,issue_date DATE,material TEXT); INSERT INTO Permits (id,name,issue_date,material) VALUES (1,'High-Rise Construction','2023-02-01','Concrete'),(2,'Townhome Construction','2023-03-15','Wood');
SELECT name, material FROM Permits WHERE issue_date > (CURRENT_DATE - INTERVAL '3 months') ORDER BY issue_date DESC;
Count the number of successful satellite launches per country
CREATE TABLE Launches (LaunchID INT,LaunchDate DATE,SatelliteName VARCHAR(50),Country VARCHAR(50),Success VARCHAR(50)); INSERT INTO Launches (LaunchID,LaunchDate,SatelliteName,Country,Success) VALUES (1,'2020-01-01','Sat1','USA','Success'); INSERT INTO Launches (LaunchID,LaunchDate,SatelliteName,Country,Success) VALUES (2,'2020-02-10','Sat2','China','Failure');
SELECT Country, COUNT(*) FROM Launches WHERE Success = 'Success' GROUP BY Country;
What's the total number of songs and albums released by a specific artist, such as 'Taylor Swift'?
CREATE TABLE artist (id INT,name VARCHAR(100)); CREATE TABLE album (id INT,title VARCHAR(100),artist_id INT,release_year INT); CREATE TABLE song (id INT,title VARCHAR(100),album_id INT,track_number INT); INSERT INTO artist (id,name) VALUES (1,'Taylor Swift'); INSERT INTO album (id,title,artist_id,release_year) VALUES (1,'Album1',1,2010); INSERT INTO song (id,title,album_id,track_number) VALUES (1,'Song1',1,1);
SELECT COUNT(*), (SELECT COUNT(*) FROM album WHERE artist_id = artist.id) as album_count FROM song WHERE artist_id = 1;
What is the average safety score for models that have at least one safety score greater than 7?
CREATE TABLE safety_audits (id INT,model_id INT,safety_score INT,created_at DATETIME); INSERT INTO safety_audits (id,model_id,safety_score,created_at) VALUES (1,1,8,'2021-01-01'); INSERT INTO safety_audits (id,model_id,safety_score,created_at) VALUES (2,2,9,'2021-01-02'); INSERT INTO safety_audits (id,model_id,safety_score,created_at) VALUES (3,3,6,'2021-01-03');
SELECT model_id, AVG(safety_score) as avg_safety_score FROM safety_audits WHERE model_id IN (SELECT model_id FROM safety_audits WHERE safety_score > 7 GROUP BY model_id HAVING COUNT(*) > 1) GROUP BY model_id;
List all explainable AI techniques and their applications, if any, in the creative AI domain.
CREATE TABLE explainable_ai (id INT,technique VARCHAR(255),application VARCHAR(255)); INSERT INTO explainable_ai (id,technique,application) VALUES (1,'SHAP','Image generation'),(2,'LIME','Music composition'),(3,'TreeExplainer','Text summarization'),(4,'DeepLIFT','Painting style transfer');
SELECT technique, application FROM explainable_ai WHERE application IS NOT NULL;
What is the minimum GPA for students in the traditional learning program?
CREATE TABLE students(id INT,program VARCHAR(255),gpa DECIMAL(3,2)); INSERT INTO students VALUES (1,'traditional learning',2.8),(2,'traditional learning',3.5),(3,'traditional learning',3.9);
SELECT MIN(gpa) FROM students WHERE program = 'traditional learning';
Which hospitals in Mumbai have a capacity greater than 500 and have reported COVID-19 cases?
CREATE TABLE hospitals (id INT,name VARCHAR(50),location VARCHAR(50),capacity INT); INSERT INTO hospitals (id,name,location,capacity) VALUES (1,'Mumbai Hospital','Mumbai',600); CREATE TABLE infections (id INT,patient_id INT,infection VARCHAR(50),date DATE,hospital_id INT); INSERT INTO infections (id,patient_id,infection,date,hospital_id) VALUES (1,1,'Covid-19','2022-01-01',1);
SELECT hospitals.name, hospitals.capacity FROM hospitals INNER JOIN infections ON hospitals.id = infections.hospital_id WHERE hospitals.location = 'Mumbai' AND hospitals.capacity > 500;
What is the total number of hybrid vehicles in the Chinese market as of 2022?
CREATE TABLE market_share (id INT,year INT,country VARCHAR(255),vehicle_type VARCHAR(255),market_share DECIMAL(5,2)); INSERT INTO market_share (id,year,country,vehicle_type,market_share) VALUES (1,2022,'China','Hybrid Vehicle',0.15),(2,2021,'China','Hybrid Vehicle',0.13);
SELECT SUM(market_share*1000000) FROM market_share WHERE year = 2022 AND country = 'China' AND vehicle_type = 'Hybrid Vehicle';
What is the average age of patients diagnosed with diabetes in rural areas of Montana?
CREATE TABLE patient_diabetes (patient_id INT,age INT,diagnosis VARCHAR(50),location VARCHAR(20)); INSERT INTO patient_diabetes (patient_id,age,diagnosis,location) VALUES (1,55,'Diabetes','Rural Montana'); INSERT INTO patient_diabetes (patient_id,age,diagnosis,location) VALUES (2,60,'Diabetes','Rural Montana'); INSERT INTO patient_diabetes (patient_id,age,diagnosis,location) VALUES (3,45,'Pre-diabetes','Urban Montana');
SELECT AVG(age) FROM patient_diabetes WHERE diagnosis = 'Diabetes' AND location = 'Rural Montana';
Count the number of customers from India and Brazil who are above 40 years old.
CREATE TABLE Customers (CustomerID INT,FirstName VARCHAR(20),LastName VARCHAR(20),Age INT,Country VARCHAR(20)); INSERT INTO Customers (CustomerID,FirstName,LastName,Age,Country) VALUES (1,'Sanaa','Ali',32,'Morocco'); INSERT INTO Customers (CustomerID,FirstName,LastName,Age,Country) VALUES (2,'Javier','Gonzalez',47,'Mexico'); INSERT INTO Customers (CustomerID,FirstName,LastName,Age,Country) VALUES (3,'Xueyan','Wang',51,'China'); INSERT INTO Customers (CustomerID,FirstName,LastName,Age,Country) VALUES (4,'Rajesh','Patel',45,'India'); INSERT INTO Customers (CustomerID,FirstName,LastName,Age,Country) VALUES (5,'Ana','Santos',50,'Brazil');
SELECT COUNT(*) FROM Customers WHERE Age > 40 AND Country IN ('India', 'Brazil');
What is the average revenue per day for each region?
CREATE TABLE sales (region VARCHAR(20),revenue INT,sale_date DATE); INSERT INTO sales (region,revenue,sale_date) VALUES ('East Coast',500,'2021-01-01'),('West Coast',300,'2021-01-01'),('Midwest',400,'2021-01-01'),('East Coast',600,'2021-01-02'),('West Coast',400,'2021-01-02'),('Midwest',500,'2021-01-02');
SELECT region, AVG(revenue) FROM sales GROUP BY region, EXTRACT(DAY FROM sale_date);
Calculate the percentage of transactions completed by each employee in the Human Resources department.
CREATE TABLE employees (employee_id INT,employee_name TEXT,department TEXT); CREATE TABLE transactions (transaction_id INT,employee_id INT,transaction_status TEXT);
SELECT e.employee_name, 100.0 * COUNT(t.transaction_id) / SUM(COUNT(t.transaction_id)) OVER (PARTITION BY NULL) AS transaction_percentage FROM transactions t JOIN employees e ON t.employee_id = e.employee_id WHERE e.department = 'Human Resources' GROUP BY e.employee_id, e.employee_name;
How many community education programs were conducted in the North American conservation areas, broken down by state and program type?
CREATE TABLE north_american_conservation_areas (id INT,name VARCHAR(255),state VARCHAR(255)); CREATE TABLE community_education_programs (id INT,conservation_area_id INT,program_type VARCHAR(255),date DATE,attendees INT);
SELECT na.state, pe.program_type, COUNT(pe.id) as program_count FROM north_american_conservation_areas na JOIN community_education_programs pe ON na.id = pe.conservation_area_id GROUP BY na.state, pe.program_type;
What is the tool with the lowest score?
CREATE TABLE tool (category VARCHAR(20),tool VARCHAR(20),score INT); INSERT INTO tool (category,tool,score) VALUES ('AI','Chatbot',85),('AI','Image Recognition',90),('Data','Data Visualization',80);
SELECT tool, score FROM tool WHERE score = (SELECT MIN(score) FROM tool);
How many fans are from NY in the fan_demographics table?
CREATE TABLE fan_demographics (fan_id INTEGER,fan_state TEXT);
SELECT COUNT(*) FROM fan_demographics WHERE fan_state = 'NY';
What was the total budget for the 'Heritage Preservation' program in 2021?
CREATE TABLE programs(id INT,name VARCHAR(255),year INT,budget FLOAT); INSERT INTO programs (id,name,year,budget) VALUES (1,'Heritage Preservation',2021,1000000.00),(2,'Arts Education',2022,750000.00),(3,'Heritage Preservation',2022,1200000.00);
SELECT budget FROM programs WHERE name = 'Heritage Preservation' AND year = 2021;
Delete all threat intelligence records from 2018
CREATE TABLE ThreatIntelligence (ID INT,Year INT,ThreatLevel TEXT); INSERT INTO ThreatIntelligence (ID,Year,ThreatLevel) VALUES (1,2017,'High'),(2,2018,'Low'),(3,2019,'Medium');
DELETE FROM ThreatIntelligence WHERE Year = 2018;
What is the total carbon offset by renewable energy projects in Brazil?
CREATE TABLE carbon_offset (id INT,project_type VARCHAR(50),country VARCHAR(50),offset_amount INT);
SELECT SUM(offset_amount) FROM carbon_offset WHERE country = 'Brazil' AND project_type = 'renewable';
What is the most common age group for Tuberculosis cases in India?
CREATE TABLE Tuberculosis (Country TEXT,Age TEXT,Cases INT); INSERT INTO Tuberculosis (Country,Age,Cases) VALUES ('India','0-4',100),('India','5-9',200),('India','10-14',300);
SELECT Age, MAX(Cases) FROM Tuberculosis WHERE Country = 'India' GROUP BY Age;
Find the number of exhibitions in Asia featuring artworks from the 'Fauvism' genre and the total revenue generated from sales of 'Impressionism' genre artworks in Germany.
CREATE TABLE Artworks (ArtworkID INT,ArtworkName VARCHAR(50),Genre VARCHAR(20)); INSERT INTO Artworks (ArtworkID,ArtworkName,Genre) VALUES (1,'The Joy of Life','Fauvism'); CREATE TABLE ExhibitionsArtworks (ExhibitionID INT,ArtworkID INT,Location VARCHAR(20)); INSERT INTO ExhibitionsArtworks (ExhibitionID,ArtworkID) VALUES (1,1); CREATE TABLE Sales (SaleID INT,ArtworkID INT,Genre VARCHAR(20),Revenue FLOAT,Location VARCHAR(20)); INSERT INTO Sales (SaleID,ArtworkID,Genre,Revenue,Location) VALUES (1,1,'Fauvism',NULL,'Japan'),(2,1,NULL,2000.00,'Germany');
SELECT COUNT(DISTINCT ExhibitionsArtworks.ExhibitionID), SUM(Sales.Revenue) FROM ExhibitionsArtworks INNER JOIN Sales ON ExhibitionsArtworks.ArtworkID = Sales.ArtworkID WHERE ExhibitionsArtworks.Location = 'Asia' AND Sales.Genre = 'Impressionism' AND Sales.Location = 'Germany';
What is the average transaction value for 'SmartContractF'?
CREATE TABLE Transactions (tx_id INT,contract_name VARCHAR(255),tx_value DECIMAL(10,2)); INSERT INTO Transactions (tx_id,contract_name,tx_value) VALUES (1,'SmartContractF',150.50); INSERT INTO Transactions (tx_id,contract_name,tx_value) VALUES (2,'SmartContractF',250.75);
SELECT AVG(tx_value) FROM Transactions WHERE contract_name = 'SmartContractF';
Insert a new record into the 'multimodal_mobility' table with 'station_name'='Capitol Hill', 'city'='Seattle', 'mode'='Scooter Share'
CREATE TABLE multimodal_mobility (station_name VARCHAR(255),city VARCHAR(255),mode VARCHAR(255));
INSERT INTO multimodal_mobility (station_name, city, mode) VALUES ('Capitol Hill', 'Seattle', 'Scooter Share');
Display the number of power plants in California
CREATE TABLE Infrastructure (id INT,name VARCHAR(100),type VARCHAR(50),location VARCHAR(100),state VARCHAR(50)); INSERT INTO Infrastructure (id,name,type,location,state) VALUES (5,'Diablo Canyon Power Plant','Power Plant','San Luis Obispo','California');
SELECT COUNT(*) FROM Infrastructure WHERE type = 'Power Plant' AND state = 'California';
Update the petition titles in the 'petitions' table to uppercase for petitions related to the 'Education' department.
CREATE TABLE departments (id INT PRIMARY KEY,name VARCHAR(255));CREATE TABLE petitions (id INT PRIMARY KEY,department_id INT,title VARCHAR(255));
UPDATE petitions SET title = UPPER(title) WHERE department_id IN (SELECT id FROM departments WHERE name = 'Education');
What is the most common application type in creative AI?
CREATE TABLE creative_ai (application_name TEXT,application_type TEXT); INSERT INTO creative_ai (application_name,application_type) VALUES ('App7','Image Generation'),('App8','Text Generation'),('App9','Image Generation');
SELECT application_type, COUNT(*) FROM creative_ai GROUP BY application_type ORDER BY COUNT(*) DESC LIMIT 1;
List all autonomous driving research projects with a budget over $8 million in 2022.
CREATE TABLE autonomous_projects_world (project_name VARCHAR(50),budget DECIMAL(10,2),year INT); INSERT INTO autonomous_projects_world (project_name,budget,year) VALUES ('Project Pegasus',9000000,2022),('Project Quantum',11000000,2022),('Project Orion',8500000,2022),('Project Titan',10000000,2022),('Project Neo',12000000,2022);
SELECT * FROM autonomous_projects_world WHERE budget > 8000000 AND year = 2022;
What is the total labor cost for green building projects in Texas and Oklahoma?
CREATE TABLE Green_Buildings (Project_ID INT,Project_Name VARCHAR(255),State VARCHAR(255),Labor_Cost DECIMAL(10,2)); INSERT INTO Green_Buildings (Project_ID,Project_Name,State,Labor_Cost) VALUES (1,'Solar Farm','Texas',200000.00),(2,'Wind Turbine Park','Oklahoma',180000.00);
SELECT State, SUM(Labor_Cost) FROM Green_Buildings WHERE State IN ('Texas', 'Oklahoma') GROUP BY State;
What is the average fine issued for traffic violations in each police precinct?
CREATE TABLE TrafficViolations (ID INT,Precinct VARCHAR(20),Fine FLOAT); INSERT INTO TrafficViolations (ID,Precinct,Fine) VALUES (1,'Precinct1',150.0),(2,'Precinct2',200.0),(3,'Precinct3',125.0);
SELECT Precinct, AVG(Fine) OVER (PARTITION BY Precinct) AS AvgFine FROM TrafficViolations;
What is the total number of bridges, dams, and roads in the 'infrastructure_database' schema?
CREATE TABLE infrastructure_database.bridges (bridge_id INT,name VARCHAR(255)); CREATE TABLE infrastructure_database.dams (dam_id INT,name VARCHAR(255)); CREATE TABLE infrastructure_database.roads (road_id INT,name VARCHAR(255)); INSERT INTO infrastructure_database.bridges (bridge_id,name) VALUES (1,'Brooklyn Bridge'),(2,'Tower Bridge'); INSERT INTO infrastructure_database.dams (dam_id,name) VALUES (1,'Hoover Dam'),(2,'Grand Coulee Dam'); INSERT INTO infrastructure_database.roads (road_id,name) VALUES (1,'Autobahn'),(2,'I-95');
SELECT COUNT(*) FROM (SELECT * FROM infrastructure_database.bridges UNION ALL SELECT * FROM infrastructure_database.dams UNION ALL SELECT * FROM infrastructure_database.roads);
Insert a new record for a staff member 'Jamal Jackson' in the 'Staff' table.
CREATE TABLE Staff (StaffID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Position VARCHAR(50)); INSERT INTO Staff (StaffID,FirstName,LastName,Position) VALUES (1,'John','Doe','Manager'),(2,'Jane','Doe','Assistant Manager'),(3,'Bob','Smith','Coordinator');
INSERT INTO Staff (StaffID, FirstName, LastName, Position) VALUES (5, 'Jamal', 'Jackson', 'Specialist');
How many concert tickets were sold for the 'Stadium Tour'?
CREATE TABLE concert_sales (sale_id INT,concert_name VARCHAR(100),total_tickets_sold INT); INSERT INTO concert_sales (sale_id,concert_name,total_tickets_sold) VALUES (1,'Stadium Tour',1000000); INSERT INTO concert_sales (sale_id,concert_name,total_tickets_sold) VALUES (2,'Arena Tour',750000);
SELECT total_tickets_sold FROM concert_sales WHERE concert_name = 'Stadium Tour';
Update all mental health assessment scores below 70 for students in the past month in the 'student_mental_health' table to 70.
CREATE TABLE student_mental_health (student_id INT,assessment_date DATE,assessment_score INT);
UPDATE student_mental_health SET assessment_score = 70 WHERE assessment_score < 70 AND assessment_date >= DATE(NOW()) - INTERVAL 1 MONTH;
What is the difference between the average song length of 'Pop' and 'Rock' genres?
CREATE TABLE genre_songs (genre VARCHAR(50),song_length FLOAT); INSERT INTO genre_songs (genre,song_length) VALUES ('Pop',225.0),('Rock',275.0),('Pop',195.0),('Rock',260.0);
SELECT AVG(gs1.song_length) - AVG(gs2.song_length) FROM genre_songs gs1 JOIN genre_songs gs2 ON gs1.genre = 'Pop' AND gs2.genre = 'Rock';
What is the maximum number of stories in high-rise residential buildings in Singapore?
CREATE TABLE Building_Heights (Building_ID INT,Building_Type VARCHAR(50),Stories INT,Location VARCHAR(50));
SELECT MAX(Stories) FROM Building_Heights WHERE Building_Type = 'Residential' AND Location = 'Singapore';
Identify the players with the most rebounds in a single game in the 'nba_games' table.
CREATE TABLE nba_games (game_id INT,home_team_id INT,away_team_id INT); CREATE TABLE nba_game_scores (game_id INT,team_id INT,player_name VARCHAR(255),rebounds INT);
SELECT game_id, home_team_id AS team_id, player_name, rebounds FROM nba_game_scores WHERE rebounds = (SELECT MAX(rebounds) FROM nba_game_scores) UNION ALL SELECT game_id, away_team_id, player_name, rebounds FROM nba_game_scores WHERE rebounds = (SELECT MAX(rebounds) FROM nba_game_scores);
What is the average attendance at the "theater_events" table for musicals?
CREATE TABLE theater_events (event_id INT,event_type VARCHAR(255),num_attendees INT); INSERT INTO theater_events (event_id,event_type,num_attendees) VALUES (1,'Musical',100),(2,'Play',120),(3,'Opera',150);
SELECT AVG(num_attendees) FROM theater_events WHERE event_type = 'Musical';
Find the number of unique patients who received therapy, counseling, or meditation sessions in Community Center D.
CREATE TABLE community_centers (id INT,name VARCHAR(255)); INSERT INTO community_centers (id,name) VALUES (1,'Community Center A'),(2,'Community Center B'),(3,'Community Center C'),(4,'Community Center D'); CREATE TABLE treatments (id INT,community_center_id INT,patient_id INT,type VARCHAR(255)); INSERT INTO treatments (id,community_center_id,patient_id,type) VALUES (1,1,1,'therapy'),(2,1,2,'counseling'),(3,2,3,'meditation'),(4,4,4,'therapy'),(5,4,5,'counseling'); CREATE TABLE patients (id INT,age INT); INSERT INTO patients (id,age) VALUES (1,35),(2,45),(3,50),(4,30),(5,40);
SELECT COUNT(DISTINCT patient_id) FROM treatments t WHERE t.community_center_id = 4 AND t.type IN ('therapy', 'counseling', 'meditation');
What is the name of the organization that has the maximum budget allocated for digital divide research?
CREATE TABLE organizations (id INT,name VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO organizations (id,name,budget) VALUES (1,'ABC Corp',5000000.00),(2,'XYZ Inc',8000000.00),(3,'DEF Org',9000000.00),(4,'GHI Co',6000000.00);
SELECT name FROM organizations WHERE budget = (SELECT MAX(budget) FROM organizations);
What is the total number of military personnel and intelligence agents from the US and China, grouped by their respective countries?
CREATE TABLE military_personnel (id INT,name TEXT,country TEXT,position TEXT); INSERT INTO military_personnel (id,name,country,position) VALUES (1,'John Doe','USA','Army Officer'); INSERT INTO military_personnel (id,name,country,position) VALUES (2,'Jane Smith','USA','Intelligence Agent'); INSERT INTO military_personnel (id,name,country,position) VALUES (3,'Li Yang','China','Army General'); INSERT INTO military_personnel (id,name,country,position) VALUES (4,'Zhang Wei','China','Intelligence Officer');
SELECT m.country, COUNT(*) as total FROM military_personnel m JOIN (SELECT * FROM military_personnel WHERE position LIKE '%Intelligence%') i ON m.country = i.country GROUP BY m.country;
What is the total number of broadband customers in the state of Illinois who have a download speed greater than 50 Mbps?
CREATE TABLE broadband_speeds (id INT,location VARCHAR(50),download_speed FLOAT); INSERT INTO broadband_speeds (id,location,download_speed) VALUES (1,'Illinois',60.5),(2,'Texas',45.7),(3,'Illinois',52.9);
SELECT COUNT(*) FROM broadband_speeds WHERE location = 'Illinois' AND download_speed > 50;
What is the total number of members in unions that focus on 'Aerospace'?
CREATE TABLE unions (id INT,name TEXT,domain TEXT,members INT); INSERT INTO unions (id,name,domain,members) VALUES (1,'International Association of Machinists and Aerospace Workers','Aerospace,Defense,Machinists',350000); INSERT INTO unions (id,name,domain,members) VALUES (2,'United Auto Workers','Automobiles,Aerospace',400000);
SELECT SUM(members) FROM unions WHERE domain LIKE '%Aerospace%';
What is the total revenue of organic products sold in the last quarter?
CREATE TABLE OrganicSales (product_id INT,sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO OrganicSales (product_id,sale_date,revenue) VALUES (1,'2021-01-01',50.00),(2,'2021-01-15',120.00);
SELECT SUM(revenue) FROM OrganicSales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE AND product_id IN (SELECT product_id FROM OrganicProducts);
What is the average time between orders for each customer, grouped by loyalty tier?
CREATE TABLE Orders (OrderID INT,CustomerID INT,OrderDate DATETIME); CREATE TABLE Customers (CustomerID INT,Name VARCHAR(50),LoyaltyTier VARCHAR(50),MembershipDate DATETIME);
SELECT Customers.LoyaltyTier, AVG(DATEDIFF('day', LAG(Orders.OrderDate) OVER (PARTITION BY Customers.CustomerID ORDER BY Orders.OrderDate), Orders.OrderDate)) as AverageTimeBetweenOrders FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID GROUP BY Customers.LoyaltyTier;
What are the security incidents that involved the finance department in the past week?
CREATE TABLE security_incidents (id INT,department VARCHAR(255),incident_time TIMESTAMP); INSERT INTO security_incidents (id,department,incident_time) VALUES (1,'HR','2022-02-07 15:45:00'),(2,'IT','2022-02-15 11:00:00'),(3,'Finance','2022-02-12 08:30:00');
SELECT * FROM security_incidents WHERE department = 'Finance' AND incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK);
What is the total revenue of virtual tours in Canada in the last quarter?
CREATE TABLE tour_revenue(id INT,country TEXT,booking_date DATE,revenue INT); INSERT INTO tour_revenue (id,country,booking_date,revenue) VALUES (1,'Canada','2022-01-01',2000),(2,'Canada','2022-02-01',3000),(3,'Canada','2022-03-01',4000);
SELECT SUM(revenue) FROM tour_revenue WHERE country = 'Canada' AND booking_date >= DATEADD(quarter, -1, GETDATE());
How many unique users from the USA engaged with LGBTQ+ related content in the past week?
CREATE TABLE users (id INT,country VARCHAR(50)); CREATE TABLE engagements (user_id INT,content_id INT,engagement_type VARCHAR(50),timestamp DATETIME);
SELECT COUNT(DISTINCT users.id) FROM users JOIN engagements ON users.id = engagements.user_id WHERE users.country = 'USA' AND engagements.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW() AND engagements.content_id IN (SELECT id FROM content WHERE content.topic = 'LGBTQ+');
Find the top 3 most expensive games per stadium, displaying only the stadium name, game name, and ticket price.
CREATE TABLE Stadiums (StadiumID INT,StadiumName VARCHAR(255));CREATE TABLE Games (GameID INT,StadiumID INT,GameName VARCHAR(255),TicketPrice DECIMAL(5,2));
SELECT StadiumName, GameName, TicketPrice FROM (SELECT StadiumName, GameName, TicketPrice, ROW_NUMBER() OVER (PARTITION BY StadiumName ORDER BY TicketPrice DESC) AS Rank FROM Stadiums JOIN Games ON Stadiums.StadiumID = Games.StadiumID) AS Subquery WHERE Subquery.Rank <= 3;
Count the number of articles published per day in the 'news_articles' table
CREATE TABLE news_articles (article_id INT,author_name VARCHAR(50),title VARCHAR(100),published_date DATE);
SELECT published_date, COUNT(article_id) as articles_per_day FROM news_articles GROUP BY published_date;
Find the states with moderate drought severity in the last month.
CREATE TABLE last_month_drought(state VARCHAR(20),severity INT); INSERT INTO last_month_drought(state,severity) VALUES ('California',6),('Texas',4),('Florida',3);
SELECT state FROM last_month_drought WHERE severity = 4;
What is the maximum budget for an accessible technology initiative in Latin America?
CREATE TABLE initiative (initiative_id INT,initiative_name VARCHAR(255),launch_date DATE,region VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO initiative (initiative_id,initiative_name,launch_date,region,budget) VALUES (1,'Accessible Software Development','2018-04-01','North America',500000),(2,'Adaptive Hardware Prototyping','2019-12-15','Europe',750000),(3,'Digital Inclusion Program','2020-08-03','Asia',800000),(4,'Diverse Tech Talent Network','2021-02-22','Africa',600000),(5,'Global Accessibility Campaign','2022-01-01','Latin America',900000);
SELECT MAX(budget) as max_budget FROM initiative WHERE region = 'Latin America';
List all smart contracts associated with the regulatory framework 'GDPR'.
CREATE TABLE smart_contracts (contract_id serial,contract_name varchar(20),regulatory_framework varchar(20)); INSERT INTO smart_contracts (contract_id,contract_name,regulatory_framework) VALUES (1,'ContractA','GDPR'),(2,'ContractB','HIPAA'),(3,'ContractC','GDPR');
SELECT contract_name FROM smart_contracts WHERE regulatory_framework = 'GDPR';
How many unique customers purchased sustainable clothing in the last 6 months?
CREATE TABLE Customers (id INT,name VARCHAR(50),sustainable_purchase_date DATE); INSERT INTO Customers (id,name,sustainable_purchase_date) VALUES (1,'Alice','2022-01-01'),(2,'Bob','2022-02-15'),(3,'Charlie','2022-03-05'),(4,'David','2022-04-10'),(5,'Eve','2022-05-25'),(6,'Frank','2022-06-12');
SELECT COUNT(DISTINCT id) FROM Customers WHERE sustainable_purchase_date >= DATEADD(MONTH, -6, GETDATE());
Which projects were started before 1990 and completed after 2010?
CREATE TABLE Projects (name TEXT,start_year INT,end_year INT,location TEXT);
SELECT name FROM Projects WHERE start_year < 1990 AND end_year > 2010;
What is the depth and coordinate of the Mariana Trench?
CREATE TABLE MappingData (Location VARCHAR(255),Depth INT,Coordinates VARCHAR(255)); INSERT INTO MappingData (Location,Depth,Coordinates) VALUES ('Mariana Trench',36000,'14.5851,145.7154');
SELECT Depth, Coordinates FROM MappingData WHERE Location = 'Mariana Trench';
Who are the top 3 suppliers of organic cotton?
CREATE TABLE suppliers (id INT,name TEXT,type TEXT); CREATE TABLE materials (id INT,name TEXT,supplier_id INT,organic BOOLEAN); INSERT INTO suppliers (id,name,type) VALUES (1,'Supplier 1','Type A'),(2,'Supplier 2','Type B'),(3,'Supplier 3','Type A'),(4,'Supplier 4','Type B'),(5,'Supplier 5','Type A'); INSERT INTO materials (id,name,supplier_id,organic) VALUES (1,'Material 1',1,true),(2,'Material 2',2,false),(3,'Material 3',3,true),(4,'Material 4',4,true),(5,'Material 5',5,false);
SELECT suppliers.name FROM suppliers INNER JOIN materials ON suppliers.id = materials.supplier_id WHERE materials.organic = true GROUP BY suppliers.name ORDER BY COUNT(*) DESC LIMIT 3;
What is the total investment in biosensor technology development in Japan?
CREATE TABLE investments(project VARCHAR(50),country VARCHAR(20),amount DECIMAL(10,2));INSERT INTO investments(project,country,amount) VALUES('ProjectX','Japan',2000000.00),('ProjectY','US',3000000.00),('ProjectZ','Japan',4000000.00);
SELECT SUM(amount) FROM investments WHERE country = 'Japan' AND project = 'Biosensor';
Find policy types with more than one policyholder living in 'FL'.
CREATE TABLE policyholders (id INT,name TEXT,state TEXT,policy_type TEXT,premium FLOAT); INSERT INTO policyholders (id,name,state,policy_type,premium) VALUES (1,'John Doe','FL','Auto',1200.00),(2,'Jane Smith','FL','Auto',1200.00),(3,'Jim Brown','CA','Home',2500.00);
SELECT policy_type, COUNT(DISTINCT name) as num_policyholders FROM policyholders WHERE state = 'FL' GROUP BY policy_type HAVING num_policyholders > 1;
Find the number of employees hired in each month of 2021 from the "hiring" table
CREATE TABLE hiring (id INT,employee_id INT,hire_date DATE);
SELECT EXTRACT(MONTH FROM hire_date) AS month, COUNT(*) AS num_hires FROM hiring WHERE hire_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month;
What is the total number of smart contracts deployed on each blockchain network?
CREATE TABLE if not exists smart_contracts (contract_id INT,contract_address VARCHAR(255),network VARCHAR(255)); INSERT INTO smart_contracts (contract_id,contract_address,network) VALUES (1,'0x123...','Ethereum'),(2,'0x456...','Binance Smart Chain'),(3,'0x789...','Tron'),(4,'0xabc...','Cardano'),(5,'0xdef...','Polkadot'),(6,'0xghi...','Solana');
SELECT network, COUNT(*) as contract_count FROM smart_contracts GROUP BY network;
What is the average speed of all vessels near the Port of Los Angeles in the past week?
CREATE TABLE Vessels(VesselID INT,VesselName TEXT,Speed FLOAT,Timestamp DATETIME); INSERT INTO Vessels(VesselID,VesselName,Speed,Timestamp) VALUES (1,'Vessel1',15.2,'2022-01-01 10:00:00'),(2,'Vessel2',18.5,'2022-01-01 11:00:00');
SELECT AVG(Speed) FROM Vessels WHERE Timestamp BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE AND VesselName IN (SELECT VesselName FROM Vessels WHERE Timestamp BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE AND ABS(X() - LOCATION_X) < 50 AND ABS(Y() - LOCATION_Y) < 50);
Add new VR technology records to the 'vr_technologies' table.
CREATE TABLE vr_technologies (id INT,name VARCHAR(255),release_date DATE);
INSERT INTO vr_technologies (id, name, release_date) VALUES (1, 'Oculus Rift S', '2019-04-01'), (2, 'HTC Vive Pro 2', '2021-05-01');
Delete records from 'Market' table where 'Year' is '2018' and 'GasPrice' is less than 3
CREATE TABLE Market (Year INT,GasPrice DECIMAL(5,2),OilPrice DECIMAL(5,2));
DELETE FROM Market WHERE Year = 2018 AND GasPrice < 3;
What is the total number of unique tech_used values in the legal_tech table, grouped by location?
CREATE TABLE legal_tech (record_id INT,location VARCHAR(20),tech_used VARCHAR(20),date DATE); INSERT INTO legal_tech (record_id,location,tech_used,date) VALUES (1,'NY','AI','2021-01-01'),(2,'NY','Natural_Language_Processing','2021-01-02'),(3,'CA','AI','2021-01-01'),(4,'CA','Natural_Language_Processing','2021-01-02'),(5,'CA','AI','2021-01-01'),(6,'CA','Natural_Language_Processing','2021-01-02'),(7,'CA','AI','2021-01-01'),(8,'CA','Natural_Language_Processing','2021-01-02'),(9,'CA','AI','2021-01-01'),(10,'CA','Natural_Language_Processing','2021-01-02'),(11,'IL','AI','2021-01-01'),(12,'IL','Natural_Language_Processing','2021-01-02');
SELECT location, COUNT(DISTINCT tech_used) FROM legal_tech GROUP BY location;
Insert a new regulatory record for the 'Australian Securities and Investments Commission' related to digital assets in the blockchain domain.
CREATE TABLE regulations (regulation_id INT,regulation_name VARCHAR(100),regulator VARCHAR(100),enforcement_date DATE);
INSERT INTO regulations (regulation_id, regulation_name, regulator, enforcement_date) VALUES (4, 'Regulation4', 'Australian Securities and Investments Commission', CURDATE());