Last answered:

21 Feb 2024

Posted on:

21 Apr 2023

1

Numbers don't match, am I missing something?

In the table salaries the count of current salaries (whose to_date is>sysday()) is 81635.

However, in the table dept_emp the amount of employees whose to_date is >sysday() = 240024

If we run the  query below, we can see that there are 158489 employees whose salary  = 0

Is it supposed to be this way? Seems counterintuitive.


select de.emp_no, count(s.to_date)
from dept_emp de
left join salaries s on (s.emp_no = de.emp_no) and (s.to_date>sysdate())
where de.to_date > sysdate()
group by de.emp_no
having count(s.to_date) = 0;



3 answers ( 0 marked as helpful)
Instructor
Posted on:

24 Apr 2023

0

Hi Eugenia!
Thanks for reaching out.


Could you please explain your question with more words and provide additional examples? Thank you.


Looking forward to your answer.
Best,
Tsvetelin

Posted on:

25 Apr 2023

0

What I am trying to say is that the amount of current employees is more than the amount of current salaries. (The query that I gave proves it). It seems counter intuitive to me, because, as far as I am concerned, every employee should have a salary. The reason I am pointing it out is because it confused me when I was trying to make sence of numbers regarding this database. 


Posted on:

21 Feb 2024

0

@Tsonkov 

Hello instructor,

@Eugenia meant to ask that when we run a query which returns the emp_no whose to_date is greater than the sysdate() on both dept_emp table and salaries table individually. The no.of rows returned is different to a great extent. Considering all the employees receive salaries and belongs to a department . She is wondering why both the values contradict.

i.e rows returned in dept_emp is higher than rows returned in salaries table whose number the fellow learner has mentioned as 240024 and 81635 respectively on the date she queried.


Submit an answer