I have a Ruby 2D Array, where each array has a row from a SQL query and its columns inside the subarray.
@mastertest = connection.execute("select code_ver from mastertest")
which might contain something like this:
@mastertest = [{"abc"} , {"abc"}, {"pqr"}, {"xyz"}, {"pqr"}, {"pqr"}]
Now, I want to form another 2D array which would give me just the rows which have a unique value of code_ver with their count.
Something like this:
@result = [{"abc", 2} , {"xyz", 1} , {"pqr", 3}]
1 Answer