Greetings,
Using Access 97. I believe that in order to accomplish my goal with this thread, I will have to use a select query with multiple expressions. I'm not even sure if that is possible, but assuming it is, here goes:
The database I am working with is basically an order tracking system. One thing it does is store three different fees in each record along with the date the order "closed" and the name of the sales person who got credit for the order.
I'm using the following SQL to calculate gross revenue on a report for our fiscal year 2005 (Dec 1, 2004 ~ Nov 30, 2005). As I have it now, it works perfectly.
The DLookUp in the SELECT clause is just for sorting purposes. The criteria in the HAVING clause just eliminates "House Accounts" from showing on the report.
The thing I am looking to add to this query is an expression to Divide the TOTAL field by the OrderCount field so I can get an "Average Total per Order" type of thing.
When I attempt this by trying to Sum([Total] / [OrderCount]) in the query, I get an error message saying: "Subqueries can not be used in the expression (Sum([Total]/[OrderCount])).
I've also tried similar things using unbound control boxes on forms and VB code behind the form, to no success, but I believe the solution is in SQL anyway. Any ideas?
Using Access 97. I believe that in order to accomplish my goal with this thread, I will have to use a select query with multiple expressions. I'm not even sure if that is possible, but assuming it is, here goes:
The database I am working with is basically an order tracking system. One thing it does is store three different fees in each record along with the date the order "closed" and the name of the sales person who got credit for the order.
I'm using the following SQL to calculate gross revenue on a report for our fiscal year 2005 (Dec 1, 2004 ~ Nov 30, 2005). As I have it now, it works perfectly.
Code:
SELECT Sum([Escrow Fee]+[Policy Premium]+[Misc Fees]) AS Total, DLookUp("[Last Name]","User Names","[First_Last] = '" & [Sales Rep] & "'") AS SortOrder, Count(Escrows.[Sales Rep]) AS OrderCount, Escrows.[Sales Rep]
FROM Escrows
WHERE (((Escrows.[Closing Date])>#11/30/2004# And (Escrows.[Closing Date])<#12/1/2005#))
GROUP BY DLookUp("[Last Name]","User Names","[First_Last] = '" & [Sales Rep] & "'"), Escrows.[Sales Rep]
HAVING (((Escrows.[Sales Rep])<>"House Account"));
The DLookUp in the SELECT clause is just for sorting purposes. The criteria in the HAVING clause just eliminates "House Accounts" from showing on the report.
The thing I am looking to add to this query is an expression to Divide the TOTAL field by the OrderCount field so I can get an "Average Total per Order" type of thing.
When I attempt this by trying to Sum([Total] / [OrderCount]) in the query, I get an error message saying: "Subqueries can not be used in the expression (Sum([Total]/[OrderCount])).
I've also tried similar things using unbound control boxes on forms and VB code behind the form, to no success, but I believe the solution is in SQL anyway. Any ideas?