473,785 Members | 2,801 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 1751
NeoPa
32,578 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,578 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,578 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,578 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
3520
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
9645
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
10336
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...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8978
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
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
5383
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...
1
4054
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 we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.