Oracle / SQL - Count number of occurrences of values in a single column Oracle / SQL - Count number of occurrences of values in a single column oracle oracle

Oracle / SQL - Count number of occurrences of values in a single column


Use:

  SELECT t.code,         COUNT(*) AS numInstances    FROM YOUR_TABLE tGROUP BY t.code

The output will resemble:

code   numInstances--------------------A      3B      5C      1

If a code exists that has not been used, it will not show up. You'd need to LEFT JOIN to the table containing the list of codes in order to see those that don't have any references.