Results 1 to 3 of 3

Thread: Need SQl Statement

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Need SQl Statement

    QUESTION IS CAPITALIZED AT THE BOTTOM...

    There is a table Employee, with three columns: Name (varchar), Department (varchar) and Salary (int):

    Name Department Salary
    John Manufacturing 30000
    James Manufacturing 30000
    Michael Manufacturing 30000
    Andrea Manufacturing 30000
    David Manufacturing 40000
    Dennis Manufacturing 50000
    Doug Manufacturing 50000
    Ellen Accounting 50000
    Eric Accounting 50000
    Glen Accounting 50000
    Gabriel Accounting 50000
    Henry Shipping 60000
    Harry Shipping 60000
    Kyle Shipping 60000
    Kurt Shipping 60000
    Ken Shipping 60000
    Larry Manufacturing 70000
    Lenny Manufacturing 80000
    Lisa Accounting 80000
    Liz Accounting 80000
    Manny Accounting 80000
    Margaret Accounting 80000
    Matthew Shipping 80000
    Norbert Shipping 90000
    Norman Shipping 90000

    List all the employees, and also list the other employees that have the same salary. For example, if John Smith has a salary of $50,000, then under John Smith, show everyone else who also has a salary of $50,000. Order this by the employee with the lowest salary.

    Results:

    John 30000
    James
    Michael
    Andrea
    James 30000
    John
    Michael
    Andrea
    Michael 30000
    John
    James
    Andrea
    Andrea 30000
    John
    James
    Michael
    David 40000
    Dennis 50000
    Doug
    Ellen
    Eric
    Glen
    Gabriel
    Doug 50000
    Dennis
    Ellen
    Eric
    Glen
    Gabriel
    Ellen 50000
    Dennis
    Doug
    Eric
    Glen
    Gabriel
    …..


    WHAT IS THE SQL STATEMENT NEEDED TO ACHIEVE THESE RESULTS?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Why don't you just select * and ORDER BY salary?

  3. #3
    Join Date
    Dec 2011
    Posts
    2

    What about...

    Write a SQL statement that will provide the employee Name and Salary for the person with the 5th highest salary.

Posting Permissions

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