imstillatwork
IS-IT--Management
The query below works great for gathering monthly totals for a givin year.
I want to modify it to gather daily totals for a givin month and year.
It seems to error as soon as I try to use day() in the group by instead of month()
I though it would be as simple as
When I change
to
the query works, but give the wrong data (of course) but as soon as I change the group by, it fails.
???????????
Kevin
THANKS!
I want to modify it to gather daily totals for a givin month and year.
It seems to error as soon as I try to use day() in the group by instead of month()
Code:
SELECT
o.order_ID
,o.order_Payment_Date
,o.order_total
,SUM(o1.order_total) AS sumtotal
FROM nwcs_orders AS o
LEFT JOIN nwcs_orders AS o1
ON o1.order_id = o.order_id
WHERE year(o.order_Payment_Date) = #MyYearVariable#
GROUP BY
month(o.order_Payment_Date)
ORDER BY
month(o.order_Payment_Date)
I though it would be as simple as
Code:
WHERE month(o.order_Payment_Date) = MyMonthVariable#
AND year(o.order_Payment_Date) = MyYearVariable#
GROUP BY
day(o.order_Payment_Date)
ORDER BY
day(o.order_Payment_Date)
When I change
Code:
WHERE year(o.order_Payment_Date) = MyMonthVariable#
Code:
WHERE month(o.order_Payment_Date) = MyMonthVariable#
the query works, but give the wrong data (of course) but as soon as I change the group by, it fails.
???????????
Kevin
THANKS!