Very strange test-case


  • 0
    D

    For this task I provided next solution:

    select dep.name Department,
        emp.name Employee,
        emp.salary Salary
    from department dep 
    inner join (
    select departmentid,
        salary,
        name,
    	@rownum:= IF(@groupname=departmentid,@rownum + 1 ,1) rownum, 
    	@groupname := departmentid groupname
    from (select 
    		departmentid, 
    		salary,
            name
    		from employee 
    		order by departmentid, salary desc)  emp,
    (SELECT @rownum := 0, @groupname := 0)  as vars
    ) emp
    on dep.id= emp.departmentid
    where rownum <=3
    

    On submission I got the next test case, can someone tell me why it has four results for IT group as expected result if in the task it says I need top 3?0_1512577874137_codeleet.png


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.