Search code examples
google-sheetsindexinggoogle-query-language

Google Sheets: QUERY to return a single column


I'm using this query to find the most popular entries in a column of my data - how do I limit the query results to just the data entries, without returning the aggregate column:

=QUERY(G2:G14,"select G, count(G) where G is not null group by G order by count(G) DESC label G 'Product'",-1)


Solution

  • try:

    =INDEX(QUERY(G2:G14,
     "select G, count(G) 
      where G is not null
      group by G
      order by count(G) desc 
      label G 'Product'", -1),, 1)