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.
Author |
Topic |
hbadministrator
Posting Yak Master
120 Posts |
Posted - 2014-02-14 : 11:07:02
|
I have 3 lines of code that work but it is showing us as multiple decimal places out. I need it to stop after 2. Code 1dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100 * dbo.job.[sched-value] AS EarnedCode 2 (dbo.job.[sched-value] - dbo.HB_JL_JobCost.EstimateCost) / dbo.job.[sched-value] * 100 AS GPperCode 3dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100 AS PerComCode 3dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100 AS PerCom |
|
hbadministrator
Posting Yak Master
120 Posts |
Posted - 2014-02-14 : 11:48:05
|
Got my answersCAST(ROUND((dbo.job.[sched-value] - dbo.HB_JL_JobCost.EstimateCost)/ dbo.job.[sched-value] * 100, 2) AS Numeric(16, 2)) AS GPperCAST(ROUND(dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100, 2) AS Numeric(16,2)) AS PerComCAST(ROUND(dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100, 2) * dbo.job.[sched-value] AS Numeric(16, 2)) AS Earned |
|
|
hbadministrator
Posting Yak Master
120 Posts |
Posted - 2014-02-14 : 11:54:58
|
how can I fix this. I am getting a divide by 0CAST(ROUND(dbo.HB_JL_JobCost.TotalTD / dbo.HB_JL_JobCost.EstimateCost * 100, 2) * dbo.job.[sched-value] AS Numeric(16 , 2)) AS Earned |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2014-02-17 : 10:46:28
|
Select dividend / nullif(divisor, 0) ... Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881 |
|
|
|
|
|