Skip to content
Advertisement

count distinct if a condition is satisfied

I have a table which shows if a address_no has a telephone or not. To determine, i am looking at cell_phone and house_phone columns and want to write ‘no phone’ only when house_phone and cell_phone is null.

every address_no has records for the people living at the address. If at least one person has a phone or house_phone is not null then that address_no has phone, otherwise address_no has no phone information.

As shown above, i want to have a result of 4 addresses out of 5 which have telephone info.

How can i write a sql query to find the number in oracle sql

Advertisement

Answer

You can use aggregation and a case expression:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement