Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to get a grand total for three columns but have been unable to get it to work. When I try group by rollup it adds lots of extra lines and when I try group by grouping set it doesn't seem to work either. What am I doing wrong? Thanks.

SELECT COALESCE(CATEGORY_DESCRIPTION,'TOTAL_DOLLARS') AS CATEGORY_DESCRIPTION
,PY_UNITS
,SUM(PY_COST) AS PY_COST
,PY_MEMBERS

,CUR_UNITS
,SUM(CUR_COST) AS CUR_COST
,CUR_MEMBERS

,PM_UNITS
,SUM(PM_COST) AS PM_COST
,PM_MEMBERS

FROM FINAL
GROUP BY ROLLUP (CATEGORY_DESCRIPTION
,PY_UNITS
,PY_MEMBERS
,CUR_UNITS
,CUR_MEMBERS
,PM_UNITS
,PM_MEMBERS)

Have: enter image description here

Want: enter image description here

question from:https://stackoverflow.com/questions/65601663/group-by-rollup-certain-columns

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
183 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...