select s.code AS "Seller code"
    , s.description AS "Seller description"
    , coalesce(c.code, '') AS "Customer code"
    , coalesce(replace(c.description, ',', ' '), '') AS "Customer description"
    , coalesce(ca.code, '') AS "Customer Account code"
    , coalesce(replace(ca.description, ',', ' '), '') AS "Customer Account description"
    , coalesce(ba.code, '') AS "Billing Account code"
    , coalesce(replace(ba.description, ',', ' '), '') AS "Billing Account description"
    , coalesce(ua.code, '') AS "User Account code"
    , coalesce(replace(ua.description, ',', ' '), '') AS "User Account description"
    , coalesce(su.code, '') AS "Subscription code"
    , coalesce(replace(su.description, ',', ' '), '') AS "Subscription description"
    , coalesce(ap.acces_user_id, '') AS "Access Point id"  
from  crm_seller s left
    OUTER JOIN crm_customer c  on c.seller_id = s.id left
    OUTER JOIN ar_customer_account ca  on ca.customer_id = c.id left
    OUTER JOIN billing_billing_account ba  on ba.customer_account_id = ca.id left
    OUTER JOIN billing_user_account ua  on ua.billing_account_id = ba.id left
    OUTER JOIN billing_subscription su  on su.user_account_id = ua.id left
    OUTER JOIN medina_access ap  on ap.subscription_id = su.id 
where s.code ilike '%' || :SEARCH_CRITERION || '%'  or s.description ilike '%' 
    || :SEARCH_CRITERION || '%'  or c.code ilike '%' || :SEARCH_CRITERION 
    || '%'  or c.description ilike '%' || :SEARCH_CRITERION || '%'  or ca.code ilike '%' 
    || :SEARCH_CRITERION || '%'  or ca.description ilike '%' || :SEARCH_CRITERION 
    || '%'  or ba.code ilike '%' || :SEARCH_CRITERION || '%'  or ba.description ilike '%' 
    || :SEARCH_CRITERION || '%'  or ua.code ilike '%' || :SEARCH_CRITERION 
    || '%'  or ua.description ilike '%' || :SEARCH_CRITERION || '%'  or su.code ilike '%' 
    || :SEARCH_CRITERION || '%'  or su.description ilike '%' || :SEARCH_CRITERION 
    || '%'  or ap.acces_user_id ilike '%' || :SEARCH_CRITERION || '%'  
order by s.code
    ,c.code
    ,ca.code
    ,ba.code
    ,ua.code
    ,su.code
    ,ap.acces_user_id