Solved

SQL Summary Report

Posted on 2008-10-07
1
990 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

739 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