0

I have a table structure like that as shown below. I want to show names under parent of names (where parent is ledger group)

I expected result like this example

Image 1

2
  • Sorry to say that we are not providing code writing services Commented Feb 9, 2017 at 6:40
  • Please read meta.stackoverflow.com/questions/285551/… and the accepted answer Commented Jun 5, 2017 at 19:59

1 Answer 1

1
DECLARE @t1 TABLE
(
 ParentGroup varchar(20),
 LedgerName varchar(20),
 TotalDebit float,
 credit float
)

INSERT INTO @t1
SELECT *
  FROM Table1

INSERT INTO @t1
SELECT Distinct ParentGroup, ParentGroup, NULL, NULL
  FROM Table1

Select LedgerName, TotalDebit, credit from @t1
group by LedgerName, TotalDebit, credit
ORDER BY (CASE WHEN TotalDebit IS NULL THEN 0 ELSE TotalDebit END)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.