title: SAP HANA -count(*) giving different outputs
body: <p>We are using SAP HANA 1.0 SPS12.</p>
  
  <p>When I run below query-</p>
  
  <pre><code>select count(*)
    from ( SELECT A.MATNR ARTICLE,
                  A.WERKS SITE, 
                  ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.DMBTR) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.DMBTR) END),0)))) DUMP_VALUE, 
                  ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.MENGE) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.MENGE) END),0)))) DUMP_QTY                   
             FROM MSEG A 
                  INNER JOIN S_SITE_MASTER B ON A.WERKS=B.STORE_NO         
                  INNER JOIN S_PRODUCT_MASTER C ON A.MATNR=C.MATERIAL                
            WHERE A.BUDAT_MKPF &gt;= ADD_MONTHS(NEXT_DAY(LAST_DAY(ADD_DAYS(CURRENT_DATE,-1))),-1)
              AND A.BUDAT_MKPF &lt;= ADD_DAYS(CURRENT_DATE,-1)                       
              AND A.BWART IN ('551','552','951','952')                                       
              AND C.LEVEL2 = 10                                                
              AND B.FORMAT_CD IN ('1')      
         GROUP BY A.MATNR,
                  A.WERKS
         );
  </code></pre>
  
  <p>Output count is - 129790</p>
  
  <p>IF i just change clause <code>AND B.FORMAT_CD IN ('1')</code> to <code>AND B.FORMAT_CD IN (1)</code>, like below -</p>
  
  <pre><code>select count(*)
    from (SELECT A.MATNR ARTICLE,
                 A.WERKS SITE, 
                 ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.DMBTR) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.DMBTR) END),0)))) DUMP_VALUE, 
                 ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.MENGE) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.MENGE) END),0)))) DUMP_QTY                   
            FROM MSEG A 
                 INNER JOIN S_SITE_MASTER B ON A.WERKS=B.STORE_NO         
                 INNER JOIN S_PRODUCT_MASTER C ON A.MATNR=C.MATERIAL                
           WHERE A.BUDAT_MKPF &gt;= ADD_MONTHS(NEXT_DAY(LAST_DAY(ADD_DAYS(CURRENT_DATE,-1))),-1)
             AND A.BUDAT_MKPF &lt;= ADD_DAYS(CURRENT_DATE,-1)                       
             AND A.BWART IN ('551','552','951','952')                                       
             AND C.LEVEL2 = 10                                                
             AND B.FORMAT_CD IN (1)      
        GROUP BY A.MATNR,
                 A.WERKS
         );
  </code></pre>
  
  <p>Ouput count - 29403 (which is correct count)</p>
  
  <p>Datatype of B.FORMAT_CD is NVARCHAR(3).</p>
  
  <p>How does count behave differently?</p>