query with calculated fields and join

It seems there is an issue while handling query with calculated fields.

I’ve a query that is calculating a percentage basing upon a quantity value in the first table and a second value as count() from a second table with a join statement.

I need to apply a filter on that calulated field.
Both using having and where statement.

It seems the application, while instantiating, is running a cut off query with * fields and not the list of fields I was choosing.
Doing that both where or having clause fail as the calculated field is not found.

In complex queries the sql parser of scriptcase sometimes looses track. Best option in that case is using a view.