Hi Everyone:

This is my first post.

I have a complex query and I cannot get large APPLHEAPSZ anymore.

I was told I should split this query. Could you tell me how?

This is the query:

SELECT
COALESCE(PRD_NM, PSG_NM, PG_NM, LOB_NM, 'All Products') AS Product
, (SELECT MONTH_NAME_DA FROM T02510B.DATA_DATE) AS Time
, COALESCE(R.ROLE_NM, R.GROUP_NM, 'All Roles') AS Role
, COALESCE(G.GEO_AREA_NM, G. SUB_REGION_NM, G.REGION_NM, 'All Geo Areas' ) AS Geo_Area
, COALESCE(C.PAYMENT_METHOD_DA, 'All Members') as Pay_Method
, COUNT(DISTINCT PRTY_ID_NO ) AS Customers
FROM T02510B.CustTxnFact F
JOIN
T02510B.Product P
ON P.Product = F.Product
JOIN
T02510B.Geo_Area G
ON G.Geo_Area = F.Geo_Area
JOIN
T02510B.Role R
ON R.Role = F.Role
JOIN
T02510B.CARD_MEMBER C
ON
F.PAYMENT_METHOD = C.PAYMENT_METHOD_ID

GROUP BY
GROUPING SETS ( (), ( G.REGION_NM ), ( G. SUB_REGION_NM ), (G.GEO_AREA_NM) )
, GROUPING SETS ( (), ( LOB_NM ), ( PG_NM ), ( PSG_NM ), ( PRD_NM ) )
, GROUPING SETS ( (), ( R.GROUP_NM ), ( R.ROLE_NM ) )
, GROUPING SETS ( (), ( C.PAYMENT_METHOD_DA ))
;