title: How to use DISTINCT in nested personal geodatabse SQL in ArcGIS
body: <p>I have this Statement used in ArcGIS for a personal geodatabse. 
  It selects the top three records in [MyColumn1], but not if the [MyColumn2] equals an inline variable.</p>
  
  <pre><code>[MyColumn1] in(SELECT TOP 3  ( [MyColumn1] ) 
  FROM MyTable
  WHERE [MyColumn2]  &lt;&gt; %Variable%
  ORDER BY [MyColumn1] DESC)
  </code></pre>
  
  <p>But I also need to add a DISTINCT function because some times there are repeated values in [MyColumn1] so that 4 records are selected.</p>
  
  <p>How to include DISTINCT in this expression so that ArcCrash and a personal geodatabase can handle it? There is a lot on this subject, but nothing specific to working Arc or at least access. </p>
  
  <p>This doesn't work</p>
  
  <pre><code>[MyColumn1] in(SELECT TOP 3  ( [MyColumn1] ) 
  FROM MyTable
  WHERE [MyColumn2]  &lt;&gt; %Variable%
  ORDER BY [MyColumn1] DESC 
  DISTINCT [MyColumn1] ) 
  </code></pre>
  
  <p>Nor does this</p>
  
  <pre><code>[MyColumn1] in(SELECT TOP 3  ( [MyColumn1] ) 
  FROM MyTable
  WHERE [MyColumn2]  &lt;&gt; %Variable%
  ORDER BY [MyColumn1] DESC 
  GROUP BY [MyColumn1]) 
  </code></pre>