oracle sql syntax help

oracle sql.  I created a field using this trunc(sysdate) - trunc(EVENT_DT) as TotalDays,   I have tried different things and none work.   Can you help with syntax to do this?

In the where statement I want only get the days >10
and TotalDays > (10)

ORA-00904: "TOTALDAYS": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 40 Column: 5
kdschoolAsked:
Who is Participating?
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:
You cannot use an alias in the where clause in the same level you define it.

Two ways around this:
select  trunc(sysdate) - trunc(EVENT_DT) as TotalDays
from some_table
where
 trunc(sysdate) - trunc(EVENT_DT) > 10

Open in new window


or
select totaldays from (
select  trunc(sysdate) - trunc(EVENT_DT) as TotalDays
from some_table
)
where
TotalDays > 10

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
kdschoolAuthor Commented:
Perfect first option worked great.  Thank you.
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
SQL

From novice to tech pro — start learning today.