I need to display employees details whose salary is greater than average salary of their department. below is table
Table:

I know that we can easily find the solution using subquery and other methods but I need to know why below group by solution not working.
Solution 1) This solution is giving correct result, when I only join ON dept_name

solution 2 ) Below code is giving wrong result when I add extra condition with emp_id.
