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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:32:55+00:00 2026-05-25T11:32:55+00:00

I have two table a) tblresign and b) tblemp tblresign has one foreign key

  • 0

I have two table a) tblresign and b) tblemp

tblresign has one foreign key which refer the tblemp primary key

tblresign have on column leavingdate
tblemp have on column retiredate

i want to write a query which will check condition that if leavingdate is present than it will not give retire date and if retiredate is present it will not give leaveingdate that mean any how i need only one date from both of them which is present

can any one help to how to write that select query in postgresql

  • 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-25T11:32:55+00:00Added an answer on May 25, 2026 at 11:32 am

    Not sure I understand your question, but what about this:

    SELECT e.emp_name,
           e.id,
           coalesce(r.leavingdate, e.retiredate) as some_date 
    FROM tblemp e
       LEFT JOIN tblresign r ON e.id = r.emp_id
    

    If there is no row in tblresign for an employee or that row’s leavingdate is null then retiredate is shown.

    You did not state which date to show if both dates are present. You might need to change the order in the coalesce() function to suit your needs. If you have a more complex rule, then you probably want a CASE statement to cover that. But we need way more information in order to answer that.

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

Sidebar

Related Questions

I have two fields in a table. One contains values such as BTA, BEA,
I have two table in mysql named rootpath with only one field 'root' and
I have two table TempStore and Store with the same column called Items. There
I have two table Company and Employee. And there relation is Company(one) - Employee(many).
I have two table and I should write a select query which join this
I have two table in my database. One called person and one called team.
Using SQL Server 2005 I have two table which have the same datatype and
I need to have two Table Views in one XIB file, is there any
I have two table with different column like this: table1 ( _id, title, name,
I have two table fields in a MySQL table. One is VARCHAR and is

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.