Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

(iii) Delete the record of products whose price is more than 500 and discount is less than 0.2

Answer:

Answer by student

The SQL query is:

DELETE FROM Product WHERE Price > 500 AND Discount < 0.2;

Detailed answer by teachoo

-lock-

  • To delete the record of products whose price is more than 500 and discount is less than 0.2, we need to use the DELETE statement with the FROM clause.
  • The FROM clause specifies the table name from which we want to delete rows.
  • We also need to use the WHERE clause to filter the rows that match the condition. The condition is that the price column should be greater than 500 and the discount column should be less than 0.2.

The SQL query for this is:

DELETE FROM Product WHERE Price > 500 AND Discount < 0.2;

This query will delete all rows from the table Product where price is more than 500 and discount is less than 0.2 and after the execution of the query, the table will look like this:

P_ID

Name

Category

Price

Discount

P01

Pen

Stationery

12

0.1

P02

Book

Stationery

50

NULL

P03

Shirt

Clothing

600

0.2

-endlock-

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo