更新时间:2022-12-11 21:24:04
我不知道它将有多快,但是我想可以这样解决:
I don't know how fast it will be but I guess it can be solved like this:
SELECT ID, min(ORDER_DATE) AS OD,
IF(COUNT(*)=COUNT(CANCEL_DATE),max(CANCEL_DATE),NULL) AS CD
FROM stats GROUP BY CLIENT
我无法对其进行测试,但是此解决方案背后的想法是count(cancel_date)
应该计算所有非空值条目,并且如果它等于count(*)
,则意味着没有空值,并且它将返回max(cancel_date)
,否则为null.
I couldn't test it but the idea behind this solution is that count(cancel_date)
should count all not null value entries and if it's equal to count(*)
that means that there are no null values and it will return max(cancel_date)
, otherwise null.