From d47429b4a7db95f8d549ac858652288f218dca71 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 17 Jan 2024 10:01:38 +0100 Subject: [PATCH] refs #6667 sql --- modules/worker/back/methods/worker/search.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 7fe9e0666..2cef3543b 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -41,13 +41,15 @@ module.exports = Self => { } const stmt = new ParameterizedSQL(` - SELECT * - FROM( - SELECT DISTINCT w.id, w.code, u.name, u.nickname, u.active, b.departmentFk - FROM worker w - JOIN account.user u ON u.id = w.id - LEFT JOIN business b ON b.workerFk = w.id - ) w`); + SELECT * + FROM( + SELECT w.id, w.code, u.name, u.nickname, u.active, b.departmentFk + FROM worker w + JOIN account.user u ON u.id = w.id + LEFT JOIN business b ON b.workerFk = w.id + ORDER BY b.id DESC + ) w + GROUP BY w.id`); stmt.merge(conn.makeSuffix(filter)); return conn.executeStmt(stmt);