instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average safety rating of all creative AI applications in the 'ai_applications' table? | CREATE TABLE ai_applications (app_id INT,app_name TEXT,safety_rating FLOAT); | SELECT AVG(safety_rating) FROM ai_applications; |
List the product names and their sourced ingredients, ordered by the ingredient cost, for products from 'The Body Shop'? | CREATE TABLE ingredients (ingredient_id INT,ingredient VARCHAR(255),product_id INT,price DECIMAL(5,2),gram_weight DECIMAL(5,2)); CREATE TABLE products (product_id INT,product_name VARCHAR(255),brand VARCHAR(255)); INSERT INTO ingredients (ingredient_id,ingredient,product_id,price,gram_weight) VALUES (1,'Aqua',1,0.01,10... | SELECT products.product_name, ingredients.ingredient, ingredients.price FROM ingredients JOIN products ON ingredients.product_id = products.product_id WHERE products.brand = 'The Body Shop' ORDER BY ingredients.price DESC; |
How many articles published in 2019 were written by Latinx authors about disinformation? | CREATE TABLE articles (id INT,title TEXT,publication_year INT,topic TEXT,author TEXT); INSERT INTO articles (id,title,publication_year,topic,author) VALUES (1,'Article1',2019,'Disinformation','Latinx Author1'); INSERT INTO articles (id,title,publication_year,topic,author) VALUES (2,'Article2',2018,'Politics','Author2')... | SELECT COUNT(*) FROM articles WHERE publication_year = 2019 AND topic = 'Disinformation' AND author IN (SELECT author FROM authors WHERE ethnicity = 'Latinx'); |
What is the minimum waste generation in the state of New York? | CREATE TABLE waste_generation (state VARCHAR(2),generation INT); INSERT INTO waste_generation (state,generation) VALUES ('CA',5000000),('NY',4000000),('NJ',3000000); | SELECT MIN(generation) FROM waste_generation WHERE state = 'NY'; |
What is the average carbon price (in USD/tonne) in Canada in 2019 and 2020? | CREATE TABLE CarbonPrices (id INT,country VARCHAR(50),year INT,price FLOAT); INSERT INTO CarbonPrices (id,country,year,price) VALUES (1,'Canada',2020,22.34),(2,'Canada',2019,18.97),(3,'USA',2020,14.56); | SELECT AVG(price) FROM CarbonPrices WHERE country = 'Canada' AND year IN (2019, 2020); |
Update the 'game_downloads' table to set the 'download_count' column as 10000 for the game 'Game2' in the 'North America' region | CREATE TABLE game_downloads (download_id INT,game_name VARCHAR(100),download_count INT,region VARCHAR(50),date DATE); | UPDATE game_downloads SET download_count = 10000 WHERE game_name = 'Game2' AND region = 'North America'; |
What is the average number of years of union membership per gender? | CREATE TABLE union_members (id INT,member_id INT,gender VARCHAR(6),years_of_membership INT); INSERT INTO union_members (id,member_id,gender,years_of_membership) VALUES (1,1001,'Male',5),(2,1002,'Female',10),(3,1003,'Male',7),(4,1004,'Non-binary',3); | SELECT gender, AVG(years_of_membership) OVER (PARTITION BY gender) AS avg_years_of_membership FROM union_members; |
Identify the top 5 regions with the highest monthly mobile and broadband network infrastructure investment, including the region name, total investment amount, and average investment per capita. | CREATE TABLE region_investment (region_name VARCHAR(50),investment_amount FLOAT,population INT); | SELECT region_name, SUM(investment_amount) as total_investment, AVG(investment_amount / population) as avg_investment_per_capita FROM region_investment WHERE investment_type IN ('mobile', 'broadband') GROUP BY region_name ORDER BY total_investment DESC LIMIT 5; |
What is the percentage of the population that has access to clean water in Southeast Asia? | CREATE TABLE WaterData (Country VARCHAR(50),Population INT,CleanWaterPopulation INT); INSERT INTO WaterData (Country,Population,CleanWaterPopulation) VALUES ('Indonesia',273523615,221523615),('Philippines',113523615,81523615); | SELECT Country, (CleanWaterPopulation / Population) * 100 AS PercentCleanWater FROM WaterData WHERE Country IN ('Indonesia', 'Philippines'); |
What is the average sustainable fabric cost per order for each region in the past month? | CREATE TABLE orders (order_id INT,region VARCHAR(50),sustainable_fabric_cost DECIMAL(5,2)); | SELECT region, AVG(sustainable_fabric_cost) FROM orders WHERE sustainable = TRUE AND order_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY region; |
List the names of athletes who have won a gold medal in the olympic_athletes table. | CREATE TABLE olympic_athletes (athlete_id INT,name VARCHAR(50),sport VARCHAR(20),country VARCHAR(50),gold_medals INT); INSERT INTO olympic_athletes (athlete_id,name,sport,country,gold_medals) VALUES (1,'Usain Bolt','Track and Field','Jamaica',8); INSERT INTO olympic_athletes (athlete_id,name,sport,country,gold_medals) ... | SELECT name FROM olympic_athletes WHERE gold_medals > 0; |
What is the average production quantity (in metric tons) of Neodymium from mines located in Australia? | CREATE TABLE mines (id INT,name TEXT,location TEXT,production_quantity INT); INSERT INTO mines (id,name,location,production_quantity) VALUES (1,'Greenbushes','Australia',3500),(2,'Mount Weld','Australia',6000); | SELECT AVG(production_quantity) FROM mines WHERE location = 'Australia' AND element = 'Neodymium'; |
What is the average number of employees per mining site, grouped by mineral type, for mining sites having a production date on or after 2014-01-01? | CREATE TABLE mining_site (site_id INT,mineral_type VARCHAR(50),production_date DATE,num_employees INT); INSERT INTO mining_site (site_id,mineral_type,production_date,num_employees) VALUES (1,'gold','2014-01-02',60),(2,'copper','2013-12-31',150),(3,'gold','2016-03-04',20),(4,'copper','2015-06-10',50); | SELECT mineral_type, AVG(num_employees) as avg_employees FROM mining_site WHERE production_date >= '2014-01-01' GROUP BY mineral_type; |
How many spacecraft were manufactured by each company? | CREATE TABLE Spacecraft (ID INT PRIMARY KEY,Name TEXT,Manufacturer TEXT); CREATE TABLE Manufacturers (ID INT PRIMARY KEY,Name TEXT); | SELECT m.Name, COUNT(s.ID) as Manufactured_Spacecraft FROM Manufacturers m INNER JOIN Spacecraft s ON m.Name = s.Manufacturer GROUP BY m.Name; |
What is the total amount donated by each donor in 2021? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationDate DATE,DonationAmount FLOAT); INSERT INTO Donors (DonorID,DonorName,DonationDate,DonationAmount) VALUES (1,'John Smith','2021-01-01',50.00),(2,'Jane Doe','2021-02-14',100.00); | SELECT DonorName, SUM(DonationAmount) as TotalDonation FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorName; |
What is the total funding for biotech startups in California? | CREATE TABLE startups (id INT,name VARCHAR(100),location VARCHAR(50),industry VARCHAR(50),funding FLOAT); INSERT INTO startups (id,name,location,industry,funding) VALUES (1,'StartupA','CA','Biotech',3000000.0); INSERT INTO startups (id,name,location,industry,funding) VALUES (2,'StartupB','CA','Biotech',6000000.0); INSE... | SELECT SUM(funding) FROM startups WHERE location = 'CA' AND industry = 'Biotech'; |
What are the names and locations of all language preservation programs in the Asia-Pacific region? | CREATE TABLE language_preservation (id INT,name TEXT,location TEXT); INSERT INTO language_preservation (id,name,location) VALUES (1,'Hawaiian Language Immersion Program','Hawaii,USA'),(2,'Ainu Language Revitalization Project','Hokkaido,Japan'); | SELECT name, location FROM language_preservation WHERE location LIKE '%%Asia-Pacific%%'; |
What are the most popular fabric types in the Asian market? | CREATE TABLE Sales (sale_id INT,product_id INT,quantity INT,price DECIMAL(10,2),customer_id INT); CREATE TABLE Inventory (product_id INT,product_name VARCHAR(255),fabric_type VARCHAR(255)); CREATE TABLE Geography (customer_id INT,country VARCHAR(255),region VARCHAR(255)); | SELECT I.fabric_type, COUNT(S.sale_id) AS sales_count FROM Sales S INNER JOIN Inventory I ON S.product_id = I.product_id INNER JOIN Geography G ON S.customer_id = G.customer_id WHERE G.region = 'Asia' GROUP BY I.fabric_type ORDER BY sales_count DESC; |
What is the total amount of socially responsible loans issued by Sustainable Bank in Q2 2022? | CREATE TABLE SustainableBank (id INT,loan_type VARCHAR(20),amount INT,issue_date DATE); INSERT INTO SustainableBank (id,loan_type,amount,issue_date) VALUES (1,'SociallyResponsible',4000,'2022-04-01'); | SELECT SUM(amount) FROM SustainableBank WHERE loan_type = 'SociallyResponsible' AND QUARTER(issue_date) = 2 AND YEAR(issue_date) = 2022; |
Delete records of the 'Beluga Whale' species from the 'species_observation' table. | CREATE TABLE species_observation (id INT PRIMARY KEY,year INT,species VARCHAR(255),location VARCHAR(255),number INT); INSERT INTO species_observation (id,year,species,location,number) VALUES (1,2010,'Polar Bear','Arctic',300),(2,2015,'Beluga Whale','Arctic',120); | DELETE FROM species_observation WHERE species = 'Beluga Whale'; |
Count of community health workers who have completed health equity metric trainings. | CREATE TABLE CommunityHealthWorkers (CHWId INT,Name VARCHAR(50)); CREATE TABLE HealthEquityMetricTrainings (HEMTrainingId INT,CHWId INT,TrainingDate DATE); INSERT INTO CommunityHealthWorkers (CHWId,Name) VALUES (1,'Jasmine'),(2,'Kareem'),(3,'Leah'),(4,'Mohammed'); INSERT INTO HealthEquityMetricTrainings (HEMTrainingId,... | SELECT COUNT(DISTINCT CHWId) FROM HealthEquityMetricTrainings; |
How many new broadband subscribers have there been in each state in the past week? | CREATE TABLE broadband_subscribers (subscriber_id INT,subscriber_name VARCHAR(255),subscribe_date DATE,state VARCHAR(255)); | SELECT state, COUNT(subscriber_id) as new_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY state; |
What are the names of the projects in the 'Transportation' table? | CREATE TABLE Transportation (project_id INT,project_name VARCHAR(50),location VARCHAR(50)); INSERT INTO Transportation (project_id,project_name,location) VALUES (1,'Bridge Replacement','Texas'); INSERT INTO Transportation (project_id,project_name,location) VALUES (2,'Road Construction','Florida'); | SELECT project_name FROM Transportation; |
Which countries do not have any warehouse locations for the company? | CREATE TABLE warehouses (id INT,company_id INT,country VARCHAR(255));INSERT INTO warehouses (id,company_id,country) VALUES (1,1,'USA'),(2,1,'Canada'),(3,2,'USA'); | SELECT country FROM warehouses GROUP BY country HAVING COUNT(company_id) = 1; |
How many mining permits were issued in California between 2015 and 2020, and what was the environmental impact assessment score for each permit? | CREATE TABLE mining_permits (id INT,state VARCHAR(255),year INT,assessment_score INT); | SELECT state, year, assessment_score FROM mining_permits WHERE state = 'California' AND year BETWEEN 2015 AND 2020; |
What is the number of employees of each job title per mining company? | CREATE TABLE employees (employee_id INT,name TEXT,gender TEXT,job_title TEXT,mining_company_id INT); INSERT INTO employees (employee_id,name,gender,job_title,mining_company_id) VALUES (1,'Rami Hamad','Male','Miner',1001),(2,'Sophia Nguyen','Female','Engineer',1001),(3,'Carlos Mendoza','Male','Miner',1002),(4,'Amina Dio... | SELECT company_name, job_title, COUNT(*) AS employee_count FROM employees JOIN mining_companies ON employees.mining_company_id = mining_companies.mining_company_id GROUP BY company_name, job_title; |
List all healthcare providers with cultural competency score greater than or equal to 0.9 | CREATE TABLE healthcare.CulturalCompetency(cc_id INT PRIMARY KEY,healthcare_provider VARCHAR(100),cultural_competency_score FLOAT); INSERT INTO healthcare.CulturalCompetency (cc_id,healthcare_provider,cultural_competency_score) VALUES (1,'Dr. Ravi Shankar',0.88),(2,'Dr. Chen Wei',0.91),(3,'Dr. Souad Haddad',0.93),(4,'D... | SELECT * FROM healthcare.CulturalCompetency WHERE cultural_competency_score >= 0.9; |
Identify the ethnicity and gender diversity among the employees in the 'Workforce Development' program. | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Department VARCHAR(50),Ethnicity VARCHAR(50),Gender VARCHAR(50)); INSERT INTO Employees (EmployeeID,FirstName,LastName,Department,Ethnicity,Gender) VALUES (1,'John','Doe','Workforce Development','Hispanic','Male'),(2,'Jane','Doe','Quality... | SELECT DISTINCT Ethnicity, Gender FROM Employees WHERE Department = 'Workforce Development'; |
Which defense contractor has the highest average contract value for satellite technology in the last 12 months? | CREATE TABLE ContractNegotiations (ContractID INT,Company VARCHAR(50),Equipment VARCHAR(50),NegotiationDate DATE,ContractValue DECIMAL(10,2)); INSERT INTO ContractNegotiations (ContractID,Company,Equipment,NegotiationDate,ContractValue) VALUES (3,'Lockheed Martin','Satellite Technology','2021-06-30',5000000); INSERT IN... | SELECT Company, AVG(ContractValue) AS AverageContractValue FROM ContractNegotiations WHERE Equipment = 'Satellite Technology' AND NegotiationDate >= DATEADD(month, -12, GETDATE()) GROUP BY Company ORDER BY AverageContractValue DESC |
How many players who identify as non-binary have used AR technology in gaming? | CREATE TABLE PlayerIdentities (PlayerID INT,Identity VARCHAR(50)); INSERT INTO PlayerIdentities (PlayerID,Identity) VALUES (1,'Male'),(2,'Female'),(3,'Non-Binary'),(4,'Male'),(5,'Female'),(6,'Non-Binary'); CREATE TABLE PlayerTechnologies (PlayerID INT,Technology VARCHAR(50)); INSERT INTO PlayerTechnologies (PlayerID,Te... | (SELECT COUNT(*) FROM PlayerIdentities JOIN PlayerTechnologies ON PlayerIdentities.PlayerID = PlayerTechnologies.PlayerID WHERE PlayerIdentities.Identity = 'Non-Binary' AND PlayerTechnologies.Technology = 'AR') |
What is the percentage of students who have completed a lifelong learning course in 'East High' school? | CREATE TABLE students_lifelong_learning (student_id INT,school_id INT,completed_course INT); INSERT INTO students_lifelong_learning VALUES (1,1,1); INSERT INTO students_lifelong_learning VALUES (2,1,0); INSERT INTO students_lifelong_learning VALUES (3,2,1); INSERT INTO students_lifelong_learning VALUES (4,2,1); CREATE ... | SELECT s.school_name, 100.0 * SUM(CASE WHEN sl.completed_course = 1 THEN 1 ELSE 0 END) / COUNT(sr.student_id) AS completion_percentage FROM school_roster sr INNER JOIN students_lifelong_learning sl ON sr.student_id = sl.student_id INNER JOIN schools s ON sr.school_id = s.school_id WHERE s.school_name = 'East High' GROU... |
What is the average occupancy rate of hotels in Paris? | CREATE TABLE hotels (hotel_id INT,name TEXT,city TEXT,country TEXT,occupancy_rate DECIMAL(5,2)); INSERT INTO hotels (hotel_id,name,city,country,occupancy_rate) VALUES (1,'Hotel Ritz','Paris','France',0.85); | SELECT AVG(occupancy_rate) FROM hotels WHERE city = 'Paris'; |
List all records from 'farmers' table sorted by age | CREATE TABLE farmers (id INT PRIMARY KEY,name VARCHAR(100),age INT,gender VARCHAR(10),location VARCHAR(50)); | SELECT * FROM farmers ORDER BY age; |
What is the total number of news articles published in 2021, in the news_articles table? | CREATE TABLE news_articles (id INT,title TEXT,publish_date DATE); INSERT INTO news_articles (id,title,publish_date) VALUES (1,'Article 1','2021-01-01'); INSERT INTO news_articles (id,title,publish_date) VALUES (2,'Article 2','2021-02-15'); | SELECT COUNT(*) FROM news_articles WHERE publish_date >= '2021-01-01' AND publish_date < '2022-01-01'; |
Delete shared EVs with less than 80% battery in Seoul | CREATE TABLE shared_evs (id INT,ev_battery_level INT,ev_status VARCHAR(50),ev_city VARCHAR(50)); | DELETE FROM shared_evs WHERE ev_status = 'shared' AND ev_city = 'Seoul' AND ev_battery_level < 80; |
What is the maximum calorie count for meals served at fine dining restaurants? | CREATE TABLE meals (id INT,name TEXT,restaurant_type TEXT); INSERT INTO meals (id,name,restaurant_type) VALUES (1,'Filet Mignon','fine dining'),(2,'Chicken Caesar','casual dining'),(3,'Tofu Stir Fry','fine dining'); CREATE TABLE nutrition (meal_id INT,calorie_count INT); INSERT INTO nutrition (meal_id,calorie_count) VA... | SELECT MAX(nutrition.calorie_count) FROM nutrition JOIN meals ON nutrition.meal_id = meals.id WHERE meals.restaurant_type = 'fine dining'; |
What is the total mass of spacecraft manufactured by 'National Aeronautics and Space Administration' in the USA, grouped by the decade of their manufacture? | CREATE TABLE SpacecraftManufacturing (Manufacturer VARCHAR(255),Country VARCHAR(255),SpacecraftModel VARCHAR(255),SpacecraftMass INT,ManufactureDate DATE); INSERT INTO SpacecraftManufacturing (Manufacturer,Country,SpacecraftModel,SpacecraftMass,ManufactureDate) VALUES ('National Aeronautics and Space Administration','U... | SELECT CONCAT(DATE_FORMAT(ManufactureDate, '%Y'), '0-', DATE_FORMAT(DATE_ADD(ManufactureDate, INTERVAL 10 YEAR), '%Y')) AS Decade, SUM(SpacecraftMass) AS Total_Spacecraft_Mass FROM SpacecraftManufacturing WHERE Manufacturer = 'National Aeronautics and Space Administration' GROUP BY Decade; |
Year-over-year percentage change in energy consumption from 2020 to 2025? | CREATE TABLE energy_consumption_yearly (year INT,consumption FLOAT); INSERT INTO energy_consumption_yearly (year,consumption) VALUES (2020,50000.0),(2021,55000.1),(2022,60000.2),(2023,65000.3),(2024,70000.4),(2025,75000.5); | SELECT ec1.year + INTERVAL '1 year' AS year, (ec2.consumption - ec1.consumption) / ec1.consumption * 100.0 AS percentage_change FROM energy_consumption_yearly ec1 JOIN energy_consumption_yearly ec2 ON ec1.year + 1 = ec2.year; |
What is the earliest discovery date for an exoplanet? | CREATE TABLE exoplanets (id INT,name VARCHAR(255),discovery_date DATE,discovery_method VARCHAR(255)); | SELECT MIN(exoplanets.discovery_date) FROM exoplanets; |
Identify all ships in the 'Caribbean' region with an overspeeding incident in the last month.' | CREATE TABLE ships (name VARCHAR(50),region VARCHAR(20),last_inspection_date DATE); INSERT INTO ships (name,region,last_inspection_date) VALUES ('Ship A','Caribbean','2022-02-15'),('Ship B','Caribbean','2022-03-01'),('Ship C','Atlantic','2022-03-10'); | SELECT * FROM ships WHERE region = 'Caribbean' AND last_inspection_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND last_inspection_date NOT IN (SELECT last_inspection_date FROM ships WHERE region = 'Caribbean' AND speed_violation = 'yes'); |
What is the average age of patients in the 'rural_clinic_1' table? | CREATE TABLE rural_clinic_1 (patient_id INT,age INT,gender VARCHAR(10)); INSERT INTO rural_clinic_1 (patient_id,age,gender) VALUES (1,35,'Male'),(2,50,'Female'),(3,42,'Male'); | SELECT AVG(age) FROM rural_clinic_1; |
How many athletes participate in each sport in the Wellbeing program? | CREATE TABLE athletes (id INT,name VARCHAR(100),sport VARCHAR(50),wellbeing_program BOOLEAN); INSERT INTO athletes (id,name,sport,wellbeing_program) VALUES (1,'Alice','Soccer',TRUE); INSERT INTO athletes (id,name,sport,wellbeing_program) VALUES (2,'Bella','Basketball',TRUE); INSERT INTO athletes (id,name,sport,wellbein... | SELECT sport, COUNT(*) FROM athletes WHERE wellbeing_program = TRUE GROUP BY sport; |
List the number of papers published by each author in the field of Explainable AI, ordered by the most prolific? | CREATE TABLE paper_data (paper_id INT,author_id INT,field VARCHAR(50),publication_year INT); CREATE TABLE author_data (author_id INT,author_name VARCHAR(50)); | SELECT a.author_name, COUNT(pd.paper_id) as num_papers FROM paper_data pd JOIN author_data a ON pd.author_id = a.author_id WHERE pd.field = 'Explainable AI' GROUP BY a.author_name ORDER BY num_papers DESC; |
What is the minimum mental health parity violation cost in the 'MentalHealthParity' table, where the violation type is 'Service'? | CREATE TABLE MentalHealthParity (ViolationID INT,ViolationType VARCHAR(255),ViolationCost FLOAT); | SELECT MIN(ViolationCost) as Min_Cost FROM MentalHealthParity WHERE ViolationType = 'Service'; |
What is the recycling rate for each material type in Canada in 2018? | CREATE TABLE recycling_rates_canada(year INT,material VARCHAR(20),recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates_canada VALUES (2018,'Plastic',0.2),(2018,'Glass',0.3),(2018,'Metal',0.4); | SELECT material, AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates_canada WHERE year = 2018 GROUP BY material; |
What is the total number of patients diagnosed with Ebola in Democratic Republic of Congo in 2021? | CREATE TABLE Patients (ID INT,Gender VARCHAR(10),Disease VARCHAR(20),Country VARCHAR(30),Diagnosis_Date DATE); INSERT INTO Patients (ID,Gender,Disease,Country,Diagnosis_Date) VALUES (1,'Male','Ebola','Democratic Republic of Congo','2021-01-01'); | SELECT COUNT(*) FROM Patients WHERE Disease = 'Ebola' AND Country = 'Democratic Republic of Congo' AND YEAR(Diagnosis_Date) = 2021; |
What is the average energy efficiency rating of solar farms in India? | CREATE TABLE solar_farms (id INT,name TEXT,country TEXT,energy_efficiency_rating FLOAT); INSERT INTO solar_farms (id,name,country,energy_efficiency_rating) VALUES (1,'Kamuthi','India',0.18),(2,'Bhadla','India',0.19); | SELECT AVG(energy_efficiency_rating) FROM solar_farms WHERE country = 'India'; |
List all courses and their duration from the 'courses' table | CREATE TABLE courses (course_id INT,course_name VARCHAR(50),course_duration VARCHAR(20)); | SELECT course_name, course_duration FROM courses; |
Delete records of discontinued cosmetic products from the Products table. | CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),IsDiscontinued BOOLEAN); INSERT INTO Products (ProductID,ProductName,IsDiscontinued) VALUES (1,'Lip Balm',false),(2,'Face Cream',true),(3,'Moisturizer',false); | DELETE FROM Products WHERE IsDiscontinued = true; |
What is the total mass (in kg) of all spacecraft manufactured by Blue Origin? | CREATE TABLE spacecraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),mass FLOAT); INSERT INTO spacecraft (id,name,manufacturer,mass) VALUES (1,'New Glenn','Blue Origin',720000.0); INSERT INTO spacecraft (id,name,manufacturer,mass) VALUES (2,'Shepard','Blue Origin',3200.0); | SELECT SUM(mass) FROM spacecraft WHERE manufacturer = 'Blue Origin'; |
List the regions and total number of relief camps for each region in the 'relief_camps' table. | CREATE TABLE relief_camps (id INT,region VARCHAR(50),num_beneficiaries INT); INSERT INTO relief_camps (id,region,num_beneficiaries) VALUES (1,'Asia',600),(2,'Africa',300),(3,'Europe',700),(4,'South America',400),(5,'North America',500); | SELECT region, COUNT(*) as total_relief_camps FROM relief_camps GROUP BY region; |
Unpivot the 'students' table to display student name and grade level in separate rows | CREATE TABLE students (student_id INT,name_grade VARCHAR(50)); | SELECT student_id, UNNEST(STRING_TO_ARRAY(name_grade, ' ')) AS student_details FROM students; |
List the names of all farmers in Nepal who have adopted innovative agricultural practices and the number of acres they cultivate? | CREATE TABLE farmers (id INT,name VARCHAR(50),acres FLOAT,country VARCHAR(50)); INSERT INTO farmers (id,name,acres,country) VALUES (1,'Ram',5.0,'Nepal'); CREATE TABLE innovative_practices (farmer_id INT,practice VARCHAR(50)); INSERT INTO innovative_practices (farmer_id,practice) VALUES (1,'System of Rice Intensificatio... | SELECT f.name, f.acres FROM farmers f INNER JOIN innovative_practices ip ON f.id = ip.farmer_id WHERE f.country = 'Nepal'; |
What are the average preference scores for organic cosmetic products? | CREATE TABLE consumer_preferences (product_id INT,product_name VARCHAR(255),preference_score FLOAT,organic BOOLEAN); | SELECT AVG(preference_score) FROM consumer_preferences WHERE organic = TRUE; |
How many items are there in each category? | CREATE TABLE Menu (menu_id INT PRIMARY KEY,item_name VARCHAR(255),category VARCHAR(255),price DECIMAL(5,2)); | SELECT category, COUNT(*) FROM Menu GROUP BY category; |
What is the total revenue for each platform? | CREATE TABLE Platform (PlatformID INT,Name VARCHAR(50),Revenue INT); | SELECT Platform.Name, SUM(Platform.Revenue) as TotalRevenue FROM Platform GROUP BY Platform.Name; |
What is the total number of open pedagogy courses offered by each institution? | CREATE TABLE institution (institution_id INT,institution_name VARCHAR(255)); CREATE TABLE open_pedagogy_courses (institution_id INT,course_id INT); INSERT INTO institution (institution_id,institution_name) VALUES (2001,'Institution X'),(2002,'Institution Y'),(2003,'Institution Z'); INSERT INTO open_pedagogy_courses (in... | SELECT institution_name, COUNT(course_id) as total_courses FROM institution JOIN open_pedagogy_courses ON institution.institution_id = open_pedagogy_courses.institution_id GROUP BY institution_name; |
Update the Gender of the community health worker with Age 45 in 'BC' 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'); | UPDATE CommunityHealthWorkersCanada SET Gender = 'Non-binary' WHERE Age = 45 AND Province = 'BC'; |
Which teams have a higher average ticket sales than the average ticket sales for all teams? | CREATE TABLE teams (team_id INT,team_name VARCHAR(255)); INSERT INTO teams (team_id,team_name) VALUES (1,'Knights'),(2,'Lions'),(3,'Titans'); CREATE TABLE events (event_id INT,team_id INT,num_tickets_sold INT); INSERT INTO events (event_id,team_id,num_tickets_sold) VALUES (1,1,500),(2,1,700),(3,2,600),(4,3,800),(5,3,90... | SELECT e.team_id, AVG(e.num_tickets_sold) as avg_tickets_sold FROM events e GROUP BY e.team_id HAVING AVG(e.num_tickets_sold) > (SELECT AVG(e.num_tickets_sold) FROM events e); |
What is the average price of traditional art pieces by artist and their total number? | CREATE TABLE ArtPieces (id INT,artist VARCHAR(255),type VARCHAR(255),price FLOAT); INSERT INTO ArtPieces (id,artist,type,price) VALUES (1,'Picasso','Painting',1000),(2,'Michelangelo','Sculpture',1500),(3,'Van Gogh','Painting',800); | SELECT artist, AVG(price), COUNT(*) FROM ArtPieces GROUP BY artist; |
Find the most popular electric vehicle model in each country | CREATE TABLE ElectricVehicles (Vehicle VARCHAR(50),Manufacturer VARCHAR(50),Year INT,Range INT,Country VARCHAR(50)); INSERT INTO ElectricVehicles (Vehicle,Manufacturer,Year,Range,Country) VALUES ('Chevy Bolt EV','Chevrolet',2022,259,'USA'); CREATE VIEW VehicleCountries AS SELECT Vehicle,Country FROM ElectricVehicles; | SELECT Vehicle, Country, COUNT(*) as num_of_vehicles FROM VehicleCountries GROUP BY Vehicle, Country HAVING COUNT(*) = (SELECT MAX(num_of_vehicles) FROM (SELECT Vehicle, Country, COUNT(*) as num_of_vehicles FROM VehicleCountries GROUP BY Vehicle, Country) as VCGroup) GROUP BY Vehicle, Country; |
What is the total number of visitors from underrepresented communities for visual arts programs and workshops, separated by age group? | CREATE TABLE visual_arts_programs (id INT,visitor_age INT,underrepresented_community BOOLEAN,visit_date DATE); CREATE TABLE workshops (id INT,visitor_age INT,underrepresented_community BOOLEAN,visit_date DATE); | SELECT 'Visual Arts Programs' AS event, visitor_age, COUNT(*) AS total FROM visual_arts_programs WHERE underrepresented_community = TRUE GROUP BY visitor_age UNION ALL SELECT 'Workshops' AS event, visitor_age, COUNT(*) AS total FROM workshops WHERE underrepresented_community = TRUE GROUP BY visitor_age; |
What is the minimum crime rate per 1000 residents in the state of California and in New York? | CREATE TABLE crime_rates (id INT,state VARCHAR(20),rate_per_1000_residents INT); INSERT INTO crime_rates (id,state,rate_per_1000_residents) VALUES (1,'California',18),(2,'California',15),(3,'New York',22),(4,'New York',20); | SELECT MIN(rate_per_1000_residents) FROM crime_rates WHERE state IN ('California', 'New York'); |
What is the total cost of construction permits issued in Los Angeles in Q2 of 2019? | CREATE TABLE Permit_Data_LA (PermitID INT,City VARCHAR(50),Quarter INT,Year INT,Cost FLOAT); | SELECT SUM(Cost) FROM Permit_Data_LA WHERE City = 'Los Angeles' AND Quarter = 2 AND Year = 2019; |
What is the total sales for each menu category, ordered by total sales in descending order? | CREATE TABLE menu_sales(menu_category VARCHAR(50),sales INT); INSERT INTO menu_sales VALUES ('Appetizers',300),('Entrees',800),('Desserts',500); | SELECT menu_category, SUM(sales) AS total_sales FROM menu_sales GROUP BY menu_category ORDER BY total_sales DESC; |
Count the number of military equipment maintenance requests for each type of equipment in the state of New York | CREATE TABLE military_equipment (equipment_id INT,name VARCHAR(255),type VARCHAR(255),maintenance_cost DECIMAL(10,2),state VARCHAR(2)); CREATE TABLE maintenance_requests (request_id INT,equipment_id INT,request_date DATE,branch VARCHAR(255)); | SELECT equipment_type, COUNT(*) as num_requests FROM military_equipment JOIN maintenance_requests ON military_equipment.equipment_id = maintenance_requests.equipment_id WHERE state = 'New York' GROUP BY equipment_type; |
Who are the top 3 cities with the most international news stories in the past month? | CREATE TABLE stories (id INT,city VARCHAR(20),date DATE); CREATE TABLE categories (id INT,category VARCHAR(20)); INSERT INTO stories VALUES (2,'Los Angeles','2022-01-05'); INSERT INTO categories VALUES (2,'international news'); | SELECT city, COUNT(*) as story_count FROM stories INNER JOIN categories ON stories.id = categories.id WHERE stories.date >= '2022-02-01' GROUP BY city ORDER BY story_count DESC LIMIT 3; |
What is the average yield of crops for each crop type in the organic farming dataset? | CREATE TABLE organic_farming (id INT,crop_type VARCHAR(255),yield INT); | SELECT crop_type, AVG(yield) FROM organic_farming GROUP BY crop_type; |
What is the total number of emergency incidents recorded per community policing station? | CREATE TABLE community_policing_station (id INT,name TEXT,location TEXT); INSERT INTO community_policing_station (id,name,location) VALUES (1,'Station A','City Center'),(2,'Station B','North District'); CREATE TABLE emergency_incidents (id INT,station_id INT,type TEXT,date DATE); INSERT INTO emergency_incidents (id,sta... | SELECT s.name, COUNT(e.id) as total_incidents FROM community_policing_station s JOIN emergency_incidents e ON s.id = e.station_id GROUP BY s.id; |
List the top 3 donors by total donation amount and their respective rank. | CREATE TABLE top_donors (donor_id INT,donor_name TEXT,total_donations DECIMAL(10,2)); INSERT INTO top_donors VALUES (1,'John Doe',1500.00),(2,'Jane Smith',700.00),(3,'Alice Johnson',800.00),(4,'Bob Jones',500.00); | SELECT donor_id, donor_name, total_donations, RANK() OVER (ORDER BY total_donations DESC) as donor_rank FROM top_donors; |
What is the number of farmers in each farming system and the total production for each farming system? | CREATE TABLE farming_system_data (farmer_id INT,farming_system TEXT,production INT); INSERT INTO farming_system_data (farmer_id,farming_system,production) VALUES (1,'Agroforestry',200),(2,'Agroforestry',250),(3,'Permaculture',150),(4,'Permaculture',180),(5,'Organic',220),(6,'Organic',250),(7,'Conventional',170),(8,'Con... | SELECT farming_system, COUNT(*) as num_farmers, SUM(production) as total_production FROM farming_system_data GROUP BY farming_system; |
Determine the dishes that have not been sold in the last 30 days | CREATE TABLE sales_data (sale_id INT,dish_id INT,sale_date DATE); INSERT INTO sales_data (sale_id,dish_id,sale_date) VALUES (1,1,'2022-01-01'),(2,2,'2022-01-05'),(3,1,'2022-01-10'); CREATE TABLE menu (dish_id INT,dish_name VARCHAR(255),dish_type VARCHAR(255)); INSERT INTO menu (dish_id,dish_name,dish_type) VALUES (1,'Q... | SELECT m.dish_id, m.dish_name FROM menu m LEFT JOIN sales_data s ON m.dish_id = s.dish_id WHERE s.sale_date < DATE_SUB(CURDATE(), INTERVAL 30 DAY) IS NULL; |
Find the average temperature and humidity for the crops in field 1 during March 2021. | CREATE TABLE field_sensors (field_id INT,sensor_type VARCHAR(20),value FLOAT,timestamp TIMESTAMP); INSERT INTO field_sensors (field_id,sensor_type,value,timestamp) VALUES (1,'temperature',22.5,'2021-03-01 10:00:00'),(1,'humidity',60.0,'2021-03-01 10:00:00'); | SELECT AVG(value) FROM field_sensors WHERE field_id = 1 AND sensor_type IN ('temperature', 'humidity') AND MONTH(timestamp) = 3 AND YEAR(timestamp) = 2021; |
Add a new excavation site 'SiteG' from the 'Stone Age' period and related artifacts. | CREATE TABLE ExcavationSites (site_id INT,site_name TEXT,period TEXT); INSERT INTO ExcavationSites (site_id,site_name,period) VALUES (1,'SiteA','Stone Age'),(2,'SiteB','Iron Age'); CREATE TABLE Artifacts (artifact_id INT,site_id INT,artifact_name TEXT); INSERT INTO Artifacts (artifact_id,site_id,artifact_name) VALUES (... | INSERT INTO ExcavationSites (site_id, site_name, period) VALUES (3, 'SiteG', 'Stone Age'); INSERT INTO Artifacts (artifact_id, site_id, artifact_name) VALUES (4, 3, 'Artifact4'), (5, 3, 'Artifact5'); |
find the average age of trees in the forestry schema, excluding eucalyptus trees | CREATE SCHEMA forestry; CREATE TABLE trees (id INT,species VARCHAR(50),age INT); INSERT INTO trees (id,species,age) VALUES (1,'oak',50),(2,'pine',30),(3,'eucalyptus',15); | SELECT AVG(age) FROM forestry.trees WHERE species NOT IN ('eucalyptus'); |
What is the average number of monthly listeners for country music artists on Spotify in 2021? | CREATE TABLE listeners (id INT,artist_id INT,platform VARCHAR(255),date DATE,listeners INT); INSERT INTO listeners (id,artist_id,platform,date,listeners) VALUES (1,1,'Spotify','2021-01-01',100000); | SELECT AVG(listeners) FROM listeners WHERE platform = 'Spotify' AND genre = 'Country' AND YEAR(date) = 2021 GROUP BY artist_id; |
Which suppliers provide more than 50% of the organic produce for our stores in the EU? | CREATE TABLE suppliers (id INT,name VARCHAR(50),organic_produce_percentage DECIMAL(5,2)); INSERT INTO suppliers (id,name,organic_produce_percentage) VALUES (1,'ABC Farms',0.6),(2,'XYZ Orchards',0.45),(3,'Green Grocers',0.9); CREATE TABLE stores (id INT,country VARCHAR(50),supplier_id INT); INSERT INTO stores (id,countr... | SELECT suppliers.name FROM suppliers JOIN stores ON suppliers.id = stores.supplier_id WHERE stores.country LIKE 'EU%' AND suppliers.organic_produce_percentage > 0.5 GROUP BY suppliers.name HAVING COUNT(DISTINCT stores.id) > 1; |
What is the minimum and maximum water temperature in Tilapia Farms? | CREATE TABLE Tilapia_Farms (Farm_ID INT,Farm_Name TEXT,Water_Temperature FLOAT); INSERT INTO Tilapia_Farms (Farm_ID,Farm_Name,Water_Temperature) VALUES (1,'Farm A',28.5); INSERT INTO Tilapia_Farms (Farm_ID,Farm_Name,Water_Temperature) VALUES (2,'Farm B',29.0); INSERT INTO Tilapia_Farms (Farm_ID,Farm_Name,Water_Temperat... | SELECT MIN(Water_Temperature), MAX(Water_Temperature) FROM Tilapia_Farms; |
Identify the space agencies with the most spacecraft in deep space. | CREATE TABLE Spacecrafts (Id INT,Agency VARCHAR(50),Mission VARCHAR(50),LaunchYear INT,Status VARCHAR(10)); INSERT INTO Spacecrafts (Id,Agency,Mission,LaunchYear,Status) VALUES (1,'NASA','Voyager 1',1977,'Active'),(2,'NASA','Voyager 2',1977,'Active'),(3,'NASA','New Horizons',2006,'Active'),(4,'ESA','Cassini-Huygens',19... | SELECT Agency, COUNT(*) as DeepSpaceMissions FROM Spacecrafts WHERE Status = 'Active' GROUP BY Agency ORDER BY DeepSpaceMissions DESC; |
Identify the exploration activities for each platform, indicating the start and end date of each activity | CREATE TABLE exploration_activities (activity_id INT,platform_id INT,activity_start_date DATE,activity_end_date DATE); INSERT INTO exploration_activities (activity_id,platform_id,activity_start_date,activity_end_date) VALUES (1,1,'2020-01-01','2020-02-01'),(2,2,'2021-01-01','2021-03-01'); | SELECT platform_id, activity_start_date, activity_end_date FROM exploration_activities; |
Update all records in the "diversity_metrics" table, setting the 'women_in_tech' to 0 | CREATE TABLE diversity_metrics (id INT,company_name VARCHAR(100),region VARCHAR(50),employees_of_color INT,women_in_tech INT); INSERT INTO diversity_metrics (id,company_name,region,employees_of_color,women_in_tech) VALUES (1,'Acme Inc.','Europe',15,22),(2,'Bravo Corp.','North America',35,18); | UPDATE diversity_metrics SET women_in_tech = 0; |
What is the total revenue generated by games released in the last 2 years? | CREATE TABLE game_revenue (id INT,game VARCHAR(20),release_date DATE,revenue INT); INSERT INTO game_revenue (id,game,release_date,revenue) VALUES (1,'Game1','2020-01-01',100),(2,'Game2','2021-01-01',200),(3,'Game3','2019-01-01',300); | SELECT SUM(revenue) FROM game_revenue WHERE release_date >= DATEADD(year, -2, CURRENT_DATE); |
List all defense projects that have a budget greater than 1,000,000,000 and have been completed before 2020. | CREATE TABLE DefenseProjects (project_name VARCHAR(255),start_date DATE,end_date DATE,budget FLOAT); INSERT INTO DefenseProjects (project_name,start_date,end_date,budget) VALUES ('Project A','2018-01-01','2019-12-31',1200000000); | SELECT * FROM DefenseProjects WHERE budget > 1000000000 AND end_date < '2020-01-01'; |
Get the total value of construction projects in California, grouped by city | CREATE TABLE construction_projects (project_id INT,city VARCHAR(20),state VARCHAR(20),value DECIMAL(10,2)); INSERT INTO construction_projects (project_id,city,state,value) VALUES (1,'San Francisco','CA',1000000.00),(2,'Los Angeles','CA',2000000.00); | SELECT city, SUM(value) FROM construction_projects WHERE state = 'CA' GROUP BY city; |
List the total labor costs for each sector in 2022. | CREATE TABLE labor_costs (project_id INT,sector VARCHAR(50),labor_cost FLOAT,year INT); INSERT INTO labor_costs (project_id,sector,labor_cost,year) VALUES (1,'Sustainable',30000,2022),(2,'Conventional',25000,2022),(3,'Sustainable',35000,2022); | SELECT sector, SUM(labor_cost) FROM labor_costs WHERE year = 2022 GROUP BY sector; |
Add a new soil moisture reading of 42 for sensor S102 | CREATE TABLE soil_moisture_sensors (sensor_id VARCHAR(10),moisture_level INT); | INSERT INTO soil_moisture_sensors (sensor_id, moisture_level) VALUES ('S102', 42); |
What is the total number of medals won by a specific athlete in their career? | CREATE TABLE career_medals (id INT,athlete_name VARCHAR(50),sport VARCHAR(20),medals INT); | SELECT SUM(medals) FROM career_medals WHERE athlete_name = 'Usain Bolt' AND sport = 'Athletics'; |
How many volunteers were there in each project category in the 'projects' table? | CREATE TABLE projects (project_id INT,project_category VARCHAR(255),project_name VARCHAR(255),num_volunteers INT); INSERT INTO projects (project_id,project_category,project_name,num_volunteers) VALUES (1,'Education','Coding for Kids',20),(2,'Education','Web Development',30),(3,'Environment','Tree Planting',40),(4,'Envi... | SELECT project_category, SUM(num_volunteers) AS total_volunteers FROM projects GROUP BY project_category; |
What is the total distance traveled for each route type? | CREATE TABLE routes (id INT,name STRING,length FLOAT,type STRING); INSERT INTO routes (id,name,length,type) VALUES (302,'Blue Line',24.5,'Train'); | SELECT type, SUM(length) as total_distance FROM routes GROUP BY type; |
List all stores located in California that carry products from suppliers located in the European Union. | CREATE TABLE stores (id INT,name VARCHAR(255),city VARCHAR(255),state VARCHAR(255)); CREATE TABLE products (id INT,name VARCHAR(255),price DECIMAL(10,2),supplier_id INT); CREATE TABLE supplier_location (supplier_id INT,country VARCHAR(255)); | SELECT s.name FROM stores s JOIN (SELECT DISTINCT store_id FROM products p JOIN supplier_location sl ON p.supplier_id = sl.supplier_id WHERE sl.country IN ('Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Ital... |
What is the total number of transactions for customers from Japan? | CREATE TABLE customers (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO customers (id,name,country) VALUES (1,'John Doe','USA'),(2,'Jane Smith','Canada'),(3,'Jim Brown','UK'),(4,'Hiroshi Nakamura','Japan'); CREATE TABLE transactions (id INT,customer_id INT,amount DECIMAL(10,2)); INSERT INTO transactions (id... | SELECT COUNT(t.id) FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE c.country = 'Japan'; |
What is the maximum budget (in USD) for Green-Star certified buildings in the 'GreenBuildings' table? | CREATE TABLE GreenBuildings (id INT,name VARCHAR(50),squareFootage INT,certification VARCHAR(10),budget DECIMAL(10,2)); INSERT INTO GreenBuildings (id,name,squareFootage,certification,budget) VALUES (1,'EcoTower',50000,'Green-Star',15000000.00),(2,'GreenHaven',35000,'Green-Star',9000000.00),(3,'GreenParadise',60000,'Gr... | SELECT MAX(budget) FROM GreenBuildings WHERE certification = 'Green-Star'; |
What is the average age of players who played MapleStory in Canada? | CREATE TABLE Players (PlayerID INT,PlayerAge INT,Game VARCHAR(20)); INSERT INTO Players (PlayerID,PlayerAge,Game) VALUES (1,23,'MapleStory'),(2,27,'Fortnite'); | SELECT AVG(PlayerAge) FROM Players WHERE Game = 'MapleStory' AND Country = 'Canada'; |
Find the total amount donated by each donor in 2021, ordered by the total donation amount in descending order. | CREATE TABLE Donors (DonorID INT,Name TEXT,Address TEXT); INSERT INTO Donors (DonorID,Name,Address) VALUES (1,'John Doe','123 Main St'); INSERT INTO Donors (DonorID,Name,Address) VALUES (2,'Jane Smith','456 Elm St'); CREATE TABLE Donations (DonationID INT,DonorID INT,Amount DECIMAL,DonationDate DATE); INSERT INTO Donat... | SELECT DonorID, SUM(Amount) as TotalDonated FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID ORDER BY TotalDonated DESC; |
How many community development initiatives were implemented in the Pacific Islands in 2017? | CREATE TABLE CommunityDevelopment (id INT,location VARCHAR(20),initiative_count INT,year INT); INSERT INTO CommunityDevelopment (id,location,initiative_count,year) VALUES (1,'Pacific Islands',20,2017),(2,'Caribbean Islands',30,2018),(3,'Atlantic Islands',15,2019); | SELECT SUM(initiative_count) FROM CommunityDevelopment WHERE location = 'Pacific Islands' AND year = 2017; |
Count the number of species records | CREATE TABLE Species (Name VARCHAR(50) PRIMARY KEY,Population INT); INSERT INTO Species (Name,Population) VALUES ('Coral',2000),('Whale Shark',1500); | SELECT COUNT(*) FROM Species; |
Calculate the percentage of sales by quarter, for each fashion trend, where the fabric is locally sourced. | CREATE TABLE FashionTrends (TrendID INT,TrendName VARCHAR(255),Quarter VARCHAR(255),FabricSource VARCHAR(255)); INSERT INTO FashionTrends (TrendID,TrendName,Quarter,FabricSource) VALUES (1,'Trend1','Q1','Local'); | SELECT TrendName, Quarter, SUM(CASE WHEN FabricSource = 'Local' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as LocalSalesPercentage FROM FashionTrends GROUP BY TrendName, Quarter; |
Insert a new eco-friendly hotel, 'Eco Paradise', in Tokyo with a revenue of 75000.00. | CREATE TABLE eco_hotels (hotel_id INT,name TEXT,city TEXT,revenue DECIMAL(6,2)); INSERT INTO eco_hotels (hotel_id,name,city,revenue) VALUES (1,'Green Hotel','Paris',80000.00),(2,'Eco Lodge','Rome',65000.00); | INSERT INTO eco_hotels (name, city, revenue) VALUES ('Eco Paradise', 'Tokyo', 75000.00); |
Update the condition of patient Jane Smith to 'Generalized Anxiety Disorder' | CREATE TABLE patients (id INT,name TEXT,age INT,condition TEXT); INSERT INTO patients (id,name,age,condition) VALUES (1,'John Doe',30,'Anxiety Disorder'); INSERT INTO patients (id,name,age,condition) VALUES (2,'Jane Smith',45,'Depression'); | UPDATE patients SET condition = 'Generalized Anxiety Disorder' WHERE name = 'Jane Smith'; |
Determine the number of unique habitats where each species is present, and display the results in a table format with species and their respective number of habitats. | CREATE TABLE AnimalHabitats (id INT PRIMARY KEY,species VARCHAR(50),habitat VARCHAR(50)); | SELECT AnimalHabitats.species, COUNT(DISTINCT AnimalHabitats.habitat) FROM AnimalHabitats GROUP BY AnimalHabitats.species; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.