Solved

SQL Summary Report

Posted on 2008-10-07
1
975 Views
Last Modified: 2012-05-05
Hello experts,
I'm running SQL Server 2000.  I need an sql query to add a row (similar to the grand total) to this query.  Net deposit should add together the two fee columns and then subtract it from the rollup value.  

Attached (current) is where I am so far....
My Goal is attached (goalview)

Thanks!



SELECT     

COALESCE (CAST(SubscriberID AS varchar(8)), 'Grand Total:') AS SubscriberID, 

SUM(PaymentAmount) AS SubcriberTotal, 

SUM(PaymentAmount) * 0.0289 AS CreditCardFee, 

COUNT(PaymentID) * 0.30 AS TransactionFee

 

FROM  dbo.vTransactions

 

GROUP BY SubscriberID WITH rollup

Open in new window

SnapShot.png
GoalView2.png
0
Comment
Question by:thomasgroup
1 Comment
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 22664019
Try this:

SELECT    
COALESCE (CAST(SubscriberID AS varchar(8)), 'Grand Total:') AS SubscriberID,
SUM(PaymentAmount) AS SubcriberTotal,
(SUM(PaymentAmount) - (SUM(PaymentAmount) * 0.0289) - (COUNT(PaymentID) * 0.30) As Net,  
SUM(PaymentAmount) * 0.0289 AS CreditCardFee,
COUNT(PaymentID) * 0.30 AS TransactionFee
FROM  
dbo.vTransactions
 GROUP BY SubscriberID WITH rollup
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now