I have a query that selects two fields and they must be Distinct, but I want the recordset to come sorted by a field I do not select. Is there a way of accomplishing this doing a sub select? Or some other fashion?
Here is my query that I have right now
Now obviously this query will not work because I am selecting Bill Code and Price Type and trying to sort by SEQ #, but is there a way of doing this?
Here is my query that I have right now
Code:
sSQLQuery = "SELECT DISTINCT [Bill Code], [Price Type], [Reference Code] FROM CBill" & sCBILL & " WHERE [KitchenID] = '" & sKitchenID_P _
& "' AND [Customer ID] = '" & sCustomerID_P _
& "' AND [Flight #] = '" & rsFlight("Flight #") _
& "' AND [Flight # Seq] = '" & rsFlight("Flight # Seq") _
& "' AND [Segment #] = '" & rsFlight("Segment #") _
& "' AND [Flight Date] BETWEEN #" & sFromDate_P & "# AND #" & sToDate_P _
& "# AND [Recap Type] = '" & sRecapType_P _
& "' AND [Account Code] = '" & rsAccount("Account Code") & "' ORDER BY [SEQ #]"
Now obviously this query will not work because I am selecting Bill Code and Price Type and trying to sort by SEQ #, but is there a way of doing this?