We should use view object and related view criteria or bind variable to get any values from the database. Even though it is not recommended in many reasons, you still could try this way if the query is simple and trying to get a single value from the query.
In your application module implementation file, you could use getDBTransaction().createStatement() method to execute a sql query at run time.
Note there are three SQL statement types available in the DBTransaction interface: statement, callableStatement and preparedStatement.
Here is the snippet of coding in your application module file: