Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 4 of 4 total |
Sum two (or more) queries |
Fri, Feb 5 2021 10:34 AM | Permanent Link |
Jose Eduardo Helminsky HPro Informatica | Hi everyone
I would like to know if there is a way to sum two queries like I tried to describe below: select a, sum(tot) from ( select a, tot from table1 union all select a, tot from table2 ) Any idea ? Regards Eduardo |
Sat, Feb 6 2021 3:35 AM | Permanent Link |
Ian Branch | Hi Jose,
Regards Eduardo |
Sat, Feb 6 2021 3:41 AM | Permanent Link |
Ian Branch | Hi Jose,
I think you are going to need something like this.. Select a, sum(tot) from ( select a, tot from table1 union all select a, tot from table2 ) Tbl group by a Assuming a is the field you want to sum against. If a isn't what you want to group/sum against then.. Select a, grpfield, sum(tot) from ( select a, grpfield, tot from table1 union all select a, grpfield, tot from table2 ) Tbl group by grpfield HTH, Ian |
Sat, Feb 6 2021 7:50 AM | Permanent Link |
Jose Eduardo Helminsky HPro Informatica | Ian
I was close to the solution but I forgot the table reference (tbl) in the outer group by. Thank you very much for your tip. Eduardo |
This web page was last updated on Sunday, May 19, 2024 at 08:46 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |