Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Parent and Children of a Left Outer Join 1

Status
Not open for further replies.

Axminster

IS-IT--Management
May 8, 2012
4
GB
Hi there, my first post here!

I have 2 tables joined by a left-outer. The {part} table and the {part_comp} table.

What I'd like my report to do is, with the use of a groupable formula, list the parent part and its components (if any).
In their most basic, relevant form, the tables look like this:
[tt]
Part Part_Comp
Part Part Comp_Part
000001 000001 001001
000001 001002
000001 001003
000002 000002 002001
000002 002002
000003
000004
000005 000005 005001
[/tt]
All I have so-far is this:
Code:
//{@Compo}
If IsNull({part_comp.comp_part}) Then {part.part} Else {part_comp.comp_part}
I know this will only display the part OR its components, I simply can't get my head around how to display the part AND...

Can anyone solve this one?
 
What is the problem you are running into? What is the resulting display (using your sample data)? I'm assuming you have a left join FROM part TO PartComp, with no selection criteria on PartComp fields.

-LB
 
To have the formula return both, use:

//{@Compo}
If IsNull({part_comp.comp_part}) Then {part.part} Else {part.part} & " " & {part_comp.comp_part}

Are you aware of the Crystal option to do hierarchical grouping? See Online help...

hth,
- Ido

view, export, burst, email, and schedule Crystal Reports.
 
@lbass
Thanks for the reply. Yes, I've left-outer joined from part to part_comp; no selection criteria.
The problem I'm running into is that if a part has components, my formula only returns those components. What I need is the part AND its components. If referring to the table in my initial post, we choose part 000001, we should have:
[tt]000001
001001
001002
001003
[/tt]

@IdoMillet
Thanks for yours also. Unfortunately, your suggestion just appends the component to the part, so we would get:
[tt]000001 001001
000001 001002
000001 001003
[/tt]
Hah! Hierarchical Grouping! B****r me sideways. (Please, don't)
That fixes everything, I've never used it before. Now I don't need my formula OR the subreport, OR the shared variables.

Thanks to the both of you for your efforts!
 
Annoyingly now, my reply of thanks is not being submitted...
 
@lbass
Thanks for the reply. Yes, I've left-outer joined from part to part_comp; no selection criteria.
The problem I'm running into is that if a part has components, my formula only returns those components. What I need is the part AND its components. If referring to the table in my initial post, we choose part 000001, we should have:
[tt]000001
001001
001002
001003
[/tt]

@IdoMillet
Thanks for yours also. Unfortunately, your suggestion just appends the component to the part, so we would get:
[tt]000001 001001
000001 001002
000001 001003
[/tt]
Hah! Hierarchical Grouping! B****r me sideways. (Please, don't)
That fixes everything, I've never used it before. Now I don't need my formula OR the subreport, OR the shared variables.

Thanks to the both of you for your efforts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top