select SUM (Account_Invoice.amount_untaxed),
right (Res_Partner.vat,length(Res_Partner.vat)-2) as RFC
from Account_Invoice inner join Res_Partner on Account_Invoice.partner_id = Res_Partner.id
inner join Account_Invoice_Tax on Account_Invoice.id = Account_Invoice_Tax.invoice_id
where account_invoice.journal_id=2
and account_invoice.date_invoice >= '2013-01-01'
and account_invoice.date_invoice <= '2013-02-01'
and account_invoice.reconciled is TRUE
and account_invoice_tax.account_id = 3237 and account_invoice.amount_tax >= 0
or account_invoice_tax.account_id = 3236 or account_invoice_tax.account_id = 3238
I'm hoping to sort the untaxed amounts from 3236 then the ones for 3237 and finally the ones with 3238. I understand I have to use "group by" but I don't understand exactly how. Any pointers?