日期:2014-05-17 浏览次数:20550 次
select *,case when (convert(float,成绩)-50)/10<0 then 0 else (convert(float,成绩)-50)/10 end as 绩点 from 成绩表
CREATE TABLE test2
(
XH VARCHAR(20),
CJ NUMERIC
)
INSERT INTO test2
SELECT '1','50' UNION ALL
SELECT '2','60' UNION ALL
SELECT '3','13'
GO
CREATE VIEW vt1 AS SELECT XH "学号",CJ"成绩",(CJ-50)/10 "积点" FROM test2
GO
SELECT * FROM vt1
DROP TABLE test2
GO
DROP VIEW vt1
GO
create table 成绩表
(
学号 varchar(20),
成绩 decimal(10,1),
绩点 as case when isnull(成绩,0)<60 then 0 else ((成绩-50)/10) end
)
insert into 成绩表 (学号,成绩) values ('201201',50)
insert into 成绩表 (学号,成绩) values ('201202',80)
select * from 成绩表