查询语句如下:
SELECT
distinct A.AccountingCode AS memberID,
A.AccountingName AS memberName,
B.Filed1 AS filed1,
B.Filed2 AS filed2,
ER.EmployeeCode as employeeCode,
ER.DepartName as departmentName,
PT.Name as positionName
FROM
Basic.FL_AccountingInfo A WITH(NOLOCK)
LEFT JOIN Basic.FL_AccountingDetail B WITH(NOLOCK)
ON A.AccountingCode = B.AccountingCode
AND A.AccountingCategoryCode = B.AccountingCategoryCode
AND A.SystemCode = B.SystemCode
AND A.AccountCode = B.AccountCode
left join Basic.FL_EmployeeResume ER with(nolock)
on A.accountingCode = ER.employeeCode
left join Basic.FL_Position PT with(nolock)
on ER.PositionCode = PT.Code
where
A.AccountingCategoryCode = 'ZY'
GROUP BY A.AccountingCode,A.AccountingName,B.Filed1,B.Filed2,ER.EmployeeCode,ER.DepartName,PT.Name
我单表查询没有出现重复的结果
但是左连接后查询就出现重复的结果了,很多人说distinct只能去重行中重复的,不能去掉列重复,那怎么去掉重复列呢,求大神们指导一下,谢谢啦!