在SQL中对两列进行排序
我有一张如下表格
FirstName |姓氏| YearOfBirth
----------------------------------------
托马斯| Alva Edison | 1847年
本杰明|富兰克林| 1706
托马斯|更多| 1478
托马斯|杰斐逊| 1826
我想按Lastname ASC和YearOfBirth ASC这两个栏目排序
有可能吗?任何人都可以帮助我。
我尝试过:
我试过了,但只有一列正在工作。对于这两列都没有用。
I have a table like below
FirstName | LastName | YearOfBirth
----------------------------------------
Thomas | Alva Edison | 1847
Benjamin | Franklin | 1706
Thomas | More | 1478
Thomas | Jefferson | 1826
I want to sort by both columns like 'Lastname ASC' and 'YearOfBirth ASC'
Is it possible??Can anyone help me.
What I have tried:
I tried ,but only for one column is working.For both columns it is not working.
试试..
try ..
SELECT * FROM table ORDER BY Lastname DESC, YearOfBirth ASC
是否有可能?任何人都可以帮助我。
Is it possible??Can anyone help me.
可以通过列和然后订购另一个(例如,参见 MSDN 一> [ ^ ])。在您的方案中,它将是
It is possible to order by a column and then by another one (see, for instance MSDN[^]). In your scenario it would be
... ORDER BY Lastname ASC, YearOfBirth ASC;
请注意,在您的样本数据中,'YearOfBirth'的排序将无关紧要。
Please note, in your sample data the ordering by 'YearOfBirth' would be irrelevant.