Don't use more than one duplicate


B

bw

When I have duplicate information, I only want to include one of them in my
report.
I have a "Find duplicates" query as follows:

SELECT qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum] And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

I thought using DISTINCTROW as follows would do that for my report, but each
of these produces exactly the same results. Can someone explain?

SELECT DISTINCTROW qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum] And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];
 
Ad

Advertisements

G

Guest

Try this --
SELECT qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
GROUP BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
HAVING (((Count(qryModules.BankName))>1));
 
B

bw

Thanks Karl, but that doesn't give me any records...either.
This is strange, and has me stumped.
Bernie


KARL DEWEY said:
Try this --
SELECT qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
GROUP BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
HAVING (((Count(qryModules.BankName))>1));

--
KARL DEWEY
Build a little - Test a little


bw said:
When I have duplicate information, I only want to include one of them in
my
report.
I have a "Find duplicates" query as follows:

SELECT qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As
Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum]
And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

I thought using DISTINCTROW as follows would do that for my report, but
each
of these produces exactly the same results. Can someone explain?

SELECT DISTINCTROW qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As
Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum]
And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];
 
J

John Spencer

First, try DISTINCT instead of DistinctRow. Distinct limits the
"duplication" based on the fields in the select clause. DistinctRow limits
the "duplication" based on all the fields in the table(s).

SELECT DISTINCT qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum] And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

And perhaps all you really need is
SELECT DISTINCT qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Ad

Advertisements

B

bw

Okay John, that worked just fine. I now see that my problem was including
additional fields that did not have duplicate values.
I appreciate your help.
Also, thanks for defining DISTINCT vs DISTINCTROW. That also helped...
Bernie


John Spencer said:
First, try DISTINCT instead of DistinctRow. Distinct limits the
"duplication" based on the fields in the select clause. DistinctRow
limits the "duplication" based on all the fields in the table(s).

SELECT DISTINCT qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As
Tmp
GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1 And
[Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] = [qryModules].[DBNum]
And
[Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

And perhaps all you really need is
SELECT DISTINCT qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

bw said:
When I have duplicate information, I only want to include one of them in
my report.
I have a "Find duplicates" query as follows:

SELECT qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As
Tmp GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1
And [Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] =
[qryModules].[DBNum] And [Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];

I thought using DISTINCTROW as follows would do that for my report, but
each of these produces exactly the same results. Can someone explain?

SELECT DISTINCTROW qryModules.BankName, qryModules.[Acct Mgr],
qryModules.DBNum, qryModules.[Inst Num], qryModules.Mnemonic
FROM qryModules
WHERE (((qryModules.BankName) In (SELECT [BankName] FROM [qryModules] As
Tmp GROUP BY [BankName],[Acct Mgr],[DBNum],[Inst Num] HAVING Count(*)>1
And [Acct Mgr] = [qryModules].[Acct Mgr] And [DBNum] =
[qryModules].[DBNum] And [Inst Num] = [qryModules].[Inst Num])))
ORDER BY qryModules.BankName, qryModules.[Acct Mgr], qryModules.DBNum,
qryModules.[Inst Num];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top