How to use sum and cast together?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougancil
    Contributor
    • Apr 2010
    • 347

    How to use sum and cast together?

    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 1
    Code:
    select name, employeenumber, sum (ontime) as totalminutes into scratchpad2
    from scratchpad1
    where date between '5/1/2010' and '5/15/2010'
    group by employeenumber, name
    order by employeenumber asc
    Query 2
    Code:
    select totalminutes, (cast (totalminutes as decimal (10,2))) as realtime
    from scratchpad1
    Thank you

    Doug
  • gpl
    New Member
    • Jul 2007
    • 152

    #2
    Try this
    Code:
    select name, employeenumber, (cast (sum (ontime) as decimal (10,2)))      
    from scratchpad1                                                          
    where date between '5/1/2010' and '5/15/2010'                             
    group by employeenumber, name                                             
    order by employeenumber asc

    Comment

    • dougancil
      Contributor
      • Apr 2010
      • 347

      #3
      GPL,

      Thank you. That's what I needed.

      Comment

      Working...