SELECT AOID FROM "ADDROBJ" WHERE AOGUID=(SELECT AOGUID FROM "ADDROBJ" WHERE aoid='{{ aoid }}' OR AOGUID='{{ aoid }}') AND ACTSTATUS=True AND LIVESTATUS=True AND NEXTID IS NULL LIMIT 1;