Re: Tough Sql Query



Tom Moreau (tom@xxxxxxxxxxxxxxxxxxxx) writes:
What business rules do you have? Based on your data, it looked like you
wanted SUM(Credit - Debit) but the desired output you posted earlier
doesn't match this.

That sum is hopefully always 0, or else something is really broken!



--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Tough Sql Query
    ... are fairly standard accounting transactions where for each voucher ... So you can explain the business requirements and posted the desired output, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: [SQL query] Generate a report from events?
    ... sum of device #1 between midnight and 10:00: ... DECLARE @endtime datetime; ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: I upsized but these SQL statements are causing errors...
    ... I'm not too sure but according to books online they are usable here is what ... Returns the sum of all the values, or only the DISTINCT values, in the ... Returns one of two numeric or string values determined by a logical test. ... > what is the sql server equivalent sql of sum and iif? ...
    (microsoft.public.inetserver.asp.db)
  • Re: sum date time differentce
    ... I got can not sum date time format error message. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.programming)
  • Re: Grouping Dates
    ... AVGAS avgtrayweight ... sum these by the datemy ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)