Seeking SQL solution

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two existing tables. Following are examples:

table1:

SalesRepID SalesDate NumSales Value1 Value2
101 9/1/04 3 40 60
101 9/2/04 1 20 30
101 9/3/04 5 10 50

table2:

SalesRepID
101 9/1/04 2 15 35
101 9/3/04 6 25 10

I want to take these two tables and produce the following result (that i can
use in a report)

SalesRepID SalesDate NumSales Value1 Value2
101 9/1/04 5 55 95
101 9/2/04 1 20 30
101 9/3/04 11 35 60

Being a novice, i might use a combination of queries, make table and
appends, but i'm sure that there is a more elegant solution. (i'm more
comfortable with SQL, but if VB is the "best" approach then that's ok)
 
jsccorps said:
I have two existing tables. Following are examples:

table1:

SalesRepID SalesDate NumSales Value1 Value2
101 9/1/04 3 40 60
101 9/2/04 1 20 30
101 9/3/04 5 10 50

table2:

SalesRepID
101 9/1/04 2 15 35
101 9/3/04 6 25 10

I want to take these two tables and produce the following result (that i can
use in a report)

SalesRepID SalesDate NumSales Value1 Value2
101 9/1/04 5 55 95
101 9/2/04 1 20 30
101 9/3/04 11 35 60

Being a novice, i might use a combination of queries, make table and
appends, but i'm sure that there is a more elegant solution. (i'm more
comfortable with SQL, but if VB is the "best" approach then that's ok)

1. Why have you got two tables with identical designs? Why aren't all
the records in the same table?
2. You could create a query on each table, then a UNION ALL query to get
just one set of results, and finally an aggregate query on the UNION query
to do the sums.
 
Back
Top