+ 2
hey guys doesn't answer
write a query to extract the sum of like for topic SELECT post_id,Sum(topic) FROM likes;
2 Answers
+ 8
You code has many mistakes
1>You have to extract topic and total sum of likes as `sum`.But you are trying to find total sum of topic which result in error.
2>These things should extract by the table `posts` not `likes`.
3>Table should be grouped by topic.
So finally after fixed these problems your code will looking like this one:-
SELECT topic,SUM(likes) AS sum
FROM posts
GROUP BY topic
+ 3
you gave good tips and thank you