create user

This commit is contained in:
kittapath 2025-03-05 12:18:24 +07:00
parent 7b2773f557
commit a7e9f78dae
5 changed files with 105 additions and 61 deletions

View file

@ -56,16 +56,18 @@ import { ViewColumn, ViewEntity } from "typeorm";
commandYear,
remark,
profileId,
@group := IF(@prevPosition = positionName, @group, @group + 1) AS groupedId,
@prevPosition := positionName
LAG(commandDateSign) OVER (ORDER BY commandDateAffect ASC, commandDateSign ASC) AS prevCommandDateSign,
ROW_NUMBER() OVER (ORDER BY commandDateAffect ASC, commandDateSign ASC) -
ROW_NUMBER() OVER (PARTITION BY positionName ORDER BY commandDateAffect ASC, commandDateSign ASC) as groupedId
FROM
profileSalary,
(SELECT @group := 0, @prevPosition := NULL) AS vars
profileSalary
WHERE
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
ORDER BY
commandDateAffect ASC, commandDateSign ASC
) AS groupedPosition
WHERE
prevCommandDateSign IS NULL OR commandDateSign >= prevCommandDateSign
GROUP BY
profileId, groupedId, positionName
)