LEFT JOIN Oracle DB line limit



  • How can the number of lines taken from the table be reduced Jobsso that all values from the first table and only 10 values from the second shall be taken into account selecting the values?

    SELECT *
    FROM HR.JOB_HISTORY 
    LEFT JOIN HR.JOBS 
    ON JOB_HISTORY.job_id = JOBS.job_id
    WHERE rownum < 10;
    


  • There you go.

    select * 
    from hr.job_history jh 
    left join (
        select * 
        from hr.jobs jb
        order by job_id
        fetch first 10 rows only) jb on jb.job_id = jh.job_id
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2