To show two columns using select syntax in Oracle 11g referring another column in same table

Tags:
Oracle
Oracle 11g
Hi everyone, I really need help on one thing. Suppose I have a table employee and there are many columns and three of them are empno, ename and managerno(of employees) and o want to show results using select syntax and the managerno contains the empno of employees and I want to show ename and (a virtual column) named manager-name to show the names of employees referring empno in the table.
I know the description is long but please help me!


Software/Hardware used:
Oracle 11g
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Select a.empno, a.ename, a.managerno, m.ename as manager_name
From employee a
Join employee m on m.empno = a.managerno

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • rvijay926

    Select a.empno as "Employee_no", a.ename as "Employee_name", a.managerno as "Manager", m.ename as "Manager_name"
    From employee a
    Join employee m on a.empno = m.managerno;

    This is actually self join where you are joining the table with itself.

    Vijay

    280 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: