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

How to combine two columns and get a total for each?

$
0
0

Hi,

I have the query below:

SELECT 
pehCurHrs AS [Current Hours], 
pehOrgLvl1 AS [Org Level 1],    
pehOrgLvl2 AS [Org Level 2] 
FROM EmpPers JOIN pearhist ph ON ph.pehEEID = eepEEID 
where pehPerControl > '201301011' 
AND pehearncode = '0001'


First I have to combine all six characters of Org Level 2 with the last three characters of Org Level 1. Guessing I would call this new column Org level 3 (?) I have to SUM all of the Current Hours so I have the summed totals in the newly made column Org level 3.

So it's the combing of org2 then org 1, then the sum for each in the org 3 column.

Does that make sense?


qeqw




Viewing all articles
Browse latest Browse all 23857

Trending Articles



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