Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Aggregate function
Table (Field1, Field2) a = "SELECT SUM(T.Field2) AS F FROM Table AS T WHERE T.field1=1" Set rs = db.OpenRecordset(a) It works. but a = "SELECT T.field1, SUM(T.Field2) AS F FROM Table AS T WHERE T.field1=1" Set rs = db.OpenRecordset(a) It doesn't work. Run-time error '3122': You tried to execute a query that does not include the specified expresion 'field1' as part of an aggregate function.) -- stefantem ------------------------------------------------------------------------ stefantem's Profile: http://www.excelforum.com/member.php...o&userid=13594 View this thread: http://www.excelforum.com/showthread...hreadid=502805 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Aggregate function
Try using group by as in:
a = "SELECT T.field1, SUM(T.Field2) AS F FROM Table AS T WHERE T.field1=1 group by T.Field1" .... -- HTHs Martin "stefantem" wrote: Table (Field1, Field2) a = "SELECT SUM(T.Field2) AS F FROM Table AS T WHERE T.field1=1" Set rs = db.OpenRecordset(a) It works. but a = "SELECT T.field1, SUM(T.Field2) AS F FROM Table AS T WHERE T.field1=1" Set rs = db.OpenRecordset(a) It doesn't work. Run-time error '3122': You tried to execute a query that does not include the specified expresion 'field1' as part of an aggregate function.) -- stefantem ------------------------------------------------------------------------ stefantem's Profile: http://www.excelforum.com/member.php...o&userid=13594 View this thread: http://www.excelforum.com/showthread...hreadid=502805 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Aggregate function
It works. Thanks. -- stefantem ------------------------------------------------------------------------ stefantem's Profile: http://www.excelforum.com/member.php...o&userid=13594 View this thread: http://www.excelforum.com/showthread...hreadid=502805 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Aggregate tables | Excel Discussion (Misc queries) | |||
Aggregate query | Excel Discussion (Misc queries) | |||
how do I aggregate dates | Excel Discussion (Misc queries) | |||
SQL - As part of an aggregate function ERROR | Excel Programming | |||
How to aggregate in Excel? | Excel Programming |