Any idea how to run some SQL that would not Select distinct, but would select the values that are not distinct. Or something like "Select Duplicate"
12 17469
I think the keyword "COUNT" might be useful in this situation, though I forget the syntax...
NeoPa 32,534
Expert Mod 16PB
Blyxx86,
I'm afraid your question is not very clear.
If you can rephrase it in clear terms I'll let you have what you're looking for.
-Adrian.
Blyxx86,
I'm afraid your question is not very clear.
If you can rephrase it in clear terms I'll let you have what you're looking for.
-Adrian.
Thank you. I'm trying to select from a table values that are not unique, therefore outputting only values that are duplicates.
I want to be able to compare entries, perhaps a SELECT DUPLICATE command or SELECT SIMILAR, except those are not actual commands.
I just can't figure out how to do it.
Thank you. I'm trying to select from a table values that are not unique, therefore outputting only values that are duplicates.
I want to be able to compare entries, perhaps a SELECT DUPLICATE command or SELECT SIMILAR, except those are not actual commands.
I just can't figure out how to do it.
Or perhaps what I am trying to do is similar to this..
Table1 has one field called FirstName with the following entries:
Dave, Joe, Ted, Ted, Frank, Dave, Ted
When the SQL string is set up similar to my "SELECT DUPLICATE" the only values that are shown are:
Ted, Ted, Ted, Dave, Dave (Notice the missing Joe and Frank)
I need these duplicate entries within the table, but need to be able to see them clearly.
NeoPa 32,534
Expert Mod 16PB
Or perhaps what I am trying to do is similar to this..
Table1 has one field called FirstName with the following entries:
Dave, Joe, Ted, Ted, Frank, Dave, Ted
When the SQL string is set up similar to my "SELECT DUPLICATE" the only values that are shown are:
Ted, Ted, Ted, Dave, Dave (Notice the missing Joe and Frank)
I need these duplicate entries within the table, but need to be able to see them clearly.
Sorry Blyxx86.
I thought this thread had an answer :(. I'll look into it now.
It won't be a predicate but we can find some SQL to give the effect you require (might be a little more complicated to understand though).
Sorry Blyxx86.
I thought this thread had an answer :(. I'll look into it now.
It won't be a predicate but we can find some SQL to give theeffect you require (might be a little more complicated to understand though).
I think I may have found an answer within this SQL bit... -
SELECT email,
-
COUNT(email) AS NumOccurrences
-
FROM users
-
GROUP BY email
-
HAVING ( COUNT(email) > 1 )
-
-
SELECT email
-
FROM users
-
GROUP BY email
-
HAVING ( COUNT(email) = 1 )
-
However, I believe that is straight SQL and will not work work within Access...
So the answer about COUNT was right, but I had no idea how to use that function.
This may help, but I do not know what the COUNT(column) AS NumOccurences reference even means. Well I could guess that it means Count as Number of Occurences, which is kinda what I want, but I want to show each occurence of the field.
NeoPa 32,534
Expert Mod 16PB
Please include the MetaData for all relevant datasets.
Posting Table/Dataset MetaData
Here is an example of how to post table MetaData : Table Name=tblStudent
StudentID; Autonumber; PK
Family; String; FK
Name; String
University; String; FK
MaxMark; Numeric
MinMark; Numeric
Without that, I will try to illustrate how to do this generally.
Assume we are dealing with the table tblStudent shown above.
To produce a list of all student names which are not unique : - SELECT *
-
FROM tblStudent INNER JOIN (SELECT [Name]
-
FROM tblStudent
-
GROUP BY [Name]
-
HAVING Count([Name]) > 1) AS subDuplicates
-
ON tblStudent.Name = subDuplicates.Name
The subquery (defined within the () after INNER JOIN) will produce the actual list of names which are not unique, but will only display one instance of the name.
NeoPa 32,534
Expert Mod 16PB
I think I may have found an answer within this SQL bit... -
SELECT email,
-
COUNT(email) AS NumOccurrences
-
FROM users
-
GROUP BY email
-
HAVING ( COUNT(email) > 1 )
-
-
SELECT email
-
FROM users
-
GROUP BY email
-
HAVING ( COUNT(email) = 1 )
-
However, I believe that is straight SQL and will not work work within Access...
So the answer about COUNT was right, but I had no idea how to use that function.
This may help, but I do not know what the COUNT(column) AS NumOccurences reference even means. Well I could guess that it means Count as Number of Occurences, which is kinda what I want, but I want to show each occurence of the field.
When you have AS after something this means that the following text (name) will be considered the name of this item for future reference. In your case, NumOccurences will be the name that indicates COUNT(column).
You could also say something like - SELECT u.*
-
FROM Users AS u
-
ORDER BY u.Name
Every u. would be equivalent to Users..
In Access Help enter Find Duplicates Query Wizard. I think that's what you want, ready made!
I modified the code just a bit to fit one of my tables. -
SELECT QC.Serial,
-
Max(IIf([Overall]='Pass',[Date],Null)) AS [Pass Date],
-
Max(IIf([Overall]='Fail',[Date],Null)) AS [Fail Date]
-
FROM QC
-
GROUP BY QC.Serial
-
HAVING ((Count(QC.Serial))>1);
-
If I try to add another field to the SQL there, it gives me an error.
You tried to execute a query that does not include the specified expression 'Tech' as part of an aggregate function. -
SELECT QC.Tech,
-
QC.Serial,
-
Max(IIf([Overall]='Pass',[Date],Null)) AS [Pass Date],
-
Max(IIf([Overall]='Fail',[Date],Null)) AS [Fail Date]
-
FROM QC
-
GROUP BY QC.Serial
-
HAVING (((Count(QC.Serial))>1));
-
I read up about how it isn't part of a TRANSFORM query, and how doing this would essentially create a cross-tab query.. The equation just gets more and more complex... I feel comfortable with VBA and Access one day, and the next it poses a new challenge. How... fun!
I modified the code just a bit to fit one of my tables. -
SELECT QC.Serial,
-
Max(IIf([Overall]='Pass',[Date],Null)) AS [Pass Date],
-
Max(IIf([Overall]='Fail',[Date],Null)) AS [Fail Date]
-
FROM QC
-
GROUP BY QC.Serial
-
HAVING ((Count(QC.Serial))>1);
-
If I try to add another field to the SQL there, it gives me an error.
You tried to execute a query that does not include the specified expression 'Tech' as part of an aggregate function. -
SELECT QC.Tech,
-
QC.Serial,
-
Max(IIf([Overall]='Pass',[Date],Null)) AS [Pass Date],
-
Max(IIf([Overall]='Fail',[Date],Null)) AS [Fail Date]
-
FROM QC
-
GROUP BY QC.Serial
-
HAVING (((Count(QC.Serial))>1));
-
I read up about how it isn't part of a TRANSFORM query, and how doing this would essentially create a cross-tab query.. The equation just gets more and more complex... I feel comfortable with VBA and Access one day, and the next it poses a new challenge. How... fun!
If you add a field you will have to include it in the Group By -
SELECT QC.Tech, QC.Serial,
-
Max(IIf([Overall]='Pass',[Date],Null)) AS [Pass Date],
-
Max(IIf([Overall]='Fail',[Date],Null)) AS [Fail Date]
-
FROM QC
-
GROUP BY QC.Tech, QC.Serial
-
HAVING (((Count(QC.Serial))>1));
-
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Phil Powell |
last post by:
Has anyone here ever done a case where you have a select multiple form
element and you have to do both server-side and client-side validation?
I am honestly not sure how to do it in Javascript (I...
|
by: Matt |
last post by:
In ASP page, there is a "SELECT ALL" button, when user click it, it will
select all checkboxes. I am not sure should I use client-side code to do
that? the following is my approach but it didnt...
|
by: Steve |
last post by:
Hi, Is there something fundamentally wrong with the following query?
SELECT MAX(OrderID) AS Expr1 FROM Orders WHERE (MarketActionCode = 'S') AND
(OrderLegCode = 'S') AND (Status = 'F') AND...
|
by: GSteven |
last post by:
(as formerly posted to microsoft.public.access.forms with no result)
I've created a continuous form which is based on a straightforward table
(ex - customers - 100 records). On the form there is...
|
by: Dave Markle |
last post by:
Good afternoon. I was just going through my code, analyzing it with FXCop,
and FxCop gave me the following error on this code:
MY CODE:
Select Case termYears
Case 5 : retVal.Append("1")
Case...
|
by: ALaurie10 |
last post by:
I am trying to write a "Select and From Statement but keep getting error 214727900 and my VBA points to the .Open Options:=acCmdTable. I am referencing a table in my Select. Can someone help me out....
|
by: bcurtu |
last post by:
Hi,
I have a BIIIIIG problem with the next query:
cursor.execute("""
SELECT titem.object_id, titem.tag_id
FROM tagging_taggeditem titem
WHERE titem.object_id IN (%s)
""",( eid_list))
|
by: bre1603 |
last post by:
I have a continuous form in Access 2007 called “Leadership Contact List.” It has a checkbox control for each record (bound to a field in the underlying table) that is used to email or create mailing...
|
by: Utku |
last post by:
Is it possible to add "select all" and "select none" buttons to MultiChoiceDialog in wxPython?
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
| |