how to remove multiple rows with different values ​​from the Oracle database using only SQL

advertisements

I have columns as below

----------------------------
brandb     model       class
nokia     x2            2nd
nokia    lumina         1st
sony    xperia          1st
sony    xperial        2nd
sumsun   deo1          1st
sumsun   deo2          1st
------------------------------------------------------------------------

o/p

sunsun deo1    1st
sumsun deo2    1st


I want to remove the brands NOKIA brand and sony completely if it contains 2nd class row product from ORACLE SQL query.

many thanks in advance


If you really want to delete the rows from the table, then you can try:

delete from table
    where brandb in (select t2.brandb from table t2 where t2.class = '2nd');

If you just want to return a query without those models:

select t.*
from table t
where t.brandb not in (select t2.brandb from table t2 where t2.class = '2nd');