Solved

Double bracketing sums inside SQL server views (queries)

Posted on 2014-02-16
4
129 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 44

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 44

Accepted Solution

by:
AndyAinscow earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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