Answered
DB Updates Using CFIF
I am trying to find the upper octile of a table and to do
this I get the number of rows in a table, divide by eight and
multiply by seven.
<cfset upperOctile = round(getRatings.RecordCount/8*7)>
Then I loop through getRatings (order by rating, of course), and if the currentRow is LT the upperOctile, I try to assign it a zero, and if it's GTE I try to assign a 1.
<cfloop query="getRatings">
<cfoutput>#currentRow#</cfoutput>
<cfquery name="update" datasource="admi-prod">
UPDATE tempTable
<cfif currentRow LT upperOctile>
SET upper = 0
<cfelse>
SET upper = 1
</cfif>
</cfquery>
</cfloop>
In this case, upper is always set to 1. I even print out currentRow to make sure the rows are turning out right.
And this always sets all the rows to 0.
<cfloop query="getRatings">
<cfoutput>#currentRow#</cfoutput>
<cfif currentRow LT upperOctile>
<cfquery name="update" datasource="admi-prod">
UPDATE tempTable
SET upper = 0
</cfquery>
</cfif>
</cfloop>
This seems like pretty straightforward stuff, but that's sometimes where I fall into the trap of missing the obvious.
Any help would be appreciated! Thanks!
<cfset upperOctile = round(getRatings.RecordCount/8*7)>
Then I loop through getRatings (order by rating, of course), and if the currentRow is LT the upperOctile, I try to assign it a zero, and if it's GTE I try to assign a 1.
<cfloop query="getRatings">
<cfoutput>#currentRow#</cfoutput>
<cfquery name="update" datasource="admi-prod">
UPDATE tempTable
<cfif currentRow LT upperOctile>
SET upper = 0
<cfelse>
SET upper = 1
</cfif>
</cfquery>
</cfloop>
In this case, upper is always set to 1. I even print out currentRow to make sure the rows are turning out right.
And this always sets all the rows to 0.
<cfloop query="getRatings">
<cfoutput>#currentRow#</cfoutput>
<cfif currentRow LT upperOctile>
<cfquery name="update" datasource="admi-prod">
UPDATE tempTable
SET upper = 0
</cfquery>
</cfif>
</cfloop>
This seems like pretty straightforward stuff, but that's sometimes where I fall into the trap of missing the obvious.
Any help would be appreciated! Thanks!