title: Postgres DISTINCT to single row
body: <p>how to DISTINCT to single row</p>
  
  <p>here is my code: </p>
  
  <pre>
  
  SELECT 
  wagon.name w_name,
  '' as su_name,
  '' as m_name,
  '' as sk_name,
  '' as p_name,
  '' as b_name,
  '' as o_name,
  total w_total,
  0 as su_total,
  0 as m_total,
  0 as sk_total,
  0 as p_total,
  0 as b_total,
  0 as o_total
  
  FROM wagoning 
  LEFT JOIN wagon ON wagoning.wagon_id = wagon.id 
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  name su_name,
  '' m_name,
  '' sk_name,
  '' p_name,
  '' b_name,
  '' o_name,
  0 w_total,
  total su_total,
  0 m_total,
  0 sk_total,
  0 p_total,
  0 b_total,
  0 o_total
  
  FROM drying 
  LEFT JOIN drier ON drying.drier_id = drier.id 
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  '' su_name,
  quantity::varchar as m_name,
  '' sk_name,
  '' p_name,
  '' b_name,
  '' o_name,
  0 w_total,
  0 su_total,
  total m_total,
  0 sk_total,
  0 p_total,
  0 b_total,
  0 o_total
  
  FROM
  bagging
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  '' su_name,
  '' m_name,
  quantity::varchar as sk_name,
  '' p_name,
  '' b_name,
  '' o_name,
  0 w_total,
  0 su_total,
  0 m_total,
  total sk_total,
  0 p_total,
  0 b_total,
  0 o_total
  
  
  FROM
  storing
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  '' su_name,
  '' m_name,
  '' sk_name,
  quantity::varchar as p_name,
  '' b_name,
  '' o_name,
  0 w_total,
  0 su_total,
  0 m_total,
  0 sk_total,
  total p_total,
  0 b_total,
  0 o_total
  
  FROM
  processing
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  '' su_name,
  '' m_name,
  '' sk_name,
  '' p_name,
  quantity::varchar as b_name,
  '' o_name,
  0 w_total,
  0 su_total,
  0 m_total,
  0 sk_total,
  0 p_total,
  quantity * net b_total,
  0 o_total
  
  FROM
  boxing
  
  UNION ALL
  
  SELECT 
  
  '' w_name,
  '' su_name,
  '' m_name,
  '' sk_name,
  '' p_name,
  '' b_name,
  '' o_name,
  0 w_total,
  0 su_total,
  0 m_total,
  0 sk_total,
  0 p_total,
  0 b_total,
  part o_total
  
  FROM
  boxing
  
  </pre>
  
  <p>Please check the screenshot below: top result (above the red) how it is working now. What I want is below the red line as in single row</p>
  
  <p><a href="https://i.stack.imgur.com/zss2X.jpg" rel="nofollow noreferrer">screenshot</a></p>