BeardedSith
Member
- Local time
- Yesterday, 23:30
- Joined
- Feb 5, 2020
- Messages
- 73
I have a query where I'm trying to read only the short date out of a table's "PurchaseDate" column (which is formatted as short date, but includes the time when input from a form) and count those unique short dates.
Details:
I have a database that tracks customer rewards. When a customer comes in on 6 separate days and makes purchases, it counts as 1 "purchase" when a customer makes multiple purchases on a single day. We need 6 unique dates, no matter the # of purchases made. The issue I'm having is when the date is saved to my table, it includes the time. So it's nearly impossible that two date entries will be identical, making my counts off. So I'm trying to reformat/trim/whatever the PurchaseDate column THEN count.
Here's what I have now, and it's counting every entry as a single "PurchaseDate" entry as a distinct entry:
Testing Query: This query isn't actually something I'm using, it's just to test the process of calculating each "PurchaseDate" entry as a DISTINCT entry
This is the "real" query I'm trying to accomplish this with:
Note: "Count([sqryCalc2]![DatePurchase]) AS DateCount" is a testing column that I'm using to try to get this to work all in one query.
Follow-up question: Is it possible to pull DISTINCT values AND Non-DISTINCT values (two different columns) in the same SQL statement?
Details:
I have a database that tracks customer rewards. When a customer comes in on 6 separate days and makes purchases, it counts as 1 "purchase" when a customer makes multiple purchases on a single day. We need 6 unique dates, no matter the # of purchases made. The issue I'm having is when the date is saved to my table, it includes the time. So it's nearly impossible that two date entries will be identical, making my counts off. So I'm trying to reformat/trim/whatever the PurchaseDate column THEN count.
Here's what I have now, and it's counting every entry as a single "PurchaseDate" entry as a distinct entry:
Testing Query: This query isn't actually something I'm using, it's just to test the process of calculating each "PurchaseDate" entry as a DISTINCT entry
Code:
SELECT DISTINCT sqryCalc2.MemberID, Count(Format([sqryCalc2]![DatePurchase],"Short Date")) AS DatePurchase
FROM sqryCalc2
GROUP BY sqryCalc2.MemberID;
This is the "real" query I'm trying to accomplish this with:
Code:
SELECT sqryCalc1.ID, Count(sqryCalc2.MemberID) AS NumPurchases, Sum(Nz([DailyPurchaseTotal],0)) AS SumOfPurchaseAmount, sqryCalc1.RealDate, Count([sqryCalc2]![DatePurchase]) AS DateCount
FROM sqryCalc1 LEFT JOIN sqryCalc2 ON sqryCalc1.ID = sqryCalc2.MemberID
GROUP BY sqryCalc1.ID, sqryCalc1.RealDate;
Follow-up question: Is it possible to pull DISTINCT values AND Non-DISTINCT values (two different columns) in the same SQL statement?