Hi all,

When coding in SQL what is the equivalent to multiple if statements to return the sum of monthly values?

For example:

Sum(IIf([Date] Between #01/08/2012# And #31/08/2012#,[Value]))
Sum(IIf([Date] Between #01/09/2012# And #30/09/2012#,[Value]))

I have attempted to use this to no avail:

SELECT
CASE
WHEN InvoiceDate between '2012-01-01' and '2012-01-31'
THEN SUM (InvoiceValue)
WHEN InvoiceDate between '2012-02-01' and '2012-02-29'
THEN SUM (InvoiceValue)
END AS Jan_2012_Value
FROM
tbSalesHistory
GROUP BY
InvoiceValue, InvoiceDate

Many thanks,

D