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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex counter query

Status
Not open for further replies.

Juan1

Programmer
Aug 28, 2009
1
0
0
GB
This is an example of my data set

Account
number Name1 Name2
1 A B
2 A
3 B
4 C D
5 C
6 D
7 D

This is what the output needs to be

Account Portfolio Portfolio
number ID size

1 1 3
2 1 3
3 1 3
4 2 4
5 2 4
6 2 4
7 2 4

My query is about linking accounts and creating output to summarise this. In this case here A is linked to 2 accounts and B is linked to 2 accounts but because they share one account the portfolio size (in the 2nd table)will be 3 and the unique id for that group of customers will be 1. Make sense.

Trying to write a piece of code that converts table 1 to table 2. I've tried a series of counters and do loops but as of yet, no success. Does anyone have any thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top