Sql Limit clause based in input Parameter

Viewed 75

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

With myJsonTable (JsonText)
as (
Select JsonText)

Select * from Data
Where...

Limit 
  Case
   WHEN (Select JSON_VALUE(JsonText, '$."Amount"') From myJsonTable is not null
     THEN (Select JSON_VALUE(JsonText, '$."Amount"') From myJsonTable)
     ELSE (10000000)
  END

Which I cant seem to get work. The Output I am getting is

Non-negative integeter value expected in LIMIT clause

Is there a way to cast the select done? Trying different Selects anywhere in the Case clause caused the same error.

1 Answers
Related