php - MySQL Select top two people with most submitted videos, where type=1 -
i have table of videos submitted people:
+----+-----------+------+---------+ | id | by_person | type | title | +----+-----------+------+---------+ | 1 | 3 | 1 | title1 | | 2 | 4 | 1 | title2 | | 3 | 3 | 1 | title3 | | 4 | 4 | 2 | title4 | | 5 | 3 | 1 | title5 | | 6 | 6 | 2 | title6 | | 7 | 6 | 2 | title7 | | 8 | 4 | 2 | title8 | | 9 | 3 | 1 | title9 | | 10 | 4 | 1 | title10 | | 11 | 4 | 1 | title11 | | 12 | 3 | 1 | title12 | +----+-----------+------+---------+
how select
top 2 people have submitted videos type=1 presentation this?
1. person(3) - 5 videos 2. person(4) - 3 videos
i think work:
select by_person, count(*) total videos type = 1 group by_person order total desc limit 2
Comments
Post a Comment