title: SAP DBTech JDBC: [305]: single-row query returns more than one row
body: <p>I have the following query:</p>
  <pre><code>SELECT DISTINCT CASE WHEN FLAG1 = 'FALSE' AND FLAG2 = 'FALSE' THEN '99Z' 
                  ELSE (CASE WHEN FLAG1 = 'FALSE' THEN TGK2 ELSE TGK1 END) END
  FROM 
  (
  SELECT DISTINCT CASE WHEN FLAG1 = 'FALSE' THEN '99Z' ELSE 'X'||CAMPO28||'_'||'Y'||CAMPO29 END AS TGK1,
                  CASE WHEN FLAG2 = 'FALSE' THEN '99Z' ELSE (CASE WHEN CAMPO15 IS NULL THEN '99Z' ELSE CAMPO15 END) END AS TGK2, 
                  FLAG1,FLAG2
  FROM
  (SELECT CASE 
             WHEN CAMPO1 IN (
               SELECT DISTINCT LEFT(COD_CONTO,7) 
                   FROM CONTO_GERARCHIA_ABBI 
                   WHERE COD_CONTO_GERARCHIA = 'H14' 
                     AND (COD_CONTO LIKE '3%' OR COD_CONTO LIKE '4%') 
               UNION ALL
               SELECT DISTINCT LEFT(COD_CONTO,10) 
                   FROM CONTO_GERARCHIA_ABBI 
                   WHERE COD_CONTO_GERARCHIA = 'H14' AND (COD_CONTO LIKE '1%' OR COD_CONTO LIKE '2%'))
             AND CAMPO27 = 'ZZ' THEN CAMPO1 ELSE 'FALSE' END AS FLAG1,
          CASE WHEN CAMPO1 IN (
                      SELECT LEFT(COD_CONTO,7) 
                      FROM CONTO_GERARCHIA_ABBI 
                      WHERE COD_CONTO_GERARCHIA = 'H10' )
                 THEN CAMPO1 ELSE 'FALSE' END AS FLAG2, 
          CAMPO15, CAMPO28, CAMPO29, CAMPO1
       FROM MAP_DATI_ACQUISITI 
       WHERE 1=1 AND COD_MAPPATURA = '100' AND COD_IMPORT = '010' 
  ) 
  GROUP BY FLAG1, FLAG2, CAMPO15, CAMPO28, CAMPO29, CAMPO1  
  )
  </code></pre>
  <p>The issue is that in SAP Hana I get the error [305].</p>
  <p>Do you have any idea what would be the issue?</p>
  <p>Thank you very much!</p>