sqloracle-database

Filter rows based on a value of a column


Suppose I have a table:

-----------------
ID | PARTY | NAME
-----------------
1  | IND   | ABC
2  | IND   | DEF
3  | CUST  | GHI
4  | CUST  | JKL
5  | IND   | MNO
-----------------

I want to filter rows based on NAME whose PARTY = 'IND'. And all other rows should be present in the result set.

For example:

if i want to filter on NAME = 'ABC' then data returned should be something like this:

-----------------
ID | PARTY | NAME
-----------------
1  | IND   | ABC
3  | CUST  | GHI
4  | CUST  | JKL
-----------------

I have tried it using where clause but not getting the right result. Any help would be appreciated.

P.S. I'm working in Oracle 10g.


Solution

  • You can simply do;

    SELECT * 
    FROM Table1 
    WHERE Name='ABC' OR Party<>'IND';
    

    An SQLfiddle to test with.