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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:45:49+00:00 2026-05-25T17:45:49+00:00

I am trying to get an employee that does not have a manager to

  • 0

I am trying to get an employee that does not have a manager to show on my table but all im getting is “no data found” when i know that such employee exist in the db.

this is my code:

ACCEPT p_1 PROMPT 'Please Enter Employee ID:'

declare 
  v_eid               employee.employee_id%TYPE := &p_1;
  v_count             NUMBER;
  v_name              employee.employee_name%TYPE;
  v_sal               employee.salary%type;
  v_mname             employee.employee_id%TYPE ;
  v_dptname           department.department_name%type;  
  v_avg               employee.salary%type;

BEGIN 
  SELECT count(*)
  INTO v_count
  FROM employee
  WHERE employee_id = v_eid;

  IF v_count = 0 THEN
      DBMS_OUTPUT.PUT_LINE(v_eid || ' is not in the table.');
  ELSE
      select e1.employee_name, e1.salary, department.department_name,
             nvl(e2.employee_name, 0)
      into v_name, v_sal, v_mname, v_dptname
      from employee e1
      inner join employee e2 on e1.manager_id = e2.employee_id 
      inner join department on e1.department_id = department.department_id
      where e1.employee_id = v_eid;

      select AVG(salary)
      into v_avg
      from employee
      where department_id = (select department_id 
                              from employee 
                              where employee_id=v_eid);
        DBMS_OUTPUT.PUT_LINE('Name:'|| LPAD(v_name,30));
        DBMS_OUTPUT.PUT_LINE('Salary:'|| LPAD(to_char(v_sal,'$9,999.00'),28));
        DBMS_OUTPUT.PUT_LINE('Manager Name:'|| LPAD(v_mname, 19));
        DBMS_OUTPUT.PUT_LINE('Department Name:'|| v_dptname);
        DBMS_OUTPUT.PUT_LINE('Department Average'|| to_char(v_avg,'$9,999.00'));
  END IF;
END;

Thanks for your help

  • 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-25T17:45:50+00:00Added an answer on May 25, 2026 at 5:45 pm

    Hi If you are looking only for employees without manager why are you doing a self join.In any case if no manager exists you should replace

    from employee e1 inner join employee e2 on e1.manager_id = e2.employee_id 
    
    by
    
    from employee e1 left outer join employee e2 on e1.manager_id = e2.employee_id 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get records that match with todays date(not time) but the
I'm trying to get started with South data migrations. I found this SO question:
I'm trying to get the total count of employee ids so that I can
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I have a fairly complex relationship that I am trying to make work with
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that
I'm trying to create a page that displays a list of employees. All the
I have data being returned in a DataTable that looks like: Department | EmployeeName
I have this javascript that pulls some data via an ajax request the method

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.