1、select * from table order by 欄位 desc
這是按此欄位的降序排.
2、select * from table order by 欄位 asc
這是按升序排.
3、舉個例子:
Public Sub SortX()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
rst.CursorLocation = adUseClient
cnn.Open "DSN=Pubs;Provider=MSDASQL;uid=sa;pwd=;"
rst.Open "SELECT * FROM Authors", cnn, _
adOpenStatic, adLockReadOnly, adCmdText
SortXprint "Initial Order", rst
rst.Sort = "au_lname ASC, au_fname ASC"
SortXprint "Last Name Ascending", rst
rst.Sort = "au_lname DESC, au_fname ASC"
SortXprint "Last Name Descending", rst
rst.Close
cnn.Close
End Sub
1、select * from table order by 欄位 desc
這是按此欄位的降序排.
2、select * from table order by 欄位 asc
這是按升序排.
3、舉個例子:
Public Sub SortX()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
rst.CursorLocation = adUseClient
cnn.Open "DSN=Pubs;Provider=MSDASQL;uid=sa;pwd=;"
rst.Open "SELECT * FROM Authors", cnn, _
adOpenStatic, adLockReadOnly, adCmdText
SortXprint "Initial Order", rst
rst.Sort = "au_lname ASC, au_fname ASC"
SortXprint "Last Name Ascending", rst
rst.Sort = "au_lname DESC, au_fname ASC"
SortXprint "Last Name Descending", rst
rst.Close
cnn.Close
End Sub