Attempt to improve Count Query, tested for DB2, SQL Server and Oracle