I have this query in MsSQL
SELECT PersonnelID, Name, EmpStartCalc,
MAX(PositionDetailsValidFromCalc) PD ,
Max(PositionHierValidFromCalc) PH,
Max(PWAValidFromCalc) Position,
Max(RowId) As RowId
FROM TV_IAMintegration_VW
where
EmpStartCalc >= 20200101 and
EmpStartCalc <= 20200131 and
((20200131 > PositionDetailsValidFromCalc And
20200101 < PositionDetailsValidToCalc) or
PositionDetailsValidToCalc is null)
GROUP BY PersonnelID, Name, EmpStartCalc
ORDER BY PersonnelID Asc.
I have a scenario where I need the query to return Null, example:
When where clause doesn't successfully meet I need the query to return null in the following columns
MAX(PositionDetailsValidFromCalc) PD , Max(PositionHierValidFromCalc) PH, Max(PWAValidFromCalc) Position
but rest of the row remains same.