select trim(to_char(date_trunc('month', i.invoice_date), 'Month')) || to_char(date_trunc('month', i.invoice_date), ' YYYY') AS  Month 
    , s.code AS  "Seller code"
    , s.description AS  "Seller description"
    , it.code AS  "Invoice type code"
    , it.description AS  "Invoice type description"
    , to_char(sum(i.amount_without_tax), '9999999990.00') AS  "Amount without tax"
    , to_char(sum(i.amount_with_tax), '9999999990.00') AS  "Amount with tax"   
from crm_seller s
    INNER JOIN crm_customer c  on c.seller_id = s.id
    INNER JOIN ar_customer_account ca  on ca.customer_id = c.id
    INNER JOIN billing_billing_account ba  on ba.customer_account_id = ca.id
    INNER JOIN billing_invoice i  on i.billing_account_id = ba.id
    INNER JOIN billing_invoice_type it  on it.id = i.invoice_type_id 
where i.invoice_date > (date_trunc('month', CURRENT_DATE) - CAST(:MONTH_INTERVAL || 'month' AS INTERVAL))  
and(  s.code ilike '%' || :SEARCH_CRITERION || '%'  or s.description ilike '%' || :SEARCH_CRITERION || '%'  )  
group by date_trunc('month', i.invoice_date)
    , it.code
    , it.description
    , s.code
    , s.description order by date_trunc('month', i.invoice_date) DESC
    , it.code DESC
    , s.code