employees table 求 ssn 为 '123456789' 的员工的房子与其他员工的房子之间的平均距离。
我已经写了一个代码来解决这个问题,但答案是错误的。有人可以帮我修复我的代码并找到正确的答案吗?
Select avg(abs(hno-hno1)) as AG from (select hno1 from employee where hno = '731') as hno from employee as e) as p;
答案选择是:
一个。 1133.37
1295.28
1133.38
1162.34
最佳答案
sql 如下,输出为 1295.28
select avg(abs(hno-(select hno
from employee
where ssn = '123456789'
)))
from employee
where ssn != '123456789';
关于mysql - 如何修复我的代码以查找选定元素与列中其他元素之间的平均差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54266971/