Using Ternary operators in Sybase

Hey,
      I have a problem writing a select statement

       SELECT
       isnull(ltrim(rtrim(A.MBS_POOL_SBTP_CD)),'Fixed'),                                      
       @FNMA,                                    
       'MF',                                    
       'MBS'
      FROM disclosure..MBS_POOL_AT_ISSN A, #CUSIPS B, disclosure..SECU C
      WHERE A.SECU_CUSIP_ID = B.CUSIP
      and B.CUSIP    = C.SECU_CUSIP_ID

      In the above Query , the function,  isnull(ltrim(rtrim(A.MBS_POOL_SBTP_CD)),'Fixed') writtens a value 'Fixed' if the column A.MBS_POOL_SBTP_CD is null. But what i want  is as follows

isnull(ltrim(rtrim(A.MBS_POOL_SBTP_CD)),'Fixed'|'ARM')--- Meaning when the value of A.MBS_POOL_SBTP_CD is null it should return FIXED and when there is an existing value for  A.MBS_POOL_SBTP_CD   it should return ARM to that specified column during the select. Actually it should mimic the following if/else condition


if (A.MBS_POOL_SBTP_CD  = null){
return 'Fixed'
}else {
return 'ARM'
}

I am not Sure how to code this in Sybase select statements.

Thanks.
LVL 2
SubhaBabuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan FranekCommented:
Use CASE command:

select case when A.MBS_POOL_SBTP_CD is null then 'Fixed' else 'ARM' end
....

For detailed info see http://manuals.sybase.com/onlinebooks/group-as/asg1251e/commands/@Generic__BookTextView/5954;pt=5954#X

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
morisceCommented:
SELECT
       case A.MBS_POOL_SBTP_CD when null then 'Fixed' else 'ARM' end,
       @FNMA,                                    
       'MF',                                    
       'MBS'
      FROM disclosure..MBS_POOL_AT_ISSN A, #CUSIPS B, disclosure..SECU C
      WHERE A.SECU_CUSIP_ID = B.CUSIP
      and B.CUSIP    = C.SECU_CUSIP_ID

If you want processing empty string like null value :
SELECT
       case isnull(A.MBS_POOL_SBTP_CD,'') when '' then 'Fixed' else 'ARM' end,
       @FNMA,                                    
       'MF',                                    
       'MBS'
      FROM disclosure..MBS_POOL_AT_ISSN A, #CUSIPS B, disclosure..SECU C
      WHERE A.SECU_CUSIP_ID = B.CUSIP
      and B.CUSIP    = C.SECU_CUSIP_ID
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.