I have the following initial query.
Select * from Table
where Datum1 < @Datum2
and Employee_Name = Employee_Name
But I want to filter Datum1 < Datum2
only if the Employee is a member of the group students. For non student employees I do not want to filter Datum1 < @Datum2
.
My first idea was
Select * from Table
where CASE WHEN Datum1 < @Datum2 END
and Employee_Name = Employee_Name
But this is not working. So I have checked other SO Solutions refering to where clause in sql if statement
but all of them take care of problems where we have a eiter or decision like if Student then Datum1 < @Datum2 else Datum2 < @Datum2
. But I want the statement not be considered at all if the condition is true. Anyone who can help me here?