d**e 发帖数: 6098 | 1 In oracle, say select max,
col1 col2 col3
--------------------
a b 1
a b 2
c d 4
c d
-------------------
group by col1, col2, i want something like a/b will return 2, c/d return
null, since c/d has a null value.
"select col1, col2, max(col3) from table group by col1, col2" doesn't work.
Is ia any way to make the max function return null if there is a null value
in the column?
Thanks! | B*****g 发帖数: 34098 | 2 CASE SUM(CASE WHEN col3 IS NULL THEN 1 ELSE 0 END) WHEN 0 THEN COUNT(*) ELSE
NULL END
.
value
【在 d**e 的大作中提到】 : In oracle, say select max, : col1 col2 col3 : -------------------- : a b 1 : a b 2 : c d 4 : c d : ------------------- : group by col1, col2, i want something like a/b will return 2, c/d return : null, since c/d has a null value.
| d**e 发帖数: 6098 | 3 this is awesome!!!
thank you, Beijing MM!!!
ELSE
【在 B*****g 的大作中提到】 : CASE SUM(CASE WHEN col3 IS NULL THEN 1 ELSE 0 END) WHEN 0 THEN COUNT(*) ELSE : NULL END : : . : value
|
|