日期:2014-05-17 浏览次数:20448 次
create table R
(
name char(4),
match int,
english int,
C# int,
sql int,
java int,
[month] int,
per int
)
insert into R select '1001',82,83,84,90,91,1,1
union all select '1001',82,83,84,90,91,2,1
union all select '1001',82,83,84,90,91,3,1
union all select '1002',66,83,84,90,91,1,1
union all select '1002',82,83,84,90,91,2,1
union all select '1002',90,83,84,90,91,3,1
union all select '1003',66,83,84,90,91,3,1
union all select '1003',82,83,84,90,91,4,2
union all select '1003',90,83,84,90,91,5,2
union all select '1003',90,83,84,90,91,6,2
union all select '1004',82,83,84,90,91,4,2
union all select '1004',90,83,84,90,91,5,2
union all select '1004',90,83,84,90,91,6,2
--每月
select MONTH, sum(match)match,sum(english)english,sum(C#)C#,sum(sql)sql,sum(java)java from R group by month
--每期
select per, sum(match)match,sum(english)english,sum(C#)C#,sum(sql)sql,sum(java)java from R group by per
create table D
(
id int,
del char(1)
)
insert into D values(1,'N')
--触发器
create trigger trigger_delete on D
for update
as
declare @a varchar(20)
select @a=del from D where id=1
if(@a='Y' )
begin
delete from R
end
go
update d set del='Y' where id=1