所以根据this website大约2007年,我们不应该使用distinct
作为函数,即不要做像
select distinct(employeeID), salary
from salaryhist
这仍然是真的吗?我很难用查询搞清楚
答案 0 :(得分:3)
DISTINCT是 不 一个功能。它从未(也可能永远不会)
表达式select distinct (employeeID)
不是函数调用。
关键字select
后跟关键字distinct
,后跟列表达式(employeeID)
。
为了使事情更清楚,以下三点是相同的:
select distinct employeeID, (salary)
select distinct (employeeID), (salary)
select distinct employeeID, salary
所有内容都相同,因为employeeID
和(employeeID)
是相同的:对列的引用。
答案 1 :(得分:0)
与查询相比,你必须得到更好的结果,
从employeehist组中选择employeeID,sum(salary)by employeeID