Skip to content

Tag: sql-server

Recursive query compute parent values

I have 2 tables Persons and Sales. In Person there is relation between child and parent, I want to compute 20 percent of parent values with the following condition Persons Sales I want to get result like this I wrote this query but it does not give appropriate result Answer This should be a two steps algorith…

Recursively Conditionally get parent Id

I have two tables: Budget Line and Expense. They are structured in such a way that an expense must have either a parent record in the budget line table, or a parent record in the expense table. I need to select all child-most expenses for each budget line. For example – BudgetLine: Id Description 1 TEST…