i think you should have a sales person table
that hold unique id for each sales force
such as
salesrep (id,etc..)
| 101 | ... |
| 102 | ... |
so you can alter the query into
select
salesrep.id,
sum(ifnull(salesinvoices.invamt,0)) as curramt,
sum(ifnull(lysalesinvoices.lyinvamt,0)) as lyamt
fro
I have the following two tables:
salesinvoiceslysalesinvoices
salesrepidsalesrepid
invamt lyinvamt
I am trying to get a current year and last year sum for each sales rep. The problem
is it looks like it is resuming each file for each record