I would like to group and total some data using a third column as the reference but I don't want that in the output (not in the group by) and am having problems. Here is an oversimplified view of what I need. I would like to total the amount column where the third column is either a value of 001 or 002.
property amount segment
A 5.00 001
B 2.00 001
A 1.00 002
A 3.00 001
B 4.00 003
C 1.00 004
Outcome (only those properties that have a segment of 001 or 002)
I tried something like select sum(case when segment in (select ssegment from table2.....) then amount end) group by property, amount but it says I need the segment in the group by and if I do that then I get totals for both 001 and 002.
I hope this makes sense.
Thank you for any suggestions you may have.