Wrox Programmer Forums
|
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:38 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to group by date

I have the following fields in table A:

 GL_ID|GL_Name_VC| Amount |Period_TI|Year_SI|
================================================== =
  1000| Software| 2,000.00 | 01 | 2005
================================================== =
  1000| Software| 2,000.00 | 01 | 2005
================================================== =
  1000| Software| 5,000.00 | 02 | 2005
================================================== =
  1000| Software| 5,000.00 | 02 | 2005
==================================================
  1001| Hardware| 10,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:

Description | Hardware | Software | Total
================================================== ==
Opening Balance | 0.00 | 4,000.00 | 4,000.00
Period 02 | 10,000.00 | 10,000.00 |20,000.00
================================================== ==
Closing Balance | 10,000.00 | 14,000.00 |24,000.00


 The above report has 4 columns, with 1st & last column being a calculated field.
Notice that the Opening Balance description is a sum of all amount under period 01,
with software having a total Opening Balance of 4,000.00 (2,000.00 + 2,000.00).
The amount for both Hardware & software are group by period 02, and a Closing Balance
is derived by adding the sum of Period 01 & Period 02.Total column is a summation of
both Hardware & Software amount.

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
[Resolved] Group date and time snufse SQL Language 8 October 24th, 2008 02:35 PM
XSL group/sort by date problem athos XSLT 4 October 7th, 2008 09:35 AM
Group Within another Group, xslt1.0 jhansib4u BOOK: XSLT Programmer's Reference, 2nd Edition 4 November 22nd, 2007 01:24 AM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 09:51 AM





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