If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to split 'grouping sets' query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-03, 14:54
jxf888 jxf888 is offline
Registered User
 
Join Date: Oct 2003
Posts: 15
Cool How to split 'grouping sets' query

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 ))
;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On