I have a table like this
CREATE TABLE `air_video` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`date` DATE NOT NULL,
`time` TIME NOT NULL,
`asset_id` INT(10) UNSIGNED NOT NULL,
`duration` TIME NOT NULL,
`name` VARCHAR(100) NOT NULL,
PRIMARY KEY (`id`),
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
There are entries with the same asset_id, duration and name, but different date and time. These are same videos that were aired multiple times during some time.
I need to calculate total duration for distinct videos grouped by each month.
Please give some ideas?
So you need the sum of the duration of each distinct video per month:
So you’ll need thesumof durations,groupedper video per month…Smart use of grouping as suggested by RobertHarvey in the comments (thanks).
time_to_secis used to convert a time value to seconds so it can be summed.