title: Sum of Money(datatype) in sql
body: <p>How to get the sum of a column of <code>money</code> datatype in SQL Server 2005? </p>
  
  <p>I get an error </p>
  
  <blockquote>
    <p>Operand data type nvarchar is invalid for sum operator.</p>
  </blockquote>
  
  <p>when I use</p>
  
  <pre><code>sum(AmountSold) as Amount
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>Complete query is like this: Not adding group by here because it has over 15 columns listed.</p>
  
  <pre><code>SELECT *,
         COUNT(RepDailyCollection.CommunityID)             AS DaysinTown,
         SUM(CAST(RepDailyCollection.AmountSold AS MONEY)) AS TownValue,
         SUM(RepDailyCollection.Spots)                     AS Spots,
         SUM(RepDailyCollection.AmountCollected)           AS Collected,
         CommuniTee.StartDate                              AS StartDate,
         Community.EndDate                                 AS EndDate,
         Community.IsClosed                                AS TownStatus
  FROM   Community
         INNER JOIN RepDailyCollection
           ON RepDailyCollection.CommunityID = Community.CommunityID
  WHERE  Community.RepID = @RepID  
  </code></pre>
  
  <p>Also, editing with Create table query</p>
  
  <pre><code>CREATE TABLE [dbo].[RepDailyCollection](
  [RepDailyCollectionID] [bigint] IDENTITY(7500,1) NOT NULL,
  [RepDailyInfoID] [bigint] NOT NULL,
  [CommuniTeeID] [int] NULL,
  [AmountSold] [money] NULL,
  [AmountCollected] [money] NULL,
  [Spots] [nvarchar](50) COLLATE Latin1_General_CI_AI NULL,
  [IsCleared] [bit] NOT NULL,
  [PaymentMethod] [nvarchar](50) COLLATE Latin1_General_CI_AI NULL,
  [CheckNumber] [bigint] NULL,
  [Invoice] [nvarchar](50) COLLATE Latin1_General_CI_AI NULL,
  [TypeofCreditCard] [nvarchar](30) COLLATE Latin1_General_CI_AI NULL,
  [OrderID] [int] NULL,
  [NewCompanyName] [nvarchar](100) COLLATE Latin1_General_CI_AI NULL,
  [PaymentDate] [datetime] NULL
  ) ON [PRIMARY]
  </code></pre>