解决方案 »

  1.   


    //把todayData 设置为int类型 默认值为0;
    1、select max(AddTime) from table where todayData <  80;2、描述的跟你给出的例子不相符;不够清楚;
      

  2.   

    1
    select *  from tb A 
    where not exists (select 1 from tb B where A. todayData=B. todayData and A. AddTime<B. AddTime)
      

  3.   

    1:select AddTime  from table where todayData <  80 order by AddTime DESC
      

  4.   

    比如现在的表结构查出的应该是 2014-01-09
    select max(AddTime)
    from (
    select AddTime,todayData
    from 表A
    where todayData<80
    union all
    select AddTime-interval 1 day as AddTime,0
    from 表A t
    where not exists (select 1 from 表A where AddTime=t.AddTime-interval 1 day )
    ) x
      

  5.   

    以下是第二个问题如表A所示
    需要查到当前数据大于80且连续每天都包含数据的总数 ,按照当前日期往前推算
    查出的结果应该为
    8                            2014-01-10                          90如表B所示
    需要查到当前数据大于80且连续每天都包含数据的总数 ,按照当前日期往前推算
    查出的结果应该为
    8                            2014-01-09                          91
    9                            2014-01-10                          90

    select * from 表A 
    where AddTime>=(
    select max(AddTime)
    from 表A t
    where not exists (select 1 from 表A where AddTime=t.AddTime-interval 1 day )
    )