我的 SQL 语句如下:
SELECT Count(DISTINCT A.LM_PERSON_ID) AS HEAD_COUNT
,A.LM_STATUS
,To_Char(A.LM_STATUS_CHANGE_DT,'YYYY') AS YEAR
,B.LM_COURSE_NAME AS COURSE_NAME
FROM LM_ENRLOLMENT A
,LM_COURSE_TBL B
WHERE A.LM_STATUS='COMP'
AND A.LM_COURSE_ID=B.LM_CI_ID
GROUP BY A.LM_STATUS_CHANGE_DT,LM_STATUS,B.LM_COURSE_NAME
我想显示的示例输出是:
COURSE_NAME 2010 2011 2012
A 4 5 1
B 2 1 1
C 6 0 3
D 1 1 2
但我面临的主要问题LM_STATUS_CHANGE_DT
是动态数据。有没有人可以告诉我如何做到这一点?