RIAS
asked on
Sql query with where clause
Hello,
I have a sql query need to add a where clause.
WHERE ( DeleteRecord is null or DeleteRecord = 0)'
I have a sql query need to add a where clause.
DECLARE @Last_Friday AS DATE = '2017-02-07'
DECLARE @This_Friday as date = '2017-02-17'
SELECT GuestName, ArrivalDate,
CASE
WHEN Extendedto IS NULL THEN DepartureDate
ELSE Extendedto
END AS DepartureDate
FROM CORRESPONDENCE
WHERE (ArrivalDate >= '2016-01-01'
AND (
(Extendedto IS NULL AND DepartureDate >= @Last_Friday)
OR Extendedto >= @Last_Friday
)
AND (ArrivalDate >= @Last_Friday AND ArrivalDate < @This_Friday)
OR (ArrivalDate < @Last_Friday
AND (
(Extendedto IS NULL AND DepartureDate >= @This_Friday)
OR Extendedto >= @This_Friday
)
)
)
Where clause to be added is : WHERE ( DeleteRecord is null or DeleteRecord = 0)'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER