title: How can I recreate a SQL statement using NHibernate that has an inner select case?
body: <p>I am trying to recreate something like the following SQL using NHibernate criteria:</p>
  
  <pre><code>select Range, count(*) from (
     select
        case
           when ent.ID between 'A' and 'N' then 'A-M'
           else 'Other'
        end as Range
     from Subject
  ) tbl
  group by tbl.Range
  </code></pre>
  
  <p>I am able to create the inner select as follows:</p>
  
  <pre><code>session.CreateCriteria&lt;Subject&gt;()
     .SetProjection(
        Projections.Conditional(
           Expression.Between("Name", "A", "N"),
           Projections.Constant("A-M"),
           Projections.Constant("Other")))
     .List();
  </code></pre>
  
  <p>However, I can't figure out how to pipe those results into a grouping by row count.</p>