Help !! How to achieve accumulative totals

K

KATHY

I have a simple data base:

Date Job # Hours Emp #

I need to be able to have a query that will give me a running total of job
hours per job even if I specify a date range.
 
N

Norman Yuan

SELECT
[Job #],
SUM(Hours) AS JobTotalHours
FROM theTable
WHERE [Date] BETWEEN '2006-01-01' AND '2006-06-30'
GROUP BY [Job #]
ORDER BY JobTotalHours
 
D

David Portas

KATHY said:
I have a simple data base:

Date Job # Hours Emp #

I need to be able to have a query that will give me a running total of job
hours per job even if I specify a date range.


What are the keys? Constraints? Datatypes? Expected results? I assume you'll
want GROUP BY. If this is SQL Server then also take a look at the CUBE /
ROLLUP operator in Books Online.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
 
Top