Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding multiple attribute from GROUP BY function in a Query

I have a table like this

1   Mo1 4
2   Mo7 2
3   Mo3 2
4   Mo2 2
5   Mo9 2
6   Mo8 1
7   Mo6 1
8   Mo4 1

I have got above results using

select movie_id, count(*) cnt from review Group by movie_id order by cnt desc

however if i want to list all movie_id for which cnt>1 my query fails.

Is there any way to get the results as desired ?

like image 331
typedef1 Avatar asked Feb 22 '23 11:02

typedef1


1 Answers

select movie_id, count(*) cnt 
from review 
Group by movie_id 
Having count(*)>1
order by cnt desc
like image 98
vc 74 Avatar answered Feb 24 '23 06:02

vc 74