patternModerate
min(column) with nulls?
Viewed 0 times
minwithnullscolumn
Problem
I am new to databases, but I hope you can help me to understand something.
Take part of this query:
select min(date) as date...
Assume that some of the dates are null. What effect would it have? Would the query break?
Take part of this query:
select min(date) as date...
Assume that some of the dates are null. What effect would it have? Would the query break?
Solution
MIN will return the smallest non-NULL value. The query won't throw an error, it will simply ignore the NULL valuesSQL> with x as (
2 select null dt from dual union all
3 select sysdate from dual
4 )
5 select min(dt)
6 from x;
MIN(DT)
---------
21-OCT-11Code Snippets
SQL> with x as (
2 select null dt from dual union all
3 select sysdate from dual
4 )
5 select min(dt)
6 from x;
MIN(DT)
---------
21-OCT-11Context
StackExchange Database Administrators Q#7080, answer score: 13
Revisions (0)
No revisions yet.