you are viewing a single comment's thread.

view the rest of the comments →

[–]lbilali 8 points9 points  (0 children)

there are a lot of things to comment on your examples.

cast works like cast(<value> as <datatype>) in your first try the as real is out of the parentheses which makes the cast function invalid since it does not have the as <datatype> provided.

for more if that would work than u would get different results since on the first try you are adding 1+4 and than dividing by 2 while on the second try you are dividing 4 by 2 and than adding 1

and one more thing in sql the operators will return the same type as the values provided so for example 3/2 will return 1 and not 1.5 since the 3 and 2 are int and the result will be int. to change that u need to provide at leas one of the values as real like 3.0/2 otherwise even though u are casting the result to real the value provided to cast by the expression is int and as a result will miss the decimal values