DatabaseCommand with sort to make easier the calculate of sessions