Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Double bracketing sums inside SQL server views (queries)

Posted on 2014-02-16
4
Medium Priority
?
135 Views
Last Modified: 2014-02-22
I have may calculations inside SQL Server views

Like.... SUM(ProductCountAct) /  SUM(ProductCountStd) ...............works fine

All work ok, but when i need to include extra brackets none of them work

(SUM(ProductCountAct) - SUM(ScrapCount)) / SUM(ProductCountAct)..........does not work

I am sure it must be something very simple but any help most welcome
0
Comment
Question by:SweetingA
  • 2
  • 2
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 39862873
>>does not work
Does that mean an error or not what you expect ?
0
 

Author Comment

by:SweetingA
ID: 39862907
Does not error, outputs a zero and the answer is not zero, it should be 0.98

Thanks
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 39864012
OK.  Are any of the fields you sum integer (not floating point) values ?  (and that the variable in your code is a floating point type, not an integer type).

This zero result can be due to the compiler treating it as integer maths rather than floating point maths.  (Or you are loading the result into an integer variable with truncation).


ps.  I assume you have checked where the opening and matching closing braces are - not that a closing brace is in the wrong location.
0
 

Author Closing Comment

by:SweetingA
ID: 39879942
Yes it was treating result as integer, thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question