SQL Error Missing keyword

I'm getting the following case statement error when trying to execute the code below

java.sql.SQLSyntaxErrorException: ORA-00905: missing keyword



Select

A.C_ALJ_APPEAL_NUM AS "Appeal Number"
,A.C_RECONSIDER_NUM AS "Level 2 Appeal Number"



,Case When DT.C_NAME IS NULL Then W.C_NAME
,Else W.C_NAME ||'  '||'('|| DT.C_NAME ||')' AS "Appeal Status"
,End


, TO_CHAR(coalesce(A.C_COMPLETE_REQUEST_RECVD_DT,A.C_REQUEST_RECV_DT), 'MM-DD-YYYY') as "Dt Comp Rqst Recd"
, ' ' as "Begin Hearing Date"
,TO_CHAR (A.C_DLM_DATE, 'MM-DD-YYYY')  AS "Dec Ltr Mailed"
, ' ' as "New Appeal Number"
,ALJ.C_Team_NAme AS "Adjudicator Login"






From

((T_APL A
inner join T_RF_STATE W on A.C_WORKFLOW_STATE = W.ID)
left outer join  T_ALJ ALJ on  ALJ.ID = A.C_ALJ_TEAM
left outer join T_APPEAL_DECISION_WRITING ADW on A.id = ADW.ID_PARENT)
left outer join T_DECISION_TYPE DT on adw.C_DECISION_TYPE = DT.ID

WHERE

A.C_WORKFLOW_STATE not in (136,140,139,143,137,138,130,144) --Draft RFH, Invalid, Not Promotable, Promote Failed ,Waiting for MAS , Validation in Progress ,Un-Promoted, process in MAS    

order by A.C_ALJ_TEAM

]
shieldscoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
Please try this-

The case statement was not correct.


Select
 A.C_ALJ_APPEAL_NUM AS "Appeal Number"
,A.C_RECONSIDER_NUM AS "Level 2 Appeal Number"
,Case When DT.C_NAME IS NULL Then W.C_NAME Else W.C_NAME ||'  '||'('|| DT.C_NAME ||')' END AS "Appeal Status"
,TO_CHAR(coalesce(A.C_COMPLETE_REQUEST_RECVD_DT,A.C_REQUEST_RECV_DT), 'MM-DD-YYYY') as "Dt Comp Rqst Recd"
,' ' as "Begin Hearing Date"
,TO_CHAR (A.C_DLM_DATE, 'MM-DD-YYYY')  AS "Dec Ltr Mailed"
,' ' as "New Appeal Number"
,ALJ.C_Team_NAme AS "Adjudicator Login"
From 
(
(T_APL A inner join T_RF_STATE W on A.C_WORKFLOW_STATE = W.ID) 
left outer join  T_ALJ ALJ on  ALJ.ID = A.C_ALJ_TEAM
left outer join T_APPEAL_DECISION_WRITING ADW on A.id = ADW.ID_PARENT)
left outer join T_DECISION_TYPE DT on adw.C_DECISION_TYPE = DT.ID
WHERE
A.C_WORKFLOW_STATE not in (136,140,139,143,137,138,130,144) 
order by A.C_ALJ_TEAM 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
You can also user NVL2 rather than CASE for what you are doing, I find it a bit tidier in this context, so:

Case When DT.C_NAME IS NULL Then W.C_NAME Else W.C_NAME ||'  '||'('|| DT.C_NAME ||')' END AS "Appeal Status"

Open in new window

becomes:

NVL2(DT.C_NAME, W.C_NAME||'  '||'('||DT.C_NAME||')', DT.C_NAME) AS "Appeal Status"

Open in new window


»bp
0
shieldscoAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.