小疑点mysql count()函数

小问题mysql count()函数

select count(a.num) from a

表a的num字段类型是int,值可能是null或数字

可以让上面的sql语句输出的结果,null的时候为0,数字的时候返回最大值。

最好能在hibernate里面也能通用?谢谢



select max(a.num) from a




select max(case when a.num is null then 0 else a.num) from a

小疑点mysql count()函数

相关文章:

你感兴趣的文章:

标签云: