Hi I have the following table,
FILE_NAME | MODIFIED_DATE | PRIORITY |
---|---|---|
A | 2022-10-11 | 1 |
A | 2022-10-03 | 1 |
A | 2022-10-02 | 1 |
B | 2022-10-11 | 3 |
B | 2022-10-01 | 3 |
C | 2022-10-11 | 2 |
D | 2022-10-11 | 4 |
I would like to order the table based on MODIFIED_DATE, PRIORITY and FILE_NAME.
For example,
FILE_NAME | MODIFIED_DATE | PRIORITY |
---|---|---|
A | 2022-10-11 | 1 |
C | 2022-10-11 | 2 |
B | 2022-10-11 | 3 |
D | 2022-10-11 | 4 |
A | 2022-10-03 | 1 |
A | 2022-10-02 | 1 |
B | 2022-10-01 | 3 |
What would be the most efficient way to do this?
2
Answers
Most efficient seems to be the only reasonable one to me, i.e.
Looking at the sample data and expected output, It seems like you need ordering in following manner
MODIFIED_DATE DESC
PRIORITY ASC
FILE_NAME ASC
(Not sure forFILE_NAME
as not clear from your output)Best is to use
ORDER BY
clause withASC
(default)/DESC
which is faster than any other method know to you (At least, I am not aware about any other method)So you can use