+ 2

hey guys doesn't answer

write a query to extract the sum of like for topic SELECT post_id,Sum(topic) FROM likes;

10th Nov 2023, 7:56 AM
AMIR H R šŸ‘‘šŸ’ŽšŸ•¹šŸ“±šŸ“” šŸ’Ŗ
AMIR  H  R šŸ‘‘šŸ’ŽšŸ•¹šŸ“±šŸ“” šŸ’Ŗ - avatar
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
10th Nov 2023, 8:49 AM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 3
you gave good tips and thank you
10th Nov 2023, 10:52 AM
AMIR H R šŸ‘‘šŸ’ŽšŸ•¹šŸ“±šŸ“” šŸ’Ŗ
AMIR  H  R šŸ‘‘šŸ’ŽšŸ•¹šŸ“±šŸ“” šŸ’Ŗ - avatar