Question:

Consider the following tables:

Write SQL queries for the following:
(i) To delete those records from table SALES whose UnitsSold is less than 80.
(ii) To display names of all products whose category is not known.
(iii) To display the product names along with their corresponding units sold.
 

Show Hint

Use DELETE with a WHERE clause to remove specific rows, IS NULL to check for unknown values, and JOINs to combine related tables.
Updated On: Jul 14, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

(i) SQL query to delete records with UnitsSold less than 80:
DELETE FROM SALES 
WHERE UnitsSold<80;

Explanation: This statement deletes rows from SALES where UnitsSold is less than 80.
(ii) SQL query to display product names with unknown category:
SELECT PName 
FROM PRODUCTS 
WHERE Category IS NULL;

Explanation: This query fetches PName from PRODUCTS where the Category value is NULL.
(iii) SQL query to display product names with units sold:
SELECT PRODUCTS.PName, SALES.UnitsSold
FROM PRODUCTS, SALES
WHERE PRODUCTS.PID = SALES.PID;

Explanation: This joins PRODUCTS and SALES on PID and displays each product’s name with its units sold.
Was this answer helpful?
0
0

Top Questions on SQL Queries

View More Questions