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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:46:56+00:00 2026-05-30T04:46:56+00:00

I have 3 tables – TableA , TableB and TableDetail **Table Detail** id FinalValue

  • 0

I have 3 tables – TableA, TableB and TableDetail

**Table Detail**
id  FinalValue
1       99
2       88
3       77


**Table A**
id   InitValue   Num
1     10         100
2     30         200


**Table B**
id   InitValue  Num
3    20          200

My requirement is to get the FinalValue from TableDetail based on

Num 

(Num value will be selected by user from a textBox UI).If TableB has a record for the partcular Num, then use Table B’s id.If not, then use Table A’s id.
The assumption is that Table A has records for all Num values.

For example,

If Num=200:

Since a record exists in TableB for Num=200, use TableB’s corresponding id (3) and get FinalValue from TableDetail where id=3, i.e.

FinalValue = 77

If Num =100:

SinceTableB does not have any record for Num=100,use TableA’s corresponding id (1) and get FinalValue from TableDetail where id=1, i.e.

FinalValue = 99

Can you plese help me frame a PL/SQL query for the same.Thanks!

  • 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-05-30T04:46:57+00:00Added an answer on May 30, 2026 at 4:46 am

    try the following, @num is passed by user

    select FinalValue
    from TableDetail
    where id in
    (select isnull(T2.id,T1.id)
    from TableA T1 on T.id = T1.id and T1.Num = @num
    left join TableB T2 on T.id = T2.id and T2.Num = @num)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my database I have tables that define types for example Table: Publication Types
Hi i have tables like this : table entry : id | total_comments _____________________
I have tables: Teachers and Students. We have a SpecialProjects Table where Teachers and
I have tables item and store (it's a store management system). item table has
I have tables foo and bar: create table foo(a int, b varchar(10), primary key
I have tables & data like this: venues table contains : id +----+---------+ |
I have tables of data samples, with a timestamp and some data. Each table
I have tables named Events and Log. The Events table comprises of ID, Event
I have two tables, say Table A and Table B. I want to have
Say we have tables A, B, and C and then we want table Z

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.