I have a query with a few fields that I am creating. I want to order by on one of the fields that I create but I get an error asking for the order by as a parameter.
SELECT IIF(Billing.invoice_num = -1,oInvoice & " (Payment)",Billing.invoice_num) AS newinvnum, Billing.method, IIF(IsNull(Billing.provided),Billing.paid,Billing.paid + Billing.provided) AS totalpaid,IIF(paid>0,"Customer", "Insurance") AS newfield, PatientList.l_name & ", " & PatientList.f_name AS fullname
FROM Billing INNER JOIN PatientList ON Billing.pat_num = PatientList.prim_key
WHERE (((Billing.paid)>0)) OR (((Billing.provided)>0)) ORDER BY newinvnum;
SELECT IIF(Billing.invoice_num = -1,oInvoice & " (Payment)",Billing.invoice_num) AS newinvnum, Billing.method, IIF(IsNull(Billing.provided),Billing.paid,Billing.paid + Billing.provided) AS totalpaid,IIF(paid>0,"Customer", "Insurance") AS newfield, PatientList.l_name & ", " & PatientList.f_name AS fullname
FROM Billing INNER JOIN PatientList ON Billing.pat_num = PatientList.prim_key
WHERE (((Billing.paid)>0)) OR (((Billing.provided)>0)) ORDER BY newinvnum;