假设我有下表:
MemberName | ProjectCode | HoursWorked
John Smith | ABC, Inc. | 5
John Smith | Intel, Inc. | 3
Mike Jones | Sesame St. | 10
这是我用来得到它的声明:
SELECT MemberName, ProjectCode, SUM(HoursWorked)
FROM table
GROUP BY MemberName, ProjectCode
ORDER BY MemberName
如果添加了一个附加列,将特定成员的所有项目代码和工作时间连接到一个列中,我如何能够产生以下结果?
MemberName | HoursWorked | Details
John Smith | 8 | ABC, Inc.-5, Intel, Inc.-3
Mike Jones | 10 | Sesame St.-10