I need a query to sort by a field called Child_Key, however, when I use "Order By" in the SQL below, it gives me a syntax error. I am using an alias on the table, and two aliases to create two copies of another table, but I don't see how that could be causing the problem because the Child_Key field only exists in one table. I use this query for a mail merge with Word and need the document to print in order by Child_Key. I'm not accustomed to using straight SQL, but I have to in this case because this can't be represented in the QBE. Any help is appreciated.
SELECT A.Primary_Unusable_id AS PrimaryID, B1.Unusable_description AS Primary_Desc, A.Secondary_Unusable_id AS SecondaryID, B2.Unusable_description AS Secondary_Desc, A.Unusable_date, A.Child_Key, A.Child_name, A.Additional_Comments, db_country.SPM_name
FROM ((tblUnusables AS A LEFT JOIN tblUnusableDefn AS B1 ON A.Primary_Unusable_id = B1.Unusable_id) LEFT JOIN tblUnusableDefn AS B2 ON A.Secondary_Unusable_id = B2.Unusable_id) INNER JOIN db_country ON LEFT(A.Child_Key,2) = db_country.country_code
WHERE (((B1.Unusable_type)="upd"
GROUP BY A.Primary_Unusable_id, B1.Unusable_description, A.Secondary_Unusable_id, B2.Unusable_description, A.Unusable_date, A.Child_Key, A.Child_name, A.Additional_Comments, db_country.SPM_name
ORDER BY A.Child_Key
HAVING (((A.Unusable_date)=(select max(unusable_date) from tblUnusables)));