wisely use subquery and beat 98.33%


  • 0
    Z
    select sum(new.tiv_2016) as TIV_2016
    from
    (select distinct i1.pid, i1.tiv_2016
    from insurance i1, insurance i2
    where i1.tiv_2015 = i2.tiv_2015 and i1.pid != i2.pid and not exists
    (select *
    from insurance i3
    where i1.lat = i3.lat and i1.lon = i3.lon and i1.pid != i3.pid)
     ) as new
    

Log in to reply
 

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