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)
 Select syntax with condtion question

Author  Topic 

vmon
Yak Posting Veteran

63 Posts

Posted - 2003-06-10 : 15:02:33
I have the following which I want to replace the NULL values with 0. The null is coming from a LEFT OUTER JOIN. How do I select the MAX(ID_Letter) column and show 0 for NULL?

SELECT ID_Eclipse, MAX(ID_Letter) AS Letter FROM tblCustomer LEFT OUTER JOIN History ON tblCustomer.ID_Eclipse = History.ID_Eclipse

Thanks,
vmon

nr
SQLTeam MVY

12543 Posts

Posted - 2003-06-10 : 15:11:36
SELECT ID_Eclipse, coalesce(MAX(ID_Letter),0) AS Letter FROM tblCustomer LEFT OUTER JOIN History ON tblCustomer.ID_Eclipse = History.ID_Eclipse


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-06-10 : 17:04:20
or, if like me you have trouble spelling COALESCE you can use ISNULL().



- Jeff
Go to Top of Page
   

- Advertisement -