I'm not used to SQL a lot, so maybe my question is so dumb, don't be hard with me guys ;)
So, this is my table PEOPLE, and what i want is with a query is find the people that are not in an expecific age, but im getting an error.
PEOPLE
+-------+------+---------+
| NUMPOL| MCT | PRODNUM|
+-------+------+---------+
| 98552 | 1054 | 9704 |
+-------+------+---------+
| 89854 | 0985 | 5014 |
+-------+------+---------+
| 78542 | 1054 | 9704 |
+-------+------+---------+
| 98552 | 0965 | 9704 |
+-------+------+---------+
| 98552 | 4222 | 9704 |
+-------+------+---------+
I'm trying to run this query
SELECT NUMPOL, MCT, PRODCO
FROM PEOPLE
WHERE MCT NOT IN (1054,0965) AND PRODNUM='9704'
GROUP BY NUMPOL
And this is the error that I'm getting, I tried to solve it googling but never could find an answer because I can't find why it told me that the select list is not valid:
SQLCODE = -122, ERROR: COLUMN OR EXPRESSION IN THE SELECT LIST IS
NOT VALID
Solved
TRY :
SELECT TEAM, [NAME], AGE
FROM PEOPLE
WHERE AGE NOT IN (20,21,22,23) AND GEND='F'
GROUP BY TEAM
NAME is an SQL keyword.
Read the error message :
COLUMN OR EXPRESSION IN THE SELECT LIST IS NOT VALID
Since it mentions the "SELECT LIST", inspect the SELECT LIST :
NUMPOL, MCT, PRODCO
Look for where there's a column named "PRODCO" in your table.
Group by has some rules
SELECT NUMPOL, MCT, PRODCO
FROM PEOPLE
WHERE MCT NOT IN (1054,0965) AND PRODNUM='9704'
GROUP BY NUMPOL,MCT, PRODCO
Comments
Post a Comment