Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: Siimple query to write

    i want the query that gives me the sal of top ten employees in the emp table?? the emp table has emp_no and sal fields

  2. #2
    Join Date
    Aug 2001
    Posts
    24

    Re: Siimple query to write

    Originally posted by khanna_nitin
    i want the query that gives me the sal of top ten employees in the emp table?? the emp table has emp_no and sal fields
    Select Top 10 Emp_Name, Sal from Emp
    Order By Sal Desc

  3. #3
    Join Date
    May 2003
    Posts
    87

    Re: Siimple query to write

    Originally posted by khanna_nitin
    i want the query that gives me the sal of top ten employees in the emp table?? the emp table has emp_no and sal fields
    Multiple ways to write -- but here is the basic one.

    select emp_no, sal
    from ( select emp_no, sal
    from emp
    order by SAL desc )
    where rownum <= 10
    order by emp_no, sal
    /

  4. #4
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208

    Re: Siimple query to write

    Top 10 works in Sql - Server, but I don't think there is an equivilent in Oracle

    so I use

    PHP Code:
    Select Emp_noSal
    From 
    (Select Emp_noSal
              From Emp
              Order by Sal Desc
    )
    Where Rownum 10 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •