INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Business Objects: Crystal Reports 4 Other topics FAQ

## Running Totals

 What are the different ways to do running totals? by MalcolmW faq149-182 Posted: 15 Aug 00 There are several ways to do a running total.  Your options on which to use depend on your Seagate Crystal Reports (SCR) version number, and database type.1) The easiest is to use the InsertÂªRunning Total wizard.  This is not always accurate in SCR v7 and below.  Easy, but use at your own risk.2) Use the three formula approach.This is reliable, but more time consuming to write.In this example, the running total calculates the number of employees in a dept.//goes in group header for dept, resets count to zeroWhilePrintingRecords ;NumberVar DeptEmpCount := 0//goes in the detail section, increments employee countWhilePrintingRecords ;NumberVar DeptEmpCount := DeptEmpCount + 1//goes in the group footer for dept, shows dept emp countWhilePrintingRecords ;NumberVar DeptEmpCount 3) Lastly, writing the RT in SQL will give you the best performance, but requires some experience with SQL.  These running totals examples are for a bank account, where the running total is the balance of the account after each transaction.SELECT B0.transaction, B0.transdate, SUM(B1.amount) AS balanceFROM BankAccount AS B0, BankAccount AS B1WHERE B1.transdate <= B0.transdateor using a scalar subquery (great terminology to confuse and intimidate)SELECT B0.transaction, B0.transdate,   (SELECT SUM(B1.amount)   FROM BankAccount AS B1   WHERE B1.transdate <= B0.transdate) AS balanceFROM BankAccount AS B0Crystal gurus will note that both of these SQL solutions require modification of the SELECT portion of the SQL statement, which isn't permitted in Crystal Reports.  Thus, you will have to use a view, stored procedure, temporary table, or the SQL Query tool to circumvent this limitation. Back to Business Objects: Crystal Reports 4 Other topics FAQ Index Back to Business Objects: Crystal Reports 4 Other topics Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!