SELECT id ,
name ,
cy ,
cot
FROM [table]
LEFT JOIN ( SELECT cy ,
COUNT(cy) AS 'cot'
FROM [table]
GROUP BY cy
) b ON [table].cy = b.cy
ORDER BY id
select name,cy,count(1) from aa group by name,cy;
select name,cy,count(1) from aa where name='w' group by name,cy;
select a.* ,b.cot from AA a left join (select cy ,count(name) as cot from aa group by cot) b on a.cy=b.cy