อัพเดท view_pos_master
This commit is contained in:
parent
b26cbad5ee
commit
8f6637a656
1 changed files with 12 additions and 8 deletions
|
|
@ -78,14 +78,18 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
|||
LEFT JOIN
|
||||
posExecutive ON position.posExecutiveId = posExecutive.id
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM profileDiscipline pd1
|
||||
WHERE pd1.date = (
|
||||
SELECT MAX(pd2.date)
|
||||
FROM profileDiscipline pd2
|
||||
WHERE pd2.profileId = pd1.profileId
|
||||
)
|
||||
) AS profileDiscipline ON profileDiscipline.profileId = profile.id
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
pd.*,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY profileId
|
||||
ORDER BY date DESC, id DESC
|
||||
) AS rn
|
||||
FROM profileDiscipline pd
|
||||
) t
|
||||
WHERE rn = 1
|
||||
) AS profileDiscipline ON profileDiscipline.profileId = profile.id
|
||||
LEFT JOIN (
|
||||
SELECT pl1.*
|
||||
FROM profileLeave pl1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue