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
Not sure I understand your question, but what about this:
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.