Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Connection Count

Author  Topic 

Kotti
Posting Yak Master

129 Posts

Posted - 2009-01-29 : 02:34:15
Dear Friends,

I have the table called connection, Please find the sample data below

ConnectionId | Reg_EMail | Rec_EMail
1 | dhina@dhina.com | kotti@kotti.com
2 | dhina@dhina.com | Reji@Reji.com
3 | Kotti@kotti.com | sam@sam.com
4 | Alex@Alex.com | xyz@xyz.com
5 | Karth@karth.com | abc@abc.com
6 | sam@sam.com | alex@alex.com
7 | PO@PO.COM | Kotti@kotti.com
This is my table structure, what i need is when dhina@dhina.com is logged in as a user in my program i have to calculate the number of connections dhina@dhina.com have.

HOW NEED TO CALCULATE THE COUNT :1> In my table dhina@dhina.com is connected with kotti@kotti.com in the first row so here the count is 1
then Kotti@Kotti.com may be connected with some other Email , For example in my table Kotti@Kotti.com connected with Sam@Sam.com [3rd Row], and PO@PO.COM [7th Row ], So here now the total count of dhina@dhina.com is 3 [ because dhina@dhina.com connected with kotti@kotti.com and kotti@kotti.com is connected with 2 contacts ]

2> Sam@Sam.com is connected with Alex@Alex.Com so here we have to increase the count by 1, So now the dhina@dhina.com coneection count is 4

3> Alex@Alex.com connected with xyz@xyz.com so here the count need to be incered by 1, SO now the dhina@dhina.com connection count is 5.

4> And dhina@dhina.com is connected with Reji@Reji.com so here we have to increase one more count , SO the total count is 6.

The Expected result for the user dhina@dhina.com connection count is 6.

NOTE : The Aim is to calculate dhina@dhina.com is connected with how many friends, and dhina's friends connected with how many friends, and dhina's friends's friend connected with how many people , like this we have calculate the count.

Is it possible, if yes ,Please help me to get the expected output. OR

PLEASE ADVICE ME HOW TO REMODIFY THE TABLE STRUCTURE AND HOW CAN I ACHIEVE MY EXPECTED OUTPUT.

Thanks in advance. THANKS FOR ALL YOUR TIME

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-29 : 02:40:14
See this topic
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73079

It will give you some clues how to solve your problem.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -