<cfquery datasource="#Application.Read#" name="qryGetRepeatSales">
SELECT *, COUNT(*) AS totalcount, SUM(Cost) AS totalcost
FROM orders, orderitems
WHERE orders.OrderID = orderitems.OrderID
AND OrderDate >= '#DateFormat(StartTime, "yyyy-mm-dd")#'
GROUP BY UserID
HAVING totalcount > 1
</cfquery>
<cfquery dbtype="query" name="qrySubGetRepeatSales">
SELECT SUM(totalcost) AS totalcost, COUNT(totalcount) AS totalcount
FROM qryGetRepeatSales
</cfquery>
The problem I'm having is when the "OrderDate" line is in the top query, I get the correct results. If I move it to the bottom query, the totalcost and totalcount end up being 1 or 2 less. The date filter really needs to be in the bottom query. What am I missing?
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

