I want to build a function that verifies if the resul of this query: SELECT count(q.LOTACAO_MAXIMA)*duracao from quarto q, (select id from TIPO_Quarto where nome=quarto) t w