先赞一个!等你分享啊!作者: danmy 时间: 2009-1-8 17:10
qc自带的分析图可以统计作者: yumaoyu 时间: 2009-1-12 10:15
CREATE proc dbo.yzhao
@name varchar(255)
as
declare @id int
declare @count int
declare @count2 int
declare @temp table( aa int )
select @id =0
select @id = AL_ITEM_ID from td.ALL_LISTS where AL_DESCRIPTION = @name
delete from dbo.bush
insert dbo.bush(aa) values( @id )
select @count = count(*) from dbo.bush
while @count > 0
BEGIN
insert into @temp select AL_ITEM_ID from td.ALL_LISTS where AL_FATHER_ID in ( select aa from dbo.bush )
insert into dbo.bush select aa from @temp where aa not in ( select aa from dbo.bush )
select @count2 = count(*) from dbo.bush
if @count2 = @count
break
set @count = @count2
END
select TS_RESPONSIBLE , sum(TS_STEPS) from td.test where TS_SUBJECT in ( select aa from dbo.bush ) group by TS_RESPONSIBLE
GO