[sql]代码库
//表结构
DROP TABLE IF EXISTS `mark`;
CREATE TABLE `mark` (
`subjects` varchar(30) NOT NULL,
`score` mediumint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of mark
-- ----------------------------
INSERT INTO `mark` VALUES ('英语', '56');
INSERT INTO `mark` VALUES ('数学', '65');
INSERT INTO `mark` VALUES ('语文', '75');
//语句用法
SELECT
subjects,
CASE//case后不根条件
WHEN score BETWEEN 80
AND 90 THEN
'优'
WHEN score BETWEEN 60
AND 79 THEN
'良'
ELSE
'差'
END as num
FROM
jy510_mark
by: 发表于:2017-09-22 09:44:42 顶(0) | 踩(0) 回复
??
回复评论