Mình đang làm cái challenge này:
nhưng chưa biết vì sao lệnh của mình sai, mọi người xem giúp với:
select h.hacker_id, h.name from hackers as h
join
(
select s.hacker_id, s.challenge_id, sum(if(d.score = s.score,1,0)) as Tong
from submissions as s
join challenges as c on s.hacker_id = c.hacker_id
and s.challenge_id = c.challenge_id
join difficulty as d on c.difficulty_level = d.difficulty_level
)
as Result(hackerID,challengeID, numberMaxScore)
on h.hacker_id = Result.hackerID
where numberMaxScore > 1
order by numberMaxScore desc, hacker_id asc;
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for
the right syntax to use near '(hackerID,challengeID, numberMaxScore)
on h.hacker_id = Result.hackerID
' at line 10