In case you need the number of the results, do not select data but select only count(xxx) expression. This is true for every place. That will have one integer (or long, do not remember) and that can be checked.