FirstName+' '+LastName
在以下Group By语句中做了什么,是否真的有必要?我尝试省略它,它产生了相同的结果。
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
答案 0 :(得分:2)
它会产生相同的结果,因为姓氏和名字都存在,如果你删除了lastname和firstname而不是firstname +''+ lastname,也可以这样说。无论哪种方式,您都可以得到相同的结果
分组依据优先顺序排列。