How2???

Y

yiannis

I have a table with two fields
One of them are days (2-5-04, 13-5-04, ...)
and the other are a positive number less than 15 (0-15)
How I can calculate the summary of numbers for a week in a query?
Example

Table
[f1] [f2]
2-5-04 2
5-5-04 5
9-5-04 10
10-5-04 3
12-5-04 11
16-5-04 3
19-5-04 7

and I want the result like this:
for week1 sum=2
for week2 sum=18 (5+10+3)
for week3 sum=14 (11+3)
for week4 sum=7

PS Sorry for my poor english!!!
 
W

Wayne Morgan

See if this will do what you want. The "ww" portion of the format statement
returns the week of the year then the "yyyy" portion returns the year. If
you don't include the year then week 3 of this year will be added together
with week 3 of previous years.

SELECT Sum(Table1.Field1) AS SumOfField1, Format([Field2],"wwyyyy") AS Expr1
FROM Table1
GROUP BY Format([Field2],"wwyyyy");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top