有这样一张表
score1, scroe2, score3
---------------------
NULL NULL 9select score1+scroe2+score3 结果是NULL
要怎么才能让结果为9呢
score1, scroe2, score3
---------------------
NULL NULL 9select score1+scroe2+score3 结果是NULL
要怎么才能让结果为9呢
解决方案 »
- 编写存储过程时出现:Recursive stored functions and triggers are not allowed.
- MySql数据库的自动维护
- MYSQL 生成insert语句
- postgresql如何设置类似MYSQL的自增属性auto_increment??
- 在Postgresql中一条修改信息的语句啊?
- mysql 字符集问题,只能求助如此了。
- 求救:can not connect to mysql server(10061)是怎么回事?
- 关于是否需要分表的问题
- mysql设置某些属性为非null
- mysql-5.7.10-winx64 在配置文件[mysqld]下加入 skip-grant-tables还是出现ERROR1045
- 这个要什么解决啊????
- show tables 如何获取一个表名?
看我的测试select * from test;
select score1+ifnull(score2,0)+ifnull(score3,0) as total from test;
select score1+(case when score2 is null then 0 else score2 end)+(case when score3 is null then 0 else score3 end) as total from test;
结果:query result(7 records)
id score1 score2 score3
1 45 (NULL) (NULL)
2 345 (NULL) 4
3 454 (NULL) 5
4 4545 (NULL) 3
5 2 45 (NULL)
6 23 6 (NULL)
7 43 (NULL) 6
query result(7 records)
total
45
349
459
4548
47
29
49 query result(7 records)
total
45
349
459
4548
47
29
49