日历表
分数表
语句:
SELECT
T1.*,
T2.*,
T3.*,
(
SELECT FS FROM
(SELECT
TO_CHAR( T4.RQ, 'yyyy-mm-dd' ) AS RL,
T4.NAME,
T4.FS,
row_number() over(partition by T4.NAME order by TO_CHAR( T4.RQ, 'yyyy-mm-dd' ) desc) RN
FROM
FS T4
) T5 WHERE RN =1 AND T5.NAME = T2.NAME1
AND T5.RL <= T1.RL1
) AS FS_ZZ
FROM
( SELECT TO_CHAR( RL, 'yyyy-mm-dd' ) AS RL1 FROM "RL" ) T1
LEFT JOIN ( SELECT DISTINCT NAME AS NAME1 FROM FS ) T2 ON 1 = 1
LEFT JOIN FS T3 ON T1.RL1 = TO_CHAR( T3.RQ, 'yyyy-mm-dd' )
AND T2.NAME1 = T3.NAME
ORDER BY
T1.RL1
结果:
多班级可以在这个位置加个班级关联条件