How to get from DB otsortirovyvaya viewed product brands?

Good time of day. There is a table with goods. Fields: id, name, the brand (name), number of views of product users

Need a certain part of the site to display a list of brands, sorted by the sum of the number of views of products under this brand. (Most popular brands)

Can't understand, how is the whole thing in the query designer of a model Yii2 to organize...
April 19th 20 at 12:34

Find more questions by tags Yii