I have a scenario where I need to select a list of employees from a table where both a min birthdate and a max birthdate could be passed. So what I need is something like this : -
Select all from employees where active=1 and
if (not @min_birthday is null and @max_birthday is null)
birthday > @min_birthday
else if (@min_birthday is null and not @max_birthday is null)
birthday < @max_birthday
else if (not @min_birthday is null and not @max_birthday is null)
birthday between (@min_birthday and @max_birthday)
Is there anyway to acomplish the above in a single sql statement?