问题描述
- 查询出最大值如果是空值用0代替 (用的DB2)
-
SELECT MAX(DATE_START) AS effectivestarttime, RULE AS rule, CONDITIONS AS condition FROM MGRSCHEMA.APPROVE WHERE CONDITIONS = '2001' AND RULE = '2001' GROUP BY CONDITIONS, RULE
MAX(DATE_START)查询出的最大值为空 用0代替 请各位大神帮帮忙
解决方案
SELECT
case when MAX(DATE_START)==null then 0 else MAX(DATE_START) AS effectivestarttime end
,RULE AS rule
,CONDITIONS AS condition
FROM
MGRSCHEMA.APPROVE
WHERE
CONDITIONS = '1'
AND RULE = '1'
GROUP BY
CONDITIONS,
RULE
时间: 2024-09-29 08:11:06