Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 91791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:05:07+00:00 2026-05-10T23:05:07+00:00

I have a query which is meant to show me any rows in table

  • 0

I have a query which is meant to show me any rows in table A which have not been updated recently enough. (Each row should be updated within 2 months after ‘month_no’.):

SELECT A.identifier      , A.name      , TO_NUMBER(DECODE( A.month_no              , 1, 200803               , 2, 200804               , 3, 200805               , 4, 200806               , 5, 200807               , 6, 200808               , 7, 200809               , 8, 200810               , 9, 200811               , 10, 200812               , 11, 200701               , 12, 200702              , NULL)) as MONTH_NO      , TO_NUMBER(TO_CHAR(B.last_update_date, 'YYYYMM')) as UPD_DATE   FROM table_a A      , table_b B  WHERE A.identifier = B.identifier    AND MONTH_NO > UPD_DATE 

The last line in the WHERE clause causes an ‘ORA-00904 Invalid Identifier’ error. Needless to say, I don’t want to repeat the entire DECODE function in my WHERE clause. Any thoughts? (Both fixes and workarounds accepted…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:05:07+00:00Added an answer on May 10, 2026 at 11:05 pm

    This is not possible directly, because chronologically, WHERE happens before SELECT, which always is the last step in the execution chain.

    You can do a sub-select and filter on it:

    SELECT * FROM (   SELECT A.identifier     , A.name     , TO_NUMBER(DECODE( A.month_no       , 1, 200803        , 2, 200804        , 3, 200805        , 4, 200806        , 5, 200807        , 6, 200808        , 7, 200809        , 8, 200810        , 9, 200811        , 10, 200812        , 11, 200701        , 12, 200702       , NULL)) as MONTH_NO     , TO_NUMBER(TO_CHAR(B.last_update_date, 'YYYYMM')) as UPD_DATE   FROM table_a A     , table_b B   WHERE A.identifier = B.identifier ) AS inner_table WHERE    MONTH_NO > UPD_DATE 

    Interesting bit of info moved up from the comments:

    There should be no performance hit. Oracle does not need to materialize inner queries before applying outer conditions — Oracle will consider transforming this query internally and push the predicate down into the inner query and will do so if it is cost effective. – Justin Cave

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Looking around quickly I found two scripts that hold promise:… May 11, 2026 at 3:28 pm
  • added an answer for C++ I've used boost::asio, it's very modern C++, and… May 11, 2026 at 3:28 pm
  • added an answer The view structure is based on the controllers, not the… May 11, 2026 at 3:28 pm

Related Questions

I am using Hibernate in a Java application to access my Database and it
I've a terrible memory. Whenever I do a CONNECT BY query in Oracle -
I have one table orders with a foreing key ProductID. I want to show
I have this code: db = C:\Dokumente und Einstellungen\hom\Anwendungsdaten\BayWotch4\Neuer Ordner\baywotch.db5 TextExportFile = C:\Dokumente und

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.