var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: join two tables and sum same-named variable
I'm joining two tables and need to sum 72 variables that appear in both tables.
Here is an example, as well as the code I've tried (using 3 of the 72 variables).
it looks like you're running SAS, not SQL Server
perhaps you could start a new thread in Applications & Tools - dBforums
It's still SQL code help that I'm looking for. I know I'm running SAS, but Proc Sql uses industry standard SQL code.
in that case, i think you'll need to change the GROUP BY clause to use column names, rather than ordinal positions
Originally Posted by Tracee
also, you need to fix the "ambiguous column" errors
You can use ordinal numbers for ORDER BY, not for GROUP BY.
Based on the required output, you must change the implicit inner join (... FROM A, B WHERE A.id = B.id ...) with a FULL OUTER JOIN (... FROM A FULL OUTER JOIN B ON A.id = B.id ...)
SUM(COALESCE(d.all_1, 0) + COALESCE(f.all_1, 0)) as all_1
Do the same for all_2 and all_3 (and the rest of the 72 variables).
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages