removing subquery, making more readable

See: https://github.com/owncloud/core/pull/6016#issuecomment-29510979