DBA2000
asked on
CASE Statement Syntax - ??? never saw befor.
Hi, Everyone:
I have never come accross this syntax in a CASE statement before; ... END = 1 ...
please see below.
What does it mean?
Thank you,
SELECT TOP (@maxIndexSize) @requestID
, svo.MlsNum
FROM
mls_unified_svo_tbl svo (nolock)
WHERE
svo.LoadOnInternet = 1
AND svo.std IS NOT NULL
AND svo.snd IS NOT NULL
AND (svo.Status IN (5, 30, 45)
OR
(svo.Status IN (10, 20)
AND DATEDIFF(day, svo.StatusDate, GETDATE()) < 365
)
)
AND
CASE WHEN @request.exist('/searchReq uest/mlsNu mber') = 0
THEN 1
ELSE
CASE WHEN svo.MlsNum = @request.value('(/searchRe quest/mlsN umber)[1]' , 'varchar(20)') THEN 1
ELSE 0
END
END = 1
AND
CASE WHEN @request.exist('/searchReq uest/zipCo de') = 0
THEN 1
ELSE
CASE WHEN svo.zip = @request.value('(/searchRe quest/zipC ode)[1]', 'varchar(500)') THEN 1
ELSE 0
END
END = 1
AND
CASE WHEN @request.exist('/searchReq uest/city' ) = 0
THEN 1
ELSE
CASE WHEN svo.city = @request.value('(/searchRe quest/city )[1]', 'varchar(50)') THEN 1
ELSE 0
END
END = 1
I have never come accross this syntax in a CASE statement before; ... END = 1 ...
please see below.
What does it mean?
Thank you,
SELECT TOP (@maxIndexSize) @requestID
, svo.MlsNum
FROM
mls_unified_svo_tbl svo (nolock)
WHERE
svo.LoadOnInternet = 1
AND svo.std IS NOT NULL
AND svo.snd IS NOT NULL
AND (svo.Status IN (5, 30, 45)
OR
(svo.Status IN (10, 20)
AND DATEDIFF(day, svo.StatusDate, GETDATE()) < 365
)
)
AND
CASE WHEN @request.exist('/searchReq
THEN 1
ELSE
CASE WHEN svo.MlsNum = @request.value('(/searchRe
ELSE 0
END
END = 1
AND
CASE WHEN @request.exist('/searchReq
THEN 1
ELSE
CASE WHEN svo.zip = @request.value('(/searchRe
ELSE 0
END
END = 1
AND
CASE WHEN @request.exist('/searchReq
THEN 1
ELSE
CASE WHEN svo.city = @request.value('(/searchRe
ELSE 0
END
END = 1
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER