Greetings,
I would like to modify on one of the working max effective date sqls below or come up with new sql to capture the max effect date <7/1/2012.
Ideally, I would like the sql to grab the max effective date for each year and have it classify year like:
<#7/1/2012# is FY12
>=#7/1/2012# and <=#6/30/2013 is FY13
>=#7/1/2013# and <=#6/30/2014 is FY14
>=#7/1/2014# and <=#6/30/2015 is FY15
SELECT t.CHARTFIELD_VALUE, t.W_CF_ATTRIBUTE, t.W_CF_ATTRIB_VALUE, t.EFFDT, t.EFF_STATUS
FROM (SELECT CHARTFIELD_VALUE, W_CF_ATTRIBUTE, MAX(EFFDT) AS latest FROM SYSADM_PS_X_S_M_CFATTRIB GROUP BY CHARTFIELD_VALUE, W_CF_ATTRIBUTE) AS m INNER JOIN SYSADM_PS_X_S_M_CFATTRIB AS t ON (m.CHARTFIELD_VALUE = t.CHARTFIELD_VALUE) AND (m.W_CF_ATTRIBUTE = t.W_CF_ATTRIBUTE) AND (m.latest = t.EFFDT)
WHERE (((t.W_CF_ATTRIBUTE)="PROG" Or (t.W_CF_ATTRIBUTE)="ACT"))
ORDER BY t.CHARTFIELD_VALUE;
or
SELECT SYSADM_PS_X_S_M_CFATTRIB.CHARTFIELD_VALUE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIB_VALUE, SYSADM_PS_X_S_M_CFATTRIB.EFFDT
FROM SYSADM_PS_X_S_M_CFATTRIB
GROUP BY SYSADM_PS_X_S_M_CFATTRIB.CHARTFIELD_VALUE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIB_VALUE, SYSADM_PS_X_S_M_CFATTRIB.EFFDT
HAVING (((SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE)="PROG") AND ((SYSADM_PS_X_S_M_CFATTRIB.EFFDT)=(Select Max(EFFDT) From [SYSADM_PS_X_S_M_CFATTRIB] M WHERE M.CHARTFIELD_VALUE = [SYSADM_PS_X_S_M_CFATTRIB]![CHARTFIELD_VALUE] )));
I would like to modify on one of the working max effective date sqls below or come up with new sql to capture the max effect date <7/1/2012.
Ideally, I would like the sql to grab the max effective date for each year and have it classify year like:
<#7/1/2012# is FY12
>=#7/1/2012# and <=#6/30/2013 is FY13
>=#7/1/2013# and <=#6/30/2014 is FY14
>=#7/1/2014# and <=#6/30/2015 is FY15
SELECT t.CHARTFIELD_VALUE, t.W_CF_ATTRIBUTE, t.W_CF_ATTRIB_VALUE, t.EFFDT, t.EFF_STATUS
FROM (SELECT CHARTFIELD_VALUE, W_CF_ATTRIBUTE, MAX(EFFDT) AS latest FROM SYSADM_PS_X_S_M_CFATTRIB GROUP BY CHARTFIELD_VALUE, W_CF_ATTRIBUTE) AS m INNER JOIN SYSADM_PS_X_S_M_CFATTRIB AS t ON (m.CHARTFIELD_VALUE = t.CHARTFIELD_VALUE) AND (m.W_CF_ATTRIBUTE = t.W_CF_ATTRIBUTE) AND (m.latest = t.EFFDT)
WHERE (((t.W_CF_ATTRIBUTE)="PROG" Or (t.W_CF_ATTRIBUTE)="ACT"))
ORDER BY t.CHARTFIELD_VALUE;
or
SELECT SYSADM_PS_X_S_M_CFATTRIB.CHARTFIELD_VALUE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIB_VALUE, SYSADM_PS_X_S_M_CFATTRIB.EFFDT
FROM SYSADM_PS_X_S_M_CFATTRIB
GROUP BY SYSADM_PS_X_S_M_CFATTRIB.CHARTFIELD_VALUE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE, SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIB_VALUE, SYSADM_PS_X_S_M_CFATTRIB.EFFDT
HAVING (((SYSADM_PS_X_S_M_CFATTRIB.W_CF_ATTRIBUTE)="PROG") AND ((SYSADM_PS_X_S_M_CFATTRIB.EFFDT)=(Select Max(EFFDT) From [SYSADM_PS_X_S_M_CFATTRIB] M WHERE M.CHARTFIELD_VALUE = [SYSADM_PS_X_S_M_CFATTRIB]![CHARTFIELD_VALUE] )));