title: Query to return the distinct first characters for given text column
body: <p>Suppose I have a contacts db - name, phone number, etc. I want to run a query where the result set would be first letters (unique) of the <code>name</code> column in ASC/DESC order. That is suppose my table looked like this:</p>
  
  <pre><code>name                           phone number
  -------------------------------------------
  Alice                          xxx
  Mitch                          xxx
  Eric                           xxx
  Eric                           xxx
  </code></pre>
  
  <p>The result set would have three rows - <code>A</code>, <code>E</code> &amp; <code>M</code>. Then when I need to fetch names beginning with <code>A</code> I would run another query.</p>
  
  <p>A pseudo query might look like:</p>
  
  <pre><code>SELECT DISTINCT 
      firstCharFrom(`name`) AS indexChar 
  FROM 
      'myTable` 
  ORDER BY
      indexChar;
  </code></pre>
  
  <p>I welcome any commentary on the performance of this query against the simple:</p>
  
  <pre><code>SELECT * FROM `myTable` ORDER BY `name`
  </code></pre>
  
  <p>where the client takes cake of grouping the result set into buckets <code>(A, E, M)</code> himself.</p>