HQL and JPQL are not the same as SQL. They are far more limited, and don't support everything that's supported in SQL. What you have there is one of those things. But you can use a native query combined with result set mappings to achieve the same thing.