简体   繁体   English

使用 IF 语句的 Google 表格查询

[英]Google sheets queries with IF statments

I am trying to write this query for a while and have tried a few sites but not explain really how to use the IF statement.我尝试编写此查询已有一段时间,并尝试了几个站点,但并未真正解释如何使用 IF 语句。

So I have data in columns that are people scores for films所以我在列中有数据,这些数据是人们对电影的评分

Jim吉姆 Jack杰克 Fred弗雷德
Film 1电影 1 6 6个 6 6个 2 2个
Film 2电影 2 7 7 8 8个 5 5个
Film 3电影 3 3 3个 5 5个 8 8个
... ...

for example and i want a query that when i select a cell with a name in it it will return the scores for that person (make top ten and scores by film genera / person etc.)例如,我想要一个查询,当我 select 一个有名字的单元格时,它将返回那个人的分数(进入前十名和电影属/人等的分数)

So I have this query I know the syntax is not correct I have tried many ways and cant get it to work.所以我有这个查询我知道语法不正确我已经尝试了很多方法但无法让它工作。 (E18 is the cell I with a pick list of the names) (E18 是带有名称选择列表的单元格 I)

=Query(Sheet1!A4:D,"select A & IF(E18=”Jim”, select B order by B desc Limit 10"")")

What I want to do is when I select a name then it returns the top 10 films for that user + the scores我想要做的是当我 select 一个名字然后它返回该用户的前 10 部电影 + 分数

Any help greatly received.收到任何帮助。

Thankyou谢谢

aaron亚伦

Let assume you will select actor name in F1 cell (as per my attached screenshot).假设您将在F1单元格中输入 select 演员姓名(根据我附上的屏幕截图)。 They try below QUERY() formula.他们尝试使用以下QUERY()公式。

=QUERY(A2:D4,"select A, " & CHAR(MATCH(F1,A1:D1,0)+64) & " order by " & CHAR(MATCH(F1,A1:D1,0)+64) & " desc limit 10")

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM