Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Loop

I have to design report for printing/viewing chart of account. My chart of account is base on two filed on acc_id (PK) second parent account id


acc_id,       ParAccountID            Title
1            NULL                  Assets
1001            1                  Fixed Assets
1001001      1001                  Computer
1001002      1001                  Office Eqipment
1001003      1001                  Furniture & Fixture
1002            1                  Current Assets
1003            1                  Cash & Bank
1004            1                  Cash at IOU
2            NULL                  Equity and Liabilities
2001            2                  Current Liabilities
2002            2                  Freight Payable
3            NULL                  Revenue
4                              Expense

I want to display them like this:

Code      Title
1      Asset
1001            Fixed Assets
1001001            Computer
1001002            Office Equipment
1001003            Furniture & Fixture

2      Equity and Liabilities
2001            Current Liabilities

Is there any one how can guide me in which format it can be display on best way or about MS SQL.
0
Mehram
Asked:
Mehram
1 Solution
 
cdemirCommented:
hi,
try this :

select acct_id,title from table where paraccountid is null
union all
select acct_id,title from table where paraccountid is not null
0
 
ozoCommented:
SELECT acc_id, Title FROM account ORDER BY CAST(acc_id AS binary)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now