SQL Server : SUM() of multiple rows including where clauses

后端 未结 6 1605
死守一世寂寞
死守一世寂寞 2020-11-30 02:19

I have a table that looks something like the following :

  PropertyID     Amount     Type       EndDate
 --------------------------------------------
   1           


        
6条回答
  •  半阙折子戏
    2020-11-30 03:14

    Try this:

    SELECT
       PropertyId,
       SUM(Amount) as TOTAL_COSTS
    FROM
       MyTable
    WHERE
       EndDate IS NULL
    GROUP BY
       PropertyId
    

提交回复
热议问题