Finding Max and Stdev of the raw tags

Hi,

I have raw tags:

Requirements are:

a) user enters Hours.
b) Based on hours I get a value of “Max” in those hours and a Value of “St Dev” during the given time period.

Please see image:

Database is stored as following schema: