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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-05-06 : 09:42:25
|
| NITIN writes "Table StructureACNO DATE DEBITAMOUNT CREDITAMOUNTA001 01/04/04 2000 0.00N001 01/04/04 0.00 3000A001 10/04/04 1500 0.00A002 10/04/04 2500 0.00N001 15/04/04 0.00 3500A002 10/04/04 0.00 4500SELECT ACNO,SUM(DEBITAMOUNT) AS DAMT, SUM(CREDITAMOUTN) AS CAMTFROM TRANS WHERE DATE < 15/04/04 GROUP BY ACNOin the above sample select statement date clause returns null values with one row. i want SUM() working with date ranges with the help of WHERE clause.from the above table i want to sum DEBITAMOUNT and CREDITAMOUNT with a date range. the result should be like this below :-ACNO DEBITAMOUNT CREDITAMOUNTA001 3500 0.00N001 0.00 3000A002 2500 4500Thanks and RegardsNitin Khanna" |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-05-06 : 09:59:03
|
| SELECT ACNO,SUM(DEBITAMOUNT) AS DAMT, SUM(CREDITAMOUTN) AS CAMTFROM TRANS WHERE DATE < '15-Apr-2004' GROUP BY ACNO |
 |
|
|
|
|
|