General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 26th, 2004, 06:24 AM
girdlardog girdlardog is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 girdlardog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQl Union Aggregate Pb

Hi, I have an access union that is being used as a string a couple of times. I want to aggregate just a part of the query, and havent been having any luck. Is it possible to do this.
Basically i would like to have a Grouped sum of the following values i.e

Select Sum([Extended Cost LC]) AS..., Sum([Extended Cost $]) AS..., ICIS.[ICIS Backup], (

SELECT ICIS.MonthNo, ICIS.[ICIS Backup], ICIS.Acct, Sum(Round([GBP],2)) AS [Extended Cost LC], Sum(Round([USD],2)) AS [Extended Cost $], ICIS.[Journal Source], ICIS.[File Link] FROM ICIS INNER JOIN 115 ON ICIS.[ICIS Link] = [115].[ICIS Inv #] GROUP BY ICIS.MonthNo, ICIS.[ICIS Backup], ICIS.Acct, ICIS.[Journal Source], ICIS.[File Link] HAVING (((ICIS.MonthNo)=7 Or (ICIS.MonthNo)=8 Or (ICIS.MonthNo)=9) AND ((ICIS.[ICIS Backup])=115) AND ((ICIS.Acct)=746000) AND ((ICIS.[Journal Source])='ICIS'))
UNION
SELECT ICIS.MonthNo, ICIS.[ICIS Backup], ICIS.Acct, Round(Sum([150].[Extended Cost LC]),2) AS [Extended Cost LC], Round(Sum([150].[Extended Cost $]),2) AS [Extended Cost $], ICIS.[Journal Source], ICIS.[File Link] FROM ICIS INNER JOIN 150 ON ICIS.[ICIS Link] = [150].[ICIS Inv #] GROUP BY ICIS.MonthNo, ICIS.[ICIS Backup], ICIS.Acct, ICIS.[Journal Source], ICIS.[File Link] HAVING (((ICIS.MonthNo)=7 Or (ICIS.MonthNo)=8 Or (ICIS.MonthNo)=9)
AND ((ICIS.[ICIS Backup])=150) AND ((ICIS.Acct)=746000) AND ((ICIS.[Journal Source])='ICIS'))
UNION
SELECT ICIS.MonthNo, ICIS.[ICIS Backup], ICIS.Acct, Round(([Net Local]),2) AS [Extended Cost LC], Round(([Total Dollar Value]),2) AS [Extended Cost $], ICIS.[Journal Source], ICIS.[File Link] FROM ICIS WHERE (((ICIS.MonthNo)=7 Or (ICIS.MonthNo)=8 Or (ICIS.MonthNo)=9) AND ((ICIS.Acct)=746000) AND ((ICIS.[Journal Source])='Manual') AND ((ICIS.Ent)=710) AND ((ICIS.[ICIS Link])=999999)) Group BY ICIS.[ICIS Backup] )

My Backup data point is my problem.

Thanks in advance

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > SQl Union


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 6 hosted by Hostway