Sample table
Order field1 field2 field3 Cost
123 Y ABC BCD $2
123 Y ABC ABC $5
Say I have a select statement containing:
case field1
when 'Y' then field2
else field3
end as 'Supplier'
This will result in displaying 'ABC' in the Supplier field correctly.
However, there is a group by statement involved. It wants me to group by both field2 and field3 because they are both in the select statement. But, I would like to group by the result of my case statement. In the example above, I would like:
Order Supplier Cost
123 ABC $7
Does that make any sense?
Order field1 field2 field3 Cost
123 Y ABC BCD $2
123 Y ABC ABC $5
Say I have a select statement containing:
case field1
when 'Y' then field2
else field3
end as 'Supplier'
This will result in displaying 'ABC' in the Supplier field correctly.
However, there is a group by statement involved. It wants me to group by both field2 and field3 because they are both in the select statement. But, I would like to group by the result of my case statement. In the example above, I would like:
Order Supplier Cost
123 ABC $7
Does that make any sense?