Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parent/Child/and Grandchild projects into a report
Message
 
To
07/04/2009 19:09:38
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01393750
Message ID:
01393877
Views:
67
>I have a table that contains a list of projects. Each project may be a parent, child, or grandchild project. One of the fields 'parentproject' identifies the relationships. If the field is populated with the ID of another project, then the referenced project is the current project's parent. I have a report with 2 groups to display these like this:
>
>Group1................Parent
>Group2.....................Child
>Details..........................Grandchild
>
>This report seems to work OK and is built on the following SELECT
>
>select r1.system, r1.rtp_id, trim(r1.st_name) + " / " + trim(r1.termini) + " / " + trim(r1.project) as st_name_a, r1.lead, r1.del1, ;
>	r2.rtp_id, trim(r2.st_name) + " / " + trim(r2.termini)  + " / " + trim(r2.project) as st_name_b, r2.lead, r2.del1 as del2, ;
>	r3.rtp_id, trim(r3.st_name) + " / " + trim(r3.termini)  + " / " + trim(r3.project) as st_name_c, r3.lead, r3.del1 as del3 ;
>	from rtp_projects r1 ;
>	left join rtp_projects r2 on r1.rtp_id = r2.parentproject ;
>	left join rtp_projects r3 on r2.rtp_id = r3.parentproject ;
>	where (r1.parentproject = 0 or isnull(r1.parentproject)) and ! isnull(r1.st_name) and ! isblank(r1.st_name);
>	order by r1.system, r1.st_name, r2.st_name, r3.st_name	
>
>Now comes my problem, there is a second table that also contains a list of projects that may be a child to any of the projects in the first table. I would like to include these projects in the report as well, either as a child, grandchild, or great-grandchild. I'm not clear on how the select should be modified to do this, and the report also. Do I need 2 or more detail bands or additional groups, a select with a UNION or more JOINS, etc?

>
>Any pointers will be appreciated. Thanks.


Because you speak about more than one Detail band I assume you use VFP9.

You can use UNION of course, but you could also use so called derived table.
But I would do this in two steps: First UNION both tables in ONE cursor and then using that cursor I'll do the main SELECT (that one you show us)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform