Home » SQL & PL/SQL » SQL & PL/SQL » SQL Sub Query Error ORA-00936: missing expression (Oracle 11)
SQL Sub Query Error ORA-00936: missing expression [message #611564] Thu, 03 April 2014 13:05 Go to next message
rlcaputo
Messages: 3
Registered: April 2014
Junior Member
I get ORA-00936 when running this query. I am trying to flag one instance per clt_id of highest res_id number.

SELECT
R.RES_CLT_ID CLT_ID,
R.RES_ID RES_ID,
(select 'YES' from dual
where R.RES_ID = (
select max(lll.res_id)
from DBxxx lll
where
lll.res_clt_id = r.res_clt_id and
lll.DELETED <> 'Y'
)
) FLAG
FROM
DBxxx R
WHERE
R.DELETED <> 'Y' AND
R.RES_STARTDT IS NOT NULL
;


Any ideas???????????????
Re: SQL Sub Query Error ORA-00936: missing expression [message #611567 is a reply to message #611564] Thu, 03 April 2014 13:16 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
welcome to this forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/


SELECT R.res_clt_id                                        CLT_ID, 
       R.res_id                                            RES_ID, 
       (SELECT 'YES' 
        FROM   dual 
        WHERE  R.res_id = (SELECT Max(lll.res_id) 
                           FROM   dbxxx lll 
                           WHERE  lll.res_clt_id = r.res_clt_id 
                                  AND lll.deleted <> 'Y')) FLAG 
FROM   dbxxx R 
WHERE  R.deleted <> 'Y' 
       AND R.res_startdt IS NOT NULL; 

what is SELECT FROM DUAL supposed to do?
Re: SQL Sub Query Error ORA-00936: missing expression [message #611568 is a reply to message #611567] Thu, 03 April 2014 13:19 Go to previous messageGo to next message
rlcaputo
Messages: 3
Registered: April 2014
Junior Member
Just puts a flag in the third field to note the highest res_id. There can be none or many res_id per clt_id.

I should mention this goes thru a dblink to Oracle 7.3.
Re: SQL Sub Query Error ORA-00936: missing expression [message #611569 is a reply to message #611568] Thu, 03 April 2014 13:24 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>SQL Sub Query Error ORA-00936: missing expression (Oracle 11)
I'm confused!
>I should mention this goes thru a dblink to Oracle 7.3.
What exactly is "this"?
I don't see any DBLINK.
V11 Oracle can NOT inter-operate with V7 Oracle directly.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: SQL Sub Query Error ORA-00936: missing expression [message #611571 is a reply to message #611569] Thu, 03 April 2014 13:28 Go to previous message
rlcaputo
Messages: 3
Registered: April 2014
Junior Member
I removed them and replaced them with dbxxx for security. It goes from 11 to 9 to 7.5. I guess this will not work. I was hoping to use features of 11 SQL to query the 7.5 db.

Sorry for confusion.
Previous Topic: Adding subpartitions in template
Next Topic: Process cursor grp
Goto Forum:
  


Current Time: Fri May 10 05:24:43 CDT 2024