Cold Fusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingCold Fusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2005, 10:03 AM
jermadem jermadem is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 1 jermadem User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 28 sec
Reputation Power: 0
displaying Crosstab column headings

i have a form that users can select three separate variables from. Term, Var1, and Var2. I use the term to determine which table to get data from, and the other variables determine which field names will be compared with each other in a crosstab.
i created the crosstab in Access and just copied and pasted the code, then changed the absolute field names to the variable names, var1 and var2.

this means i only need one sql statement that can be used no matter what term or variables the person chooses. Unfortunately, it seems i still need to write different code for each combination possible (at least 70) in order to display it correctly.

for example, after the sql code:

<cfset term = #Form.Term#>
<cfset var1 = #Form.Var1#>
<cfset var2 = #Form.Var2#>
<cfset comb = "#var1##var2#">
<CFQUERY NAME="#var1##var2#" DATASOURCE="DSN">
TRANSFORM Count(#term#.count) AS CountOfcount
SELECT #term#.#var1#, Count(#term#.count) AS [Total_Of_count]
FROM #term#
GROUP BY #term#.#var1#
PIVOT #term#.#var2#;
</CFQUERY>

i'll display the results as such:
<table cellpadding="3" cellspacing="0" border="0" width="600">
<tr bgcolor="#E1E8EC"><td><cfoutput>#var1#</cfoutput></td><td align="right">Undergrad</td><td align="right">Graduate</td><td align="right">Law</td><td align="right">Medical</td><td align="right"><b>Total</b></td></tr>
<CFOUTPUT QUERY="#comb#" group="#Evaluate(var2)#">
<tr><td>#Evaluate(var2)#</td></tr>
<tr><td>#Replace(Evaluate(var1), "_", " ", "ALL")#</td><td align="right">#Undergrad#</td><td align="right">#Grad#</td><td align="right">#Law#</td><td align="right">#Medical#</td><td align="right"><b>#Total_Of_count#</b></td></tr>
<cfif #Undergrad# gt 0><cfset atotal = atotal + #Undergrad#></cfif>
<cfif #Grad# gt 0><cfset btotal = btotal + #Grad#></cfif>
<cfif #Law# gt 0><cfset ctotal = ctotal + #Law#></cfif>
<cfif #Medical# gt 0><cfset dtotal = dtotal + #Medical#></cfif>
<cfset etotal = etotal + #Total_Of_count#>
</CFOUTPUT>
<cfoutput><tr><td><b>Total</b></td><td align="right"><b>#atotal#</b></td><td align="right"><b>#btotal#</b></td><td align="right"><b>#ctotal#</b></td><td align="right"><b>#dtotal#</b></td><td align="right"><b>#etotal#</b></td></tr></cfoutput>
</table>

what i would prefer to do is somehow replace the Grad, Law, Medical, etc variables with something not specific to any case. So that i'll only need one section that is used to display the results. Undergrad, Grad, Law, and Medical were in a column in the original table, and they are being summed up in the crosstab.
in order for this to work, i would need a way to have the words "Undergrad", "Grad", etc displayed as the column headings. And for every possible combination the user might pick, it would change not only the heading names, but the number of headings being displayed.
I don't know if this is possible or if i've explained it well enough, but any suggestions would be much appreciated.
thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > displaying Crosstab column headings


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek