We help IT Professionals succeed at work.
Get Started

SQL to list detail accounting unit as well as summary accounting unit

490 Views
Last Modified: 2012-05-11
Hello,

I am writing a Crystal SQL Command report on an Oracle database for the Lawson ERP.   The report has data from several tables but this section of code is not working.  The table name is GLNAMES.  The table contains a posting level account as well as a summary account; see sample data file.  My code is not pulling in the summary account and summary account description.

 Here is my code
select
gln.description,
gln.posting_flag,
(select gln2.acct_unit from lsfmigd.glnames gln, lsfmigd.glnames gln2
where gln2.posting_flag = 'S'
and gln.parent_obj_id = gln2.obj_id
and gln.company = gln2.company
and gln.acct_unit = gln2.acct_unit
and gln.company = gln.company) as Parent_Unit,
(select gln2.description from lsfmigd.glnames gln, lsfmigd.glnames gln2
where gln2.posting_flag = 'S'
and gln.parent_obj_id = gln2.obj_id
and gln.company = gln2.company
and gln.acct_unit = gln2.acct_unit
and gln.company = gln2.company) as Parent_Desc
from  lsfmigd.glnames gln
where gln.posting_flag = 'P'
and cast(gln.acct_unit as integer) = 10001

I would like your help to modify my code so that the query pulls in accounting unit 100_NURSING_ADM and description Nursing Administration
glnames.csv
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE