473,785 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Group By query that groups FK and counts the PK

1 New Member
I am working with a two field table of 144,020 rows.

The PERSONID field is the FK and the ADDRESSID is the PK.

FK is a number type, PK is autonumber.

PERSONID represents employees, ADDRESSID represents addresses.

The objective is to mark all single addresses as primary and all double addresses (for the same employee) as 'primary and secondary'.

Here is what I am doing that is not working, perhaps someone can tell me the problem and hopefully a solution that meets the objective.

I am doing a 'group by' query that groups by PERSONID and counts the PK of ADDRESSID.

I set the criteria for the count to 1, (as I need to return only those PERSONID with one address.

After running this. I run an Update query that sets the PRIORITY (new added field) to PRIMARY for all the single records by using a Subquery (I set the criteria for the PERSONID to:

IN(SELECT PERSONID FROM qrySglAddress)

What am I missing in order to have all single addresses marked as primary and all double addresses marked as 'primary and secondary'.

thanks for any help on this.

richforsandy
Oct 1 '06 #1
1 2051
PEB
1,418 Recognized Expert Top Contributor
Hi man,

It seems that you need to do soth like ranking of your adresses! Here in the Access forum recently has a lot of usefull information about ranking, done by SQL and by VB!

Type

ranking
rank
rang
Count

in the search engine in the scripts and Y'll have all needed results :)

If pb here we are! :)

Best regards

:)


I am working with a two field table of 144,020 rows.

The PERSONID field is the FK and the ADDRESSID is the PK.

FK is a number type, PK is autonumber.

PERSONID represents employees, ADDRESSID represents addresses.

The objective is to mark all single addresses as primary and all double addresses (for the same employee) as 'primary and secondary'.

Here is what I am doing that is not working, perhaps someone can tell me the problem and hopefully a solution that meets the objective.

I am doing a 'group by' query that groups by PERSONID and counts the PK of ADDRESSID.

I set the criteria for the count to 1, (as I need to return only those PERSONID with one address.

After running this. I run an Update query that sets the PRIORITY (new added field) to PRIMARY for all the single records by using a Subquery (I set the criteria for the PERSONID to:

IN(SELECT PERSONID FROM qrySglAddress)

What am I missing in order to have all single addresses marked as primary and all double addresses marked as 'primary and secondary'.

thanks for any help on this.

richforsandy
Oct 1 '06 #2

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

Similar topics

3
4618
by: Rich Protzel | last post by:
Hello, So my table contains say 100,000 records, and I need to group the categories in fld1 by the highest count of subcategories. Say fld1 contains categories A, B, C, D, E. All of these categories contain subcategories AA, AB, AC, AD,...AJ, BA, BB...BJ, CA, CB, CC...CJ, etc in fld2. I am counting how many subcategories are listed for each category. Like
3
2138
by: Abhi | last post by:
Hi! I am wondering if this query is possible somehow: I have a table with many fields that all can have a value from 1 to 5. if I wanna see the count of each value from one field, then this is easy: SELECT field1, count(field1) as cntnr FROM table group by field1
6
17924
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by year & month When I try to place a date filter 'Between x And y ' on an expression field
7
4544
by: Darin | last post by:
I have a report that sub-totals on a group, then grand-totals at the report footer. If there's only one group, the sub-total and grand total are redundant, so I only want to show one of them. I know how to count the groups, then hide the report footer if there's only one group, but my problem is I want to hide the group footer (sub-total), not the report footer (because the report footer references what the grand total is for, which is...
9
10849
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using LDIFDE as a comparison I get the same results. No members means just that, an empty group. Zero means that the DirectorySearcher.SizeLimit has been exceeded....
3
9880
by: Chad Beckner | last post by:
I am starting to translate some code from ASP to ASP.NET (VB). I was able to query ADS to get a users groups that they belong to, and also query a group and get a list of users. However, I can't seem to get this to work in VB.Net. Here's what I have: OLD ASP Code: Function Get_ADS_Users_For_Group(ADS_Path) Dim Group_Information Dim Error_Number
1
1568
by: John | last post by:
Hi I have a field that can have either A, B or C as its value. I need to write a query that will return the number of A's, B's & C's in the field X for a given criteria and then the total records for the same criteria. How do I write such as query? Thanks Regards
9
5254
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in ADSearch.FindAll()) { //ActiveDs.ADSearchres.Properties
7
16545
by: kooch54 | last post by:
I am trying to write a script to simply query the group members in an active directory group. I need to use LDAP to make sure I capture any global global group nestings that may occur. I already have a function that uses WinNT provider to capture this info from NT4 or AD domains and it works beautifully. It just doesn't capture global > global nestings. I am having great difficulties in getting this to work on AD though with ldap. I...
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
9481
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,...
1
10095
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
8979
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
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...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.