title: How get count element in query select with Distinct?
body: <pre><code>SELECT DISTINCT 
             t1.name as t1_name, 
             t1.unit as t1_unit, 
             t1.id_producer_goods AS hi_id_producer_goods, 
            t2.name as t2_name 
  FROM Table1 t1 
      left join Table2 t2 on t1.id_web_site=t2.id_web_site 
  WHERE t1.id='23'
  </code></pre>
  
  <p>How get count <code>t1.name</code> in it query?</p>
  
  <p>I check code:</p>
  
  <pre><code>SELECT DISTINCT 
             t1.name as t1_name,
             count(t1.name) as count,           
             t1.unit as t1_unit, 
             t1.id_producer_goods AS hi_id_producer_goods, 
             t2.name as t2_name 
  FROM Table1 t1 
      left join Table2 t2 on t1.id_web_site=t2.id_web_site 
  WHERE t1.id='23'
  </code></pre>
  
  <p>But it code have error:</p>
  
  <pre><code>Column 'Table1.name' is invalid in the select list because
  it is not contained in either an aggregate function or the GROUP BY clause.
  </code></pre>
  
  <p>I know that i write not aright in line <code>count(t1.name) as count,</code> but how get aright count <code>t1.name</code>?</p>
  
  <p>P.S.: query get results with unique rows <code>t1.name, t1.unit, t1.id_producer_goods, t2.name</code>. Count <code>t1.name</code> should show all count each element <code>t1.name</code>.</p>