Results 1 to 2 of 2

Thread: T-SQL Help

  1. #1
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    144

    Unanswered: T-SQL Help

    Hi,
    When i try to run this query, i can't seem to divide the sum of two grouped data together. It keeps coming up as 0.00. It's ok to add or subtract but not divide. Any help will be appreciated.

    select
    b.TimeActualDate,
    sum(a.totalCalls) as total_calls,
    sum(a.callsanswered) as answered,
    Cast((sum(a.callsanswered)/sum(a.totalCalls)) as decimal(12,2))
    from
    dbo.FactAggCalls a, dbo.DimTime b
    where
    a.TimeID = b.TimeID
    and
    datepart(month,b.TimeActualDate) = '6'
    group by
    b.TimeActualDate

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try

    Cast(sum(a.callsanswered) as decimal(12,2)) / Cast(sum(a.totalCalls) as decimal(12,2))
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •