Found this in the AND condition of LEFT OUTER JOIN between AA & DD
AND DD.EMPL_ID LIKE '%' + AA.[Emp_Id]
LIKE operator does a string comparison but treats
_ as wildcards matching any string and any single character, respectively. This is analoguous to
? in the shell.
DD.EMPL_ID LIKE '%' + AA.[Emp_Id]
looks like your DBM uses
+ for string concatenation (standard SQL would be
||). So if
'hello', then that condition becomes
DD.EMPL_ID LIKE '%' + 'hello'
DD.EMPL_ID LIKE '%hello'
which checks whether
DD.EMPL_ID is an arbitrary string followed by
hello, i.e. whether
DD.EMPL_ID ends with