So I played around with this a little and this is what I cam up with. There is probably a better way to accomplish this but it works. It take into account the possibility each year doesn't have the same data. HTH, --Dave <cfquery name="getData" datasource="demo" > select year, material, area from sample order by year </cfquery> <cfset materialList = listremoveduplicates(valuelist(getData.material))> <cfset yearList = listremoveduplicates(valuelist(getData.year))> <table border="1"> <tr> <th>Year</th> <cfloop list="#materiallist#" index="l"> <th><cfoutput>#l#</cfoutput></th> </cfloop> </tr> <cfloop list="#yearList#" index="y"> <tr> <td><cfoutput>#y#</cfoutput></td> <cfquery dbtype="query" name="data" > select * from getdata where [year] = #y# </cfquery> <cfset thisMaterial = valuelist(data.material)> <cfset thisArea = valuelist(data.area)> <cfloop list="#materialList#" index="m" > <cfset item = listFindNocase( thisMaterial, m)> <td> <cfif item> <cfoutput>#listGetAt(thisArea, item)#</cfoutput> </cfif> </td> </cfloop> </tr> </cfloop> </table>
... View more