Coldfusion 8: identify repeating values in a column and counting number of times it appears -
i need query table in sql db using cf 8, @ specific column repeating values, , count how many times occurs. i new cf , life of me can't figure out how this. can query db , specify results referenced column, rest frustrating!
so, if had following results query specific column:
apple apple grape pear apple pear apple
i know query of query, have know values (fruits in case) before hand. or believe.
basically, need able run cfm , have spit out:
- apple: 4
- pear: 2
- grape: 1
not knowing values might beforehand.
can please help?
<cfquery name="qmyfruits"> select fruitname, count(fruitname) instances fruits group fruitname </cfquery> <cfoutput query="qmyfruits"> <p>#qmyfruits.fruitname# : #qmyfruits.instances#</p> </cfoutput>
Comments
Post a Comment