sql - Exclusive IF Statement in WHERE clause -


i have following initial query.

select * table datum1 < @datum2 , employee_name = employee_name 

but want filter datum1 < datum2 if employee member of group students. non student employees not want filter datum1 < @datum2.

my first idea

select * table case when datum1 < @datum2 end , employee_name = employee_name 

but not working. have checked other solutions refering where clause in sql if statement of them take care of problems have eiter or decision if student datum1 < @datum2 else datum2 < @datum2. want statement not considered @ if condition true. can me here?

you can or statement, accounting both of scenarios. i'm assuming there's field called employee_group wasn't mentioned in question, should point in right direction:

select  *    table   employee_group <> 'students' or (     employee_group = 'students' , datum1 < @datum2 ) ,     employee_name = @employee_name 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -