473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Combine name changes in query

1
I have a customer database in which a number of companies have modified their company names. When I look at my sales performance query I have to manually total the numbers for these different "name changes" for comparison purposes.

Is it possible to make a query in which I can total the "name changes" as one company.

eg. Joe Bloggs, Joe Bloggs & Co, Joe Bloggs & Co Ltd, J Bloggs Ltd. I would like to total all under name Joe Bloggs.
May 24 '10 #1
1 1245
Jim Doherty
897 Expert 512MB
@lcmts
Yes you can.... but the extent of your client database and the number of potential quirks would dictate the method by which you might wish to approach this. Just going by your simple example is easy enough.

A simple search through the Company name string for the rather unique sequence of characters ie 'Bloggs' which if existing would trigger logic where you could replace by way of calculation the name of the company with something of your choosing. Your table data remains the same, it is not affected by this, only the company name is calculated to appear differently.

This would then serve to do as you ask specifically. An example of this:- imagine a table called tblSales where grouping by the Company name expressed as a calculation and summing the Amount field

Expand|Select|Wrap|Line Numbers
  1. SELECT IIf(InStr(1,[CompanyName],"Bloggs")>0,"Joe Bloggs Ltd",[CompanyName]) AS Company, Sum(tblSales.Amount) AS Total
  2. FROM tblSales
  3. GROUP BY IIf(InStr(1,[CompanyName],"Bloggs")>0,"Joe Bloggs Ltd",[CompanyName]);
The criticism I have of this is that it only applies where you know the safety and uniqueness of the sequence you intend to use in the calculated replacement and is too specific to an individual case of 'Bloggs'. What if there are more than one set of 'Bloggs' or same name companies with different purpose and so on.......not very practical or safe as I am sure you can see.

My advice would be this (if you are NOT desirous of standardising your data in the table for whatever reason and there can be quite legitimate reasons for this) then to create another table of the proper company names only maybe call the field 'AliasCompany' and then create an extra name in your main table and populate it with the actual proper name of the company from this alias table. This way you keep a controlled handle on any query outcome. You would group by on the alias name instead of the disparate names that would appear in the usual company name field.

Obviously this 'new' table would be linked to your client table as a 'one to many' potential relationship

The fundamental design however of your system should take into account practical issues such as company name changes. It 'does' happen we know that and my latter point using the 'alias' concept when used properly will track and account for that

I hope this helps you a little
May 24 '10 #2

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

Similar topics

2
by: Leee | last post by:
Dear all, I have a contacts table (table1) detailing ID First Name Last Name I have another table (table2) with a combo detailing the ID, First Name and Last Name i.e.
3
by: dim1ann | last post by:
Hi,i'm new to access and not sure whether it's possible to create a query on two tables below to get data from tblB or i should do some trick through VBA? thank u in advance Dim tblA: Date, ...
18
by: NickName | last post by:
The following example may further clarify the question, Select fieldA, filedB, fieldC >From tblX Where fieldD = Forms!formName!controlName What I'd like to know is how to determine or get...
3
by: ryanmhuc | last post by:
Is it possible to have a dynamic table name within a query or a table name that is a variable? This does not work but gives an example: SELECT * FROM concat('table', 'name') - OR - SET @table...
1
by: colleen1980 | last post by:
There is a form where it ask the two dates and then run a query then report. Private Sub Command36_Click() DoCmd.OpenQuery "qryResultsReport" DoCmd.OpenReport "rpt_TopTen", acPreview, "", ""...
1
by: katieking | last post by:
I would like a field in a query to contain the name of the query that is producing the data, in order to maintain transparency of data flows when the data is copied into Excel. Is there any way of...
3
by: Sundaram Muthusamy | last post by:
how we find the server name using sqlserver2005-Query analyser
1
by: kababoom | last post by:
Is it possible to combine multiple sql queries into 1? or does anyone has any sites or reference on how to do this? Thks for any info :)
1
by: randyse | last post by:
Hello all, This is my first post, please let me know if I've missed any relevant data or guidelines. I'm using Access 2003 for the database and Excel 2003 for the reporting to avoid having...
2
by: dantebothermy | last post by:
Hi, I'm using Access 2003. Sometimes, when I have a table used in a query, if I rename the table it Access also renames the table in the query. It's also happened in VB scripts. It...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...

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.