In SQL, is it somehow possible to select an identical value (if existent) of a column which is not listed within the
SELECT a, IDENTICAL_VALUE(b)
GROUP BY a;
You can count the distinct values and just return the
MAX if there's only one.
SELECT a, CASE WHEN COUNT(DISTINCT b) =1 THEN MAX(b) END FROM x GROUP BY a;
Or, alternatively (may be better performing as no need to actually identify the distinct values)
SELECT a, CASE WHEN MAX(b) = MIN(b) THEN MAX(b) END FROM x GROUP BY a;