0

I'm trying to add an ORDER by F to the following query, but every time I do it returns a syntax error.

ORIGINAL QUERY (working)

=QUERY(data!A2:Z, "select G, E, F, I, J WHERE A = " & C1, "")

UPDATED QUERY (not working)

=QUERY(data!A2:Z, "select G, E, F, I, J WHERE A = " & C1, " ORDER by F")
  • 1
    @pnuts A is a unique ID# and C1 is a blank cell where the user can type a unique ID#. – Mr. B Sep 22 '17 at 18:12
2

Both your syntax is wrong. Both shouldn't be working and they're not working. You just think that the first one is working.

ORDER by F will not and does NOT cause the parse error.

There should be no , after C1

If C1 is number,

=QUERY(data!A2:Z, "select G, E, F, I, J WHERE A = "&C1&" ORDER by F")

If C1 is text,

 =QUERY(data!A2:Z, "select G, E, F, I, J WHERE A = '"&C1& "' ORDER by F")

OR

 =QUERY(data!A2:Z, "select G, E, F, I, J WHERE A contains ' "&C1& " ' ORDER by F")

Notice the position of &,' and " in different instances.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.