473,770 Members | 5,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding similar entries&duplica tes

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 1750
NeoPa
32,573 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,573 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,573 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,573 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
3420
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 period and 13 periods a year. normally 52 weeks per year but one 53-week a year every 6 years. The 53th week is included in period 13. Can someone advise any idea how to construct such conversion.
16
3519
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
1163
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 time stamped, and the duplicates are happening sometimes 3 or 4 hours later, after the user is no longer on the site. I'm totally stumped with this. So here are the 2 pages that are used in the site. The first one is the index page, every...
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.