Fixed a query which is failing in for "in Memory" DB