SunQuest
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old July 9th, 2003, 07:03 AM
Hena Hena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 28 Hena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile GROUP BY with less fields than SELECT requires?

Code:
INSERT INTO EXCEL_TEMP_PUR ( PROJID, WORK_NUMBER, LAJI, ORDERID, ORDER_ROWNUM, ITEMID, ITEMNAME, COMPANYNAME, SIDOTUT ) 
SELECT PUR_ORDERBATCH.PROJID, PUR_ORDERBATCH.WORK_NUMBER, Left(DLG_ITEM.ITEM_TYPE_NAME,2) AS LAJI, PUR_ORDERBATCH.ORDERID, PUR_ORDERBATCH.ORDER_ROWNUM, PUR_ORDERBATCH.ITEMID, PUR_ORDERBATCH.ITEMNAME, PUR_ORDERBATCH.COMPNAME, Sum(PUR_ORDERBATCH.AMOUNT_BATCH) AS SumOfAMOUNT_BATCH 
FROM PUR_ORDERBATCH, DLG_ITEM 
WHERE (((PUR_ORDERBATCH.PROJID) Is Not Null) AND ((DLG_ITEM.ITEMID)=[PUR_ORDERBATCH].[ITEMID])) 
GROUP BY PUR_ORDERBATCH.PROJID, PUR_ORDERBATCH.WORK_NUMBER, Left(DLG_ITEM.ITEM_TYPE_NAME,2), PUR_ORDERBATCH.ORDERID, PUR_ORDERBATCH.ORDER_ROWNUM, PUR_ORDERBATCH.ITEMID, PUR_ORDERBATCH.ITEMNAME, PUR_ORDERBATCH.COMPNAME;



This query returns the fields I want (need) as stated in the select query, and they are grouped by the same values in the group by part of the query.
However, I do not want to group by with all those fields, I would like to group without these 3 fields, ITEMID, ITEMNAME, COMPNAME, however, if I try to just remove those fields, access will say: "You tried to execute a query that doesn't include the specified expresssion 'ITEMID' as part of an aggregate function."

Has anyone had the same problem? Know of a workaround?


Hena

Reply With Quote
  #2  
Old July 9th, 2003, 12:12 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to MattR
If you understand how group by works you'll know why this is not possible. Do you really want an ORDER BY?

Reply With Quote
  #3  
Old July 10th, 2003, 12:33 AM
Hena Hena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 28 Hena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sum(PUR_ORDERBATCH.AMOUNT_BATCH) AS SumOfAMOUNT_BATCH

Nope, I don't think I want an order by

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > GROUP BY with less fields than SELECT requires?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway