(length(trim(cbkssj)) is null
这个语句应该只适用于oracle的奇怪情况,判断length等于null?!

除了这个以外奉送一条满强的sql语法,里面有很多的or和and,经过这次的经验,我发现如果写错了or和and会增加语句的难度.

已知:有两个时间字段,kssj和jssj,如果都为空则算全年,其他即使大于kssj的,算以后的时间.小于jssj的算今年开始至结束时间的.

最后的语句:
 where ((length(trim(cbkssj)) is null and
                               (length(trim(cbjssj)) is null or
                               substr(trim(cbjssj), 1, 6) >= v_yf)) or
                               (substr(trim(cbkssj), 1, 6) <= v_yf and
                               (length(trim(cbjssj)) is null or
                               substr(trim(cbjssj), 1, 6) >= v_yf)))) t1,
posted on 2007-02-15 10:50  xiazhaoxia  阅读(2539)  评论(0编辑  收藏  举报