Solved

SQL Summary Report

Posted on 2008-10-07
1
982 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Database Integrity 1 50
Dynamic SQL select query 4 38
MS SQL Delete Duplicate Rows Only 2 20
Setting variables in a stored procedure 5 22
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

830 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