Search code examples
sqlarrayssortinggoogle-sheetsgoogle-query-language

How to run nested/subquery in google sheet?


SQl : select id,tod,count from new_temp where (id,count) in (select id,min(count) from new_temp group by id);

i want to run this in google sheet. How i can run this ?

[DatasetResult
Resultset


Solution

  • try:

    =SORTN(SORT(A2:C, 1, 1, 3, 1), 9^9, 2, 1, 1)
    

    enter image description here


    =SORTN(QUERY(A2:C7, 
     "select A,B,min(C) 
      where A is not null 
      group by A,B 
      order by A,min(C) 
      label min(C)''"), 9^9, 2, 1, 1)
    

    enter image description here