Last answered:

07 Oct 2022

Posted on:

06 Oct 2022

1

using distinct insted of min

Hi, could we have used here the: DISTINCT e.emp_no ,  insted of : MIN(de.dept_no) ?

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

07 Oct 2022

0

Hi Kfir!
Thanks for reaching out.

We use the MIN() function to extract just one department number. If we didn't, we would have obtained all of them, thus getting more records than we need. We can also use the MAX() function with the same idea. But if we use DISTINCT, it will give us another result set.

Note: DISTINCT is not a function, it is a keyword. The DISTINCT keyword is used in conjunction with the SELECT statement to eliminate all the duplicate records and fetching only unique records. There may be a situation when you have multiple duplicate records in a table.

Hope this helps.
Best,
Tsvetelin

Submit an answer