A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Duplicate Values in Query



 
 
Thread Tools Display Modes
  #1  
Old December 1st, 2009, 04:12 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default Duplicate Values in Query

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?
  #2  
Old December 1st, 2009, 04:22 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default Duplicate Values in Query

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

  #3  
Old December 1st, 2009, 04:22 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default Duplicate Values in Query

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

  #4  
Old December 1st, 2009, 04:22 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default Duplicate Values in Query

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

  #5  
Old December 2nd, 2009, 06:43 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Duplicate Values in Query

AccessIM -

You do not need the ", qryDisciplineLevelAll AS qryDisciplineLevelAll_1" at
the end (right before the ORDER BY clause). That will cause the duplicate
records.
--
Daryl S


"AccessIM" wrote:

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

  #6  
Old December 2nd, 2009, 06:43 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Duplicate Values in Query

AccessIM -

You do not need the ", qryDisciplineLevelAll AS qryDisciplineLevelAll_1" at
the end (right before the ORDER BY clause). That will cause the duplicate
records.
--
Daryl S


"AccessIM" wrote:

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

  #7  
Old December 2nd, 2009, 06:43 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Duplicate Values in Query

AccessIM -

You do not need the ", qryDisciplineLevelAll AS qryDisciplineLevelAll_1" at
the end (right before the ORDER BY clause). That will cause the duplicate
records.
--
Daryl S


"AccessIM" wrote:

Sorry, I have a correction to my post below. I have not done the group by
but I have tried creating a relationship between qryDisciplineLevelAll and
qryDisciplineLevelAll_1 in Design view. This stopped the duplicate records
but returned the incorrect two records.

"AccessIM" wrote:

I have the following code in a query:

SELECT qryDisciplineLevelAll.EMPLOYEEID, qryDisciplineLevelAll.SSN,
qryDisciplineLevelAll.NAME, qryDisciplineLevelAll.DISCIPLINEDATE,
qryDisciplineLevelAll.LASTINCIDENTDATE, qryDisciplineLevelAll.TOTALPOINTS,
qryDisciplineLevelAll.DISCIPLINELEVEL, qryDisciplineLevelAll.FROZEN,
(SELECT Count(*) FROM [qryDisciplineLevelAll] As [qryDisciplineLevelAll_1]
WHERE [qryDisciplineLevelAll].[SSN]=[qryDisciplineLevelAll_1].[SSN] AND
(Format([qryDisciplineLevelAll].[DISCIPLINEDATE],
"mmddyyyy"))=(Format([qryDisciplineLevelAll_1].[DISCIPLINEDATE],
"mmddyyy"))-1) AS SEQUENCE_NUMBER,
IIf([qryDisciplineLevelAll.DISCIPLINELEVEL]=[qryDisciplineLevelAll_1.DISCIPLINELEVEL],
"NO DISCIPLINE NECESSARY", [qryDisciplineLevelAll.DISCIPLINE]) AS
DISCIPLINENOTICE
FROM qryDisciplineLevelAll, qryDisciplineLevelAll AS qryDisciplineLevelAll_1
ORDER BY qryDisciplineLevelAll.DISCIPLINEDATE;

When I run the query, which should return two records, it duplicates the
records and returns four.

qryDisciplineLevelAll is a union query and returns the two records. Of the
duplicate records in the query coded above, two shoe the correct information
and two do not. I tried adding the Total line and using the Group By but it
grabs the two incorrect records.

Can someone help me with this and let me know what I am doing wrong that is
creating duplicates?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.