diff --git a/back/methods/campaign/latest.js b/back/methods/campaign/latest.js index a05a18eca..7a4778033 100644 --- a/back/methods/campaign/latest.js +++ b/back/methods/campaign/latest.js @@ -29,10 +29,11 @@ module.exports = Self => { filter = mergeFilters(filter, {where}); const stmt = new ParameterizedSQL( - `SELECT * FROM campaign`); + `SELECT * FROM (`); + stmt.merge('SELECT * FROM campaign'); stmt.merge(conn.makeWhere(filter.where)); + stmt.merge('ORDER BY dated ASC) sub'); stmt.merge('GROUP BY code'); - stmt.merge('ORDER BY dated ASC'); stmt.merge('LIMIT 10000000000000000000'); stmt.merge(conn.makePagination(filter));