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

  • Home
  • SEARCH
  • 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 8649111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:28:42+00:00 2026-06-12T13:28:42+00:00

This is an employee to dependent relationship. I am having trouble displaying only the

  • 0

This is an employee to dependent relationship. I am having trouble displaying only the employee who has more than one dependent. The line that should not be there is for emp_no 555555.

 SELECT emp_no, emp_name, dep_emp_no, dep_name, dep_relationship, trunc(MONTHS_BETWEEN(current_date, dep_date_of_birth)/12) "Age"
 FROM DEPENDENT d JOIN employee e ON e.emp_no=d.dep_emp_no
WHERE dep_date_of_birth=(SELECT MIN(DEP_DATE_OF_BIRTH) FROM DEPENDENT dd WHERE d.dep_emp_no=dd.dep_emp_no)


 EMP_NO EMP_NAME                       DEP_EM DEP_NAME             DEP_RELATI        Age
 ------ ------------------------------ ------ -------------------- ---------- ----------
 444444 Hickman, Ron                   444444 Amy                  DAUGHTER           22
 555555 Moore, Wayne                   555555 Sharon               SPOUSE             65
 111111 Li, Anna                       111111 Chris                SON                 8

This is what is giving me the error:

 SELECT emp_no, 
        emp_name, 
        dep_emp_no, 
        dep_name, 
        dep_relationship, 
        trunc(MONTHS_BETWEEN(current_date, dep_date_of_birth)/12) "Age"
   FROM DEPENDENT d 
   JOIN employee e ON e.emp_no=d.dep_emp_no
  WHERE dep_date_of_birth=(SELECT MIN(DEP_DATE_OF_BIRTH) 
                             FROM DEPENDENT dd 
                            WHERE d.dep_emp_no=dd.dep_emp_no)
 and where DEP_EMP_NO exists (select count(dep_emp_no) 
                                from dependent 
                              having count(dep_emp_no)>1 
                            group by dep_emp_no);
  • 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-06-12T13:28:43+00:00Added an answer on June 12, 2026 at 1:28 pm

    There is a and where DEP_EMP_NO too much and a condition missing in the count. The following should work.

    SELECT emp_no, 
           emp_name, 
           dep_emp_no, 
           dep_name, 
           dep_relationship, 
           trunc(MONTHS_BETWEEN(current_date, dep_date_of_birth)/12) "Age"
      FROM DEPENDENT d 
      JOIN employee e ON e.emp_no=d.dep_emp_no
     WHERE dep_date_of_birth=(SELECT MIN(DEP_DATE_OF_BIRTH) 
                                FROM DEPENDENT dd 
                               WHERE d.dep_emp_no=dd.dep_emp_no)
      and  exists (select count(dep_emp_no) 
                               from dependent d2 
                               where d.dep_emp_no=d2.dep_emp_no
                               group by dep_emp_no
                               having count(dep_emp_no)>1 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine this scenario: in our company there is an employee that play around graphic,css,html
In my edit action of my employees_controller I have this line of code: #Employee#edit
So this is the only example of outer joins that we've gotten all year,
My question is similar to this one but I'm having some problems with the
I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does
This is what my data model classes look like: public class Employee { public
This is my query, CREATE VIEW employee_vu AS( SELECT employee_id,last_name employee,department_id FROM employees); I
I have written this clone method for when the parent of the Employee class
I have class Employee which is something like this. class Emp { int EmpID;
In this JDO, why is .class needed here? Query averageSalaryQuery = pm.newQuery(Employee.class); I would

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.