Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql查询错误_Sql - Fatal编程技术网

sql查询错误

sql查询错误,sql,Sql,我想用D函数对结果排序,但我有一个错误 select E.Job_ID, count(*), max(Employee_Salary) as kos, avg(Employee_Salary) from Employee E inner join JOB D on E.Job_ID = D.Job_ID group by E.Job_ID 错误消息中有什么不清楚的地方?您试图按未聚合的内容进行排序。这里有一个解决方案: Msg 8120, Level 16, Sta

我想用D函数对结果排序,但我有一个错误

select E.Job_ID, count(*), max(Employee_Salary) as kos, avg(Employee_Salary)
    from Employee E  
    inner join JOB D on E.Job_ID = D.Job_ID
    group by E.Job_ID

错误消息中有什么不清楚的地方?您试图按未聚合的内容进行排序。这里有一个解决方案:

Msg 8120, Level 16, State 1, Line 1
Column 'JOB.Functio' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
问题是别名作业未知。您需要使用分配给表的d

这应该是可行的,因为每个作业id大概有一个作业。Function。另一个修复方法是将group by更改为:


错误消息中有什么不清楚的地方?您试图按未聚合的内容进行排序。这里有一个解决方案:

Msg 8120, Level 16, State 1, Line 1
Column 'JOB.Functio' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
问题是别名作业未知。您需要使用分配给表的d

这应该是可行的,因为每个作业id大概有一个作业。Function。另一个修复方法是将group by更改为:


如果是描述性列作业函数,是否要将其添加到组中

group by e.Job_ID, d.Job.Functio

否则,在排序中,您需要应用一个聚合函数,如最小值、最大值、平均值等。

您想通过是否为描述性列作业函数将其添加到组中

group by e.Job_ID, d.Job.Functio
否则,在排序中,您需要应用聚合函数,如最小值、最大值、平均值等。

在“选择和分组依据”中包含D.函数

在选择和分组依据中包括D.函数


这是完整的查询吗?这是完整的查询吗?
select E.Job_ID, D.Functio,
     count(*), max(Employee_Salary) as kos, avg(Employee_Salary)
from Employee E  
inner join JOB D on E.Job_ID = D.Job_ID
group by E.Job_ID, D.Functio
order by D.Functio