Reporting staff grouped by columns
Hi all,
As a reminder, I am not a programmer, far from it. Please forgive the poor design. This is for a small intranet, so I am not looking to improve what we're working with.
I have an employees table. In that table I have these columns that I am interested in working with:
- First_Name
- Last_name
- Sup (more on that in a minute)
- Job Title
I want to display the Supervisors in a column with their staff, by group, under them. The number of Sups will vary over time. Today it's four, in a few months it will be three...
This is what I am looking for:

OK, so the Sup column form the database.
If the employee is a Supervisor, they have a 0 in the Sup column.
Reporting staff then have the Supervisor's employee number in their Sup column establishing who reports to whom.
I have been able to get the column display for the Supervisors but cannot figure out how to get the staff listed (in groups) under them.
Here is what I am using:
<cfquery name="Sups" DataSource="#APPLICATION.DSN#">
SELECT
First_Name + ' ' + last_name AS SupName
FROM
Employees
Where
Sup = 0
Order By
Last_name
</cfquery>
<table width="100%">
<caption>Supervisors</caption>
<cfloop list="#Sups.columnList#" index="col">
<thead>
<tr>
<cfloop query="Sups">
<th><cfoutput>#SupName#</cfoutput></th>
</cfloop>
</tr>
</thead>
</cfloop>
</table>That displays this for me:

Any tips on how to add the staff query / output?
If I add a column to the Sups query, it duplicates the rows in the output.
I found the partial solution above here https://stackoverflow.com/questions/28238242/coldfusion-can-cfoutput-list-all-columns-in-the-table-without-explicitly-listi
Thank you for any help pointing me in the right direction.


