繁体   English   中英

MySql查询问题上次在数据库中找到的记录

[英]MySql Query question last time record found in database

我有这个问题:

  SELECT device, COUNT(*) 
    FROM database.table 
GROUP BY device 
  HAVING count(*) > 1 
ORDER BY device;

我需要做的是添加一个列,显示设备上次连接到数据库的时间。

该表的结构如下:

ID, device(string),
data1(int),data2(int), 
time(timestamp), 
data3(int),
data4(int)

谢谢

  select device, count(*) as cnt, max(time) <-- same as latest time
    from database.table 
group by device
  having cnt>1
order by device;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM