查询以基于多个条件从不同的列中检索值

时间:2019-02-21 13:44:19

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

我需要创建一个QUERY函数以根据以下2个条件从不同的列中检索值:

如果列A中的值为“公司名称已更改”,则我需要列B和C。 并且,如果A列中的值为“电子邮件已更改”,我需要从B,C,D和E列中检索该记录的相应值。 以上所有都在同一个表中。

请原谅我不要共享虚拟工作表,但是我有公司安全限制,这不允许我将任何工作表公开给公司以外的任何人。

“源”标签:

+----------------------+------+-------------+--------------------------+----------------------------+
|           A          |   B  |      C      |             D            |              E             |
+----------------------+------+-------------+--------------------------+----------------------------+
| Status               | ID   | Company     | Email                    | Generic Email              |
+----------------------+------+-------------+--------------------------+----------------------------+
| Email changed        | 223A | ABC Capital | george@abccapital.com    | info@abccapital.com        |
+----------------------+------+-------------+--------------------------+----------------------------+
| In progress          | 446g | DEF Finance | stephan@deffinance.co.uk | enquiries@deffinance.co.uk |
+----------------------+------+-------------+--------------------------+----------------------------+
| Company name changed | 233A | GHI Dealing | michael@ghidealing.ru    | contact@ghidealing.ru      |
+----------------------+------+-------------+--------------------------+----------------------------+
| Dissolved            | 334s | JKL Brokers | john@jklbrokers.au       | help@jklbrokers.au         |
+----------------------+------+-------------+--------------------------+----------------------------+

“输出”标签:

+------+-------------+-----------------------+---------------------+
| ID   | Company     | Email                 | Generic Email       |
+------+-------------+-----------------------+---------------------+
| 223A | ABC Capital | george@abccapital.com | info@abccapital.com |
+------+-------------+-----------------------+---------------------+
| 233A | GHI Dealing |                       |                     |
+------+-------------+-----------------------+---------------------+

可能有什么解决方法?

1 个答案:

答案 0 :(得分:1)

={QUERY(A1:E, "select B, C, D, E 
               where A = 'Email changed'", 1);
  QUERY(A2:E, "select B, C, ' ', '  ' 
               where A = 'Company name changed'
               label ' ''', '  '''", 0)}

0