1

I want to compare two value with avg rating of user

select * from dt_tutor_comments where avg(rating_value) BETWEEN 1 and 2 GROUP by u.id 
  • Please provide a small dataset as an example of what you are talking about. – Rick James May 22 '17 at 5:58
  • actually i want to find out how many menbers has 2 two 4 avgrating in dt_tutor_comment table select * from dt_tutor_comments where avg(rating_value) BETWEEN 1 and 2 GROUP by u.id – jayaprakash k May 22 '17 at 6:05
  • "data", as in "numbers". – Rick James May 22 '17 at 6:06
  • avg rating of each user i'm saving in other rating table just i want to joining that table with this query and need to calculate who are having from 2 to 4 avgrating – jayaprakash k May 22 '17 at 6:11
8

Can you try this instead? Instead of having it in the WHERE clause, use it in HAVING clause.

SELECT u.id, AVG(rating_value) avg_rate
FROM dt_tutor_comments u
GROUP by u.id
HAVING AVG(rating_value) BETWEEN 1 AND 2
  • @jayaprakashk so approve his answer – Sedighe Rahimi May 22 '17 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.