Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Double bracketing sums inside SQL server views (queries)

Posted on 2014-02-16
4
Medium Priority
?
133 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 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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