title: Executing SQL query in Ruby
body: <p>I have this query in Ruby to fetch some data from the database:</p>
  
  <pre><code>@mastertest = connection.execute("select code_ver, date from mastertest")
  </code></pre>
  
  <p>So now I assume <code>@mastertest</code> is a 2-dimensional array containing all rows and columns</p>
  
  <p>I try this to print everything out:</p>
  
  <pre><code>@mastertest.each do |row|
    puts row[0]
  end
  </code></pre>
  
  <p>And it prints the first column of all rows.</p>
  
  <p>Now I want to find out the unique values from the first column of all rows and count the number of it's occurrence too. I know it can be done through Hash or Array. Can someone help me with this?</p>