Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

CASE in JOIN CONDITION

$
0
0

Hi,

I have written below sample code for a join condition. Please let me know, if there is a good way to write it.

SELECT * FROM dbo.DETAIL AS DET WITH(NOLOCK)

LEFT JOIN #Data AS Acct WITH(NOLOCK) ON

               CASE       WHEN DET.type NOT IN ('30', '50','10030','10050','20', ,'12021') THEN 'NOT_SPECIFIC'

                               WHEN DET.type IN ('20','1010','9000','10020','11010','19000') THEN 'SPECIFIC'

                               WHEN DET.type IN ('10','2000','10010','12000','12020','12021') THEN 'UNKNOWN'

               END = Acct.SrcVal

Thanks

Kranthi


Viewing all articles
Browse latest Browse all 23857

Trending Articles