0
select DISTINCT(cctv_id), cctv.[name] from points_cctv left join cctv on points_cctv.[cctv_id] = cctv.[id]

我想计算points_cctvwhere的记录数points_cctv.[cctv_id] = cctv.[id]并将其显示为上述查询中的附加列。当我插入count(points_cctv.[cctv_id])时,它只会给我一行。

4

1 回答 1

1
select cctv_id, cctv.[name], count(cctv_id)
from points_cctv left join cctv on points_cctv.[cctv_id] = cctv.[id]
group by cctv_id, cctv.name
于 2012-12-11T23:06:48.890 回答