【问题标题】:Google Sheets select, count, limitGoogle 表格选择、计数、限制
【发布时间】:2019-07-01 10:32:48
【问题描述】:

在 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 |
+-------+----+

【问题讨论】:

  • 出于隐私原因我不能这样做
  • 您要计算其他计数还是其他计数本身?
  • 我想计算被限制子句排除的每个元素

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


【解决方案1】:
={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)))}}

_____________________________________________________________

={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)))}}

【讨论】:

  • 这正是我所需要的,它就像一个魅力。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-08
相关资源
最近更新 更多