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 65k
  • Answers 65k
  • 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 Found a solution on this website All you need is… May 11, 2026 at 11:14 am
  • added an answer The following article gives a nice, simple way to manage… May 11, 2026 at 11:14 am
  • added an answer This HashSet MSDN page specifically says: A set is a… May 11, 2026 at 11:14 am

Related Questions

I have a query which is meant to show me any rows in table
I have the following problem. If I query values with a keyfigure which is
I have a query in which I am pulling the runtime of an executable.
I have a MySQL query in which I want to include a list of
I have a SQL SELECT query which has a LIKE clause containing an underscore,
I have a query to insert a row into a table, which has a
I am running oracle and have a query which pulls some results from the
Strange performance outcome, I have a LINQ to SQL query which uses several let
I am writing a query in which I have to get the data for
I have an MDX query which lists a measure for all 'Week' and 'Day'

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.