I have the following two tables:

salesinvoices            lysalesinvoices
  salesrepid                salesrepid  
  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.  
select salesrepid, sum(invamt) as curramt, sum(lyinvamt) as lyamt from 
salesinvoices,lysalesinvoices group by salesrepid order by curramt;

+----------------+-----------------+------------------+
| salesrepid | curramt        | lyamt          |
+---------------+-------------------+-----------------+
| 101           | 3434464.00  | 4286744.00 |
| 102           | 3507312.00  | 4286744.00 |
+---------------+-------------------+------------------+

I've attached the individual file records below.

Any help would be appreciated.

Thanks
David.


mysql> select salesrepid, invamt from salesinvoices;
+------------+----------+
| salesrepid | invamt   |
+------------+----------+
| 101        | 25230.00 |
| 101        | 34332.00 |
| 101        | 24564.00 |
| 101        | 15155.00 |
| 101        | 43243.00 |
| 101        | 34352.00 |
| 101        | 24352.00 |
| 101        | 13426.00 |
| 102        | 26330.00 |
| 102        | 36433.00 |
| 102        | 25436.00 |
| 102        | 16335.00 |
| 102        | 43543.00 |
| 102        | 34456.00 |
| 102        | 23422.00 |
| 102        | 13252.00 |
+------------+----------+

mysql> select lysalesrepid, lyinvamt from lysalesinvoices;
+--------------+----------+
| lysalesrepid | lyinvamt |
+--------------+----------+
| 101          | 25230.00 |
| 101          | 34332.00 |
| 101          | 24564.00 |
| 101          | 15155.00 |
| 101          | 32650.00 |
| 101          | 43224.00 |
| 101          | 43623.00 |
| 101          | 45633.00 |
| 102          | 23330.00 |
| 102          | 34653.00 |
| 102          | 23264.00 |
| 102          | 26435.00 |
| 102          | 43550.00 |
| 102          | 32524.00 |
| 102          | 32353.00 |
| 102          | 55323.00 |
+--------------+----------+

Reply via email to