4 solutions


  • 0

    //V1.1 use groupby and max

    select max(a.num) as num
    from (select num from number group by num having count(*)=1) as a
    

    //V1.2 use groupby with order by limit

    select(
    	select num from number
            group by num having count(*) = 1
    	order by num desc limit 0,1
    ) as num;
    

    //V2.1 no groupby with max

    select max(a.num) as num
    from number a
    where (select count(b.num) from number b where b.num = a.num) = 1;
    

    //V2.2 no groupby with order by limit

    select( 
            select * from number a
    	where (select count(b.num) from number b where b.num=a.num) = 1
    	order by a.num desc limit 0,1
    ) as num

Log in to reply
 

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