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 9027313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:43:17+00:00 2026-06-16T06:43:17+00:00

This is in Oracle. I’m having an issue that I’m not sure can actually

  • 0

This is in Oracle. I’m having an issue that I’m not sure can actually be solved. But I’ve created a query that essentially compares several different fields and needs to be able to utilize 2 substring columns and compare them to each other. I’m not overly sure how to go about doing this as I’ve tried the following code blocks and I keep getting either an “invalid identifier” error or “single-row subquery returns more than one row.” I know why the latter comes up and thats not the issue. I’m trying to figure out why my substring column’s are unable to be compared against each other.

Code samples:

This one gives me the correct columns so I know its not the syntax.

select substr(p.new_plan, 1, 1) as np, substr(p.old_plan, 1, 1) as op 
from sbsb_plan_conv p, cmc_sbel_elig_ent e
where p.sbsb_ck = e.sbsb_ck

This is the full code block which gives me the “OP”: invalid identifier error

SELECT p.cspi_id, p.sbel_eff_dt, co.new_plan, co.ch_dt, co.sbsb_ck
FROM sbsb_plan_conv co, cmc_sbel_elig_ent p
WHERE co.ch_dt > p.SBEL_EFF_DT
AND co.new_plan <> p.CSPI_ID
AND co.sbsb_ck = p.sbsb_ck
AND p.cspi_id   = co.OLD_PLAN
and (p.cspd_cat = (
          select substr(o.old_plan, 1, 1) as op  
          from sbsb_plan_conv o, cmc_sbel_elig_ent e
          where op = (
                select substr(q.new_plan, 1, 1) as np   
                from sbsb_plan_conv q, cmc_sbel_elig_ent w
                where q.sbsb_ck = w.sbsb_ck)
          and o.sbsb_ck = e.sbsb_ck)
or p.cspd_cat = (
          select substr(o.new_plan, 1, 1) as np   
          from sbsb_plan_conv o, cmc_sbel_elig_ent e
          where np = (
                select substr(q.old_plan, 1, 1) as op  
                from sbsb_plan_conv q, cmc_sbel_elig_ent w
                where q.sbsb_ck = w.sbsb_ck)
          and o.sbsb_ck = e.sbsb_ck)
            )
AND (p.SBEL_ELIG_TYPE = 'tm'
OR p.sbel_elig_type = 'ce'
OR p.SBEL_ELIG_TYPE = 'TM'
OR p.sbel_elig_type = 'CE')

I had originally tried to use the two substring names as a conditional but that didn’t work either. What am I doing wrong here?

  • 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. Editorial Team
    Editorial Team
    2026-06-16T06:43:18+00:00Added an answer on June 16, 2026 at 6:43 am

    You can’t use aliases that were defined in the select clause in the where clause of the same query.

    Change this:

    select substr(o.old_plan, 1, 1) as op  
    from sbsb_plan_conv o, cmc_sbel_elig_ent e
    where op = ...
    

    To this:

    select substr(o.old_plan, 1, 1) as op  
    from sbsb_plan_conv o, cmc_sbel_elig_ent e
    where substr(o.old_plan, 1, 1) = ...
    

    Related

    • Using an Alias in a WHERE clause
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Oracle, this returns 03/01/2010. That does not make sense to me. Anybody know
This Oracle documentation page mentions ... columns of type LONG are created last but
I am writing a sql query in Oracle that's something like this: SELECT *
I have a query in a TableAdapter that wrapped this SQL (Oracle SQL, uses
Tried running a java method that runs this oracle SQL query String query =
Asking for your help on this Oracle query. It's giving me the error 2
This might be simple but I am new to Oracle. I am using Oracle
Hello I am trying to run this oracle query in toad and I am
I can't figure out Oracle's encryptic syntax for the life of me. This is
I need to perform this Oracle query in SQL Server: select case_id, channel_index, min(su_min)

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.