Sum problem....

2004-12-08 Thread Mike Morton
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) +

RE: Sum problem....

2004-12-08 Thread Jay Blanchard
[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]

Re: Sum problem....

2004-12-08 Thread Ian Sales
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:

RE: Sum problem....

2004-12-08 Thread Jay Blanchard
[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) +

multitable sum problem

2003-11-07 Thread David Katz
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

Re: multitable sum problem

2003-11-07 Thread Leo
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