【发布时间】:2018-03-24 20:18:59
【问题描述】:
我有一个场景,我需要从可以传递最小生日和最大生日的表中选择员工列表。 所以我需要的是这样的:-
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)
有没有办法在一条 sql 语句中完成上述操作?
【问题讨论】:
标签: sql-server