title: SQL query returns multiple rows
body: <p>I wrote a SQL query to return a values from column if product type of one contract more than 1. </p>
  
  <p>When I use this query to my main query I get this error:</p>
  
  <blockquote>
    <p>Single row subquery returns more than one row </p>
  </blockquote>
  
  <p>When I use <code>rownum = 1</code>, then no rows are returned.</p>
  
  <p>I need to return the type of the contract</p>
  
  <pre><code>(SELECT
       MAX(TYPE) AS TYPE,
       CONT_NO
   FROM 
       (SELECT    
            MO.CONT_NO, 
            MO.TYPE, 
            COUNT (*) C1
        FROM 
            TABLE1.MORG MO 
        GROUP BY    
            MO.CONT_NO, MO.TYPE) DRT1  
   WHERE  
       DRT1.CONT_NO = CONT_NO 
   GROUP BY 
       CONT_NO
   HAVING 
       COUNT (*) = 1 AND SUM (C1) &gt; 1
  ) 
  </code></pre>