I am hoping someone can help interpret the last code line (@Active=1....) for this SQL clause:
SELECT DISTINCT LOC_ID
,LOC_CODE
,ADDR_LINE_1
,ADDR_LINE_2
,ADDR_LINE_3
,CITY
,STATE
,COUNTRY
,POSTAL_CODE
,COMPANY
,OPERATION_TYPE
,PROCESS
,ADDR_LINE_1 + ',' +ADDR_LINE_2+ ',' + CITY + '-' + COUNTRY + ' ' + POSTAL_CODE AS ADDRESS
,COMPANY + '.' + CENTER + '.' + OPERATION_TYPE + '.' + PROCESS AS Proc_Combo
,CASE WHEN INACTIVE_DATE IS NULL THEN 'Active'
WHEN INACTIVE_DATE IS NOT NULL THEN 'InActive'
ELSE 'UNKNOWN' END AS INACTIVE_DATE
,CASE WHEN INSTANCE_ID = 1 THEN 'AP'
WHEN INSTANCE_ID = 2 THEN 'GAP'
ELSE 'ALL' END AS INSTANCE_ID
FROM HR_Locations
WHERE
(@STATE IS NOT NULL AND STATE =@STATE OR @STATE='' AND STATE =STATE OR @STATE IS NULL AND 1=1)
AND
(@ACTIVE=1 AND INACTIVE_DATE IS NULL OR @ACTIVE=2 AND INACTIVE_DATE IS NOT NULL OR @ACTIVE=0 AND 1=1 OR @ACTIVE IS NULL)
I have encountered code like this, only this is not contained in an "IF" block