Try

SELECT MONTH(SHIPDATE), SUM(SHIPPED * DATE)
FROM
ORDERS
GROUP BY MONTH(SHIPDATE)

J.

On 09/04/2006, at 8:16 AM, Mark Weiss wrote:

Hi,

I have a table of sales. 3 sales for Jan, 4 for Feb, 10 for march, etc, for the entire year.

I could
sum stuff where shipdate between "01/01/2006" and "01/31/2006"
sum stuff where shipdate between "02/01/2006" and "02/28/2006"

etc...


I am trying to come up with some kind of sql that will sum the sales total for a month, without having to do date ranges.

select month(shipdate), sum(shipped * price) from orders where shipdate = month(shipdate) group by shipdate


or something like that.

It would end up with

1 456
2 325
3 555
4 234
5 222
6 848
7 395
8 294
9 920
10 535
11 432
12 123


if I selected all the records for a year beginning Jan 1 and ending December 31

Basically sum by month.

I have been trying for about 2 hours different things, sub queries, group by having, without much luck.

Can anyone give me an idea if this is even possible?




________________________________________________________________________


WITH IMAGINATION

Planning, Implementation and Management of Web Applications 


160 Pacific Highway North Sydney NSW Australia 2060

phone + 612 9929 9229 fax + 612 9460 4770 

web - www.wi.com.au email -  [EMAIL PROTECTED]



________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to