I'm still busy, but want a quick break, so anyway...
CFML code:
<!---
Count how many of each wood type is used...
--->
<cfset WoodTypes = [] />
<cfloop query="batch_report3">
<cfset WoodName = extractWoodName(Description) />
<cfif StructKeyExists(WoodTypes,WoodName)>
<cfset WoodTypes[WoodName]++ />
<cfelse>
<cfset WoodTypes[WoodName] = 0 />
</cfif>
</cfloop>
<!---
Work out what the most common wood type is...
--->
<cfset MaxCount = 0 />
<cfset MaxType = "" />
<cfloop item="CurType" collection=#WoodTypes#>
<cfif WoodTypes[CurType] GT MaxCount >
<cfset MaxCount = WoodTypes[CurType] />
<cfset MaxType = CurType />
</cfif>
</cfloop>
<cfoutput>
<p>Most common wood type is "<b>#MaxType#</b>".</p>
</cfoutput>
<!---
Extract the name from the description.
(May need changing/expanding depending on other description formats.)
--->
<cffunction name="extractWoodName" returntype="string" output="false" >
<cfargument name="Text" type="string" required />
<cfset var Name = rereplace(Arguments.Text,'^\d/\d x RW','') />
<cfset Name = rereplace(Arguments.Text,'(?:prime|\da?)? (?:common|boards|unselected|blocking) green') />
<cfreturn Trim(Name) />
</cffunction>
If one of the many crazy columns has just the wood name on its own, you don't need the extractWoodName bit.
I didn't test that, so there might be bugs in it, but hopefully not.
Oh, and that only returns one maximum, so if there's like 5 Cherry, 5 Hard Maple, 2 White Oak, it'll say "cherry" OR "hard maple", but not both.
Don't know if that's good enough, or if you do need to cater for that?
If I wasn't busy, I'd suggest a billion ways to make your code look nicer, but I will say just two things:
TABS ARE YOUR FRIEND!
Identing blocks makes things MUCH easier to read.
(Although using eight space for it, like Firefox is doing above, is a tad annoying.)
Also, you don't need lots of those #s - they basically only need to be used when outputting HTML/etc (i.e. inside cfoutput), or when using a variable in a string (i.e. inside "quotes"), but generally not in cfset tags.
EDITED: 20 Apr 2011 17:22 by BOUGHTONP