sql server - Can someone please help me understand the case function? -
i working in sql data base. have make 2 columns. first column length of employee name(i have that) second column title of courtesy , last name of employee.
my problem how add case function have ms displayed miss, mr. mister , dr doctor. not understand. appreciated. here code have far:
select 'your full name ' + cast(len(firstname) + len(lastname) varchar(12)) + ' character(s).' [length of employee name] , titleofcourtesy + lastname title dbo.employees
you can this:
select ... previous things here ... case titleofcourtesy when 'mr' 'mister ' when 'ms' 'miss ' when 'dr' 'doctor ' else '' end + lastname title
Comments
Post a Comment