Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grouping problem
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01338206
Message ID:
01338297
Views:
19
>Sure. After the information about the case itself (the header), they want the Attorney and Party data to look like this:
>
>
>Attorney Julie Nagle
>---Plaintiff Bob Bridge
>---Plaintiff Helen Bridge
>
>Attorney Ben Bogle
>Attorney John Doe
>Attorney Nancy Golden
>---Plaintiff Roger Randle
>---Plaintiff Geri Randle
>---Plaintiff Jennifer Randle
>---Plaintiff Henry Randle
>---Plaintiff Percy Wilson
>
>Attorney Jim Daniels
>Attorney Frank Smith
>---Defendant Amy Black
>---Defendant George Green
>
>Attorney Henry Prince
>---Defendant Mary French
>
>For each Case, there is at least one Party on each side; each Party is represented by one or more Attorneys. The problems with the report formatting come when they share Attorneys.. The data structure doesn't really facilitate grouping them. The Case is the 'parent', the Party the 'child', and the Attorney the 'grandchild'--and 'grandchildren' can be (and are) entered multiple times.. In this example, there are 20 Attorney records, but only 7 distinct individuals.

Assuming the data is in a flat file .. this is what I came up with to get the data sorted by "sets" which will make the reporting fall into place .. but maybe somebody else that's better at SQL and data can improve this:
SELECT case, side, atty, MAX(name) as maxname ;
	FROM junk ;
	GROUP BY case, side, atty ;
	into cursor atty
	
SELECT case, side, name, MAX(atty) as maxatty ;
	FROM junk ;
	GROUP BY case, side, name ;
	into cursor name
	
SELECT distinct atty.case, atty.side, atty.maxname, name.maxatty ;
	FROM atty ;
		RIGHT JOIN name ;
			ON name.case + name.side + name.maxatty = atty.case + atty.side + atty.atty ;
	INTO CURSOR sets

SELECT junk.case, junk.side, sets.maxname + sets.maxatty AS Set, junk.atty, junk.name ;
	FROM junk ;
		LEFT OUTER JOIN atty ;
			ON atty.case + atty.side + atty.atty + atty.maxname = junk.case + junk.side + junk.atty + junk.name ;
		LEFT OUTER JOIN name ;
			ON name.case + name.side + name.name + name.maxatty = junk.case + junk.side + junk.name + junk.atty ;
		LEFT OUTER JOIN sets ;
			ON sets.case + sets.side + sets.maxatty = junk.case + junk.side + name.maxatty ;
		WHERE NOT ISNULL(Sets.Maxatty) ;
UNION ALL ;
SELECT atty.case, atty.side, sets.maxname + sets.maxatty AS Set, atty.atty, '' as name ;
	from atty ;
	LEFT OUTER JOIN sets ;
		ON sets.case + sets.side + sets.maxname = atty.case + atty.side + atty.maxname ;
	WHERE NOT atty.atty = sets.maxatty ;
	order by 1, 2, 3, 4, 5 ;
	into cursor results ;
Cathy Pountney, Microsoft Visual FoxPro MVP
Memorial Business Systems, Inc. (www.mbs-intl.com)

My Website: (www.frontier2000.com)
My Blog: (www.cathypountney.blogspot.com)
My Book: The Visual FoxPro Report Writer - Pushing it to the Limit and Beyond
Free MSDN Article: What's New in the VFP 9.0 Report Writer
Free MSDN Article: The VFP 9.0 Report Writer In Action
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform