Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: SQL Case not working in Crystal Post Reply Post New Topic
Author Message
ma12
Newbie
Newbie
Avatar

Joined: 15 Nov 2013
Online Status: Offline
Posts: 3
Quote ma12 Replybullet Topic: SQL Case not working in Crystal
     Posted: 15 Nov 2013 at 9:30am
Hello All,

I have query with case statement that is not working in Crystal report. Could someone please help me with how the query should be in crystal format?

Thanks,

MN



with KPI as
(select * from CMN_LOOKUPS_V where lookup_type in ('SI_KPI_STATUS') and language_code='en')
select pr.PRPROJECTID PRJ_ID,
pr.prname,
pr.prFinish,
pr.prStart,
PR.prcategory,
NVl(odf.si_trk_phase_status,-99) TRK_PHASE_STATUS,
L1.Name TRK_PHASE_STATUS_name,
odf.si_track_phase,
odf.si_trk_dep_status,
odf.si_trk_budet_status,
odf.si_trk_res_status,
odf.si_trk_scope_status,
odf.si_trk_comment,
(case
when pr.prCategory = 'Deployed' then odf.si_org_dep_date
else null
END)org_dt,
(case
when pr.prCategory ='Deployed' then odf.si_cur_dep_date
else null
END)cur_dt
from PRTASK pr
inner join odf_ca_task odf on odf.id = PR.PRid
AND odf.si_status_rpt_flag = 1
left join KPI L1 on L1.lookup_code=odf.si_trk_phase_status
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 15 Nov 2013 at 1:54pm
i dont think its the case statement try


select pr.PRPROJECTID PRJ_ID,
pr.prname,
pr.prFinish,
pr.prStart,
PR.prcategory,
NVl(odf.si_trk_phase_status,-99) TRK_PHASE_STATUS,
L1.Name TRK_PHASE_STATUS_name,
odf.si_track_phase,
odf.si_trk_dep_status,
odf.si_trk_budet_status,
odf.si_trk_res_status,
odf.si_trk_scope_status,
odf.si_trk_comment,
(case
when pr.prCategory = 'Deployed' then odf.si_org_dep_date
else null
END)org_dt,
(case
when pr.prCategory ='Deployed' then odf.si_cur_dep_date
else null
END)cur_dt
from PRTASK pr
inner join odf_ca_task odf on odf.id = PR.PRid
AND odf.si_status_rpt_flag = 1
left join (select * from CMN_LOOKUPS_V where lookup_type in ('SI_KPI_STATUS') and language_code='en') L1 on L1.lookup_code=odf.si_trk_phase_status
IP IP Logged
ma12
Newbie
Newbie
Avatar

Joined: 15 Nov 2013
Online Status: Offline
Posts: 3
Quote ma12 Replybullet Posted: 16 Nov 2013 at 5:56am
Thank you. I tried the query and not getting output for org_dt and cur_dt.

I added the field outside the case statement and the data is coming up. While searching the web couple of places it was mentioned to use the DEFAULT option in the query.

IP IP Logged
ma12
Newbie
Newbie
Avatar

Joined: 15 Nov 2013
Online Status: Offline
Posts: 3
Quote ma12 Replybullet Posted: 16 Nov 2013 at 1:00pm
The issue is resolved. It was a data issue.
Feel like such a dumbo.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum