Oracle Query Error

Hello,
I have the below query:
WITH DVTB AS
(
	SELECT 'AAP052' as VEND
)
SELECT x.*
FROM (
        SELECT V.CREATED as 'CREATEDDATE',        
              V.value as 'VENDORCODE',     
             V.NAME AS 'VENDOR_NAME,
            CO.DOCUMENTNO AS PO_NUM,
            CO.EM_SC_PROGRAM_CODE AS Program,
           CO.DATEPRINTED AS PO_CREATEDATE,
           u.name  AS BUYER,
			     row_number() over(partition by V.value order by CO.DOCUMENTNO) as rn
  FROM c_bpartner V 
inner join c_order CO  on  co.c_bpartner_id = V.C_BPARTNER_ID
left join ad_user u on co.SALESREP_ID = u.AD_USER_ID
WHERE
 CO.ISSOTRX='N' AND  V.created >= '01-NOV-2014'
 and V.value in (SELECT VEND FROM DVTB)) x
where x.rn = 1
order by x.vendorcode

Open in new window

when I execute this Iam getting an error below.Not sure what is causing it.Please help.
ORA-00923: FROM keyword not found where expected
00923. 00000 -  "FROM keyword not found where expected"
*Cause:    
*Action:
Error at Line: 4 Column: 1

Thanks
Star79Asked:
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.

slightwv (䄆 Netminder) Commented:
In Oracle you need to select FROM something.

Change:
SELECT 'AAP052' as VEND


to:
SELECT 'AAP052' as VEND from dual

You are also missing a single quote here:
    V.NAME AS 'VENDOR_NAME,

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
johnsoneSenior Oracle DBACommented:
Also, column aliases require double quotes, not single quotes.  It should be:

        SELECT V.CREATED as "CREATEDDATE",        
              V.value as "VENDORCODE",    
             V.NAME AS "VENDOR_NAME",
Star79Author Commented:
I tried the below:
WITH DVTB AS
(
	SELECT 'AAP052' as VEND from dual
)
SELECT x.*
FROM (
        SELECT V.CREATED as 'CREATEDDATE',        
              V.value as 'VENDORCODE',     
             V.NAME AS 'VENDOR_NAME',
            CO.DOCUMENTNO AS PO_NUM,
            CO.EM_SC_PROGRAM_CODE AS Program,
           CO.DATEPRINTED AS PO_CREATEDATE,
           u.name  AS BUYER,
			     row_number() over(partition by V.value order by CO.DOCUMENTNO) as rn
  FROM c_bpartner V 
inner join c_order CO  on  co.c_bpartner_id = V.C_BPARTNER_ID
left join ad_user u on co.SALESREP_ID = u.AD_USER_ID
WHERE
 CO.ISSOTRX='N' AND  V.created >= '01-NOV-2014'
 and V.value in (SELECT VEND FROM DVTB)) x
where x.rn = 1
order by x.vendorcode

Open in new window

It gives the error:
ORA-00923: FROM keyword not found where expected
00923. 00000 -  "FROM keyword not found where expected"
*Cause:    
*Action:
Error at Line: 7 Column: 29
Star79Author Commented:
Thanks all this worked:
I was kind of confused with sql and oracle
WITH DVTB AS
(
	SELECT 'AAP052' as VEND from dual
)
SELECT x.*
FROM (
        SELECT V.CREATED as "CREATEDDATE",        
              V.value as "VENDORCODE",     
             V.NAME AS "VENDOR_NAME",
            CO.DOCUMENTNO AS "PO_NUM",
            CO.EM_SC_PROGRAM_CODE AS "Program",
           CO.DATEPRINTED AS "PO_CREATEDATE",
           u.name  AS "BUYER",
			     row_number() over(partition by V.value order by CO.DOCUMENTNO) as rn
  FROM c_bpartner V 
inner join c_order CO  on  co.c_bpartner_id = V.C_BPARTNER_ID
left join ad_user u on co.SALESREP_ID = u.AD_USER_ID
WHERE
 CO.ISSOTRX='N' AND  V.created >= '01-NOV-2014'
 and V.value in (SELECT VEND FROM DVTB)) x
where x.rn = 1
order by x.vendorcode

Open in new window

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
Oracle Database

From novice to tech pro — start learning today.