- client_master
- product_master
UPDATE product_master
SET sell_price = 1150.00
WHERE description = '1.44 Drive';Explanation: This query updates the sell_price of the product with description '1.44 Drive' to 1150.00.
DELETE FROM client_master
WHERE client_no = '0001';Explanation: This removes the record of client with client_no '0001' from the client_master table.
UPDATE client_master
SET city = 'Bombay'
WHERE client_no = '0005';Explanation: Updates the city field to 'Bombay' for the client with client_no '0005'.
UPDATE client_master
SET bal_due = 1000
WHERE client_no = '0001';Explanation: Sets the bal_due amount to 1000 for client with client_no '0001'.
SELECT description,
sell_price AS original_price,
sell_price * 15 AS new_price
FROM product_master
WHERE sell_price > 1500;Explanation: This query:
- Filters products with selling price > 1500
- Shows original price and calculates new price (original * 15)
- Displays description and both prices
SELECT * FROM client_master
WHERE city LIKE '_a%';Explanation: The underscore (_) represents any single character, followed by 'a' and % for any remaining characters.
SELECT name FROM client_master
WHERE name LIKE '_a%';Explanation: Similar to previous query but searches in the name field instead of city.
SELECT * FROM product_master
ORDER BY description;Explanation: Returns all products sorted alphabetically by their description.
SELECT COUNT(*) AS total_orders
FROM product_master;Explanation: Counts all records in the product_master table.
SELECT AVG(sell_price) AS average_price
FROM product_master;Explanation: Calculates the average of sell_price for all products.
SELECT MIN(sell_price) AS minimum_price
FROM product_master;Explanation: Finds the lowest sell_price among all products.
SELECT MAX(sell_price) AS max_price,
MIN(sell_price) AS min_price
FROM product_master;Explanation:
- Returns both highest and lowest sell_prices
- Renames the output columns as requested
SELECT COUNT(*) AS expensive_products
FROM product_master
WHERE sell_price >= 1500;Explanation: Counts the number of products that have a sell_price of 1500 or more.
-
Data Modification Commands:
- UPDATE: Questions 1, 3, 4
- DELETE: Question 2
-
Query Commands:
- SELECT
- WHERE
- ORDER BY
- LIKE
-
Aggregate Functions:
- COUNT()
- AVG()
- MIN()
- MAX()
-
String Pattern Matching:
- LIKE with wildcards (_, %)
-
Arithmetic Operations:
- Multiplication (*)
- Column aliasing (AS)
-
Clarity:
- Clear, readable query structure
- Proper indentation
- Meaningful alias names
-
Safety:
- Specific WHERE clauses for updates and deletes
- Precise condition matching
-
Efficiency:
- Appropriate use of aggregate functions
- Proper column selection
-
Style:
- Consistent SQL keyword capitalization
- Clear separation of clauses
- Proper use of whitespace