Re: Display records based on count value of one field
- From: "Wolfgang Kais" <spam@xxxxxxxxx>
- Date: Sun, 23 Sep 2007 14:23:26 +0200
Hello Michael.
You're wellcome. But I made a little mistake:
In order to view the groups of duplicates together, the "Order By"
clause should be moved outside the brackets of the subquery.
--
Rehards,
Wolfgang
Michael Bond wrote:
Hi Wolfgang,
Thank you so much. The subquery idea never entered my head. Not had time
to
try it yet on my full table but I can see how that structure will deliver
what I need
Appreciate your help
Regards
Michael
"Wolfgang Kais" wrote:
Hello Michael.
Michael Bond wrote:
I have a SQL query.....but I've posted here cos I'm using SQL in a
VB.net app to interrogate records in an Access table. I apologise
in advance if I've posted in the wrong forum and would welcome a
pointer to the correct forum to use....
I guess the forum is ok. Usig the "find duplicates wizard" in Access
you can easily build a query that has a common syntax.
I have a table containing records that include a name field. A
particular name can occur more than once in the table. I want to
be able to view the full record where the field name contains a
value that occurs more than a given number of times in the table
(e.g. => 3)
So if my table contains as follows
RecordID Points Name
1 10 Alan
2 5 Joe
3 10 Joe
4 6 Henry
5 6 Alan
7 10 Joe
I want the query to show the following result
RecordID Points Name
2 5 Joe
3 10 Joe
7 10 Joe
....and if there were more than records for Alan then they too
would display....
....my table also contains considerably more fields than the
sample I've given and I need to be able to see the full record
with all the fields.
I cannot get my head round the syntax of the query despite the use
of group by clause. all that gives me is either a distinct count
for the name field or a count of the name field
Would appreciate any help you can offer.
The magic word is "subquery". Try this:
Select * From YourTable Where Name In (Select Name From YourTable
As Tmp Group By Name Having Count(*) >= 3 Order By Name)
--
Regards,
Wolfgang
.
- Follow-Ups:
- References:
- Re: Display records based on count value of one field
- From: Wolfgang Kais
- Re: Display records based on count value of one field
- From: mabond
- Re: Display records based on count value of one field
- Prev by Date: Re: Time based query - records within 10 minute intervals
- Next by Date: Re: Problem: query from two tables connected to a third table
- Previous by thread: Re: Display records based on count value of one field
- Next by thread: Re: Display records based on count value of one field
- Index(es):
Relevant Pages
|