Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Merging 2 records and summing up to have just 1 record

$
0
0

All,

I have a situation where I need to do a union of 2 data sets. The columns will be the same in both the sets but the data will come from different source tables. So, for example, these are the records in my dataset:

SET-1

Col1  Col2  Col3  Col4  Col5  Col6  Col7
VA      A    NULL  NULL  NULL  5000  500

SET-2

Col1  Col2  Col3  Col4  Col5  Col6  Col7
VA      A    Plan  1000  2000  NULL  NULL

Desired result set:

Col1  Col2  Col3  Col4  Col5  Col6  Col7
VA     A     Plan  1000  2000  5000  500

How can I achieve the desired result set? Right now, I am able to get two records. But I basically want to have just 1 record, with Col4,Col5,Col6,Col7 summed up.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>