select count(id) as tot from sbr_property where 1 = 1 and longitude <> '' and main_image <> '' and lookup_sbr_price_category <> 3 and lookup_sbr_listing_status in (6,11,13,16) and ((lookup_sbr_price_category = 7 and (lookup_sbr_property_master > 0 or is_master = 'True' or department_id = 'CO')) or lookup_sbr_price_category <> 7) and (is_master is null or is_master = 'False') and (archived is null or archived = 'False') and (internet_advertising_off is null or internet_advertising_off = 'False')