title: Using DISTINCT, COUNT AND SUBSTRING in a statement
body: <p>I have a <code>id</code> column below</p>
  
  <p><a href="https://i.stack.imgur.com/89FxR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/89FxR.png" alt="id column"></a></p>
  
  <p>I want to <code>count</code> the 3 unique char in the column starting from 3 on the right. So I did this: <code>SELECT SUBSTRING(id,3,3) FROM lhr</code> and I get this result:</p>
  
  <p><a href="https://i.stack.imgur.com/sIcOj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sIcOj.png" alt="enter image description here"></a></p>
  
  <p>Now how do I count the total in the <code>id</code> column such as <code>A00</code> = 7 and <code>A90</code> = 1? I try <code>Count As</code> such as this : <code>SELECT SUBSTRING(id,3,3), COUNT(*) AS 'total' FROM lhr</code></p>
  
  <p>but it did not worked. I don't get the result i wanted. The result I get is <code>total</code> = 8. Help me please and thanks in advance.</p>