select DISTINCT(cctv_id), cctv.[name] from points_cctv left join cctv on points_cctv.[cctv_id] = cctv.[id]
我想计算points_cctv
points_cctv.[cctv_id] = cctv.[id]
中的记录数,并将其显示为上述查询中的附加列。当我插入count(points_cctv.[cctv_id])
时,它会给我一行。
答案 0 :(得分: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