Solved

Loop

Posted on 2006-07-07
2
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This is an explanation of a simple data model to help parse a JSON feed
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

947 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

23 Experts available now in Live!

Get 1:1 Help Now