using distinct insted of min
Hi, could we have used here the: DISTINCT e.emp_no , insted of : MIN(de.dept_no) ?
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.