Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Syntax help

Author  Topic 

SimonG
Starting Member

15 Posts

Posted - 2010-02-09 : 12:37:52
Hi,

New to the forum and would appreciate if anyone can guide me on the best way to achieve the following;

I've got a table created by a DTS package that exports a list of transactions. Each transaction has a contract, a posting date and a value;

CW031,30/1/2010,25.00
CW031,30/1/2010,35.00
CW032, 30/1/2010,75.00
CW034, 30/12/2009, 65.00

I basically need to query this and produce a line for the aggregate value for each contract in each period;

CW031, 1/2010, 60.00
CW032, 1/2010, 75.00
CW034, 12/2009, 65.00

What's the best way to achieve this?

Regards,

Simon

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-09 : 12:46:40
[code]SELECT contract,date,SUM(value) AS total
FROM Table
GROUP BY contract,date
[/code]
Go to Top of Page

SimonG
Starting Member

15 Posts

Posted - 2010-02-10 : 04:16:50
Thanks - I appreciate your posting.

Works a treat!

Simon
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 04:24:34
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page
   

- Advertisement -