LogIDLogTallyLogDateItemAnd if someone wants to see a report on apples, they would see something like:
1 2 3/28/03 apples
2 1 3/29/03 apples
3 2 4/01/03 oranges
4 3 4/01/03 apples
5 1 4/01/03 grapes......
293 1 3/17/04 oranges
294 1 3/17/04 apples
3/034/035/03..............3/04I can select one month (this one) like this:
3 3 - 3
SELECT SUM(LogTally) AS Expr1but, I just don't know how to do it for the past 12 months. Do I play with the dates and do 12 seperate SELECTS?
FROM TABLE
WHERE (MONTH(GETDATE()) = MONTH(LogDate)) AND (YEAR(GETDATE()) = YEAR(LogDate)) AND (item = 'apples')
GROUP BY item
THANK YOU!you could do something like:
SELECT
SUM(LogTally),
DATEPART(mm, LogDate)
FROM
YourTable
WHERE
<input criteria for last year here>
GROUP BY
DATEPART(mm, LogDate)
which should sum the values for each month.
Cheer
Ken|||Thanks for the reply.
What I need is to have each column in my datagrid to be a different month. There will always be 12 months, but there can be any amount of items(rows)
Can I do this with what you showed me?
Thanks again
No comments:
Post a Comment