I have 2 tables to join
Sales
Customer
Sales table has customer id, customer billing id and product/sale price/qty etc info.
Customer table has customer id, customer billing id and buying group info
What I want to do is return sales summary by customer billing info unless the billing account is marked as a buying group - then I want it by customer ID
so something like
Select customer code, customer name, sum(sales)
from sales
left join customer on sales.billing id = customer id unless customer buying group = 1 then make the join sales customer id = customer id
I can't quite get my head around how to do that (it is friday afternoon and it's hot.)