Oracle LISTAGG

29 views
Skip to first unread message

Filipe Sousa

unread,
Apr 13, 2016, 7:09:11 AM4/13/16
to Querydsl
Hi,

I'm trying to implement this query using querydsl sql 4.1.0 with oracle database

SELECT
bce.BOLETIM_CTESP_ID, listagg(e.ABREVIATURA, '/') WITHIN GROUP (ORDER BY e.COD_ESCOLA DESC) escolas
FROM BOLETIM_CTESP_ESCOLA bce
JOIN IPB_ESCOLAS e ON bce.COD_ESCOLA = e.COD_ESCOLA
WHERE bce.BOLETIM_CTESP_ID = 568
GROUP BY bce.BOLETIM_CTESP_ID;

What I'm missing is the DESC order

QBoletimCtespEscola bce = QBoletimCtespEscola.boletimCtespEscola;
QIpbEscolas e = QIpbEscolas.ipbEscolas;
WithinGroup<Object>.OrderBy escolas = SQLExpressions.listagg(e.abreviatura, "/").withinGroup().orderBy(e.codEscola);

List<Tuple> fetch = queryFactory.select(bce.boletimCtespId, escolas)
.from(bce)
.join(e).on(bce.codEscola.eq(e.codEscola))
.where(bce.boletimCtespId.eq(568))
.groupBy(bce.boletimCtespId)
.fetch();

Using .orderBy(e.codEscola.desc()) gives me a sintax error

Thanks.

timowest

unread,
Apr 13, 2016, 3:20:31 PM4/13/16
to Querydsl
Hi.

Could you create an issue for this on GitHub?

Timo

Filipe Sousa

unread,
Apr 13, 2016, 4:28:15 PM4/13/16
to Querydsl
Reply all
Reply to author
Forward
0 new messages