I don't think that FireBird will help, but with PostgreSQL you can just make your existing SELECT statement a virtual table, so you could use something like:
Code:
SELECT Count(*)
FROM ( -- original SELECT goes here
) AS a
This will count the number of rows returned by the original SELECT statement.
-PatP