0

在下面的 Group By 语句中做了什么FirstName+' '+LastName,真的有必要吗?我尝试省略它,它产生了相同的结果。

SELECT FirstName+' '+LastName AS Employee, tblEmployee.EID, SUM(GrossAmount) AS [2011 Gross], SUM(NetAmount) AS [2011 Net], SUM(GrossAmount) - SUM(NetAmount) AS [2011 Taxes & WH]
FROM tblEmployee INNER JOIN tblPaycheck ON tblEmployee.EID=tblPaycheck.EID
WHERE YEAR(PayDate)=2011
GROUP BY tblEmployee.EID, LastName, FirstName, FirstName+' '+LastName
HAVING SUM(NetAmount)>=45000
ORDER BY LastName, FirstName, tblEmployeeA7.EID
4

1 回答 1

2

它将产生相同的结果,因为存在姓氏和名字,如果您删除了姓氏和名字而不是名字 + ' ' + 姓氏,也可以这样说。无论哪种方式,您都会得到相同的结果

Group by 按优先级取列。

于 2013-04-24T15:49:36.447 回答