Link to home
Start Free TrialLog in
Avatar of DBA2000
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('/searchRequest/mlsNumber') = 0
                        THEN 1
                        ELSE
                              CASE WHEN svo.MlsNum = @request.value('(/searchRequest/mlsNumber)[1]', 'varchar(20)') THEN 1
                              ELSE 0
                              END
                        END = 1

            AND
                  CASE WHEN @request.exist('/searchRequest/zipCode') = 0
                        THEN 1
                        ELSE
                              CASE WHEN svo.zip = @request.value('(/searchRequest/zipCode)[1]', 'varchar(500)') THEN 1
                              ELSE 0
                              END
                  END = 1
            
            AND
                  CASE WHEN @request.exist('/searchRequest/city') = 0
                        THEN 1
                        ELSE
                              CASE WHEN svo.city = @request.value('(/searchRequest/city)[1]', 'varchar(50)') THEN 1
                              ELSE 0
                              END
                        END = 1
SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DBA2000
DBA2000

ASKER

I get it!  Thank you very much.