Here is my current query:
SELECT c.COLUMN_NAME, t.NUM_ROWS
FROM ALL_TAB_COLUMNS c
INNER JOIN ALL_TABLES t ON t.OWNER = c.OWNER AND t.TABLE_NAME = c.TABLE_NAME
WHERE c.TABLE_NAME='MY_TABLE_NAME'
AND c.OWNER = 'MY_SCHEMA_NAME'
What this does is retrieve both the name of each column in my table along with the number of rows in each column.
What I need to do is retrieve the number of distinct values present in each column and then ultimately determine which column has the maximum number of distinct entries. How would I go about doing that given my current query?
Is there a better way to achieve what I want to do? Is dynamic SQL necessary?