在下面的 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