Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 changing datatype in SQL server

Author  Topic 

aash
Starting Member

11 Posts

Posted - 2011-03-28 : 10:17:49
Hi,

This forum is very helpful for a newbee like me. I have been using MSACCESS for a while, now with migration to SQL Server I am trying to learn many things now.

Select
4100/((t.TotalKS)/(t.Mins) *60)*((t.TotalKS)/(t.Mins) *60)/(t.KSPerDoc) as Norm
from
(select
Sum(NOKES) as TotalKS,
Sum(ETES - STES) As Mins
FROM
WINTPOP
WHERE VSON = '333' and VDATE='1/3/2011' group by VDATE, VSON)t

This querey works without error but result is being truncated

result of the calulation 4100/((t.TotalKS)/(t.Mins) *60) is 1.95 but this querey is truncating it to 1, so I am not getting the accurate result. From reading forums I came to know can use CAST, CONVERT or ROUND to correct this. But I am not exactly sure how to apply in my query.

Experts Please help me!

Ifor
Aged Yak Warrior

700 Posts

Posted - 2011-03-28 : 10:22:39
Try making the result a float, instead of an integer, by making the constants floats. ie Use 4100.0 and 60.0
Go to Top of Page

aash
Starting Member

11 Posts

Posted - 2011-03-28 : 10:43:12
:) Thats easy, Thanks a lot
Go to Top of Page
   

- Advertisement -