Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2014
    Posts
    4

    Unanswered: How to use order by for more than 1 attributes

    Question:
    Create a report to display the last name, salary and commission of all employees
    who earn commissions. Sort data in descending order of salary and commissions.

    Here's my first attempt using this code:

    select last_name, salary, commission_pct
    from employees
    where commission_pct is not null
    order by salary desc
    /


    and it produced result in attachment 1. Since the question required us to order by salary and commissions, here's my second attempt:

    select last_name, salary, commission_pct
    from employees
    where commission_pct is not null
    order by salary,commission_pct desc


    Somehow it produces result in attachment 2 which is all in acsending order, why is that so? how can I solve this? Thank you!
    Attached Thumbnails Attached Thumbnails 1.JPG   2.JPG  

  2. #2
    Join Date
    Dec 2007
    Posts
    253
    You want salary in descending order?
    salary desc, commission_pct

Posting Permissions

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