Solved

Loop

Posted on 2006-07-07
2
267 Views
Last Modified: 2010-04-17
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
Comment
Question by:Mehram
2 Comments
 
LVL 3

Expert Comment

by:cdemir
ID: 17057354
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
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17057375
SELECT acc_id, Title FROM account ORDER BY CAST(acc_id AS binary)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question