How can I avoid using a Union statement here?

Database
Enthusiast

How can I avoid using a Union statement here?

I want two seperate rollups of the data but I do not want to display every rollup.  IE:

Data:

Group1    Group2    Sales

1              2             $100

1              3             $50

1              3             $50

1              1             $50

2              1             $25

1. I want to see all summed values of groups (1,2),(1,3),(2,1)

2. I want to see sum of Group 1 only when it is = 1 or $250

3. I want to see sum of group 2 when it is in (1,2) or $175

4. I do not want to see 2 lines displaying $25 for the group 2 rollup

2 REPLIES
Senior Apprentice

Re: How can I avoid using a Union statement here?

What is the query to create this output?

Are you using ROLLUP?

Then of course you could apply some filter in HAVING like

HAVING (Group1 in (1) or sales = 250) 

Dieter

Enthusiast

Re: How can I avoid using a Union statement here?

the data above is base data.  I do not have a query to return those results yet.  The issue I am having is I am not able to filter on sales because the values will change.  I have tried rollup and grouping set but have not been able to get my results above (1,2,3,4).