Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loop

Posted on 2006-07-07
2
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 total points
ID: 17057375
SELECT acc_id, Title FROM account ORDER BY CAST(acc_id AS binary)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…
Simple Linear Regression

721 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