检查订单表最近10分钟有没订单导入
select count(*)<br>from ods_pck_info<br>where create_date > date_sub(now(), interval 10 minute)<br>and process_center_id=1111
检查最近一个小时有没订单导入<br>
select count(*)<br>from ods_pck_info opi<br>where opi.create_date > date_sub(now(), interval 1 hour)<br>and process_center_id=1111;
检查最近一小时跟最近一周内的同小时区间单量对比
select count(*)<br>into @curCount<br>from ods_pck_info opi<br>where opi.create_date > date_sub(now(), interval 1 hour);<br><br>select min(t.hisCount) minWeekCount,<br> avg(t.hisCount) avgWeekCount,<br> @curCount,<br> (@curCount / min(t.hisCount)) < 0.8 as 最近一小时导入单量小于最近一周最小单量的百分值80<br>from (<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 1 day), interval 1 hour)<br> and date_sub(now(), interval 1 day)<br><br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 2 day), interval 1 hour)<br> and date_sub(now(), interval 2 day)<br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 3 day), interval 1 hour)<br> and date_sub(now(), interval 3 day)<br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 4 day), interval 1 hour)<br> and date_sub(now(), interval 4 day)<br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 5 day), interval 1 hour)<br> and date_sub(now(), interval 5 day)<br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 6 day), interval 1 hour)<br> and date_sub(now(), interval 6 day)<br> union<br> select count(*) as hisCount<br> from ods_pck_info opi<br> where opi.create_date between date_sub(date_sub(now(), interval 7 day), interval 1 hour)<br> and date_sub(now(), interval 7 day)<br> ) t;