title: Firebird howto count all record in table and sort max to min
body: <p>My DB Structure</p>
  
  <pre><code>Table_1
  Customer    |
  cust_a
  cust_a
  cust_a
  cust_c
  cust_c
  cust_c
  cust_c
  cust_b
  cust_d
  cust_d
  cust_e
  cust_e
  cust_e
  </code></pre>
  
  <p>How to get result and sort it like this in firebird.</p>
  
  <pre><code>Table 1
  customer     |    Frequency
  cust_c               4
  cust_a               3
  cust_e               3
  cust_d               2
  cust_b               1
  </code></pre>
  
  <p>Note .. now i use this command it's very slow. and real data is 9800 records</p>
  
  <pre><code>select first 10 skip 0 distinct
      customer, (select count(*) from table_1 pdr
      where pdr.customer = prd.customer)
  from
      table_1 prd
  </code></pre>