title: Sql Limit clause based in input Parameter
body: <p>I have been trying to find a solution for a limit-clause based on an input parameter from a Json-File. The current code looks somewhat like this</p>
  <pre><code>With myJsonTable (JsonText)
  as (
  Select JsonText)
  
  Select * from Data
  Where...
  
  Limit 
    Case
     WHEN (Select JSON_VALUE(JsonText, '$.&quot;Amount&quot;') From myJsonTable is not null
       THEN (Select JSON_VALUE(JsonText, '$.&quot;Amount&quot;') From myJsonTable)
       ELSE (10000000)
    END
  </code></pre>
  <p>Which I cant seem to get work. The Output I am getting is</p>
  <pre><code>Non-negative integeter value expected in LIMIT clause
  </code></pre>
  <p>Is there a way to cast the select done? Trying different Selects anywhere in the Case clause caused the same error.</p>