|
-
Aug 1st, 2007, 05:09 AM
#1
Frenzied Member
Re: Writing SQL
I wouldn't use month as a field name since it's also the name of a function in VB.
Anyway, instead of your WHERE clause, try a GROUP BY month.
Tengo mas preguntas que contestas
-
Aug 1st, 2007, 05:26 AM
#2
Re: Writing SQL
To expand on salvelinus's post...
You want the montha nd a (sum) total of spend, yet in your Sql you only bring back one sum field and filter on a where.
Tru this works, but you'd need sub queries for each month.
As salvelinus posted, use a group by.
Code:
SELECT
[table1].[month]
,Sum(spent) AS Total
FROM
table1
GROUP BY
[table1].[month]
When you use group by you must list all fields that are not aggregate functions (sum, max, min etc).
Try the above then mess around with the sql, see what happens.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|