1.由人员计算出总数,在部门树(tree)按结构汇总(主父绑定) CREATE function [dbo].[GetEmpDepNum] ( @ID int ) RETURNS @Tree Table (ID [, ),PID Int,FID Int,SN Varchar(), Name Varchar(), Num Varchar()) as begin declare @MaxNum int,@i int,@f int,@sNnm int Insert @Tree SELECT c1.pi…
sql 树 递归 with SubQuery(No,Name,ParentNo) as ( ' union all select A.No,A.Name,A.ParentNo from [Port_Dept] A inner join SubQuery B on A.No = B.ParentNo ) select * from SubQuery…
--SQL Server2008 程序设计 汇总 GROUP BY ,WITH ROLLUP WITH CUBE GROUPING SET(..) /******************************************************************************** *主题:SQL Server2008 程序设计 汇总 group by ,WITH ROLLUP WITH CUBE *说明:本文是个人学习的一些笔记和个人愚见 * 有很多…