Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
knutso
Starting Member
20 Posts |
Posted - 2006-05-06 : 14:37:02
|
| I have made an aggregate function sql (as far as I understand).I need the sum but also the features column. But I can only read one column in the select.Here is the select trying to read two columns:select oitems.catalogid,oitems.features, sum(oitems.numitems) as SumOfItems from oitemshere is the error:[Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'features' as part of an aggregate function. ...anyone? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-05-06 : 15:43:11
|
| Not sure what result you want - and neither is the server hence the error.Perhapsselect oitems.catalogid,oitems.features, sum(oitems.numitems) as SumOfItems from oitems group by oitems.catalogid,oitems.features==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
knutso
Starting Member
20 Posts |
Posted - 2006-05-06 : 16:10:15
|
| I have got excellent help on this forum today. Also this query you give runs well. Can you combine it with this query:sSQL="select oitems.catalogid, sum(oitems.numitems) as SumOfItems from oitems Inner Join Orders On Orders.orderid = oitems.orderid Where Orders.oshippeddate =" & dDate & " AND Orders.orderid <> 1 group by oitems.catalogid"this last query does everything I want except that I cannot include oitems.features in the select without getting the above error. Propably not so difficult since both queries runs well on their own. Can you combine them? |
 |
|
|
knutso
Starting Member
20 Posts |
Posted - 2006-05-06 : 17:10:03
|
| Well, well! I managed to combine your query with the former, like this:sSQL="select oitems.catalogid,oitems.features, sum(oitems.numitems) as SumOfItems from oitems Inner Join Orders On Orders.orderid = oitems.orderid Where Orders.oshippeddate =" & dDate & " AND Orders.orderid <> 1 group by oitems.catalogid,oitems.features"......now it runs very well...... then I have another problem I will post in a new thread.. |
 |
|
|
|
|
|