Listing 1
<cfquery name="qAll" datasource="#request.maindsn#">
SELECT Count(searchid) AS Total
FROM Searches
</cfquery>
<cfquery name="qSearches" datasource="#request.maindsn#">
SELECT DISTINCT Term
FROM Searches
</cfquery>
<cfset sumSearches = qAll.Total>
<style type="text/css">
.style1 {font-family: Arial, Helvetica, sans-serif}
</style>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#CCCCCC">
<th scope="col"><span class="style1">Search Term</span></th>
<th scope="col"><span class="style1">Number of Searches</span></th>
<th scope="col"><span class="style1">Most Recent Search </span></th>
<th scope="col"><span class="style1">Percent of Total </span></th>
</tr>
<cfoutput query="qSearches">
<cfquery name="qDetail" datasource="#request.maindsn#">
SELECT Count(searchid) AS Count FROM Searches WHERE Term = '#Term#'
</cfquery>
<cfset numSearches = qDetail.Count>
<cfquery name="qDetail2" datasource="#request.maindsn#">
SELECT Max(WhenRan) AS Last FROM Searches WHERE Term = '#Term#'
</cfquery>
<cfset LastSearch = qDetail2.Last>
<cfset PercentTotal = (numSearches / sumSearches) * 100>
<tr<cfif CurrentRow MOD 2> bgcolor="##669999"</cfif>>
<td><strong>#Term#</strong></td>
<td><div align="right">#NumberFormat(numSearches)#</div></td>
<td><div align="right">#DateFormat(LastSearch,"m/dd/yyyy")#</div></td>
<td><div align="right">#NumberFormat(PercentTotal)#%</div></td>
</tr>
</cfoutput>
</table>
Listing 2
<cfquery name="qAll" datasource="#request.maindsn#">
SELECT Count(searchid) AS Total
FROM Searches
</cfquery>
<cfset sumSearches = qAll.Total>
<cfquery name="qSearches" datasource="#request.maindsn#">
SELECT Term,
Count(searchid) AS numSearches,
Max(WhenRan) AS LastSearch,
((Count(searchid)/#sumSearches#)*100) AS PercentTotal
FROM Searches
GROUP BY Term
ORDER BY Count(searchid) DESC
</cfquery>
<style type="text/css">
.style1 {font-family: Arial, Helvetica, sans-serif}
</style>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#CCCCCC">
<th scope="col"><span class="style1">Search Term</span></th>
<th scope="col"><span class="style1">Number of Searches</span></th>
<th scope="col"><span class="style1">Most Recent Search </span></th>
<th scope="col"><span class="style1">Percent of Total </span></th>
</tr>
<cfoutput query="qSearches">
<tr<cfif CurrentRow MOD 2> bgcolor="##669999"</cfif>>
<td><strong>#Term#</strong></td>
<td><div align="right">#NumberFormat(numSearches)#</div></td>
<td><div align="right">#DateFormat(LastSearch,"m/dd/yyyy")#</div></td>
<td><div align="right">#NumberFormat(PercentTotal)#%</div></td>
</tr>
</cfoutput>
</table>
Listing 3
<cfquery name="qAll" datasource="#request.maindsn#">
SELECT Count(searchid) AS Total
FROM Searches
</cfquery>
<cfset sumSearches = qAll.Total>
<cfquery name="qSearches" datasource="#request.maindsn#">
SELECT Term,
Count(searchid) AS numSearches,
Max(WhenRan) AS LastSearch,
'' AS PercentTotal
FROM Searches
GROUP BY Term
ORDER BY Count(searchid) DESC
</cfquery>
<cfoutput query="qSearches">
<cfset QuerySetCell(qSearches, 'PercentTotal', ((numSearches/sumSearches)*100), CurrentRow)>
</cfoutput>
<style type="text/css">
.style1 {font-family: Arial, Helvetica, sans-serif}
</style>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#CCCCCC">
<th scope="col"><span class="style1">Search Term</span></th>
<th scope="col"><span class="style1">Number of Searches</span></th>
<th scope="col"><span class="style1">Most Recent Search </span></th>
<th scope="col"><span class="style1">Percent of Total </span></th>
</tr>
<cfoutput query="qSearches">
<tr<cfif CurrentRow MOD 2> bgcolor="##669999"</cfif>>
<td><strong>#Term#</strong></td>
<td><div align="right">#NumberFormat(numSearches)#</div></td>
<td><div align="right">#DateFormat(LastSearch,"m/dd/yyyy")#</div></td>
<td><div align="right">#NumberFormat(PercentTotal)#%</div></td>
</tr>
</cfoutput>
</table>
Listing 4
<style type="text/css">
th {background-color:#CCCCCC;font-family: Arial, Helvetica, sans-serif;}
tr.odd {background-color:#669999;}
td.number {text-align:right;}
td.date {text-align:right;}
</style>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tr>
<th scope="col">Search Term</th>
<th scope="col">Number of Searches</th>
<th scope="col">Most Recent Search</th>
<th scope="col">Percent of Total</th>
</tr>
<cfoutput query="qSearches">
<tr class="<cfif CurrentRow MOD 2>odd<cfelse>even</cfif>">
<td class="text"><strong>#Term#</strong></td>
<td class="number">#NumberFormat(numSearches)#</td>
<td class="date">#DateFormat(LastSearch,"m/dd/yyyy")#</td>
<td class="number">#NumberFormat(PercentTotal)#%</td>
</tr>
</cfoutput>
</table>
Listing 5
<style type="text/css">
#searchapp table {border:1px solid black;width:600px;}
#searchapp th {background-color:#CCCCCC;font-family: Arial, Helvetica, sans-serif;}
#searchapp tr.odd td {background-color:#669999;}
#searchapp td.number {text-align:right;}
#searchapp td.date {text-align:right;}
</style>
<div id="searchapp">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<th scope="col">Search Term</th>
<th scope="col">Number of Searches</th>
<th scope="col">Most Recent Search</th>
<th scope="col">Percent of Total</th>
</tr>
<cfoutput query="qSearches">
<tr class="<cfif CurrentRow MOD 2>odd<cfelse>even</cfif>">
<td class="text"><strong>#Term#</strong></td>
<td class="number">#NumberFormat(numSearches)#</td>
<td class="date">#DateFormat(LastSearch,"m/dd/yyyy")#</td>
<td class="number">#NumberFormat(PercentTotal)#%</td>
</tr>
</cfoutput>
</table>