我想从 sql server 2088 R2 查询。但它是重复值。
我需要它不是重复值。
代码:
Select es.EmpCode,es.Eff,es.Year,MAX(es.Month)
From SP_EffEmpAnalysis es
Where es.Year = '2012'
Group By es.EmpCode,es.Eff,es.Year
Order By es.EmpCode,MAX(es.Month) desc
输出
EmpCode | Eff | Year | Month
1410013 | 0 | 2012 | 11
1450021 | 0.952700018882751 | 2012 | 8
1460037 | 0.653999984264374 | 2012 | 9
1460037 | 0.809899985790253 | 2012 | 8
1460037 | 0.863600015640259 | 2012 | 7
1460047 | 0.796299993991852 | 2012 | 7
1480013 | 0 | 2012 | 11
1480080 | 0.91839998960495 | 2012 | 12
1480080 | 0.982299983501434 | 2012 | 11
1480080 | 1.08259999752045 | 2012 | 10
1480080 | 0.989700019359589 | 2012 | 9
我需要输出
EmpCode | Eff | Year | Month
1410013 | 0 | 2012 | 11
1450021 | 0.952700018882751 | 2012 | 8
1460037 | 0.653999984264374 | 2012 | 9
1460047 | 0.796299993991852 | 2012 | 7
1480013 | 0 | 2012 | 11
1480080 | 0.91839998960495 | 2012 | 12