Reputation: 45
This works:
select
idpelamar,
case
when jk = 'L' then 'Laki'
when jk = 'P' then 'Perem'
end as XJENIS
from tblpelamar
How to apply the case
statement to initialize a variable?
Like this below:
declare @jenis nvarchar(1)
declare @perintah nvarchar(100)
set @jenis = 'L'
set @perintah = 'case when jk=@jenis then Laki when jk=@jenis then Prem end as XJENIS'
select
idpelamar,
+@perintah
from tblpelamar
Upvotes: 0
Views: 60