//第一图直接查询出所有的id
SELECT
d.id
FROM
t_device d
LEFT JOINt_device_collect_state a on d.id = a.device_collect_id
LEFT JOIN t_group b on d.group_id = b.id
LEFT JOIN t_farm c on d.farm_id = c.id
where
d.del_flag = '0' and d.type =2 and c.id =1
order by b.create_time desc
//第二图 查询所有id(已经去重)
SELECT
distinct d.id
FROM
t_device d
LEFT JOINt_device_collect_state a on d.id = a.device_collect_id
LEFT JOIN t_group b on d.group_id = b.id
LEFT JOIN t_farm c on d.farm_id = c.id
where
d.del_flag = '0' and d.type =2 and c.id =1
order by b.create_time desc
//第三图 求和(去重求和)
SELECT
count(distinct d.id)
FROM
t_device d
LEFT JOINt_device_collect_state a on d.id = a.device_collect_id
LEFT JOIN t_group b on d.group_id = b.id
LEFT JOIN t_farm c on d.farm_id = c.id
where
d.del_flag = '0' and d.type =2 and c.id =1
order by b.create_time desc