Results 1 to 3 of 3

Thread: [RESOLVED] Oracle 9i: Alias in WHERE clause

  1. #1

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Resolved [RESOLVED] Oracle 9i: Alias in WHERE clause

    So, it appears that I can't use an Alias in a WHERE clause with Oracle 9i? ORA-00904:"SELLOFFDATE":Invalid Identifier is the error.

    If that is the case, how shall I perform the comparison in my WHERE clause below? If I'm simply making some SQL error, let me know that too.

    Here's a snippet of what I'd like to do. Thanks for any help!
    sql Code:
    1. select
    2.   (select to_date(r2.FIELD_VALUE, 'dd-mon-yyyy')
    3.   from V_REPCUSTOMFIELDDATA r2
    4.   where
    5.     r2.INTERNAL_DESCRIPTIONS_CODE = 35
    6.     and r2.ASSOCIATED_WITH_CODE = ag.AGREEMENTS_ABBR) SellOffDate,
    7.   ag.AGREEMENTS_ABBR LicensorNumber
    8. from V_AGREEMENT ag
    9. where SellOffDate between
    10.     to_date('01/01/1999', 'mm/dd/yyyy') and to_date('12/31/2001', 'mm/dd/yyyy')

  2. #2
    Lively Member
    Join Date
    Aug 2007
    Posts
    86

    Re: Oracle 9i: Alias in WHERE clause

    you can put your where condition in your subquery
    Code:
    SELECT 
      (SELECT to_date(r2.FIELD_VALUE, 'dd-mon-yyyy')
      FROM V_REPCUSTOMFIELDDATA r2
      WHERE
        r2.INTERNAL_DESCRIPTIONS_CODE = 35
        AND r2.ASSOCIATED_WITH_CODE = ag.AGREEMENTS_ABBR
        AND to_date(r2.FIELD_VALUE, 'dd-mon-yyyy')  BETWEEN 
        to_date('01/01/1999', 'mm/dd/yyyy') AND to_date('12/31/2001', 'mm/dd/yyyy') ) SellOffDate,
      ag.AGREEMENTS_ABBR LicensorNumber
    FROM V_AGREEMENT ag

  3. #3

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Oracle 9i: Alias in WHERE clause

    Easy enough. That seems to work! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width