join historical from n rows into one row