title: Sum two columns and show the columns which were added in postgres query
body: <p>I have four tables which I have joined and I know I have not joined using the desired way, but for now I am just trying to find a solution to it.</p>
  
  <pre><code>with cte as 
   (select
  pw.noc_id as noc_id ,
  sum(pw.amt) as Collected_AMT
  
  from
  tamsnoc.noc_basic_vw bw,
  tamsnoc.noc_wf_vw nw,
  pymt.noc_pymt_vw pw,
  pymt.noc_available_for_pymt_vw nvp
  where
  pw.noc_id = bw.noc_id
  and nw.object_id = bw.noc_id
  and bw.noc_id = nvp.object_id
  and bw.noc_id =874
  and nvp.total_amt_due::numeric(65,
  2) &gt; 0::numeric
  group by
  pw.noc_id)
   SELECT distinct ct.noc_id,bw.scac_code as SCAC,
  nvp.drn as DRN,
  pw.new_overcharge_amt,
   ct.Collected_AMT,
   pw.check_no,
   to_char(pw.check_date, 'MM/DD/YYYY') as Check_date,
   pw.amt
   FROM tamsnoc.noc_basic_vw bw,
   tamsnoc.noc_wf_vw nw,
   pymt.noc_pymt_vw pw,
   pymt.noc_available_for_pymt_vw nvp,
   cte ct
   WHERE pw.noc_id = bw.noc_id 
   AND nw.object_id = bw.noc_id 
   AND bw.noc_id = nvp.object_id 
   and ct.noc_id=bw.noc_id
   AND nvp.total_amt_due::numeric(65,2) &gt; 0::numeric
  </code></pre>
  
  <p>This is what I get from the output of the above query</p>
  
  <p><a href="https://i.stack.imgur.com/rUUiz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rUUiz.png" alt="enter image description here"></a></p>
  
  <p>But here how I want it </p>
  
  <p><a href="https://i.stack.imgur.com/4z8oR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4z8oR.png" alt="enter image description here"></a></p>
  
  <p>any solutions will be helpful</p>