询问:
select city.name as name, sum(count) as views from profpostview
inner join professional as prof on prof.pfid = profpostview.viewerpfid
left join cityinfo as city on city.cityid = prof.cityid
where pfpid = _pfpid group by name order by views desc;
Run Code Online (Sandbox Code Playgroud)
输出:
**name , views**
'Ahmedabad', '14'
'Gandhinagar', '7'
'Mumbai', '5'
'Aalborg', '5'
'Rajkot', '3'
'Bhavnagar', '2'
'Baroda', '1'
Run Code Online (Sandbox Code Playgroud)
必需的:
**name, views**
'Ahmedabad', '14'
'Gandhinagar', '7'
'Aalborg', '5'
'others', '11
Run Code Online (Sandbox Code Playgroud)
解释:当行数超过 3 时,我想通过添加视图数来合并行。 Profpostview 表通过 pfpid 与 profpostinfo 相关联,而 profpostinfo 表又通过 cityid …
mysql ×1