What is the syntax when including standard Google Sheets functions within the QUERY function?

I would like to reference a cell in a query lookup using the LARGE function in Google Sheets. I have tried variations on the code below without success:

=QUERY(C2:D49,"select C where D = "large(D2:D49,2)"")

This leads me to ask what the rule is for referencing cell values within queries using standard functions.

2 answers

  • answered 2019-09-14 21:07 player0

    the syntax would be:

    =QUERY(C2:D49, "select C where D = "&LARGE(D2:D49, 2), 0)

  • answered 2019-09-14 22:23 TheMaster

    The query string is a plain string. No special rules apply as long as the resulting string is a valid query. Standard rules that apply to strings in spreadsheets apply to query strings too. You're looking for string concatenation in this instance:

    ="Maximum number of players allowed: "&large(D2:D49,1)
    =JOIN(" ", "Maximum number of players allowed:", large(D2:D49,1))