I am trying a SQL query (in Oracle) to get the number of occurrences of all combinations of values in columns V1 and V2. For this I used the query below.
SELECT V1, V2, COUNT(*) AS count
FROM table1
GROUP BY V1, V2
Output:
V1 V2 COUNT
-------------------
X A 4
X B 2
X C 5
X D 1
Y A 8
Y B 2
Y C 8
Y D 6
I now have a list of counts of all combinations of values in V1 and V2. I now want to select only the maximum counts for each value of V1 (if there are ties, show all). The Result should be as follows.
V1 V2 COUNT
-------------------
X C 5
Y A 8
Y C 8