Solved

Loop

Posted on 2006-07-07
2
259 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
Comment Utility
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
Comment Utility
SELECT acc_id, Title FROM account ORDER BY CAST(acc_id AS binary)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now