我经常有一些查询,我想在其中按 case 子句进行分组,例如:
SELECT
CASE WHEN FIELD IS NULL |
AND (SOMETHING > 100 OR SOMETHINGELSE < 50) |
AND THATDATE >= add_months(sysdate, -4) | -> Case
THEN 0 ELSE 1 |
END AS dim_1, |
dim_2,
sum(SOMEFIELD_TOTAL) as measure_1
FROM MY_TABLE
GROUP BY
CASE WHEN FIELD IS NULL |
AND (SOMETHING > 100 OR SOMETHINGELSE < 50) |
AND THATDATE >= add_months(sysdate, -4) | -> Same case
THEN 0 ELSE 1 |
END, |
dim_2
有没有办法可以将我为整个案例定义的别名用于group by
, 像, group by dim_1
?
找到了这个解释,我仍然想知道是否有出路。