sql maths
-
I chased this sql server error for weeks. This a query for getting received items total value. For brevity, the fields are: q (int) = unit quantity us (int) = units per sleeve (never null or 0) sc (int) = sleeves per case (never null or 0) cv (money) = case value The basic query provided to me from the vendor looked like this:
Sum((q / (us*sc)) * cv) as totalValue
The query ran just fine, but we were always short... :laugh: It turns out the original query was only ever tested with full case counts. :omg: btw, it's fixed, but just thought someone might get a chuckle out of it! :)
"Go forth into the source" - Neal Morse
-
I chased this sql server error for weeks. This a query for getting received items total value. For brevity, the fields are: q (int) = unit quantity us (int) = units per sleeve (never null or 0) sc (int) = sleeves per case (never null or 0) cv (money) = case value The basic query provided to me from the vendor looked like this:
Sum((q / (us*sc)) * cv) as totalValue
The query ran just fine, but we were always short... :laugh: It turns out the original query was only ever tested with full case counts. :omg: btw, it's fixed, but just thought someone might get a chuckle out of it! :)
"Go forth into the source" - Neal Morse
-
Without showing code there's little interesting here (especially since "nothing" was fixed :laugh: ) ... There's 'yer chuckle though.
kmoorevs wrote:
fixed
That's like some sort of like quantum foam, right? if i'm not mistaken
-
I chased this sql server error for weeks. This a query for getting received items total value. For brevity, the fields are: q (int) = unit quantity us (int) = units per sleeve (never null or 0) sc (int) = sleeves per case (never null or 0) cv (money) = case value The basic query provided to me from the vendor looked like this:
Sum((q / (us*sc)) * cv) as totalValue
The query ran just fine, but we were always short... :laugh: It turns out the original query was only ever tested with full case counts. :omg: btw, it's fixed, but just thought someone might get a chuckle out of it! :)
"Go forth into the source" - Neal Morse
-
Tomz_KV wrote:
Is decimal portion not required?
Yes, which was the problem...division casts to the datatype with highest precision for parameters in the equation. (I'm probably saying that wrong!) The correction was to convert one of the parameters in the division to a decimal. :laugh: I only posted here 'cause we no longer have a 'hall of shame'!
"Go forth into the source" - Neal Morse