[firebird-support] How do you get a summary SUM() from a union of tables

2012-07-02 Thread cornievs
Hi I have 2 (and more) tables with identical structure: Simplified structure and data: CODE VARCHAR(15) QUAN INTEGER Table A Item1, 50 Item1, 40 Item2, 70 Table B Item1, 50 Item2, 100 Item2, 30 I need to get the sum(QUAN) for all the rows in all the tables group by CODE Item1, 140 Item2, 200

RE: [firebird-support] How do you get a summary SUM() from a union of tables

2012-07-02 Thread Svein Erling Tysvær
I have 2 (and more) tables with identical structure: Simplified structure and data: CODE VARCHAR(15) QUAN INTEGER Table A Item1, 50 Item1, 40 Item2, 70 Table B Item1, 50 Item2, 100 Item2, 30 I need to get the sum(QUAN) for all the rows in all the tables group by CODE Item1, 140 Item2, 200 Is

RE: [firebird-support] How do you get a summary SUM() from a union of tables

2012-07-02 Thread Cornie van Schoor
I have 2 (and more) tables with identical structure: Simplified structure and data: CODE VARCHAR(15) QUAN INTEGER Table A Item1, 50 Item1, 40 Item2, 70 Table B Item1, 50 Item2, 100 Item2, 30 I need to get the sum(QUAN) for all the rows in all the tables group by CODE

Re: [firebird-support] How do you get a summary SUM() from a union of tables

2012-07-02 Thread Mark Rotteveel
On 2-7-2012 20:07, Cornie van Schoor wrote: Set thanks for the reply, I just have one problem, the union removes duplicates. So if both tables have Item1, 50 the result is Item1, 50 and not Item1, 100 as I require. Use UNION ALL instead of UNION. Mark -- Mark Rotteveel