I have 2 tables, identical in fields. One is an 'archived items' table, the
other is a live items.
I want to run a query that will grab the sum of all products in both tables,
like:
The results would display the total qty by item:
QTY NAME
The logic is something like:
sum(table1.qty) +
[snip]
I have 2 tables, identical in fields. One is an 'archived items' table,
the
other is a live items.
[/snip]
Are they also identical in record count?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Mike Morton wrote:
I have 2 tables, identical in fields. One is an 'archived items' table, the
other is a live items.
I want to run a query that will grab the sum of all products in both tables,
like:
The results would display the total qty by item:
QTY NAME
The logic is something like:
[snip]
No, they have different record numbers...
[/snip]
a. Always reply to the list. I just happened to spot this in my spam
folder while cleaning.
2. You're getting Cartesian results, so your query needs to be a little
more specific
Your original query --
select (sum(table1.qty) +
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
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