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 2008 Forums
 Transact-SQL (2008)
 remove line from results,where all line is 0

Author  Topic 

nord
Posting Yak Master

126 Posts

Posted - 2013-01-25 : 14:01:14
I have 4 columns sometimes all 4 columns is 0,how i can remove this line from results
Thanks

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-25 : 14:13:38
You have to use a WHERE clause like shown below:
WHERE 
col1=0 AND col2=0 AND col3=0 AND col4=0;
Go to Top of Page

nord
Posting Yak Master

126 Posts

Posted - 2013-01-25 : 14:26:36
ISNULL(credit_complet_qty and credit_complet_amt and diff_arrivage_qty and diff_arrivage_amt)
I can write like that but doesnt work
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-25 : 14:50:16
Can you try one of these
-- eliminate if all are nulls
WHERE
COALESCE(col1,col2,col3,col4) IS NOT NULL;

-- eliminate if it is a combination of nulls and zeros
WHERE
COALESCE(NULLIF(col1,0),NULLIF(col2,0),NULLIF(col3,0),NULLIF(col4,0)) IS NOT NULL;
Go to Top of Page

nord
Posting Yak Master

126 Posts

Posted - 2013-01-25 : 15:16:22
Thanks a lot second one its work!!!!!!!!!!!!!!!!!!!!
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-25 : 17:15:34
You are very welcome - glad to be of help.
Go to Top of Page
   

- Advertisement -