Avatar of RenitlahHelp
RenitlahHelp
Flag for United States of America asked on

Oracle SQL Question

I am receiving an invalid identifier for "CUSTBAL"... any ideas why?  Thanks!
SELECT CUSTOMER_NUM, CUSTOMER_NAME, SUM(BALANCE) AS CUSTBAL, REP.REP_NUM FROM CUSTOMER, REP WHERE CUSTOMER.REP_NUM=REP.REP_NUM AND (CUSTBAL>10000) GROUP BY CUSTOMER_NUM;

Open in new window

Oracle DatabaseEnterprise Software

Avatar of undefined
Last Comment
RenitlahHelp

8/22/2022 - Mon
yousaftahir

It is not working becuase CUSTBAL column does not exist in either cusomter and rep. you need to use derived table for the solution as :

select CUSTOMER_NUM, CUSTOMER_NAME,  CUSTBAL, REP.REP_NUM from (
 SELECT CUSTOMER_NUM, CUSTOMER_NAME, SUM(BALANCE) AS CUSTBAL, REP.REP_NUM FROM CUSTOMER, REP
WHERE CUSTOMER.REP_NUM=REP.REP_NUM  GROUP BY CUSTOMER_NUM)
as tblderived where (CUSTBAL>10000)
ASKER CERTIFIED SOLUTION
Sharath S

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RenitlahHelp

ASKER
Excellent!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23