http://stackoverflow.com/questions/14781069/grouping-data-by-time-interval
https://community.oracle.com/thread/1042863?tstart=0