Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

output the right information

$
0
0

I have a query (yes is very long,it works, trying to make it better ).

 

DECLARE @today DATETIMESET @today = '2014-04-13'    ;with CTE as(          Select d.csedept_name,d.csedept_id, Average = CASEWHEN d.csedept_question5 ISNULL          THEN (SelectAVG(((cast(c.rating1 asFloat)+ cast(c.rating2 asFloat)+cast (c.rating3 asFloat)+cast(c.rating4 asFloat))/4))                    From intranet.dbo.CSEReduxResponses c                    Where c.employeedept = d.csedept_id                    AND c.execoffice_status > 0                    ANDmonth(approveddate) = MONTH(@today))          ELSE (SelectAVG(((cast(c.rating1 asFloat)+ cast(c.rating2 asFloat)+cast (c.rating3 asFloat)+cast(c.rating4 asFloat)+cast(c.rating5 asFloat))/5))                    From intranet.dbo.CSEReduxResponses c                    Where c.employeedept = d.csedept_id                    AND c.execoffice_status > 0                    ANDmonth(approveddate) = MONTH(@today))          ENDfrom Intranet.dbo.CSEReduxDepts d
)Select Top 2 Ranks = RANK() Over(OrderBy Average DESC) ,* from CTE

well it get the top 2 of the data.

so im tyring to ouput those top two results:

 

 

<cfset highest_dept_name_average_runnerup = 0>

<cfset highest_dept_name_average_runnerup = 0>

<cfoutput query="getHighestDeptAverage">

<cfif Ranks eq 1>

<cfset highest_dept_name_average =csedept_name>

<cfset hihest_dept_average = average>

</cfif>

<cfif Ranks eq 2>

<cfset highest_dept_name_average_runnerup =csedept_name>

<cfset highest_dept_name_average_runnerup = average>

</cfif>

</cfoutput>

--------------------------------------------------------------

  <cfoutput query="getHighestDeptAverage">

 

<h1><cfoutput>#self1#</cfoutput></h1>

  <h3><cfoutput>Department-#csedept_name#</cfoutput></h3>

 

 

  </cfoutput>

 

 

so right now it output like this, its repeateing 'cfif Rank eq 1'

 

picture.PNG

how can i get it to only display once?


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>