I tried to "search" on this forum, however the "search" function is currently not available.
I'm very new to SQL, so please bear with me. The code below gives this result:
LWIA Participants
00 1
However, if I remove the Having statement, I get LWIA
00 through 13, which is correct but,the number of participants is not correct.
LWIA Participants
00 1
01 500
02 112
03 222
etc. through LWIA 13
I'm using MAX because there could be several occurrences of SPP.ACTV_ACTL_END_DATE for one participant.
In other words, one participant could have several activities associated with him. However, all I need is the latest activity date.
What am I doing wrong. I've read about the Having statement and everything appears to be coded okay.
Why does removing the Having statement give all LWIAs, even though the number of participants is incorrect. I need to refer to only the latest activity date when doing the calculation, so the Having statement is critical.
Code Follows:
select SUBSTR (IPP.CUR_LOC_ID,3,2)"LWIA", Count(Distinct IPP.PARTC_ID) "Participants"
from ecmatsdba.ETR_INT_PARTC_PGM IPP,ecmatsdba.ETR_SDT_PARTC_PGM_ACTV SPP
where SUBSTR (IPP.Cur_Loc_ID, 3,2)is not null
and IPP.Pgm_Actv_Ind = 1
and IPP.AGY_ID = 'LW'
and IPP.partc_id = SPP.partc_id
and IPP.APPLC_ID = SPP.APPLC_ID
and SPP.ACTV_ACTL_END_DTE is not null
Group by SUBSTR (IPP.CUR_LOC_ID,3,2)
-- remove Having and you get all LWIAs
-- but the number of participangts is incorrect.
Having SYSDATE - MAX(SPP.ACTV_ACTL_END_DTE) >90
Order By "LWIA"
TIA for any assistance.
Newbie
I'm very new to SQL, so please bear with me. The code below gives this result:
LWIA Participants
00 1
However, if I remove the Having statement, I get LWIA
00 through 13, which is correct but,the number of participants is not correct.
LWIA Participants
00 1
01 500
02 112
03 222
etc. through LWIA 13
I'm using MAX because there could be several occurrences of SPP.ACTV_ACTL_END_DATE for one participant.
In other words, one participant could have several activities associated with him. However, all I need is the latest activity date.
What am I doing wrong. I've read about the Having statement and everything appears to be coded okay.
Why does removing the Having statement give all LWIAs, even though the number of participants is incorrect. I need to refer to only the latest activity date when doing the calculation, so the Having statement is critical.
Code Follows:
select SUBSTR (IPP.CUR_LOC_ID,3,2)"LWIA", Count(Distinct IPP.PARTC_ID) "Participants"
from ecmatsdba.ETR_INT_PARTC_PGM IPP,ecmatsdba.ETR_SDT_PARTC_PGM_ACTV SPP
where SUBSTR (IPP.Cur_Loc_ID, 3,2)is not null
and IPP.Pgm_Actv_Ind = 1
and IPP.AGY_ID = 'LW'
and IPP.partc_id = SPP.partc_id
and IPP.APPLC_ID = SPP.APPLC_ID
and SPP.ACTV_ACTL_END_DTE is not null
Group by SUBSTR (IPP.CUR_LOC_ID,3,2)
-- remove Having and you get all LWIAs
-- but the number of participangts is incorrect.
Having SYSDATE - MAX(SPP.ACTV_ACTL_END_DTE) >90
Order By "LWIA"
TIA for any assistance.
Newbie