SELECT ID_Asset, 'H2' as 'ZE', date_format(min(Zeit),'%Y-%m-%d %H:%i:00') as Zeit, substring_index(group_concat(`Open` order by Zeit asc),',',1) as `Open`, max(High) as High, min(Low) as Low, substring_index(group_concat(`Close` order by Zeit desc),',',1) as `Close` FROM FXM.APP_Analyse_CS group by unix_timestamp(Zeit) DIV 7200 union all SELECT ID_Asset, 'H3' as 'ZE', date_format(min(Zeit),'%Y-%m-%d %H:%i:00') as Zeit, substring_index(group_concat(`Open` order by Zeit asc),',',1) as `Open`, max(High) as High, min(Low) as Low, substring_index(group_concat(`Close` order by Zeit desc),',',1) as `Close` FROM FXM.APP_Analyse_CS group by unix_timestamp(Zeit) DIV 10800 union all SELECT ID_Asset, 'H4' as 'ZE', date_format(min(Zeit),'%Y-%m-%d %H:%i:00') as Zeit, substring_index(group_concat(`Open` order by Zeit asc),',',1) as `Open`, max(High) as High, min(Low) as Low, substring_index(group_concat(`Close` order by Zeit desc),',',1) as `Close` FROM FXM.APP_Analyse_CS group by unix_timestamp(Zeit) DIV 14400