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)
 How can I avoid the lable in the query

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2009-02-11 : 05:34:39
Hi
I have a sql query like this which is used in an SP or generating reports

select customerName,('PObox '+customerPOBox+' ,'+customerFaxNo)Contact from InventoryCustomerMaster

some times customerPOBox field may be null on such data how can I avoid the label PObox

Thanks and Regards
Anu Palavila

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-11 : 05:47:53
select customerName, case when customerpobox is null then customerFaxNo else('PObox '+customerPOBox+' ,'+customerFaxNo) end as Contact from InventoryCustomerMaster
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2009-02-11 : 06:15:05
thanks bklr for your valuable answer

Thanks and Regards
Anu Palavila
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-11 : 06:19:23
quote:
Originally posted by anupalavila

thanks bklr for your valuable answer

Thanks and Regards
Anu Palavila


ur welcome
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-11 : 06:52:04
select customerName,('PObox '+coalesce(customerPOBox,'')+' ,'+customerFaxNo)Contact from InventoryCustomerMaster


Jai Krishna
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-11 : 07:08:29
quote:
Originally posted by Jai Krishna

select customerName,('PObox '+coalesce(customerPOBox,'')+' ,'+customerFaxNo)Contact from InventoryCustomerMaster
Jai Krishna


the above case is to avoid the pobox when customerpobox is null
but ur query will return the pobox when customerpbox is null also
once check it
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-11 : 07:36:34
select customerName,(coalesce('PObox '+customerPOBox +' ,','')+customerFaxNo)Contact from InventoryCustomerMaster


Jai Krishna
Go to Top of Page
   

- Advertisement -