How to count a query result

Here is some Database Manager docs.

You will need an understanding how databases work though.