Hi there!
I am trying to find out what is wrong with the following code: - SELECT Investor.Company, Investor.ID, Investor.Country
-
FROM Investor
-
WHERE ((( Investor.Company) In (
-
SELECT [Company]
-
FROM [Investor] As Tmp GROUP BY Left([Company],3)
-
HAVING Count(*)>1
-
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!
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)
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. - SELECT [Company], [ID], [Country]
-
FROM Investor
-
WHERE Left([Company],3) In((
-
SELECT DISTINCT Left([Company],3)
-
FROM [Investor]
-
WHERE [Company] Like 'Some Value*'))
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 : - SELECT [Company], [ID], [Country]
-
FROM Investor
-
WHERE Left([Company],3) In((
-
SELECT Left([Company],3)
-
FROM [Investor]
-
GROUP BY Left([Company],3)
-
HAVING Count(*)>1))
Thank you so much for your help! I really appreciate it! I will try to see what I get.
Cheers :)
It works perfect! Thanks a million! I O U :D
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |