Mysql数据跳跃检查

时间:2011-07-15 12:18:18

标签: mysql

我有一个看起来像这样的表

MAC-ADDRESS | ACCESSPOINT | TIMESTAMP

所有接入点每隔15分钟将数据推送到表中。

我想运行一个查询来告诉我在一个给定的datim范围内出现在多个接入点上的MAC地址?

5 个答案:

答案 0 :(得分:0)

尝试类似......

select mac 
where datim between firstdate and lastdate
group by mac
having count(*) > 1

- 删除了额外的acc表单组... JK

答案 1 :(得分:0)

查询将如下:

Select `MAC_ADDRESS`,`ACCESSPOINT`,`TIMESTAMP`,count(*) as occurences from
theTable where occurences > 1 and `TIMSTAMP` between TIME1 and TIME2 
group by `MAC_ADDRESS` order by occurences desc ;

这将为您提供最重复的mac地址列表,后面是相同接入点上的较小的地址。

答案 2 :(得分:0)

试试这个:

SELECT `MAC-ADDRESS`
  FROM mytable
    WHERE `TIMESTAMP` BETWEEN <YOUR-TIMESTAMP-1> AND <YOUR-TIMESTAMP-2>
    GROUP BY `ACCESSPOINT`
    HAVING COUNT(1) > 1

答案 3 :(得分:0)

SELECT mac_address
     , COUNT(DISTINCT accesspoint) AS occurences
FROM maclist
WHERE `timestamp` BETWEEN @StartTimestamp AND @EndTimestamp
GROUP BY mac_address
HAVING COUNT(DISTINCT accesspoint) > 1

答案 4 :(得分:-1)

中选择mac,count(不同名称)作为occ

(从maclist中选择macname 其中datim介于“2011-07-08 00:00:00”和“2011-07-14 23:59:59”之间 按名称分组,mac按Mac排序)

作为tmo group by mac,其中occ> 1;

这对我有用