Lori F
asked on
Contract Query to Count unique records based on the date.
I'm trying to figure out how to run a query that counts the unique (or distinct) values. I'm having issues with the fields being similar. Example, I have one contract with 2 different dates. I only want to count the exact dates as one. I've attached an example. The query should only be showing a count of 3 records though, not 4. Any suggestions are welcome.
ContractQuery.accdb
ContractQuery.accdb
ASKER
Thanks! That does work, but unfortunately, I need to keep at least the description field.
Any "Row" in a Totals (Summary) query might contain data from multiple records, ...so you cant really get a unique "description" of a record that summarizes multiple rows (that might contain multiple descriptions).
make sense?
For example, the "$7,000" is the sum of the first two records in the table.
Each of those two records has a different description ("Line 1" and "Line 2", respectively)
So, which of these descriptions would be displayed for the summary $7,000???
make sense?
For example, the "$7,000" is the sum of the first two records in the table.
Each of those two records has a different description ("Line 1" and "Line 2", respectively)
So, which of these descriptions would be displayed for the summary $7,000???
ASKER
That you for your comment, Jeffrey. Line 1 would be the correct description.
Does this give you the results you're looking for?
SELECT DISTINCT Contract.ContractDate, Contract.ContractNumber, Sum(Contract.ContractValue) AS SumOfContractValue, Count(Contract.ContractDate) AS CountOfContractDate, Min(Contract.Description) AS MinOfDescription
FROM Contract
GROUP BY Contract.ContractDate, Contract.ContractNumber;
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
Paul