I think the following query will do the trick (untested):
select
types.table_name, types.id_column, attr.attribute_name,
attr.datatype
from
acs_attributes attr RIGHT OUTER JOIN
( select
ot2.object_type, ot2.table_name, ot2.id_column,
tree_level(ot2.tree_sortkey) as inherit_level
from
(select *
from acs_object_types
where object_type = :content_type) ot1,
acs_object_types ot2
where
ot2.object_type <> 'acs_object'
and
ot2.object_type <> 'content_revision'
and
ot2.tree_sortkey <= ot1.tree_sortkey
and
ot1.tree_sortkey like (ot2.tree_sortkey || '%')) types
ON attr.object_type = types.object_type
order by
types.inherit_level desc