Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Times Address has been Used 1

Status
Not open for further replies.

uncleG

Technical User
Jun 10, 2004
63
US
Hi All,

I have an address list "tblOrgLocate" pk "LOID" (2066 records)that has many duplicate and unused addresses in it. I would like to count the number of times each entry [LOID] has been used in 10 different tables. Once identified I can remove those which have not been used.

Table.field Names which may contain matching LOID
tlbSo.DeLoc
tlbPO.DeLoc
tlbQuotes.DeLoc
tblRFQ.Deloc
etc
Thanks UncleG
 
Code:
Select LOID, Count(*) As [Number of Uses]

From 

(Select LOID From tblOrgLocate
UNION ALL
Select DeLoc From tblSo
UNION ALL
Select DeLoc From tblPO
[blue]etc.[/blue]
) As X

Group By LOID
 
run a summary query on each table that has the column which holds the address in it grouped, and a second column that is set to count on that same field. that will give you a count of how many times each address is used.
keep in mind that this will not take into account punctuation marks.
 
Thank you Golum,
Right on the money.
Of 2066 address records 1249 were never used, Original developer had given them a duplicate this record button and they used it often.
This will help shorten up the Combo boxes a bit.
Thanks Again,
UncleG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top