Yes, both suggestions will work. As it was already typed, here's an untested
cfoutput example.
SELECT department, EmployeeName
FROM Employees
ORDER BY department, EmployeeName
<cfoutput query="yourQuery" group="department">
<b>#department#</b><br>
<cfoutput>#EmployeeName#<br></cfoutput>
<br>
</cfoutput>
Wow, that didn't work at all :-)
I got all the employees listed under all the departments.
<cfquery name="deptDirectory" datasource="sql_abt">
Select s.firstname, s.lastname, s.ext, s.title, s.email, d.dept
FROM lsstaff S, lsdepts D
Where s.deptid = d.deptid
AND s.rank <> 2 OR s.rank <> 5
ORDER BY d.dept
</cfquery>
And then used the suggested CFML to output it....
<cfset deptDirectory = viewState.getValue("deptDirectory")>
<cfoutput query="deptDirectory" group="dept">
<b>#dept#</b><br>
<cfoutput>
<table width="98%" border="0" align="center">
<tr>
<td>#firstname# #lastname#</td>
<td>#title#</td>
<td>
<cfif LEN(#ext#) GT 4>
#ext#
<cfelse>
734.827.#ext#
</cfif></td>
</tr>
</table>
<br></cfoutput>
<br>
</cfoutput>
What did I miss?
Ian Skinner - 12 Sep 2007 20:23 GMT
No obvious syntax errors that I can see. So HOW did it not work at all?
Error messages? Improper data? Improper display? What went awry?
P.S.
WHERE s.deptid = d.deptid
AND s.rank <> 2 OR s.rank <> 5
This looks a bit odd to me. Would this not return all rank values? I
presume every rank value is going to either not be two OR not be five?
WebDev - 12 Sep 2007 20:36 GMT
It looped everyone in each department header.
Admissions
Everyone in the database
Academic Affairs
Everyone in the database
Career Services
Everyone in the database
WebDev - 12 Sep 2007 20:37 GMT
Nevermind, got it to work.
Dan Bracuk - 12 Sep 2007 20:53 GMT
[q][i]Originally posted by: [b][b]Newsgroup User[/b][/b][/i]
Wow, that didn't work at all :-)
I got all the employees listed under all the departments.
<cfquery name="deptDirectory" datasource="sql_abt">
Select s.firstname, s.lastname, s.ext, s.title, s.email, d.dept
FROM lsstaff S, lsdepts D
Where s.deptid = d.deptid
AND s.rank <> 2 OR s.rank <> 5
ORDER BY d.dept
</cfquery>
And then used the suggested CFML to output it....
<cfset deptDirectory = viewState.getValue("deptDirectory")>
<cfoutput query="deptDirectory" group="dept">
[B]#dept#[/B]<br>
<cfoutput>
<table width="98%" border="0" align="center">
<tr>
<td>#firstname# #lastname#</td>
<td>#title#</td>
<td>
<cfif LEN(#ext#) GT 4>
#ext#
<cfelse>
734.827.#ext#
</cfif></td>
</tr>
</table>
<br></cfoutput>
<br>
</cfoutput>
What did I miss?
[/q]
My guess is that you missed column aliases in the select clause.
WebDev - 20 Sep 2007 12:00 GMT
Actually, for anyone else out there, I messed the WHERE clause of rank. I
changed it and it worked like a charm.
Thanks everyone!