Solved

Double bracketing sums inside SQL server views (queries)

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

709 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now