sql多条件检索

AND (ISNULL(@DateType,-1)=-1 or (@DateType=1 AND ((ISNULL(@StartDate,'')='01  1 1900 12:00AM' OR A.CreateDate>=@StartDate+' 00:00:00' ) AND (ISNULL(@EndDate,'')='01  1 1900 12:00AM' OR A.CreateDate<=@EndDate +'23:59:59')))
or (@DateType=2 AND ((ISNULL(@StartDate,'')='01  1 1900 12:00AM' OR A.SolveDate>=@StartDate+' 00:00:00' ) AND (ISNULL(@EndDate,'')='01  1 1900 12:00AM' OR A.SolveDate<=@EndDate +'23:59:59')))
or (@DateType=3 AND ((ISNULL(@StartDate,'')='01  1 1900 12:00AM' OR A.CloseDate>=@StartDate+' 00:00:00' ) AND (ISNULL(@EndDate,'')='01  1 1900 12:00AM' OR A.CloseDate<=@EndDate +'23:59:59')))
)

 

sql多条件检索

and (ISNULL(@DateType,-1)=-1 or (@DateType=1 or createdate>@startDate))

你可能感兴趣的:(sql)