I have a Table that displays a teams salaries and I want to display their minimum, maximum and average salary for each team for each year.
My table looks like:
I run the following SQL:
SELECT MIN(salary), MAX(salary), AVG(salary), teamID, yearID FROM salaries;
But get the following error:
ERROR: column "salaries.teamid" must appear in the GROUP BY clause or be used in an aggregate function
What does it mean?
Try this
SELECT MIN(salary), MAX(salary), AVG(salary), teamID, yearID FROM
salaries group by teamID,yearID
SELECT MIN(salary), MAX(salary), AVG(salary), teamID, yearID
FROM salaries
GROUP BY teamID, yearID;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.