I questioned here this:
How make this sql. ( conditions sql )
but now, I want
SELECT SUM( Post.rating ) as countRating <--- THIS i want Post.rating * 5 WHEN Post.recommended = 1
FROM posts as Post
ORDER BY countRating DESC
help me
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically, use the same technique as in the answers to the other question – use a CASE expression, this time in the SUM instead of in the ORDER BY clause.
If the alternative value for Recommended is 0 (a plausible guess), then you could also write:
And, indeed, you could do the same with the ORDER BY clause in the previous question.