表
id A B
1 3 5
2 1 3
3 7 8
4 5 3
5 2 5
6 11 5
我想要结果
A count
3 2
5 3
计数:B中存在A的次数
答案 0 :(得分:3)
您需要自行加入(匿名)表格。
SELECT A1.A, COUNT(*)
FROM Anonymous AS A1
JOIN Anonymous AS A2 ON A1.A = A2.B
GROUP BY A1.A;