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

  • Home
  • SEARCH
  • 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 8249685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:37:44+00:00 2026-06-07T23:37:44+00:00

I have 3 queries which retrieves maximum value depending on a condition. select max(to_number(substr(attr_value,9)))+1

  • 0

I have 3 queries which retrieves maximum value depending on a condition.

select max(to_number(substr(attr_value,9)))+1 
  from circ_inst inner
  join circ_attr_settings 
    on circ_inst.circ_inst_id=circ_attr_settings.circ_inst_id 
   and val_attr_inst_id=1045 
 where circ_attr_settings.attr_value like 'IPANEMA-%' 



select max(to_number(substr(attr_value,10)))+1 
  from circ_inst inner
  join circ_attr_settings 
    on circ_inst.circ_inst_id=circ_attr_settings.circ_inst_id 
   and val_attr_inst_id=1045 
 where circ_attr_settings.attr_value like 'FIREWALL-%'



select max(to_number(substr(attr_value,16)))+1 
  from circ_inst 
 inner join circ_attr_settings
    on circ_inst.circ_inst_id=circ_attr_settings.circ_inst_id
   and val_attr_inst_id=1045 
 where circ_attr_settings.attr_value like 'LAYER2 SWITCH-%'

I would like to get the maximum number out of these 3 queries(if the results of the 3 queries are 6430, 6434 and 6418 respectively, then I would like to get the value “6434” which is the maximum of the three results.

I tried using max(query1,query2,query3) but not successful.

  • 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-07T23:37:47+00:00Added an answer on June 7, 2026 at 11:37 pm

    I think you can do this with one query:

    select max(to_number(substr(attr_value,instr(attr_value, '-')+1)))+1
    from circ_inst inner join
         circ_attr_settings
         on circ_inst.circ_inst_id=circ_attr_settings.circ_inst_id and
            val_attr_inst_id=1045
    where circ_attr_settings.attr_value like 'LAYER 2 SWITCH-%') or
          circ_attr_settings.attr_value like 'IPANEMA-%' or
          circ_attr_settings.attr_value like 'FIREWALL-%'
    

    Your joins all appear to be the same. The only difference is extracting the number. You can get the right start location by looking for a “-” in the value.

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

Sidebar

Related Questions

i have some queries which group datasets and count them, e.g. SELECT COUNT(*) FROM
i have SOQL query which queries for some records based on a where condition.
I have two queries with subqueries for dateparts which I like to join. SELECT
I have to generate a single sql query, which retrieves two columns from two
I have an xml file which contains query details like <queries> <query> <name>GetStudentById</name> <statement>select
I have the following two queries which I want to get in one query.
I have a simple query which queries by item_id and it obviously works because
I have a T-SQL query as below which queries a table holding the search
I'm currently trying to develop a site which queries text information. I already have
I have a JSP page which accepts SQL queries, performs them then returns the

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.