这是我的查询
select count(fp.kat),fs.cid,fcc.cid
from tbl1 fs
left join tbl2 fp on fs.cid=fp.cid
left join tbl3 fcc on fcc.cid=fp.kat
group by fcc.cid,fs.cid
输出
count(fp.kat) cid cid
3 1 3
2 2 3
1 3 4
2 4 4
但我想将输出作为
count cid
2 3
2 4
我不知道这个问题,请让我知道
答案 0 :(得分:0)
select count(*), x
from
(
select count(fp.kat),fs.cid,fcc.cid as x
from tbl1 fs
left join tbl2 fp on fs.cid=fp.cid
left join tbl3 fcc on fcc.cid=fp.kat
group by fcc.cid,fs.cid
) y
group by x