Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare @votes_count int
- select @votes_count = count(ID) from EventRating
- where
- IDEvent in (31,32,33,34,35,36,37,38,57,39,40,120,41,42,43,44,45,46,122,121,47,123,48,124,50,51,125,63,55,66,52,58,53,59,62,54,60,56,61,67)
- and Rating != 0
- select
- IDevent,
- e.[Name],
- (count(cast(er.ID as decimal)) / @votes_count) + (sum(cast(er.Rating as decimal)) / count(er.ID) / 5) as score
- from EventRating as er
- inner join Events as e on e.ID = er.IDEvent
- where
- er.IDEvent in (31,32,33,34,35,36,37,38,57,39,40,120,41,42,43,44,45,46,122,121,47,123,48,124,50,51,125,63,55,66,52,58,53,59,62,54,60,56,61,67)
- and er.Rating != 0
- group by er.IDEvent, e.Name
- order by score desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement