我在使用Having子句时遇到问题并且在说出错误时出现错误:
群组功能嵌套太深
基本上我试图在WITH子句中使用CASE WHEN,并且在CASE WHEN中有多个CASE WHEN。
Having(SUM(CASE WHEN OUTLET_ACCOUNT_GROUP IN('7-Eleven','99 Speedmart','KK Mart','MyNews.Com')
THEN SUM(NVL(MAVEN_SALES,0))>=0.02
ELSE
SUM(CASE WHEN NVL(TURIN_SALES,0)<0 AND NVL(MAVEN_SALES,0)>0 THEN
CASE WHEN NVL(MAVEN_SALES,0)>(NVL(TURIN_SALES,0)*-1) THEN
NVL(MAVEN_SALES,0)+ NVL(TURIN_SALES,0)
ELSE
0
END
WHEN NVL(MAVEN_SALES,0)<0 THEN 0 ELSE NVL(MAVEN_SALES,0)
END ) >=0.02 )