473,473 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Finding similar entries&duplicates

11 New Member
Hi there!

I am trying to find out what is wrong with the following code:

Expand|Select|Wrap|Line Numbers
  1. SELECT Investor.Company, Investor.ID, Investor.Country
  2. FROM Investor
  3. WHERE ((( Investor.Company) In (
  4.   SELECT [Company]
  5.   FROM [Investor] As Tmp GROUP BY Left([Company],3)
  6.   HAVING  Count(*)>1
  7.      And Left([Company],3) =Left([Investor].[Company],3) )));
Its purpose is to find similar entries (that have 3 or more characters common in the begining of their name). egg: if I have ABC234 and ABC345 I want to be given both entries, not only if I have perfect matches, meaning having entered twice ABC234.

The message I keep getting is:

You tried to execute a query that does not include the specified expression "Company" as part of an aggregate function.

Does anyone know what I am doing wrong and what would be the solution?
Thank you!
Feb 5 '07 #1
6 1720
NeoPa
32,556 Recognized Expert Moderator MVP
Firstly, what is wrong.
In your last line of the GROUPed subquery you refer to the [Company] field. Within GROUPing, you can only refer to fields directly if they are GROUPed. Other fields can only be used if within some sort of aggregate function (First; Max; Sum; Count; etc)
Feb 5 '07 #2
NeoPa
32,556 Recognized Expert Moderator MVP
You also don't specify what three letter code you want to select on.
Your code seems to want to make it select whatever the current record is (therefore no selection at all).
Something similar to the code below should be what you're looking for but you need to decide exactly what you want before you can find out how best to get it.
Expand|Select|Wrap|Line Numbers
  1. SELECT [Company], [ID], [Country]
  2. FROM Investor
  3. WHERE Left([Company],3) In((
  4.   SELECT DISTINCT Left([Company],3)
  5.   FROM [Investor]
  6.   WHERE [Company] Like 'Some Value*'))
Feb 5 '07 #3
NeoPa
32,556 Recognized Expert Moderator MVP
I reread your post and realised you'd explained it but I'd missed it. What you ask does make sense.
Try this instead :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Company], [ID], [Country]
  2. FROM Investor
  3. WHERE Left([Company],3) In((
  4.   SELECT Left([Company],3)
  5.   FROM [Investor]
  6.   GROUP BY Left([Company],3)
  7.   HAVING Count(*)>1))
Feb 5 '07 #4
Anca Floria
11 New Member
Thank you so much for your help! I really appreciate it! I will try to see what I get.
Cheers :)
Feb 5 '07 #5
Anca Floria
11 New Member
It works perfect! Thanks a million! I O U :D
Feb 5 '07 #6
NeoPa
32,556 Recognized Expert Moderator MVP
I'm very pleased that's done it for you.
Thanks for posting saying it's fixed - that's always good to see.
Feb 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
Jon Wenzel
by: Jon Wenzel | last post by:
This is blowing my mind. I've got a system where sales reps can write notes on contacts in the DB. The issue is, I'm getting duplicate notes, but they're happening at different times. Each note is...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.