sql server - Clarification in CASE statement in sql -
i came across code assumption made in end of case statement
in join , couldn't understand. please tell me purpose of using such method/code.
code:
full outer join #std b on a.empid = b.mgrid , case when a.empname not null a.empname else a.mgrname end = b.stdname
the bit don't understand end = b.std
. know purpose of it. thanks.
this second predicate of where
clause equivalent to:
coalesce(a.empname, a.mgrname) = b.stdname
i.e. a.empname
used compare b.stdname
, unless a.empname
null. in latter case a.mgrname
used instead.
Comments
Post a Comment