Solved

Double bracketing sums inside SQL server views (queries)

Posted on 2014-02-16
4
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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