Accepted but some issues


  • 0

    Accepted Query -

    (select name as 'name',null as 'bonus'
    from Employee
    where empId NOT IN (select empId from bonus))
    union
    (select e.name as 'name',b.bonus as 'bonus'
    from Employee e
    inner join Bonus b
    ON e.empId = b.empId
    where b.bonus < 1000);

    I tried the below left join but it doesn't work as expected. It doesn't return null for non-matched rows whereas it should.This link explains the left join. Correct me if I am wrong.

    select e.name as 'name',b.bonus as 'bonus'
    from Employee e
    left join Bonus b
    ON e.empId = b.empId
    where b.bonus < 1000;


  • 0
    F

    It's because if bonus is NULL, b.bonus < 1000 will not return True so you should add one more restriction OR b.bonus IS NULL


Log in to reply
 

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