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 |
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2004-07-13 : 02:25:06
|
| I have a following structuretable A userid ReferedByB A C BTable BUserid compIDA AlphaB selfC selfnow the scenario is :the user A is from the company "Alpha"he introduces user B, who registers in the system his company bcomes "self",now B inturn refers user C who also registers in the system and his company is now again "self".Now I need to generate a report of number of users that have registered under one company, for eg.for the company "Alpha" no of users becomes 2 since A refered to two users and both of them have registered.I m stuck with the query.thanks in advance...regards,HarshalHe is a fool for five minutes who asks , but who does not ask remains a fool for life!http://www.sqldude.4t.com |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-07-13 : 08:05:28
|
| So, in your example, do you want the results to be:Alpha 2self 2-or-Alpha 2self 1MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2004-07-13 : 08:22:39
|
quote: Originally posted by derrickleggett So, in your example, do you want the results to be:Alpha 2self 2-or-Alpha 2self 1MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA.
I want the count of users who are registered under the company "Alpha".I think the best bet would be to add a column parentCompany to the table, still in that case i'll have to update the existing records ...He is a fool for five minutes who asks , but who does not ask remains a fool for life!http://www.sqldude.4t.com |
 |
|
|
|
|
|
|
|