Assume that some of the dates are null
For completeness, I'm also assuming there may be zero rows
I'm using this test data:
create table t as
select to_date('20110101', 'YYYYMMDD')+level-1 as d from dual connect by level<=5
union all select null from dual;
select * from t;
D
-------------------------
01-JAN-11 00.00.00
02-JAN-11 00.00.00
03-JAN-11 00.00.00
04-JAN-11 00.00.00
05-JAN-11 00.00.00
(null)
and considering the following cases:
some rows but no null values:
select min(d) from t where d is not null;
MIN(D)
-------------------------
01-JAN-11 00.00.00
some rows and both null and non-null values:
select min(d) from t;
MIN(D)
-------------------------
01-JAN-11 00.00.00
some rows and all values are null:
select min(d) from t where d is null;
MIN(D)
-------------------------
(null)
no rows:
select min(d) from t where 1=2;
MIN(D)
-------------------------
(null)
an interesting edge case with group by that returns no rows:
select min(d) from t where 1=2 group by 1;
MIN(D)
-------------------------
aside: I've haven't used date as an alias because Oracle complains (not unreasonably IMO):
select to_date('20110101', 'YYYYMMDD') as date from dual;
ORA-00923: FROM keyword not found where expected