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:38 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create a Temporary Table

I have the following fields in table A:

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

Description | Period 01 | Period 02 | Year to Date
================================================== =======
Sales | 20,000.00 | 10,000.00 | 30,000.00
Total Sales | 20,000.00 | 10,000.00 | 30,000.00

Cost | 5,000.00 | 5,000.00 | 10,000.00
Total Cost | 5,000.00 | 5,000.00 | 10,000.00
================================================== =======
Profit | 15,000.00 | 5,000.00 | 20,000.00

The above report would list 4 columns, with the last column being a calculated field as a sum of
Period01 + Period02 Amount, sorted by GL_ID and group under a summation row called
Total Sales & Total Cost.There would be a net amount appearing as Profit (Total Sales-Total Cost).

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 generic XSL Template to create table Venkatachalapathy XSLT 5 March 11th, 2008 07:49 AM
Temporary table in a shopping cart project ann03 ASP.NET 2.0 Professional 1 October 5th, 2007 07:50 PM
Oracle global temporary table and VB akmhasan Pro VB Databases 0 May 9th, 2005 11:31 PM
Create Temporary Table jmss66 Classic ASP Databases 5 March 11th, 2004 01:00 PM





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