select entity0_.id as id1_5_,
entity0_.REV as REV2_5_,
entity0_.REVTYPE as REVTYPE3_5_,
entity0_.name as name4_5_,
entity0_.description as descript5_5_,
entity0_.reference as referenc6_5_
from schema.entity_AUD entity0_
where entity0_.REV=(select max(entity1_.REV)
from schema.entity_AUD entity1_
where entity1_.REV<=18
and entity0_.id=entity1_.id)
and entity0_.REVTYPE<>2 and entity0_.id=1