Reputation: 29519
select DISTINCT(cctv_id), cctv.[name] from points_cctv left join cctv on points_cctv.[cctv_id] = cctv.[id]
I want to count number of records in points_cctv
where points_cctv.[cctv_id] = cctv.[id]
and show this as additional column in the above query. When I insert count(points_cctv.[cctv_id])
it will give me just one row.
Upvotes: 0
Views: 49
Reputation: 2730
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
Upvotes: 1