This CF query does what I want but I'd like to show only one occurrence of each matching "HEADLINE" that has a count greater than 5. I don't need to display the actual count, just the headline which will be a link using that headline as a url variable. And there must be a more efficient way for my code to work?
<cfquery name="HeadInfo" datasource="certify">
select headline
from post
where deleted = 0
and headline IS NOT NULL
order by altid desc
</cfquery>
<cfoutput>#HeadInfo.RecordCount#</cfoutput>
<cfoutput query="HeadInfo">
<cfquery name="CountInfo" datasource="certify">
select *
from post
where deleted = 0
and headline = '#HeadInfo.Headline#'
order by headline desc
</cfquery>
<cfif CountInfo.RecordCount GT 5>
#HeadInfo.headline# - Count:#CountInfo.RecordCount#<br>
</cfif>
</cfoutput>
You need to do it in one query.