Solved

Access 2010 Trying to find duplicate statements in a month

Posted on 2014-03-10
6
329 Views
Last Modified: 2014-03-10
I am trying to find duplicate statements that are entered in 1 month but the data entry may be off a day.  
Example: Statement Dates are 01/31/14, 02/28/14, 02/28/14, 03/30/14
          or  Statement Dates are 01/31/14, 02/28/14, 03/05/14, 03/30/14

I should only have 1 statement a month.  I wanted to try to create a field to convert the statement date to Month format, then look for duplicates in the month.

Fields:  
AccountID (Account Number)
StatementDate (Statement Date)

I tried:
Expr1: Format([StatementDate],"mmm")
0
Comment
Question by:NNiicckk
  • 3
  • 3
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39918567
try this query

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
where Count(Format([StatementDate],"yyyymm"))>1
Group by AccountID,Count(Format([StatementDate],"yyyymm"))


or

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
Group by AccountID,Count(Format([StatementDate],"yyyymm"))
having Count(Format([StatementDate],"yyyymm"))>1
0
 

Author Comment

by:NNiicckk
ID: 39918680
It says I cannot have a aggregate funtion in GROUP BY clause (Count(Format([StatementDate],"yyyymm")))
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39918711
oops sorry


select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
where Count(Format([StatementDate],"yyyymm"))>1
Group by AccountID, Format([StatementDate],"yyyymm")


or

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
Group by AccountID, Format([StatementDate],"yyyymm")
having Count(Format([StatementDate],"yyyymm"))>1
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:NNiicckk
ID: 39918850
The first one had "Cannot have aggregate function in WHERE clause (Count(Format([StatementDate],"yyyymm"))>1

The second one worked, thanks.

The results give me the # of statements in expr1 and expr2:

AccountID      Expr1      Expr2
125555                  3               3
567891               2          2


Is there a way to show the Month duplicated or should I just hide 1 of the fields?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39918875
try


select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Format([StatementDate],"yyyymm") As expr2
from tableName
Group by AccountID, Format([StatementDate],"yyyymm")
having Count(Format([StatementDate],"yyyymm"))>1
0
 

Author Comment

by:NNiicckk
ID: 39919087
That works, thanks again
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now