P
P
Probus12021-08-09 09:04:29
Google Sheets
Probus1, 2021-08-09 09:04:29

How to combine multiple selects in one Google Query?

Need to find 2 sums in the same column, but with different conditions.
Now it is implemented like this:

Columns A-C are filled through
=QUERY('Sheet6'!A:G;
"Select A, B, sum(F)
Where (C contains 'Fruits' OR C contains 'Fruits')
Group by B, A
LABEL A'', B'', sum(F)''")

A column D
=QUERY('Sheet6'!A:G;
"Select F
Where (B = '"&B2&"')
AND (C contains ' Apples' OR C contains 'Apple')
LABEL F''")

The problem is that the second query needs to be passed through. How to combine these requests:?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-08-15
@oshliaer

Without a Table, it's hard to tell exactly what formula you need, but you can start by concatenating the ranges.

=QUERY({
  QUERY('Лист6'!A:G;
    "Select A, B, sum(F)
    Where (C contains 'Фрукты' OR C contains 'Fruits')
    Group by B, A
    LABEL A'', B'', sum(F)''")
;
  QUERY('Лист6'!A:G;
    "Select F, '', ''
    Where (B = '"&B2&"')
    AND (C contains 'Яблоки' OR C contains 'Apple')
    LABEL F''")
};"select Col1 where Col1<>''";0)

Please note that the formula may not work because I don't see the data you are working with.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question