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

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:
  #1  
Old February 9th, 2006, 04:28 PM
dba123 dba123 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 2 dba123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
Help with modifying SUM

Table Structure

DCR
------
CustomerNumber
CC
PDC
EnteredDate
FeeGoal
FeeSchedule
PostedAmount

I need a query which will do:

SUM(PostedAmount + SUM(All PDC where EnteredDate in current month) + SUM(All CC where entered date in current month) + SUM(All PDC where EnteredDate not in current month) + SUM(All CC where entered date in current month)) * FeeSchedule
for each company

call that In-House for the above Sum

Then I need to do a grand total on all In-House as one sum. I did something similar like this for another calculation but it didn't include the additions of PDC and CC. That query looked like this:

Select Total = SUM(gt)

FROM
(Select Distinct CustomerName, CustomerNumber, FeeGoal AS FG, FeeSchedule,
(cast(FeeGoal as numeric(30,10)) / FeeSchedule) * 100 AS gt
from DCR WHERE branch='00002'
group by CustomerName,
CustomerNumber,
FeeGoal,
FeeSchedule
) as dTable

so really what I want to change is (cast(FeeGoal as numeric(30,10)) / FeeSchedule) * 100 to add the PDC and CC sums and then * FeeSchedule instead of / like I have here

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Help with modifying SUM


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 2 hosted by Hostway
Stay green...Green IT