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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-18 : 18:49:36
|
Wouter writes "Good afternoon, I have the following problem that I would like to solve using a stored procedure.
First of all, the database is fairly large, thus it has to be an optimzid solution, it has around 200.000 rows, each having around 50 columns.
Each row contains the following fields
UserID RefererID (the rest is not important)
Now when somebody signs up for my service, they are refered by somebody (or not) in which case refererID would be 0
Now what I would like to know is how many people somebody has 'below' them thus in level1 so to speak.
I would also like to know how many people are in level 2, 3 and 4, and so on... even in level 21 if I would like...
I have tried using inner joins ... but im not very good at those and it was too slow...
Right now, im using another solution. Up to a maximum of 7 levels deep. upon signing up, the database stores all upline information in columns called refererID .. ref2ID ref3ID.. etc and just do a count(*) on those colums.... however... this a lot of double information and therefore there might be a better way.
Please advise and please keep my email address private.
I am using sql server 7" |
|
|
|
|
|