title: Max Date Based on Different Input Parameters
body: <p>Can anyone let me know what I'm missing here?</p>
  
  <pre><code>SELECT    fld1,   fld2,    fld3, 
  MAX(DATE)    OVER     (PARTITION    BY    fld1,    fld2,    fld3)
  FROM table1 where fld1 = userinput1 and Fld2 = userinput2 and Fld3 = userinput3
  </code></pre>
  
  <p>When the user enters userinput1, userinput2 and userinput3, I want the max date based on that combination.<br>
  When the user enters only userinput1 and userinput3, I want the max date based on that combination: userinput1, userinput2.<br>
  When the user enters only userinput3, I want the max date based on that unerinput3.</p>
  
  <p>In fact it can be any combination </p>
  
  <pre><code>Table1  has
  
  Fld1    fld2   fld3   date
  
  1         a     A      01/01/2014
  1         a     A      01/02/2014
  1         a     B      01/03/2014
  1         b     C      01/04/2014
  1         b     C      01/05/2014
  1         c     D      01/06/2014
  2         a     A      01/07/2014
  
  
  userinput1  = 1
  unerinput2  = a
  userinput3  = A
  
  Max Date should be  01/02/2014
  
  
  userinput1  = 1
  unerinput2  = a
  userinput3  = user doesn’t enter anything
  
  Max Date should be 01/03/2014
  
  
  userinput1  = 1
  unerinput2  = user doesn’t enter anything
  userinput3  = user doesn’t enter anything
  
  Max Date should be 01/06/2014
  
  
  
  userinput1  = user doesn’t enter anything
  unerinput2  = user doesn’t enter anything
  userinput3  = user doesn’t enter anything
  
  
  Max Date should be  01/07/2014
  </code></pre>
  
  <p>Thanks in advance
  Ram</p>