title: Is there an aggregate function that could return first non-null value within a group?
body: <p>I'm using Oracle XE 10g.</p>
  
  <p>Please I beg you to read my question carefully. I have a weird use case for this but please bear with it.</p>
  
  <p>Let's say I have the following records:</p>
  
  <pre><code>Table person
  Name  YearOfBirth
  a     null
  a     2001
  a     2002
  b     1990
  b     null
  c     null
  c     2001
  c     2009
  </code></pre>
  
  <p>Basically if I do the following query:</p>
  
  <pre><code>select
    p.Name, max(p.YearOfBirth)
  from
    person p
  group by
    p.Name
  </code></pre>
  
  <p>That will give me records with distinct Names and each distinct name will be paired to maximum value of YearOfBirth within its group. In the given example the group where Name='a', the maximum YearOfBirth is 2002.</p>
  
  <p>If max() is an aggregate function that returns the maximum value of a column in a given group, is there a function that returns the <strong>first value within the group</strong> that is not null? <strong>Instead of giving me the maximum value, I want the first value you could find as long as it is not null.</strong></p>
  
  <p>Please don't ask me why I can't simply use min() or max() instead.</p>
  
  <p>Obviously I can't use rownum here as some might suggest because doing so will limit the number of groups I could get.</p>