instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the total number of small-scale farms in Europe and South America that use regenerative agriculture practices, and what is the average land area used by these farms?
CREATE TABLE farms (region VARCHAR(20),practice VARCHAR(20),land_area INT); INSERT INTO farms VALUES ('Europe','Regenerative',2000),('South America','Holistic',3000),('Europe','No-till',1500);
SELECT f.region, COUNT(f.region) as num_farms, AVG(f.land_area) as avg_land_area FROM farms f WHERE f.region IN ('Europe', 'South America') AND f.practice = 'Regenerative' GROUP BY f.region;
What is the average delivery time, in days, for orders placed with fair trade certified suppliers?
CREATE TABLE orders (id INT PRIMARY KEY,supplier_id INT,delivery_time INT,fair_trade_certified BOOLEAN); INSERT INTO orders (id,supplier_id,delivery_time,fair_trade_certified) VALUES (1,1,7,true),(2,2,10,false),(3,3,5,true),(4,4,8,true),(5,5,12,false); CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(50),fair_trade_certified BOOLEAN); INSERT INTO suppliers (id,name,fair_trade_certified) VALUES (1,'EcoFarm',true),(2,'GreenHarvest',false),(3,'SustainableSource',true),(4,'RecycledResources',true),(5,'NaturalFibers',false);
SELECT AVG(delivery_time) as avg_delivery_time FROM orders JOIN suppliers ON orders.supplier_id = suppliers.id WHERE fair_trade_certified = true;
What is the average age of healthcare providers in the 'rural_clinic' table?
CREATE TABLE rural_clinic (id INT,name VARCHAR(50),age INT); INSERT INTO rural_clinic (id,name,age) VALUES (1,'John Doe',45),(2,'Jane Smith',38);
SELECT AVG(age) FROM rural_clinic;
Identify the total quantity of ingredients used in vegan dishes.
CREATE TABLE ingredients (ingredient_id INT,ingredient_name VARCHAR(255),dish_type VARCHAR(255),quantity INT); INSERT INTO ingredients VALUES (1,'Tomatoes','Vegan',500),(2,'Garlic','Vegan',200),(3,'Chickpeas','Vegan',1000);
SELECT SUM(quantity) AS total_quantity FROM ingredients WHERE dish_type = 'Vegan';
What is the percentage of female and male employees in each department?
CREATE TABLE department (id INT,name TEXT); INSERT INTO department (id,name) VALUES (1,'Operations'),(2,'Engineering'),(3,'HR'); CREATE TABLE employee (id INT,name TEXT,department_id INT,gender TEXT); INSERT INTO employee (id,name,department_id,gender) VALUES (1,'John Doe',1,'male'),(2,'Jane Smith',1,'female'),(3,'Mike Johnson',2,'male');
SELECT department_id, gender, COUNT(*) as num_employees, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employee WHERE department_id = department.id), 2) as percentage FROM employee GROUP BY department_id, gender;
What is the maximum price of lipsticks?
CREATE TABLE Lipsticks (product_id INT,product_name VARCHAR(255),category VARCHAR(255),price DECIMAL(10,2)); INSERT INTO Lipsticks (product_id,product_name,category,price) VALUES (1,'Lipstick 1','Lipsticks',12.99),(2,'Lipstick 2','Lipsticks',17.99),(3,'Lipstick 3','Lipsticks',22.99),(4,'Lipstick 4','Lipsticks',27.99);
SELECT MAX(price) FROM Lipsticks WHERE category = 'Lipsticks';
Delete all records from the 'habitat_preservation' table where the 'organization' is 'Wildlife Protection Agency'
CREATE TABLE habitat_preservation (id INT PRIMARY KEY,region VARCHAR(20),organization VARCHAR(30),start_date DATE,end_date DATE);
DELETE FROM habitat_preservation WHERE organization = 'Wildlife Protection Agency';
What is the number of transactions for the healthcare sector?
CREATE TABLE transactions (transaction_id INT,sector VARCHAR(20)); INSERT INTO transactions (transaction_id,sector) VALUES (1,'Healthcare'),(2,'Technology');
SELECT COUNT(*) FROM transactions WHERE sector = 'Healthcare';
Insert a new healthcare resource record into the rural_resources table
CREATE TABLE rural_resources (id INT PRIMARY KEY,resource_name VARCHAR(100),location VARCHAR(200),capacity INT);
INSERT INTO rural_resources (id, resource_name, location, capacity) VALUES (1, 'Clinic', 'Rural Town 1', 50);
What is the total number of union members in the 'transportation' industry?
CREATE TABLE union_members (id INT,name VARCHAR(50),union_id INT,industry VARCHAR(20)); INSERT INTO union_members (id,name,union_id,industry) VALUES (1,'John Doe',123,'construction'),(2,'Jane Smith',456,'retail'),(3,'Mike Johnson',789,'healthcare'),(4,'Liam Lee',111,'transportation');
SELECT COUNT(*) FROM union_members WHERE industry = 'transportation';
Delete the records of movies from the 'Movies' table where the production budget exceeds $150 million.
CREATE TABLE Movies (movie_id INT PRIMARY KEY,title VARCHAR(100),release_year INT,production_budget INT); INSERT INTO Movies (movie_id,title,release_year,production_budget) VALUES (1,'Avatar',2009,237000000),(2,'The Lion King',2019,260000000),(3,'Pirates of the Caribbean: On Stranger Tides',2011,379000000);
DELETE FROM Movies WHERE production_budget > 150000000;
What is the average age of founders in the education sector who received funding?
CREATE TABLE company (id INT,name TEXT,industry TEXT,founder_age INT);CREATE TABLE funding (id INT,company_id INT,amount INT); INSERT INTO company (id,name,industry,founder_age) VALUES (1,'EdTechX','Education',35),(2,'LearnMore','Education',45); INSERT INTO funding (id,company_id,amount) VALUES (1,1,2000000),(2,2,3000000);
SELECT AVG(company.founder_age) FROM company INNER JOIN funding ON company.id = funding.company_id WHERE company.industry = 'Education';
Find the top 3 renewable energy producers by capacity and their regions.
CREATE TABLE renewable_producers (id INT,name TEXT,capacity FLOAT,region TEXT); INSERT INTO renewable_producers (id,name,capacity,region) VALUES (1,'ABC Energy',2500,'North'),(2,'XYZ Solar',3000,'South'),(3,'DEF Wind',3500,'West');
SELECT name, region, capacity FROM (SELECT name, region, capacity, ROW_NUMBER() OVER (ORDER BY capacity DESC) as rn FROM renewable_producers) sub WHERE rn <= 3;
List all smart contracts associated with a specific user '0x123...'.
CREATE TABLE smart_contracts (contract_address VARCHAR(64),user_address VARCHAR(64));
SELECT contract_address FROM smart_contracts WHERE user_address = '0x123...';
List all mining sites in the USA and their environmental impact scores.
CREATE TABLE mining_sites (id INT,site VARCHAR,country VARCHAR,score INT); INSERT INTO mining_sites (id,site,country,score) VALUES (1,'SiteA','USA',78),(2,'SiteB','USA',82);
SELECT site, score FROM mining_sites WHERE country = 'USA';
What is the total number of heritage sites and associated artifacts in each continent?
CREATE TABLE Site (SiteID INT,SiteName VARCHAR(50),Continent VARCHAR(50)); INSERT INTO Site (SiteID,SiteName,Continent) VALUES (1,'Great Wall','Asia'),(2,'Machu Picchu','South America'),(3,'Easter Island','South America'); CREATE TABLE Artifact (ArtifactID INT,ArtifactName VARCHAR(50),SiteID INT); INSERT INTO Artifact (ArtifactID,ArtifactName,SiteID) VALUES (1,'Watchtower',1),(2,'Temple of the Sun',1),(3,'Temple of the Moon',1),(4,'Llama Figurine',2);
SELECT Continent, COUNT(DISTINCT SiteID) as SiteCount, (SELECT COUNT(*) FROM Artifact WHERE EXISTS (SELECT 1 FROM Site WHERE Site.SiteID = Artifact.SiteID AND Site.Continent = Site.Continent)) as ArtifactCount FROM Site GROUP BY Continent;
What is the maximum water usage by industrial users in the state of Ohio?
CREATE TABLE industrial_users (id INT,state VARCHAR(20),water_usage FLOAT); INSERT INTO industrial_users (id,state,water_usage) VALUES (1,'Ohio',100.5),(2,'Ohio',125.6),(3,'California',150.2);
SELECT MAX(water_usage) FROM industrial_users WHERE state = 'Ohio';
Show the "equipment_name" and "quantity" columns from the "military_equipment" table, sorted by the "quantity" column in descending order
CREATE TABLE military_equipment (id INT,equipment_name VARCHAR(50),quantity INT); INSERT INTO military_equipment (id,equipment_name,quantity) VALUES (1,'tank',20),(2,'fighter_jet',12),(3,'humvee',8);
SELECT equipment_name, quantity FROM military_equipment ORDER BY quantity DESC;
List the top three regions with the highest average permit cost.
CREATE TABLE permit (permit_id INT,region VARCHAR(20),cost FLOAT); INSERT INTO permit VALUES (1,'Northeast',8000); INSERT INTO permit VALUES (2,'Midwest',5000); INSERT INTO permit VALUES (3,'Southwest',6000);
SELECT region, AVG(cost) as avg_cost, RANK() OVER (ORDER BY AVG(cost) DESC) as avg_cost_rank FROM permit GROUP BY region HAVING avg_cost_rank <= 3;
What is the total amount of minerals extracted by each company, considering both open-pit and underground mining methods?
CREATE TABLE mining_companies (company_id INT,company_name TEXT); INSERT INTO mining_companies (company_id,company_name) VALUES (1,'CompanyA'),(2,'CompanyB'); CREATE TABLE mining_methods (method_id INT,method_name TEXT); INSERT INTO mining_methods (method_id,method_name) VALUES (1,'Open-pit'),(2,'Underground'); CREATE TABLE extraction_data (company_id INT,method_id INT,amount_extracted INT); INSERT INTO extraction_data (company_id,method_id,amount_extracted) VALUES (1,1,500),(1,2,300),(2,1,700),(2,2,400);
SELECT mc.company_name, SUM(ed.amount_extracted) AS total_amount_extracted FROM extraction_data ed JOIN mining_companies mc ON ed.company_id = mc.company_id JOIN mining_methods mm ON ed.method_id = mm.method_id WHERE mm.method_name IN ('Open-pit', 'Underground') GROUP BY mc.company_name;
What is the total amount of research grants awarded to each department for a specific year?
CREATE TABLE department (id INT,name TEXT); CREATE TABLE research_grants (id INT,department_id INT,amount INT,year INT);
SELECT d.name, r.year, SUM(r.amount) FROM department d JOIN research_grants r ON d.id = r.department_id WHERE r.year = 2020 GROUP BY d.name, r.year;
What is the average budget spent on language preservation programs per region?
CREATE TABLE LanguagePreservation (Region VARCHAR(255),Budget INT); INSERT INTO LanguagePreservation (Region,Budget) VALUES ('North America',500000),('South America',300000),('Europe',700000),('Asia',900000),('Africa',400000);
SELECT Region, AVG(Budget) as Avg_Budget FROM LanguagePreservation GROUP BY Region;
List all the erbium supply chain transparency reports for the last 2 years.
CREATE TABLE erbium_supply_chain (report_id INT,year INT,report_status TEXT); INSERT INTO erbium_supply_chain (report_id,year,report_status) VALUES (1,2020,'Published'),(2,2020,'Published'),(3,2021,'Published'),(4,2021,'Draft'),(5,2022,'Planned');
SELECT * FROM erbium_supply_chain WHERE year >= 2020;
What is the ratio of police officers to citizens in each precinct?
CREATE TABLE precincts (name VARCHAR(255),officers INT,population INT); INSERT INTO precincts (name,officers,population) VALUES ('Precinct 1',50,1000),('Precinct 2',75,2000),('Precinct 3',100,3000);
SELECT name, officers, population, officers*1.0/population AS ratio FROM precincts;
What is the total number of autonomous driving research studies conducted in the US and China?
CREATE TABLE Studies (ID INT,Location VARCHAR(255),Type VARCHAR(255)); INSERT INTO Studies (ID,Location,Type) VALUES (1,'US','Autonomous Driving'),(2,'China','Autonomous Driving'),(3,'France','Electric Vehicles');
SELECT COUNT(*) FROM Studies WHERE Location IN ('US', 'China') AND Type = 'Autonomous Driving';
List all the countries that have at least one urban agriculture program and their respective program names, excluding Canada?
CREATE TABLE countries (id INT,name VARCHAR(50)); CREATE TABLE urban_agriculture_programs (id INT,country_id INT,name VARCHAR(50)); INSERT INTO countries (id,name) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'); INSERT INTO urban_agriculture_programs (id,country_id,name) VALUES (1,1,'GrowNYC'),(2,3,'Ciudad Verde'),(3,1,'Chicago Urban Agriculture'),(4,2,'Vancouver Urban Farming');
SELECT c.name, program_name FROM countries c JOIN urban_agriculture_programs p ON c.id = p.country_id WHERE c.name != 'Canada';
What is the average budget allocated for ethical AI research in the year 2022?
CREATE TABLE Ethical_AI_Budget (Year INT,Budget FLOAT); INSERT INTO Ethical_AI_Budget (Year,Budget) VALUES (2021,1500000),(2022,1800000),(2023,2000000);
SELECT AVG(Budget) FROM Ethical_AI_Budget WHERE Year = 2022;
Find the average landfill capacity in APAC for countries with a capacity greater than 100,000 cubic meters.
CREATE TABLE LandfillCapacityAPAC (id INT,country VARCHAR(50),region VARCHAR(50),capacity_cubic_meters INT); INSERT INTO LandfillCapacityAPAC (id,country,region,capacity_cubic_meters) VALUES (1,'China','APAC',120000),(2,'Japan','APAC',90000),(3,'India','APAC',150000);
SELECT AVG(capacity_cubic_meters) FROM LandfillCapacityAPAC WHERE capacity_cubic_meters > 100000 AND region = 'APAC';
Which categories have an average sustainability score above 80?
CREATE TABLE category_scores (id INT PRIMARY KEY,category VARCHAR(255),sustainability_score INT); INSERT INTO category_scores (id,category,sustainability_score) VALUES (1,'Dresses',82); INSERT INTO category_scores (id,category,sustainability_score) VALUES (2,'Shirts',78);
SELECT category, AVG(sustainability_score) as avg_sustainability_score FROM category_scores GROUP BY category HAVING AVG(sustainability_score) > 80;
Delete records of languages with no speakers
CREATE TABLE languages (id INT,language VARCHAR(50),region VARCHAR(50),num_speakers INT); INSERT INTO languages (id,language,region,num_speakers) VALUES (1,'Livonian','Latvia',0),(2,'Ubykh','Turkey',0),(3,'Eyak','USA',0)
DELETE FROM languages WHERE num_speakers = 0
What is the total number of construction labor hours worked, in each state, in the past month, ordered from highest to lowest?
CREATE TABLE LaborHours (State VARCHAR(2),HoursWorked DATE,Job VARCHAR(50));
SELECT State, SUM(HoursWorked) as TotalHours FROM LaborHours WHERE HoursWorked >= DATEADD(MONTH, -1, GETDATE()) GROUP BY State ORDER BY TotalHours DESC;
Update the 'victims' table: change the last_name to 'Johnson' for records with victim_id 2001, 2002
CREATE TABLE victims (victim_id INT,first_name VARCHAR(20),last_name VARCHAR(20)); INSERT INTO victims (victim_id,first_name,last_name) VALUES (2001,'Victoria','Martin'),(2002,'Victor','Martin'),(2003,'Tom','Brown');
UPDATE victims SET last_name = 'Johnson' WHERE victim_id IN (2001, 2002);
What is the policy advocacy history for a specific organization, per type of advocacy?
CREATE TABLE PolicyAdvocacy (PolicyAdvocacyID INT,Organization VARCHAR(255),AdvocacyDate DATE); INSERT INTO PolicyAdvocacy (PolicyAdvocacyID,Organization,AdvocacyDate) VALUES (1,'National Alliance on Mental Illness','2020-01-01'),(2,'Autistic Self Advocacy Network','2019-12-15');
SELECT Organization, AdvocacyDate FROM PolicyAdvocacy WHERE Organization = 'National Alliance on Mental Illness';
What is the total revenue for each menu category by customer in the last 30 days?
CREATE TABLE customers (customer_id INT,customer_name VARCHAR(255)); CREATE TABLE menu_items (menu_item_id INT,menu_category VARCHAR(255),item_name VARCHAR(255),is_sustainable BOOLEAN); CREATE TABLE orders (order_id INT,customer_id INT,menu_item_id INT,order_date DATE,order_price INT);
SELECT c.customer_name, m.menu_category, SUM(o.order_price) as total_revenue FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id JOIN menus m ON mi.menu_category = m.menu_category WHERE o.order_date BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE() GROUP BY c.customer_name, m.menu_category;
What is the average carbon dioxide concentration in the atmosphere each year?
CREATE TABLE carbon_dioxide_measurements (year INT,co2_ppm FLOAT);
SELECT year, AVG(co2_ppm) FROM carbon_dioxide_measurements GROUP BY year;
What is the average cultural competency score for community health workers, partitioned by race?
CREATE TABLE CommunityHealthWorker (WorkerID int,Race varchar(25),CulturalCompetencyScore int); INSERT INTO CommunityHealthWorker (WorkerID,Race,CulturalCompetencyScore) VALUES (1,'Asian',85),(2,'Black',90),(3,'Hispanic',80),(4,'White',95);
SELECT Race, AVG(CulturalCompetencyScore) OVER (PARTITION BY Race) AS AvgScore FROM CommunityHealthWorker;
List the top 5 graduate students with the highest number of research publications in the past year, partitioned by their advisors.
CREATE TABLE GraduateStudents(StudentID INT,Name VARCHAR(50),Advisor VARCHAR(50),Publications INT); INSERT INTO GraduateStudents (StudentID,Name,Advisor,Publications) VALUES (1,'Doe,J','Prof. Brown',12),(2,'Doe,J','Prof. Black',8);
SELECT StudentID, Name, Advisor, ROW_NUMBER() OVER(PARTITION BY Advisor ORDER BY Publications DESC) AS Rank FROM GraduateStudents WHERE YEAR(PublicationDate) = YEAR(CURRENT_DATE()) - 1;
What is the total distance run by male and female users?
CREATE TABLE workouts (id INT,user_id INT,distance FLOAT,workout_date DATE); INSERT INTO workouts VALUES (1,1,5.6,'2022-01-01'),(2,2,7.2,'2022-01-02'),(3,3,6.3,'2022-01-03'); CREATE TABLE users (id INT,age INT,gender VARCHAR(10)); INSERT INTO users VALUES (1,23,'Female'),(2,32,'Male'),(3,27,'Male');
SELECT u.gender, SUM(w.distance) AS total_distance FROM workouts w JOIN users u ON w.user_id = u.id GROUP BY u.gender;
What is the cultural competency score for each hospital in the last quarter?
CREATE TABLE Hospitals (HospitalID INT,CulturalCompetencyScore DECIMAL(5,2),ReportDate DATE); INSERT INTO Hospitals (HospitalID,CulturalCompetencyScore,ReportDate) VALUES (1,85.6,'2022-01-01'); INSERT INTO Hospitals (HospitalID,CulturalCompetencyScore,ReportDate) VALUES (2,92.3,'2022-02-15'); INSERT INTO Hospitals (HospitalID,CulturalCompetencyScore,ReportDate) VALUES (3,78.9,'2022-03-05'); INSERT INTO Hospitals (HospitalID,CulturalCompetencyScore,ReportDate) VALUES (4,96.1,'2022-04-10');
SELECT ReportDate, CulturalCompetencyScore FROM Hospitals WHERE ReportDate >= DATEADD(quarter, -1, GETDATE());
What is the maximum depth of oceanic trenches in the Caribbean plate?
CREATE TABLE Trench (trench_name VARCHAR(50),plate_name VARCHAR(50),max_depth NUMERIC(8,2)); INSERT INTO Trench (trench_name,plate_name,max_depth) VALUES ('Cayman Trough','Caribbean',25000);
SELECT MAX(max_depth) FROM Trench WHERE plate_name = 'Caribbean';
Delete the record with id 3 from the landfill_capacity table
CREATE TABLE landfill_capacity (id INT PRIMARY KEY,location VARCHAR(50),capacity INT);
DELETE FROM landfill_capacity WHERE id = 3;
Delete all packages that were delivered more than 30 days ago
CREATE TABLE packages (package_id INT,delivery_date DATE); INSERT INTO packages (package_id,delivery_date) VALUES (1,'2021-05-01'),(2,'2021-06-10'),(3,'2021-07-20');
DELETE FROM packages WHERE delivery_date < DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
What is the total amount donated to social causes?
CREATE TABLE causes (id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO causes (id,name,type) VALUES (1,'Education','Social'),(2,'Health','Social'),(3,'Environment','Non-social'); CREATE TABLE donations (id INT,cause_id INT,amount DECIMAL(10,2)); INSERT INTO donations (id,cause_id,amount) VALUES (1,1,500.00),(2,1,1000.00),(3,2,750.00),(4,3,1500.00);
SELECT SUM(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id WHERE c.type = 'Social';
What is the average age of all tugboats in the 'tugboats' table?
CREATE TABLE tugboats (id INT PRIMARY KEY,name VARCHAR(50),year_built INT,type VARCHAR(50));
SELECT AVG(year_built) FROM tugboats;
What is the average revenue per month for cultural heritage events in Europe?
CREATE TABLE cultural_events (id INT,name VARCHAR(50),month VARCHAR(10),revenue DECIMAL(10,2));
SELECT AVG(cultural_events.revenue) FROM cultural_events WHERE cultural_events.name LIKE '%cultural heritage%' AND cultural_events.month LIKE '%Europe%';
What is the maximum number of satellites launched by a manufacturer in a single year, and the year in which this occurred?
CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),LaunchDate DATE,Manufacturer VARCHAR(50)); INSERT INTO Satellites (SatelliteID,Name,LaunchDate,Manufacturer) VALUES (1,'Sat1','2022-02-01','SpaceCorp'),(2,'Sat2','2022-02-10','Galactic'),(3,'Sat3','2022-02-20','SpaceCorp'),(4,'Sat4','2023-01-01','AstroTech'),(5,'Sat5','2023-03-15','SpaceCorp'),(6,'Sat6','2023-03-25','Galactic');
SELECT Manufacturer, YEAR(LaunchDate) AS Launch_Year, MAX(COUNT(SatelliteID)) OVER (PARTITION BY Manufacturer) AS Max_Launches FROM Satellites GROUP BY Manufacturer, LaunchDate;
What is the total waste generation for the Manufacturing industry across all regions?
CREATE TABLE Waste_Generation_All (industry VARCHAR(20),region VARCHAR(20),waste_quantity INT); INSERT INTO Waste_Generation_All (industry,region,waste_quantity) VALUES ('Manufacturing','North',1000),('Manufacturing','South',1500),('Retail','North',500),('Retail','East',700),('Agriculture','West',2000),('Manufacturing','West',2500);
SELECT industry, SUM(waste_quantity) FROM Waste_Generation_All WHERE industry = 'Manufacturing' GROUP BY industry;
What is the total circular economy initiatives in Germany over the last 3 years?
CREATE TABLE circular_economy (country VARCHAR(50),initiative_count INT,year INT); INSERT INTO circular_economy (country,initiative_count,year) VALUES ('Germany',250,2019),('Germany',300,2020),('Germany',350,2021);
SELECT SUM(initiative_count) FROM circular_economy WHERE country = 'Germany' AND year >= 2019;
Insert a new movie 'Pulp Fiction' with release year 1994 and rating 9.0.
CREATE TABLE movies (id INT,title VARCHAR(255),release_year INT,director_gender VARCHAR(10),rating DECIMAL(2,1));
INSERT INTO movies (title, release_year, rating, director_gender) VALUES ('Pulp Fiction', 1994, 9.0, 'Male');
What is the average distance of space debris generated by NASA from the Earth's center?
CREATE TABLE space_debris (id INT,name VARCHAR(50),type VARCHAR(50),source VARCHAR(50),location POINT);
SELECT AVG(DISTANCE(location, POINT(0, 0))) as average_distance FROM space_debris WHERE source = 'NASA';
What is the distribution of models trained on different datasets for AI applications?
CREATE TABLE dataset_data (model_id INT,model_name VARCHAR(50),dataset VARCHAR(50),application VARCHAR(50));
SELECT dataset, COUNT(model_id) as num_models FROM dataset_data GROUP BY dataset;
List the top 3 most affordable neighborhoods by median home price.
CREATE TABLE Neighborhoods (name VARCHAR(50),median_home_price INT); INSERT INTO Neighborhoods (name,median_home_price) VALUES ('Central Park',500000),('Harlem',350000),('Bronx',400000);
SELECT name, median_home_price FROM Neighborhoods ORDER BY median_home_price LIMIT 3;
Which wells in 'FieldE' have a production greater than 1000 in the first quarter of 2022?
CREATE TABLE wells (well_id varchar(10),field varchar(10),production int,datetime date); INSERT INTO wells (well_id,field,production,datetime) VALUES ('W003','FieldE',1200,'2022-01-01'),('W004','FieldE',1800,'2022-02-01');
SELECT well_id, field, production FROM wells WHERE field = 'FieldE' AND production > 1000 AND YEAR(datetime) = 2022 AND QUARTER(datetime) = 1;
What is the average production (in tons) of quinoa in the Andean region, disaggregated by country?
CREATE TABLE QuinoaProduction (country VARCHAR(50),year INT,production_tons INT); INSERT INTO QuinoaProduction (country,year,production_tons) VALUES ('Bolivia',2015,70000),('Peru',2015,100000),('Ecuador',2015,50000),('Bolivia',2016,80000),('Peru',2016,120000),('Ecuador',2016,60000);
SELECT country, AVG(production_tons) FROM QuinoaProduction WHERE country IN ('Bolivia', 'Peru', 'Ecuador') AND year = 2015 OR year = 2016 GROUP BY country;
What is the average salary of workers in the 'textile' industry who are female and over 40 years old, sorted by highest salary?
CREATE TABLE Workers (ID INT,Age INT,Gender VARCHAR(10),Salary DECIMAL(5,2),Industry VARCHAR(20)); INSERT INTO Workers (ID,Age,Gender,Salary,Industry) VALUES (1,42,'Female',50000.00,'Textile'); INSERT INTO Workers (ID,Age,Gender,Salary,Industry) VALUES (2,35,'Male',55000.00,'Textile'); INSERT INTO Workers (ID,Age,Gender,Salary,Industry) VALUES (3,45,'Female',60000.00,'Textile');
SELECT AVG(Salary) FROM Workers WHERE Gender = 'Female' AND Age > 40 AND Industry = 'Textile' ORDER BY Salary DESC;
What are the top 10 most popular beauty products in the UK, based on sales in Q2 2022?
CREATE TABLE sales (id INT,product_name VARCHAR(255),country VARCHAR(255),sales_amount DECIMAL(10,2),sale_date DATE);
SELECT product_name, SUM(sales_amount) as total_sales FROM sales WHERE country = 'UK' AND sale_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY product_name ORDER BY total_sales DESC LIMIT 10;
What is the total donation amount given to nonprofits offering programs in the categories of Education, Health, and Environment, excluding any duplicate records?
CREATE TABLE donations (id INT,donor TEXT,program TEXT,amount FLOAT); INSERT INTO donations (id,donor,program,amount) VALUES (1,'Donor A','Education',500.00),(2,'Donor B','Health',1000.00),(3,'Donor C','Environment',750.00),(4,'Donor D','Education',250.00),(5,'Donor A','Health',750.00);
SELECT SUM(amount) as total_donations FROM donations WHERE program IN (SELECT DISTINCT program FROM donations WHERE program IN ('Education', 'Health', 'Environment'));
Calculate the percentage of hospitals in urban areas in each state.
CREATE TABLE hospitals (id INT,name TEXT,location TEXT,num_beds INT,state TEXT); INSERT INTO hospitals (id,name,location,num_beds,state) VALUES (1,'General Hospital','Urban,California',200,'California'); INSERT INTO hospitals (id,name,location,num_beds,state) VALUES (2,'Community Hospital','Rural,New York',150,'New York'); INSERT INTO hospitals (id,name,location,num_beds,state) VALUES (3,'City Hospital','Urban,Texas',250,'Texas');
SELECT state, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM hospitals WHERE location = 'Urban') as percentage FROM hospitals WHERE location = 'Urban' GROUP BY state
Update the donation amount in the 'Donations' table
CREATE TABLE Donations (DonationID INT PRIMARY KEY,DonorID INT,Amount DECIMAL(10,2),DonationDate DATE);
UPDATE Donations SET Amount = 600.00 WHERE DonationID = 301;
List all astronauts from the USA
CREATE TABLE Astronauts (ID INT,Name VARCHAR(50),Nationality VARCHAR(50)); INSERT INTO Astronauts VALUES (1,'Mark Watney','USA'),(2,'Melissa Lewis','USA');
SELECT * FROM Astronauts WHERE Nationality = 'USA';
How many landfills were operational in 2018, excluding data from North America and Europe?
CREATE TABLE LandfillCapacity (year INT,region VARCHAR(50),landfill VARCHAR(50),capacity FLOAT,filled_volume FLOAT); INSERT INTO LandfillCapacity (year,region,landfill,capacity,filled_volume) VALUES (2018,'North America','Landfill A',100000,95000),(2018,'Europe','Landfill B',120000,110000),(2018,'Asia','Landfill C',150000,145000),(2018,'South America','Landfill D',80000,75000),(2018,'Africa','Landfill E',70000,65000);
SELECT COUNT(*) FROM LandfillCapacity WHERE year = 2018 AND region NOT IN ('North America', 'Europe');
Delete military equipment sales records with a value less than 1000000 from the year 2021.
CREATE TABLE Military_Equipment_Sales(id INT,country VARCHAR(255),year INT,value FLOAT); INSERT INTO Military_Equipment_Sales(id,country,year,value) VALUES (1,'India',2020,50000000),(2,'India',2021,4500000),(3,'US',2020,80000000),(4,'India',2019,40000000),(5,'US',2019,75000000),(6,'China',2020,60000000),(7,'China',2019,55000000),(8,'US',2018,70000000);
DELETE FROM Military_Equipment_Sales WHERE year = 2021 AND value < 1000000;
What is the total number of hospital beds in each country in the Oceania continent?
CREATE TABLE Countries (Country VARCHAR(50),Continent VARCHAR(50),Hospital_Beds INT); INSERT INTO Countries (Country,Continent,Hospital_Beds) VALUES ('Australia','Oceania',64000),('New Zealand','Oceania',10000);
SELECT Country, SUM(Hospital_Beds) FROM Countries WHERE Continent = 'Oceania' GROUP BY Country WITH ROLLUP;
What is the average salary of employees in the 'mining_operations' table?
CREATE TABLE mining_operations (id INT,name VARCHAR(100),role VARCHAR(50),salary FLOAT); INSERT INTO mining_operations (id,name,role,salary) VALUES (1,'John Doe','Mining Engineer',75000.00); INSERT INTO mining_operations (id,name,role,salary) VALUES (2,'Jane Smith','Geologist',60000.00);
SELECT AVG(salary) FROM mining_operations;
What is the earliest and latest date of exhibitions held in 'London' and 'Tokyo'?
CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY,Title TEXT,Date DATE,City TEXT);
SELECT MIN(Exhibitions.Date), MAX(Exhibitions.Date) FROM Exhibitions WHERE Exhibitions.City IN ('London', 'Tokyo');
Update the price of all mascaras to $25
CREATE TABLE products (id INT,name VARCHAR(255),price DECIMAL(10,2),category VARCHAR(255)); INSERT INTO products (id,name,price,category) VALUES (1,'Mascara 1',20.00,'Mascara'),(2,'Mascara 2',30.00,'Mascara'),(3,'Mascara 3',40.00,'Mascara'),(4,'Mascara 4',50.00,'Mascara');
UPDATE products SET price = 25.00 WHERE category = 'Mascara';
What is the maximum fare for a ferry in the 'Sydney' region?
CREATE TABLE ferries (id INT,region VARCHAR(20),fare DECIMAL(5,2)); INSERT INTO ferries (id,region,fare) VALUES (1,'Sydney',7.00),(2,'Sydney',5.50),(3,'Melbourne',4.50),(4,'Sydney',6.00);
SELECT MAX(fare) FROM ferries WHERE region = 'Sydney';
What is the average amount of aid donated by individuals in the US and Canada?
CREATE TABLE donations (id INT,donor TEXT,country TEXT,donation FLOAT); INSERT INTO donations (id,donor,country,donation) VALUES (1,'John Doe','USA',100),(2,'Jane Smith','Canada',150),(3,'Michael Lee','USA',75);
SELECT AVG(donation) as avg_donation FROM donations WHERE country IN ('USA', 'Canada');
Delete records with sale amount less than $50,000 in the MilitaryEquipmentSales table
CREATE TABLE MilitaryEquipmentSales (id INT,equipment_name VARCHAR(50),sale_amount INT,sale_date DATE); INSERT INTO MilitaryEquipmentSales (id,equipment_name,sale_amount,sale_date) VALUES (1,'Fighter Jet',45000,'2021-01-01'),(2,'Tank',75000,'2021-02-01'),(3,'Helicopter',35000,'2021-03-01');
DELETE FROM MilitaryEquipmentSales WHERE sale_amount < 50000;
What is the total area of all marine protected areas in the Indian Ocean?
CREATE TABLE marine_protected_areas (name VARCHAR(255),area_size FLOAT,ocean VARCHAR(255)); INSERT INTO marine_protected_areas (name,area_size,ocean) VALUES ('Chagos Marine Protected Area',545000,'Indian');
SELECT SUM(area_size) FROM marine_protected_areas WHERE ocean = 'Indian';
What are the names and locations of all carriers that have a fleet size greater than 50 vehicles?
CREATE TABLE Carriers (id INT,name TEXT,fleet_size INT,headquarters TEXT); INSERT INTO Carriers (id,name,fleet_size,headquarters) VALUES (1,'ABC Carriers',75,'New York'); INSERT INTO Carriers (id,name,fleet_size,headquarters) VALUES (2,'XYZ Carriers',35,'Los Angeles'); INSERT INTO Carriers (id,name,fleet_size,headquarters) VALUES (3,'DEF Carriers',60,'Chicago');
SELECT name, headquarters FROM Carriers WHERE fleet_size > 50;
What is the average age of players who have not played VR games and their total game purchase count?
CREATE TABLE Players (PlayerID INT,Age INT,GamePurchaseCount INT); INSERT INTO Players (PlayerID,Age,GamePurchaseCount) VALUES (1,25,120),(2,35,200),(3,42,150),(4,22,80),(5,31,175); CREATE TABLE VR_Games (PlayerID INT,VRGamePlayed BOOLEAN); INSERT INTO VR_Games (PlayerID,VRGamePlayed) VALUES (1,TRUE),(2,FALSE),(3,TRUE),(4,FALSE),(5,FALSE);
SELECT AVG(Players.Age), SUM(Players.GamePurchaseCount) FROM Players INNER JOIN VR_Games ON Players.PlayerID = VR_Games.PlayerID WHERE VR_Games.VRGamePlayed = FALSE;
Display the number of hospitals in each city, ordered by the number of hospitals in descending order
CREATE TABLE hospitals (hospital_id INT,city_id INT,hospital_name TEXT);CREATE TABLE cities (city_id INT,city_name TEXT,population INT);
SELECT c.city_name, COUNT(h.hospital_id) FROM hospitals h INNER JOIN cities c ON h.city_id = c.city_id GROUP BY c.city_name ORDER BY COUNT(h.hospital_id) DESC;
What is the maximum daily transaction volume for the 'Tether' digital asset on the 'ETH' network in the last 30 days?
CREATE TABLE daily_transaction_volume (date DATE,asset_id INT,volume DECIMAL(10,2)); INSERT INTO daily_transaction_volume (date,asset_id,volume) VALUES ('2022-01-01',1,5000),('2022-01-02',1,5500),('2022-01-03',1,6000);
SELECT MAX(dt.volume) as max_daily_volume FROM daily_transaction_volume dt WHERE dt.asset_id = 1 AND dt.date >= CURDATE() - INTERVAL 30 DAY;
How many publications do graduate students in the Physics department have?
CREATE SCHEMA publications;CREATE TABLE student_publications(student_name TEXT,department TEXT,num_publications INTEGER);INSERT INTO student_publications(student_name,department,num_publications)VALUES('Eve','Physics',5),('Frank','Computer Science',3);
SELECT department,SUM(num_publications) FROM publications.student_publications WHERE department='Physics' GROUP BY department;
What was the maximum wave height ever recorded in the Arctic?
CREATE TABLE wave_heights (id INT,location VARCHAR(255),height FLOAT,date DATE); INSERT INTO wave_heights (id,location,height,date) VALUES (1,'Arctic Ocean',20.0,'2020-01-01'),(2,'North Atlantic Ocean',30.0,'2019-12-31');
SELECT MAX(height) FROM wave_heights WHERE location = 'Arctic Ocean';
How many companies have a female CEO in the renewable energy sector?
CREATE TABLE companies (id INT,name TEXT,industry TEXT,ceo_gender TEXT); INSERT INTO companies (id,name,industry,ceo_gender) VALUES (1,'GreenTech','Renewable Energy','Female'); INSERT INTO companies (id,name,industry,ceo_gender) VALUES (2,'CleanEnergy','Energy','Male');
SELECT COUNT(*) FROM companies WHERE industry = 'Renewable Energy' AND ceo_gender = 'Female';
List all artists who have had at least one concert in 'New York' and 'Los Angeles'.
CREATE TABLE Concerts (ConcertID INT,Artist VARCHAR(50),City VARCHAR(50)); INSERT INTO Concerts (ConcertID,Artist,City) VALUES (1,'Taylor Swift','Los Angeles'),(2,'BTS','New York'),(3,'Adele','London'),(4,'Taylor Swift','New York');
SELECT Artist FROM Concerts WHERE City IN ('New York', 'Los Angeles') GROUP BY Artist HAVING COUNT(DISTINCT City) = 2;
What is the total number of successful habitat preservation projects in the 'conservation_projects' table?
CREATE TABLE conservation_projects (id INT,project_name VARCHAR(50),status VARCHAR(10)); INSERT INTO conservation_projects (id,project_name,status) VALUES (1,'Habitat Restoration','Success'),(2,'Community Education','In Progress'),(3,'Species Protection','Success');
SELECT COUNT(*) FROM conservation_projects WHERE status = 'Success';
Find the average ESG score for the Renewable Energy sector, if any investments exist.
CREATE TABLE investments(id INT,sector VARCHAR(20),esg_score INT); INSERT INTO investments VALUES(1,'Tech',85),(2,'Healthcare',75),(3,'Tech',82);
SELECT AVG(esg_score) as avg_esg_score FROM investments WHERE sector = 'Renewable Energy' HAVING COUNT(*) > 0;
List AI models that were added in Q2 2022.
CREATE TABLE AIModels (model_id INT,model_name VARCHAR(50),added_date DATE); INSERT INTO AIModels (model_id,model_name,added_date) VALUES (1,'ModelA','2022-04-15'),(2,'ModelB','2022-05-20'),(3,'ModelC','2022-06-05'),(4,'ModelD','2022-07-18');
SELECT model_name FROM AIModels WHERE added_date BETWEEN '2022-04-01' AND '2022-06-30';
Update the production of Dysprosium in the Brazilian mine for March 2021 to 95.0.
CREATE TABLE mine (id INT,name TEXT,location TEXT,Dysprosium_monthly_production FLOAT,timestamp TIMESTAMP); INSERT INTO mine (id,name,location,Dysprosium_monthly_production,timestamp) VALUES (1,'Australian Mine','Australia',120.5,'2021-03-01'),(2,'Californian Mine','USA',150.3,'2021-03-01'),(3,'Brazilian Mine','Brazil',80.0,'2021-03-01');
UPDATE mine SET Dysprosium_monthly_production = 95.0 WHERE name = 'Brazilian Mine' AND EXTRACT(MONTH FROM timestamp) = 3 AND EXTRACT(YEAR FROM timestamp) = 2021;
What is the maximum ticket price for classical concerts?
CREATE TABLE concert_prices (id INT,type VARCHAR(10),price DECIMAL(5,2)); INSERT INTO concert_prices (id,type,price) VALUES (1,'classical',35.50),(2,'pop',20.00),(3,'classical',40.00),(4,'jazz',28.30);
SELECT MAX(price) FROM concert_prices WHERE type = 'classical';
Who is the top scorer among players from Canada in the 2019 season?
CREATE TABLE players (player_id INT,name TEXT,nationality TEXT,points INT,season INT); INSERT INTO players (player_id,name,nationality,points,season) VALUES (1,'Alice Johnson','Canada',700,2019),(2,'Bob Williams','Canada',600,2019);
SELECT name, MAX(points) FROM players WHERE nationality = 'Canada' AND season = 2019;
What is the maximum community policing score for each precinct?
CREATE TABLE Precincts (PrecinctID INT,Name VARCHAR(50)); CREATE TABLE CommunityPolicing (Score INT,PrecinctID INT);
SELECT P.Name, MAX(CP.Score) as MaxScore FROM Precincts P INNER JOIN CommunityPolicing CP ON P.PrecinctID = CP.PrecinctID GROUP BY P.Name;
Generate a view 'contract_value_summary' to display the total value of defense contracts awarded by year and department
CREATE TABLE defense_contracts (id INT PRIMARY KEY,department VARCHAR(50),year INT,contract_value FLOAT);INSERT INTO defense_contracts (id,department,year,contract_value) VALUES (1,'Army',2018,1000000),(2,'Navy',2018,2000000),(3,'Air Force',2018,1500000),(4,'Army',2019,1200000),(5,'Navy',2019,1800000),(6,'Air Force',2019,2000000);
CREATE VIEW contract_value_summary AS SELECT year, department, SUM(contract_value) as total_contract_value FROM defense_contracts GROUP BY year, department;
What is the total cost of materials for each supplier, grouped by supplier name and product type?
CREATE TABLE material_cost (id INT,supplier_name VARCHAR(50),product_name VARCHAR(50),quantity INT,cost_per_unit DECIMAL(10,2)); INSERT INTO material_cost (id,supplier_name,product_name,quantity,cost_per_unit) VALUES (1,'Green Products Inc.','Solar Panels',50,500.00);
SELECT supplier_name, product_name, SUM(quantity * cost_per_unit) as total_cost FROM material_cost GROUP BY supplier_name, product_name;
What is the average sustainability score of suppliers that provide linen?
CREATE TABLE supplier_sustainability (supplier_id INT,name TEXT,sustainability_score INT); INSERT INTO supplier_sustainability (supplier_id,name,sustainability_score) VALUES (1,'Supplier A',85),(2,'Supplier B',90),(3,'Supplier C',70),(4,'Supplier D',60),(5,'Supplier E',50),(6,'Supplier F',95),(7,'Supplier G',80); CREATE TABLE supplier_materials (supplier_id INT,material TEXT); INSERT INTO supplier_materials (supplier_id,material) VALUES (3,'linen'),(6,'linen'),(7,'linen');
SELECT AVG(sustainability_score) FROM supplier_sustainability s JOIN supplier_materials m ON s.supplier_id = m.supplier_id WHERE material = 'linen';
What is the average speed of vessels that transported dangerous goods in the Pacific Ocean in H1 2021?
CREATE TABLE vessels (id INT,name TEXT,type TEXT,safety_score FLOAT,average_speed FLOAT);CREATE TABLE cargos (id INT,vessel_id INT,material TEXT,destination TEXT,date DATE,weight FLOAT); INSERT INTO vessels (id,name,type,safety_score,average_speed) VALUES (1,'VesselH','Tanker',75,12.5); INSERT INTO cargos (id,vessel_id,material,destination,date,weight) VALUES (1,1,'Dangerous','Pacific','2021-04-01',10000);
SELECT AVG(v.average_speed) FROM vessels v JOIN cargos c ON v.id = c.vessel_id WHERE v.safety_score > 70 AND c.material = 'Dangerous' AND c.destination = 'Pacific' AND c.date BETWEEN '2021-01-01' AND '2021-06-30';
Which is the oldest active satellite in the "satellite_status" table?
CREATE TABLE satellite_status (id INT,name VARCHAR(50),status VARCHAR(20),last_contact_date DATE); INSERT INTO satellite_status (id,name,status,last_contact_date) VALUES (1,'Sat1','Active','2019-01-01'); INSERT INTO satellite_status (id,name,status,last_contact_date) VALUES (2,'Sat2','Active','2022-01-01');
SELECT name, last_contact_date FROM (SELECT name, last_contact_date, ROW_NUMBER() OVER (PARTITION BY status ORDER BY last_contact_date ASC) as row_num FROM satellite_status WHERE status = 'Active') tmp WHERE row_num = 1;
What is the total production output for each manufacturer in the aerospace industry?
CREATE TABLE Manufacturers (id INT,industry VARCHAR(255),name VARCHAR(255),production_output INT); INSERT INTO Manufacturers (id,industry,name,production_output) VALUES (1,'Aerospace','ABC Aerospace',1000),(2,'Aerospace','DEF Aerospace',1500),(3,'Automotive','GHI Automotive',500);
SELECT name, production_output FROM Manufacturers WHERE industry = 'Aerospace';
What is the sum of the weight of shipments sent to the United States from January 5, 2021 to January 10, 2021?
CREATE TABLE ShipmentsUS (id INT,weight FLOAT,destination VARCHAR(20),ship_date DATE); INSERT INTO ShipmentsUS (id,weight,destination,ship_date) VALUES (1,70.3,'United States','2021-01-05'),(2,80.1,'Canada','2021-01-06');
SELECT SUM(weight) FROM ShipmentsUS WHERE destination = 'United States' AND ship_date BETWEEN '2021-01-05' AND '2021-01-10';
What is the ratio of male to female patients diagnosed with heart disease?
CREATE TABLE Patients (PatientID INT,Age INT,Gender TEXT,Diagnosis TEXT,State TEXT); INSERT INTO Patients (PatientID,Age,Gender,Diagnosis,State) VALUES (1,67,'Female','Heart Disease','New York');
SELECT COUNT(*) FILTER (WHERE Gender = 'Male') / COUNT(*) FILTER (WHERE Gender = 'Female') AS Ratio FROM Patients WHERE Diagnosis = 'Heart Disease';
List cybersecurity strategies with a higher success rate than 70%
CREATE TABLE CybersecurityStrategies (Id INT PRIMARY KEY,Name VARCHAR(50),SuccessRate DECIMAL(3,2));
SELECT Name FROM CybersecurityStrategies WHERE SuccessRate > 0.7;
What is the average horsepower of vehicles released in 2020?
CREATE TABLE Vehicles (year INT,make VARCHAR(100),model VARCHAR(100),horsepower INT); INSERT INTO Vehicles (year,make,model,horsepower) VALUES (2015,'Toyota','Corolla',132),(2018,'Honda','Civic',158),(2020,'Tesla','Model 3',263);
SELECT AVG(horsepower) FROM Vehicles WHERE year = 2020;
Which countries had the highest average weight of artifacts?
CREATE TABLE excavation_sites (id INT,site_name VARCHAR(50),location VARCHAR(50),num_artifacts INT,total_funding DECIMAL(10,2));
SELECT country, AVG(weight) as avg_weight FROM artifact_details GROUP BY country ORDER BY avg_weight DESC LIMIT 1
What is the total square footage of inclusive housing units in Oakland?
CREATE TABLE properties (id INT,city VARCHAR(20),square_footage INT,inclusive_housing BOOLEAN); INSERT INTO properties (id,city,square_footage,inclusive_housing) VALUES (1,'Oakland',1200,true); INSERT INTO properties (id,city,square_footage,inclusive_housing) VALUES (2,'Oakland',1500,false);
SELECT SUM(square_footage) FROM properties WHERE city = 'Oakland' AND inclusive_housing = true;
What is the total number of wins for players from the United States?
CREATE TABLE players (id INT,name VARCHAR(50),country VARCHAR(50),wins INT); INSERT INTO players (id,name,country,wins) VALUES (1,'Player1','USA',100),(2,'Player2','Canada',80),(3,'Player3','USA',120);
SELECT SUM(wins) FROM players WHERE country = 'USA';
What is the percentage of tourists who visited historical sites in Africa that also participated in sustainable activities?
CREATE TABLE Visitors (VisitorID INT,Nationality VARCHAR(20),VisitedHistoricalSites BOOLEAN,ParticipatedInSustainableActivities BOOLEAN,Continent VARCHAR(20)); INSERT INTO Visitors (VisitorID,Nationality,VisitedHistoricalSites,ParticipatedInSustainableActivities,Continent) VALUES (1,'Egyptian',true,true,'Africa');
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Visitors WHERE Continent = 'Africa')) as Percentage FROM Visitors WHERE VisitedHistoricalSites = true AND ParticipatedInSustainableActivities = true AND Continent = 'Africa';
Which genetic research projects have a duration greater than 3 years?
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects(id INT,name TEXT,duration INT);INSERT INTO genetics.research_projects(id,name,duration) VALUES (1,'ProjectA',48),(2,'ProjectB',24),(3,'ProjectC',60);
SELECT name FROM genetics.research_projects WHERE duration > 36;