LPS-34888 Fix issue by rewriting non-standard SQL