Solved

SQL Summary Report

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Select2 jquery help 9 46
How to query date ranges with SQL 6 26
Mssql SQL query 14 28
shrink datafile Sql server 4 18
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

744 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

10 Experts available now in Live!

Get 1:1 Help Now