SQLite – How to Properly Filter Columns After Applying Aggregate Function

sqlitesyntax

I find that I need to apply an aggregate a lot, but I don't want to show the aggregated value as well. So the best way to do this was to just nest the query to filter it out (like below) but there has to be a better way, how?

select state
from(
    select state, max(cnt)
    from (
        select state, count(*) as cnt
        from customer
        group by state) as t
) as r;

Here I just want to show state without the max value.

Best Answer

I think you can achieve this result without so many subqueries:

Select State
  From Customer
  Group By State
  Order By Count(*) Desc
  Limit 1;