473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

count total paired members of the tree by sqlquery

I am having a table tbltestingtree representing the tree structure, Member_Id is the id of the member, Parent_Id represent the Parentid of that member , Lefts and Rights tells us that the member is attached to the left or right of the Parent.
**My problem is that i have to make a sqlquery that counts the total number of pared members for any particular parent ,**

Ex- currently member with id 1 has 3 pairs with id 2,3 and 4
currently member with id 2 has 1 pair with id 4

Expand|Select|Wrap|Line Numbers
  1.       Member_Id     Parent_Id      Lefts         Rights
  2.          1               Null       Null          Null  
  3.          2                1          1            Null
  4.          3                1         Null           1
  5.          4                2          1            Null
  6.          5                2         Null           1
  7.          6                3          1            Null
  8.          7                3         Null           1
  9.          8                4          1            Null
  10.          9                4         Null           1
  11.  
Oct 4 '13 #1

✓ answered by Ashumeerut


2 1436
Rabbit
12,516 Expert Mod 8TB
I don't understand why you're counting 4 in your results, its parent id is not 1.
Oct 4 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ZyPhiX | last post by:
Hi, I've got a little problem: I'm trying to make a webpage with a few scrolldown menu's and I want to count the values of them. In the scrolldown menu's are no numeric values but the have to...
2
by: patang | last post by:
I found the following to count the total number of VISIBLE rows of datagrid datagrid.visiblerowcount How do we count the total number of ACTUAL (not just visible) rows of datagrid? Thanks...
1
by: iht | last post by:
Fairly new to Access and really doesn't know much about SQL except some basic commands. Currently I'm working with a database that I've already sorted by some queries, and here's a simplified...
2
kiss07
by: kiss07 | last post by:
Hi friends, I want calculate Total Number Of columns in table. Example: A table have 80 columns means , I want output is 80. please reply.. Regards,
25
by: Umesh | last post by:
Please try to do it while I try myself!
6
by: sangam56 | last post by:
C:\Documents and Settings\oOo\Desktop\Introducer Table.jpg Hi all. I have a table in sql 2005 management studio express edition. The table consists of three columns: IntroducerID, LeftCustomerID and...
2
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.