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
 SQL Server Development (2000)
 SPECIAL SQL STATMENT

Author  Topic 

azim
Starting Member

29 Posts

Posted - 2002-11-04 : 05:37:15



SELECT NAME,SUM(DEBIT)-SUM(CRIDIT) AS DEBIT ,SUM(CRIDIT)-SUM(DEBIT)AS CRIDIT FROM LEDGER
GROUP BY NAME


I WANT OT GET ONLY POSITIVE VALUES
PLEASE ADVICE

azim

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-04 : 06:22:22
quote:




SELECT NAME,SUM(DEBIT)-SUM(CRIDIT) AS DEBIT ,SUM(CRIDIT)-SUM(DEBIT)AS CRIDIT FROM LEDGER
GROUP BY NAME


I WANT OT GET ONLY POSITIVE VALUES
PLEASE ADVICE

azim



SELECT NAME,SUM(DEBIT)-SUM(CRIDIT) AS DEBIT ,SUM(CRIDIT)-SUM(DEBIT)AS CRIDIT FROM LEDGER
GROUP BY NAME
HAVING SUM(CRIDIT)-SUM(DEBIT) > 0

Go to Top of Page

azim
Starting Member

29 Posts

Posted - 2002-11-04 : 17:03:47
thanks for reply question

if the return value < 0 (negative) then write (0)instead

azim
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-05 : 04:07:24
quote:

thanks for reply question

if the return value < 0 (negative) then write (0)instead

azim



Case when value < 0 then 0 else value end as value

Go to Top of Page
   

- Advertisement -