Skip to content
Advertisement

how to find the maximum occurence of a string in Oracle SQL developer

i have 2 columns in a table. Data looks like this

The output should give the folio_no along with the flag which occured maximum number of times for that particular folio number.

i tried doing the below but it throws an error

select folio_no, max(count(flag)) from table group by folio_no;

Advertisement

Answer

We can use an aggregation:

Note that I assume should two flags within a given folio number be tied for the max frequency, that you want to report the earlier flag.

Here is a working demo.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement