Hi All, I hope someone can help me out with this query.
Lets say I have a table with 4 columns. Person ID, Friend's Last Name, Friend's Number.
Each person id has at least 2 friends, some have different last names and some have same last names. For example, person 1 can have John Doe, Jane Doe, Billy Bob as friends and person 2 can have Sam Wise, Peter Piper, Jane Doe as friends... so the table would look like this:
person id friend's last name friend's number
1 Doe 5555551212
1 Doe 5555555555
1 Bob 5551565555
2 Wise 5155556532
2 Piper 1532565152
2 Doe 5238545623
I am trying to figure out how to select ONLY ONE friend for each Person ID. I don't care who I select, I just want to pick one friend. Using the above example, my result could be:
person id friend's last name friend's number
1 Doe 5555551212
2 Wise 5155556532
I can figure out one way of doing this, using cursors. But can I do this without cursors?
Lets say I have a table with 4 columns. Person ID, Friend's Last Name, Friend's Number.
Each person id has at least 2 friends, some have different last names and some have same last names. For example, person 1 can have John Doe, Jane Doe, Billy Bob as friends and person 2 can have Sam Wise, Peter Piper, Jane Doe as friends... so the table would look like this:
person id friend's last name friend's number
1 Doe 5555551212
1 Doe 5555555555
1 Bob 5551565555
2 Wise 5155556532
2 Piper 1532565152
2 Doe 5238545623
I am trying to figure out how to select ONLY ONE friend for each Person ID. I don't care who I select, I just want to pick one friend. Using the above example, my result could be:
person id friend's last name friend's number
1 Doe 5555551212
2 Wise 5155556532
I can figure out one way of doing this, using cursors. But can I do this without cursors?