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 - 2010-11-04 : 13:23:20
|
I'm trying to sum a column as well as round a column up to the nearest minute. Here's 2 queries I'm running, but I'd like to combine them in to one. Can anyone offer any suggestions:Query 1select name, employeenumber, sum (ontime) as totalminutes into scratchpad2from scratchpad1where date between '5/1/2010' and '5/15/2010'group by employeenumber, nameorder by employeenumber ascQuery 2select totalminutes, (cast (totalminutes as decimal (10,2))) as realtimefrom scratchpad1Thank youDoug |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-11-04 : 18:54:00
|
what do you mean by "combine" ? How do you want the result to looks like ?Pls post some sample data and expected result KH[spoiler]Time is always against us[/spoiler] |
|
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2010-11-05 : 11:29:16
|
I want to be able to sum the ontime and round it to the nearest minute. Right now that takes two queries, I'd like to combine it into one query. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-11-06 : 08:24:52
|
[code]select name, employeenumber, cast(sum (ontime) as decimal(10,2)) as totalminutes into scratchpad2from scratchpad1where date between '5/1/2010' and '5/15/2010'group by employeenumber, nameorder by employeenumber asc[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|