注意:添加两个值的SUM与添加值和SUM它提供不同的输出

时间:2016-03-02 11:15:44

标签: sql sql-server tsql

这可能是一个愚蠢的问题。我有一个工作人员function abc($rootScope,$scope, $state, $stateParams, $timeout, Upload, baseURL, $cookieStore, $log, errorCheckFactory) { var columnDefs = [ {headerName: "Make", field: "make"}, {headerName: "Model", field: "model"}, {headerName: "Price", field: "price"} ]; var rowData = [ {make: "Toyota", model: "Celica", price: 35000}, {make: "Ford", model: "Mondeo", price: 32000}, {make: "Porsche", model: "Boxter", price: 72000} ]; $scope.gridOptions2 = { columnDefs: columnDefs, rowData: rowData, enableFilter: true, enableColResize: true, enableSorting: true, groupHeaders: true, rowHeight: 22, //onModelUpdated: onModelUpdated, suppressRowClickSelection: true }; ,存储员工信息。我需要得到每个员工的薪水。所以我尝试了下面的查询

table

但是输错了。然后我尝试如下,

SELECT staffid, SUM(ISNULL(amount,0) +ISNULL(bonus,0)) as amount
from payments
group by staffid

这次我得到了正确的SELECT staffid, SUM(ISNULL(amount,0)) + SUM(ISNULL(bonus,0)) from payments group by staffid 。但我想知道为什么会出现差异。以上两个output操作是否有所不同?有人请对此有所了解。

0 个答案:

没有答案