如下:
1
select b.部门号,b.部门名,count(*) as 职工人数,avg(工资) as 平均工资
from
职工表 as a,部门表 as b
where a.部门号=b.部门号
group by b.部门号,b.部门名
2
delete from 部门表 where 部门号 in (select 部门号 from 职工表 group by 部门号 having count(*)<10)
3
update 职工表 set 部门经理 is null where 年龄>55
4
create view v_职工
as
select 部门号,姓名,年龄,工资 from 职工表
CREATE TABLE dbo.员工工资(
No int NOT NULL IDENTITY (1, 1),
Xm varchar(30) NOT NULL,
Gz decimal(8, 2) NOT NULL,
YwJj decimal(8, 2) NOT NULL,
Sds decimal(8, 2) NOT NULL,
SfGz AS Gz+YwJj-Sds
) ON [PRIMARY]
GO
DECLARE @v sql_variant
SET @v = N'员工工资'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', NULL, NULL
GO
DECLARE @v sql_variant
SET @v = N'编号'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', N'COLUMN', N'No'
GO
DECLARE @v sql_variant
SET @v = N'姓名'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', N'COLUMN', N'Xm'
GO
DECLARE @v sql_variant
SET @v = N'工资'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', N'COLUMN', N'Gz'
GO
DECLARE @v sql_variant
SET @v = N'业务奖金'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', N'COLUMN', N'YwJj'
GO
DECLARE @v sql_variant
SET @v = N'所得税'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'员工工资', N'COLUMN', N'Sds'
GO
ALTER TABLE dbo.员工工资 ADD CONSTRAINT
PK_员工工资 PRIMARY KEY CLUSTERED
(
No
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.员工工资 SET (LOCK_ESCALATION = TABLE)
GO
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)