各单位计算机数量的统计
declare   @dw   nvarchar(50) 
 select   distinct   @dw=department   from   computers 
 select   @dw   as   单位,count(*)   as   计算机(台)   from   computers   where   department=@dw   
 应该如何写循环呢?谢谢。
------解决方案--------------------select department as 单位,count(*) as [计算机(台)] from computers group by department
------解决方案--------------------select department as 单位,count(*) as 计算机(台) from computers group by department