当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: -_- ......
    摘要: 现在公司同事间技术交流少,平时也不说话,就是没有交流。郁闷,不喜欢这样的环境! ......


求一个sql语句

 
  select   dept,count(dept)    
  from   employee    
  group   by   dept  
  以上语句实现统计各部门人数,但是如果要求统计各部门人数占总人数百分比时如何实现?

NO.1   作者: tyhsys2000

你要先算出总人数才能进行计算,如  
  declare   @cnt   money  
   
  select   @cnt=count(dept)   from   employee  
   
  select   dept,count(dept)   as   bmrs,round(count(dept)/@cnt,2)   as   bfb    
  from   employee  
  group   by   dept  
   
 

NO.2   作者: pumawang

select   dept   ,   round(t1.dcc/t2.tcc,2)   as   bfb  
  from   (     select   dept,count(dept)   dcc    
                  from   employee      
                  group   by   dept  
            )   t1,  
            (select   count(dept)   tcc   from   employee   )   t2  
   
  没有实验,   你看行不行??  
   
 


 ·类型转换问题(二)    »显示摘要«
    摘要: 代码如下: try wldmq.rc_csinvoicerecordq.fieldbyname(csircount).asinteger := strtoint64(trim(trendno.text)) - strtoint64(trim(trbeginno.text))+1 except wldmq.rc_csinvoicerecordq.fieldbyname(csircount)......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE