When I was calling CRM_Core_DAO::executeQuery() it gave error. I don't have any idea what went wrong. Not sure whether the SQL statement was correct or not. After searching for some time I found one function, composeQuery() in CRM_Core_DAO. It can be used to verify SQL query.