在工作台上打开一个新会话并尝试运行此查询此查询在第一次执行时返回计数“15”,在第二次执行时返回“4”为什么会这样..
select count(id)
from (
select *,@num := if(@company_id = company_id, @num + 1, 1) as row_number,@company_id := company_id as dummy
from salebuild_ctl.company_contact
where id in (12352,59898,59899,59900,59901,59902,59903,59904,14047,15196,15197,41402,41403,41404,41405)
order by company_id, date_created asc
) as x
where x.row_number <= 2;