I read a course in SQL right now, and have a problem I can´t find a solution at.The first task is the following:View average salary for all customers in the table. I wrote the following SQL statement, which also worked:SELECT ROUND(avg(nvl(årslön, 0))) AS Medellön FROM kund;
But it is the second task that is the problem.The second task is the following:Show username, fname, enamn, arslan for those customers who have an annual income of less than average salary for all customers.It is working when I enter this SQL statement:SELECT username, fnamn, enamn, nvl(årslön, 0) FROM kund GROUP BY årslön, username, fnamn, enamn HAVING nvl(årslön, 0) < 355300;
But I want to replace the 355 300 with a calculation. It is the same calculation that i used in the first task. I tried with this solution, but it does not work:SELECT username, fnamn, enamn, nvl(årslön, 0) FROM kund GROUP BY årslön, username, fnamn, enamn HAVING nvl(årslön, 0) < avg(nvl(årslön, 0));
Does anyone have any suggestions for solution?