title: Escaping Null Values From Quartile in SQl Server
body: <p>I have create a table and inserted some records.</p>
  
  <pre><code>CREATE TABLE #t 
     (
     ID INT IDENTITY(1,1) PRIMARY KEY,
     val INT NULL
     );
  
  --   INSERT 10 values: 3 NULL, 7 integers
     INSERT INTO #t SELECT NULL;
     INSERT INTO #t SELECT NULL;
     INSERT INTO #t SELECT NULL;
     INSERT INTO #t SELECT 5;
     INSERT INTO #t SELECT 7;
     INSERT INTO #t SELECT 8;
     INSERT INTO #t SELECT 9;
     INSERT INTO #t SELECT 9;
     INSERT INTO #t SELECT 11;
     INSERT INTO #t SELECT 12;
  </code></pre>
  
  <p>Now when i am executing script to find quartile </p>
  
  <pre><code>SELECT *,
    NTILE(4) OVER (ORDER BY val) As Q
  FROM #t;
  </code></pre>
  
  <p>i am getting values as </p>
  
  <pre><code>ID val Q
  ---------
  1 NULL 1
  2 NULL 1
  3 NULL 1
  4 5 2
  5 7 2
  6 8 2
  7 9 3
  8 9 3
  9 11 4
  10 12 4
  </code></pre>
  
  <p>I don't want "Null" records and don't want to use "Where" clause.
  I want result like this</p>
  
  <pre><code>ID val Q
  ---------
  4 5 1
  5 7 1
  6 8 2
  7 9 2
  8 9 3
  9 11 3
  10 12 4
  </code></pre>