Pure SQL question
IT
it at plastipol.com
Mon May 21 04:50:27 EDT 2012
Hi all
This is not an omnis question, is pure sql challange.
I have an invoice table.
Customer bill date amount
01 1 01/01/2011 12
01 3 02/02/2011 26
01 9 30/12/211 10
01 4 31/12/2011 15
02 2 02/01/2011 33
02 5 06/04/2011 15
02 6 05/08/2011 10
02 7 10/11/2011 5
02 8 30/12/2011 6
Now i have a selection of bills in a perior(1year) of bills in a
table grouped by customer.
The select looks like:
select invoice.Customer, sum(invoice.amount) from invoice
where invoice.date between 01/01/2011 and 31/12/2011
group by invoice.Customer
The result looks like
Customer amount
01 63
02 69
Now, I need the same selection of invoices in a period (1 year)
grouped by customer but columns for every quarters
The select not sure how is, but the result must be something like:
Customer Q1 Q2 Q3 Q4 total
01 38 0 0 25 63
02 33 15 10 11 69
Any help how to make this quarter subtotals in sql ?
I'm new in sql and this is to much for me.
regards
xavier
More information about the omnisdev-en
mailing list