Can I group by in SQL query with window function?
<p>I need to get <strong>employees with smallest salary in their departments</strong>
I did it using anti join.</p>

<pre><code>     select emp.employee_id,emp.last_name,emp.salary,emp.department_id
     from employees emp
     left join employees sml 
     on sml.department_id = emp.department_id and sml.salary &lt; emp.salary
     where sml.employee_id is null and emp.department_id is not null
</code></pre>

<p>But I've been told that it's possible to do it using window function <strong>using one select</strong>.
However I can't group it by department_id and use it at the same time.
Is that a bug or me being stupid?</p>

<pre><code>     SELECT  department_id,
     min(salary) OVER (partition by department_id)  as minsalary
     FROM employees;
     GROUP BY department_id
</code></pre>

<p>SQL Developer says 00979. 00000 -  "not a GROUP BY expression"</p>