Is it in one query? If so, use CF's Grouping
<CFOUTPUT QUERY="Departments" GROUP="Dept">
#Dept#
<dir>
<CFOUTPUT GROUP="Manager">
#Manager#
<dir>
<CFOUTPUT>
#Worker#<br>
</CFOUTPUT>
</dir>
</CFOUTPUT>
</dir>
</CFOUTPUT>
Philip Arnold
Technical Director
Certified ColdFusion Developer
ASP Multimedia Limited
Switchboard: +44 (0)20 8680 8099
Fax: +44 (0)20 8686 7911
www.aspmedia.co.uk
www.aspevents.net
An ISO9001 registered company.
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
> -----Original Message-----
> From: Thane Sherrington [mailto:[EMAIL PROTECTED]]
> Sent: 27 May 2002 15:45
> To: CF-Talk
> Subject: Grouping issue
>
>
> I have a database with three tables:
> Departments
> ID
> Name
>
> Managers
> ID
> Name
> DeptID
>
> Workers
> ID
> Name
> ManagerID
>
> I'm creating a report that looks like this:
>
> Dept 1
> Manager1
> Worker1
> Worker2
> Worker3
> Manager2
> Worker4
> Worker5
> Dept2
> Manager3
> Worker6
> Worker7
>
> Etc.
>
> The first time I did this report, I did a query loop through
> departments,
> with a nested loop through managers, and finally a nested loop throuh
> workers. But this was three queries, which seemed inefficient.
>
> So then I created a single query, but it kept repeating the
> dept or manager
> name for each worker, so I instead did this (pseudocode):
>
> begin dept loop
> if deptname NEQ olddeptname
> display deptname
> else
> if managername NEQ old managername
> display managername
> else
> display workername
> endif
> endif
> end loop
>
> I'm not sure if this is the right approach either. Is there
> a way either
> in SQL or Coldfusion to have it only show the department and
> and manager
> the first time the value appears?
>
> T
>
>
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists