Last answered:

20 Jun 2022

Posted on:

16 Jun 2022

0

first column always ascending when combined by a second descending column?

Hi

When I ran this code

SELECT
    *
FROM
    employees
ORDER BY first_name, last_name DESC;

Only last_name was ordered in descending order, and first_name appeared in ascending order. So, I suppose the first field would always be in ascending order when combined with a descending order. Is that right?

1 answers ( 0 marked as helpful)
Instructor
Posted on:

20 Jun 2022

4

Hi Saeed!
Thanks for reaching out.

By default a column is sorted in an ascending way. So, if you want to sort both the first name and the last name in a descending way, you should specify it. Please, use the following code:
SELECT
    *
FROM
    employees
ORDER BY first_name DESC , last_name DESC;



Hope this helps.
Best,
Tsvetelin

Submit an answer