Count Child node from table on base of parent id.

  • Hi There,

    I'm creating MLM software. I'm stuck on sharp sql curve. I've created tables. Now I need to fetch records count. I'm attaching screen shots of two tables. I'm inserting records in both tables.

    I need to count all child nodes available in X leg and Y leg under ParentId. like

    1 (It has 6 Child nodes : Left = 3, Right = 3)

    2 (It has 2 : Left = 2, Right = 2) 3 (It has 2 : Left = 2, Right = 2)

    4 5 6 7

    Sorry for Bad way of presentation.

    Please help me out.

    Regards,

    Tushar

  • please give us a clear description if you want the problem to be solved.

    I do not understand even a single thing to ask questions to solve the problem.

    It looks like an abstract question asked by an artist to a viewer.

  • Hi,

    Sorry for inconvenience. I need to count all child nodes for one user. Here I'm attaching an image, it has node up to 4 levels but I need nodes count till 12 levels.

    I need two counts for main user: left count and right count.

    In original post I've uploaded two screenshots of database tables, which I'm using for registration.

    Is it clear enough ? if not I'll try once again.

    Regards,

    Tushar Jindle

  • I'd like to suggest that you read the first (or first two) links in my signature. Then, instead of those images, please post some CREATE TABLE and INSERT statements to give us what is in the graphics. And finally, based upon the sample data supplied, provide what the expected results are.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Hi,

    Please find attached Image. I forgot to attach in previous post.

    Regards,

    Tushar Jindle

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply