September 1, 2019 at 2:34 pm
Please help me to get the below output from table
September 1, 2019 at 4:56 pm
You need to include more information. Do you have any code at all? What are the table structures? Where is the team amount column?
September 1, 2019 at 7:17 pm
sorry for ray team_amount
mike report to ray 200+matt report to mike 100
magan report to ray 50+ stephaine report to magan 25
ray team amount (200+100+50+25)=375
ray individual amount 250
total amount 250+375=625
September 1, 2019 at 8:22 pm
Use a common table expression.
https://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/
September 1, 2019 at 8:49 pm
Please help me to get the below output from table
For future posts, please see the first link in my signature line below. Producing "readily consumable" data, as suggested in the linked article, will get you coded responses and in a whole lot less time.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 1, 2019 at 8:52 pm
Also, see the following article that provides a method to solve for most things that you could as of an "Adjacency List" Hierarchy.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 3, 2019 at 6:07 pm
Look up the nested set model for hierarchies and trees. This will make your problem trivial. Also in the future, would you mind posting DDL instead of spreadsheet pictures? We really don't like the copy your data into our own machines we could have cut and pasted a properly done posting.
Please post DDL and follow ANSI/ISO standards when asking for help.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply