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.
| 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 belowConnectionId | Reg_EMail | Rec_EMail1 | dhina@dhina.com | kotti@kotti.com2 | dhina@dhina.com | Reji@Reji.com3 | Kotti@kotti.com | sam@sam.com4 | Alex@Alex.com | xyz@xyz.com5 | Karth@karth.com | abc@abc.com6 | sam@sam.com | alex@alex.com7 | PO@PO.COM | Kotti@kotti.comThis 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 1then 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 43> 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. ORPLEASE 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 |
|
|
|
|
|
|
|