Sql statement error (1 Viewer)

Coldsteel

Registered User.
Local time
Today, 07:16
Joined
Feb 23, 2009
Messages
73
I have a question I keep getting a error when I try to fun my SQL Statment. Access says I tried to execute a query that does not include the specified expression 'Time Closed' as part of an aggregate function.

Here is a sample of my Statment:

tbl_referral.[Time Closed], tbl_referral.[MBR FIRST NAME], tbl_referral.[MBR LAST NAME], tbl_referral.[DATE REFERRED], tbl_referral.[STATUS],

Sum(IIf([Time Closed] Not Between GetDateLower() And Now(),IIf([STATUS]="Closed - Funded",1,0))) AS Total

FROM tbl_referral;

Does anyone know what I am doing wrong?

Thanks,
Mike
 

ByteMyzer

AWF VIP
Local time
Today, 05:16
Joined
May 3, 2004
Messages
1,409
Yes. Your SQL statement does not contain a GROUP BY clause after the FROM clause.
 

Coldsteel

Registered User.
Local time
Today, 07:16
Joined
Feb 23, 2009
Messages
73
Sorry, I am a still new to SQL Statments
Can you give me a example of what you mean?
 

ByteMyzer

AWF VIP
Local time
Today, 05:16
Joined
May 3, 2004
Messages
1,409
Let's say you have a table like the following:
Code:
tblItemsList
------------
ItemType | ItemName  | Qty
--------------------------
TOOL     | Hammer    | 1
TOOL     | Drill     | 2
TOOL     | Saw       | 5
ACCESS   | Drill Bit | 14
ACCESS   | Saw Blade | 20
If you want to know the total number each of TOOLs and ACCESSories you have, you could use a query like the following:
Code:
SELECT tblItemsList.ItemType, Sum(tblItemsList.Qty) AS Qty
FROM tblItemsList.ItemType
GROUP BY tblItemsList.ItemType;
...which would yield the following results:
Code:
ItemType | Qty
--------------
TOOL     | 8
ACCESS   | 34
 

Users who are viewing this thread

Top Bottom