0

I have a table with several columns filled with data from different parameters. As some of the rows might share the same column values I'd like to extract the most repeating values for each column so I can get a profile of the most common values for each column.

I am using Oracle Databases technology, so... what's the best way to do it?

Best regards!

Bruno Fernandes
  • 427
  • 2
  • 6
  • 14

1 Answers1

0

Your formulation is very vague but... perhaps this is what you need. Suppose you have a column named col1 in your table named table_t, and you want to get the values that repeat the most times (either the single one with the most repeating value, or if there are ties, show them all).

  with z as (select col1, count(1) as ct from table_t group by col1)
  select col1 from z where ct = (select max(ct) from z)