Google表格选择,计数和限制

时间:2019-07-01 10:32:48

标签: google-sheets count google-sheets-formula google-sheets-query google-query-language

在Google表格文档中,我有一列包含多个值。 我想按计数获取前20个值,然后对其他计数进行分组。

我现在有这个工作代码:

=QUERY(B2:B165,"select B, count(B) group by B order by count(B) desc limit 20 label B 'Pubblication venue'")

这将使我知道一个值出现在该列中的次数,并将结果限制为20。现在,我需要计数其他结果(〜100)。

让我通过示例进行解释。通过我的代码,我可以得到A,B和C的数量。现在我想要其他的数量。

+-------+----+
| A     | 5  |
+-------+----+
| B     | 2  |
+-------+----+
| C     | 4  |
+-------+----+
| Other | 90 |
+-------+----+

1 个答案:

答案 0 :(得分:0)

={QUERY(B2:B165, 
 "select B, count(B) 
  where B is not null
  group by B 
  order by count(B) desc 
  limit 20 
  label B 'Pubblication venue'", 0); 
 {"Other", COUNTA(IFERROR(QUERY(QUERY(B2:B165, 
 "select B, count(B) 
  where B is not null
  group by B 
  order by count(B) desc 
  offset 20
  label count(B)''", 0), 
  "select Col1", 0)))}}

0

_____________________________________________________________

={QUERY(B2:B165, 
 "select B, count(B) 
  where B is not null
  group by B 
  order by count(B) desc 
  limit 20 
  label B 'Pubblication venue'", 0); 
 {"Other", SUM(IFERROR(QUERY(QUERY(B2:B165, 
 "select B, count(B) 
  where B is not null
  group by B 
  order by count(B) desc 
  offset 20
  label count(B)''", 0), 
  "select Col2", 0)))}}

0