+ 1
MySQL command!
You have a table with employee payment, you have to select employee with less payment than average. I tried the following command: SELECT username FROM users WHERE payment < AVG(payment) ERROR #1111 - invalid use of group function
5 Respuestas
+ 7
SELECT username FROM users WHERE payment < (SELECT AVG (payment) FROM users) ?
+ 4
Not to my knowledge.
+ 1
Well, just found the answer. That would be
SELECT username FROM users WHERE payment<(SELECT AVG(payment) FROM users)
**IF anyone knows a better /easier way let me know.
+ 1
Yah, I found it too. Any easier command?
+ 1
SELECT username FROM users WHERE payment<(SELECT AVG(payment) FROM users)
**This is the simplest command you can find out there unless you want to group the observations and then use the HAVING clause.