如何使用QUERY函数仅返回列表中的最新条目?

问题描述 投票:1回答:1

我想返回一个过滤的产品列表,只显示列表中每个产品的最新条目(意味着选择每个产品的MAX日期行)。

我已经使用select子句中的MAX(日期)设置了QUERY函数,但问题是它显示了所有值(即不显示最新的条目)。

我设置的查询是:

=QUERY('SKU list'!A:C,"select max(A),B,C where A is not null group by B,C")

A sheet with sample data and query is here

实际结果是查询返回旧行和新行,我希望查询只返回每个产品的最新行。

google-sheets google-sheets-formula
1个回答
0
投票
={"max Date entered", "SKU", "MSRP"; 
 QUERY(ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B4:B), QUERY({A4:C},
 "select Col2,Col1,Col3 
  where Col1 is not null 
  order by Col2, Col1 desc", 0), {2,1,3}, 0))),
 "where Col1 is not null 
  order by Col2 
  format Col1 'dd/mm/yyyy'")}

0

© www.soinside.com 2019 - 2024. All rights reserved.