Q: Select from Select in QueryDSL I wonder if there is a way to phrase something like 
SELECT `sum(<field>)` FROM (SELECT field from ... WHERE ...)

in QueryDSL(Version 4.x).
Let's say I have an Article "green Balloon" in all my Stores and I need to know how many "green Balloon" I have in total (I know it's a stupid example but it will do ;)).
The SQL could look like:
SELECT count(a.id) 
    FROM (
        SELECT art.id 
        FROM article art
        LEFT JOIN store s ON (art.storeId = s.id)
        WHERE art.name = 'green Balloon'
        GROUP BY s.id
    ) a;

How can I translate said SQL to QueryDSL?
Edit: As it was subject to confusion: Yes, the example is stupid. No I do not want to 'optimize' the SQL. All I need is some QueryDSL-Code generating the exact same (stupid) SQL. Or any other QueryDSL-Code generation any sort of SELECT ... FROM (SELECT ...) for that matter. If that is even possible.
There is a two year old post handling this topic, but apparently it was not possible then. Maybe it is now?

A: Accepting that the OP just want to know if that syntax can be duplicated in QueryDsl - consider the following.
It should be something like:
SQLExpression.select(Expressions.numberPath(Long.class, "ID").count())
             .from(SQLExpressions.select(QArticle.id().as("ID"))
                                 .from(QArticle)
                                 .leftJoin(QStore).on(QStore.id()
                                                 .eq(QArticle.storeId())
                                 .where(QArticle.name()
                                 .eq("green Balloon"))
             .as("SQ")

It might well be possible to simplify this - but it should get you most of the way there.
