I've got a table recording views of programs. Each program can have two different types (1=video, 2=audio)
My table to record the views:
TABLE views
view_id
user_agent
created_at
type
program_id (which related to table programs)
My current MySQL call:
SELECT COUNT(*) as views,
`mp`.`title`,
`mp`.`program_date` as date
FROM (`applications_media_views` as v)
JOIN `media_programs` as mp ON `v`.`program_id` = `mp`.`program_id`
GROUP BY `v`.`program_id`
ORDER BY `views` desc
The trouble is, this does not keep the types separated. I need to report on views by program_id, but I need to keep the types separate.
What am I missing?