14 thoughts on “Eastern challenge

  1. Colin 't Hart

    OK… 67… but it does print it out 5 times… once for each job 🙂

    SELECT FIRST_VALUE(job)OVER(ORDER BY COUNT(*))FROM emp GROUP BY job

  2. Laurent Schneider Post author

    well done all!
    I first add Sten solution in mind, but Colin first solution could be a 77
    SELECT*FROM(SELECT job FROM emp GROUP BY job ORDER BY COUNT(*))WHERE ROWNUM=1

    and Colin first_value could be a 78 by adding unique
    SELECT unique FIRST_VALUE(job)OVER(ORDER BY COUNT(*))FROM lsc_emp GROUP BY job

    (unique is a rare synonym of distinct, but shorter to type 🙂 )

  3. Sokrates

    nice and great fun !

    but the question is wrong (at least, there is something missing):
    what, if there is more than one jobs that are ‘the less common’ ?

    sokrates > select job from emp;

    JOB
    ———
    bunny
    bunny
    easter
    easter

    4 rows selected.

    which of them should the query return ?
    all ?
    a randomly chosen ?
    none ?

    happy easterday to you !

  4. Pacman

    Hi, 72 for less than 100K employees companies 🙂

    select substr(min(to_char(sum(1),’00000′)||job),7)from emp group by job

  5. Pacman

    Actually we can do 61 chars for up to 90 millions employees 🙂

    select substr(min(10e6+sum(1)||job),9) from emp group by job

Comments are closed.