SQL语句 - 计数和百分比 [英] SQL Statement - Count and Percentage
问题描述
Hello All,
我正在使用MS Access 2003和VB 2010.
选择公司,部门,计数(* )部门为CountOfDepartments,百分比为PercentOfDepartments FROM tblCompany Where Company ='Starbucks'
输出结果:
公司 - 部门  -    CountOfDepartments  -   百分比
----------------------------------------- --------------------------------
$
星巴克 - 会计  -    5    -    10%
星巴克 工程  -    10    -    20%
星巴克 送货   -    20    -    40%
星巴克 设计   -    15    -    30%
谢谢,
Amanda Dawn
您是否需要访问查询?
选择公司,部门,计数(*)作为CountOfDepartments,计数(*)* 100.0 /(选择计数(*)<来自InfoTable公司='星巴克'的/ p>
来自IntoTable的[百分比]
其中公司='星巴克'GROUP BY公司,部门
Hello All,
I'm using MS Access 2003 with VB 2010.
Select Company, Departments, Count(*) Departments as CountOfDepartments, Percent as PercentOfDepartments FROM tblCompany Where Company = 'Starbucks'
Output Result:
Company - Departments - CountOfDepartments - Percent
-------------------------------------------------------------------------
Starbucks - Accounting - 5 - 10%
Starbucks - Engineering - 10 - 20%
Starbucks - Shipping - 20 - 40%
Starbucks - Design - 15 - 30%
Thanks,
Amanda Dawn
Do you need an Access query?
select Company, Departments, count(*) as CountOfDepartments, count(*) * 100.0/ (select count(*)
from InfoTable where Company = 'Starbucks') as [Percent]from IntoTable
where Company = 'Starbucks' GROUP BY Company, Departments
这篇关于SQL语句 - 计数和百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!