独特和平均 [英] Distinct and Average
本文介绍了独特和平均的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要显示为,
员工总数
官员,职员,联系方式
总工时数:官员/总工时数
人员/总工作时间
我的代码为:
选择 count(不同名称) as tot
来自 Staff,时间表其中 Staff.StaffCategoryID = ' span> 1'
它将乘以NoOfPerson * tot
如何进行校正并找出平均值
帮助pl
问候,
Pravin
解决方案
这很简单.您加入表Staff和Timesheet而不说明将两个表合并的内容.
您的查询需要以下内容:
选择 count(不同名称) as tot 来自员工按设置,时间表按设置 其中 s.StaffCategoryID = ' 1' and s.字段名 = t.字段名
>
Hello all,
I need to display as,
Total No of employees
Officer, staff, Contact
total no of working hours:officer/total no of working hrs
staff/total no of working hrs
my code as:
select count(distinct Name) as NoOfPersons,sum(duration) as tot
from Staff,Timesheet where Staff.StaffCategoryID='1'
it will multiply the NoOfPerson * tot
How to make a correction and find out the average for it
Help pl
Regards,
Pravin
解决方案
it is pretty simple. you join the table Staff and Timesheet without stating what combines both tables.
Your query needs something like below:
select count(distinct Name) as NoOfPersons,sum(duration) as tot from Staff as s,Timesheet as t where s.StaffCategoryID='1' and s.fieldname = t.fieldname
这篇关于独特和平均的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文