What's happening is the system is protecting you from SQL Injection by escaping your query. So what you'd need is a parameter to escape this AND a default value.
{% QueryString.ParamName|(default)-1\|(handlesqlinjection)false %}
To break this down a bit:
QueryString.ParamName
This is an alternative to use {%ParamName%}
It allows you to use additional macro syntax in it vs. simply get a URL parameter.
|(default)-1
This is a macro parameter. There are several macro parameters them but this one is setting a default value of -1
if a value isn't provided/found.
\|(handlesqlinjection)false
This is a second macro parameter. Macro parameters are defined by using a |
. BUT when using more than one parameter, you need to escape them by using a backward slash. The second macro parameter is telling the macro engine to NOT escape any special string syntax and expose your query to SQL injection.
Using the {%QueryString%}
macro is OK but you ALWAYS need to make sure you do something with the value so it doesn't harm your site.