Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aggregate tables nc Excel Discussion (Misc queries) 0 September 12th 08 03:35 PM
Aggregate query Hilton Excel Discussion (Misc queries) 2 June 27th 07 09:20 AM
how do I aggregate dates Johnopp Excel Discussion (Misc queries) 5 March 5th 06 10:26 PM
SQL - As part of an aggregate function ERROR dave k Excel Programming 6 January 7th 05 03:25 PM
How to aggregate in Excel? Frank Krogh Excel Programming 1 March 4th 04 02:31 PM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"