Post Closed as "Off-topic" by Colin 't Hart, kevinsky, mustaccio, Tony Hinkle, Joe Obbish
    Removed from Hot Network Questions by Paul White says GoFundMonica
4 Meaningful title (more easily indexed by Google), table structure and data to actual SQL, more professional tone
source | link

Order by does not work as I expect Only first column in ORDER BY clause is sorted

It seems like I've understoodmisunderstood the concept of 'Order by' completely wrong.

I have a table with this structure and data:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

CREATE TABLE TestTest (Value1 Int, Value2 Int);

INSERT INTO TestTest VALUES
(1, 10),
(2, 9),
(3, 8),
(4, 7),
(5, 6),
(6, 5),
(7, 4),
(8, 3),
(9, 2),
(10, 1)
;

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Bothboth columns Value1Value1 and Value2Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

enter image description hereValue1 in descending order, Value2 not

I'm really really confused!!!Why isn't Value2 also in descending order?

Order by does not work as I expect

It seems like I've understood the concept of 'Order by' completely wrong.

I have a table with this structure:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

enter image description here

I'm really really confused!!!

Only first column in ORDER BY clause is sorted

It seems like I've misunderstood the concept of 'Order by'.

I have a table with this structure and data:

CREATE TABLE TestTest (Value1 Int, Value2 Int);

INSERT INTO TestTest VALUES
(1, 10),
(2, 9),
(3, 8),
(4, 7),
(5, 6),
(6, 5),
(7, 4),
(8, 3),
(9, 2),
(10, 1)
;

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

Value1 in descending order, Value2 not

Why isn't Value2 also in descending order?

    Became Hot Network Question
3 added 61 characters in body
source | link

It seems like I've understood the concept of 'Order by' completely wrong.

I have a table with this structure:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

enter image description here

I'm really really confused!!!

It seems like I've understood the concept of 'Order by' completely wrong.

I have a table with this structure:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

enter image description here

It seems like I've understood the concept of 'Order by' completely wrong.

I have a table with this structure:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output:

enter image description here

I'm really really confused!!!

2 deleted 44 characters in body
source | link

Hope you're doing well Something wired happened and itIt seems like I've understood the concept of 'Order by' completely wrong  .  

I have a table with this structure  :

TestTest (Value1 Int , Value2 Int)
TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1. With

With the query below  :

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output  : Both columns Value1 and Value2 from 10 to 1 Causebecause I use DESCDESC for both columns. But

But I see this output:   

enter image description here

Hope you're doing well Something wired happened and it seems like I've understood the concept of 'Order by' completely wrong  .  

I have a table with this structure  :

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1. With the query below  :

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output  : Both columns Value1 and Value2 from 10 to 1 Cause I use DESC for both columns. But I see this output:  enter image description here

It seems like I've understood the concept of 'Order by' completely wrong.

I have a table with this structure:

TestTest (Value1 Int , Value2 Int)

Data for column Value1 is from 1 to 10 and for column Value2 is from 10 to 1.

With the query below:

Select Value1 , Value2
from TestTest
order by Value1 desc,Value2 desc

I expect to have this output: Both columns Value1 and Value2 from 10 to 1 because I use DESC for both columns.

But I see this output: 

enter image description here

1
source | link