Desktop productivity for business analysts and programmers

Proc SQL subquery in a left join

Reply
Occasional Contributor
Posts: 8

Proc SQL subquery in a left join

I am trying to use a subquery within a left join and I am getting this error.

 

ERROR: ORACLE prepare error: ORA-00905: missing keyword. SQL statement: select WDM_HSBSB_SUBSC.SBSB_ID as CARD_HLDR_ID_NUM,

WDM_HMEME_MEMBER.MEME_FIRST_NAME || ' ' || WDM_HMEME_MEMBER.MEME_LAST_NAME as PATIENT_NAME, WDM_HMEME_MEMBER.MEME_BIRTH_DT

 

Here is a sample of my code

 

left join

select

   max (HIDCD_SK) as max_HIDCD_SK,

       IDCD_DESC

from WDM_HIDCD_DIAG_CD

where max_HIDCD_SK = HIDCD_SK) as DIAG_DESC

on (WDM_DDIST_DIAG_SET.DDIST_IDCD_AD = DIAG_DESC.max_HIDCD_SK)

 

where

WDM_HSBSB_SUBSC.SBSB_ID in

('XXXXX') 

and WDM_DFNIN_FUNDING_INFO.DFNIN_CLAIM_TYPE <> 'R' /* R = pharmacy */

and WFT_FCDML_CL_LINE.FCDML_RPT_PAID_DT <> WFT_FCDML_CL_LINE.FCDML_PROCESS_DT

and WDM_HCLCL_CLAIM.HCLCL_AS_OF_TO_DT = '31-Dec-9999'

and WDM_DCDBC_CL_LINE_BCN_CODES.DCDCD_DENIAL_IND = 'N'

 

What am I doing wrong?

 

Super User
Posts: 5,827

Re: Proc SQL subquery in a left join

Since you are not sharing the full code, I'm assuming your submitting this in a pass through block (...FROM CONNECTION TO...).

Everything within this block is totally agnostic for SAS, it's the responsibility for the target DBMS (Oracle). So reach out to your fellow Oracle users instead.

Data never sleeps
Occasional Contributor
Posts: 8

Re: Proc SQL subquery in a left join

You are correct I am using a pass through.  I will start searching oracle joins then.

 

Thank you

Super User
Posts: 22,850

Re: Proc SQL subquery in a left join

where max_HIDCD_SK = HIDCD_SK) as DIAG_DESC

on (WDM_DDIST_DIAG_SET.DDIST_IDCD_AD = DIAG_DESC.max_HIDCD_SK)


That first line doesn't look correct, you usually don't alias on WHERE conditions?

Super User
Posts: 3,768

Re: Proc SQL subquery in a left join

Where does your subquery end? I don't see any closing bracket.

Occasional Contributor
Posts: 8

Re: Proc SQL subquery in a left join

It's there.  I just didn't copy and paste it.

Ask a Question
Discussion stats
  • 5 replies
  • 198 views
  • 0 likes
  • 4 in conversation