If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Query 5% of each other

Hi:

Currently i am doing an application which administers sales of certain products. I am trying to make a report that shows all pairs of salesman whose sales were 5% of each other on every product, any ideas on how to do this??

... all pairs of salesman whose sales were 5% of each other on every product

Try a self-join with these two conditions (equality on product, and "sales1 > 1.05*sales2") as the join condition.
You'll probably also need some kind of "group by" (& having count(*) = 3) if by "every product" you really mean all 3 products.
Try building up the query logic step by step, by using CTEs.

Try a self-join with these two conditions (equality on product, and "sales1 > 1.05*sales2") as the join condition.
You'll probably also need some kind of "group by" (& having count(*) = 3) if by "every product" you really mean all 3 products.
Try building up the query logic step by step, by using CTEs.