bd528
bd528

Reputation: 886

Filtering data on 2 fields using Oracle

I have the following sample data :-

ID  PET_TYPE  REF
101 Dog       1
102 Cat       7
103 Gerbil    2
104 Cat       9
105 Mouse     5
106 Cat       1
107 Rabbit    2

Using Oracle, is it possible to return all pet types, but only type Cat when the Ref is 9. So the expected output would be :-

ID  PET_TYPE  REF
101 Dog       1
103 Gerbil    2
104 Cat       9
105 Mouse     5
107 Rabbit    2

Upvotes: 0

Views: 36

Answers (1)

juergen d
juergen d

Reputation: 204884

select * from your_table
where pet_type <> 'Cat' 
or ref = 9

Upvotes: 4

Related Questions