Query Builder - How to sort by a column alias (aggregate)

Hi

First of all a happy new year to you all, wishing good health, happiness, and many successful Servoy projects :D

I have the following SQL code and would like to rewrite it as QB Select. But I didn’t find an example, docu or hint on how a QB sort is done by an alias like needed in the following SELECT.

SELECT supplier, MAX(creation_date) as theDate
FROM invoices
GROUP BY supplier
ORDER BY theDate DESC;

The missing piece is how to write the query.sort

var query = datasources.db.<name>.invoices.createSelect();
var i = query.columns;
query.result
	.add(i.supplier)
	.add(i.creation_date.max, 'creationDate');
query.groupBy
	.add(i.supplier);
query.sort
	.add(???);

Best regards,

the docs should be quite clear what you can put in there:

query.sort.add(query.columns.orderid)

or

query.sort.add(query.columns.orderid.desc)

Ah, ok, a column with a method is a valid sort column, like .add(query.columns.creation_date.max.desc)

Regards,