Sybase Question:

How to implement if-then-else in a select clause in Sybase?

Tweet Share WhatsApp

Answer:

declare @val char(20)
select @val = 'grand'

select case when @val = 'small' then
'petit'
else
'grand'
end


However, quite a number of people are still using pre-11.5 implementations, including those people using the free 11.0.3.3 Linux release. In that case you can use the following recipe.

To implement the following condition in a select clause:

if @val = 'small' then
print 'petit'
else
print 'grand'
fi

Download Sybase PDF Read All 123 Sybase Questions
Previous QuestionNext Question
Fixing a Munged Log in Sybase?How do I remove duplicate rows from a table in Sybase?