1
我需要在where
子句中实现。在SQL Server 2008的where子句中使用if-else
我试着在case
声明,但之间不能case
语句中使用
where
if start_mth < end_mth
mth_no between start_mth and end_mth
else start_mth > end_mth
mth_no between start_mth and 12
or
mth_no between 1 and end_mth
看起来像你的条件是不正确的,因为它使用相同的start_mth
AnandPhadke
无论如何,您无法使用其他条件为“else start_mth> end_mth”的条件。 – Geethanga
如果你确实需要一个“if-else”,那么你应该使用start_mth> = end_mth。因为如果你没有使用它,那么=就会丢失,如果值相等,查询就会中断。如果你不需要它,那么你需要一个“if-else if”而不是“if-else” –