建一个表,里面包含多个约束条件以及标识符

use mysales
drop table if exists dbo.hh
create table hh
(
id int identity,
number char(5) primary key,
name varchar(100),
age tinyint not null,
school char(30) default('浙江理工大学'),
egrade int check(egrade>60),
cgrade int check(cgrade>70)
)
insert into hh(number,name,age,egrade,cgrade) values
('e1235','李红',20,61,88),
('e1222','李华',19,99,78),
('e5555','王明',21,99,75),
('a2626','杨克',18,88,98)
insert into hh(number,name,age,school,egrade,cgrade) values
('w2665','李丽',19,'浙江财经大学',88,79),
('w1512','徐旭',18,'浙江财经大学',78,78)
select *,cast((egrade+cgrade)/2 as decimal) as ave from hh

你可能感兴趣的:(work)