问一下是不是3月初.6月末.
如果是:
select count(id) from client where to_days(dt1)>=to_days(2002-3-1) and  to_days(dt1)<to_days(2002-7-1) and to_days(dt2)<to_days(2002-7-1)
也就是接待时间在3月1日到6月30日并且失败时间在7月1日以前的
你看这么写行不.

解决方案 »

  1.   

    我需要得到的各月分别有多少正在洽谈中。而不是各月之和,有点难度大家努力喔!如果只查3月的应该是
    select count(id) from client where dt1<='2002-3-31' and (dt2>='2002-3-31' or dt2 is null) and (dt3>'2002-3-31' or dt3 is null)
      

  2.   

    select month(dt1) as month,count(id) as total from client where dt1<='2002-3-31' and (dt2>='2002-3-31' or dt2 is null) and (dt3>'2002-3-31' or dt3 is null) group by month