troubleshooting Question

Need Help writing query to calculate sales

Avatar of pcalabria
pcalabriaFlag for United States of America asked on
Microsoft AccessMicrosoft ApplicationsSQL
4 Comments1 Solution617 ViewsLast Modified:
Hello Experts, I'm using Access 2K.

I need to write a query to calculate four numbers:
Lifetime Orders
YTD Orders
LifeTime Sales (in dollars)
YTD Sales (in dollars)

 I already have code that calculates the first day of the current year.

Here's what I have so far.  The code below calculates three of the four values I need (LifeTime and YTD Orders, as well as Lifetime Sales in dollars), but I can't figure out how to calculate YTD sales in dollars with the same query.

   'New code to calculate Orders (YTD and Lifetime) and Lifetime Dollars
        strSQLtext = "SELECT Count(invoicenumber) AS LifeTimeOrders,"
        strSQLtext = strSQLtext & "SUM(ABS(shippeddate > #" & dteYTDstartDate & "# )) AS YTDOrders, "
        strSQLtext = strSQLtext & "SUM(price * Quantity) AS LifetimeDollars "
        strSQLtext = strSQLtext & "FROM invoicehistory "
        strSQLtext = strSQLtext & "where AccountNumber = " & Forms!ProspectInfo!AccountNumber & " And [quantity] <> 0;"


Thanks!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros