regarding min() function for department no
I understand the fact that an employee could be associated with more than one table. But we have learnt that all the aggregate functions except COUNT() can be applied only to numerical value. But department numbers in this dataset is actually starting with an alphabet 'd' followed by some number so that couldnt be said as a number. So applying min() to such data values is contradicting the about fact. Could you please explain the same.
I believe that in this case, the MIN function will choose the minimum value depending on the ASC order of the dept_no column. Meaning, it will sort the department codes ascendingly and choose the topmost value.
Hi Meenakshi!
Thanks for reaching out.
You’re right that we should use aggregate functions with numeric values. But we use the aggregate function MIN() with the column dept_no which is a column containing numeric values.
We use the MIN() function because in this way only one row per employee is returned. If we don't use it, all the rows from the dept_manager table will be included in the output.
Hope this helps.
Best,
Tsvetelin