I have a table of IP addresses that includes the address, and the person's ID that address is assigned to. What I'm trying to get to is a query that puts out a list of owners and the total number of addresses assigned to each owner. Obviously, each address is in there only once, but any given owner will have many addresses. The following is what I have:
What I get in return is the owner listed once, which is fine, but AdrCount returns 1, and it should return 10 from my test data. Any suggestions welcome! Thanks! Calista :-X
Jedi Knight,
Champion of the Force
Code:
<!--- Query IP table and group by owner. --->
<CFQUERY NAME="GetIPOwners"
DATASOURCE="#Application.Datasource#"
DBTYPE="ODBC">
SELECT IPA_ID,IPA_Address,IPA_PersonID,
COUNT (IPA_PersonID) AS AdrCount
FROM IP_AdrTable
WHERE IPA_Available = No
GROUP BY IPA_PersonID,IPA_ID,IPA_Address
ORDER BY IPA_PersonID
</CFQUERY>
<BR><BR>
<CFOUTPUT QUERY="GetIPOwners" GROUP="IPA_PersonID">#IPA_PersonID#<BR>#AdrCount#</CFOUTPUT>
<BR><BR>
Jedi Knight,
Champion of the Force