Copy link to clipboard
Copied
This part of my query;
SUM(totalSCs)+(totalCalls)+((TSLdays)*(WCG))/(5)/(QTCG) AS PerCalls
is giving me an erratic result...specifically 24.03 instead of .16
1 + 23 + (1 * 22) / 5) /176 = .16
Am I writing this incorrectly? Any assistance would be greatly appreciated!
(1 + 23 + (1 * 22 / 5)) /176 = 0.16...
Similarly,
(SUM(totalSCs) + totalCalls + (TSLdays*WCG/5))/QTCG AS PerCalls
Copy link to clipboard
Copied
(1 + 23 + (1 * 22 / 5)) /176 = 0.16...
Similarly,
(SUM(totalSCs) + totalCalls + (TSLdays*WCG/5))/QTCG AS PerCalls
Copy link to clipboard
Copied
Yep, the parenthesis makes all the difference. Things are not evaluated left to right exclusively. There is an order of operations http://en.wikipedia.org/wiki/Order_of_operations in which things are evaluated. For CF, take a look at the
cfdocs: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec09d55-7fff.html
(the link is for CF9, but I don't believe things have changed at all from prior versions).
Copy link to clipboard
Copied
Thanks BKBK and everyone else who responded. The parentheses were the key!
Copy link to clipboard
Copied
Am I writing this incorrectly?
Yes. As BKBK and editcorp mentioned, always use parenthesis to ensure the correct order of evaluation.