D
D
Deldahi2021-05-12 23:15:26
MySQL
Deldahi, 2021-05-12 23:15:26

How to make a sql query whose rating is higher than 3?

Greetings! Please help, how can I select all users whose rating sum (AVG) is more than 3 in total?
there are two tables:
1) ratings:
609c36ad4fc09694548352.png
2) users:
609c36bfb89d4815407273.png

how to get all users who have a rating, average - AVG function > 3?
Tried like this:

SELECT users.*, AVG(ratings.rating) as rate  FROM users INNER JOIN ratings WHERE rate > 3;

but I am getting an error. Googled a lot and couldn't find it. please tell me what is wrong and how to get users who have a rating of 'from'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kirillinyakin, 2021-05-12
@Deldahi

SELECT user_id FROM ratings group by user_id HAVING AVG(rating) > 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question