Merge sub-queries to a single query
This should work:

-- Query every name_changes where rownum &lt;= per group limit (2)
select * from (
    -- subquery for attaching rownumber counter for `name:city` groups
    select `date`, name, city , old_mul, new_mul, 
        case when @lag != concat(name, ':', city) then @rownum:=1 else @rownum:=@rownum+1 end as rownum, 
        @lag:=concat(name, ':', city)
    from name_changes,
    -- init values
    (select @rownum:=0) init_rownum, 
    (select @lag:=null) init_la
    order by name, city, d desc
) numbered
where rownum &lt;= 2;


I had a previous answer about mimicking window functions in mysql: How do I write this query? where I explained this in more details.