Reputation: 43
I have this query:
SELECT device, COUNT(*)
FROM database.table
GROUP BY device
HAVING count(*) > 1
ORDER BY device;
What I need to do is add a column that shows the last time the device connected to the database.
The table is structured like:
ID, device(string),
data1(int),data2(int),
time(timestamp),
data3(int),
data4(int)
Thanks
Upvotes: 0
Views: 118
Reputation: 47321
select device, count(*) as cnt, max(time) <-- same as latest time
from database.table
group by device
having cnt>1
order by device;
Upvotes: 2