I have this SQL statement:
select a.title, a.video_id, b.id
from
tzrat_community_videos a
inner join
tzrat_video_views b on a.video_id = b.videoid
where
b.cdate >= '2014-01-01 00:00:00' and
b.cdate <= '2014-06-26 23:59:59' and
a.video_id = 'dCflt1d2xPw' and
a.published = 1 and b.duration != 0 and
(
(a.percent is not null and (100*b.seconds)/b.duration >= a.percent ) or
((100*b.seconds)/b.duration >= 80)
)
group by b.videoid, a.title, a.video_id, b.id
Result: https://i.sstatic.net/I649X.png
But I want to have only the title, video_id and the number of times it appears (I want the number of views this video have) So , I make this statement:
select a.title, a.video_id, count(b.id) as views
from
tzrat_community_videos a
inner join
tzrat_video_views b on a.video_id = b.videoid
where
b.cdate >= '2014-01-01 00:00:00' and
b.cdate <= '2014-06-26 23:59:59' and
a.video_id = 'dCflt1d2xPw' and
a.published = 1 and
b.duration != 0 and
(
(a.percent is not null and (100*b.seconds)/b.duration >= a.percent ) or
((100*b.seconds)/b.duration >= 80)
)
group by b.videoid, a.title, a.video_id
But this returns me this : https://i.sstatic.net/fD1zY.png
So... what am I doing wrong? is the same statement, just b.id -> count(b.id) as views