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
 Calculation of Points

Author  Topic 

zafarthesultan
Starting Member

16 Posts

Posted - 2010-01-16 : 09:14:04
Dear Friends,
I am getting a lot of help from this forum. Thanks, now my sql query requirement is something like:

I have to calculate the business points a user obtains by referring other members. For example:

A introduces B (A gets 50 points)
A introduces C (A gets 50 points)

B introduces D (B gets 50 points)
B introduces E (B gets 50 points)

C introduces F (c gets 50 points)
C introduces G (c gets 50 points)

This chain continues ( basically it is a binary tree structure. B and C are under A's left and right respectively ). The points for A will be a sum of all the points generated by members to his left and the members to his right.

For every member in this tree the reward points should be calculated as follows:

If a member has 500 points to his left and 250 points to his right, or 500 points to his right and 250 points to his left he will get 200 reward points. After initial 250:500 or 500:250 points the member will get 100 reward points for every 100:100

Can anyone solve this query? Please, I need it for my project. Thanks a lot once again.




SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-16 : 09:44:24
How are you storing the data?



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

zafarthesultan
Starting Member

16 Posts

Posted - 2010-01-16 : 09:51:10
MasterUsers Table Format:

id/userid/introducer/businesspoints/leftmember/rightmember

1/A/Z/50/B/C
2/B/A/50/D/E
3/C/A/50/F/G
4/D/B/50/null/null
5/E/B/50/null/null
6/F/C/50/null/null
1/G/C/50/null/null
Go to Top of Page
   

- Advertisement -