b.rule_link_id as sub_rule_link_id, b.alarm_rule_type as sub_alarm_rule_type, b.alarm_rule_id as sub_alarm_rule_id, b.link_type as sub_link_type, b.link_device_id as sub_link_device_id, b.link_device_function_id as sub_link_device_function_id, b.link_device_function_identifier as sub_link_device_function_identifier, b.link_device_function_data as sub_link_device_function_data, hd.device_name as sub_link_device_name,hdmf.function_name as sub_link_device_mode_function_name
,d.device_mode_id as device_mode_id,d.device_mode_name as device_mode_name
from hw_alarm_rule a
left join hw_alarm_rule_link b on b.alarm_rule_id = a.alarm_rule_id and b.alarm_rule_type=1
left join hw_device hd on b.link_device_id = hd.device_id
left join hw_device_mode_function hdmf on b.link_device_function_id=hdmf.mode_function_id
left join hw_device c on a.rule_device_id = c.device_id
left join hw_device_mode d on d.device_mode_id = c.device_mode_id