Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2006, 08:40 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create an aggregated field

I have the following fields in table A:

 GL_ID|GL_Name_VC | Amount |Period_TI|Year_SI
================================================== =
  1000| Inventory| 8,000.00 | 01 | 2005
================================================== =
  1000| Inventory| -3,000.00 | 02 | 2005
================================================== =
  1000| Inventory| 5,000.00 | 02 | 2005
================================================== =


the fields above have the following datatype:

 Fields | Datatype
 ===================================
 GL_ID | Integer
 GL_Name_VC | Variable Character
 Amount | Integer
 Period_TI | TinyInteger
 Year_SI | SmallInteger

The above database is running on Microsoft SQL Server 2000 and i would like to query
for a report that looks something as below:

GL_ID | GL_Name_VC |Op Bal|Period_Dr|Period_Cr|Period Bal|Closing Bal
================================================== ====================
1000 | Inventory |8,000 | 5,000 | -3,000 | 2,000 |10,000

 The above report has an Op Bal column which is the sum of all amount in Period 01 in
Year 2005 carried forward as opening balance in Period 02, Period_Dr Column would contain
all positive amount in Period 02 & Period_Cr Column would contain all negative amount
in Period 02. Period Bal is the summation of both Period_Dr & Period_Cr and Closing Bal
column is the summation of Op Bal + Period Bal.

Guys, hope someone out there can help me with the sql command for the above report?








Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a View "Name" field & Populate bren582 SQL Server 2005 2 February 11th, 2008 10:28 PM
Create a field in a query Vision G Access 1 July 26th, 2006 03:33 PM
Create Custom Field Property using ADOX BoGusman Pro VB Databases 2 July 13th, 2006 05:16 PM
How to create a Calculated Field fdtoo SQL Server 2000 0 April 11th, 2006 08:34 PM
Create lookup based on field value s.hendy Access 2 May 20th, 2005 04:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.