instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the average number of comments on posts made by users located in India, in the last week?
CREATE TABLE users (id INT,location VARCHAR(50)); CREATE TABLE posts (id INT,user_id INT,comments INT,created_at DATETIME);
SELECT AVG(posts.comments) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.location = 'India' AND posts.created_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
Which support programs are not being utilized by students with hearing impairments?
CREATE TABLE SupportPrograms (ProgramID INT,ProgramName VARCHAR(50),ProgramType VARCHAR(50)); INSERT INTO SupportPrograms VALUES (1,'Sign Language Interpretation','Interpretation'); CREATE TABLE StudentDisabilities (StudentID INT,DisabilityType VARCHAR(50)); INSERT INTO StudentDisabilities VALUES (1,'Hearing Impairment'); CREATE TABLE StudentPrograms (StudentID INT,ProgramID INT); INSERT INTO StudentPrograms VALUES (1,1);
SELECT sp.ProgramName, sp.ProgramType FROM SupportPrograms sp LEFT JOIN StudentPrograms spj ON sp.ProgramID = spj.ProgramID LEFT JOIN StudentDisabilities sd ON spj.StudentID = sd.StudentID WHERE sd.DisabilityType IS NULL;
What is the total energy storage capacity (in MWh) for batteries and pumped hydro by year?
CREATE TABLE energy_storage (type VARCHAR(255),year INT,capacity FLOAT);
SELECT type, SUM(capacity) FROM energy_storage GROUP BY type, year;
What is the total number of cybersecurity incidents reported by European countries in 2020?
CREATE TABLE CybersecurityIncidents (id INT PRIMARY KEY,country VARCHAR(50),incident_type VARCHAR(50),incident_date DATE); INSERT INTO CybersecurityIncidents (id,country,incident_type,incident_date) VALUES (1,'Germany','Data Breach','2020-01-15'),(2,'France','Phishing Attack','2020-02-20'),(3,'UK','Malware Infection','2020-03-10');
SELECT country, COUNT(*) as total_incidents FROM CybersecurityIncidents WHERE YEAR(incident_date) = 2020 AND country IN ('Germany', 'France', 'UK') GROUP BY country;
What are the names of the artists who have held more concerts in New York than in Los Angeles?
CREATE TABLE Artists (artist_name TEXT,location TEXT,num_concerts INTEGER); INSERT INTO Artists (artist_name,location,num_concerts) VALUES ('Artist A','New York',300),('Artist B','New York',400),('Artist A','Los Angeles',500),('Artist C','New York',200),('Artist C','Los Angeles',600);
SELECT artist_name FROM Artists WHERE num_concerts > (SELECT num_concerts FROM Artists WHERE artist_name = Artists.artist_name AND location = 'Los Angeles') AND location = 'New York';
Delete the record with the lowest explainability score in the 'creative_ai' table.
CREATE TABLE creative_ai (model_name TEXT,explainability_score INTEGER); INSERT INTO creative_ai (model_name,explainability_score) VALUES ('modelA',65),('modelB',72),('modelC',68);
DELETE FROM creative_ai WHERE explainability_score = (SELECT MIN(explainability_score) FROM creative_ai);
Which warehouses have less than 200 items in stock?
CREATE TABLE Warehouse (id INT,city VARCHAR(50),country VARCHAR(50),quantity INT); INSERT INTO Warehouse (id,city,country,quantity) VALUES (1,'Mumbai','India',500),(2,'Delhi','India',200),(3,'Sydney','Australia',150),(4,'Toronto','Canada',250);
SELECT * FROM Warehouse WHERE quantity < 200;
What is the total amount donated by each donor, ordered by the total donation amount in descending order?
CREATE TABLE donors (id INT,name VARCHAR(50),total_donation FLOAT); INSERT INTO donors (id,name,total_donation) VALUES (1,'John Doe',500.00),(2,'Jane Smith',350.00),(3,'Mike Johnson',200.00);
SELECT name, total_donation FROM donors ORDER BY total_donation DESC;
Show the total construction hours worked in 'Rio de Janeiro' for the month of 'March' in 2019 and 2021.
CREATE TABLE construction_hours_br (worker_id INT,city VARCHAR(20),hours_worked INT,work_date DATE); INSERT INTO construction_hours_br (worker_id,city,hours_worked,work_date) VALUES (1,'Rio de Janeiro',12,'2019-03-01'); INSERT INTO construction_hours_br (worker_id,city,hours_worked,work_date) VALUES (2,'Rio de Janeiro',15,'2021-03-03');
SELECT SUM(hours_worked) FROM construction_hours_br WHERE city = 'Rio de Janeiro' AND EXTRACT(MONTH FROM work_date) = 3 AND (EXTRACT(YEAR FROM work_date) = 2019 OR EXTRACT(YEAR FROM work_date) = 2021);
Display the total number of employees by gender at each mining site.
CREATE TABLE mining_sites(id INT,name VARCHAR,location VARCHAR); CREATE TABLE employees(site_id INT,gender VARCHAR,role VARCHAR); INSERT INTO mining_sites(id,name,location) VALUES (1,'Acme Mining','Northern MN'),(2,'Beta Mining','Southern MN'); INSERT INTO employees(site_id,gender,role) VALUES (1,'Male','Engineer'),(1,'Female','Operator'),(2,'Male','Manager');
SELECT mining_sites.name, gender, COUNT(*) FROM mining_sites INNER JOIN employees ON mining_sites.id = employees.site_id GROUP BY mining_sites.name, gender;
Provide the number of wildlife species in the 'Asian' region.
CREATE TABLE wildlife_species (region VARCHAR(255),species INT); INSERT INTO wildlife_species (region,species) VALUES ('Asian',500),('African',400),('European',300),('Australian',600);
SELECT region, SUM(species) FROM wildlife_species WHERE region = 'Asian';
Total sales of all drugs approved in 2018
CREATE TABLE drug_approval (approval_id INT,drug_name TEXT,approval_date DATE); INSERT INTO drug_approval (approval_id,drug_name,approval_date) VALUES (1,'DrugI','2018-01-01'),(2,'DrugJ','2017-01-01'); CREATE TABLE sales (sale_id INT,drug_name TEXT,sales_figure DECIMAL); INSERT INTO sales (sale_id,drug_name,sales_figure) VALUES (1,'DrugI',4000000),(2,'DrugJ',3500000);
SELECT SUM(sales_figure) FROM sales INNER JOIN drug_approval ON sales.drug_name = drug_approval.drug_name WHERE YEAR(approval_date) = 2018;
Show the total number of creative AI applications in each country in the database, ordered alphabetically.
CREATE TABLE creative_ai (application_id INT,application_name VARCHAR(255),country VARCHAR(255),application_type VARCHAR(255)); INSERT INTO creative_ai (application_id,application_name,country,application_type) VALUES (1,'Art Generation','USA','Image'),(2,'Music Composition','Canada','Audio'),(3,'Storytelling','Mexico','Text'),(4,'Movie Recommendation','Japan','Video');
SELECT country, COUNT(*) as total_applications FROM creative_ai GROUP BY country ORDER BY country;
Identify suppliers with the most significant price fluctuations and their average price changes.
CREATE TABLE suppliers (supplier_id INT,supplier_name VARCHAR(255),product_price INT); CREATE VIEW supplier_price_changes AS SELECT supplier_id,product_price,LAG(product_price,30) OVER (PARTITION BY supplier_id ORDER BY order_date) as prev_price FROM orders;
SELECT s.supplier_name, AVG(ABS(spc.product_price - spc.prev_price)) as avg_price_change FROM suppliers s INNER JOIN supplier_price_changes spc ON s.supplier_id = spc.supplier_id GROUP BY s.supplier_name ORDER BY avg_price_change DESC LIMIT 10;
How many public awareness campaigns were launched in Asia in the last 5 years?
CREATE TABLE campaigns (campaign_id INT,campaign_name TEXT,launch_date DATE,region TEXT); INSERT INTO campaigns (campaign_id,campaign_name,launch_date,region) VALUES (1,'Mental Health Awareness','2018-01-01','Asia'); INSERT INTO campaigns (campaign_id,campaign_name,launch_date,region) VALUES (2,'End Stigma','2019-05-15','Europe');
SELECT COUNT(*) FROM campaigns WHERE region = 'Asia' AND launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
How many intelligence operations were carried out by the CIA in South America between 2000 and 2010?
CREATE TABLE intelligence_ops (id INT PRIMARY KEY,mission VARCHAR(50),agency VARCHAR(50),location VARCHAR(50),year INT); INSERT INTO intelligence_ops (id,mission,agency,location,year) VALUES (5,'Operation Active Endeavour','CIA','South America',2005); INSERT INTO intelligence_ops (id,mission,agency,location,year) VALUES (6,'Operation Urgent Fury','CIA','Caribbean',2010);
SELECT COUNT(*) as total_missions FROM intelligence_ops WHERE agency = 'CIA' AND location = 'South America' AND year BETWEEN 2000 AND 2010;
Who is the attorney with the highest billing amount?
CREATE TABLE Attorneys (AttorneyID INT,Name VARCHAR(50)); INSERT INTO Attorneys (AttorneyID,Name) VALUES (1,'Jane Smith'),(2,'Bob Johnson'),(3,'Mike Williams'); CREATE TABLE Billing (BillingID INT,AttorneyID INT,Amount DECIMAL(10,2)); INSERT INTO Billing (BillingID,AttorneyID,Amount) VALUES (1,1,500.00),(2,2,800.00),(3,3,1000.00),(4,1,1200.00);
SELECT Attorneys.Name, MAX(Billing.Amount) FROM Attorneys INNER JOIN Billing ON Attorneys.AttorneyID = Billing.AttorneyID GROUP BY Attorneys.Name;
Update the status column to 'actively preserving' in the community_program table where language is 'Tlingit' and the end_year is NULL.
community_program (id,program_name,location,start_year,end_year,language,status)
UPDATE community_program SET status = 'actively preserving' WHERE language = 'Tlingit' AND end_year IS NULL;
How many farmers are there in each region?
CREATE TABLE farmer (id INT PRIMARY KEY,name VARCHAR(50),region_id INT); CREATE TABLE region (id INT PRIMARY KEY,name VARCHAR(50)); INSERT INTO region (id,name) VALUES (1,'Delta Region'),(2,'Great Plains'); INSERT INTO farmer (id,name,region_id) VALUES (1,'John Doe',1),(2,'Jane Doe',1),(3,'Bob Smith',2);
SELECT r.name, COUNT(f.id) FROM farmer f INNER JOIN region r ON f.region_id = r.id GROUP BY r.name;
What is the total number of community events in Chicago this year?
CREATE TABLE CommunityEvents (id INT,city VARCHAR(50),event_date DATE,event_type VARCHAR(50));
SELECT COUNT(*) FROM CommunityEvents WHERE city = 'Chicago' AND event_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND event_type = 'community';
Add new cultural heritage sites with their respective visitor counts and updated timestamps.
CREATE TABLE cultural_heritage_sites (site_id INT,site_name TEXT,yearly_visitor_count INT,updated_at DATETIME); INSERT INTO cultural_heritage_sites (site_id,site_name,yearly_visitor_count,updated_at) VALUES (4,'Taj Mahal',2500000,NOW()),(5,'Forbidden City',1800000,NOW()),(6,'Istanbul Hagia Sophia',3000000,NOW());
INSERT INTO cultural_heritage_sites (site_id, site_name, yearly_visitor_count, updated_at) VALUES (7, 'Auschwitz-Birkenau Memorial', 2000000, NOW()), (8, 'Pyramids of Giza', 1200000, NOW());
What is the average depth of all marine protected areas in the Atlantic Ocean?
CREATE TABLE marine_protected_areas (area_name TEXT,ocean TEXT,depth FLOAT); INSERT INTO marine_protected_areas (area_name,ocean,depth) VALUES ('Galapagos Islands','Pacific Ocean',2000.0),('Great Barrier Reef','Pacific Ocean',1000.0),('Bermuda Park','Atlantic Ocean',5000.0);
SELECT AVG(depth) FROM marine_protected_areas WHERE ocean = 'Atlantic Ocean';
How many esports events have been held in Asia and how many players have participated in those events?
CREATE TABLE EsportsEvents (EventID INT,EventName VARCHAR(20),Location VARCHAR(10)); INSERT INTO EsportsEvents VALUES (1,'EventA','Asia'),(2,'EventB','Europe'),(3,'EventC','Americas'); CREATE TABLE EventParticipation (PlayerID INT,EventID INT); INSERT INTO EventParticipation VALUES (1,1),(2,1),(3,1),(4,2),(5,3);
SELECT COUNT(EsportsEvents.EventID) AS AsianEventCount, COUNT(DISTINCT EventParticipation.PlayerID) AS PlayersInAsia FROM EsportsEvents INNER JOIN EventParticipation ON EsportsEvents.EventID = EventParticipation.EventID WHERE EsportsEvents.Location = 'Asia';
What is the total revenue for the last month?
CREATE TABLE Sales (sale_date DATE,revenue INT); INSERT INTO Sales (sale_date,revenue) VALUES ('2022-01-01',5000),('2022-01-02',6000),('2022-01-03',7000),('2022-01-04',8000),('2022-01-05',9000),('2022-01-06',10000),('2022-01-07',11000),('2022-02-01',5500),('2022-02-02',6500),('2022-02-03',7500),('2022-02-04',8500),('2022-02-05',9500),('2022-02-06',10500),('2022-02-07',11500);
SELECT SUM(revenue) AS total_revenue FROM Sales WHERE sale_date BETWEEN DATEADD(month, -1, CURRENT_DATE) AND CURRENT_DATE;
What is the average energy efficiency (in kWh/m2) of buildings in 'Tokyo' that were constructed before 2000?
CREATE TABLE buildings (id INT,city TEXT,year INT,efficiency FLOAT); INSERT INTO buildings (id,city,year,efficiency) VALUES (1,'Building A',1995,50.7),(2,'Building B',2005,70.2);
SELECT AVG(efficiency) FROM buildings WHERE city = 'Tokyo' AND year < 2000;
Get all products that use 'Recycled Material' from 'material' table
CREATE TABLE material (material_id VARCHAR(10),name VARCHAR(50),description TEXT,primary key (material_id));
SELECT * FROM product p JOIN product_material pm ON p.product_id = pm.product_id JOIN material m ON pm.material_id = m.material_id WHERE m.name = 'Recycled Material';
What is the total fare collected for the 'Blue Line' in the month of March?
CREATE TABLE fare_by_month_and_line (month_year DATE,line_name VARCHAR(50),fare_amount DECIMAL(10,2)); INSERT INTO fare_by_month_and_line (month_year,line_name,fare_amount) VALUES ('2022-03-01','Blue Line',600.00),('2022-03-01','Green Line',700.00);
SELECT SUM(fare_amount) FROM fare_by_month_and_line WHERE line_name = 'Blue Line' AND month_year = '2022-03-01';
How many publications were made by graduate students in the Mathematics department in 2020?
CREATE TABLE students (student_id INT,name VARCHAR(50),department VARCHAR(50),graduate_status VARCHAR(10)); INSERT INTO students VALUES (1,'Alice Johnson','Mathematics','Graduate'); INSERT INTO students VALUES (2,'Bob Brown','Mathematics','Undergraduate'); INSERT INTO students VALUES (3,'Charlie Davis','Physics','Graduate'); CREATE TABLE publications (publication_id INT,student_id INT,year INT,title VARCHAR(100)); INSERT INTO publications VALUES (1,1,2019,'Theory of Numbers'); INSERT INTO publications VALUES (2,1,2020,'Calculus for Beginners'); INSERT INTO publications VALUES (3,3,2019,'Quantum Mechanics');
SELECT COUNT(*) FROM publications p INNER JOIN students s ON p.student_id = s.student_id WHERE s.department = 'Mathematics' AND s.graduate_status = 'Graduate' AND p.year = 2020;
Identify the number of customers who made transactions in both Q1 and Q2 of 2022?
CREATE TABLE customers (customer_id INT,country_code CHAR(2)); CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_date DATE);
SELECT COUNT(DISTINCT customer_id) FROM transactions WHERE EXTRACT(QUARTER FROM transaction_date) IN (1, 2) GROUP BY customer_id HAVING COUNT(DISTINCT EXTRACT(QUARTER FROM transaction_date)) = 2;
Create a view named 'top_sustainable_suppliers' with the top 3 suppliers ordered by sustainability_score
CREATE VIEW top_sustainable_suppliers AS SELECT * FROM suppliers ORDER BY sustainability_score DESC LIMIT 3;
CREATE VIEW top_sustainable_suppliers AS SELECT * FROM suppliers ORDER BY sustainability_score DESC LIMIT 3;
Rank autonomous vehicles in the 'autoshow' table by top speed in descending order, assigning row numbers.
CREATE TABLE autoshow (vehicle_type VARCHAR(10),top_speed INT);
SELECT vehicle_type, top_speed, ROW_NUMBER() OVER (PARTITION BY vehicle_type ORDER BY top_speed DESC) as row_num FROM autoshow WHERE vehicle_type LIKE '%Autonomous%';
Determine the total amount of funding allocated for primary education in California for the fiscal year 2022 and the amount spent on textbooks.
CREATE TABLE education_funding (fiscal_year INT,state VARCHAR(255),category VARCHAR(255),allocation FLOAT,expenditure FLOAT); INSERT INTO education_funding (fiscal_year,state,category,allocation,expenditure) VALUES (2022,'California','primary education',1000000.0,400000.0),(2022,'California','textbooks',150000.0,50000.0);
SELECT SUM(allocation) AS total_allocation, SUM(expenditure) AS total_expenditure FROM education_funding WHERE fiscal_year = 2022 AND state = 'California' AND (category = 'primary education' OR category = 'textbooks');
What is the distribution of fairness scores for AI algorithms in the algorithmic fairness dataset?
CREATE TABLE algorithmic_fairness (id INT,algorithm VARCHAR,fairness FLOAT);
SELECT algorithm, PERCENT_RANK() OVER (ORDER BY fairness) FROM algorithmic_fairness;
What is the success rate for cases in the "litigation" department?
CREATE TABLE Cases (id INT,case_number INT,case_type VARCHAR(50),department VARCHAR(50),opened_date DATE,closed_date DATE,case_outcome VARCHAR(50));
SELECT department, COUNT(CASE WHEN case_outcome = 'successful' THEN 1 END) / COUNT(*) AS SuccessRate FROM Cases WHERE department = 'litigation' GROUP BY department;
How many Container Ships are in the 'vessels' table?
CREATE TABLE vessels (vessel_id INT,name VARCHAR(50),type VARCHAR(50)); INSERT INTO vessels (vessel_id,name,type) VALUES (1,'MV Ocean Wave','Container Ship'),(2,'MS Ocean Breeze','Tanker'),(3,'MV Ocean Tide','Tanker'),(4,'MV Ocean Current','Container Ship');
SELECT COUNT(*) FROM vessels WHERE type = 'Container Ship';
What is the average age of patients who have been diagnosed with a mental health condition in the North American region?
CREATE TABLE patients (id INT,condition_id INT,age INT,region VARCHAR(50)); INSERT INTO patients (id,condition_id,age,region) VALUES (1,1,35,'North America'),(2,1,40,'North America'),(3,2,25,'North America');
SELECT AVG(age) FROM patients WHERE region = 'North America' AND condition_id IS NOT NULL;
Delete records with a membership older than 5 years in the members table
CREATE TABLE members (id INT,name VARCHAR(50),membership_start_date DATE);
DELETE FROM members WHERE membership_start_date <= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
What is the average diversity score for startups in the technology industry?
CREATE TABLE company (name VARCHAR(255),industry VARCHAR(100),diversity_score INT); INSERT INTO company (name,industry,diversity_score) VALUES ('CompanyA','Technology',80),('CompanyB','Finance',90),('CompanyC','Technology',85),('CompanyD','Retail',70);
SELECT AVG(company.diversity_score) as avg_diversity_score FROM company WHERE company.industry = 'Technology';
What is the total number of recycling facilities in Africa?
CREATE TABLE RecyclingFacilities (country VARCHAR(255),num_facilities INT); INSERT INTO RecyclingFacilities (country,num_facilities) VALUES ('Egypt',123),('South Africa',251),('Nigeria',189),('Ethiopia',104),('Algeria',142);
SELECT SUM(num_facilities) FROM RecyclingFacilities WHERE country IN ('Egypt', 'South Africa', 'Nigeria', 'Ethiopia', 'Algeria')
What is the maximum weight of packages shipped from the United States to Canada?
CREATE TABLE packages (id INT,weight FLOAT,origin VARCHAR(50),destination VARCHAR(50)); INSERT INTO packages (id,weight,origin,destination) VALUES (1,15.3,'United States','Canada'),(2,22.1,'Mexico','Canada');
SELECT MAX(weight) FROM packages WHERE origin = 'United States' AND destination = 'Canada';
Drop 'smart_grid_view'
CREATE TABLE smart_grid (id INT PRIMARY KEY,city VARCHAR(50),power_sources VARCHAR(50),renewable_energy_percentage INT); CREATE VIEW smart_grid_view AS SELECT * FROM smart_grid;
DROP VIEW smart_grid_view;
Which gender has the highest number of patients with a specific mental health condition?
CREATE TABLE Patients (PatientID INT,Age INT,Gender VARCHAR(10),ConditionID INT); CREATE TABLE MentalHealthConditions (ConditionID INT,Condition VARCHAR(50));
SELECT MentalHealthConditions.Condition, Patients.Gender, COUNT(Patients.PatientID) FROM Patients INNER JOIN MentalHealthConditions ON Patients.ConditionID = MentalHealthConditions.ConditionID GROUP BY MentalHealthConditions.Condition, Patients.Gender;
Update the last_activity date for a volunteer with id '123' to 2022-02-01.
CREATE TABLE volunteers (id INT,name TEXT,last_activity DATE);
UPDATE volunteers SET last_activity = '2022-02-01' WHERE volunteers.id = '123';
How many volunteers are there in each region?
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Region TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName,Region) VALUES (1,'Alex Brown','North'),(2,'Bella Johnson','South'),(3,'Charlie Davis','East'),(4,'David White','West'),(5,'Eva Green','North');
SELECT Region, COUNT(*) as TotalVolunteers FROM Volunteers GROUP BY Region;
What is the total number of fish in freshwater aquaculture facilities in the South Pacific region with a stocking density of more than 4000?
CREATE TABLE freshwater_aquaculture (id INT,name TEXT,region TEXT,fish_count INT,stocking_density INT); INSERT INTO freshwater_aquaculture (id,name,region,fish_count,stocking_density) VALUES (1,'Facility X','South Pacific',20000,3500),(2,'Facility Y','South Pacific',25000,5000),(3,'Facility Z','Indian Ocean',18000,6000);
SELECT SUM(fish_count) FROM freshwater_aquaculture WHERE region = 'South Pacific' AND stocking_density > 4000;
How many transactions were processed by each node in the 'nodes' table?
CREATE TABLE nodes (node_id INT,node_name TEXT,total_transactions INT); INSERT INTO nodes (node_id,node_name,total_transactions) VALUES (1,'NodeA',200),(2,'NodeB',350),(3,'NodeC',400),(4,'NodeD',550);
SELECT node_name, SUM(total_transactions) FROM nodes GROUP BY node_name;
Find the number of IoT devices connected to each field in the past month, grouped by week.
CREATE TABLE field_iot_devices (field_id INTEGER,device_id INTEGER,connected_at TIMESTAMP);
SELECT DATE_TRUNC('week', connected_at) as week, field_id, COUNT(DISTINCT device_id) as devices_count FROM field_iot_devices WHERE connected_at >= NOW() - INTERVAL '1 month' GROUP BY week, field_id ORDER BY week, field_id;
Identify the top 2 countries with the highest number of marine protected areas in the Caribbean.
CREATE TABLE marine_protected_areas (country VARCHAR(255),region VARCHAR(255),number_of_sites INT); INSERT INTO marine_protected_areas (country,region,number_of_sites) VALUES ('Bahamas','Caribbean',43),('Cuba','Caribbean',34),('Jamaica','Caribbean',25),('Haiti','Caribbean',12),('Dominican Republic','Caribbean',30);
SELECT country, number_of_sites, ROW_NUMBER() OVER (ORDER BY number_of_sites DESC) as rn FROM marine_protected_areas WHERE region = 'Caribbean' LIMIT 2;
How many mental health parity violation incidents occurred in each region over time, ranked by the number of incidents?
CREATE TABLE mental_health_parity (incident_id INT,incident_date DATE,region TEXT,violation_details TEXT); INSERT INTO mental_health_parity (incident_id,incident_date,region,violation_details) VALUES (1,'2022-01-01','Northeast','Inadequate coverage for mental health services'),(2,'2022-02-01','Southeast','Discrimination against patients with mental health conditions'),(3,'2022-03-01','Northeast','Lack of coverage for mental health and substance abuse services'),(4,'2022-04-01','Midwest','Discrimination against patients with mental health conditions'),(5,'2022-05-01','West','Lack of coverage for mental health services');
SELECT region, COUNT(*) as num_incidents FROM mental_health_parity GROUP BY region ORDER BY num_incidents DESC;
How many members joined in the first six months of 2022, by age group?
CREATE TABLE memberships (membership_id INT,join_date DATE,age INT); INSERT INTO memberships (membership_id,join_date,age) VALUES (1,'2022-01-15',25),(2,'2022-04-20',32),(3,'2022-06-05',28);
SELECT COUNT(*) as first_half_count, FLOOR(age / 10) * 10 as age_group FROM memberships WHERE join_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY age_group;
What is the average amount donated per donor in the past year?
CREATE TABLE Donors (DonorID INT,Name TEXT,TotalDonation DECIMAL(10,2));
SELECT AVG(TotalDonation) FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE());
How many local vendors participated in the sustainable tourism conference in Sydney?
CREATE TABLE vendors (vendor_id INT,vendor_name TEXT,conference TEXT); INSERT INTO vendors (vendor_id,vendor_name,conference) VALUES (1,'Green Solutions','Sydney Sustainable Tourism Conference'),(2,'Eco Travel','Sydney Sustainable Tourism Conference'),(3,'Sustainable Foods','Sydney Sustainable Tourism Conference');
SELECT COUNT(*) FROM vendors WHERE conference = 'Sydney Sustainable Tourism Conference';
Find the total number of spacecraft manufactured by companies from 2015 to 2017
CREATE TABLE Spacecraft_Manufacturing(manufacturer VARCHAR(20),year INT,quantity INT); INSERT INTO Spacecraft_Manufacturing(manufacturer,year,quantity) VALUES ('SpaceCorp',2015,120),('SpaceCorp',2016,150),('SpaceCorp',2017,175),('Galactic Inc',2015,110),('Galactic Inc',2016,145),('Galactic Inc',2017,180),('AstroTech',2015,105),('AstroTech',2016,120),('AstroTech',2017,135);
SELECT SUM(quantity) FROM Spacecraft_Manufacturing WHERE year BETWEEN 2015 AND 2017;
What are the names of all AI researchers who have published at least two research papers?
CREATE TABLE Researchers (id INT,name VARCHAR(255),paper_count INT);
SELECT name FROM Researchers WHERE paper_count >= 2;
What is the average assets value for customers in the United Kingdom?
CREATE TABLE customers (id INT,name VARCHAR(255),country VARCHAR(255),assets DECIMAL(10,2)); INSERT INTO customers (id,name,country,assets) VALUES (1,'John Doe','USA',150000.00),(2,'Jane Smith','Canada',200000.00),(3,'Alice Johnson','UK',250000.00),(4,'Bob Brown','UK',300000.00);
SELECT AVG(assets) FROM customers WHERE country = 'UK';
How many total funding sources supported the Dance Program in 2023?
CREATE TABLE Funding (id INT PRIMARY KEY,program VARCHAR(20),source VARCHAR(20),year INT); INSERT INTO Funding (id,program,source,year) VALUES (1,'Dance Program','Government Grant',2023); INSERT INTO Funding (id,program,source,year) VALUES (2,'Music Program','Private Donation',2022);
SELECT COUNT(DISTINCT source) FROM Funding WHERE program = 'Dance Program' AND year = 2023;
What is the total distance covered by athletes in the athletics_results table?
CREATE TABLE athletics_results (result_id INT,athlete_name VARCHAR(100),distance FLOAT);
SELECT SUM(distance) FROM athletics_results;
List the top 5 most popular cultural attractions by total visitor count
CREATE TABLE cultural_attractions (attraction_id INT,attraction_name VARCHAR(255),country VARCHAR(255),city VARCHAR(255),visitor_count INT);
SELECT attraction_name, SUM(visitor_count) AS total_visitors FROM cultural_attractions GROUP BY attraction_name ORDER BY total_visitors DESC LIMIT 5;
Show all records from the Artifacts table
CREATE TABLE Artifacts (id INT PRIMARY KEY,name VARCHAR(255),description TEXT,date_found DATE); INSERT INTO Artifacts (id,name,description,date_found) VALUES (1,'Pottery Shard','Fragment of a ceramic pot','2020-08-23'),(2,'Bronze Coin','Ancient coin made of bronze','2019-05-15');
SELECT * FROM Artifacts;
What is the engagement rate of virtual tours in Japan in the last month?
CREATE TABLE virtual_tours (tour_id INT,country TEXT,date DATE,unique_views INT,total_views INT); INSERT INTO virtual_tours (tour_id,country,date,unique_views,total_views) VALUES (1,'Japan','2023-01-01',50,100),(2,'Japan','2023-01-02',60,120),(3,'Japan','2023-01-03',70,140),(4,'USA','2023-01-01',80,200);
SELECT (SUM(unique_views) / SUM(total_views)) * 100 AS engagement_rate FROM virtual_tours WHERE country = 'Japan' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
What is the average labor cost for factories in Southeast Asia?
CREATE TABLE factories (factory_id INT,location VARCHAR(50),labor_cost DECIMAL(10,2)); INSERT INTO factories (factory_id,location,labor_cost) VALUES (1,'Bangkok',500),(2,'Ho Chi Minh City',450),(3,'Manila',520);
SELECT AVG(factories.labor_cost) FROM factories WHERE factories.location LIKE '%Southeast Asia%';
Update the Gender of the community health worker with Age 50 in 'QC' province to 'Non-binary'.
CREATE TABLE CommunityHealthWorkersCanada (WorkerID INT,Age INT,Gender VARCHAR(10),Province VARCHAR(2)); INSERT INTO CommunityHealthWorkersCanada (WorkerID,Age,Gender,Province) VALUES (1,35,'F','ON'),(2,40,'M','QC'),(3,45,'F','BC'),(4,50,'M','AB'),(5,55,'F','ON');
UPDATE CommunityHealthWorkersCanada SET Gender = 'Non-binary' WHERE Age = 50 AND Province = 'QC';
What is the maximum temperature recorded in California in the past month?
CREATE TABLE Weather (location VARCHAR(50),temperature INT,timestamp TIMESTAMP);
SELECT MAX(temperature) FROM Weather WHERE location = 'California' AND timestamp > NOW() - INTERVAL '1 month';
What is the maximum number of visitors at a single exhibition in Paris?
CREATE TABLE Exhibitions (exhibition_id INT,location VARCHAR(20),date DATE); INSERT INTO Exhibitions (exhibition_id,location,date) VALUES (1,'Paris','2022-06-01'),(2,'Paris','2022-06-15'),(3,'Paris','2022-07-01'); CREATE TABLE Visitors (visitor_id INT,exhibition_id INT,date DATE); INSERT INTO Visitors (visitor_id,exhibition_id,date) VALUES (1,1,'2022-06-01'),(2,1,'2022-06-01'),(3,2,'2022-06-15'),(4,3,'2022-07-01'),(5,3,'2022-07-01');
SELECT MAX(visitor_count) FROM (SELECT exhibition_id, COUNT(DISTINCT visitor_id) AS visitor_count FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.location = 'Paris' GROUP BY exhibition_id) t;
What is the total production quantity for each chemical in site 'G'?
CREATE TABLE chemical_production_4 (site VARCHAR(10),chemical VARCHAR(10),quantity INT); INSERT INTO chemical_production_4 VALUES ('F','A',500),('F','B',600),('F','C',700),('G','D',800),('G','E',900);
SELECT chemical, SUM(quantity) FROM chemical_production_4 WHERE site = 'G' GROUP BY chemical;
How many safety protocol violations were recorded in the past month for each facility?
CREATE TABLE facility (id INT,name VARCHAR(255)); CREATE TABLE safety_record (id INT,facility_id INT,record_date DATE,violation_count INT); INSERT INTO facility (id,name) VALUES (1,'Facility A'),(2,'Facility B'); INSERT INTO safety_record (id,facility_id,record_date,violation_count) VALUES (1,1,'2022-01-01',3),(2,1,'2022-01-02',2),(3,2,'2022-01-01',1),(4,2,'2022-01-02',4);
SELECT f.name, SUM(sr.violation_count) FROM facility f INNER JOIN safety_record sr ON f.id = sr.facility_id WHERE sr.record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY f.name;
What is the number of clean energy policies in the 'oceania' region, ranked in descending order?
CREATE TABLE clean_energy_policies_oceania (id INT,policy VARCHAR(50),region VARCHAR(50)); INSERT INTO clean_energy_policies_oceania (id,policy,region) VALUES (1,'Renewable Energy Target','oceania'),(2,'Carbon Price','oceania'),(3,'Feed-in Tariff','oceania');
SELECT region, COUNT(policy) as total_policies FROM clean_energy_policies_oceania WHERE region = 'oceania' GROUP BY region ORDER BY total_policies DESC;
What is the total revenue from music festivals in Europe in 2021?
CREATE TABLE FestivalRevenue (region VARCHAR(255),year INT,revenue FLOAT);
SELECT SUM(revenue) FROM FestivalRevenue WHERE region = 'Europe' AND year = 2021;
What is the average speed in knots for the vessel 'CoastalCruiser'?
CREATE TABLE Vessels(Id INT,Name VARCHAR(255),AverageSpeed DECIMAL(5,2)); INSERT INTO Vessels VALUES (1,'VesselA',15.5),(2,'CoastalCruiser',18.3),(3,'VesselC',20.2);
SELECT AVG(v.AverageSpeed) FROM Vessels v WHERE v.Name = 'CoastalCruiser';
List all countries with their respective AI safety initiatives count.
CREATE TABLE ai_safety_initiatives (country TEXT,initiative_name TEXT); CREATE TABLE countries (country TEXT,continent TEXT);
SELECT c.country, COUNT(ai_safety_initiatives.country) FROM countries c LEFT JOIN ai_safety_initiatives ON c.country = ai_safety_initiatives.country GROUP BY c.country;
What are the names of all AI safety research papers that were published in the year 2020?
CREATE TABLE SafetyPapers (id INT,title VARCHAR(255),year INT);
SELECT title FROM SafetyPapers WHERE year = 2020;
What is the minimum number of streams for any artist from India?
CREATE TABLE Streaming (id INT,artist VARCHAR(50),streams INT,country VARCHAR(50)); INSERT INTO Streaming (id,artist,streams,country) VALUES (1,'Arijit Singh',1500000,'India'),(2,'Shreya Ghoshal',1200000,'India'),(3,'Badshah',1000000,'India');
SELECT MIN(streams) FROM Streaming WHERE country = 'India';
What is the average number of injuries in Airbus aircraft accidents since 2010?
CREATE TABLE accidents (accident_id INT,aircraft_model VARCHAR(50),num_injuries INT,accident_year INT); INSERT INTO accidents (accident_id,aircraft_model,num_injuries,accident_year) VALUES (1,'Airbus A320',20,2010),(2,'Airbus A330',30,2011),(3,'Airbus A340',10,2012),(4,'Airbus A350',5,2013),(5,'Airbus A320',15,2014);
SELECT AVG(num_injuries) FROM accidents WHERE aircraft_model LIKE 'Airbus%' AND accident_year >= 2010;
Find the average financial wellbeing score for Shariah-compliant loans in Florida?
CREATE TABLE loans (id INT,employee_id INT,amount INT,is_shariah_compliant BOOLEAN,financial_wellbeing_score INT); INSERT INTO loans (id,employee_id,amount,is_shariah_compliant,financial_wellbeing_score) VALUES (1,2,25000,TRUE,7),(2,2,40000,TRUE,9),(3,3,50000,FALSE,8);
SELECT AVG(loans.financial_wellbeing_score) FROM loans WHERE loans.is_shariah_compliant = TRUE AND loans.id IN (SELECT loan_id FROM customers WHERE customers.city = 'Florida');
List all unique countries involved in "Finance" projects that don't have any "Communication" projects in the same countries.
CREATE TABLE Finance (country VARCHAR(255)); INSERT INTO Finance VALUES ('Country1'),('Country2'),('Country3'); CREATE TABLE Communication (country VARCHAR(255)); INSERT INTO Communication VALUES ('Country1'),('Country3'),('Country4');
SELECT Finance.country FROM Finance WHERE Finance.country NOT IN (SELECT Communication.country FROM Communication)
How many menu items contain both meat and dairy products?
CREATE TABLE Menu (item_id INT,name VARCHAR(50),has_meat BOOLEAN,has_dairy BOOLEAN); INSERT INTO Menu (item_id,name,has_meat,has_dairy) VALUES (1,'Cheese Pizza',true,true),(2,'Garden Salad',false,false),(3,'Vegan Pizza',false,false);
SELECT COUNT(*) FROM Menu WHERE has_meat = true AND has_dairy = true;
What is the maximum safe pressure for each chemical stored at a specific facility?
CREATE TABLE Chemicals (id INT,name VARCHAR(255),max_safe_pressure FLOAT); CREATE TABLE Storage (id INT,chemical_id INT,facility_id INT,storage_date DATE);
SELECT Chemicals.name, Chemicals.max_safe_pressure FROM Chemicals INNER JOIN Storage ON Chemicals.id = Storage.chemical_id WHERE Storage.facility_id = 1;
What is the average lead time for each country of garment suppliers?
CREATE TABLE garment_suppliers(supplier_id INT,country VARCHAR(255),lead_time FLOAT); INSERT INTO garment_suppliers(supplier_id,country,lead_time) VALUES (1,'Bangladesh',60.5),(2,'China',45.3),(3,'Vietnam',52.7);
SELECT country, AVG(lead_time) FROM garment_suppliers GROUP BY country;
How many mental health parity violations were reported by race?
CREATE TABLE MentalHealthParityRace (ViolationID INT,Race VARCHAR(255),ViolationDate DATE); INSERT INTO MentalHealthParityRace (ViolationID,Race,ViolationDate) VALUES (1,'Hispanic','2022-01-01'),(2,'African American','2022-02-01'),(3,'Hispanic','2022-03-01');
SELECT Race, COUNT(*) as ViolationCount FROM MentalHealthParityRace GROUP BY Race;
What is the average ESG score for organizations in the technology sector?
CREATE TABLE organizations (id INT,name VARCHAR(100),sector VARCHAR(50),ESG_score FLOAT); INSERT INTO organizations (id,name,sector,ESG_score) VALUES (1,'Tesla','Technology',85.0),(2,'Microsoft','Technology',82.5),(3,'IBM','Technology',80.0);
SELECT AVG(ESG_score) FROM organizations WHERE sector = 'Technology';
List the names and launch dates of satellites from Japan
CREATE TABLE satellites (id INT,name TEXT,country TEXT,launch_date DATE); INSERT INTO satellites (id,name,country,launch_date) VALUES (1,'Himawari-8','Japan','2014-10-07'); INSERT INTO satellites (id,name,country,launch_date) VALUES (2,'GCOM-W1','Japan','2012-05-18');
SELECT name, launch_date FROM satellites WHERE country = 'Japan';
What's the minimum property price in affordable housing areas?
CREATE TABLE affordable_housing (community_id INT,property_id INT,price DECIMAL(10,2)); INSERT INTO affordable_housing (community_id,property_id,price) VALUES (1,111,200000.00),(1,112,215000.00),(2,221,185000.00);
SELECT MIN(price) FROM affordable_housing;
List all distinct satellite imagery analysis types performed in the USA and Australia.
CREATE TABLE Satellite_Imagery_Analysis (id INT,analysis_type VARCHAR(50),Farm_id INT); INSERT INTO Satellite_Imagery_Analysis (id,analysis_type,Farm_id) VALUES (1,'NDVI',1),(2,'EVI',2),(3,'SAVI',3);
SELECT DISTINCT analysis_type FROM Satellite_Imagery_Analysis WHERE Farm_id IN (SELECT id FROM Farmers WHERE country IN ('USA', 'Australia'));
List the top 3 cities with the most electric vehicle adoption in the 'ev_adoption_stats' table.
CREATE TABLE ev_adoption_stats (id INT,city VARCHAR,state VARCHAR,num_evs INT);
SELECT city, state, num_evs, RANK() OVER (PARTITION BY state ORDER BY num_evs DESC) as rank FROM ev_adoption_stats WHERE rank <= 3;
Delete records with a biomass value lower than 10 in the 'species_data' table.
CREATE TABLE species_data (species_id INT,species_name VARCHAR(255),biomass FLOAT); INSERT INTO species_data (species_id,species_name,biomass) VALUES (1,'polar_bear',800.0),(2,'arctic_fox',15.0),(3,'caribou',220.0),(4,'lemming',5.0);
DELETE FROM species_data WHERE biomass < 10;
What is the total number of language courses offered per community center?
CREATE TABLE CommunityCenters (CenterID INT,CenterName VARCHAR(50)); CREATE TABLE LanguageCourses (CourseID INT,CourseName VARCHAR(50),CenterID INT); INSERT INTO CommunityCenters VALUES (1,'CenterA'),(2,'CenterB'),(3,'CenterC'); INSERT INTO LanguageCourses VALUES (1,'Spanish',1),(2,'French',1),(3,'Spanish',2),(4,'Chinese',3),(5,'English',3);
SELECT CC.CenterName, COUNT(LC.CourseID) AS TotalCourses FROM CommunityCenters CC JOIN LanguageCourses LC ON CC.CenterID = LC.CenterID GROUP BY CC.CenterName;
What is the total number of bike-sharing trips in Beijing?
CREATE TABLE if not exists bike_trips (id INT,city VARCHAR(20),num_trips INT); INSERT INTO bike_trips (id,city,num_trips) VALUES (1,'Beijing',10000),(2,'Shanghai',8000);
SELECT num_trips FROM bike_trips WHERE city = 'Beijing';
What is the virtual tourism revenue in Rome for 2022?
CREATE TABLE virtual_tourism_italy (location TEXT,year INT,revenue INT); INSERT INTO virtual_tourism_italy (location,year,revenue) VALUES ('Rome',2022,1200000),('Rome',2023,1400000);
SELECT revenue FROM virtual_tourism_italy WHERE location = 'Rome' AND year = 2022;
Update the color of all garments in the 'Tops' category to 'Red'
CREATE TABLE Garments (id INT,name VARCHAR(255),category VARCHAR(255),color VARCHAR(255),size VARCHAR(10),price DECIMAL(5,2));
UPDATE Garments SET color = 'Red' WHERE category = 'Tops';
What is the total volume of wastewater treated in regions that experienced a drought in 2018?
CREATE TABLE wastewater_treatment (region VARCHAR(255),year INT,treated_volume INT); INSERT INTO wastewater_treatment (region,year,treated_volume) VALUES ('North',2018,4000),('North',2019,4500),('South',2018,4800),('South',2019,5200); CREATE TABLE drought_info (region VARCHAR(255),year INT,severity INT); INSERT INTO drought_info (region,year,severity) VALUES ('North',2018,3),('North',2019,5),('South',2018,2),('South',2019,4);
SELECT SUM(w.treated_volume) FROM wastewater_treatment w JOIN drought_info d ON w.region = d.region WHERE w.year = 2018 AND d.severity > 0;
Insert new records of shared mobility programs in NYC.
CREATE TABLE SharedMobilityNYC (id INT,program VARCHAR(20),num_vehicles INT,agency VARCHAR(20));
INSERT INTO SharedMobilityNYC (id, program, num_vehicles, agency) VALUES (1, 'CitiBike NYC', 1000, 'NYC DOT'), (2, 'Revel NYC', 500, 'NYC DOT'), (3, 'Via NYC', 200, 'NYC DOT'), (4, 'Lyft Bikes NYC', 300, 'NYC DOT');
What is the average ticket price per city in 'concert_ticket_sales' table?
CREATE TABLE concert_ticket_sales (ticket_id INT,song_id INT,quantity INT,price FLOAT,city_id INT,sale_date DATE);
SELECT city_id, AVG(price) as avg_price FROM concert_ticket_sales GROUP BY city_id;
What is the distribution of medical specialists by rural hospital?
use rural_health; CREATE TABLE hospital_specialists (id int,hospital_id int,specialist text); INSERT INTO hospital_specialists (id,hospital_id,specialist) VALUES (1,1,'Cardiologist'); INSERT INTO hospital_specialists (id,hospital_id,specialist) VALUES (2,1,'Dermatologist'); INSERT INTO hospital_specialists (id,hospital_id,specialist) VALUES (3,2,'Neurologist');
SELECT hospital_id, specialist, COUNT(*) as count FROM rural_health.hospital_specialists GROUP BY hospital_id, specialist;
How many community health workers have been trained in each region in the last 5 years?
CREATE TABLE CHWTraining (CHWId INT,TrainingYear INT,Region VARCHAR(255)); INSERT INTO CHWTraining (CHWId,TrainingYear,Region) VALUES (1,2018,'North'); INSERT INTO CHWTraining (CHWId,TrainingYear,Region) VALUES (2,2019,'South'); INSERT INTO CHWTraining (CHWId,TrainingYear,Region) VALUES (3,2020,'East'); INSERT INTO CHWTraining (CHWId,TrainingYear,Region) VALUES (4,2021,'West');
SELECT Region, COUNT(*) FROM CHWTraining WHERE TrainingYear BETWEEN 2018 AND 2022 GROUP BY Region;
Find the transaction dates and the total transaction amount for transactions made by customers residing in India.
CREATE TABLE transactions_4 (id INT,customer_id INT,amount DECIMAL(10,2),tx_date DATE,country VARCHAR(255)); INSERT INTO transactions_4 (id,customer_id,amount,tx_date,country) VALUES (1,1,100.00,'2022-01-01','India'),(2,2,50.00,'2022-01-01','USA'),(3,3,200.00,'2022-01-02','Canada'),(4,1,300.00,'2022-01-03','India'),(5,4,1000.00,'2022-01-04','USA');
SELECT tx_date, SUM(amount) as total_transaction_amount FROM transactions_4 WHERE country = 'India' GROUP BY tx_date;
Calculate the average daily waste generation rate for the city of San Francisco in the year 2020
CREATE TABLE waste_generation (city VARCHAR(20),year INT,daily_waste_generation FLOAT);INSERT INTO waste_generation (city,year,daily_waste_generation) VALUES ('San Francisco',2019,3.2),('San Francisco',2020,3.5),('San Francisco',2021,3.7),('Oakland',2019,2.8),('Oakland',2020,3.1),('Oakland',2021,3.3);
SELECT AVG(daily_waste_generation) FROM waste_generation WHERE city = 'San Francisco' AND year = 2020;
Delete records of patients without a diagnosis in 'RuralHealthFacility10'.
CREATE TABLE RuralHealthFacility10 (patient_id INT,patient_name VARCHAR(50),age INT,diagnosis VARCHAR(20)); INSERT INTO RuralHealthFacility10 (patient_id,patient_name,age,diagnosis) VALUES (22,'Penny',42,'diabetes'),(23,'Quentin',NULL,'hypertension'),(24,'Rosa',47,NULL);
DELETE FROM RuralHealthFacility10 WHERE diagnosis IS NULL;
What is the average claim amount for each policy type, excluding policy types with fewer than 3 policies in the United Kingdom?
CREATE TABLE Claims (ClaimID INT,PolicyID INT,ClaimAmount DECIMAL(10,2)); CREATE TABLE Policy (PolicyID INT,PolicyType VARCHAR(20),Country VARCHAR(20)); INSERT INTO Claims (ClaimID,PolicyID,ClaimAmount) VALUES (1,1,1500.00),(2,2,250.00),(3,3,500.00),(4,1,1000.00); INSERT INTO Policy (PolicyID,PolicyType,Country) VALUES (1,'Homeowners','UK'),(2,'Auto','UK'),(3,'Renters','UK'),(4,'Homeowners','UK'),(5,'Homeowners','UK');
SELECT Policy.PolicyType, AVG(Claims.ClaimAmount) AS AvgClaimAmount FROM Policy INNER JOIN Claims ON Policy.PolicyID = Claims.PolicyID WHERE Policy.Country = 'UK' GROUP BY Policy.PolicyType HAVING COUNT(DISTINCT Policy.PolicyID) >= 3;
What is the maximum price of vegan makeup products sold in Germany?
CREATE TABLE MakeupProducts(productID INT,productName VARCHAR(50),price DECIMAL(5,2),isVegan BOOLEAN,country VARCHAR(50)); INSERT INTO MakeupProducts(productID,productName,price,isVegan,country) VALUES (1,'Red Lipstick',32.99,FALSE,'US'),(2,'Black Mascara',19.99,TRUE,'Germany'),(3,'Brown Eyeshadow',24.99,TRUE,'Canada');
SELECT MAX(price) FROM MakeupProducts WHERE country = 'Germany' AND isVegan = TRUE;
Add a new safety testing record for 'Cruise Automation' in the 'autonomous_driving_tests' table
CREATE TABLE autonomous_driving_tests (id INT PRIMARY KEY,company VARCHAR(255),test_location VARCHAR(255),test_date DATE,safety_rating INT);
INSERT INTO autonomous_driving_tests (company, test_location, test_date, safety_rating) VALUES ('Cruise Automation', 'San Francisco', '2023-01-05', 95);