How to select rows where for a column there are two rows one with null and another with non-null value then select only row with non-null value

oracle

Column A      Column B

117220177     BOOK9488
117220177     NULL
14061         NULL

Oracle query for selecting rows:

When Column B has two rows corresponding to column A then pick row with non-null value in Column B. When there is only one row then pick irrespective of value in Column B

Expected Output:

Column A      Column B

117220177     BOOK9488
14061         NULL

Best Answer

SELECT Column_A, MAX(Column_B) Column_B
FROM test
GROUP BY Column_A;

fiddle