标签:
DISTINCT(COL)用来对结果去除重复
比如表内容如下:
SELECT DISTINCT(id) FROM yww_test
下面的例子实现:选择过去一天,没有出现过的数据
-- 统计最原始的未上线采集数据,准备和其他表合并 DROP VIEW if EXISTS `unconnected_elemeterhead`; CREATE VIEW unconnected_elemeterhead AS SELECT DATE_SUB(curdate() , INTERVAL 1 DAY) as 'uhead_date', head.`NAME` as 'uhead_name', head.PADDRESS as head_address, head.E_BUREAU_ID as bureau_id, head.ID as 'uhead_id' FROM e_elemeterhead_link39 AS head WHERE head.`STATUS` = 0 AND head.ID NOT IN ( SELECT DISTINCT (a.E_ELEMETERHEAD_ID) FROM e_eledata AS a WHERE to_days(now()) - to_days(a.DLDT) = 1 );注意:如何确定昨天,如何统计未出现的ID
标签:
原文地址:http://blog.csdn.net/calmreason/article/details/42679051