Question
Group by or Loop
Hi Everyone,
I'm trying to generate the following output from an Access DB:
Desired Ouput:
<u>Minneapolis</u>
ND, SD -John ext 2240
IL- Charles ext 2222
MI, WI -Laurie ext1300
MN – Sara ext 4555
Here's the CF code i'm using:
<!---Minneapolis--->
<cfquery name="Minneapolis" datasource="cs_data">
SELECT responsibility.state_name, responsibility.state, admin.csr_name, admin.csr_extension,
admin.csr_first_name, admin.csr_extension, responsibility.reg_office
FROM admin, responsibility
WHERE responsibility.csr_id = admin.id AND responsibility.reg_office = 'Minneapolis'
ORDER BY admin.csr_name
</cfquery>
<table width="1000">
<tr>
<td valign="top" width="600"><cfloop query="Minneapolis">
<cfoutput><br>#state#–#csr_name# | Ext–#csr_extension#</cfoutput>
</cfloop></td>
</tr>
</table>
But instead of the desired output i'm getting the following output:
WI–Laurie | Ext–1300
SD–John | Ext–2240
ND–John | Ext–2240
MN–Sara | Ext–4555
MI–Laurie | Ext–1300
IL–Charles | Ext–2222
I just want the Person's name listed with all the states they're responsible for.
Would I use a group by to solve this? Any help would be appreciated.
thanks,
I'm trying to generate the following output from an Access DB:
Desired Ouput:
<u>Minneapolis</u>
ND, SD -John ext 2240
IL- Charles ext 2222
MI, WI -Laurie ext1300
MN – Sara ext 4555
Here's the CF code i'm using:
<!---Minneapolis--->
<cfquery name="Minneapolis" datasource="cs_data">
SELECT responsibility.state_name, responsibility.state, admin.csr_name, admin.csr_extension,
admin.csr_first_name, admin.csr_extension, responsibility.reg_office
FROM admin, responsibility
WHERE responsibility.csr_id = admin.id AND responsibility.reg_office = 'Minneapolis'
ORDER BY admin.csr_name
</cfquery>
<table width="1000">
<tr>
<td valign="top" width="600"><cfloop query="Minneapolis">
<cfoutput><br>#state#–#csr_name# | Ext–#csr_extension#</cfoutput>
</cfloop></td>
</tr>
</table>
But instead of the desired output i'm getting the following output:
WI–Laurie | Ext–1300
SD–John | Ext–2240
ND–John | Ext–2240
MN–Sara | Ext–4555
MI–Laurie | Ext–1300
IL–Charles | Ext–2222
I just want the Person's name listed with all the states they're responsible for.
Would I use a group by to solve this? Any help would be appreciated.
thanks,
