question

9703371999 avatar image
9703371999 asked

count left position and right position from parent and child nodes

hi friends i create one table as below CREATE TABLE [dbo].[regi]( [id] [int] IDENTITY(1,1) NOT NULL, [sponserid] [varchar](50) NULL, [introducername] [varchar](50) NULL, [placedunderid] [varchar](50) NULL, [name] [varchar](50) NULL, [so] [varchar](50) NULL, [position] [int] NOT NULL, [gender] [int] NOT NULL, [occupation] [varchar](50) NULL, [dob] [varchar](50) NULL, [addr] [varchar](200) NULL, [area] [varchar](50) NULL, [city] [varchar](50) NULL, [district] [varchar](50) NULL, [state] [varchar](50) NULL, [pincode] [varchar](50) NULL, [email] [varchar](50) NULL, [landline] [varchar](50) NULL, [mobileno] [varchar](50) NULL, [pwd] [varchar](50) NULL, [pin] [varchar](50) NULL, [nominee] [varchar](50) NULL, [relation] [varchar](50) NULL, [age] [varchar](50) NULL, [bankpayeename] [varchar](50) NULL, [accno] [varchar](50) NULL, [bankname] [varchar](50) NULL, [branch] [varchar](50) NULL, [ifsc] [varchar](50) NULL, [createddate] [datetime] NULL) ON [PRIMARY]GO SET ANSI_PADDING OFF GO 1. in this table sponserid is the parent of the table. 2. name is the child of the parent. 3. position indicates left and right. 4. here condition is parent must have 2 childs (**left and right only ). 5. For the first parent have to left + right+ left (or) left +right + right then it calculate to 500 rs for the parent after every child add 250 rs Can any one help me to write the code for count left and right position and calculate rupees for particular child. ==
sql-server-2008-r2hierarchynested-setadjacency-list
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The use of left and right sounds like a nested set tree, but your use of a parent ID sounds more like an adjacency tree. What hierarchy methodology are you using? Also, what code have you tried so far?
0 Likes 0 ·
my tree was sholud be like this Mohan(parent) | --------------------------- | | krish(child-left) phani(child-right) | ------------------ | mani(child-left) if 3 childs in one parent then we have to give the commission 500 and after for every child commission increase to 250(500 + 250 = 750)
0 Likes 0 ·
It sounds like you have a combination of adjacency tree and nested set, but I don't understand how you are using the left and right. It seems like the only thing that matters is the parent-child relationship and how many levels down a child is. Do the left and right make a difference?
0 Likes 0 ·

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.