如何离开联盟计数?

时间:2012-12-11 22:56:06

标签: database sqlite

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])时,它会给我一行。

1 个答案:

答案 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