从同一列中减去两个值

时间:2016-11-29 16:48:02

标签: sql sum inner-join

我想从同一列中减去两个值,如下所示:

SELECT tblTask.CustomerName,
       Sum(Isnull(Cast(Value AS FLOAT), 0)) AS summa
FROM   tblExtraFieldData
       INNER JOIN tblTask
               ON tblExtraFieldData.OwnerId = tblTask.Id
       INNER JOIN tblLog
               ON tblExtraFieldData.OwnerId = tblLog.OwnerId
WHERE  tblLog.Modified BETWEEN '2016-11-25' AND '2016-12-31'
       AND tblExtraFieldData.FieldId = '10052'
       AND tblTask.Status = '5'
       AND tblLog.Text LIKE '%Exporterat%'
       AND tblTask.ProjectNr NOT LIKE 'Fastpris'
GROUP  BY tblTask.CustomerName
ORDER  BY summa 

现在我想用tblExtraFieldData.Value中的值和表tblExtraFieldData

中的FieldId ='10048'来减去它

0 个答案:

没有答案