Reputation: 1
I would like to restrict the results for column count(rm_ca) as office
to be rm_ca ='1'
I can't put this into the where
clause as I don't want the other fields restricted. only that one column. How can this be done?
SELECT count(distinct bl) as bld,
count(rm) as rooms,
sum(area) as total_area,
count(rm_ca) as office
FROM table
WHERE dp= '345';
Upvotes: 0
Views: 751
Reputation: 1033
Use:
SELECT count(distinct bl) as bld,
count(rm) as rooms,
sum(area) as total_area,
count(decode (rm_ca,1,0)) as office
FROM table
WHERE dp= '345';
To learn more about Decode read this
Upvotes: 0