title: SQL in Oracle Group by NULL returns multiple rows
body: <p>I have a sql statement which is trying to retrieve the rows having a count greater than 1 for all the similar rows. In all those rows, one field appears to be holding null value.</p>
  
  <p>Case 1 :</p>
  
  <p>Let's say the table name is ABC</p>
  
  <hr>
  
  <p>BUSINESS_UNIT,    INVOICE,        FLAG</p>
  
  <p>A                  1          (Null)</p>
  
  <p>A                  1          (Null)</p>
  
  <hr>
  
  <p>SQL Statement :  SELECT BUSINESS_UNIT, INVOICE, FLAG from TABLE ABC group by BUSINESS_UNIT, INVOICE, FLAG having COUNT(*) > 1</p>
  
  <p>I am expecting it to return no rows as both the flags are basically blank. But it returns the</p>
  
  <hr>
  
  <p>BUSINESS_UNIT, INVOICE, FLAG</p>
  
  <p>A             1     (Null)</p>
  
  <hr>
  
  <p>Case 2 :</p>
  
  <p>TABLE ABC</p>
  
  <hr>
  
  <p>BUSINESS_UNIT, INVOICE,    FLAG</p>
  
  <p>A           1          (Null)</p>
  
  <p>A           1          (Null)</p>
  
  <p>B           1            1</p>
  
  <p>B           1          (Null)</p>
  
  <hr>
  
  <p>SQL Statement : SELECT BUSINESS_UNIT, INVOICE, FLAG from TABLE ABC group by BUSINESS_UNIT, INVOICE, FLAG having COUNT(*) >1</p>
  
  <p>I am expecting the result to be</p>
  
  <hr>
  
  <p>BUSINESS_UNIT, INVOICE, FLAG</p>
  
  <p>B            1         1</p>
  
  <hr>
  
  <p>This is for Oracle 11g. Can someone please help on this and let me know if we can use any of the delivered functions in Oracle?</p>
  
  <hr>
  
  <p>After editing the original sql statements.</p>
  
  <p>I should actually have removed flag from the Group by and select and added to the count in order to identify multiple flags for similar rows.</p>
  
  <hr>
  
  <p>Thanks!</p>