title: SQL counting elements from two columns
body: <p>I am trying to come up with a query that will allow me to count the values of two columns of the same table. For example</p>
  <pre><code>table: rider_geo_addresses
  ==================================
  |id  | origin_id | destination_id |
  ==================================
   1        4             8
   1        2             6
   1        8             4
   1        6             2
   1        1             5
   1        2             8
  </code></pre>
  <p>i want a query that will give me the count of origin_id and destination_id combined sorted desc</p>
  <pre><code>table: result
  ============================
  | geo_addresses  | counter |
  ============================
         8              3
         2              3
         6              2
         4              2
         5              1
         1              1
  </code></pre>
  <p>i tried to get the values on two separate tables and use <strong>union</strong> to combined them but it doesnt take into account the same values that may appear at both columns.
  This is what i tried</p>
  <pre><code>select ( origin_id) as geo_addresses, count(origin_id) as counter
  from rider_geo_addresses
  where rider_profile_id
  group by  origin_id
  union
  select ( destination_id) as geo_addresses, count(destination_id) as counter
  from rider_geo_addresses
  where rider_profile_id
  group by  destination_id
  order by counter desc;
  </code></pre>