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
 General SQL Server Forums
 New to SQL Server Programming
 Case Select in Select Query

Author  Topic 

velnias2010
Posting Yak Master

125 Posts

Posted - 2011-06-14 : 09:41:11
select r.inkexID,
name,primaryOrgName
FROM organisationRegulatory

What I want to change it to is something like

if len(primaryOrgName) > 0 or IS NOT NULL then use name else use primaryOrgName as Name

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-14 : 09:54:15
SELECT r.inkexID, COALESCE(primaryOrgName,name) Name
FROM organisationRegulatory r

or

SELECT r.inkexID, CASE WHEN primaryOrgName>'' THEN primaryOrgName ELSE name END Name
FROM organisationRegulatory r
Go to Top of Page

velnias2010
Posting Yak Master

125 Posts

Posted - 2011-06-14 : 10:20:02
Great thanks for that
Go to Top of Page
   

- Advertisement -