Computer Science

Write SQL queries to perform the following based on the table PRODUCT having fields as (prod_id, prod_name, quantity, unit_rate, price, city)

(i) Display those records from table PRODUCT where prod_id is more than 100.

(ii) List records from table PRODUCT where prod_name is 'Almirah'.

(iii) List all those records whose price is between 200 and 500.

(iv) Display the product names whose price is less than the average of price.

(v) Show the total number of records in the table PRODUCT.

SQL Queries

3 Likes

Answer

(i)

SELECT * FROM PRODUCT
WHERE prod_id > 100;

(ii)

SELECT * FROM PRODUCT
WHERE prod_name = 'Almirah';

(iii)

SELECT * FROM PRODUCT
WHERE price BETWEEN 200 AND 500; 

(iv)

SELECT prod_name
FROM PRODUCT
WHERE price < (SELECT AVG(price) FROM PRODUCT);

(v)

SELECT COUNT(*) AS total_records FROM PRODUCT;

Answered By

1 Like


Related Questions