+ 2
Why alias 'NC' is referred as unknow column?
MySql code:- SELECT C.HACKER_ID,COUNT(C.CHALLENGE_ID) AS NC FROM CHALLENGES AS C WHERE C.NC=50 GROUP BY C.HACKER_ID; OUTPUT:- ERROR 1054 (42S22) at line 4: Unknown column 'C.NC' in 'where clause' pls reply me the correct query
3 ответов
0
Jawa this might be a use case for the HAVING clause. Try this:
SELECT C.HACKER_ID,COUNT(C.CHALLENGE_ID) AS NC FROM CHALLENGES AS C
GROUP BY C.HACKER_ID
HAVING COUNT(C.CHALLENGE_ID)=50;
0
-- try this
SELECT C.HACKER_ID, COUNT(C.CHALLENGE_ID) AS NC
FROM CHALLENGES C
WHERE COUNT(C.CHALLENGE_ID)=50
GROUP BY C.HACKER_ID;