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 |
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-15 : 14:27:40
|
I have the following query:SELECT DISTINCT [ScratchPad5].EmployeeNumber, SUM( case when [sumhours]>40 THEN 40 ELSE [sumhours] END ) AS TotalRegHours, SUM( case when [sumhours]>40 THEN [sumhours]-40 ELSE 0 END ) AS TotalOT into scratchpad7FROM ScratchPad5GROUP BY [ScratchPad5].EmployeeNumber, sumhoursorder by employeenumber ascand when I run that query it produces a result which looks like this: 8474 21.385166 0.000and what I'd like to do is just my result be to two decimal places, rounded up to the nearest minute (if possible) ... can someone offer a way to do that? |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-15 : 14:36:25
|
Select EmployeeNumber, cast(TotalRegHours as Numeric(12,2) as TotalRegHours , cast(TotalOT as Numeric(12,2) as TotalOT From scratchpad7 |
|
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-15 : 15:09:11
|
MIK,your response has me confused. Is that From Scratchpad7 supposed to be into? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-16 : 09:20:21
|
quote: Originally posted by dougancil MIK,your response has me confused. Is that From Scratchpad7 supposed to be into?
After running your query you need to use the above code to get the data you wantMadhivananFailing to plan is Planning to fail |
|
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-16 : 11:18:11
|
Madhivanan,Can I add that code to what I already have so that I don't have to run two queries? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-16 : 11:45:20
|
Try thisSELECT DISTINCT [ScratchPad5].EmployeeNumber,SUM( case when [sumhours]>40 THEN 40ELSE cast([sumhours] as numeric(12,2))END ) AS TotalRegHours, SUM( case when [sumhours]>40 THEN cast([sumhours]-40 as numeric(12,2))ELSE 0 END ) AS TotalOT into scratchpad7FROM ScratchPad5GROUP BY [ScratchPad5].EmployeeNumber, sumhoursorder by employeenumber ascMadhivananFailing to plan is Planning to fail |
|
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-16 : 15:47:02
|
Madhivanan,Thank you. That does the trick. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-18 : 09:56:15
|
quote: Originally posted by dougancil Madhivanan,Thank you. That does the trick.
You are welcome MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|