such as "order by col_location", if location is the same, then "order by col_time"
例如“order by col_location”,如果位置相同,则“order by col_time”
3 个解决方案
#1
1
You can string columns in an ORDER BY, separated by commas.
您可以按顺序将列串起来,用逗号分隔。
#2
4
SELECT * FROM something
ORDER BY col_location, col_time DESC;
#3
0
As others have said,listing the different columns in order of priority. You can also go one step further and build logic into your ORDER BY
so that it becomes conditional e.g.
正如其他人所说,按优先级列出不同的列。你也可以更进一步,将逻辑构建到你的顺序中,使它成为条件句。
order by case when col_location = col_something_else then
col_location
else
col_time
end
#1
1
You can string columns in an ORDER BY, separated by commas.
您可以按顺序将列串起来,用逗号分隔。
#2
4
SELECT * FROM something
ORDER BY col_location, col_time DESC;
#3
0
As others have said,listing the different columns in order of priority. You can also go one step further and build logic into your ORDER BY
so that it becomes conditional e.g.
正如其他人所说,按优先级列出不同的列。你也可以更进一步,将逻辑构建到你的顺序中,使它成为条件句。
order by case when col_location = col_something_else then
col_location
else
col_time
end