google query, limit, "reference cell"

I'm trying to use a reference cell to inform a Google sheets query limit.

The =QUERY statement I'm trying to use is:

=QUERY(mrclean,"SELECT T,U where V='Unique' 
And W='no match' order by U desc limit 10",1)

where I want to replace the "...limit 10"" with a specific cell reference (e.g., '"&E3"'). Where E3 is used as an input for the Top N values (e.g., Top 10, Top 15, Top 20, etc.)

When I replace "... limit 10" with "...limit '"&E3"'), I get this error:

unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered "where" at line 1, column 62. Was expecting one of: "skipping" ... "limit" ... "offset" ... "label" ... "format" ... "options" ... "," ...

I'm sure this is a simple syntax problem on my part - Any suggestions on 'how' to get the =QUERY to work using a 'cell referenced' value?


Solution 1:

Putting spaces in, you appear to have

limit ' " & E3 " '

which has extra (single?) quotes bad syntax to append the string. I would expect this to work:

=QUERY(mrclean,"SELECT T,U where V='Unique' And W='no match' order by U desc limit " & E3 ,1)