Fixed bug in case statement when the value depended on a query parameter