Hi am writing a sql query that should return multiple values from mulitple tables, that part works (whoopee) but it is returning the same employee multiple times. One of the values I am returning contains many similarites in them form example "BankAL, BankAAL, BankALE, BankALC, BankDTE" Lets say these are different Bank categories. Now an Employee can belong to just one of these categories, or all of them, or just some of them.
The user of this proc knows the Bank part, thats constant. So they just want the first two characters displayed after Bank. eg. "AL, AA, DT" This can be done, but I am assuming I am getting multiple values or the same employee multiple times because one employee can belong to BankAL and BankALC, even though I am displaying only AL, i think it still reads both and therefore would display the employee twice. (like I said, I think)
This is the case statement I am using to only select the "AL" part, but it doesn't sort out the problem
@SQL = @SQL + 'CASE WHEN OEMPBANK.BankID LIKE ''Bank%'' THEN IsNull(SUBSTRING(OEMPBANK.BankID , 5, 2),'' '') ELSE ' ' END
As you can imagine this is sensitive info so cant post too much code